Merge "Backport sendBroadcastAsUserMultiplePermissions to oc-dev" into oc-dev am: d1bcf628bd
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12724292 Change-Id: Ic35e179d67e2804f71d53489101d1c6efc05f156
This commit is contained in:
@@ -1011,6 +1011,22 @@ class ContextImpl extends Context {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user,
|
||||
String[] receiverPermissions) {
|
||||
warnIfCallingFromSystemProcess();
|
||||
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
|
||||
try {
|
||||
intent.prepareToLeaveProcess(this);
|
||||
ActivityManager.getService().broadcastIntent(
|
||||
mMainThread.getApplicationThread(), intent, resolvedType, null,
|
||||
Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE,
|
||||
null, false, false, user.getIdentifier());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBroadcast(Intent intent, String receiverPermission, Bundle options) {
|
||||
warnIfCallingFromSystemProcess();
|
||||
|
||||
@@ -1950,6 +1950,33 @@ public abstract class Context {
|
||||
public abstract void sendBroadcastMultiplePermissions(Intent intent,
|
||||
String[] receiverPermissions);
|
||||
|
||||
/**
|
||||
* Broadcast the given intent to all interested BroadcastReceivers, allowing
|
||||
* an array of required permissions to be enforced. This call is asynchronous; it returns
|
||||
* immediately, and you will continue executing while the receivers are run. No results are
|
||||
* propagated from receivers and receivers can not abort the broadcast. If you want to allow
|
||||
* receivers to propagate results or abort the broadcast, you must send an ordered broadcast
|
||||
* using {@link #sendOrderedBroadcast(Intent, String)}.
|
||||
*
|
||||
* <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
|
||||
*
|
||||
* @param intent The Intent to broadcast; all receivers matching this
|
||||
* Intent will receive the broadcast.
|
||||
* @param user The user to send the broadcast to.
|
||||
* @param receiverPermissions Array of names of permissions that a receiver must hold
|
||||
* in order to receive your broadcast.
|
||||
* If null or empty, no permissions are required.
|
||||
*
|
||||
* @see android.content.BroadcastReceiver
|
||||
* @see #registerReceiver
|
||||
* @see #sendBroadcast(Intent)
|
||||
* @see #sendOrderedBroadcast(Intent, String)
|
||||
* @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
|
||||
* @hide
|
||||
*/
|
||||
public abstract void sendBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user,
|
||||
String[] receiverPermissions);
|
||||
|
||||
/**
|
||||
* Broadcast the given intent to all interested BroadcastReceivers, allowing
|
||||
* an optional required permission to be enforced. This
|
||||
|
||||
@@ -447,6 +447,13 @@ public class ContextWrapper extends Context {
|
||||
mBase.sendBroadcastMultiplePermissions(intent, receiverPermissions);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public void sendBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user,
|
||||
String[] receiverPermissions) {
|
||||
mBase.sendBroadcastAsUserMultiplePermissions(intent, user, receiverPermissions);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
@Override
|
||||
|
||||
@@ -234,6 +234,12 @@ public class DpmMockContext extends MockContext {
|
||||
spiedContext.sendBroadcastMultiplePermissions(intent, receiverPermissions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user,
|
||||
String[] receiverPermissions) {
|
||||
spiedContext.sendBroadcastAsUserMultiplePermissions(intent, user, receiverPermissions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBroadcast(Intent intent, String receiverPermission, Bundle options) {
|
||||
spiedContext.sendBroadcast(intent, receiverPermission, options);
|
||||
|
||||
@@ -358,6 +358,13 @@ public class MockContext extends Context {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public void sendBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user,
|
||||
String[] receiverPermissions) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
@Override
|
||||
|
||||
@@ -174,6 +174,12 @@ public class BroadcastInterceptingContext extends ContextWrapper {
|
||||
sendBroadcast(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBroadcastAsUserMultiplePermissions(Intent intent, UserHandle user,
|
||||
String[] receiverPermissions) {
|
||||
sendBroadcast(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBroadcastAsUser(Intent intent, UserHandle user) {
|
||||
sendBroadcast(intent);
|
||||
|
||||
Reference in New Issue
Block a user