Revert "Revoke permissions defined in a to-be removed package."
This reverts commit e264f6e313e6dab3f3713aacd88687f85f075728.
Reason for revert: test
Change-Id: Ib7c6d00b92ce07c229f955d389478c6979b683e2
diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
index 4b6760c..18c6a3d 100644
--- a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
+++ b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
@@ -31,7 +31,6 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
-import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.pm.PackageParser;
@@ -39,7 +38,6 @@
import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
import android.metrics.LogMaker;
-import android.os.AsyncTask;
import android.os.Binder;
import android.os.Build;
import android.os.Handler;
@@ -478,9 +476,8 @@
" to " + newPermissionGroupName);
try {
- revokeRuntimePermission(permissionName, packageName,
- mSettings.getPermission(permissionName), false,
- Process.SYSTEM_UID, userId, permissionCallback, false);
+ revokeRuntimePermission(permissionName, packageName, false,
+ Process.SYSTEM_UID, userId, permissionCallback);
} catch (IllegalArgumentException e) {
Slog.e(TAG, "Could not revoke " + permissionName + " from "
+ packageName, e);
@@ -573,59 +570,9 @@
}
- private void revokeAllPermissions(
- @NonNull List<BasePermission> bps,
- @NonNull List<String> allPackageNames,
- @Nullable PermissionCallback permissionCallback) {
- AsyncTask.execute(() -> {
- final int numRemovedPermissions = bps.size();
- for (int permissionNum = 0; permissionNum < numRemovedPermissions; permissionNum++) {
- final int[] userIds = mUserManagerInt.getUserIds();
- final int numUserIds = userIds.length;
-
- final int numPackages = allPackageNames.size();
- for (int packageNum = 0; packageNum < numPackages; packageNum++) {
- final String packageName = allPackageNames.get(packageNum);
- final ApplicationInfo applicationInfo = mPackageManagerInt.getApplicationInfo(
- packageName, 0, Process.SYSTEM_UID, UserHandle.USER_SYSTEM);
- if (applicationInfo != null
- && applicationInfo.targetSdkVersion < Build.VERSION_CODES.M) {
- continue;
- }
- for (int userIdNum = 0; userIdNum < numUserIds; userIdNum++) {
- final int userId = userIds[userIdNum];
- final String permissionName = bps.get(permissionNum).getName();
- if (checkPermission(permissionName, packageName, UserHandle.USER_SYSTEM,
- userId) == PackageManager.PERMISSION_GRANTED) {
- try {
- revokeRuntimePermission(
- permissionName,
- packageName,
- bps.get(permissionNum),
- false,
- Process.SYSTEM_UID,
- userId,
- permissionCallback,
- true);
- } catch (IllegalArgumentException e) {
- Slog.e(TAG, "Could not revoke " + permissionName + " from "
- + packageName, e);
- }
- }
- }
- }
- }
- });
- }
-
- private void removeAllPermissions(
- @NonNull PackageParser.Package pkg,
- @NonNull List<String> allPackageNames,
- @Nullable PermissionCallback permissionCallback,
- boolean chatty) {
+ private void removeAllPermissions(PackageParser.Package pkg, boolean chatty) {
synchronized (mLock) {
int N = pkg.permissions.size();
- List<BasePermission> bps = new ArrayList<BasePermission>(N);
StringBuilder r = null;
for (int i=0; i<N; i++) {
PackageParser.Permission p = pkg.permissions.get(i);
@@ -634,9 +581,6 @@
bp = mSettings.mPermissionTrees.get(p.info.name);
}
if (bp != null && bp.isPermission(p)) {
- if ((p.info.getProtection() & PermissionInfo.PROTECTION_DANGEROUS) != 0) {
- bps.add(bp);
- }
bp.setPermission(null);
if (DEBUG_REMOVE && chatty) {
if (r == null) {
@@ -655,7 +599,6 @@
}
}
}
- revokeAllPermissions(bps, allPackageNames, permissionCallback);
if (r != null) {
if (DEBUG_REMOVE) Log.d(TAG, " Permissions: " + r);
}
@@ -1571,10 +1514,9 @@
}
}
-
- private void revokeRuntimePermission(String permName, String packageName, BasePermission bp,
- boolean overridePolicy, int callingUid, int userId, PermissionCallback callback,
- boolean permissionRemoved) {
+
+ private void revokeRuntimePermission(String permName, String packageName,
+ boolean overridePolicy, int callingUid, int userId, PermissionCallback callback) {
if (!mUserManagerInt.exists(userId)) {
Log.e(TAG, "No such user:" + userId);
return;
@@ -1599,7 +1541,7 @@
if (mPackageManagerInt.filterAppAccess(pkg, Binder.getCallingUid(), userId)) {
throw new IllegalArgumentException("Unknown package: " + packageName);
}
-
+ final BasePermission bp = mSettings.getPermissionLocked(permName);
if (bp == null) {
throw new IllegalArgumentException("Unknown permission: " + permName);
}
@@ -2156,10 +2098,8 @@
PermissionManagerService.this.addAllPermissionGroups(pkg, chatty);
}
@Override
- public void removeAllPermissions(Package pkg, List<String> allPackageNames,
- PermissionCallback permissionCallback, boolean chatty) {
- PermissionManagerService.this.removeAllPermissions(
- pkg, allPackageNames, permissionCallback, chatty);
+ public void removeAllPermissions(Package pkg, boolean chatty) {
+ PermissionManagerService.this.removeAllPermissions(pkg, chatty);
}
@Override
public boolean addDynamicPermission(PermissionInfo info, boolean async, int callingUid,
@@ -2195,8 +2135,7 @@
boolean overridePolicy, int callingUid, int userId,
PermissionCallback callback) {
PermissionManagerService.this.revokeRuntimePermission(permName, packageName,
- mSettings.getPermission(permName), overridePolicy, callingUid, userId,
- callback, false);
+ overridePolicy, callingUid, userId, callback);
}
@Override
public void updatePermissions(String packageName, Package pkg, boolean replaceGrant,