Skip to content
Snippets Groups Projects
Commit e2b06285 authored by Achim Thesmann's avatar Achim Thesmann Committed by Android (Google) Code Review
Browse files

Merge "Revert^2 "Check Bundle when creating/sending a PendingIntent"" into main

parents 83b7e101 028210ad
No related branches found
No related tags found
No related merge requests found
......@@ -179,6 +179,14 @@ public final class PendingIntent implements Parcelable {
@Overridable
public static final long BLOCK_MUTABLE_IMPLICIT_PENDING_INTENT = 236704164L;
/**
* Validate options passed in as bundle.
* @hide
*/
@ChangeId
@EnabledAfter(targetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
public static final long PENDING_INTENT_OPTIONS_CHECK = 320664730L;
/** @hide */
@IntDef(flag = true,
value = {
......
......@@ -30,6 +30,7 @@ import android.app.ActivityOptions;
import android.app.AppGlobals;
import android.app.PendingIntent;
import android.app.PendingIntentStats;
import android.app.compat.CompatChanges;
import android.content.IIntentSender;
import android.content.Intent;
import android.os.Binder;
......@@ -136,6 +137,11 @@ public class PendingIntentController {
+ "intent creator ("
+ packageName
+ ") because this option is meant for the pending intent sender");
if (CompatChanges.isChangeEnabled(PendingIntent.PENDING_INTENT_OPTIONS_CHECK,
callingUid)) {
throw new IllegalArgumentException("pendingIntentBackgroundActivityStartMode "
+ "must not be set when creating a PendingIntent");
}
opts.setPendingIntentBackgroundActivityStartMode(
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED);
}
......
......@@ -406,6 +406,9 @@ public final class PendingIntentRecord extends IIntentSender.Stub {
String resolvedType, IBinder allowlistToken, IIntentReceiver finishedReceiver,
String requiredPermission, IBinder resultTo, String resultWho, int requestCode,
int flagsMask, int flagsValues, Bundle options) {
final int callingUid = Binder.getCallingUid();
final int callingPid = Binder.getCallingPid();
if (intent != null) intent.setDefusable(true);
if (options != null) options.setDefusable(true);
......@@ -458,6 +461,12 @@ public final class PendingIntentRecord extends IIntentSender.Stub {
+ key.packageName
+ ") because this option is meant for the pending intent "
+ "creator");
if (CompatChanges.isChangeEnabled(PendingIntent.PENDING_INTENT_OPTIONS_CHECK,
callingUid)) {
throw new IllegalArgumentException(
"pendingIntentCreatorBackgroundActivityStartMode "
+ "must not be set when sending a PendingIntent");
}
opts.setPendingIntentCreatorBackgroundActivityStartMode(
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED);
}
......@@ -494,9 +503,6 @@ public final class PendingIntentRecord extends IIntentSender.Stub {
}
// We don't hold the controller lock beyond this point as we will be calling into AM and WM.
final int callingUid = Binder.getCallingUid();
final int callingPid = Binder.getCallingPid();
// Only system senders can declare a broadcast to be alarm-originated. We check
// this here rather than in the general case handling below to fail before the other
// invocation side effects such as allowlisting.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment