Loading core/java/android/app/ActivityOptions.java +1 −9 Original line number Diff line number Diff line Loading @@ -103,8 +103,7 @@ public class ActivityOptions extends ComponentOptions { @IntDef(prefix = {"MODE_BACKGROUND_ACTIVITY_START_"}, value = { MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED, MODE_BACKGROUND_ACTIVITY_START_ALLOWED, MODE_BACKGROUND_ACTIVITY_START_DENIED, MODE_BACKGROUND_ACTIVITY_START_COMPAT}) MODE_BACKGROUND_ACTIVITY_START_DENIED}) public @interface BackgroundActivityStartMode {} /** * No explicit value chosen. The system will decide whether to grant privileges. Loading @@ -118,13 +117,6 @@ public class ActivityOptions extends ComponentOptions { * Deny the {@link PendingIntent} to use the background activity start privileges. */ public static final int MODE_BACKGROUND_ACTIVITY_START_DENIED = 2; /** * Special behavior for compatibility. * Similar to {@link #MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED} * * @hide */ public static final int MODE_BACKGROUND_ACTIVITY_START_COMPAT = -1; /** * The package name that created the options. Loading core/java/android/app/ComponentOptions.java +29 −18 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package android.app; import static android.app.ActivityOptions.BackgroundActivityStartMode; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_COMPAT; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_DENIED; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED; Loading Loading @@ -55,7 +54,7 @@ public class ComponentOptions { public static final String KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED_BY_PERMISSION = "android.pendingIntent.backgroundActivityAllowedByPermission"; private Integer mPendingIntentBalAllowed = MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED; private @Nullable Boolean mPendingIntentBalAllowed = null; private boolean mPendingIntentBalAllowedByPermission = false; ComponentOptions() { Loading @@ -66,9 +65,12 @@ public class ComponentOptions { // results they want, which is their loss. opts.setDefusable(true); boolean pendingIntentBalAllowedIsSetExplicitly = opts.containsKey(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED); if (pendingIntentBalAllowedIsSetExplicitly) { mPendingIntentBalAllowed = opts.getInt(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED, MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED); opts.getBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED); } setPendingIntentBackgroundActivityLaunchAllowedByPermission( opts.getBoolean( KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED_BY_PERMISSION, false)); Loading @@ -83,8 +85,7 @@ public class ComponentOptions { * @hide */ @Deprecated public void setPendingIntentBackgroundActivityLaunchAllowed(boolean allowed) { mPendingIntentBalAllowed = allowed ? MODE_BACKGROUND_ACTIVITY_START_ALLOWED : MODE_BACKGROUND_ACTIVITY_START_DENIED; mPendingIntentBalAllowed = allowed; } /** Loading @@ -97,8 +98,11 @@ public class ComponentOptions { * @hide */ @Deprecated public boolean isPendingIntentBackgroundActivityLaunchAllowed() { // cannot return all detail, so return the value used up to API level 33 for compatibility return mPendingIntentBalAllowed != MODE_BACKGROUND_ACTIVITY_START_DENIED; if (mPendingIntentBalAllowed == null) { // cannot return null, so return the value used up to API level 33 for compatibility return true; } return mPendingIntentBalAllowed; } /** Loading @@ -115,15 +119,16 @@ public class ComponentOptions { @BackgroundActivityStartMode int state) { switch (state) { case MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED: case MODE_BACKGROUND_ACTIVITY_START_DENIED: case MODE_BACKGROUND_ACTIVITY_START_COMPAT: mPendingIntentBalAllowed = null; break; case MODE_BACKGROUND_ACTIVITY_START_ALLOWED: mPendingIntentBalAllowed = state; mPendingIntentBalAllowed = true; break; default: // Assume that future values are some variant of allowing the start. mPendingIntentBalAllowed = MODE_BACKGROUND_ACTIVITY_START_ALLOWED; case MODE_BACKGROUND_ACTIVITY_START_DENIED: mPendingIntentBalAllowed = false; break; default: throw new IllegalArgumentException(state + " is not valid"); } return this; } Loading @@ -136,7 +141,13 @@ public class ComponentOptions { * @see #setPendingIntentBackgroundActivityStartMode(int) */ public @BackgroundActivityStartMode int getPendingIntentBackgroundActivityStartMode() { return mPendingIntentBalAllowed; if (mPendingIntentBalAllowed == null) { return MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED; } else if (mPendingIntentBalAllowed) { return MODE_BACKGROUND_ACTIVITY_START_ALLOWED; } else { return MODE_BACKGROUND_ACTIVITY_START_DENIED; } } /** Loading @@ -159,8 +170,8 @@ public class ComponentOptions { /** @hide */ public Bundle toBundle() { Bundle b = new Bundle(); if (mPendingIntentBalAllowed != MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED) { b.putInt(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED, mPendingIntentBalAllowed); if (mPendingIntentBalAllowed != null) { b.putBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED, mPendingIntentBalAllowed); } if (mPendingIntentBalAllowedByPermission) { b.putBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED_BY_PERMISSION, Loading core/java/android/content/IntentSender.java +2 −7 Original line number Diff line number Diff line Loading @@ -60,10 +60,6 @@ import android.util.AndroidException; * {@link android.app.PendingIntent#getIntentSender() PendingIntent.getIntentSender()}. */ public class IntentSender implements Parcelable { private static final Bundle SEND_INTENT_DEFAULT_OPTIONS = ActivityOptions.makeBasic().setPendingIntentBackgroundActivityStartMode( ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_COMPAT).toBundle(); @UnsupportedAppUsage private final IIntentSender mTarget; IBinder mWhitelistToken; Loading Loading @@ -165,8 +161,7 @@ public class IntentSender implements Parcelable { */ public void sendIntent(Context context, int code, Intent intent, OnFinished onFinished, Handler handler) throws SendIntentException { sendIntent(context, code, intent, onFinished, handler, null, SEND_INTENT_DEFAULT_OPTIONS); sendIntent(context, code, intent, onFinished, handler, null, null /* options */); } /** Loading Loading @@ -199,7 +194,7 @@ public class IntentSender implements Parcelable { OnFinished onFinished, Handler handler, String requiredPermission) throws SendIntentException { sendIntent(context, code, intent, onFinished, handler, requiredPermission, SEND_INTENT_DEFAULT_OPTIONS); null /* options */); } /** Loading services/core/java/com/android/server/am/PendingIntentRecord.java +5 −16 Original line number Diff line number Diff line Loading @@ -18,10 +18,6 @@ package com.android.server.am; import static android.app.ActivityManager.PROCESS_STATE_TOP; import static android.app.ActivityManager.START_SUCCESS; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_COMPAT; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_DENIED; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED; import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM; import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME; Loading Loading @@ -393,20 +389,13 @@ public final class PendingIntentRecord extends IIntentSender.Stub { private static BackgroundStartPrivileges getBackgroundStartPrivilegesAllowedByCaller( @Nullable Bundle options, int callingUid, @Nullable String callingPackage) { if (options == null) { if (options == null || !options.containsKey( ActivityOptions.KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED)) { return getDefaultBackgroundStartPrivileges(callingUid, callingPackage); } switch (options.getInt(ActivityOptions.KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED, MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED)) { case MODE_BACKGROUND_ACTIVITY_START_DENIED: return BackgroundStartPrivileges.NONE; case MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED: return getDefaultBackgroundStartPrivileges(callingUid, callingPackage); case MODE_BACKGROUND_ACTIVITY_START_ALLOWED: case MODE_BACKGROUND_ACTIVITY_START_COMPAT: default: return BackgroundStartPrivileges.ALLOW_BAL; } return options.getBoolean(ActivityOptions.KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED) ? BackgroundStartPrivileges.ALLOW_BAL : BackgroundStartPrivileges.NONE; } /** Loading services/core/java/com/android/server/wm/BackgroundActivityStartController.java +0 −6 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import static android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND; import static android.app.ActivityManager.PROCESS_STATE_NONEXISTENT; import static android.app.ActivityOptions.BackgroundActivityStartMode; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_COMPAT; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_DENIED; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; Loading Loading @@ -106,7 +105,6 @@ public class BackgroundActivityStartController { static final String AUTO_OPT_IN_NOT_PENDING_INTENT = "notPendingIntent"; static final String AUTO_OPT_IN_CALL_FOR_RESULT = "callForResult"; static final String AUTO_OPT_IN_SAME_UID = "sameUid"; static final String AUTO_OPT_IN_COMPAT = "compatibility"; /** If enabled the creator will not allow BAL on its behalf by default. */ @ChangeId Loading Loading @@ -305,10 +303,6 @@ public class BackgroundActivityStartController { } else if (callingUid == realCallingUid && !balRequireOptInSameUid()) { mAutoOptInReason = AUTO_OPT_IN_SAME_UID; mAutoOptInCaller = false; } else if (realCallerBackgroundActivityStartMode == MODE_BACKGROUND_ACTIVITY_START_COMPAT) { mAutoOptInReason = AUTO_OPT_IN_COMPAT; mAutoOptInCaller = false; } else { mAutoOptInReason = null; mAutoOptInCaller = false; Loading Loading
core/java/android/app/ActivityOptions.java +1 −9 Original line number Diff line number Diff line Loading @@ -103,8 +103,7 @@ public class ActivityOptions extends ComponentOptions { @IntDef(prefix = {"MODE_BACKGROUND_ACTIVITY_START_"}, value = { MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED, MODE_BACKGROUND_ACTIVITY_START_ALLOWED, MODE_BACKGROUND_ACTIVITY_START_DENIED, MODE_BACKGROUND_ACTIVITY_START_COMPAT}) MODE_BACKGROUND_ACTIVITY_START_DENIED}) public @interface BackgroundActivityStartMode {} /** * No explicit value chosen. The system will decide whether to grant privileges. Loading @@ -118,13 +117,6 @@ public class ActivityOptions extends ComponentOptions { * Deny the {@link PendingIntent} to use the background activity start privileges. */ public static final int MODE_BACKGROUND_ACTIVITY_START_DENIED = 2; /** * Special behavior for compatibility. * Similar to {@link #MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED} * * @hide */ public static final int MODE_BACKGROUND_ACTIVITY_START_COMPAT = -1; /** * The package name that created the options. Loading
core/java/android/app/ComponentOptions.java +29 −18 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package android.app; import static android.app.ActivityOptions.BackgroundActivityStartMode; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_COMPAT; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_DENIED; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED; Loading Loading @@ -55,7 +54,7 @@ public class ComponentOptions { public static final String KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED_BY_PERMISSION = "android.pendingIntent.backgroundActivityAllowedByPermission"; private Integer mPendingIntentBalAllowed = MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED; private @Nullable Boolean mPendingIntentBalAllowed = null; private boolean mPendingIntentBalAllowedByPermission = false; ComponentOptions() { Loading @@ -66,9 +65,12 @@ public class ComponentOptions { // results they want, which is their loss. opts.setDefusable(true); boolean pendingIntentBalAllowedIsSetExplicitly = opts.containsKey(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED); if (pendingIntentBalAllowedIsSetExplicitly) { mPendingIntentBalAllowed = opts.getInt(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED, MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED); opts.getBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED); } setPendingIntentBackgroundActivityLaunchAllowedByPermission( opts.getBoolean( KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED_BY_PERMISSION, false)); Loading @@ -83,8 +85,7 @@ public class ComponentOptions { * @hide */ @Deprecated public void setPendingIntentBackgroundActivityLaunchAllowed(boolean allowed) { mPendingIntentBalAllowed = allowed ? MODE_BACKGROUND_ACTIVITY_START_ALLOWED : MODE_BACKGROUND_ACTIVITY_START_DENIED; mPendingIntentBalAllowed = allowed; } /** Loading @@ -97,8 +98,11 @@ public class ComponentOptions { * @hide */ @Deprecated public boolean isPendingIntentBackgroundActivityLaunchAllowed() { // cannot return all detail, so return the value used up to API level 33 for compatibility return mPendingIntentBalAllowed != MODE_BACKGROUND_ACTIVITY_START_DENIED; if (mPendingIntentBalAllowed == null) { // cannot return null, so return the value used up to API level 33 for compatibility return true; } return mPendingIntentBalAllowed; } /** Loading @@ -115,15 +119,16 @@ public class ComponentOptions { @BackgroundActivityStartMode int state) { switch (state) { case MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED: case MODE_BACKGROUND_ACTIVITY_START_DENIED: case MODE_BACKGROUND_ACTIVITY_START_COMPAT: mPendingIntentBalAllowed = null; break; case MODE_BACKGROUND_ACTIVITY_START_ALLOWED: mPendingIntentBalAllowed = state; mPendingIntentBalAllowed = true; break; default: // Assume that future values are some variant of allowing the start. mPendingIntentBalAllowed = MODE_BACKGROUND_ACTIVITY_START_ALLOWED; case MODE_BACKGROUND_ACTIVITY_START_DENIED: mPendingIntentBalAllowed = false; break; default: throw new IllegalArgumentException(state + " is not valid"); } return this; } Loading @@ -136,7 +141,13 @@ public class ComponentOptions { * @see #setPendingIntentBackgroundActivityStartMode(int) */ public @BackgroundActivityStartMode int getPendingIntentBackgroundActivityStartMode() { return mPendingIntentBalAllowed; if (mPendingIntentBalAllowed == null) { return MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED; } else if (mPendingIntentBalAllowed) { return MODE_BACKGROUND_ACTIVITY_START_ALLOWED; } else { return MODE_BACKGROUND_ACTIVITY_START_DENIED; } } /** Loading @@ -159,8 +170,8 @@ public class ComponentOptions { /** @hide */ public Bundle toBundle() { Bundle b = new Bundle(); if (mPendingIntentBalAllowed != MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED) { b.putInt(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED, mPendingIntentBalAllowed); if (mPendingIntentBalAllowed != null) { b.putBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED, mPendingIntentBalAllowed); } if (mPendingIntentBalAllowedByPermission) { b.putBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED_BY_PERMISSION, Loading
core/java/android/content/IntentSender.java +2 −7 Original line number Diff line number Diff line Loading @@ -60,10 +60,6 @@ import android.util.AndroidException; * {@link android.app.PendingIntent#getIntentSender() PendingIntent.getIntentSender()}. */ public class IntentSender implements Parcelable { private static final Bundle SEND_INTENT_DEFAULT_OPTIONS = ActivityOptions.makeBasic().setPendingIntentBackgroundActivityStartMode( ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_COMPAT).toBundle(); @UnsupportedAppUsage private final IIntentSender mTarget; IBinder mWhitelistToken; Loading Loading @@ -165,8 +161,7 @@ public class IntentSender implements Parcelable { */ public void sendIntent(Context context, int code, Intent intent, OnFinished onFinished, Handler handler) throws SendIntentException { sendIntent(context, code, intent, onFinished, handler, null, SEND_INTENT_DEFAULT_OPTIONS); sendIntent(context, code, intent, onFinished, handler, null, null /* options */); } /** Loading Loading @@ -199,7 +194,7 @@ public class IntentSender implements Parcelable { OnFinished onFinished, Handler handler, String requiredPermission) throws SendIntentException { sendIntent(context, code, intent, onFinished, handler, requiredPermission, SEND_INTENT_DEFAULT_OPTIONS); null /* options */); } /** Loading
services/core/java/com/android/server/am/PendingIntentRecord.java +5 −16 Original line number Diff line number Diff line Loading @@ -18,10 +18,6 @@ package com.android.server.am; import static android.app.ActivityManager.PROCESS_STATE_TOP; import static android.app.ActivityManager.START_SUCCESS; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_COMPAT; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_DENIED; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED; import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM; import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME; Loading Loading @@ -393,20 +389,13 @@ public final class PendingIntentRecord extends IIntentSender.Stub { private static BackgroundStartPrivileges getBackgroundStartPrivilegesAllowedByCaller( @Nullable Bundle options, int callingUid, @Nullable String callingPackage) { if (options == null) { if (options == null || !options.containsKey( ActivityOptions.KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED)) { return getDefaultBackgroundStartPrivileges(callingUid, callingPackage); } switch (options.getInt(ActivityOptions.KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED, MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED)) { case MODE_BACKGROUND_ACTIVITY_START_DENIED: return BackgroundStartPrivileges.NONE; case MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED: return getDefaultBackgroundStartPrivileges(callingUid, callingPackage); case MODE_BACKGROUND_ACTIVITY_START_ALLOWED: case MODE_BACKGROUND_ACTIVITY_START_COMPAT: default: return BackgroundStartPrivileges.ALLOW_BAL; } return options.getBoolean(ActivityOptions.KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED) ? BackgroundStartPrivileges.ALLOW_BAL : BackgroundStartPrivileges.NONE; } /** Loading
services/core/java/com/android/server/wm/BackgroundActivityStartController.java +0 −6 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import static android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND; import static android.app.ActivityManager.PROCESS_STATE_NONEXISTENT; import static android.app.ActivityOptions.BackgroundActivityStartMode; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_COMPAT; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_DENIED; import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; Loading Loading @@ -106,7 +105,6 @@ public class BackgroundActivityStartController { static final String AUTO_OPT_IN_NOT_PENDING_INTENT = "notPendingIntent"; static final String AUTO_OPT_IN_CALL_FOR_RESULT = "callForResult"; static final String AUTO_OPT_IN_SAME_UID = "sameUid"; static final String AUTO_OPT_IN_COMPAT = "compatibility"; /** If enabled the creator will not allow BAL on its behalf by default. */ @ChangeId Loading Loading @@ -305,10 +303,6 @@ public class BackgroundActivityStartController { } else if (callingUid == realCallingUid && !balRequireOptInSameUid()) { mAutoOptInReason = AUTO_OPT_IN_SAME_UID; mAutoOptInCaller = false; } else if (realCallerBackgroundActivityStartMode == MODE_BACKGROUND_ACTIVITY_START_COMPAT) { mAutoOptInReason = AUTO_OPT_IN_COMPAT; mAutoOptInCaller = false; } else { mAutoOptInReason = null; mAutoOptInCaller = false; Loading