summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2020-04-15 11:13:19 -0700
committerRoshan Pius <rpius@google.com>2020-04-15 11:15:12 -0700
commit918655a0bdeef18afe5749852913840b00c17f6d (patch)
treecff0caf82bcb67ba72d5f9fafdf03b66ef204b5f /service
parentf85ddd3f8f0f2cba9bf1194983424e98088c5e11 (diff)
FrameworkFacade: Check if DPM service is null
DPM service may not be available on all devices. Handle the non-existence of DPM service gracefully. Bug: 154128878 Test: Compiles Change-Id: I378bce1cc94611610ea1aec8a9e82c3bd50d8921
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/FrameworkFacade.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/FrameworkFacade.java b/service/java/com/android/server/wifi/FrameworkFacade.java
index 0262cc32b..a0b510f0f 100644
--- a/service/java/com/android/server/wifi/FrameworkFacade.java
+++ b/service/java/com/android/server/wifi/FrameworkFacade.java
@@ -17,6 +17,7 @@
package com.android.server.wifi;
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE;
+import static android.content.pm.PackageManager.FEATURE_DEVICE_ADMIN;
import android.app.ActivityManager;
import android.app.AlertDialog;
@@ -33,6 +34,7 @@ import android.net.ip.IpClientCallbacks;
import android.net.ip.IpClientUtil;
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
+import android.util.Log;
import android.widget.Toast;
import com.android.server.wifi.util.WifiAsyncChannel;
@@ -122,8 +124,14 @@ public class FrameworkFacade {
* Returns whether the device is in NIAP mode or not.
*/
public boolean isNiapModeOn(Context context) {
- return context.getSystemService(DevicePolicyManager.class)
- .isCommonCriteriaModeEnabled(null);
+ DevicePolicyManager devicePolicyManager =
+ context.getSystemService(DevicePolicyManager.class);
+ if (devicePolicyManager == null
+ && context.getPackageManager().hasSystemFeature(FEATURE_DEVICE_ADMIN)) {
+ Log.e(TAG, "Error retrieving DPM service");
+ }
+ if (devicePolicyManager == null) return false;
+ return devicePolicyManager.isCommonCriteriaModeEnabled(null);
}
/**