Prevent system reset staged installer bypass flag unexpactly

Perform stage installer check and consume bypass flag only when it's
creating stage session and was not calling from system/shell.

Fix: 159412477
Fix: 159684099
Test: atest CtsStagedInstallHostTestCases
Change-Id: Ic5439ad57b3c475d36746b1b36a99618c5b09ad6
This commit is contained in:
Jerry Chang
2020-06-30 12:47:55 +08:00
parent cdaa4f3cb0
commit acd05fa33e

View File

@@ -589,12 +589,12 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
}
}
if (mBypassNextStagedInstallerCheck) {
mBypassNextStagedInstallerCheck = false;
} else if (params.isStaged
&& !isCalledBySystemOrShell(callingUid)
&& !isWhitelistedStagedInstaller(requestedInstallerPackageName)) {
throw new SecurityException("Installer not allowed to commit staged install");
if (params.isStaged && !isCalledBySystemOrShell(callingUid)) {
if (mBypassNextStagedInstallerCheck) {
mBypassNextStagedInstallerCheck = false;
} else if (!isStagedInstallerAllowed(requestedInstallerPackageName)) {
throw new SecurityException("Installer not allowed to commit staged install");
}
}
if (!params.isMultiPackage) {
@@ -725,7 +725,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
|| callingUid == Process.SHELL_UID;
}
private boolean isWhitelistedStagedInstaller(String installerName) {
private boolean isStagedInstallerAllowed(String installerName) {
return SystemConfig.getInstance().getWhitelistedStagedInstallers().contains(installerName);
}