Merge "Add excludedPackages parameter to broadcast" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e10b6c4df4
@@ -4617,8 +4617,8 @@ public class ActivityManager {
|
||||
try {
|
||||
getService().broadcastIntentWithFeature(
|
||||
null, null, intent, null, null, Activity.RESULT_OK, null, null,
|
||||
null /*requiredPermissions*/, null /*excludedPermissions*/, appOp, null, false,
|
||||
true, userId);
|
||||
null /*requiredPermissions*/, null /*excludedPermissions*/,
|
||||
null /*excludedPackages*/, appOp, null, false, true, userId);
|
||||
} catch (RemoteException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1193,7 +1193,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, null, null /*excludedPermissions=*/,
|
||||
AppOpsManager.OP_NONE, null, false, false, getUserId());
|
||||
null, AppOpsManager.OP_NONE, null, false, false, getUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1210,7 +1210,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, receiverPermissions,
|
||||
null /*excludedPermissions=*/, AppOpsManager.OP_NONE, null, false, false,
|
||||
null /*excludedPermissions=*/, null, AppOpsManager.OP_NONE, null, false, false,
|
||||
getUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
@@ -1226,7 +1226,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, receiverPermissions,
|
||||
null /*excludedPermissions=*/, AppOpsManager.OP_NONE, null, false, false,
|
||||
null /*excludedPermissions=*/, null, AppOpsManager.OP_NONE, null, false, false,
|
||||
getUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
@@ -1243,8 +1243,8 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, receiverPermissions,
|
||||
null /*excludedPermissions=*/, AppOpsManager.OP_NONE, options, false, false,
|
||||
getUserId());
|
||||
null /*excludedPermissions=*/, null /*excludedPackages*/,
|
||||
AppOpsManager.OP_NONE, options, false, false, getUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1259,7 +1259,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, receiverPermissions,
|
||||
null /*excludedPermissions=*/, AppOpsManager.OP_NONE, null, false, false,
|
||||
null /*excludedPermissions=*/, null, AppOpsManager.OP_NONE, null, false, false,
|
||||
user.getIdentifier());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
@@ -1268,7 +1268,7 @@ class ContextImpl extends Context {
|
||||
|
||||
@Override
|
||||
public void sendBroadcastMultiplePermissions(Intent intent, String[] receiverPermissions,
|
||||
String[] excludedPermissions) {
|
||||
String[] excludedPermissions, String[] excludedPackages) {
|
||||
warnIfCallingFromSystemProcess();
|
||||
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
|
||||
try {
|
||||
@@ -1276,7 +1276,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, receiverPermissions, excludedPermissions,
|
||||
AppOpsManager.OP_NONE, null, false, false, getUserId());
|
||||
excludedPackages, AppOpsManager.OP_NONE, null, false, false, getUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1303,7 +1303,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, receiverPermissions,
|
||||
excludedPermissions, AppOpsManager.OP_NONE, options, false, false,
|
||||
excludedPermissions, null, AppOpsManager.OP_NONE, options, false, false,
|
||||
getUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
@@ -1321,7 +1321,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, receiverPermissions,
|
||||
null /*excludedPermissions=*/, appOp, null, false, false, getUserId());
|
||||
null /*excludedPermissions=*/, null, appOp, null, false, false, getUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1338,7 +1338,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, receiverPermissions,
|
||||
null /*excludedPermissions=*/, AppOpsManager.OP_NONE, null, true, false,
|
||||
null /*excludedPermissions=*/, null, AppOpsManager.OP_NONE, null, true, false,
|
||||
getUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
@@ -1402,7 +1402,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
rd, initialCode, initialData, initialExtras, receiverPermissions,
|
||||
null /*excludedPermissions=*/, appOp, options, true, false, getUserId());
|
||||
null /*excludedPermissions=*/, null, appOp, options, true, false, getUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1416,7 +1416,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, null, null /*excludedPermissions=*/,
|
||||
AppOpsManager.OP_NONE, null, false, false, user.getIdentifier());
|
||||
null, AppOpsManager.OP_NONE, null, false, false, user.getIdentifier());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1439,8 +1439,8 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, receiverPermissions,
|
||||
null /*excludedPermissions=*/, AppOpsManager.OP_NONE, options, false, false,
|
||||
user.getIdentifier());
|
||||
null /*excludedPermissions=*/, null, AppOpsManager.OP_NONE, options, false,
|
||||
false, user.getIdentifier());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1457,7 +1457,8 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, receiverPermissions,
|
||||
null /*excludedPermissions=*/, appOp, null, false, false, user.getIdentifier());
|
||||
null /*excludedPermissions=*/, null, appOp, null, false, false,
|
||||
user.getIdentifier());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1508,7 +1509,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
rd, initialCode, initialData, initialExtras, receiverPermissions,
|
||||
null /*excludedPermissions=*/, appOp, options, true, false,
|
||||
null /*excludedPermissions=*/, null, appOp, options, true, false,
|
||||
user.getIdentifier());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
@@ -1550,7 +1551,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, null, null /*excludedPermissions=*/,
|
||||
AppOpsManager.OP_NONE, null, false, true, getUserId());
|
||||
null, AppOpsManager.OP_NONE, null, false, true, getUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1589,7 +1590,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, null, null /*excludedPermissions=*/,
|
||||
AppOpsManager.OP_NONE, options, false, true, getUserId());
|
||||
null, AppOpsManager.OP_NONE, options, false, true, getUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1625,7 +1626,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
rd, initialCode, initialData, initialExtras, null,
|
||||
null /*excludedPermissions=*/, AppOpsManager.OP_NONE, null, true, true,
|
||||
null /*excludedPermissions=*/, null, AppOpsManager.OP_NONE, null, true, true,
|
||||
getUserId());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
@@ -1658,7 +1659,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, null, null /*excludedPermissions=*/,
|
||||
AppOpsManager.OP_NONE, null, false, true, user.getIdentifier());
|
||||
null, AppOpsManager.OP_NONE, null, false, true, user.getIdentifier());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1673,7 +1674,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
null, Activity.RESULT_OK, null, null, null, null /*excludedPermissions=*/,
|
||||
AppOpsManager.OP_NONE, options, false, true, user.getIdentifier());
|
||||
null, AppOpsManager.OP_NONE, options, false, true, user.getIdentifier());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1708,7 +1709,7 @@ class ContextImpl extends Context {
|
||||
ActivityManager.getService().broadcastIntentWithFeature(
|
||||
mMainThread.getApplicationThread(), getAttributionTag(), intent, resolvedType,
|
||||
rd, initialCode, initialData, initialExtras, null,
|
||||
null /*excludedPermissions=*/, AppOpsManager.OP_NONE, null, true, true,
|
||||
null /*excludedPermissions=*/, null, AppOpsManager.OP_NONE, null, true, true,
|
||||
user.getIdentifier());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
|
||||
@@ -141,7 +141,7 @@ interface IActivityManager {
|
||||
int broadcastIntentWithFeature(in IApplicationThread caller, in String callingFeatureId,
|
||||
in Intent intent, in String resolvedType, in IIntentReceiver resultTo, int resultCode,
|
||||
in String resultData, in Bundle map, in String[] requiredPermissions, in String[] excludePermissions,
|
||||
int appOp, in Bundle options, boolean serialized, boolean sticky, int userId);
|
||||
in String[] excludePackages, int appOp, in Bundle options, boolean serialized, boolean sticky, int userId);
|
||||
void unbroadcastIntent(in IApplicationThread caller, in Intent intent, int userId);
|
||||
@UnsupportedAppUsage
|
||||
oneway void finishReceiver(in IBinder who, int resultCode, in String resultData, in Bundle map,
|
||||
|
||||
@@ -2269,6 +2269,19 @@ public abstract class Context {
|
||||
*/
|
||||
public void sendBroadcastMultiplePermissions(@NonNull Intent intent,
|
||||
@NonNull String[] receiverPermissions, @Nullable String[] excludedPermissions) {
|
||||
sendBroadcastMultiplePermissions(intent, receiverPermissions, excludedPermissions, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Like {@link #sendBroadcastMultiplePermissions(Intent, String[], String[])}, but also allows
|
||||
* specification of a list of excluded packages.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void sendBroadcastMultiplePermissions(@NonNull Intent intent,
|
||||
@NonNull String[] receiverPermissions, @Nullable String[] excludedPermissions,
|
||||
@Nullable String[] excludedPackages) {
|
||||
throw new RuntimeException("Not implemented. Must override in a subclass.");
|
||||
}
|
||||
|
||||
|
||||
@@ -515,8 +515,10 @@ public class ContextWrapper extends Context {
|
||||
/** @hide */
|
||||
@Override
|
||||
public void sendBroadcastMultiplePermissions(@NonNull Intent intent,
|
||||
@NonNull String[] receiverPermissions, @Nullable String[] excludedPermissions) {
|
||||
mBase.sendBroadcastMultiplePermissions(intent, receiverPermissions, excludedPermissions);
|
||||
@NonNull String[] receiverPermissions, @Nullable String[] excludedPermissions,
|
||||
@Nullable String[] excludedPackages) {
|
||||
mBase.sendBroadcastMultiplePermissions(intent, receiverPermissions, excludedPermissions,
|
||||
excludedPackages);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
|
||||
@@ -2627,7 +2627,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
public void batterySendBroadcast(Intent intent) {
|
||||
synchronized (this) {
|
||||
broadcastIntentLocked(null, null, null, intent, null, null, 0, null, null, null, null,
|
||||
OP_NONE, null, false, false, -1, SYSTEM_UID, Binder.getCallingUid(),
|
||||
null, OP_NONE, null, false, false, -1, SYSTEM_UID, Binder.getCallingUid(),
|
||||
Binder.getCallingPid(), UserHandle.USER_ALL);
|
||||
}
|
||||
}
|
||||
@@ -4241,7 +4241,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
intent.putExtra(Intent.EXTRA_UID, uid);
|
||||
intent.putExtra(Intent.EXTRA_USER_HANDLE, UserHandle.getUserId(uid));
|
||||
broadcastIntentLocked(null, null, null, intent,
|
||||
null, null, 0, null, null, null, null, OP_NONE,
|
||||
null, null, 0, null, null, null, null, null, OP_NONE,
|
||||
null, false, false, MY_PID, SYSTEM_UID, Binder.getCallingUid(),
|
||||
Binder.getCallingPid(), UserHandle.getUserId(uid));
|
||||
}
|
||||
@@ -8122,7 +8122,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
| Intent.FLAG_RECEIVER_FOREGROUND);
|
||||
intent.putExtra(Intent.EXTRA_USER_HANDLE, currentUserId);
|
||||
broadcastIntentLocked(null, null, null, intent,
|
||||
null, null, 0, null, null, null, null, OP_NONE,
|
||||
null, null, 0, null, null, null, null, null, OP_NONE,
|
||||
null, false, false, MY_PID, SYSTEM_UID, callingUid, callingPid,
|
||||
currentUserId);
|
||||
intent = new Intent(Intent.ACTION_USER_STARTING);
|
||||
@@ -8134,8 +8134,8 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
public void performReceive(Intent intent, int resultCode,
|
||||
String data, Bundle extras, boolean ordered, boolean sticky,
|
||||
int sendingUser) {}
|
||||
}, 0, null, null, new String[] {INTERACT_ACROSS_USERS}, null, OP_NONE,
|
||||
null, true, false, MY_PID, SYSTEM_UID, callingUid, callingPid,
|
||||
}, 0, null, null, new String[] {INTERACT_ACROSS_USERS}, null, null,
|
||||
OP_NONE, null, true, false, MY_PID, SYSTEM_UID, callingUid, callingPid,
|
||||
UserHandle.USER_ALL);
|
||||
} catch (Throwable e) {
|
||||
Slog.wtf(TAG, "Failed sending first user broadcasts", e);
|
||||
@@ -13165,8 +13165,8 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
Intent intent = allSticky.get(i);
|
||||
BroadcastQueue queue = broadcastQueueForIntent(intent);
|
||||
BroadcastRecord r = new BroadcastRecord(queue, intent, null,
|
||||
null, null, -1, -1, false, null, null, null, OP_NONE, null, receivers,
|
||||
null, 0, null, null, false, true, true, -1, false, null,
|
||||
null, null, -1, -1, false, null, null, null, null, OP_NONE, null,
|
||||
receivers, null, 0, null, null, false, true, true, -1, false, null,
|
||||
false /* only PRE_BOOT_COMPLETED should be exempt, no stickies */);
|
||||
queue.enqueueParallelBroadcastLocked(r);
|
||||
queue.scheduleBroadcastsLocked();
|
||||
@@ -13422,12 +13422,14 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
String callerPackage, String callerFeatureId, Intent intent, String resolvedType,
|
||||
IIntentReceiver resultTo, int resultCode, String resultData,
|
||||
Bundle resultExtras, String[] requiredPermissions, String[] excludedPermissions,
|
||||
int appOp, Bundle bOptions, boolean ordered, boolean sticky, int callingPid,
|
||||
String[] excludedPackages, int appOp, Bundle bOptions, boolean ordered,
|
||||
boolean sticky, int callingPid,
|
||||
int callingUid, int realCallingUid, int realCallingPid, int userId) {
|
||||
return broadcastIntentLocked(callerApp, callerPackage, callerFeatureId, intent,
|
||||
resolvedType, resultTo, resultCode, resultData, resultExtras, requiredPermissions,
|
||||
excludedPermissions, appOp, bOptions, ordered, sticky, callingPid, callingUid,
|
||||
realCallingUid, realCallingPid, userId, false /* allowBackgroundActivityStarts */,
|
||||
excludedPermissions, excludedPackages, appOp, bOptions, ordered, sticky, callingPid,
|
||||
callingUid, realCallingUid, realCallingPid, userId,
|
||||
false /* allowBackgroundActivityStarts */,
|
||||
null /* tokenNeededForBackgroundActivityStarts */, null /* broadcastAllowList */);
|
||||
}
|
||||
|
||||
@@ -13436,7 +13438,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
@Nullable String callerFeatureId, Intent intent, String resolvedType,
|
||||
IIntentReceiver resultTo, int resultCode, String resultData,
|
||||
Bundle resultExtras, String[] requiredPermissions,
|
||||
String[] excludedPermissions, int appOp, Bundle bOptions,
|
||||
String[] excludedPermissions, String[] excludedPackages, int appOp, Bundle bOptions,
|
||||
boolean ordered, boolean sticky, int callingPid, int callingUid,
|
||||
int realCallingUid, int realCallingPid, int userId,
|
||||
boolean allowBackgroundActivityStarts,
|
||||
@@ -14043,10 +14045,10 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
final BroadcastQueue queue = broadcastQueueForIntent(intent);
|
||||
BroadcastRecord r = new BroadcastRecord(queue, intent, callerApp, callerPackage,
|
||||
callerFeatureId, callingPid, callingUid, callerInstantApp, resolvedType,
|
||||
requiredPermissions, excludedPermissions, appOp, brOptions, registeredReceivers,
|
||||
resultTo, resultCode, resultData, resultExtras, ordered, sticky, false, userId,
|
||||
allowBackgroundActivityStarts, backgroundActivityStartsToken,
|
||||
timeoutExempt);
|
||||
requiredPermissions, excludedPermissions, excludedPackages, appOp, brOptions,
|
||||
registeredReceivers, resultTo, resultCode, resultData, resultExtras, ordered,
|
||||
sticky, false, userId, allowBackgroundActivityStarts,
|
||||
backgroundActivityStartsToken, timeoutExempt);
|
||||
if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "Enqueueing parallel broadcast " + r);
|
||||
final boolean replaced = replacePending
|
||||
&& (queue.replaceParallelBroadcastLocked(r) != null);
|
||||
@@ -14141,7 +14143,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
BroadcastQueue queue = broadcastQueueForIntent(intent);
|
||||
BroadcastRecord r = new BroadcastRecord(queue, intent, callerApp, callerPackage,
|
||||
callerFeatureId, callingPid, callingUid, callerInstantApp, resolvedType,
|
||||
requiredPermissions, excludedPermissions, appOp, brOptions,
|
||||
requiredPermissions, excludedPermissions, excludedPackages, appOp, brOptions,
|
||||
receivers, resultTo, resultCode, resultData, resultExtras,
|
||||
ordered, sticky, false, userId, allowBackgroundActivityStarts,
|
||||
backgroundActivityStartsToken, timeoutExempt);
|
||||
@@ -14270,14 +14272,16 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
String[] requiredPermissions, int appOp, Bundle bOptions,
|
||||
boolean serialized, boolean sticky, int userId) {
|
||||
return broadcastIntentWithFeature(caller, null, intent, resolvedType, resultTo, resultCode,
|
||||
resultData, resultExtras, requiredPermissions, null, appOp, bOptions, serialized,
|
||||
sticky, userId);
|
||||
resultData, resultExtras, requiredPermissions, null, null, appOp, bOptions,
|
||||
serialized, sticky, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int broadcastIntentWithFeature(IApplicationThread caller, String callingFeatureId,
|
||||
Intent intent, String resolvedType, IIntentReceiver resultTo,
|
||||
int resultCode, String resultData, Bundle resultExtras,
|
||||
String[] requiredPermissions, String[] excludedPermissions, int appOp, Bundle bOptions,
|
||||
String[] requiredPermissions, String[] excludedPermissions,
|
||||
String[] excludedPackages, int appOp, Bundle bOptions,
|
||||
boolean serialized, boolean sticky, int userId) {
|
||||
enforceNotIsolatedCaller("broadcastIntent");
|
||||
synchronized(this) {
|
||||
@@ -14292,8 +14296,8 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
return broadcastIntentLocked(callerApp,
|
||||
callerApp != null ? callerApp.info.packageName : null, callingFeatureId,
|
||||
intent, resolvedType, resultTo, resultCode, resultData, resultExtras,
|
||||
requiredPermissions, excludedPermissions, appOp, bOptions, serialized,
|
||||
sticky, callingPid, callingUid, callingUid, callingPid, userId);
|
||||
requiredPermissions, excludedPermissions, excludedPackages, appOp, bOptions,
|
||||
serialized, sticky, callingPid, callingUid, callingUid, callingPid, userId);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(origId);
|
||||
}
|
||||
@@ -14316,7 +14320,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
try {
|
||||
return broadcastIntentLocked(null, packageName, featureId, intent, resolvedType,
|
||||
resultTo, resultCode, resultData, resultExtras, requiredPermissions, null,
|
||||
OP_NONE, bOptions, serialized, sticky, -1, uid, realCallingUid,
|
||||
null, OP_NONE, bOptions, serialized, sticky, -1, uid, realCallingUid,
|
||||
realCallingPid, userId, allowBackgroundActivityStarts,
|
||||
backgroundActivityStartsToken, broadcastAllowList);
|
||||
} finally {
|
||||
@@ -16835,10 +16839,11 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
return ActivityManagerService.this.broadcastIntentLocked(null /*callerApp*/,
|
||||
null /*callerPackage*/, null /*callingFeatureId*/, intent,
|
||||
null /*resolvedType*/, resultTo, 0 /*resultCode*/, null /*resultData*/,
|
||||
null /*resultExtras*/, requiredPermissions, null, AppOpsManager.OP_NONE,
|
||||
bOptions /*options*/, serialized, false /*sticky*/, callingPid,
|
||||
callingUid, callingUid, callingPid, userId,
|
||||
false /*allowBackgroundStarts*/,
|
||||
null /*resultExtras*/, requiredPermissions,
|
||||
null /*excludedPermissions*/, null /*excludedPackages*/,
|
||||
AppOpsManager.OP_NONE, bOptions /*options*/, serialized,
|
||||
false /*sticky*/, callingPid, callingUid, callingUid, callingPid,
|
||||
userId, false /*allowBackgroundStarts*/,
|
||||
null /*tokenNeededForBackgroundActivityStarts*/, appIdAllowList);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(origId);
|
||||
@@ -16974,7 +16979,7 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
| Intent.FLAG_RECEIVER_FOREGROUND
|
||||
| Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS);
|
||||
broadcastIntentLocked(null, null, null, intent, null, null, 0, null, null, null,
|
||||
null, OP_NONE, null, false, false, MY_PID, SYSTEM_UID,
|
||||
null, null, OP_NONE, null, false, false, MY_PID, SYSTEM_UID,
|
||||
Binder.getCallingUid(), Binder.getCallingPid(), UserHandle.USER_ALL);
|
||||
if ((changes & ActivityInfo.CONFIG_LOCALE) != 0) {
|
||||
intent = new Intent(Intent.ACTION_LOCALE_CHANGED);
|
||||
@@ -16989,8 +16994,8 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_ALLOWED,
|
||||
PowerExemptionManager.REASON_LOCALE_CHANGED, "");
|
||||
broadcastIntentLocked(null, null, null, intent, null, null, 0, null, null, null,
|
||||
null, OP_NONE, bOptions.toBundle(), false, false, MY_PID, SYSTEM_UID,
|
||||
Binder.getCallingUid(), Binder.getCallingPid(),
|
||||
null, null, OP_NONE, bOptions.toBundle(), false, false, MY_PID,
|
||||
SYSTEM_UID, Binder.getCallingUid(), Binder.getCallingPid(),
|
||||
UserHandle.USER_ALL);
|
||||
}
|
||||
|
||||
@@ -17005,8 +17010,9 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
String[] permissions =
|
||||
new String[] { android.Manifest.permission.INSTALL_PACKAGES };
|
||||
broadcastIntentLocked(null, null, null, intent, null, null, 0, null, null,
|
||||
permissions, null, OP_NONE, null, false, false, MY_PID, SYSTEM_UID,
|
||||
Binder.getCallingUid(), Binder.getCallingPid(), UserHandle.USER_ALL);
|
||||
permissions, null, null, OP_NONE, null, false, false, MY_PID,
|
||||
SYSTEM_UID, Binder.getCallingUid(), Binder.getCallingPid(),
|
||||
UserHandle.USER_ALL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17030,8 +17036,8 @@ public class ActivityManagerService extends IActivityManager.Stub
|
||||
}
|
||||
|
||||
broadcastIntentLocked(null, null, null, intent, null, null, 0, null, null, null,
|
||||
null, OP_NONE, null, false, false, -1, SYSTEM_UID, Binder.getCallingUid(),
|
||||
Binder.getCallingPid(), UserHandle.USER_ALL);
|
||||
null, null, OP_NONE, null, false, false, -1, SYSTEM_UID,
|
||||
Binder.getCallingUid(), Binder.getCallingPid(), UserHandle.USER_ALL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -804,8 +804,8 @@ final class ActivityManagerShellCommand extends ShellCommand {
|
||||
pw.flush();
|
||||
Bundle bundle = mBroadcastOptions == null ? null : mBroadcastOptions.toBundle();
|
||||
mInterface.broadcastIntentWithFeature(null, null, intent, null, receiver, 0, null, null,
|
||||
requiredPermissions, null, android.app.AppOpsManager.OP_NONE, bundle, true, false,
|
||||
mUserId);
|
||||
requiredPermissions, null, null, android.app.AppOpsManager.OP_NONE, bundle, true,
|
||||
false, mUserId);
|
||||
if (!mAsync) {
|
||||
receiver.waitForFinish();
|
||||
}
|
||||
|
||||
@@ -860,6 +860,21 @@ public final class BroadcastQueue {
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the receiver does *not* belong to any of the excluded packages
|
||||
if (!skip && r.excludedPackages != null && r.excludedPackages.length > 0) {
|
||||
if (ArrayUtils.contains(r.excludedPackages, filter.packageName)) {
|
||||
Slog.w(TAG, "Skipping delivery of excluded package "
|
||||
+ r.intent.toString()
|
||||
+ " to " + filter.receiverList.app
|
||||
+ " (pid=" + filter.receiverList.pid
|
||||
+ ", uid=" + filter.receiverList.uid + ")"
|
||||
+ " excludes package " + filter.packageName
|
||||
+ " due to sender " + r.callerPackage
|
||||
+ " (uid " + r.callingUid + ")");
|
||||
skip = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If the broadcast also requires an app op check that as well.
|
||||
if (!skip && r.appOp != AppOpsManager.OP_NONE
|
||||
&& mService.getAppOpsManager().noteOpNoThrow(r.appOp,
|
||||
@@ -1721,6 +1736,19 @@ public final class BroadcastQueue {
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the receiver does *not* belong to any of the excluded packages
|
||||
if (!skip && r.excludedPackages != null && r.excludedPackages.length > 0) {
|
||||
if (ArrayUtils.contains(r.excludedPackages, component.getPackageName())) {
|
||||
Slog.w(TAG, "Skipping delivery of excluded package "
|
||||
+ r.intent + " to "
|
||||
+ component.flattenToShortString()
|
||||
+ " excludes package " + component.getPackageName()
|
||||
+ " due to sender " + r.callerPackage
|
||||
+ " (uid " + r.callingUid + ")");
|
||||
skip = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!skip && info.activityInfo.applicationInfo.uid != Process.SYSTEM_UID &&
|
||||
r.requiredPermissions != null && r.requiredPermissions.length > 0) {
|
||||
for (int i = 0; i < r.requiredPermissions.length; i++) {
|
||||
|
||||
@@ -75,6 +75,7 @@ final class BroadcastRecord extends Binder {
|
||||
final String resolvedType; // the resolved data type
|
||||
final String[] requiredPermissions; // permissions the caller has required
|
||||
final String[] excludedPermissions; // permissions to exclude
|
||||
final String[] excludedPackages; // packages to exclude
|
||||
final int appOp; // an app op that is associated with this broadcast
|
||||
final BroadcastOptions options; // BroadcastOptions supplied by caller
|
||||
final List receivers; // contains BroadcastFilter and ResolveInfo
|
||||
@@ -162,6 +163,10 @@ final class BroadcastRecord extends Binder {
|
||||
pw.print(prefix); pw.print("excludedPermissions=");
|
||||
pw.print(Arrays.toString(excludedPermissions));
|
||||
}
|
||||
if (excludedPackages != null && excludedPackages.length > 0) {
|
||||
pw.print(prefix); pw.print("excludedPackages=");
|
||||
pw.print(Arrays.toString(excludedPackages));
|
||||
}
|
||||
if (options != null) {
|
||||
pw.print(prefix); pw.print("options="); pw.println(options.toBundle());
|
||||
}
|
||||
@@ -260,7 +265,8 @@ final class BroadcastRecord extends Binder {
|
||||
Intent _intent, ProcessRecord _callerApp, String _callerPackage,
|
||||
@Nullable String _callerFeatureId, int _callingPid, int _callingUid,
|
||||
boolean _callerInstantApp, String _resolvedType,
|
||||
String[] _requiredPermissions, String[] _excludedPermissions, int _appOp,
|
||||
String[] _requiredPermissions, String[] _excludedPermissions,
|
||||
String[] _excludedPackages, int _appOp,
|
||||
BroadcastOptions _options, List _receivers, IIntentReceiver _resultTo, int _resultCode,
|
||||
String _resultData, Bundle _resultExtras, boolean _serialized, boolean _sticky,
|
||||
boolean _initialSticky, int _userId, boolean allowBackgroundActivityStarts,
|
||||
@@ -280,6 +286,7 @@ final class BroadcastRecord extends Binder {
|
||||
resolvedType = _resolvedType;
|
||||
requiredPermissions = _requiredPermissions;
|
||||
excludedPermissions = _excludedPermissions;
|
||||
excludedPackages = _excludedPackages;
|
||||
appOp = _appOp;
|
||||
options = _options;
|
||||
receivers = _receivers;
|
||||
@@ -321,6 +328,7 @@ final class BroadcastRecord extends Binder {
|
||||
resolvedType = from.resolvedType;
|
||||
requiredPermissions = from.requiredPermissions;
|
||||
excludedPermissions = from.excludedPermissions;
|
||||
excludedPackages = from.excludedPackages;
|
||||
appOp = from.appOp;
|
||||
options = from.options;
|
||||
receivers = from.receivers;
|
||||
@@ -381,9 +389,10 @@ final class BroadcastRecord extends Binder {
|
||||
// build a new BroadcastRecord around that single-target list
|
||||
BroadcastRecord split = new BroadcastRecord(queue, intent, callerApp, callerPackage,
|
||||
callerFeatureId, callingPid, callingUid, callerInstantApp, resolvedType,
|
||||
requiredPermissions, excludedPermissions, appOp, options, splitReceivers, resultTo,
|
||||
resultCode, resultData, resultExtras, ordered, sticky, initialSticky, userId,
|
||||
allowBackgroundActivityStarts, mBackgroundActivityStartsToken, timeoutExempt);
|
||||
requiredPermissions, excludedPermissions, excludedPackages, appOp, options,
|
||||
splitReceivers, resultTo, resultCode, resultData, resultExtras, ordered, sticky,
|
||||
initialSticky, userId, allowBackgroundActivityStarts,
|
||||
mBackgroundActivityStartsToken, timeoutExempt);
|
||||
split.enqueueTime = this.enqueueTime;
|
||||
split.enqueueRealTime = this.enqueueRealTime;
|
||||
split.enqueueClockTime = this.enqueueClockTime;
|
||||
@@ -459,7 +468,7 @@ final class BroadcastRecord extends Binder {
|
||||
for (int i = 0; i < uidSize; i++) {
|
||||
final BroadcastRecord br = new BroadcastRecord(queue, intent, callerApp, callerPackage,
|
||||
callerFeatureId, callingPid, callingUid, callerInstantApp, resolvedType,
|
||||
requiredPermissions, excludedPermissions, appOp, options,
|
||||
requiredPermissions, excludedPermissions, excludedPackages, appOp, options,
|
||||
uid2receiverList.valueAt(i), null /* _resultTo */,
|
||||
resultCode, resultData, resultExtras, ordered, sticky, initialSticky, userId,
|
||||
allowBackgroundActivityStarts, mBackgroundActivityStartsToken, timeoutExempt);
|
||||
|
||||
@@ -124,7 +124,7 @@ public abstract class PreBootBroadcaster extends IIntentReceiver.Stub {
|
||||
REASON_PRE_BOOT_COMPLETED, "");
|
||||
synchronized (mService) {
|
||||
mService.broadcastIntentLocked(null, null, null, mIntent, null, this, 0, null, null,
|
||||
null, null, AppOpsManager.OP_NONE, bOptions.toBundle(), true,
|
||||
null, null, null, AppOpsManager.OP_NONE, bOptions.toBundle(), true,
|
||||
false, ActivityManagerService.MY_PID,
|
||||
Process.SYSTEM_UID, Binder.getCallingUid(), Binder.getCallingPid(), mUserId);
|
||||
}
|
||||
|
||||
@@ -3203,8 +3203,8 @@ class UserController implements Handler.Callback {
|
||||
synchronized (mService) {
|
||||
return mService.broadcastIntentLocked(null, null, null, intent, resolvedType,
|
||||
resultTo, resultCode, resultData, resultExtras, requiredPermissions, null,
|
||||
appOp, bOptions, ordered, sticky, callingPid, callingUid, realCallingUid,
|
||||
realCallingPid, userId);
|
||||
null, appOp, bOptions, ordered, sticky, callingPid, callingUid,
|
||||
realCallingUid, realCallingPid, userId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -501,6 +501,7 @@ public final class AppHibernationService extends SystemService {
|
||||
null /* resultExtras */,
|
||||
requiredPermissions,
|
||||
null /* excludedPermissions */,
|
||||
null /* excludedPackages */,
|
||||
OP_NONE,
|
||||
null /* bOptions */,
|
||||
false /* serialized */,
|
||||
@@ -519,6 +520,7 @@ public final class AppHibernationService extends SystemService {
|
||||
null /* resultExtras */,
|
||||
requiredPermissions,
|
||||
null /* excludedPermissions */,
|
||||
null /* excludedPackages */,
|
||||
OP_NONE,
|
||||
null /* bOptions */,
|
||||
false /* serialized */,
|
||||
|
||||
@@ -197,7 +197,7 @@ public final class BroadcastHelper {
|
||||
final BroadcastOptions bOptions = getTemporaryAppAllowlistBroadcastOptions(
|
||||
REASON_LOCKED_BOOT_COMPLETED);
|
||||
am.broadcastIntentWithFeature(null, null, lockedBcIntent, null, null, 0, null, null,
|
||||
requiredPermissions, null, android.app.AppOpsManager.OP_NONE,
|
||||
requiredPermissions, null, null, android.app.AppOpsManager.OP_NONE,
|
||||
bOptions.toBundle(), false, false, userId);
|
||||
|
||||
// Deliver BOOT_COMPLETED only if user is unlocked
|
||||
@@ -207,7 +207,7 @@ public final class BroadcastHelper {
|
||||
bcIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
}
|
||||
am.broadcastIntentWithFeature(null, null, bcIntent, null, null, 0, null, null,
|
||||
requiredPermissions, null, android.app.AppOpsManager.OP_NONE,
|
||||
requiredPermissions, null, null, android.app.AppOpsManager.OP_NONE,
|
||||
bOptions.toBundle(), false, false, userId);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
@@ -263,7 +263,7 @@ public final class BroadcastHelper {
|
||||
};
|
||||
try {
|
||||
am.broadcastIntentWithFeature(null, null, intent, null, null, 0, null, null,
|
||||
requiredPermissions, null, android.app.AppOpsManager.OP_NONE, null, false,
|
||||
requiredPermissions, null, null, android.app.AppOpsManager.OP_NONE, null, false,
|
||||
false, UserHandle.USER_ALL);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
@@ -301,7 +301,7 @@ public final class BroadcastHelper {
|
||||
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
|
||||
try {
|
||||
am.broadcastIntentWithFeature(null, null, intent, null, null,
|
||||
0, null, null, null, null, android.app.AppOpsManager.OP_NONE,
|
||||
0, null, null, null, null, null, android.app.AppOpsManager.OP_NONE,
|
||||
null, false, false, userId);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
|
||||
@@ -416,6 +416,7 @@ public class BroadcastRecordTest {
|
||||
null /* resolvedType */,
|
||||
null /* requiredPermissions */,
|
||||
null /* excludedPermissions */,
|
||||
null /* excludedPackages */,
|
||||
0 /* appOp */,
|
||||
null /* options */,
|
||||
new ArrayList<>(receivers), // Make a copy to not affect the original list.
|
||||
|
||||
@@ -339,7 +339,7 @@ public final class AppHibernationServiceTest {
|
||||
ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
verify(mIActivityManager, times(2)).broadcastIntentWithFeature(any(), any(),
|
||||
intentArgumentCaptor.capture(), any(), any(), anyInt(), any(), any(), any(), any(),
|
||||
anyInt(), any(), anyBoolean(), anyBoolean(), eq(USER_ID_1));
|
||||
any(), anyInt(), any(), anyBoolean(), anyBoolean(), eq(USER_ID_1));
|
||||
List<Intent> capturedIntents = intentArgumentCaptor.getAllValues();
|
||||
assertEquals(capturedIntents.get(0).getAction(), Intent.ACTION_LOCKED_BOOT_COMPLETED);
|
||||
assertEquals(capturedIntents.get(1).getAction(), Intent.ACTION_BOOT_COMPLETED);
|
||||
|
||||
Reference in New Issue
Block a user