Merge "Remove redundant module check when enabling rollback"

This commit is contained in:
Gavin Corkery
2020-10-19 19:03:28 +00:00
committed by Android (Google) Code Review

View File

@@ -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);
}
/**