= "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
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);
}
);
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.
}