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

Commit 79b700bb authored by Achim Thesmann's avatar Achim Thesmann
Browse files

Use correct feature to opt in non-PendingIntents

Opting in non-PendingIntents to allow BAL requires the fix in the
visibility check (so that it does not break existing CTS tests).

Test: atest BackgroundActivityLaunchTests (next + feature flag)
Bug: 321421781
Change-Id: I2f33aec6c048032ab6ad27f0dfd419be4ea2b8d6
parent d6c1282c
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLAS
import static com.android.server.wm.ActivityTaskManagerService.APP_SWITCH_ALLOW;
import static com.android.server.wm.ActivityTaskManagerService.APP_SWITCH_FG_ONLY;
import static com.android.server.wm.ActivityTaskSupervisor.getApplicationLabel;
import static com.android.window.flags.Flags.balImproveRealCallerVisibilityCheck;
import static com.android.window.flags.Flags.balRequireOptInByPendingIntentCreator;
import static com.android.window.flags.Flags.balRequireOptInSameUid;
import static com.android.window.flags.Flags.balShowToasts;
@@ -69,7 +70,6 @@ import com.android.internal.util.FrameworkStatsLog;
import com.android.internal.util.Preconditions;
import com.android.server.UiThread;
import com.android.server.am.PendingIntentRecord;
import com.android.window.flags.Flags;

import java.lang.annotation.Retention;
import java.util.HashMap;
@@ -274,10 +274,13 @@ public class BackgroundActivityStartController {
            @BackgroundActivityStartMode int realCallerBackgroundActivityStartMode =
                    checkedOptions.getPendingIntentBackgroundActivityStartMode();

            if (balRequireOptInByPendingIntentCreator() && originatingPendingIntent == null) {
                mAutoOptInReason = "notPendingIntent";
            } else if (balRequireOptInByPendingIntentCreator() && mIsCallForResult) {
            if (!balImproveRealCallerVisibilityCheck()) {
                // without this fix the auto-opt ins below would violate CTS tests
                mAutoOptInReason = null;
            } else if (mIsCallForResult) {
                mAutoOptInReason = "callForResult";
            } else if (originatingPendingIntent == null) {
                mAutoOptInReason = "notPendingIntent";
            } else if (callingUid == realCallingUid && !balRequireOptInSameUid()) {
                mAutoOptInReason = "sameUid";
            } else {
@@ -949,7 +952,7 @@ public class BackgroundActivityStartController {
        // is allowed, or apps like live wallpaper with non app visible window will be allowed.
        final boolean appSwitchAllowedOrFg = state.mAppSwitchState == APP_SWITCH_ALLOW
                || state.mAppSwitchState == APP_SWITCH_FG_ONLY;
        if (Flags.balImproveRealCallerVisibilityCheck()) {
        if (balImproveRealCallerVisibilityCheck()) {
            if (appSwitchAllowedOrFg && state.mRealCallingUidHasAnyVisibleWindow) {
                return new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW,
                        /*background*/ false, "realCallingUid has visible window");