Add missing isShellUser check

Bug: 160390416
Test: verified command still works from shell
Change-Id: I23bb06e00f1623e4f27c02d7eb2c0d273b40771b
(cherry picked from commit 0354261197)
Merged-In: I23bb06e00f1623e4f27c02d7eb2c0d273b40771b
This commit is contained in:
John Reck
2020-07-06 16:10:49 -07:00
parent 3bc3d3e0a3
commit 3a5cd5bbe3

View File

@@ -4260,9 +4260,18 @@ public class ActivityManagerService extends IActivityManager.Stub
return procState; return procState;
} }
private boolean isCallerShell() {
final int callingUid = Binder.getCallingUid();
return callingUid == SHELL_UID || callingUid == ROOT_UID;
}
@Override @Override
public boolean setProcessMemoryTrimLevel(String process, int userId, int level) public boolean setProcessMemoryTrimLevel(String process, int userId, int level)
throws RemoteException { throws RemoteException {
if (!isCallerShell()) {
EventLog.writeEvent(0x534e4554, 160390416, Binder.getCallingUid(), "");
throw new SecurityException("Only shell can call it");
}
synchronized (this) { synchronized (this) {
final ProcessRecord app = findProcessLocked(process, userId, "setProcessMemoryTrimLevel"); final ProcessRecord app = findProcessLocked(process, userId, "setProcessMemoryTrimLevel");
if (app == null) { if (app == null) {