From f4dc2d5f25bf7bc31abc2c9e588c84d6d9318fe3 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Fri, 23 Sep 2022 15:17:52 -0700 Subject: [PATCH] Add FLAG_IMMUTABLE to PendingIntents If your app targets Android 12, you must specify the mutability of each PendingIntent object that your app creates. This additional requirement improves your app's security. https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability Android Lint is being updated, and adds an error-level check for this. Bug: 247885568 Test: Presubmits Change-Id: I2bb91d98b443af2b5c16944ce197d863dbd33f9a --- .../src/com/android/development/SyncAdapterDriver.java | 2 +- .../src/com/example/android/sip/WalkieTalkieActivity.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/Development/src/com/android/development/SyncAdapterDriver.java b/apps/Development/src/com/android/development/SyncAdapterDriver.java index b11e7c7fd..2913a1c29 100644 --- a/apps/Development/src/com/android/development/SyncAdapterDriver.java +++ b/apps/Development/src/com/android/development/SyncAdapterDriver.java @@ -299,7 +299,7 @@ public class SyncAdapterDriver extends Activity intent.putExtra(Intent.EXTRA_CLIENT_LABEL, com.android.internal.R.string.sync_binding_label); intent.putExtra(Intent.EXTRA_CLIENT_INTENT, PendingIntent.getActivity( - this, 0, new Intent(Settings.ACTION_SYNC_SETTINGS), 0)); + this, 0, new Intent(Settings.ACTION_SYNC_SETTINGS), PendingIntent.FLAG_IMMUTABLE)); if (!bindService(intent, mActiveServiceConnection, Context.BIND_AUTO_CREATE)) { mBoundAdapterTextView.setText(getString(R.string.binding_bind_failed)); mActiveServiceConnection = null; diff --git a/samples/SipDemo/src/com/example/android/sip/WalkieTalkieActivity.java b/samples/SipDemo/src/com/example/android/sip/WalkieTalkieActivity.java index 4c187eddc..9996f01b3 100644 --- a/samples/SipDemo/src/com/example/android/sip/WalkieTalkieActivity.java +++ b/samples/SipDemo/src/com/example/android/sip/WalkieTalkieActivity.java @@ -137,7 +137,7 @@ public class WalkieTalkieActivity extends Activity implements View.OnTouchListen Intent i = new Intent(); i.setAction("android.SipDemo.INCOMING_CALL"); - PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, Intent.FILL_IN_DATA); + PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, Intent.FILL_IN_DATA | PendingIntent.FLAG_IMMUTABLE); manager.open(me, pi, null);