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

Commit be31f46d authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Force another loc perm expansion

by moving it later. This change by itself does nothing, but we can
temporarily remove the sdkUpgradedFromP to force this change onto
everybody including people upgrading from Q to Q.

Bug: 118661683
Test: Upgraded from P->Q and saw location permission expanded.
Change-Id: Iaa32507547da19cfb00d6376035f904bd92913aa
parent 0f6bfd95
Loading
Loading
Loading
Loading
+32 −27
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ class RuntimePermissionsUpgradeController {
    private static final String LOG_TAG = RuntimePermissionsUpgradeController.class.getSimpleName();

    // The latest version of the runtime permissions database
    private static final int LATEST_VERSION = 6;
    private static final int LATEST_VERSION = 7;

    private RuntimePermissionsUpgradeController() {
        /* do nothing - hide constructor */
@@ -148,6 +148,36 @@ class RuntimePermissionsUpgradeController {
        }

        if (currentVersion == 4) {
            // moved to step 5->6 to clean up broken permission state during beta 4->5 upgrade
            currentVersion = 5;
        }

        if (currentVersion == 5) {
            Log.i(LOG_TAG, "Grandfathering Storage permissions");

            final List<String> storagePermissions = Utils.getPlatformPermissionNamesOfGroup(
                    Manifest.permission_group.STORAGE);

            for (int i = 0; i < appCount; i++) {
                final PackageInfo app = apps.get(i);
                if (app.requestedPermissions == null) {
                    continue;
                }

                // We don't want to allow modification of storage post install, so put it
                // on the internal system whitelist to prevent the installer changing it.
                for (String requestedPermission : app.requestedPermissions) {
                    if (storagePermissions.contains(requestedPermission)) {
                        context.getPackageManager().addWhitelistedRestrictedPermission(
                                app.packageName, requestedPermission,
                                PackageManager.FLAG_PERMISSION_WHITELIST_UPGRADE);
                    }
                }
            }
            currentVersion = 6;
        }

        if (currentVersion == 6) {
            if (sdkUpgradedFromP) {
                Log.i(LOG_TAG, "Expanding location permissions");

@@ -183,32 +213,7 @@ class RuntimePermissionsUpgradeController {
                        + "from Android P");
            }

            currentVersion = 5;
        }

        if (currentVersion == 5) {
            Log.i(LOG_TAG, "Grandfathering Storage permissions");

            final List<String> storagePermissions = Utils.getPlatformPermissionNamesOfGroup(
                    Manifest.permission_group.STORAGE);

            for (int i = 0; i < appCount; i++) {
                final PackageInfo app = apps.get(i);
                if (app.requestedPermissions == null) {
                    continue;
                }

                // We don't want to allow modification of storage post install, so put it
                // on the internal system whitelist to prevent the installer changing it.
                for (String requestedPermission : app.requestedPermissions) {
                    if (storagePermissions.contains(requestedPermission)) {
                        context.getPackageManager().addWhitelistedRestrictedPermission(
                                app.packageName, requestedPermission,
                                PackageManager.FLAG_PERMISSION_WHITELIST_UPGRADE);
                    }
                }
            }
            currentVersion = 6;
            currentVersion = 7;
        }

        // XXX: Add new upgrade steps above this point.