diff options
author | 2024-01-29 18:31:33 -0800 | |
---|---|---|
committer | 2024-02-02 01:17:38 +0000 | |
commit | a05e4c4255bf465dd20703b351c0702c3295a52a (patch) | |
tree | 098a234be6b8b8c82a51c50130b8582c79f53aae | |
parent | 0a7628115474e2f668d97d36e04cae51cd09f27b (diff) |
[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
-rw-r--r-- | framework-s/java/android/app/ecm/EnhancedConfirmationManager.java | 8 |
1 files changed, 6 insertions, 2 deletions
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 { |