DO NOT MERGE Set app op mode to allowed when granting permissions to reset state.
We grant GRANTED_BY_DEFAULT permissions again when user clears data for a package to reset its state, but the app op mode needs to be granted as well. Fixes: 137723522 Test: presubmit & manual Change-Id: Ibbbbff9e5d8161538637a4c542d7c0bc92a90501
This commit is contained in:
@@ -19865,6 +19865,9 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
}
|
||||
};
|
||||
|
||||
final AppOpsManager appOpsManager = mContext.getSystemService(AppOpsManager.class);
|
||||
final int uid = UserHandle.getUid(userId, ps.pkg.applicationInfo.uid);
|
||||
|
||||
final int permissionCount = ps.pkg.requestedPermissions.size();
|
||||
for (int i = 0; i < permissionCount; i++) {
|
||||
final String permName = ps.pkg.requestedPermissions.get(i);
|
||||
@@ -19924,6 +19927,14 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
if ((oldFlags & FLAG_PERMISSION_GRANTED_BY_DEFAULT) != 0) {
|
||||
mPermissionManager.grantRuntimePermission(permName, packageName, false,
|
||||
Process.SYSTEM_UID, userId, delayingPermCallback);
|
||||
// Allow app op later as we are holding mPackages
|
||||
// PermissionPolicyService will handle the app op for foreground/background
|
||||
// permissions.
|
||||
String appOp = AppOpsManager.permissionToOp(permName);
|
||||
if (appOp != null) {
|
||||
mHandler.post(() -> appOpsManager.setUidMode(appOp, uid,
|
||||
AppOpsManager.MODE_ALLOWED));
|
||||
}
|
||||
// If permission review is enabled the permissions for a legacy apps
|
||||
// are represented as constantly granted runtime ones, so don't revoke.
|
||||
} else if ((flags & FLAG_PERMISSION_REVIEW_REQUIRED) == 0) {
|
||||
|
||||
Reference in New Issue
Block a user