From 9b9d10ff8951454bc0edc26ef029fffda0710a0a Mon Sep 17 00:00:00 2001 From: Ashwini Oruganti Date: Mon, 5 Oct 2020 11:50:03 -0700 Subject: [PATCH] Enforce that a PendingIntent has an explicit mutability flag on creation. This was previously a log.e, this change enforces this requirement except when an app is under instrumentation. See go/immutable-pendingintents for more context. Bug: 160794467 Test: atest PendingIntentTest Change-Id: I6506dd311f2e440ad74fdf4f5aa447ea471a02f4 --- core/java/android/app/PendingIntent.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/java/android/app/PendingIntent.java b/core/java/android/app/PendingIntent.java index 602e9a338febe..269ccb169774c 100644 --- a/core/java/android/app/PendingIntent.java +++ b/core/java/android/app/PendingIntent.java @@ -40,7 +40,6 @@ import android.os.RemoteException; import android.os.UserHandle; import android.util.AndroidException; import android.util.ArraySet; -import android.util.Log; import android.util.proto.ProtoOutputStream; import com.android.internal.os.IResultReceiver; @@ -108,7 +107,6 @@ import java.lang.annotation.RetentionPolicy; * FLAG_ONE_SHOT, both FLAG_ONE_SHOT and FLAG_NO_CREATE need to be supplied. */ public final class PendingIntent implements Parcelable { - private static final String TAG = "PendingIntent"; private final IIntentSender mTarget; private IResultReceiver mCancelReceiver; private IBinder mWhitelistToken; @@ -354,7 +352,7 @@ public final class PendingIntent implements Parcelable { if (Compatibility.isChangeEnabled(PENDING_INTENT_EXPLICIT_MUTABILITY_REQUIRED) && !flagImmutableSet && !flagMutableSet) { - Log.e(TAG, msg); + throw new IllegalArgumentException(msg); } }