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

Commit c4a31ca3 authored by Gavin Corkery's avatar Gavin Corkery Committed by Android (Google) Code Review
Browse files

Merge "Remove redundant module check when enabling rollback"

parents 967aae75 38bdaef0
Loading
Loading
Loading
Loading
+4 −22
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentSender;
import android.content.pm.ApplicationInfo;
import android.content.pm.ModuleInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager;
@@ -1089,8 +1088,8 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub implements Rollba
                Manifest.permission.TEST_MANAGE_ROLLBACKS,
                installerPackageName) == PackageManager.PERMISSION_GRANTED;

        // For now only allow rollbacks for modules or for testing.
        return (isRollbackWhitelisted(packageName) && manageRollbacksGranted)
        // For now only allow rollbacks for allowlisted packages or for testing.
        return (isRollbackAllowlisted(packageName) && manageRollbacksGranted)
            || testManageRollbacksGranted;
    }

@@ -1098,25 +1097,8 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub implements Rollba
     * Returns true is this package is eligible for enabling rollback.
     */
    @AnyThread
    private boolean isRollbackWhitelisted(String packageName) {
        // TODO: Remove #isModule when the allowlist is ready.
        return SystemConfig.getInstance().getRollbackWhitelistedPackages().contains(packageName)
                || isModule(packageName);
    }
    /**
     * Returns true if the package name is the name of a module.
     */
    @AnyThread
    private boolean isModule(String packageName) {
        PackageManager pm = mContext.getPackageManager();
        final ModuleInfo moduleInfo;
        try {
            moduleInfo = pm.getModuleInfo(packageName, 0);
        } catch (PackageManager.NameNotFoundException e) {
            return false;
        }

        return moduleInfo != null;
    private boolean isRollbackAllowlisted(String packageName) {
        return SystemConfig.getInstance().getRollbackWhitelistedPackages().contains(packageName);
    }

    /**