Merge "[pm] prevent non-debuggable app downgrades via shell"

This commit is contained in:
Song Chun Fan
2023-01-31 17:28:26 +00:00
committed by Android (Google) Code Review

View File

@@ -706,7 +706,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
}
}
if (Build.IS_DEBUGGABLE || isCalledBySystemOrShell(callingUid)) {
if (Build.IS_DEBUGGABLE || isCalledBySystem(callingUid)) {
params.installFlags |= PackageManager.INSTALL_ALLOW_DOWNGRADE;
} else {
params.installFlags &= ~PackageManager.INSTALL_ALLOW_DOWNGRADE;
@@ -916,6 +916,10 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
return sessionId;
}
private static boolean isCalledBySystem(int callingUid) {
return callingUid == Process.SYSTEM_UID || callingUid == Process.ROOT_UID;
}
private boolean isCalledBySystemOrShell(int callingUid) {
return callingUid == Process.SYSTEM_UID || callingUid == Process.ROOT_UID
|| callingUid == Process.SHELL_UID;