Fixing a NullPointerException in isProfileOwnerApp.
Fixing a NullPointerException in isProfileOwnerApp of DevicePolicyManager
if there is no profile owner.
BUG: 16673376
Change-Id: I912fcd38343d3c1893313e6335802d26014a2e9d
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 9310bf8..8be52a2 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -2296,9 +2296,10 @@
public boolean isProfileOwnerApp(String packageName) {
if (mService != null) {
try {
- String profileOwnerPackage = mService.getProfileOwner(
- Process.myUserHandle().getIdentifier()).getPackageName();
- return profileOwnerPackage != null && profileOwnerPackage.equals(packageName);
+ ComponentName profileOwner = mService.getProfileOwner(
+ Process.myUserHandle().getIdentifier());
+ return profileOwner != null
+ && profileOwner.getPackageName().equals(packageName);
} catch (RemoteException re) {
Log.w(TAG, "Failed to check profile owner");
}