diff options
author | 2022-12-06 11:21:10 -0800 | |
---|---|---|
committer | 2022-12-06 19:33:36 +0000 | |
commit | eaf3a33999c348ba46628d795a7de1c6732b74b1 (patch) | |
tree | 0b384d7a203763ede96b68b910ba7efbd8bf88ff | |
parent | 6f4354c50f3f4bbde92e042134da3db8c15c58ec (diff) |
Do not merge multiple app-triggered permission dialogs
If we do merge multiple app-triggered dialogs, there's a chance that we
can end up merging a dialog into a dialog that's now hidden behind an
activity. The merging code is really for system-triggered dialogs, so
restrict it to that.
Fixes: 250101648
Test: manual
Change-Id: Ibb9e18d59f53663683f898675b9dd47fa18ab495
-rw-r--r-- | PermissionController/src/com/android/permissioncontroller/permission/ui/GrantPermissionsActivity.java | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/PermissionController/src/com/android/permissioncontroller/permission/ui/GrantPermissionsActivity.java b/PermissionController/src/com/android/permissioncontroller/permission/ui/GrantPermissionsActivity.java index 296a007aa..b9c4a07d9 100644 --- a/PermissionController/src/com/android/permissioncontroller/permission/ui/GrantPermissionsActivity.java +++ b/PermissionController/src/com/android/permissioncontroller/permission/ui/GrantPermissionsActivity.java @@ -147,6 +147,8 @@ public class GrantPermissionsActivity extends SettingsActivity private List<GrantPermissionsActivity> mFollowerActivities = new ArrayList<>(); /** Whether this activity has asked another GrantPermissionsActivity to show on its behalf */ private boolean mDelegated; + /** Whether this activity has been triggered by the system */ + private boolean mIsSystemTriggered = false; /** The set result code, or MAX_VALUE if it hasn't been set yet */ private int mResultCode = Integer.MAX_VALUE; /** Package that shall have permissions granted */ @@ -178,6 +180,7 @@ public class GrantPermissionsActivity extends SettingsActivity .getStringArrayExtra(PackageManager.EXTRA_REQUEST_PERMISSIONS_NAMES); if (PackageManager.ACTION_REQUEST_PERMISSIONS_FOR_OTHER.equals(getIntent().getAction())) { + mIsSystemTriggered = true; mTargetPackage = getIntent().getStringExtra(Intent.EXTRA_PACKAGE_NAME); if (mTargetPackage == null) { Log.e(LOG_TAG, "null EXTRA_PACKAGE_NAME. Must be set for " @@ -213,16 +216,17 @@ public class GrantPermissionsActivity extends SettingsActivity if (!sCurrentGrantRequests.containsKey(mKey)) { sCurrentGrantRequests.put(mKey, this); finishSystemStartedDialogsOnOtherTasksLocked(); - } else if (getCallingPackage() == null) { - // The trampoline doesn't require results. Delegate, and finish. + } else if (mIsSystemTriggered) { + // The system triggered dialog doesn't require results. Delegate, and finish. sCurrentGrantRequests.get(mKey).onNewFollowerActivity(null, mRequestedPermissions); finishAfterTransition(); return; - } else { + } else if (sCurrentGrantRequests.get(mKey).mIsSystemTriggered) { + // Normal permission requests should only merge into the system triggered dialog, + // which has task overlay set mDelegated = true; - sCurrentGrantRequests.get(mKey).onNewFollowerActivity(this, - mRequestedPermissions); + sCurrentGrantRequests.get(mKey).onNewFollowerActivity(this, mRequestedPermissions); } } @@ -793,9 +797,7 @@ public class GrantPermissionsActivity extends SettingsActivity for (Pair<String, Integer> key : sCurrentGrantRequests.keySet()) { if (key.first.equals(mTargetPackage) && key.second != getTaskId()) { GrantPermissionsActivity other = sCurrentGrantRequests.get(key); - if (other.getIntent().getAction() - .equals(PackageManager.ACTION_REQUEST_PERMISSIONS_FOR_OTHER) - && other.mFollowerActivities.isEmpty()) { + if (other.mIsSystemTriggered && other.mFollowerActivities.isEmpty()) { other.finish(); } } |