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

Commit f670a2fe authored by Jing Ji's avatar Jing Ji Committed by Android Build Coastguard Worker
Browse files

DO NOT MERGE: ActivityManager#killBackgroundProcesses can kill caller's own app only

unless it's a system app.

Bug: 239423414
Bug: 223376078
Test: atest CtsAppTestCases:ActivityManagerTest
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:f5943a364164f5d88cac42df7a7749a205932e7c)
Merged-In: Iac6baa889965b8ffecd9a43179a4c96632ad1d02
Change-Id: Iac6baa889965b8ffecd9a43179a4c96632ad1d02
parent 346a778e
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -3745,6 +3745,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) {