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

Unverified Commit ba7e9fa7 authored by Jing Ji's avatar Jing Ji Committed by Kevin F. Haggerty
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:d1c95670b248df945784b0f2830acf83b5682de3)
Merged-In: Iac6baa889965b8ffecd9a43179a4c96632ad1d02
AOSP-Change-Id: Iac6baa889965b8ffecd9a43179a4c96632ad1d02

Change-Id: I3a39b5e2b2ff0c314972ddeccb012894de704de8
parent 408a024e
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -3746,6 +3746,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) {