DivestOS/Patches/LineageOS-14.1/android_packages_apps_PackageInstaller/64d8b44.patch

112 lines
5.8 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2017-12-04 18:49:19 -05:00
From: Daniel Micay <danielmicay@gmail.com>
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
---
.../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
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
@@ -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
@@ -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;
@@ -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();
-
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);
+ 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();
}
}
}
@@ -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;
@@ -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);
}
}
}