Loading core/java/android/app/ActivityOptions.java +5 −5 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ import java.util.ArrayList; * {@link android.content.Context#startActivity(android.content.Intent, android.os.Bundle) * Context.startActivity(Intent, Bundle)} and related methods. */ public class ActivityOptions { public class ActivityOptions extends ComponentOptions { private static final String TAG = "ActivityOptions"; /** Loading Loading @@ -963,13 +963,12 @@ public class ActivityOptions { } private ActivityOptions() { super(); } /** @hide */ public ActivityOptions(Bundle opts) { // If the remote side sent us bad parcelables, they won't get the // results they want, which is their loss. opts.setDefusable(true); super(opts); mPackageName = opts.getString(KEY_PACKAGE_NAME); try { Loading Loading @@ -1575,8 +1574,9 @@ public class ActivityOptions { * object; you must not modify it, but can supply it to the startActivity * methods that take an options Bundle. */ @Override public Bundle toBundle() { Bundle b = new Bundle(); Bundle b = super.toBundle(); if (mPackageName != null) { b.putString(KEY_PACKAGE_NAME, mPackageName); } Loading core/java/android/app/BroadcastOptions.java +23 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ import android.os.Bundle; * {@hide} */ @SystemApi public class BroadcastOptions { public class BroadcastOptions extends ComponentOptions { private long mTemporaryAppWhitelistDuration; private int mMinManifestReceiverApiLevel = 0; private int mMaxManifestReceiverApiLevel = Build.VERSION_CODES.CUR_DEVELOPMENT; Loading Loading @@ -72,10 +72,12 @@ public class BroadcastOptions { } private BroadcastOptions() { super(); } /** @hide */ public BroadcastOptions(Bundle opts) { super(opts); mTemporaryAppWhitelistDuration = opts.getLong(KEY_TEMPORARY_APP_WHITELIST_DURATION); mMinManifestReceiverApiLevel = opts.getInt(KEY_MIN_MANIFEST_RECEIVER_API_LEVEL, 0); mMaxManifestReceiverApiLevel = opts.getInt(KEY_MAX_MANIFEST_RECEIVER_API_LEVEL, Loading Loading @@ -173,6 +175,24 @@ public class BroadcastOptions { return mAllowBackgroundActivityStarts; } /** * Set PendingIntent activity is allowed to be started in the background if the caller * can start background activities. * @hide */ public void setPendingIntentBackgroundActivityLaunchAllowed(boolean allowed) { super.setPendingIntentBackgroundActivityLaunchAllowed(allowed); } /** * Get PendingIntent activity is allowed to be started in the background if the caller * can start background activities. * @hide */ public boolean isPendingIntentBackgroundActivityLaunchAllowed() { return super.isPendingIntentBackgroundActivityLaunchAllowed(); } /** * Returns the created options as a Bundle, which can be passed to * {@link android.content.Context#sendBroadcast(android.content.Intent) Loading @@ -181,8 +201,9 @@ public class BroadcastOptions { * object; you must not modify it, but can supply it to the sendBroadcast * methods that take an options Bundle. */ @Override public Bundle toBundle() { Bundle b = new Bundle(); Bundle b = super.toBundle(); if (mTemporaryAppWhitelistDuration > 0) { b.putLong(KEY_TEMPORARY_APP_WHITELIST_DURATION, mTemporaryAppWhitelistDuration); } Loading core/java/android/app/ComponentOptions.java 0 → 100644 +84 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app; import android.os.Bundle; /** * @hide */ public class ComponentOptions { /** * Default value for KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED. * @hide **/ public static final boolean PENDING_INTENT_BAL_ALLOWED_DEFAULT = true; /** * PendingIntent caller allows activity start even if PendingIntent creator is in background. * This only works if the PendingIntent caller is allowed to start background activities, * for example if it's in the foreground, or has BAL permission. * @hide */ public static final String KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED = "android.pendingIntent.backgroundActivityAllowed"; private boolean mPendingIntentBalAllowed = PENDING_INTENT_BAL_ALLOWED_DEFAULT; ComponentOptions() { } ComponentOptions(Bundle opts) { // If the remote side sent us bad parcelables, they won't get the // results they want, which is their loss. opts.setDefusable(true); setPendingIntentBackgroundActivityLaunchAllowed( opts.getBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED, PENDING_INTENT_BAL_ALLOWED_DEFAULT)); } /** * Set PendingIntent activity is allowed to be started in the background if the caller * can start background activities. * * @hide */ public void setPendingIntentBackgroundActivityLaunchAllowed(boolean allowed) { mPendingIntentBalAllowed = allowed; } /** * Get PendingIntent activity is allowed to be started in the background if the caller * can start background activities. * * @hide */ public boolean isPendingIntentBackgroundActivityLaunchAllowed() { return mPendingIntentBalAllowed; } /** * @hide */ public Bundle toBundle() { Bundle bundle = new Bundle(); bundle.putBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED, mPendingIntentBalAllowed); return bundle; } } core/java/android/content/Intent.java +1 −1 Original line number Diff line number Diff line Loading @@ -10750,7 +10750,7 @@ public class Intent implements Parcelable, Cloneable { private void toUriInner(StringBuilder uri, String scheme, String defAction, String defPackage, int flags) { if (scheme != null) { uri.append("scheme=").append(scheme).append(';'); uri.append("scheme=").append(Uri.encode(scheme)).append(';'); } if (mAction != null && !mAction.equals(defAction)) { uri.append("action=").append(Uri.encode(mAction)).append(';'); Loading core/java/android/content/IntentSender.java +40 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,9 @@ package android.content; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.ActivityOptions; import android.compat.annotation.UnsupportedAppUsage; import android.os.Bundle; import android.os.Handler; Loading Loading @@ -154,7 +156,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); sendIntent(context, code, intent, onFinished, handler, null, null /* options */); } /** Loading Loading @@ -186,6 +188,42 @@ public class IntentSender implements Parcelable { public void sendIntent(Context context, int code, Intent intent, OnFinished onFinished, Handler handler, String requiredPermission) throws SendIntentException { sendIntent(context, code, intent, onFinished, handler, requiredPermission, null /* options */); } /** * Perform the operation associated with this IntentSender, allowing the * caller to specify information about the Intent to use and be notified * when the send has completed. * * @param context The Context of the caller. This may be null if * <var>intent</var> is also null. * @param code Result code to supply back to the IntentSender's target. * @param intent Additional Intent data. See {@link Intent#fillIn * Intent.fillIn()} for information on how this is applied to the * original Intent. Use null to not modify the original Intent. * @param onFinished The object to call back on when the send has * completed, or null for no callback. * @param handler Handler identifying the thread on which the callback * should happen. If null, the callback will happen from the thread * pool of the process. * @param requiredPermission Name of permission that a recipient of the PendingIntent * is required to hold. This is only valid for broadcast intents, and * corresponds to the permission argument in * {@link Context#sendBroadcast(Intent, String) Context.sendOrderedBroadcast(Intent, String)}. * If null, no permission is required. * @param options Additional options the caller would like to provide to modify the sending * behavior. May be built from an {@link ActivityOptions} to apply to an activity start. * * @throws SendIntentException Throws CanceledIntentException if the IntentSender * is no longer allowing more intents to be sent through it. * @hide */ public void sendIntent(Context context, int code, Intent intent, OnFinished onFinished, Handler handler, String requiredPermission, @Nullable Bundle options) throws SendIntentException { try { String resolvedType = intent != null ? intent.resolveTypeIfNeeded(context.getContentResolver()) Loading @@ -195,7 +233,7 @@ public class IntentSender implements Parcelable { onFinished != null ? new FinishedDispatcher(this, onFinished, handler) : null, requiredPermission, null); requiredPermission, options); if (res < 0) { throw new SendIntentException(); } Loading Loading
core/java/android/app/ActivityOptions.java +5 −5 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ import java.util.ArrayList; * {@link android.content.Context#startActivity(android.content.Intent, android.os.Bundle) * Context.startActivity(Intent, Bundle)} and related methods. */ public class ActivityOptions { public class ActivityOptions extends ComponentOptions { private static final String TAG = "ActivityOptions"; /** Loading Loading @@ -963,13 +963,12 @@ public class ActivityOptions { } private ActivityOptions() { super(); } /** @hide */ public ActivityOptions(Bundle opts) { // If the remote side sent us bad parcelables, they won't get the // results they want, which is their loss. opts.setDefusable(true); super(opts); mPackageName = opts.getString(KEY_PACKAGE_NAME); try { Loading Loading @@ -1575,8 +1574,9 @@ public class ActivityOptions { * object; you must not modify it, but can supply it to the startActivity * methods that take an options Bundle. */ @Override public Bundle toBundle() { Bundle b = new Bundle(); Bundle b = super.toBundle(); if (mPackageName != null) { b.putString(KEY_PACKAGE_NAME, mPackageName); } Loading
core/java/android/app/BroadcastOptions.java +23 −2 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ import android.os.Bundle; * {@hide} */ @SystemApi public class BroadcastOptions { public class BroadcastOptions extends ComponentOptions { private long mTemporaryAppWhitelistDuration; private int mMinManifestReceiverApiLevel = 0; private int mMaxManifestReceiverApiLevel = Build.VERSION_CODES.CUR_DEVELOPMENT; Loading Loading @@ -72,10 +72,12 @@ public class BroadcastOptions { } private BroadcastOptions() { super(); } /** @hide */ public BroadcastOptions(Bundle opts) { super(opts); mTemporaryAppWhitelistDuration = opts.getLong(KEY_TEMPORARY_APP_WHITELIST_DURATION); mMinManifestReceiverApiLevel = opts.getInt(KEY_MIN_MANIFEST_RECEIVER_API_LEVEL, 0); mMaxManifestReceiverApiLevel = opts.getInt(KEY_MAX_MANIFEST_RECEIVER_API_LEVEL, Loading Loading @@ -173,6 +175,24 @@ public class BroadcastOptions { return mAllowBackgroundActivityStarts; } /** * Set PendingIntent activity is allowed to be started in the background if the caller * can start background activities. * @hide */ public void setPendingIntentBackgroundActivityLaunchAllowed(boolean allowed) { super.setPendingIntentBackgroundActivityLaunchAllowed(allowed); } /** * Get PendingIntent activity is allowed to be started in the background if the caller * can start background activities. * @hide */ public boolean isPendingIntentBackgroundActivityLaunchAllowed() { return super.isPendingIntentBackgroundActivityLaunchAllowed(); } /** * Returns the created options as a Bundle, which can be passed to * {@link android.content.Context#sendBroadcast(android.content.Intent) Loading @@ -181,8 +201,9 @@ public class BroadcastOptions { * object; you must not modify it, but can supply it to the sendBroadcast * methods that take an options Bundle. */ @Override public Bundle toBundle() { Bundle b = new Bundle(); Bundle b = super.toBundle(); if (mTemporaryAppWhitelistDuration > 0) { b.putLong(KEY_TEMPORARY_APP_WHITELIST_DURATION, mTemporaryAppWhitelistDuration); } Loading
core/java/android/app/ComponentOptions.java 0 → 100644 +84 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app; import android.os.Bundle; /** * @hide */ public class ComponentOptions { /** * Default value for KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED. * @hide **/ public static final boolean PENDING_INTENT_BAL_ALLOWED_DEFAULT = true; /** * PendingIntent caller allows activity start even if PendingIntent creator is in background. * This only works if the PendingIntent caller is allowed to start background activities, * for example if it's in the foreground, or has BAL permission. * @hide */ public static final String KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED = "android.pendingIntent.backgroundActivityAllowed"; private boolean mPendingIntentBalAllowed = PENDING_INTENT_BAL_ALLOWED_DEFAULT; ComponentOptions() { } ComponentOptions(Bundle opts) { // If the remote side sent us bad parcelables, they won't get the // results they want, which is their loss. opts.setDefusable(true); setPendingIntentBackgroundActivityLaunchAllowed( opts.getBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED, PENDING_INTENT_BAL_ALLOWED_DEFAULT)); } /** * Set PendingIntent activity is allowed to be started in the background if the caller * can start background activities. * * @hide */ public void setPendingIntentBackgroundActivityLaunchAllowed(boolean allowed) { mPendingIntentBalAllowed = allowed; } /** * Get PendingIntent activity is allowed to be started in the background if the caller * can start background activities. * * @hide */ public boolean isPendingIntentBackgroundActivityLaunchAllowed() { return mPendingIntentBalAllowed; } /** * @hide */ public Bundle toBundle() { Bundle bundle = new Bundle(); bundle.putBoolean(KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED, mPendingIntentBalAllowed); return bundle; } }
core/java/android/content/Intent.java +1 −1 Original line number Diff line number Diff line Loading @@ -10750,7 +10750,7 @@ public class Intent implements Parcelable, Cloneable { private void toUriInner(StringBuilder uri, String scheme, String defAction, String defPackage, int flags) { if (scheme != null) { uri.append("scheme=").append(scheme).append(';'); uri.append("scheme=").append(Uri.encode(scheme)).append(';'); } if (mAction != null && !mAction.equals(defAction)) { uri.append("action=").append(Uri.encode(mAction)).append(';'); Loading
core/java/android/content/IntentSender.java +40 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,9 @@ package android.content; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.ActivityOptions; import android.compat.annotation.UnsupportedAppUsage; import android.os.Bundle; import android.os.Handler; Loading Loading @@ -154,7 +156,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); sendIntent(context, code, intent, onFinished, handler, null, null /* options */); } /** Loading Loading @@ -186,6 +188,42 @@ public class IntentSender implements Parcelable { public void sendIntent(Context context, int code, Intent intent, OnFinished onFinished, Handler handler, String requiredPermission) throws SendIntentException { sendIntent(context, code, intent, onFinished, handler, requiredPermission, null /* options */); } /** * Perform the operation associated with this IntentSender, allowing the * caller to specify information about the Intent to use and be notified * when the send has completed. * * @param context The Context of the caller. This may be null if * <var>intent</var> is also null. * @param code Result code to supply back to the IntentSender's target. * @param intent Additional Intent data. See {@link Intent#fillIn * Intent.fillIn()} for information on how this is applied to the * original Intent. Use null to not modify the original Intent. * @param onFinished The object to call back on when the send has * completed, or null for no callback. * @param handler Handler identifying the thread on which the callback * should happen. If null, the callback will happen from the thread * pool of the process. * @param requiredPermission Name of permission that a recipient of the PendingIntent * is required to hold. This is only valid for broadcast intents, and * corresponds to the permission argument in * {@link Context#sendBroadcast(Intent, String) Context.sendOrderedBroadcast(Intent, String)}. * If null, no permission is required. * @param options Additional options the caller would like to provide to modify the sending * behavior. May be built from an {@link ActivityOptions} to apply to an activity start. * * @throws SendIntentException Throws CanceledIntentException if the IntentSender * is no longer allowing more intents to be sent through it. * @hide */ public void sendIntent(Context context, int code, Intent intent, OnFinished onFinished, Handler handler, String requiredPermission, @Nullable Bundle options) throws SendIntentException { try { String resolvedType = intent != null ? intent.resolveTypeIfNeeded(context.getContentResolver()) Loading @@ -195,7 +233,7 @@ public class IntentSender implements Parcelable { onFinished != null ? new FinishedDispatcher(this, onFinished, handler) : null, requiredPermission, null); requiredPermission, options); if (res < 0) { throw new SendIntentException(); } Loading