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

Commit 9a142670 authored by Jing Ji's avatar Jing Ji
Browse files

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
Merged-In: I35d20539ffac055a6d61260445620f45584bd9c5
Merged-In: Ieed6af77da1bc31cfecc5272b9f97971db7ae7b2
Merged-In: I8b8a427ee87339cc038e53adc0912283b05d2cfc
Change-Id: I9471a77188ee63ec32cd0c81569193e4ccad885b
parent 3569c110
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -3690,6 +3690,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) {
@@ -3730,22 +3746,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) {