Merge changes I28fe3a63,I1466fb45

* changes:
  Update in DPM delegation documentation.
  Fix delegation broadcast to send an ArrayList<String> extra.
This commit is contained in:
Edman Anjos
2017-01-30 17:32:36 +00:00
committed by Android (Google) Code Review
2 changed files with 13 additions and 7 deletions

View File

@@ -1177,9 +1177,9 @@ public class DevicePolicyManager {
= "android.app.action.SHOW_DEVICE_MONITORING_DIALOG";
/**
* Broadcast Action: Sent after application delegation scopes are changed. The new list of
* delegation scopes will be sent in an extra identified by the {@link #EXTRA_DELEGATION_SCOPES}
* key.
* Broadcast Action: Sent after application delegation scopes are changed. The new delegation
* scopes will be sent in an {@code ArrayList<String>} extra identified by the
* {@link #EXTRA_DELEGATION_SCOPES} key.
*
* <p class=”note”> Note: This is a protected intent that can only be sent by the system.</p>
*/
@@ -1188,7 +1188,7 @@ public class DevicePolicyManager {
"android.app.action.APPLICATION_DELEGATION_SCOPES_CHANGED";
/**
* A list of Strings corresponding to the delegation scopes given to an app in the
* An {@code ArrayList<String>} corresponding to the delegation scopes given to an app in the
* {@link #ACTION_APPLICATION_DELEGATION_SCOPES_CHANGED} broadcast.
*/
public static final String EXTRA_DELEGATION_SCOPES = "android.app.extra.DELEGATION_SCOPES";
@@ -3669,6 +3669,11 @@ public class DevicePolicyManager {
* Granted APIs are determined by {@code scopes}, which is a list of the {@code DELEGATION_*}
* constants.
* <p>
* A broadcast with the {@link #ACTION_APPLICATION_DELEGATION_SCOPES_CHANGED} action will be
* sent to the {@code delegatePackage} with its new scopes in an {@code ArrayList<String>} extra
* under the {@link #EXTRA_DELEGATION_SCOPES} key. The broadcast is sent with the
* {@link Intent#FLAG_RECEIVER_REGISTERED_ONLY} flag.
* <p>
* Delegated scopes are a per-user state. The delegated access is persistent until it is later
* cleared by calling this method with an empty {@code scopes} list or uninstalling the
* {@code delegatePackage}.
@@ -3704,7 +3709,7 @@ public class DevicePolicyManager {
* @throws SecurityException if {@code admin} is not a device or a profile owner.
*/
@NonNull
public List<String> getDelegatedScopes(@NonNull ComponentName admin,
public List<String> getDelegatedScopes(@Nullable ComponentName admin,
@NonNull String delegatedPackage) {
throwIfParentInstance("getDelegatedScopes");
if (mService != null) {

View File

@@ -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));