Check DeviceOwner exists before using packageName
Creating a profile owner when there is no device owner present also creates a new DeviceOwner object without packageName set -- this situation can lead to a null pointer access when calling isDeviceOwner. Change-Id: I31eab498d78cadc67a1aedd205b458dee2d27705
This commit is contained in:
@@ -1315,9 +1315,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
||||
}
|
||||
if (admin.getUid() != Binder.getCallingUid()) {
|
||||
// If trying to remove device owner, refuse when the caller is not the owner.
|
||||
if (mDeviceOwner != null
|
||||
&& adminReceiver.getPackageName().equals(
|
||||
mDeviceOwner.getDeviceOwnerPackageName())) {
|
||||
if (isDeviceOwner(adminReceiver.getPackageName())) {
|
||||
return;
|
||||
}
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
@@ -2793,6 +2791,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
||||
}
|
||||
synchronized (this) {
|
||||
return mDeviceOwner != null
|
||||
&& mDeviceOwner.hasDeviceOwner()
|
||||
&& mDeviceOwner.getDeviceOwnerPackageName().equals(packageName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user