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

Commit abff7881 authored by Varun Shah's avatar Varun Shah Committed by android-build-merger
Browse files

Merge "RESTRICT AUTOMERGE: Added an app id security check in isAppForeground."...

Merge "RESTRICT AUTOMERGE: Added an app id security check in isAppForeground." into oc-dev am: 546ba589
am: 84376cb9

Change-Id: I096470de6d03ab34591b12bc7172056a1ffe38ed
parents 3c53f926 84376cb9
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -131,6 +131,19 @@ public final class UserHandle implements Parcelable {
        }
    }

    /**
     * Whether a UID belongs to a system core component or not.
     * @hide
     */
    public static boolean isCore(int uid) {
        if (uid >= 0) {
            final int appId = getAppId(uid);
            return appId < Process.FIRST_APPLICATION_UID;
        } else {
            return false;
        }
    }

    /**
     * Returns the user for a given uid.
     * @param uid A uid for an application running in a particular user.
+8 −0
Original line number Diff line number Diff line
@@ -8021,6 +8021,14 @@ public class ActivityManagerService extends IActivityManager.Stub
    @Override
    public boolean isAppForeground(int uid) throws RemoteException {
        int callerUid = Binder.getCallingUid();
        if (UserHandle.isCore(callerUid) || callerUid == uid) {
            return isAppForegroundInternal(uid);
        }
        return false;
    }
    private boolean isAppForegroundInternal(int uid) {
        synchronized (this) {
            UidRecord uidRec = mActiveUids.get(uid);
            if (uidRec == null || uidRec.idle) {