mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-30 01:46:30 -05:00
109 lines
5.4 KiB
Diff
109 lines
5.4 KiB
Diff
From 64d8b44f6625292bc4a5f90913713e97fc4a0032 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Micay <danielmicay@gmail.com>
|
|
Date: Sun, 06 Aug 2017 10:27:32 -0400
|
|
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
|
|
---
|
|
|
|
diff --git a/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java b/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java
|
|
index 6bc251a..b6fd0c1 100644
|
|
--- a/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java
|
|
+++ b/src/com/android/packageinstaller/permission/ui/ReviewPermissionsActivity.java
|
|
@@ -48,6 +48,7 @@
|
|
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
|
|
@@ -103,6 +104,7 @@
|
|
private Button mCancelButton;
|
|
|
|
private PreferenceCategory mNewPermissionsCategory;
|
|
+ private PreferenceCategory mCurrentPermissionsCategory;
|
|
|
|
private boolean mHasConfirmedRevoke;
|
|
|
|
@@ -218,22 +220,29 @@
|
|
}
|
|
|
|
private void confirmPermissionsReview() {
|
|
- PreferenceGroup preferenceGroup = mNewPermissionsCategory != null
|
|
- ? mNewPermissionsCategory : getPreferenceScreen();
|
|
+ final List<PreferenceGroup> preferenceGroups = new ArrayList<PreferenceGroup>();
|
|
+ if (mNewPermissionsCategory != null) {
|
|
+ preferenceGroups.add(mNewPermissionsCategory);
|
|
+ preferenceGroups.add(mCurrentPermissionsCategory);
|
|
+ } else {
|
|
+ preferenceGroups.add(getPreferenceScreen());
|
|
+ }
|
|
|
|
- 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);
|
|
+ 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();
|
|
}
|
|
}
|
|
}
|
|
@@ -295,7 +304,7 @@
|
|
screen.removeAll();
|
|
}
|
|
|
|
- PreferenceGroup currentPermissionsCategory = null;
|
|
+ mCurrentPermissionsCategory = null;
|
|
PreferenceGroup oldNewPermissionsCategory = mNewPermissionsCategory;
|
|
mNewPermissionsCategory = null;
|
|
|
|
@@ -353,13 +362,13 @@
|
|
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);
|
|
}
|
|
}
|
|
}
|