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

Commit 10c01c2f authored by John Reck's avatar John Reck Committed by Kevin Haggerty
Browse files

Add missing isShellUser check



Bug: 160390416
Test: verified command still works from shell

[basilgello: Back-port to 14.1:
 - {ROOT,SHELL}_UID -> Process.{ROOT,SHELL}_UID]
Signed-off-by: default avatarVasyl Gello <vasek.gello@gmail.com>

Change-Id: I23bb06e00f1623e4f27c02d7eb2c0d273b40771b
(cherry picked from commit 03542611)
Merged-In: I23bb06e00f1623e4f27c02d7eb2c0d273b40771b
(cherry picked from commit 5e2931c6)
(cherry picked from commit 4a31000e6072c14608ec1c59321481c8aa330313)
parent 3afe5662
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -4306,8 +4306,17 @@ public final class ActivityManagerService extends ActivityManagerNative
        return procState;
    }
    private boolean isCallerShell() {
        final int callingUid = Binder.getCallingUid();
        return callingUid == Process.SHELL_UID || callingUid == Process.ROOT_UID;
    }
    @Override
    public boolean setProcessMemoryTrimLevel(String process, int userId, int level) {
        if (!isCallerShell()) {
            EventLog.writeEvent(0x534e4554, 160390416, Binder.getCallingUid(), "");
            throw new SecurityException("Only shell can call it");
        }
        synchronized (this) {
            final ProcessRecord app = findProcessLocked(process, userId, "setProcessMemoryTrimLevel");
            if (app == null) {