summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJing Ji <jji@google.com>2023-10-19 14:22:58 -0700
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-11-28 17:34:14 +0000
commit476078b2948e5ffe8ade4927946ba51da39aeead (patch)
tree3fac55778ae623c2a24564ba0151d53b436d5f83
parent749a862c02eccdc83e4382588119ab4941a3a854 (diff)
downloadbase-476078b2948e5ffe8ade4927946ba51da39aeead.tar.gz
DO NOT MERGE: Fix ActivityManager#killBackgroundProcesses permissions
In the pevious CL, we incorrectly added the permission check in the killBackgroundProcessesExcept. Now fix this issue. Bug: 239423414 Bug: 223376078 Test: atest CtsAppTestCases:ActivityManagerTest (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:140fce861944419a375c669010c6c47cd7ff5b37) Merged-In: I9471a77188ee63ec32cd0c81569193e4ccad885b Change-Id: I9471a77188ee63ec32cd0c81569193e4ccad885b
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java32
1 files changed, 16 insertions, 16 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index c01fa239a4b4..e94ee6024d40 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -3663,6 +3663,22 @@ public class ActivityManagerService extends IActivityManager.Stub
throw new SecurityException(msg);
}
+ final int callingUid = Binder.getCallingUid();
+ final int callingPid = Binder.getCallingPid();
+
+ ProcessRecord proc;
+ synchronized (mPidsSelfLocked) {
+ proc = mPidsSelfLocked.get(callingPid);
+ }
+ if (callingUid >= FIRST_APPLICATION_UID
+ && (proc == null || !proc.info.isSystemApp())) {
+ final String msg = "Permission Denial: killAllBackgroundProcesses() from pid="
+ + callingPid + ", uid=" + callingUid + " is not allowed";
+ Slog.w(TAG, msg);
+ // Silently return to avoid existing apps from crashing.
+ return;
+ }
+
final long callingId = Binder.clearCallingIdentity();
try {
synchronized (this) {
@@ -3703,22 +3719,6 @@ public class ActivityManagerService extends IActivityManager.Stub
throw new SecurityException(msg);
}
- final int callingUid = Binder.getCallingUid();
- final int callingPid = Binder.getCallingPid();
-
- ProcessRecord proc;
- synchronized (mPidsSelfLocked) {
- proc = mPidsSelfLocked.get(callingPid);
- }
- if (callingUid >= FIRST_APPLICATION_UID
- && (proc == null || !proc.info.isSystemApp())) {
- final String msg = "Permission Denial: killAllBackgroundProcesses() from pid="
- + callingPid + ", uid=" + callingUid + " is not allowed";
- Slog.w(TAG, msg);
- // Silently return to avoid existing apps from crashing.
- return;
- }
-
final long callingId = Binder.clearCallingIdentity();
try {
synchronized (this) {