diff options
3 files changed, 9 insertions, 1 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index 851cf50a7585..cfc451996fe0 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -878,7 +878,7 @@ public class DevicePolicyManager { = "android.app.action.DEVICE_POLICY_MANAGER_STATE_CHANGED"; /** - * Broadcast action: sent when the device owner is set or changed. + * Broadcast action: sent when the device owner is set, changed or cleared. * * This broadcast is sent only to the primary user. * @see #ACTION_PROVISION_MANAGED_DEVICE diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 9c4b94eab310..f5fcc6419e0d 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -5883,6 +5883,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { try { clearDeviceOwnerLocked(admin, deviceOwnerUserId); removeActiveAdminLocked(deviceOwnerComponent, deviceOwnerUserId); + Intent intent = new Intent(DevicePolicyManager.ACTION_DEVICE_OWNER_CHANGED); + mContext.sendBroadcastAsUser(intent, UserHandle.of(deviceOwnerUserId)); } finally { mInjector.binderRestoreCallingIdentity(ident); } diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java index 0fd128641180..01b2c3b3c0bf 100644 --- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java +++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java @@ -839,6 +839,12 @@ public class DevicePolicyManagerTest extends DpmTestBase { ); assertFalse(dpm.isAdminActiveAsUser(admin1, UserHandle.USER_SYSTEM)); + + // ACTION_DEVICE_OWNER_CHANGED should be sent twice, once for setting the device owner + // and once for clearing it. + verify(mContext.spiedContext, times(2)).sendBroadcastAsUser( + MockUtils.checkIntentAction(DevicePolicyManager.ACTION_DEVICE_OWNER_CHANGED), + MockUtils.checkUserHandle(UserHandle.USER_SYSTEM)); // TODO Check other calls. } |