[automerge] DO NOT MERGE Fix auto-grant of AR runtime permission if device is upgrading from pre-Q 2p: 23aac9cb8e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19500370 Bug: 210065877 Change-Id: I8304dc2102aa472d836d17155c35f41f391fb45a
This commit is contained in:
committed by
Presubmit Automerger Backend
commit
3ea7195f3b
@@ -2764,7 +2764,6 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
|||||||
final Permission bp = mRegistry.getPermission(permName);
|
final Permission bp = mRegistry.getPermission(permName);
|
||||||
final boolean appSupportsRuntimePermissions =
|
final boolean appSupportsRuntimePermissions =
|
||||||
pkg.getTargetSdkVersion() >= Build.VERSION_CODES.M;
|
pkg.getTargetSdkVersion() >= Build.VERSION_CODES.M;
|
||||||
String legacyActivityRecognitionPermission = null;
|
|
||||||
|
|
||||||
if (DEBUG_INSTALL && bp != null) {
|
if (DEBUG_INSTALL && bp != null) {
|
||||||
Log.i(TAG, "Package " + friendlyName
|
Log.i(TAG, "Package " + friendlyName
|
||||||
@@ -2788,47 +2787,12 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
|||||||
// Cache newImplicitPermissions before modifing permissionsState as for the
|
// Cache newImplicitPermissions before modifing permissionsState as for the
|
||||||
// shared uids the original and new state are the same object
|
// shared uids the original and new state are the same object
|
||||||
if (!origState.hasPermissionState(permName)
|
if (!origState.hasPermissionState(permName)
|
||||||
&& (pkg.getImplicitPermissions().contains(permName)
|
&& (pkg.getImplicitPermissions().contains(permName))) {
|
||||||
|| (permName.equals(Manifest.permission.ACTIVITY_RECOGNITION)))) {
|
|
||||||
if (pkg.getImplicitPermissions().contains(permName)) {
|
|
||||||
// If permName is an implicit permission, try to auto-grant
|
// If permName is an implicit permission, try to auto-grant
|
||||||
newImplicitPermissions.add(permName);
|
newImplicitPermissions.add(permName);
|
||||||
|
|
||||||
if (DEBUG_PERMISSIONS) {
|
if (DEBUG_PERMISSIONS) {
|
||||||
Slog.i(TAG, permName + " is newly added for " + friendlyName);
|
Slog.i(TAG, permName + " is newly added for " + friendlyName);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Special case for Activity Recognition permission. Even if AR
|
|
||||||
// permission is not an implicit permission we want to add it to the
|
|
||||||
// list (try to auto-grant it) if the app was installed on a device
|
|
||||||
// before AR permission was split, regardless of if the app now requests
|
|
||||||
// the new AR permission or has updated its target SDK and AR is no
|
|
||||||
// longer implicit to it. This is a compatibility workaround for apps
|
|
||||||
// when AR permission was split in Q.
|
|
||||||
// TODO(zhanghai): This calls into SystemConfig, which generally
|
|
||||||
// shouldn't cause deadlock, but maybe we should keep a cache of the
|
|
||||||
// split permission list and just eliminate the possibility.
|
|
||||||
final List<PermissionManager.SplitPermissionInfo> permissionList =
|
|
||||||
getSplitPermissionInfos();
|
|
||||||
int numSplitPerms = permissionList.size();
|
|
||||||
for (int splitPermNum = 0; splitPermNum < numSplitPerms;
|
|
||||||
splitPermNum++) {
|
|
||||||
PermissionManager.SplitPermissionInfo sp = permissionList.get(
|
|
||||||
splitPermNum);
|
|
||||||
String splitPermName = sp.getSplitPermission();
|
|
||||||
if (sp.getNewPermissions().contains(permName)
|
|
||||||
&& origState.isPermissionGranted(splitPermName)) {
|
|
||||||
legacyActivityRecognitionPermission = splitPermName;
|
|
||||||
newImplicitPermissions.add(permName);
|
|
||||||
|
|
||||||
if (DEBUG_PERMISSIONS) {
|
|
||||||
Slog.i(TAG, permName + " is newly added for "
|
|
||||||
+ friendlyName);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(b/140256621): The package instant app method has been removed
|
// TODO(b/140256621): The package instant app method has been removed
|
||||||
@@ -2959,8 +2923,7 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
|||||||
// Hard restricted permissions cannot be held.
|
// Hard restricted permissions cannot be held.
|
||||||
} else if (!permissionPolicyInitialized
|
} else if (!permissionPolicyInitialized
|
||||||
|| (!hardRestricted || restrictionExempt)) {
|
|| (!hardRestricted || restrictionExempt)) {
|
||||||
if ((origPermState != null && origPermState.isGranted())
|
if ((origPermState != null && origPermState.isGranted())) {
|
||||||
|| legacyActivityRecognitionPermission != null) {
|
|
||||||
if (!uidState.grantPermission(bp)) {
|
if (!uidState.grantPermission(bp)) {
|
||||||
wasChanged = true;
|
wasChanged = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user