2021-10-16 14:05:45 -04:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2017-12-04 18:49:19 -05:00
|
|
|
From: Daniel Micay <danielmicay@gmail.com>
|
2021-10-16 14:05:45 -04:00
|
|
|
Date: Sun, 6 Aug 2017 10:27:32 -0400
|
2017-12-04 18:49:19 -05:00
|
|
|
Subject: [PATCH] fix toggling off current permissions in review
|
|
|
|
|
|
|
|
The confirmPermissionsReview function currently only takes into account
|
|
|
|
changes to the new permissions section. Since permissions review shows
|
|
|
|
toggles for the current permissions, those should work too. It doesn't
|
|
|
|
necessarily need to show toggles for the current permissions but since
|
|
|
|
they're present the toggles should work to avoid misleading users into
|
|
|
|
thinking they've toggled off a permission that they haven't.
|
|
|
|
|
|
|
|
Change-Id: I84310a1c20981a239169069a881dbb79267d784f
|
|
|
|
---
|
2021-10-16 14:05:45 -04:00
|
|
|
.../ui/ReviewPermissionsActivity.java | 53 +++++++++++--------
|
|
|
|
1 file changed, 31 insertions(+), 22 deletions(-)
|
2017-12-04 18:49:19 -05:00
|
|
|
|
|
|
|
diff --git a/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java b/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java
|
2021-10-16 14:05:45 -04:00
|
|
|
index 6bc251aed..b6fd0c161 100644
|
2017-12-04 18:49:19 -05:00
|
|
|
--- a/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java
|
|
|
|
+++ b/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java
|
2021-10-16 14:05:45 -04:00
|
|
|
@@ -48,6 +48,7 @@ import com.android.packageinstaller.permission.model.AppPermissions;
|
2017-12-04 18:49:19 -05:00
|
|
|
import com.android.packageinstaller.permission.utils.Utils;
|
|
|
|
import com.android.packageinstaller.permission.ui.ConfirmActionDialogFragment.OnActionConfirmedListener;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public final class ReviewPermissionsActivity extends Activity
|
2021-10-16 14:05:45 -04:00
|
|
|
@@ -103,6 +104,7 @@ public final class ReviewPermissionsActivity extends Activity
|
2017-12-04 18:49:19 -05:00
|
|
|
private Button mCancelButton;
|
|
|
|
|
|
|
|
private PreferenceCategory mNewPermissionsCategory;
|
|
|
|
+ private PreferenceCategory mCurrentPermissionsCategory;
|
|
|
|
|
|
|
|
private boolean mHasConfirmedRevoke;
|
|
|
|
|
2021-10-16 14:05:45 -04:00
|
|
|
@@ -218,22 +220,29 @@ public final class ReviewPermissionsActivity extends Activity
|
2017-12-04 18:49:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private void confirmPermissionsReview() {
|
|
|
|
- PreferenceGroup preferenceGroup = mNewPermissionsCategory != null
|
|
|
|
- ? mNewPermissionsCategory : getPreferenceScreen();
|
2021-10-16 14:05:45 -04:00
|
|
|
-
|
2017-12-04 18:49:19 -05:00
|
|
|
- final int preferenceCount = preferenceGroup.getPreferenceCount();
|
|
|
|
- for (int i = 0; i < preferenceCount; i++) {
|
|
|
|
- Preference preference = preferenceGroup.getPreference(i);
|
|
|
|
- if (preference instanceof TwoStatePreference) {
|
|
|
|
- TwoStatePreference twoStatePreference = (TwoStatePreference) preference;
|
|
|
|
- String groupName = preference.getKey();
|
|
|
|
- AppPermissionGroup group = mAppPermissions.getPermissionGroup(groupName);
|
|
|
|
- if (twoStatePreference.isChecked()) {
|
|
|
|
- group.grantRuntimePermissions(false);
|
|
|
|
- } else {
|
|
|
|
- group.revokeRuntimePermissions(false);
|
2021-10-16 14:05:45 -04:00
|
|
|
+ final List<PreferenceGroup> preferenceGroups = new ArrayList<PreferenceGroup>();
|
|
|
|
+ if (mNewPermissionsCategory != null) {
|
|
|
|
+ preferenceGroups.add(mNewPermissionsCategory);
|
|
|
|
+ preferenceGroups.add(mCurrentPermissionsCategory);
|
|
|
|
+ } else {
|
|
|
|
+ preferenceGroups.add(getPreferenceScreen());
|
|
|
|
+ }
|
|
|
|
+
|
2017-12-04 18:49:19 -05:00
|
|
|
+ for (PreferenceGroup preferenceGroup : preferenceGroups) {
|
|
|
|
+ final int preferenceCount = preferenceGroup.getPreferenceCount();
|
|
|
|
+ for (int i = 0; i < preferenceCount; i++) {
|
|
|
|
+ Preference preference = preferenceGroup.getPreference(i);
|
|
|
|
+ if (preference instanceof TwoStatePreference) {
|
|
|
|
+ TwoStatePreference twoStatePreference = (TwoStatePreference) preference;
|
|
|
|
+ String groupName = preference.getKey();
|
|
|
|
+ AppPermissionGroup group = mAppPermissions.getPermissionGroup(groupName);
|
|
|
|
+ if (twoStatePreference.isChecked()) {
|
|
|
|
+ group.grantRuntimePermissions(false);
|
|
|
|
+ } else {
|
|
|
|
+ group.revokeRuntimePermissions(false);
|
|
|
|
+ }
|
|
|
|
+ group.resetReviewRequired();
|
|
|
|
}
|
|
|
|
- group.resetReviewRequired();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-16 14:05:45 -04:00
|
|
|
@@ -295,7 +304,7 @@ public final class ReviewPermissionsActivity extends Activity
|
2017-12-04 18:49:19 -05:00
|
|
|
screen.removeAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
- PreferenceGroup currentPermissionsCategory = null;
|
|
|
|
+ mCurrentPermissionsCategory = null;
|
|
|
|
PreferenceGroup oldNewPermissionsCategory = mNewPermissionsCategory;
|
|
|
|
mNewPermissionsCategory = null;
|
|
|
|
|
2021-10-16 14:05:45 -04:00
|
|
|
@@ -353,13 +362,13 @@ public final class ReviewPermissionsActivity extends Activity
|
2017-12-04 18:49:19 -05:00
|
|
|
mNewPermissionsCategory.addPreference(preference);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
- if (currentPermissionsCategory == null) {
|
|
|
|
- currentPermissionsCategory = new PreferenceCategory(activity);
|
|
|
|
- currentPermissionsCategory.setTitle(R.string.current_permissions_category);
|
|
|
|
- currentPermissionsCategory.setOrder(2);
|
|
|
|
- screen.addPreference(currentPermissionsCategory);
|
|
|
|
+ if (mCurrentPermissionsCategory == null) {
|
|
|
|
+ mCurrentPermissionsCategory = new PreferenceCategory(activity);
|
|
|
|
+ mCurrentPermissionsCategory.setTitle(R.string.current_permissions_category);
|
|
|
|
+ mCurrentPermissionsCategory.setOrder(2);
|
|
|
|
+ screen.addPreference(mCurrentPermissionsCategory);
|
|
|
|
}
|
|
|
|
- currentPermissionsCategory.addPreference(preference);
|
|
|
|
+ mCurrentPermissionsCategory.addPreference(preference);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|