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

Commit a1bd6260 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5637155 from cbdd0fb5 to qt-qpr1-release

Change-Id: I035b65151fc31987ad358c40b51660d1e27d9fef
parents 62755854 cbdd0fb5
Loading
Loading
Loading
Loading
+27 −22
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 = 5;
    private static final int LATEST_VERSION = 6;

    private RuntimePermissionsUpgradeController() {
        /* do nothing - hide constructor */
@@ -121,27 +121,7 @@ class RuntimePermissionsUpgradeController {
        }

        if (currentVersion == 2) {
            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);
                    }
                }
            }
            // moved to step 5->6 to clean up broken permission state during dogfooding
            currentVersion = 3;
        }

@@ -206,6 +186,31 @@ class RuntimePermissionsUpgradeController {
            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;
        }

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

        return currentVersion;