From 8f3de48e1947ef00c0f52c4b972f5def09840660 Mon Sep 17 00:00:00 2001 From: John Reck Date: Mon, 6 Jul 2020 16:10:49 -0700 Subject: [PATCH] Add missing isShellUser check Bug: 160390416 Test: verified command still works from shell Change-Id: I23bb06e00f1623e4f27c02d7eb2c0d273b40771b Merged-In: I23bb06e00f1623e4f27c02d7eb2c0d273b40771b --- .../java/com/android/server/am/ActivityManagerService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 0d9b907cddfdc..781b085751992 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -3171,6 +3171,10 @@ public class ActivityManagerService extends IActivityManager.Stub @Override public boolean setProcessMemoryTrimLevel(String process, int userId, int level) throws RemoteException { + 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) {