Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d4d6b18e authored by Ganesh Olekar's avatar Ganesh Olekar
Browse files

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
parent cc020a24
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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);
}
+5 −0
Original line number Diff line number Diff line
@@ -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")
+21 −14
Original line number Diff line number Diff line
@@ -2771,10 +2771,15 @@ 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.
                        // 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++) {
                            for (int splitPermNum = 0; splitPermNum < numSplitPerms;
                                    splitPermNum++) {
                                SplitPermissionInfoParcelable sp = permissionList.get(splitPermNum);
                                String splitPermName = sp.getSplitPermission();
                                if (sp.getNewPermissions().contains(permName)
@@ -2783,13 +2788,15 @@ public class PermissionManagerService extends IPermissionManager.Stub {
                                    newImplicitPermissions.add(permName);

                                    if (DEBUG_PERMISSIONS) {
                                    Slog.i(TAG, permName + " is newly added for " + friendlyName);
                                        Slog.i(TAG, permName + " is newly added for "
                                                + friendlyName);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }

                // 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