summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2016-05-03 17:46:42 (GMT)
committerThe Android Automerger <android-build@google.com>2016-05-03 20:20:30 (GMT)
commit3942ad1e78f775f33509fc56775376d1c9a77dc2 (patch)
tree883efd610b5e2bbae57d7619bc34c890e1cd6492
parent1c5fb8f4f4baef6cd337f3280489b87957636b2e (diff)
downloadandroid_packages_apps_PackageInstaller-3942ad1e78f775f33509fc56775376d1c9a77dc2.zip
android_packages_apps_PackageInstaller-3942ad1e78f775f33509fc56775376d1c9a77dc2.tar.gz
android_packages_apps_PackageInstaller-3942ad1e78f775f33509fc56775376d1c9a77dc2.tar.bz2
Revert "Grant only the requested permissions"
This reverts commit 294b6406798c59e9db5ffa99d042f9b8c6ca6f90. Change-Id: Ifb48eb1fbdb0499743f4ca88adbd5ed77cfa4cf8
-rw-r--r--src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java50
-rw-r--r--src/com/android/packageinstaller/permission/utils/ArrayUtils.java18
2 files changed, 9 insertions, 59 deletions
diff --git a/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java b/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java
index 807d3a3..78d33d2 100644
--- a/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java
+++ b/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java
@@ -29,6 +29,7 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.graphics.drawable.Icon;
+import android.hardware.camera2.utils.ArrayUtils;
import android.os.Build;
import android.os.Bundle;
import android.text.SpannableString;
@@ -46,7 +47,6 @@ import com.android.packageinstaller.permission.model.AppPermissionGroup;
import com.android.packageinstaller.permission.model.AppPermissions;
import com.android.packageinstaller.permission.model.Permission;
import com.android.packageinstaller.permission.ui.handheld.GrantPermissionsViewHandlerImpl;
-import com.android.packageinstaller.permission.utils.ArrayUtils;
import com.android.packageinstaller.permission.utils.SafetyNetLogger;
import java.util.ArrayList;
@@ -147,36 +147,24 @@ public class GrantPermissionsActivity extends OverlayTouchActivity
switch (permissionPolicy) {
case DevicePolicyManager.PERMISSION_POLICY_AUTO_GRANT: {
if (!group.areRuntimePermissionsGranted()) {
- group.grantRuntimePermissions(false, computeAffectedPermissions(
- callingPackageInfo, requestedPermission));
+ group.grantRuntimePermissions(false);
}
group.setPolicyFixed();
} break;
case DevicePolicyManager.PERMISSION_POLICY_AUTO_DENY: {
if (group.areRuntimePermissionsGranted()) {
- group.revokeRuntimePermissions(false, computeAffectedPermissions(
- callingPackageInfo, requestedPermission));
+ group.revokeRuntimePermissions(false);
}
group.setPolicyFixed();
} break;
default: {
if (!group.areRuntimePermissionsGranted()) {
- GroupState state = mRequestGrantPermissionGroups.get(group.getName());
- if (state == null) {
- state = new GroupState(group);
- mRequestGrantPermissionGroups.put(group.getName(), state);
- }
- String affectedPermission = computeAffectedPermission(
- callingPackageInfo, requestedPermission);
- if (affectedPermission != null) {
- state.affectedPermissions = ArrayUtils.appendString(
- state.affectedPermissions, affectedPermission);
- }
+ mRequestGrantPermissionGroups.put(group.getName(),
+ new GroupState(group));
} else {
- group.grantRuntimePermissions(false, computeAffectedPermissions(
- callingPackageInfo, requestedPermission));
+ group.grantRuntimePermissions(false);
updateGrantResults(group);
}
} break;
@@ -283,12 +271,10 @@ public class GrantPermissionsActivity extends OverlayTouchActivity
GroupState groupState = mRequestGrantPermissionGroups.get(name);
if (groupState.mGroup != null) {
if (granted) {
- groupState.mGroup.grantRuntimePermissions(doNotAskAgain,
- groupState.affectedPermissions);
+ groupState.mGroup.grantRuntimePermissions(doNotAskAgain);
groupState.mState = GroupState.STATE_ALLOWED;
} else {
- groupState.mGroup.revokeRuntimePermissions(doNotAskAgain,
- groupState.affectedPermissions);
+ groupState.mGroup.revokeRuntimePermissions(doNotAskAgain);
groupState.mState = GroupState.STATE_DENIED;
}
updateGrantResults(groupState.mGroup);
@@ -300,7 +286,7 @@ public class GrantPermissionsActivity extends OverlayTouchActivity
private void updateGrantResults(AppPermissionGroup group) {
for (Permission permission : group.getPermissions()) {
- final int index = ArrayUtils.indexOf(
+ final int index = ArrayUtils.getArrayIndex(
mRequestedPermissions, permission.getName());
if (index >= 0) {
mGrantResults[index] = permission.isGranted() ? PackageManager.PERMISSION_GRANTED
@@ -416,23 +402,6 @@ public class GrantPermissionsActivity extends OverlayTouchActivity
SafetyNetLogger.logPermissionsRequested(mAppPermissions.getPackageInfo(), groups);
}
- private static String[] computeAffectedPermissions(PackageInfo callingPackageInfo,
- String permission) {
- String affectedPermission = computeAffectedPermission(callingPackageInfo, permission);
- if (affectedPermission != null) {
- return new String[] {permission};
- }
- return null;
- }
-
- private static String computeAffectedPermission(PackageInfo callingPackageInfo,
- String permission) {
- if (callingPackageInfo.applicationInfo.targetSdkVersion > Build.VERSION_CODES.M) {
- return permission;
- }
- return null;
- }
-
private static final class GroupState {
static final int STATE_UNKNOWN = 0;
static final int STATE_ALLOWED = 1;
@@ -440,7 +409,6 @@ public class GrantPermissionsActivity extends OverlayTouchActivity
final AppPermissionGroup mGroup;
int mState = STATE_UNKNOWN;
- String[] affectedPermissions;
GroupState(AppPermissionGroup group) {
mGroup = group;
diff --git a/src/com/android/packageinstaller/permission/utils/ArrayUtils.java b/src/com/android/packageinstaller/permission/utils/ArrayUtils.java
index 2af641b..4b7a394 100644
--- a/src/com/android/packageinstaller/permission/utils/ArrayUtils.java
+++ b/src/com/android/packageinstaller/permission/utils/ArrayUtils.java
@@ -16,8 +16,6 @@
package com.android.packageinstaller.permission.utils;
-import android.text.TextUtils;
-
import java.util.Objects;
public final class ArrayUtils {
@@ -44,20 +42,4 @@ public final class ArrayUtils {
}
return -1;
}
-
- public static String[] appendString(String[] cur, String val) {
- if (cur == null) {
- return new String[] { val };
- }
- final int N = cur.length;
- for (int i = 0; i < N; i++) {
- if (TextUtils.equals(cur[i], val)) {
- return cur;
- }
- }
- String[] ret = new String[N + 1];
- System.arraycopy(cur, 0, ret, 0, N);
- ret[N] = val;
- return ret;
- }
}