Merge "Add missing isShellUser check" into oc-dev am: adc8f21ad1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12099340

Change-Id: Ie74d2561c45785dddc65efc46902a368c8a35736
This commit is contained in:
TreeHugger Robot
2020-07-31 05:32:49 +00:00
committed by Automerger Merge Worker

View File

@@ -4235,9 +4235,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) {