From a5ec280b4a684a5298279a0c303b85e47cd8763e Mon Sep 17 00:00:00 2001 From: Edman Anjos Date: Thu, 26 Jan 2017 22:16:13 +0100 Subject: [PATCH] Fix delegation broadcast to send an ArrayList extra. Change DPMS to call Intent#putStringArrayListExtra to ensure the extra is sent as an array list of strings. Bug: 33099995 Test: cts-tradefed run cts-dev --module CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.MixedDeviceOwnerTest#testDelegation Change-Id: I1466fb457e34adbfb7704320c021210c1569f55f --- .../server/devicepolicy/DevicePolicyManagerService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index d91b473096d7e..5b5e904abd1f9 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -4887,7 +4887,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { // Set the new delegate in user policies. final DevicePolicyData policy = getUserData(userId); if (!scopes.isEmpty()) { - policy.mDelegationMap.put(delegatePackage, new ArrayList<>(scopes)); + policy.mDelegationMap.put(delegatePackage, scopes); } else { // Remove any delegation info if the given scopes list is empty. policy.mDelegationMap.remove(delegatePackage); @@ -4896,12 +4896,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { // Notify delegate package of updates. final Intent intent = new Intent( DevicePolicyManager.ACTION_APPLICATION_DELEGATION_SCOPES_CHANGED); - // Only call receivers registered in the manifest (don’t wake app if not running). + // Only call receivers registered with Context#registerReceiver (don’t wake delegate). intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); // Limit components this intent resolves to to the delegate package. intent.setPackage(delegatePackage); // Include the list of delegated scopes as an extra. - intent.putExtra(DevicePolicyManager.EXTRA_DELEGATION_SCOPES, scopes.toArray()); + intent.putStringArrayListExtra(DevicePolicyManager.EXTRA_DELEGATION_SCOPES, + (ArrayList) scopes); // Send the broadcast. mContext.sendBroadcastAsUser(intent, UserHandle.of(userId));