summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2016-10-22 08:59:10 -0600
committerLinux Build Service Account <lnxbuild@localhost>2016-10-22 08:59:10 -0600
commit41dc63be55dbd9fc40ae666c0f8ae7117a0d6681 (patch)
tree4149bf7f583a300ffb5e093ca9ac2dd73d8a7609
parentebcfa18461cf6280c09ba119102e039761b3330d (diff)
parentfafa0d8c4d775fd83d3d08cfabcb82999eb62014 (diff)
downloadandroid_packages_apps_PackageInstaller-41dc63be55dbd9fc40ae666c0f8ae7117a0d6681.zip
android_packages_apps_PackageInstaller-41dc63be55dbd9fc40ae666c0f8ae7117a0d6681.tar.gz
android_packages_apps_PackageInstaller-41dc63be55dbd9fc40ae666c0f8ae7117a0d6681.tar.bz2
Merge fafa0d8c4d775fd83d3d08cfabcb82999eb62014 on remote branch
Change-Id: I396da89b9a50d2909e14727775f754ba94f960ef
-rw-r--r--[-rwxr-xr-x]src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java214
-rw-r--r--[-rwxr-xr-x]src/com/android/packageinstaller/permission/ui/handheld/AppPermissionsFragment.java39
2 files changed, 96 insertions, 157 deletions
diff --git a/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java b/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java
index 97de80e..4a4b755 100755..100644
--- a/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java
+++ b/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java
@@ -61,7 +61,6 @@ public class GrantPermissionsActivity extends OverlayTouchActivity
private int[] mGrantResults;
private LinkedHashMap<String, GroupState> mRequestGrantPermissionGroups = new LinkedHashMap<>();
- private LinkedHashMap<String, ItemState> mRequestGrantPermissionItems = new LinkedHashMap<>();
private GrantPermissionsViewHandler mViewHandler;
private AppPermissions mAppPermissions;
@@ -143,68 +142,49 @@ public class GrantPermissionsActivity extends OverlayTouchActivity
}
// We allow the user to choose only non-fixed permissions. A permission
// is fixed either by device policy or the user denying with prejudice.
- if (!AppPermissionGroup.isStrictOpEnable()) {
- if (!group.isUserFixed() && !group.isPolicyFixed()) {
- switch (permissionPolicy) {
- case DevicePolicyManager.PERMISSION_POLICY_AUTO_GRANT: {
- if (!group.areRuntimePermissionsGranted()) {
- group.grantRuntimePermissions(false);
- }
- group.setPolicyFixed();
- } break;
+ if (!group.isUserFixed() && !group.isPolicyFixed()) {
+ switch (permissionPolicy) {
+ case DevicePolicyManager.PERMISSION_POLICY_AUTO_GRANT: {
+ if (!group.areRuntimePermissionsGranted()) {
+ group.grantRuntimePermissions(false);
+ }
+ group.setPolicyFixed();
+ }
+ break;
- case DevicePolicyManager.PERMISSION_POLICY_AUTO_DENY: {
- if (group.areRuntimePermissionsGranted()) {
- group.revokeRuntimePermissions(false);
- }
- group.setPolicyFixed();
- } break;
-
- default: {
- if (!group.areRuntimePermissionsGranted()) {
- mRequestGrantPermissionGroups.put(group.getName(),
- new GroupState(group));
- } else {
- group.grantRuntimePermissions(false);
- updateGrantResults(group);
- }
- } break;
+ case DevicePolicyManager.PERMISSION_POLICY_AUTO_DENY: {
+ if (group.areRuntimePermissionsGranted()) {
+ group.revokeRuntimePermissions(false);
+ }
+ group.setPolicyFixed();
}
- } else {
- // if the permission is fixed, ensure that we return the right request result
- updateGrantResults(group);
- }
- }
- }
+ break;
- if (AppPermissionGroup.isStrictOpEnable()) {
- for (String permName : mRequestedPermissions) {
- PermissionInfo permissionInfo;
- AppPermissionGroup permAppGroup;
- try {
- permissionInfo = this.getPackageManager().getPermissionInfo(permName, 0);
- permAppGroup = mAppPermissions.getPermissionGroup(permissionInfo.group);
- } catch (PackageManager.NameNotFoundException e) {
- continue;
+ default: {
+ if (!group.areRuntimePermissionsGranted()) {
+ mRequestGrantPermissionGroups.put(group.getName(),
+ new GroupState(group));
+ } else {
+ group.grantRuntimePermissions(false);
+ updateGrantResults(group);
+ }
+ }
+ break;
}
- mRequestGrantPermissionItems.put(
- permName, new ItemState(permAppGroup, permissionInfo, permName));
+ } else {
+ // if the permission is fixed, ensure that we return the right request result
+ updateGrantResults(group);
}
}
+
setContentView(mViewHandler.createView());
Window window = getWindow();
WindowManager.LayoutParams layoutParams = window.getAttributes();
mViewHandler.updateWindowAttributes(layoutParams);
window.setAttributes(layoutParams);
- if (AppPermissionGroup.isStrictOpEnable()) {
- if (!showNextPermissionItemGrantRequest()) {
- setResultAndFinish();
- }
- } else {
- if (!showNextPermissionGroupGrantRequest()) {
- setResultAndFinish();
- }
+ if (!showNextPermissionGroupGrantRequest()) {
+ setResultAndFinish();
}
}
@@ -253,8 +233,31 @@ public class GrantPermissionsActivity extends OverlayTouchActivity
for (GroupState groupState : mRequestGrantPermissionGroups.values()) {
if (groupState.mState == GroupState.STATE_UNKNOWN) {
CharSequence appLabel = mAppPermissions.getAppLabel();
+ CharSequence desc = null;
+ if (AppPermissionGroup.isStrictOpEnable()) {
+ String info = "";
+ AppPermissionGroup group = mAppPermissions.getPermissionGroup(groupState
+ .mGroup.getName());
+ for (Permission permission : group.getPermissions()) {
+ try {
+ PermissionInfo permissionInfo = this.getPackageManager()
+ .getPermissionInfo(permission.getName(), 0);
+ if (info.length() != 0) {
+ info += ", ";
+ }
+ info += permissionInfo.loadLabel(getPackageManager());
+ } catch (PackageManager.NameNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+ if (info.length() != 0) {
+ desc = groupState.mGroup.getDescription() + "(" + info + ")";
+ }
+ } else {
+ desc = groupState.mGroup.getDescription();
+ }
Spanned message = Html.fromHtml(getString(R.string.permission_warning_template,
- appLabel, groupState.mGroup.getDescription()), 0);
+ appLabel, desc), 0);
// Set the permission message as the title so it can be announced.
setTitle(message);
@@ -269,46 +272,15 @@ public class GrantPermissionsActivity extends OverlayTouchActivity
resources = Resources.getSystem();
}
int icon = groupState.mGroup.getIconResId();
-
- mViewHandler.updateUi(groupState.mGroup.getName(), groupCount, currentIndex,
- Icon.createWithResource(resources, icon), message,
- groupState.mGroup.isUserSet());
- return true;
- }
-
- currentIndex++;
- }
- return false;
- }
-
- private boolean showNextPermissionItemGrantRequest() {
- final int itemCount = mRequestGrantPermissionItems.size();
- int currentIndex = 0;
- for (ItemState permState : mRequestGrantPermissionItems.values()) {
- if (permState.mState == ItemState.STATE_UNKNOWN) {
- CharSequence appLabel = mAppPermissions.getAppLabel();
- Spanned message = Html.fromHtml(getString(R.string.permission_warning_template,
- appLabel, permState.mItem.loadLabel(this.getPackageManager())), 0);
- // Set the permission message as the title so it can be announced.
- setTitle(message);
-
- // Set the new grant view
- // TODO: Use a real message for the action. We need group action APIs
- AppPermissionGroup permGroup = mAppPermissions.getPermissionGroup(
- permState.mItem.group);
- Resources resources;
- try {
- resources = getPackageManager().getResourcesForApplication(
- permGroup.getIconPkg());
- } catch (NameNotFoundException e) {
- // Fallback to system.
- Log.w(LOG_TAG, "Can't get resources", e);
- resources = Resources.getSystem();
+ if (AppPermissionGroup.isStrictOpEnable()) {
+ mViewHandler.updateUi(groupState.mGroup.getName(), groupCount, currentIndex,
+ Icon.createWithResource(resources, icon), message,
+ true);
+ } else {
+ mViewHandler.updateUi(groupState.mGroup.getName(), groupCount, currentIndex,
+ Icon.createWithResource(resources, icon), message,
+ groupState.mGroup.isUserSet());
}
- int icon = permGroup.getIconResId();
- mViewHandler.updateUi(permState.mPermName, itemCount, currentIndex, ///updateUi
- Icon.createWithResource(resources, icon), message,
- true);
return true;
}
@@ -319,39 +291,19 @@ public class GrantPermissionsActivity extends OverlayTouchActivity
@Override
public void onPermissionGrantResult(String name, boolean granted, boolean doNotAskAgain) {
- if (AppPermissionGroup.isStrictOpEnable()) {
- ItemState permItemState = mRequestGrantPermissionItems.get(name);
- final String[] filterPermissions = new String[]{name};
- if (permItemState.mGroup != null) {
- Log.i(LOG_TAG, "onPermissionGrantResult permItemState.mGroup != null ");
- if (granted) {
- permItemState.mGroup.grantRuntimePermissions(doNotAskAgain, filterPermissions);
- permItemState.mState = ItemState.STATE_ALLOWED;
- } else {
- permItemState.mGroup.revokeRuntimePermissions(doNotAskAgain, filterPermissions);
- permItemState.mState = ItemState.STATE_DENIED;
- }
- updateGrantResults(permItemState.mGroup);
- }
-
- if (!showNextPermissionItemGrantRequest()) {
- setResultAndFinish();
- }
- } else {
- GroupState groupState = mRequestGrantPermissionGroups.get(name);
- if (groupState.mGroup != null) {
- if (granted) {
- groupState.mGroup.grantRuntimePermissions(doNotAskAgain);
- groupState.mState = GroupState.STATE_ALLOWED;
- } else {
- groupState.mGroup.revokeRuntimePermissions(doNotAskAgain);
- groupState.mState = GroupState.STATE_DENIED;
- }
- updateGrantResults(groupState.mGroup);
- }
- if (!showNextPermissionGroupGrantRequest()) {
- setResultAndFinish();
+ GroupState groupState = mRequestGrantPermissionGroups.get(name);
+ if (groupState.mGroup != null) {
+ if (granted) {
+ groupState.mGroup.grantRuntimePermissions(doNotAskAgain);
+ groupState.mState = GroupState.STATE_ALLOWED;
+ } else {
+ groupState.mGroup.revokeRuntimePermissions(doNotAskAgain);
+ groupState.mState = GroupState.STATE_DENIED;
}
+ updateGrantResults(groupState.mGroup);
+ }
+ if (!showNextPermissionGroupGrantRequest()) {
+ setResultAndFinish();
}
}
@@ -485,20 +437,4 @@ public class GrantPermissionsActivity extends OverlayTouchActivity
mGroup = group;
}
}
-
- private static final class ItemState {
- static final int STATE_UNKNOWN = 0;
- static final int STATE_ALLOWED = 1;
- static final int STATE_DENIED = 2;
-
- final PermissionInfo mItem;
- int mState = STATE_UNKNOWN;
- String mPermName;
- final AppPermissionGroup mGroup;
- ItemState(AppPermissionGroup group, PermissionInfo item, String itemId) {
- mItem = item;
- mPermName = itemId;
- mGroup = group;
- }
- }
}
diff --git a/src/com/android/packageinstaller/permission/ui/handheld/AppPermissionsFragment.java b/src/com/android/packageinstaller/permission/ui/handheld/AppPermissionsFragment.java
index f4e5962..b5f57ad 100755..100644
--- a/src/com/android/packageinstaller/permission/ui/handheld/AppPermissionsFragment.java
+++ b/src/com/android/packageinstaller/permission/ui/handheld/AppPermissionsFragment.java
@@ -30,6 +30,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PermissionInfo;
import android.graphics.drawable.Drawable;
+import android.Manifest;
import android.net.Uri;
import android.os.Bundle;
import android.preference.Preference;
@@ -243,24 +244,25 @@ public final class AppPermissionsFragment extends SettingsWithHeader
}
if (AppPermissionGroup.isStrictOpEnable() && isPlatform) {
try {
- PackageManager pm = context.getPackageManager();
- for (Permission permission : group.getPermissions()) {
- PermissionInfo perm = pm.getPermissionInfo(permission.getName(), 0);
- final String[] filterPermissions = new String[]{permission.getName()};
-
- if (perm.protectionLevel == PermissionInfo.PROTECTION_DANGEROUS) {
- SwitchPreference preference_permission = new SwitchPreference(context);
- preference_permission.setOnPreferenceChangeListener(this);
- preference_permission.setKey(permission.getName());
- preference_permission.setTitle(perm.loadLabel(pm));
- preference_permission.setPersistent(false);
- preference_permission.setEnabled(true);
- AppPermissionGroup permissionGroup = getPermisssionGroup(perm.group);
- preference_permission.setChecked(
- permissionGroup.areRuntimePermissionsGranted(filterPermissions));
- screen.addPreference(preference_permission);
- } else if (perm.protectionLevel == PermissionInfo.PROTECTION_NORMAL) {
- continue;
+ if (!group.getName().equals(Manifest.permission_group.STORAGE)) {
+ PackageManager pm = context.getPackageManager();
+ for (Permission permission : group.getPermissions()) {
+ PermissionInfo perm = pm.getPermissionInfo(permission.getName(), 0);
+ final String[] filterPermissions = new String[]{permission.getName()};
+ if (perm.protectionLevel == PermissionInfo.PROTECTION_DANGEROUS) {
+ SwitchPreference preference_permission = new SwitchPreference(context);
+ preference_permission.setOnPreferenceChangeListener(this);
+ preference_permission.setKey(permission.getName());
+ preference_permission.setTitle(perm.loadLabel(pm));
+ preference_permission.setPersistent(false);
+ preference_permission.setEnabled(true);
+ AppPermissionGroup permissionGroup = getPermisssionGroup(perm.group);
+ preference_permission.setChecked(
+ permissionGroup.areRuntimePermissionsGranted(filterPermissions));
+ screen.addPreference(preference_permission);
+ } else if (perm.protectionLevel == PermissionInfo.PROTECTION_NORMAL) {
+ continue;
+ }
}
}
} catch (NameNotFoundException e) {
@@ -302,6 +304,7 @@ public final class AppPermissionsFragment extends SettingsWithHeader
}
private void updateEveryPermissionPreference(AppPermissionGroup group) {
+ if (group.getName().equals(Manifest.permission_group.STORAGE)) return;
PackageManager pm = getContext().getPackageManager();
PreferenceScreen screen = getPreferenceScreen();
for (Permission permission : group.getPermissions()) {