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

Commit b6540144 authored by Song Chun Fan's avatar Song Chun Fan Committed by Android (Google) Code Review
Browse files

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

parents 860119e2 435c8fe2
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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;