Send DEVICE_OWNER_CHANGED to manifest receivers in background

- DEVICE_OWNER_CHANGED is an event that could happen maximum of 2 times
after device factory reset. The event rarely
happens, and it shouldn't affect any system health

Fix: 34446573
Test: adb shell am instrument -w -e class
com.android.server.devicepolicy.DevicePolicyManagerTest
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner

Change-Id: Ic1af2016f590e1200bb3e56f63caa0e0b12f71f8
This commit is contained in:
Victor Chang
2017-01-24 15:42:33 +00:00
parent 1a29288420
commit 94666c0570

View File

@@ -6110,7 +6110,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
try {
// TODO Send to system too?
mContext.sendBroadcastAsUser(
new Intent(DevicePolicyManager.ACTION_DEVICE_OWNER_CHANGED),
new Intent(DevicePolicyManager.ACTION_DEVICE_OWNER_CHANGED)
.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND),
UserHandle.of(userId));
} finally {
mInjector.binderRestoreCallingIdentity(ident);
@@ -6253,6 +6254,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
clearDeviceOwnerLocked(admin, deviceOwnerUserId);
removeActiveAdminLocked(deviceOwnerComponent, deviceOwnerUserId);
Intent intent = new Intent(DevicePolicyManager.ACTION_DEVICE_OWNER_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
mContext.sendBroadcastAsUser(intent, UserHandle.of(deviceOwnerUserId));
} finally {
mInjector.binderRestoreCallingIdentity(ident);