From 94666c0570aff5f545592482ffdcae55c5b763cf Mon Sep 17 00:00:00 2001 From: Victor Chang Date: Tue, 24 Jan 2017 15:42:33 +0000 Subject: 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 --- .../com/android/server/devicepolicy/DevicePolicyManagerService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index f3b013122890..a8f09294dd53 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -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); -- cgit v1.2.3-59-g8ed1b