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
This commit is contained in:
Cole Faust
2022-09-23 15:17:52 -07:00
parent 16a8d0fa8e
commit f4dc2d5f25
2 changed files with 2 additions and 2 deletions

View File

@@ -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;