Fix delegation broadcast to send an ArrayList<String> 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
This commit is contained in:
Edman Anjos
2017-01-26 22:16:13 +01:00
parent 628c0f1879
commit a5ec280b4a

View File

@@ -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<String>) scopes);
// Send the broadcast.
mContext.sendBroadcastAsUser(intent, UserHandle.of(userId));