Loading core/java/android/app/ActivityManagerInternal.java +4 −2 Original line number Diff line number Diff line Loading @@ -318,12 +318,14 @@ public abstract class ActivityManagerInternal { int uid, int realCallingUid, int realCallingPid, Intent intent, String resolvedType, IIntentReceiver resultTo, int resultCode, String resultData, Bundle resultExtras, String requiredPermission, Bundle bOptions, boolean serialized, boolean sticky, @UserIdInt int userId, boolean allowBackgroundActivityStarts); @UserIdInt int userId, boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken); public abstract ComponentName startServiceInPackage(int uid, Intent service, String resolvedType, boolean fgRequired, String callingPackage, @Nullable String callingFeatureId, @UserIdInt int userId, boolean allowBackgroundActivityStarts) throws TransactionTooLargeException; boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken) throws TransactionTooLargeException; public abstract void disconnectActivityFromServices(Object connectionHolder); public abstract void cleanUpServices(@UserIdInt int userId, ComponentName component, Loading services/core/java/com/android/server/am/ActiveServices.java +3 −6 Original line number Diff line number Diff line Loading @@ -4881,13 +4881,10 @@ public final class ActiveServices { if (instr != null && instr.mHasBackgroundActivityStartsPermission) { return true; } } final boolean hasAllowBackgroundActivityStartsToken = r.app != null ? !r.app.mAllowBackgroundActivityStartsTokens.isEmpty() : false; if (hasAllowBackgroundActivityStartsToken) { if (r.app.areBackgroundActivityStartsAllowedByToken()) { return true; } } if (mAm.checkPermission(START_ACTIVITIES_FROM_BACKGROUND, callingPid, callingUid) == PERMISSION_GRANTED) { Loading services/core/java/com/android/server/am/ActivityManagerService.java +21 −10 Original line number Diff line number Diff line Loading @@ -4325,11 +4325,11 @@ public class ActivityManagerService extends IActivityManager.Stub intent.putExtra(Intent.EXTRA_PACKAGE_NAME, packageName); broadcastIntentInPackage("android", null, SYSTEM_UID, uid, pid, intent, null, null, 0, null, null, permission.ACCESS_INSTANT_APPS, null, false, false, resolvedUserId, false); false, false, resolvedUserId, false, null); } else { broadcastIntentInPackage("android", null, SYSTEM_UID, uid, pid, intent, null, null, 0, null, null, null, null, false, false, resolvedUserId, false); false, null); } if (observer != null) { Loading Loading @@ -15713,7 +15713,7 @@ public class ActivityManagerService extends IActivityManager.Stub BroadcastQueue queue = broadcastQueueForIntent(intent); BroadcastRecord r = new BroadcastRecord(queue, intent, null, null, null, -1, -1, false, null, null, OP_NONE, null, receivers, null, 0, null, null, false, true, true, -1, false, 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(); Loading Loading @@ -15960,7 +15960,7 @@ public class ActivityManagerService extends IActivityManager.Stub resolvedType, resultTo, resultCode, resultData, resultExtras, requiredPermissions, appOp, bOptions, ordered, sticky, callingPid, callingUid, realCallingUid, realCallingPid, userId, false /* allowBackgroundActivityStarts */, null /*broadcastWhitelist*/); null /* tokenNeededForBackgroundActivityStarts */, null /* broadcastWhitelist */); } @GuardedBy("this") Loading @@ -15970,6 +15970,7 @@ public class ActivityManagerService extends IActivityManager.Stub Bundle resultExtras, String[] requiredPermissions, int appOp, Bundle bOptions, boolean ordered, boolean sticky, int callingPid, int callingUid, int realCallingUid, int realCallingPid, int userId, boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken, @Nullable int[] broadcastWhitelist) { intent = new Intent(intent); Loading Loading @@ -16060,6 +16061,8 @@ public class ActivityManagerService extends IActivityManager.Stub throw new SecurityException(msg); } else { allowBackgroundActivityStarts = true; // We set the token to null since if it wasn't for it we'd allow anyway here backgroundActivityStartsToken = null; } } } Loading Loading @@ -16528,7 +16531,8 @@ public class ActivityManagerService extends IActivityManager.Stub callerFeatureId, callingPid, callingUid, callerInstantApp, resolvedType, requiredPermissions, appOp, brOptions, registeredReceivers, resultTo, resultCode, resultData, resultExtras, ordered, sticky, false, userId, allowBackgroundActivityStarts, timeoutExempt); allowBackgroundActivityStarts, backgroundActivityStartsToken, timeoutExempt); if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "Enqueueing parallel broadcast " + r); final boolean replaced = replacePending && (queue.replaceParallelBroadcastLocked(r) != null); Loading Loading @@ -16625,7 +16629,8 @@ public class ActivityManagerService extends IActivityManager.Stub callerFeatureId, callingPid, callingUid, callerInstantApp, resolvedType, requiredPermissions, appOp, brOptions, receivers, resultTo, resultCode, resultData, resultExtras, ordered, sticky, false, userId, allowBackgroundActivityStarts, timeoutExempt); allowBackgroundActivityStarts, backgroundActivityStartsToken, timeoutExempt); if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "Enqueueing ordered broadcast " + r); Loading Loading @@ -16785,7 +16790,8 @@ public class ActivityManagerService extends IActivityManager.Stub int realCallingUid, int realCallingPid, Intent intent, String resolvedType, IIntentReceiver resultTo, int resultCode, String resultData, Bundle resultExtras, String requiredPermission, Bundle bOptions, boolean serialized, boolean sticky, int userId, boolean allowBackgroundActivityStarts) { int userId, boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken) { synchronized(this) { intent = verifyBroadcastLocked(intent); Loading @@ -16797,6 +16803,7 @@ public class ActivityManagerService extends IActivityManager.Stub resultTo, resultCode, resultData, resultExtras, requiredPermissions, OP_NONE, bOptions, serialized, sticky, -1, uid, realCallingUid, realCallingPid, userId, allowBackgroundActivityStarts, backgroundActivityStartsToken, null /*broadcastWhitelist*/); } finally { Binder.restoreCallingIdentity(origId); Loading Loading @@ -19487,12 +19494,14 @@ public class ActivityManagerService extends IActivityManager.Stub int realCallingUid, int realCallingPid, Intent intent, String resolvedType, IIntentReceiver resultTo, int resultCode, String resultData, Bundle resultExtras, String requiredPermission, Bundle bOptions, boolean serialized, boolean sticky, int userId, boolean allowBackgroundActivityStarts) { int userId, boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken) { synchronized (ActivityManagerService.this) { return ActivityManagerService.this.broadcastIntentInPackage(packageName, featureId, uid, realCallingUid, realCallingPid, intent, resolvedType, resultTo, resultCode, resultData, resultExtras, requiredPermission, bOptions, serialized, sticky, userId, allowBackgroundActivityStarts); serialized, sticky, userId, allowBackgroundActivityStarts, backgroundActivityStartsToken); } } Loading @@ -19514,6 +19523,7 @@ public class ActivityManagerService extends IActivityManager.Stub null /*resultExtras*/, requiredPermissions, AppOpsManager.OP_NONE, null /*options*/, serialized, false /*sticky*/, callingPid, callingUid, callingUid, callingPid, userId, false /*allowBackgroundStarts*/, null /*tokenNeededForBackgroundActivityStarts*/, appIdWhitelist); } finally { Binder.restoreCallingIdentity(origId); Loading @@ -19525,7 +19535,8 @@ public class ActivityManagerService extends IActivityManager.Stub @Override public ComponentName startServiceInPackage(int uid, Intent service, String resolvedType, boolean fgRequired, String callingPackage, @Nullable String callingFeatureId, int userId, boolean allowBackgroundActivityStarts) int userId, boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken) throws TransactionTooLargeException { synchronized(ActivityManagerService.this) { if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, services/core/java/com/android/server/am/BroadcastQueue.java +1 −1 Original line number Diff line number Diff line Loading @@ -1677,7 +1677,7 @@ public final class BroadcastQueue { // that request - we don't want the token to be swept from under our feet... mHandler.removeCallbacksAndMessages(msgToken); // ...then add the token proc.addAllowBackgroundActivityStartsToken(r); proc.addAllowBackgroundActivityStartsToken(r, r.mBackgroundActivityStartsToken); } final void setBroadcastTimeoutLocked(long timeoutTime) { Loading services/core/java/com/android/server/am/BroadcastRecord.java +10 −4 Original line number Diff line number Diff line Loading @@ -92,6 +92,9 @@ final class BroadcastRecord extends Binder { // if set to true, app's process will be temporarily allowed to start activities from background // for the duration of the broadcast dispatch final boolean allowBackgroundActivityStarts; // token used to trace back the grant for activity starts, optional @Nullable final IBinder mBackgroundActivityStartsToken; static final int IDLE = 0; static final int APP_RECEIVE = 1; Loading Loading @@ -240,7 +243,8 @@ final class BroadcastRecord extends Binder { String[] _requiredPermissions, int _appOp, BroadcastOptions _options, List _receivers, IIntentReceiver _resultTo, int _resultCode, String _resultData, Bundle _resultExtras, boolean _serialized, boolean _sticky, boolean _initialSticky, int _userId, boolean _allowBackgroundActivityStarts, boolean _timeoutExempt) { boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken, boolean timeoutExempt) { if (_intent == null) { throw new NullPointerException("Can't construct with a null intent"); } Loading Loading @@ -270,8 +274,9 @@ final class BroadcastRecord extends Binder { userId = _userId; nextReceiver = 0; state = IDLE; allowBackgroundActivityStarts = _allowBackgroundActivityStarts; timeoutExempt = _timeoutExempt; this.allowBackgroundActivityStarts = allowBackgroundActivityStarts; mBackgroundActivityStartsToken = backgroundActivityStartsToken; this.timeoutExempt = timeoutExempt; } /** Loading Loading @@ -317,6 +322,7 @@ final class BroadcastRecord extends Binder { manifestSkipCount = from.manifestSkipCount; queue = from.queue; allowBackgroundActivityStarts = from.allowBackgroundActivityStarts; mBackgroundActivityStartsToken = from.mBackgroundActivityStartsToken; timeoutExempt = from.timeoutExempt; } Loading Loading @@ -352,7 +358,7 @@ final class BroadcastRecord extends Binder { callerFeatureId, callingPid, callingUid, callerInstantApp, resolvedType, requiredPermissions, appOp, options, splitReceivers, resultTo, resultCode, resultData, resultExtras, ordered, sticky, initialSticky, userId, allowBackgroundActivityStarts, timeoutExempt); allowBackgroundActivityStarts, mBackgroundActivityStartsToken, timeoutExempt); split.splitToken = this.splitToken; return split; Loading Loading
core/java/android/app/ActivityManagerInternal.java +4 −2 Original line number Diff line number Diff line Loading @@ -318,12 +318,14 @@ public abstract class ActivityManagerInternal { int uid, int realCallingUid, int realCallingPid, Intent intent, String resolvedType, IIntentReceiver resultTo, int resultCode, String resultData, Bundle resultExtras, String requiredPermission, Bundle bOptions, boolean serialized, boolean sticky, @UserIdInt int userId, boolean allowBackgroundActivityStarts); @UserIdInt int userId, boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken); public abstract ComponentName startServiceInPackage(int uid, Intent service, String resolvedType, boolean fgRequired, String callingPackage, @Nullable String callingFeatureId, @UserIdInt int userId, boolean allowBackgroundActivityStarts) throws TransactionTooLargeException; boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken) throws TransactionTooLargeException; public abstract void disconnectActivityFromServices(Object connectionHolder); public abstract void cleanUpServices(@UserIdInt int userId, ComponentName component, Loading
services/core/java/com/android/server/am/ActiveServices.java +3 −6 Original line number Diff line number Diff line Loading @@ -4881,13 +4881,10 @@ public final class ActiveServices { if (instr != null && instr.mHasBackgroundActivityStartsPermission) { return true; } } final boolean hasAllowBackgroundActivityStartsToken = r.app != null ? !r.app.mAllowBackgroundActivityStartsTokens.isEmpty() : false; if (hasAllowBackgroundActivityStartsToken) { if (r.app.areBackgroundActivityStartsAllowedByToken()) { return true; } } if (mAm.checkPermission(START_ACTIVITIES_FROM_BACKGROUND, callingPid, callingUid) == PERMISSION_GRANTED) { Loading
services/core/java/com/android/server/am/ActivityManagerService.java +21 −10 Original line number Diff line number Diff line Loading @@ -4325,11 +4325,11 @@ public class ActivityManagerService extends IActivityManager.Stub intent.putExtra(Intent.EXTRA_PACKAGE_NAME, packageName); broadcastIntentInPackage("android", null, SYSTEM_UID, uid, pid, intent, null, null, 0, null, null, permission.ACCESS_INSTANT_APPS, null, false, false, resolvedUserId, false); false, false, resolvedUserId, false, null); } else { broadcastIntentInPackage("android", null, SYSTEM_UID, uid, pid, intent, null, null, 0, null, null, null, null, false, false, resolvedUserId, false); false, null); } if (observer != null) { Loading Loading @@ -15713,7 +15713,7 @@ public class ActivityManagerService extends IActivityManager.Stub BroadcastQueue queue = broadcastQueueForIntent(intent); BroadcastRecord r = new BroadcastRecord(queue, intent, null, null, null, -1, -1, false, null, null, OP_NONE, null, receivers, null, 0, null, null, false, true, true, -1, false, 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(); Loading Loading @@ -15960,7 +15960,7 @@ public class ActivityManagerService extends IActivityManager.Stub resolvedType, resultTo, resultCode, resultData, resultExtras, requiredPermissions, appOp, bOptions, ordered, sticky, callingPid, callingUid, realCallingUid, realCallingPid, userId, false /* allowBackgroundActivityStarts */, null /*broadcastWhitelist*/); null /* tokenNeededForBackgroundActivityStarts */, null /* broadcastWhitelist */); } @GuardedBy("this") Loading @@ -15970,6 +15970,7 @@ public class ActivityManagerService extends IActivityManager.Stub Bundle resultExtras, String[] requiredPermissions, int appOp, Bundle bOptions, boolean ordered, boolean sticky, int callingPid, int callingUid, int realCallingUid, int realCallingPid, int userId, boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken, @Nullable int[] broadcastWhitelist) { intent = new Intent(intent); Loading Loading @@ -16060,6 +16061,8 @@ public class ActivityManagerService extends IActivityManager.Stub throw new SecurityException(msg); } else { allowBackgroundActivityStarts = true; // We set the token to null since if it wasn't for it we'd allow anyway here backgroundActivityStartsToken = null; } } } Loading Loading @@ -16528,7 +16531,8 @@ public class ActivityManagerService extends IActivityManager.Stub callerFeatureId, callingPid, callingUid, callerInstantApp, resolvedType, requiredPermissions, appOp, brOptions, registeredReceivers, resultTo, resultCode, resultData, resultExtras, ordered, sticky, false, userId, allowBackgroundActivityStarts, timeoutExempt); allowBackgroundActivityStarts, backgroundActivityStartsToken, timeoutExempt); if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "Enqueueing parallel broadcast " + r); final boolean replaced = replacePending && (queue.replaceParallelBroadcastLocked(r) != null); Loading Loading @@ -16625,7 +16629,8 @@ public class ActivityManagerService extends IActivityManager.Stub callerFeatureId, callingPid, callingUid, callerInstantApp, resolvedType, requiredPermissions, appOp, brOptions, receivers, resultTo, resultCode, resultData, resultExtras, ordered, sticky, false, userId, allowBackgroundActivityStarts, timeoutExempt); allowBackgroundActivityStarts, backgroundActivityStartsToken, timeoutExempt); if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "Enqueueing ordered broadcast " + r); Loading Loading @@ -16785,7 +16790,8 @@ public class ActivityManagerService extends IActivityManager.Stub int realCallingUid, int realCallingPid, Intent intent, String resolvedType, IIntentReceiver resultTo, int resultCode, String resultData, Bundle resultExtras, String requiredPermission, Bundle bOptions, boolean serialized, boolean sticky, int userId, boolean allowBackgroundActivityStarts) { int userId, boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken) { synchronized(this) { intent = verifyBroadcastLocked(intent); Loading @@ -16797,6 +16803,7 @@ public class ActivityManagerService extends IActivityManager.Stub resultTo, resultCode, resultData, resultExtras, requiredPermissions, OP_NONE, bOptions, serialized, sticky, -1, uid, realCallingUid, realCallingPid, userId, allowBackgroundActivityStarts, backgroundActivityStartsToken, null /*broadcastWhitelist*/); } finally { Binder.restoreCallingIdentity(origId); Loading Loading @@ -19487,12 +19494,14 @@ public class ActivityManagerService extends IActivityManager.Stub int realCallingUid, int realCallingPid, Intent intent, String resolvedType, IIntentReceiver resultTo, int resultCode, String resultData, Bundle resultExtras, String requiredPermission, Bundle bOptions, boolean serialized, boolean sticky, int userId, boolean allowBackgroundActivityStarts) { int userId, boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken) { synchronized (ActivityManagerService.this) { return ActivityManagerService.this.broadcastIntentInPackage(packageName, featureId, uid, realCallingUid, realCallingPid, intent, resolvedType, resultTo, resultCode, resultData, resultExtras, requiredPermission, bOptions, serialized, sticky, userId, allowBackgroundActivityStarts); serialized, sticky, userId, allowBackgroundActivityStarts, backgroundActivityStartsToken); } } Loading @@ -19514,6 +19523,7 @@ public class ActivityManagerService extends IActivityManager.Stub null /*resultExtras*/, requiredPermissions, AppOpsManager.OP_NONE, null /*options*/, serialized, false /*sticky*/, callingPid, callingUid, callingUid, callingPid, userId, false /*allowBackgroundStarts*/, null /*tokenNeededForBackgroundActivityStarts*/, appIdWhitelist); } finally { Binder.restoreCallingIdentity(origId); Loading @@ -19525,7 +19535,8 @@ public class ActivityManagerService extends IActivityManager.Stub @Override public ComponentName startServiceInPackage(int uid, Intent service, String resolvedType, boolean fgRequired, String callingPackage, @Nullable String callingFeatureId, int userId, boolean allowBackgroundActivityStarts) int userId, boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken) throws TransactionTooLargeException { synchronized(ActivityManagerService.this) { if (DEBUG_SERVICE) Slog.v(TAG_SERVICE,
services/core/java/com/android/server/am/BroadcastQueue.java +1 −1 Original line number Diff line number Diff line Loading @@ -1677,7 +1677,7 @@ public final class BroadcastQueue { // that request - we don't want the token to be swept from under our feet... mHandler.removeCallbacksAndMessages(msgToken); // ...then add the token proc.addAllowBackgroundActivityStartsToken(r); proc.addAllowBackgroundActivityStartsToken(r, r.mBackgroundActivityStartsToken); } final void setBroadcastTimeoutLocked(long timeoutTime) { Loading
services/core/java/com/android/server/am/BroadcastRecord.java +10 −4 Original line number Diff line number Diff line Loading @@ -92,6 +92,9 @@ final class BroadcastRecord extends Binder { // if set to true, app's process will be temporarily allowed to start activities from background // for the duration of the broadcast dispatch final boolean allowBackgroundActivityStarts; // token used to trace back the grant for activity starts, optional @Nullable final IBinder mBackgroundActivityStartsToken; static final int IDLE = 0; static final int APP_RECEIVE = 1; Loading Loading @@ -240,7 +243,8 @@ final class BroadcastRecord extends Binder { String[] _requiredPermissions, int _appOp, BroadcastOptions _options, List _receivers, IIntentReceiver _resultTo, int _resultCode, String _resultData, Bundle _resultExtras, boolean _serialized, boolean _sticky, boolean _initialSticky, int _userId, boolean _allowBackgroundActivityStarts, boolean _timeoutExempt) { boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken, boolean timeoutExempt) { if (_intent == null) { throw new NullPointerException("Can't construct with a null intent"); } Loading Loading @@ -270,8 +274,9 @@ final class BroadcastRecord extends Binder { userId = _userId; nextReceiver = 0; state = IDLE; allowBackgroundActivityStarts = _allowBackgroundActivityStarts; timeoutExempt = _timeoutExempt; this.allowBackgroundActivityStarts = allowBackgroundActivityStarts; mBackgroundActivityStartsToken = backgroundActivityStartsToken; this.timeoutExempt = timeoutExempt; } /** Loading Loading @@ -317,6 +322,7 @@ final class BroadcastRecord extends Binder { manifestSkipCount = from.manifestSkipCount; queue = from.queue; allowBackgroundActivityStarts = from.allowBackgroundActivityStarts; mBackgroundActivityStartsToken = from.mBackgroundActivityStartsToken; timeoutExempt = from.timeoutExempt; } Loading Loading @@ -352,7 +358,7 @@ final class BroadcastRecord extends Binder { callerFeatureId, callingPid, callingUid, callerInstantApp, resolvedType, requiredPermissions, appOp, options, splitReceivers, resultTo, resultCode, resultData, resultExtras, ordered, sticky, initialSticky, userId, allowBackgroundActivityStarts, timeoutExempt); allowBackgroundActivityStarts, mBackgroundActivityStartsToken, timeoutExempt); split.splitToken = this.splitToken; return split; Loading