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

Commit a5fd75bf authored by Achim Thesmann's avatar Achim Thesmann
Browse files

Split visibility check

Fix the visibility check condition and create a separate return case for
persistent system processes.

Bug: 296478951
Test: atest BackgroundActivityLaunchTest
Change-Id: If3a594f7f1d7d82a39d143500cbe2b101da9eaaf
parent 07739727
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -716,17 +716,18 @@ public class BackgroundActivityStartController {
        // is allowed, or apps like live wallpaper with non app visible window will be allowed.
        final boolean appSwitchAllowedOrFg =
                appSwitchState == APP_SWITCH_ALLOW || appSwitchState == APP_SWITCH_FG_ONLY;
        final boolean allowCallingUidStartActivity =
                ((appSwitchAllowedOrFg || mService.mActiveUids.hasNonAppVisibleWindow(callingUid))
                        && callingUidHasAnyVisibleWindow)
                        || isCallingUidPersistentSystemProcess;
        if (allowCallingUidStartActivity) {
        if (appSwitchAllowedOrFg && callingUidHasAnyVisibleWindow) {
            return new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW,
                    /*background*/ false,
                    "callingUidHasAnyVisibleWindow = "
                            + callingUid
                            + ", isCallingUidPersistentSystemProcess = "
                            + isCallingUidPersistentSystemProcess);
                    /*background*/ false, "callingUid has visible window");
        }
        if (mService.mActiveUids.hasNonAppVisibleWindow(callingUid)) {
            return new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW,
                    /*background*/ false, "callingUid has non-app visible window");
        }

        if (isCallingUidPersistentSystemProcess) {
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_COMPONENT,
                    /*background*/ false, "callingUid is persistent system process");
        }

        // don't abort if the callingUid has START_ACTIVITIES_FROM_BACKGROUND permission