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

Commit 5cf9f41e authored by Varun Shah's avatar Varun Shah
Browse files

Added an app id security check in isAppForeground.

ActivityManagerService#isAppForeground now checks if the caller has the
permission to view if an app is in the foreground.

Bug: 115384617
Test: atest cts/tests/tests/security/src/android/security/cts/ActivityManagerTest.java#testActivityManager_checkAppInForegroundCall
Change-Id: I9602c89b2d40036e525c38960a08326dc74c6682
parent abc7143e
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -5137,6 +5137,14 @@ public class ActivityManagerService extends IActivityManager.Stub
    @Override
    public boolean isAppForeground(int uid) {
        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) {