Loading cmds/am/src/com/android/commands/am/Am.java +3 −1 Original line number Original line Diff line number Diff line Loading @@ -1003,8 +1003,10 @@ public class Am extends BaseCommand { private void sendBroadcast() throws Exception { private void sendBroadcast() throws Exception { Intent intent = makeIntent(UserHandle.USER_CURRENT); Intent intent = makeIntent(UserHandle.USER_CURRENT); IntentReceiver receiver = new IntentReceiver(); IntentReceiver receiver = new IntentReceiver(); String[] requiredPermissions = mReceiverPermission == null ? null : new String[] {mReceiverPermission}; System.out.println("Broadcasting: " + intent); System.out.println("Broadcasting: " + intent); mAm.broadcastIntent(null, intent, null, receiver, 0, null, null, mReceiverPermission, mAm.broadcastIntent(null, intent, null, receiver, 0, null, null, requiredPermissions, android.app.AppOpsManager.OP_NONE, null, true, false, mUserId); android.app.AppOpsManager.OP_NONE, null, true, false, mUserId); receiver.waitForFinish(); receiver.waitForFinish(); } } Loading core/java/android/app/ActivityManagerNative.java +4 −4 Original line number Original line Diff line number Diff line Loading @@ -456,14 +456,14 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM int resultCode = data.readInt(); int resultCode = data.readInt(); String resultData = data.readString(); String resultData = data.readString(); Bundle resultExtras = data.readBundle(); Bundle resultExtras = data.readBundle(); String perm = data.readString(); String[] perms = data.readStringArray(); int appOp = data.readInt(); int appOp = data.readInt(); Bundle options = data.readBundle(); Bundle options = data.readBundle(); boolean serialized = data.readInt() != 0; boolean serialized = data.readInt() != 0; boolean sticky = data.readInt() != 0; boolean sticky = data.readInt() != 0; int userId = data.readInt(); int userId = data.readInt(); int res = broadcastIntent(app, intent, resolvedType, resultTo, int res = broadcastIntent(app, intent, resolvedType, resultTo, resultCode, resultData, resultExtras, perm, appOp, resultCode, resultData, resultExtras, perms, appOp, options, serialized, sticky, userId); options, serialized, sticky, userId); reply.writeNoException(); reply.writeNoException(); reply.writeInt(res); reply.writeInt(res); Loading Loading @@ -3007,7 +3007,7 @@ class ActivityManagerProxy implements IActivityManager public int broadcastIntent(IApplicationThread caller, public int broadcastIntent(IApplicationThread caller, Intent intent, String resolvedType, IIntentReceiver resultTo, Intent intent, String resolvedType, IIntentReceiver resultTo, int resultCode, String resultData, Bundle map, int resultCode, String resultData, Bundle map, String requiredPermission, int appOp, Bundle options, boolean serialized, String[] requiredPermissions, int appOp, Bundle options, boolean serialized, boolean sticky, int userId) throws RemoteException boolean sticky, int userId) throws RemoteException { { Parcel data = Parcel.obtain(); Parcel data = Parcel.obtain(); Loading @@ -3020,7 +3020,7 @@ class ActivityManagerProxy implements IActivityManager data.writeInt(resultCode); data.writeInt(resultCode); data.writeString(resultData); data.writeString(resultData); data.writeBundle(map); data.writeBundle(map); data.writeString(requiredPermission); data.writeStringArray(requiredPermissions); data.writeInt(appOp); data.writeInt(appOp); data.writeBundle(options); data.writeBundle(options); data.writeInt(serialized ? 1 : 0); data.writeInt(serialized ? 1 : 0); Loading core/java/android/app/ContextImpl.java +39 −10 Original line number Original line Diff line number Diff line Loading @@ -180,7 +180,7 @@ class ContextImpl extends Context { @GuardedBy("mSync") @GuardedBy("mSync") private File[] mExternalMediaDirs; private File[] mExternalMediaDirs; private static final String[] EMPTY_FILE_LIST = {}; private static final String[] EMPTY_STRING_ARRAY = {}; // The system service cache for the system services that are cached per-ContextImpl. // The system service cache for the system services that are cached per-ContextImpl. final Object[] mServiceCache = SystemServiceRegistry.createServiceCache(); final Object[] mServiceCache = SystemServiceRegistry.createServiceCache(); Loading Loading @@ -552,7 +552,7 @@ class ContextImpl extends Context { @Override @Override public String[] fileList() { public String[] fileList() { final String[] list = getFilesDir().list(); final String[] list = getFilesDir().list(); return (list != null) ? list : EMPTY_FILE_LIST; return (list != null) ? list : EMPTY_STRING_ARRAY; } } @Override @Override Loading Loading @@ -591,7 +591,7 @@ class ContextImpl extends Context { @Override @Override public String[] databaseList() { public String[] databaseList() { final String[] list = getDatabasesDir().list(); final String[] list = getDatabasesDir().list(); return (list != null) ? list : EMPTY_FILE_LIST; return (list != null) ? list : EMPTY_STRING_ARRAY; } } Loading Loading @@ -777,11 +777,28 @@ class ContextImpl extends Context { public void sendBroadcast(Intent intent, String receiverPermission) { public void sendBroadcast(Intent intent, String receiverPermission) { warnIfCallingFromSystemProcess(); warnIfCallingFromSystemProcess(); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String[] receiverPermissions = receiverPermission == null ? null : new String[] {receiverPermission}; try { try { intent.prepareToLeaveProcess(); intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, null, mMainThread.getApplicationThread(), intent, resolvedType, null, Activity.RESULT_OK, null, null, receiverPermission, AppOpsManager.OP_NONE, Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, null, false, false, getUserId()); } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); } } @Override public void sendBroadcastMultiplePermissions(Intent intent, String[] receiverPermissions) { warnIfCallingFromSystemProcess(); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); try { intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, null, Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, null, false, false, getUserId()); null, false, false, getUserId()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); throw new RuntimeException("Failure from system", e); Loading @@ -792,11 +809,13 @@ class ContextImpl extends Context { public void sendBroadcast(Intent intent, String receiverPermission, Bundle options) { public void sendBroadcast(Intent intent, String receiverPermission, Bundle options) { warnIfCallingFromSystemProcess(); warnIfCallingFromSystemProcess(); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String[] receiverPermissions = receiverPermission == null ? null : new String[] {receiverPermission}; try { try { intent.prepareToLeaveProcess(); intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, null, mMainThread.getApplicationThread(), intent, resolvedType, null, Activity.RESULT_OK, null, null, receiverPermission, AppOpsManager.OP_NONE, Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, options, false, false, getUserId()); options, false, false, getUserId()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); throw new RuntimeException("Failure from system", e); Loading @@ -807,11 +826,13 @@ class ContextImpl extends Context { public void sendBroadcast(Intent intent, String receiverPermission, int appOp) { public void sendBroadcast(Intent intent, String receiverPermission, int appOp) { warnIfCallingFromSystemProcess(); warnIfCallingFromSystemProcess(); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String[] receiverPermissions = receiverPermission == null ? null : new String[] {receiverPermission}; try { try { intent.prepareToLeaveProcess(); intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, null, mMainThread.getApplicationThread(), intent, resolvedType, null, Activity.RESULT_OK, null, null, receiverPermission, appOp, null, false, false, Activity.RESULT_OK, null, null, receiverPermissions, appOp, null, false, false, getUserId()); getUserId()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); throw new RuntimeException("Failure from system", e); Loading @@ -822,11 +843,13 @@ class ContextImpl extends Context { public void sendOrderedBroadcast(Intent intent, String receiverPermission) { public void sendOrderedBroadcast(Intent intent, String receiverPermission) { warnIfCallingFromSystemProcess(); warnIfCallingFromSystemProcess(); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String[] receiverPermissions = receiverPermission == null ? null : new String[] {receiverPermission}; try { try { intent.prepareToLeaveProcess(); intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, null, mMainThread.getApplicationThread(), intent, resolvedType, null, Activity.RESULT_OK, null, null, receiverPermission, AppOpsManager.OP_NONE, Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, null, true, false, getUserId()); null, true, false, getUserId()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); throw new RuntimeException("Failure from system", e); Loading Loading @@ -883,11 +906,13 @@ class ContextImpl extends Context { } } } } String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String[] receiverPermissions = receiverPermission == null ? null : new String[] {receiverPermission}; try { try { intent.prepareToLeaveProcess(); intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, rd, mMainThread.getApplicationThread(), intent, resolvedType, rd, initialCode, initialData, initialExtras, receiverPermission, appOp, initialCode, initialData, initialExtras, receiverPermissions, appOp, options, true, false, getUserId()); options, true, false, getUserId()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); throw new RuntimeException("Failure from system", e); Loading Loading @@ -917,11 +942,13 @@ class ContextImpl extends Context { public void sendBroadcastAsUser(Intent intent, UserHandle user, public void sendBroadcastAsUser(Intent intent, UserHandle user, String receiverPermission, int appOp) { String receiverPermission, int appOp) { String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String[] receiverPermissions = receiverPermission == null ? null : new String[] {receiverPermission}; try { try { intent.prepareToLeaveProcess(); intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, null, mMainThread.getApplicationThread(), intent, resolvedType, null, Activity.RESULT_OK, null, null, receiverPermission, appOp, null, false, false, Activity.RESULT_OK, null, null, receiverPermissions, appOp, null, false, false, user.getIdentifier()); user.getIdentifier()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); throw new RuntimeException("Failure from system", e); Loading Loading @@ -959,11 +986,13 @@ class ContextImpl extends Context { } } } } String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String[] receiverPermissions = receiverPermission == null ? null : new String[] {receiverPermission}; try { try { intent.prepareToLeaveProcess(); intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, rd, mMainThread.getApplicationThread(), intent, resolvedType, rd, initialCode, initialData, initialExtras, receiverPermission, initialCode, initialData, initialExtras, receiverPermissions, appOp, null, true, false, user.getIdentifier()); appOp, null, true, false, user.getIdentifier()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); throw new RuntimeException("Failure from system", e); Loading core/java/android/app/IActivityManager.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -106,7 +106,7 @@ public interface IActivityManager extends IInterface { public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException; public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException; public int broadcastIntent(IApplicationThread caller, Intent intent, public int broadcastIntent(IApplicationThread caller, Intent intent, String resolvedType, IIntentReceiver resultTo, int resultCode, String resolvedType, IIntentReceiver resultTo, int resultCode, String resultData, Bundle map, String requiredPermission, String resultData, Bundle map, String[] requiredPermissions, int appOp, Bundle options, boolean serialized, boolean sticky, int userId) throws RemoteException; int appOp, Bundle options, boolean serialized, boolean sticky, int userId) throws RemoteException; public void unbroadcastIntent(IApplicationThread caller, Intent intent, int userId) throws RemoteException; public void unbroadcastIntent(IApplicationThread caller, Intent intent, int userId) throws RemoteException; public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, Loading core/java/android/content/Context.java +27 −0 Original line number Original line Diff line number Diff line Loading @@ -1516,6 +1516,33 @@ public abstract class Context { public abstract void sendBroadcast(Intent intent, public abstract void sendBroadcast(Intent intent, @Nullable String receiverPermission); @Nullable String receiverPermission); /** * 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 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 sendBroadcastMultiplePermissions(Intent intent, String[] receiverPermissions); /** /** * Broadcast the given intent to all interested BroadcastReceivers, allowing * Broadcast the given intent to all interested BroadcastReceivers, allowing * an optional required permission to be enforced. This * an optional required permission to be enforced. This Loading Loading
cmds/am/src/com/android/commands/am/Am.java +3 −1 Original line number Original line Diff line number Diff line Loading @@ -1003,8 +1003,10 @@ public class Am extends BaseCommand { private void sendBroadcast() throws Exception { private void sendBroadcast() throws Exception { Intent intent = makeIntent(UserHandle.USER_CURRENT); Intent intent = makeIntent(UserHandle.USER_CURRENT); IntentReceiver receiver = new IntentReceiver(); IntentReceiver receiver = new IntentReceiver(); String[] requiredPermissions = mReceiverPermission == null ? null : new String[] {mReceiverPermission}; System.out.println("Broadcasting: " + intent); System.out.println("Broadcasting: " + intent); mAm.broadcastIntent(null, intent, null, receiver, 0, null, null, mReceiverPermission, mAm.broadcastIntent(null, intent, null, receiver, 0, null, null, requiredPermissions, android.app.AppOpsManager.OP_NONE, null, true, false, mUserId); android.app.AppOpsManager.OP_NONE, null, true, false, mUserId); receiver.waitForFinish(); receiver.waitForFinish(); } } Loading
core/java/android/app/ActivityManagerNative.java +4 −4 Original line number Original line Diff line number Diff line Loading @@ -456,14 +456,14 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM int resultCode = data.readInt(); int resultCode = data.readInt(); String resultData = data.readString(); String resultData = data.readString(); Bundle resultExtras = data.readBundle(); Bundle resultExtras = data.readBundle(); String perm = data.readString(); String[] perms = data.readStringArray(); int appOp = data.readInt(); int appOp = data.readInt(); Bundle options = data.readBundle(); Bundle options = data.readBundle(); boolean serialized = data.readInt() != 0; boolean serialized = data.readInt() != 0; boolean sticky = data.readInt() != 0; boolean sticky = data.readInt() != 0; int userId = data.readInt(); int userId = data.readInt(); int res = broadcastIntent(app, intent, resolvedType, resultTo, int res = broadcastIntent(app, intent, resolvedType, resultTo, resultCode, resultData, resultExtras, perm, appOp, resultCode, resultData, resultExtras, perms, appOp, options, serialized, sticky, userId); options, serialized, sticky, userId); reply.writeNoException(); reply.writeNoException(); reply.writeInt(res); reply.writeInt(res); Loading Loading @@ -3007,7 +3007,7 @@ class ActivityManagerProxy implements IActivityManager public int broadcastIntent(IApplicationThread caller, public int broadcastIntent(IApplicationThread caller, Intent intent, String resolvedType, IIntentReceiver resultTo, Intent intent, String resolvedType, IIntentReceiver resultTo, int resultCode, String resultData, Bundle map, int resultCode, String resultData, Bundle map, String requiredPermission, int appOp, Bundle options, boolean serialized, String[] requiredPermissions, int appOp, Bundle options, boolean serialized, boolean sticky, int userId) throws RemoteException boolean sticky, int userId) throws RemoteException { { Parcel data = Parcel.obtain(); Parcel data = Parcel.obtain(); Loading @@ -3020,7 +3020,7 @@ class ActivityManagerProxy implements IActivityManager data.writeInt(resultCode); data.writeInt(resultCode); data.writeString(resultData); data.writeString(resultData); data.writeBundle(map); data.writeBundle(map); data.writeString(requiredPermission); data.writeStringArray(requiredPermissions); data.writeInt(appOp); data.writeInt(appOp); data.writeBundle(options); data.writeBundle(options); data.writeInt(serialized ? 1 : 0); data.writeInt(serialized ? 1 : 0); Loading
core/java/android/app/ContextImpl.java +39 −10 Original line number Original line Diff line number Diff line Loading @@ -180,7 +180,7 @@ class ContextImpl extends Context { @GuardedBy("mSync") @GuardedBy("mSync") private File[] mExternalMediaDirs; private File[] mExternalMediaDirs; private static final String[] EMPTY_FILE_LIST = {}; private static final String[] EMPTY_STRING_ARRAY = {}; // The system service cache for the system services that are cached per-ContextImpl. // The system service cache for the system services that are cached per-ContextImpl. final Object[] mServiceCache = SystemServiceRegistry.createServiceCache(); final Object[] mServiceCache = SystemServiceRegistry.createServiceCache(); Loading Loading @@ -552,7 +552,7 @@ class ContextImpl extends Context { @Override @Override public String[] fileList() { public String[] fileList() { final String[] list = getFilesDir().list(); final String[] list = getFilesDir().list(); return (list != null) ? list : EMPTY_FILE_LIST; return (list != null) ? list : EMPTY_STRING_ARRAY; } } @Override @Override Loading Loading @@ -591,7 +591,7 @@ class ContextImpl extends Context { @Override @Override public String[] databaseList() { public String[] databaseList() { final String[] list = getDatabasesDir().list(); final String[] list = getDatabasesDir().list(); return (list != null) ? list : EMPTY_FILE_LIST; return (list != null) ? list : EMPTY_STRING_ARRAY; } } Loading Loading @@ -777,11 +777,28 @@ class ContextImpl extends Context { public void sendBroadcast(Intent intent, String receiverPermission) { public void sendBroadcast(Intent intent, String receiverPermission) { warnIfCallingFromSystemProcess(); warnIfCallingFromSystemProcess(); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String[] receiverPermissions = receiverPermission == null ? null : new String[] {receiverPermission}; try { try { intent.prepareToLeaveProcess(); intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, null, mMainThread.getApplicationThread(), intent, resolvedType, null, Activity.RESULT_OK, null, null, receiverPermission, AppOpsManager.OP_NONE, Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, null, false, false, getUserId()); } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); } } @Override public void sendBroadcastMultiplePermissions(Intent intent, String[] receiverPermissions) { warnIfCallingFromSystemProcess(); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); try { intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, null, Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, null, false, false, getUserId()); null, false, false, getUserId()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); throw new RuntimeException("Failure from system", e); Loading @@ -792,11 +809,13 @@ class ContextImpl extends Context { public void sendBroadcast(Intent intent, String receiverPermission, Bundle options) { public void sendBroadcast(Intent intent, String receiverPermission, Bundle options) { warnIfCallingFromSystemProcess(); warnIfCallingFromSystemProcess(); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String[] receiverPermissions = receiverPermission == null ? null : new String[] {receiverPermission}; try { try { intent.prepareToLeaveProcess(); intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, null, mMainThread.getApplicationThread(), intent, resolvedType, null, Activity.RESULT_OK, null, null, receiverPermission, AppOpsManager.OP_NONE, Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, options, false, false, getUserId()); options, false, false, getUserId()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); throw new RuntimeException("Failure from system", e); Loading @@ -807,11 +826,13 @@ class ContextImpl extends Context { public void sendBroadcast(Intent intent, String receiverPermission, int appOp) { public void sendBroadcast(Intent intent, String receiverPermission, int appOp) { warnIfCallingFromSystemProcess(); warnIfCallingFromSystemProcess(); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String[] receiverPermissions = receiverPermission == null ? null : new String[] {receiverPermission}; try { try { intent.prepareToLeaveProcess(); intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, null, mMainThread.getApplicationThread(), intent, resolvedType, null, Activity.RESULT_OK, null, null, receiverPermission, appOp, null, false, false, Activity.RESULT_OK, null, null, receiverPermissions, appOp, null, false, false, getUserId()); getUserId()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); throw new RuntimeException("Failure from system", e); Loading @@ -822,11 +843,13 @@ class ContextImpl extends Context { public void sendOrderedBroadcast(Intent intent, String receiverPermission) { public void sendOrderedBroadcast(Intent intent, String receiverPermission) { warnIfCallingFromSystemProcess(); warnIfCallingFromSystemProcess(); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String[] receiverPermissions = receiverPermission == null ? null : new String[] {receiverPermission}; try { try { intent.prepareToLeaveProcess(); intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, null, mMainThread.getApplicationThread(), intent, resolvedType, null, Activity.RESULT_OK, null, null, receiverPermission, AppOpsManager.OP_NONE, Activity.RESULT_OK, null, null, receiverPermissions, AppOpsManager.OP_NONE, null, true, false, getUserId()); null, true, false, getUserId()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); throw new RuntimeException("Failure from system", e); Loading Loading @@ -883,11 +906,13 @@ class ContextImpl extends Context { } } } } String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String[] receiverPermissions = receiverPermission == null ? null : new String[] {receiverPermission}; try { try { intent.prepareToLeaveProcess(); intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, rd, mMainThread.getApplicationThread(), intent, resolvedType, rd, initialCode, initialData, initialExtras, receiverPermission, appOp, initialCode, initialData, initialExtras, receiverPermissions, appOp, options, true, false, getUserId()); options, true, false, getUserId()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); throw new RuntimeException("Failure from system", e); Loading Loading @@ -917,11 +942,13 @@ class ContextImpl extends Context { public void sendBroadcastAsUser(Intent intent, UserHandle user, public void sendBroadcastAsUser(Intent intent, UserHandle user, String receiverPermission, int appOp) { String receiverPermission, int appOp) { String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String[] receiverPermissions = receiverPermission == null ? null : new String[] {receiverPermission}; try { try { intent.prepareToLeaveProcess(); intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, null, mMainThread.getApplicationThread(), intent, resolvedType, null, Activity.RESULT_OK, null, null, receiverPermission, appOp, null, false, false, Activity.RESULT_OK, null, null, receiverPermissions, appOp, null, false, false, user.getIdentifier()); user.getIdentifier()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); throw new RuntimeException("Failure from system", e); Loading Loading @@ -959,11 +986,13 @@ class ContextImpl extends Context { } } } } String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String resolvedType = intent.resolveTypeIfNeeded(getContentResolver()); String[] receiverPermissions = receiverPermission == null ? null : new String[] {receiverPermission}; try { try { intent.prepareToLeaveProcess(); intent.prepareToLeaveProcess(); ActivityManagerNative.getDefault().broadcastIntent( ActivityManagerNative.getDefault().broadcastIntent( mMainThread.getApplicationThread(), intent, resolvedType, rd, mMainThread.getApplicationThread(), intent, resolvedType, rd, initialCode, initialData, initialExtras, receiverPermission, initialCode, initialData, initialExtras, receiverPermissions, appOp, null, true, false, user.getIdentifier()); appOp, null, true, false, user.getIdentifier()); } catch (RemoteException e) { } catch (RemoteException e) { throw new RuntimeException("Failure from system", e); throw new RuntimeException("Failure from system", e); Loading
core/java/android/app/IActivityManager.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -106,7 +106,7 @@ public interface IActivityManager extends IInterface { public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException; public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException; public int broadcastIntent(IApplicationThread caller, Intent intent, public int broadcastIntent(IApplicationThread caller, Intent intent, String resolvedType, IIntentReceiver resultTo, int resultCode, String resolvedType, IIntentReceiver resultTo, int resultCode, String resultData, Bundle map, String requiredPermission, String resultData, Bundle map, String[] requiredPermissions, int appOp, Bundle options, boolean serialized, boolean sticky, int userId) throws RemoteException; int appOp, Bundle options, boolean serialized, boolean sticky, int userId) throws RemoteException; public void unbroadcastIntent(IApplicationThread caller, Intent intent, int userId) throws RemoteException; public void unbroadcastIntent(IApplicationThread caller, Intent intent, int userId) throws RemoteException; public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, Loading
core/java/android/content/Context.java +27 −0 Original line number Original line Diff line number Diff line Loading @@ -1516,6 +1516,33 @@ public abstract class Context { public abstract void sendBroadcast(Intent intent, public abstract void sendBroadcast(Intent intent, @Nullable String receiverPermission); @Nullable String receiverPermission); /** * 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 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 sendBroadcastMultiplePermissions(Intent intent, String[] receiverPermissions); /** /** * Broadcast the given intent to all interested BroadcastReceivers, allowing * Broadcast the given intent to all interested BroadcastReceivers, allowing * an optional required permission to be enforced. This * an optional required permission to be enforced. This Loading