DO NOT MERGE Fix auto-grant of AR runtime permission if device is upgrading from pre-Q
Test: Manually install app apks targeting Q and verifying that AR permission is not auto-granted Test: atest ActivityRecognitionPermissionTest Bug: 210065877 Change-Id: I7004055c9573d17f31255c2b1adee1e0aeeb238f
This commit is contained in:
@@ -998,4 +998,10 @@ public abstract class PackageManagerInternal {
|
||||
* Returns {@code true} if the package is suspending any packages for the user.
|
||||
*/
|
||||
public abstract boolean isSuspendingAnyPackages(String suspendingPackage, int userId);
|
||||
|
||||
/**
|
||||
* Get installed SDK version of the package
|
||||
* @param pkg package for which to retrieve the installed sdk version
|
||||
*/
|
||||
public abstract int getInstalledSdkVersion(AndroidPackage pkg);
|
||||
}
|
||||
|
||||
@@ -25208,6 +25208,11 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
public boolean isSuspendingAnyPackages(String suspendingPackage, int userId) {
|
||||
return PackageManagerService.this.isSuspendingAnyPackages(suspendingPackage, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledSdkVersion(AndroidPackage pkg) {
|
||||
return PackageManagerService.this.getSettingsVersionForPackage(pkg).sdkVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@GuardedBy("mLock")
|
||||
|
||||
@@ -2755,7 +2755,7 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
||||
// uids the original and new state are the same object
|
||||
if (!origPermissions.hasRequestedPermission(permName)
|
||||
&& (pkg.getImplicitPermissions().contains(permName)
|
||||
|| (permName.equals(Manifest.permission.ACTIVITY_RECOGNITION)))) {
|
||||
|| (permName.equals(Manifest.permission.ACTIVITY_RECOGNITION)))) {
|
||||
if (pkg.getImplicitPermissions().contains(permName)) {
|
||||
// If permName is an implicit permission, try to auto-grant
|
||||
newImplicitPermissions.add(permName);
|
||||
@@ -2771,21 +2771,28 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
||||
// 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.
|
||||
final List<SplitPermissionInfoParcelable> permissionList =
|
||||
getSplitPermissions();
|
||||
int numSplitPerms = permissionList.size();
|
||||
for (int splitPermNum = 0; splitPermNum < numSplitPerms; splitPermNum++) {
|
||||
SplitPermissionInfoParcelable sp = permissionList.get(splitPermNum);
|
||||
String splitPermName = sp.getSplitPermission();
|
||||
if (sp.getNewPermissions().contains(permName)
|
||||
&& origPermissions.hasInstallPermission(splitPermName)) {
|
||||
upgradedActivityRecognitionPermission = splitPermName;
|
||||
newImplicitPermissions.add(permName);
|
||||
// b/210065877: Check that the installed version is pre Q to auto-grant in
|
||||
// case of OS update
|
||||
if (mPackageManagerInt.getInstalledSdkVersion(pkg)
|
||||
< Build.VERSION_CODES.Q) {
|
||||
final List<SplitPermissionInfoParcelable> permissionList =
|
||||
getSplitPermissions();
|
||||
int numSplitPerms = permissionList.size();
|
||||
for (int splitPermNum = 0; splitPermNum < numSplitPerms;
|
||||
splitPermNum++) {
|
||||
SplitPermissionInfoParcelable sp = permissionList.get(splitPermNum);
|
||||
String splitPermName = sp.getSplitPermission();
|
||||
if (sp.getNewPermissions().contains(permName)
|
||||
&& origPermissions.hasInstallPermission(splitPermName)) {
|
||||
upgradedActivityRecognitionPermission = splitPermName;
|
||||
newImplicitPermissions.add(permName);
|
||||
|
||||
if (DEBUG_PERMISSIONS) {
|
||||
Slog.i(TAG, permName + " is newly added for " + friendlyName);
|
||||
if (DEBUG_PERMISSIONS) {
|
||||
Slog.i(TAG, permName + " is newly added for "
|
||||
+ friendlyName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user