Merge "DO NOT MERGE Fix auto-grant of AR runtime permission if device is upgrading from pre-Q" into rvc-qpr-dev

This commit is contained in:
Ganesh Olekar
2022-08-24 16:55:00 +00:00
committed by Android (Google) Code Review
3 changed files with 32 additions and 14 deletions

View File

@@ -998,4 +998,10 @@ public abstract class PackageManagerInternal {
* Returns {@code true} if the package is suspending any packages for the user. * Returns {@code true} if the package is suspending any packages for the user.
*/ */
public abstract boolean isSuspendingAnyPackages(String suspendingPackage, int userId); 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);
} }

View File

@@ -25209,6 +25209,11 @@ public class PackageManagerService extends IPackageManager.Stub
public boolean isSuspendingAnyPackages(String suspendingPackage, int userId) { public boolean isSuspendingAnyPackages(String suspendingPackage, int userId) {
return PackageManagerService.this.isSuspendingAnyPackages(suspendingPackage, userId); return PackageManagerService.this.isSuspendingAnyPackages(suspendingPackage, userId);
} }
@Override
public int getInstalledSdkVersion(AndroidPackage pkg) {
return PackageManagerService.this.getSettingsVersionForPackage(pkg).sdkVersion;
}
} }
@GuardedBy("mLock") @GuardedBy("mLock")

View File

@@ -2771,10 +2771,15 @@ public class PermissionManagerService extends IPermissionManager.Stub {
// or has updated its target SDK and AR is no longer implicit to it. // 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 // This is a compatibility workaround for apps when AR permission was
// split in Q. // split in Q.
// 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 = final List<SplitPermissionInfoParcelable> permissionList =
getSplitPermissions(); getSplitPermissions();
int numSplitPerms = permissionList.size(); int numSplitPerms = permissionList.size();
for (int splitPermNum = 0; splitPermNum < numSplitPerms; splitPermNum++) { for (int splitPermNum = 0; splitPermNum < numSplitPerms;
splitPermNum++) {
SplitPermissionInfoParcelable sp = permissionList.get(splitPermNum); SplitPermissionInfoParcelable sp = permissionList.get(splitPermNum);
String splitPermName = sp.getSplitPermission(); String splitPermName = sp.getSplitPermission();
if (sp.getNewPermissions().contains(permName) if (sp.getNewPermissions().contains(permName)
@@ -2783,13 +2788,15 @@ public class PermissionManagerService extends IPermissionManager.Stub {
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);
} }
break; break;
} }
} }
} }
} }
}
// TODO(b/140256621): The package instant app method has been removed // TODO(b/140256621): The package instant app method has been removed
// as part of work in b/135203078, so this has been commented out in the meantime // as part of work in b/135203078, so this has been commented out in the meantime