From a05e4c4255bf465dd20703b351c0702c3295a52a Mon Sep 17 00:00:00 2001 From: Jay Thomas Sullivan Date: Mon, 29 Jan 2024 18:31:33 -0800 Subject: [ECM] Use unique requestCodes for PendingIntent Use a unique requestCode for each call to PendingIntent.getActivity. Without this, each call returns the same object, even if the supplied *extra*s differ. This is a problem because, it would mean that after the first call to PendingIntent.getActivity, each subsequent call will have the wrong extras. Fix: 322891228 Test: manual Change-Id: If774bfc1e03963ec32980ea7c935774eb930eaf0 --- framework-s/java/android/app/ecm/EnhancedConfirmationManager.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'framework-s/java') diff --git a/framework-s/java/android/app/ecm/EnhancedConfirmationManager.java b/framework-s/java/android/app/ecm/EnhancedConfirmationManager.java index 52e220bc0..b05c361e1 100644 --- a/framework-s/java/android/app/ecm/EnhancedConfirmationManager.java +++ b/framework-s/java/android/app/ecm/EnhancedConfirmationManager.java @@ -37,6 +37,7 @@ import android.util.ArraySet; import androidx.annotation.NonNull; import java.lang.annotation.Retention; +import java.util.concurrent.atomic.AtomicInteger; /** * This class provides the core API for ECM (Enhanced Confirmation Mode). ECM is a feature that @@ -218,6 +219,8 @@ public final class EnhancedConfirmationManager { private final @NonNull IEnhancedConfirmationManager mService; + private final @NonNull AtomicInteger mNextRequestCode; + /** * @hide */ @@ -226,6 +229,7 @@ public final class EnhancedConfirmationManager { mContext = context; mPackageManager = context.getPackageManager(); mService = service; + mNextRequestCode = new AtomicInteger(1); } /** @@ -335,8 +339,8 @@ public final class EnhancedConfirmationManager { Intent intent = new Intent(Settings.ACTION_SHOW_RESTRICTED_SETTING_DIALOG); intent.putExtra(Intent.EXTRA_PACKAGE_NAME, packageName); intent.putExtra(Intent.EXTRA_UID, getPackageUid(packageName)); - // TODO(b/323225971): Pass settingIdentifier to dialog - return PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_IMMUTABLE); + return PendingIntent.getActivity(mContext, mNextRequestCode.getAndIncrement(), + intent, PendingIntent.FLAG_IMMUTABLE); } private int getPackageUid(String packageName) throws NameNotFoundException { -- cgit v1.2.3-59-g8ed1b