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

Commit 644d71b0 authored by Achim Thesmann's avatar Achim Thesmann Committed by Android (Google) Code Review
Browse files

Merge changes Ide580fb2,Ide0fa068 into main

* changes:
  Remove mBalAllowedByPiCreatorWithHardening
  Remove unused "background" flag
parents 05e1ba2d e7ba1304
Loading
Loading
Loading
Loading
+27 −66
Original line number Diff line number Diff line
@@ -312,7 +312,6 @@ public class BackgroundActivityStartController {
        private final @ActivityManager.ProcessState int mCallingUidProcState;
        private final boolean mIsCallingUidPersistentSystemProcess;
        final BackgroundStartPrivileges mBalAllowedByPiSender;
        final BackgroundStartPrivileges mBalAllowedByPiCreatorWithHardening;
        final BackgroundStartPrivileges mBalAllowedByPiCreator;
        private final String mRealCallingPackage;
        private final int mRealCallingUid;
@@ -379,22 +378,14 @@ public class BackgroundActivityStartController {

            if (mAutoOptInCaller) {
                // grant BAL privileges unless explicitly opted out
                mBalAllowedByPiCreatorWithHardening = mBalAllowedByPiCreator =
                mBalAllowedByPiCreator =
                        callerBackgroundActivityStartMode == MODE_BACKGROUND_ACTIVITY_START_DENIED
                                ? BackgroundStartPrivileges.NONE
                                : BackgroundStartPrivileges.ALLOW_BAL;
            } else {
                // for PendingIntents we restrict BAL based on target_sdk
                mBalAllowedByPiCreatorWithHardening = getBackgroundStartPrivilegesAllowedByCreator(
                mBalAllowedByPiCreator = getBackgroundStartPrivilegesAllowedByCreator(
                        callingUid, callingPackage, checkedOptions);
                final BackgroundStartPrivileges mBalAllowedByPiCreatorWithoutHardening =
                        callerBackgroundActivityStartMode
                                == MODE_BACKGROUND_ACTIVITY_START_DENIED
                                ? BackgroundStartPrivileges.NONE
                                : BackgroundStartPrivileges.ALLOW_BAL;
                mBalAllowedByPiCreator = balRequireOptInByPendingIntentCreator()
                        ? mBalAllowedByPiCreatorWithHardening
                        : mBalAllowedByPiCreatorWithoutHardening;
            }

            if (mAutoOptInReason != null) {
@@ -585,9 +576,8 @@ public class BackgroundActivityStartController {
            if (mCallerApp != null) {
                sb.append("; inVisibleTask: ").append(mCallerApp.hasActivityInVisibleTask());
            }
            sb.append("; balAllowedByPiCreator: ").append(mBalAllowedByPiCreator);
            sb.append("; balAllowedByPiCreatorWithHardening: ")
                    .append(mBalAllowedByPiCreatorWithHardening);
            sb.append("; balAllowedByPiCreator: ")
                    .append(mBalAllowedByPiCreator);
            if (mResultForCaller != null) {
                sb.append("; resultIfPiCreatorAllowsBal: ")
                        .append(balCodeToString(mResultForCaller.mCode));
@@ -638,14 +628,13 @@ public class BackgroundActivityStartController {
    }

    static class BalVerdict {
        static final BalVerdict BLOCK = new BalVerdict(BAL_BLOCK, false, "Blocked");
        static final BalVerdict BLOCK = new BalVerdict(BAL_BLOCK, "Blocked");
        static final BalVerdict ALLOW_BY_DEFAULT =
                new BalVerdict(BAL_ALLOW_DEFAULT, false, "Default");
                new BalVerdict(BAL_ALLOW_DEFAULT, "Default");
        // Careful using this - it will bypass all ASM checks.
        static final BalVerdict ALLOW_PRIVILEGED =
                new BalVerdict(BAL_ALLOW_ALLOWLISTED_UID, false, "PRIVILEGED");
                new BalVerdict(BAL_ALLOW_ALLOWLISTED_UID, "PRIVILEGED");
        private final @BalCode int mCode;
        private final boolean mBackground;
        private final String mMessage;
        private String mProcessInfo;
        // indicates BAL would be blocked because only creator of the PI has the privilege to allow
@@ -654,8 +643,7 @@ public class BackgroundActivityStartController {
        /** indicates that this verdict is based on the real calling UID and not the calling UID */
        private boolean mBasedOnRealCaller;

        BalVerdict(@BalCode int balCode, boolean background, String message) {
            this.mBackground = background;
        BalVerdict(@BalCode int balCode, String message) {
            this.mCode = balCode;
            this.mMessage = message;
        }
@@ -708,16 +696,7 @@ public class BackgroundActivityStartController {
                    builder.append(" [realCaller]");
                }
                if (DEBUG_ACTIVITY_STARTS) {
                    builder.append(" (");
                    if (mBackground) {
                        builder.append("Background ");
                    }
                    builder.append("Activity start ");
                    if (mCode == BAL_BLOCK) {
                        builder.append("denied");
                    } else {
                        builder.append("allowed: ").append(mMessage);
                    }
                    builder.append(" (").append(mMessage);
                    if (mProcessInfo != null) {
                        builder.append(" ");
                        builder.append(mProcessInfo);
@@ -795,7 +774,6 @@ public class BackgroundActivityStartController {
            // to realCallingUid when calculating resultForRealCaller below.
            if (getService().hasActiveVisibleWindow(realCallingSdkSandboxUidToAppUid)) {
                state.setResultForRealCaller(new BalVerdict(BAL_ALLOW_SDK_SANDBOX,
                        /*background*/ false,
                        "uid in SDK sandbox has visible (non-toast) window"));
                return allowBasedOnRealCaller(state);
            }
@@ -1059,8 +1037,7 @@ public class BackgroundActivityStartController {
                || state.mAppSwitchState == APP_SWITCH_FG_ONLY
                || isHomeApp(state.mCallingUid, state.mCallingPackage);
        if (appSwitchAllowedOrFg && state.mCallingUidHasVisibleActivity) {
            return new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW,
                    /*background*/ false, "callingUid has visible window");
            return new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, "callingUid has visible window");
        }
        return BalVerdict.BLOCK;
    };
@@ -1068,7 +1045,7 @@ public class BackgroundActivityStartController {
    private final BalExemptionCheck mCheckCallerNonAppVisible = state -> {
        if (state.mCallingUidHasNonAppVisibleWindow) {
            return new BalVerdict(BAL_ALLOW_NON_APP_VISIBLE_WINDOW,
                    /*background*/ false, "callingUid has non-app visible window "
                    "callingUid has non-app visible window "
                    + getService().mActiveUids.getNonAppVisibleWindowDetails(state.mCallingUid));
        }
        return BalVerdict.BLOCK;
@@ -1080,9 +1057,7 @@ public class BackgroundActivityStartController {
        if (state.mCallingUid == Process.ROOT_UID
                || callingAppId == Process.SYSTEM_UID
                || callingAppId == Process.NFC_UID) {
            return new BalVerdict(
                    BAL_ALLOW_ALLOWLISTED_UID, /*background*/ false,
                    "Important callingUid");
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_UID, "Important callingUid");
        }
        return BalVerdict.BLOCK;
    };
@@ -1090,9 +1065,7 @@ public class BackgroundActivityStartController {
    private final BalExemptionCheck mCheckCallerIsAllowlistedComponent = state -> {
        // Always allow home application to start activities.
        if (isHomeApp(state.mCallingUid, state.mCallingPackage)) {
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_COMPONENT,
                    /*background*/ false,
                    "Home app");
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_COMPONENT, "Home app");
        }

        final int callingAppId = UserHandle.getAppId(state.mCallingUid);
@@ -1100,37 +1073,31 @@ public class BackgroundActivityStartController {
        final WindowState imeWindow =
                getService().mRootWindowContainer.getCurrentInputMethodWindow();
        if (imeWindow != null && callingAppId == imeWindow.mOwnerUid) {
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_COMPONENT,
                    /*background*/ false,
                    "Active ime");
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_COMPONENT, "Active ime");
        }

        // don't abort if the callingUid is a persistent system process
        if (state.mIsCallingUidPersistentSystemProcess) {
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_COMPONENT,
                    /*background*/ false, "callingUid is persistent system process");
                    "callingUid is persistent system process");
        }

        // don't abort if the caller has the same uid as the recents component
        if (getSupervisor().mRecentTasks.isCallerRecents(state.mCallingUid)) {
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_COMPONENT,
                    /*background*/ true, "Recents Component");
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_COMPONENT, "Recents Component");
        }
        // don't abort if the callingUid is the device owner
        if (getService().isDeviceOwner(state.mCallingUid)) {
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_COMPONENT,
                    /*background*/ true, "Device Owner");
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_COMPONENT, "Device Owner");
        }
        // don't abort if the callingUid is a affiliated profile owner
        if (getService().isAffiliatedProfileOwner(state.mCallingUid)) {
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_COMPONENT,
                    /*background*/ true, "Affiliated Profile Owner");
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_COMPONENT, "Affiliated Profile Owner");
        }
        // don't abort if the callingUid has companion device
        final int callingUserId = UserHandle.getUserId(state.mCallingUid);
        if (getService().isAssociatedCompanionApp(callingUserId, state.mCallingUid)) {
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_COMPONENT,
                    /*background*/ true, "Companion App");
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_COMPONENT, "Companion App");
        }
        return BalVerdict.BLOCK;
    };
@@ -1139,7 +1106,6 @@ public class BackgroundActivityStartController {
        // don't abort if the callingUid has START_ACTIVITIES_FROM_BACKGROUND permission
        if (hasBalPermission(state.mCallingUid, state.mCallingPid)) {
            return new BalVerdict(BAL_ALLOW_PERMISSION,
                    /*background*/ true,
                    "START_ACTIVITIES_FROM_BACKGROUND permission granted");
        }
        return BalVerdict.BLOCK;
@@ -1149,7 +1115,7 @@ public class BackgroundActivityStartController {
        if (getService().hasSystemAlertWindowPermission(state.mCallingUid, state.mCallingPid,
                state.mCallingPackage)) {
            return new BalVerdict(BAL_ALLOW_SAW_PERMISSION,
                    /*background*/ true, "SYSTEM_ALERT_WINDOW permission is granted");
                    "SYSTEM_ALERT_WINDOW permission is granted");
        }
        return BalVerdict.BLOCK;
    };
@@ -1159,7 +1125,7 @@ public class BackgroundActivityStartController {
        if (isSystemExemptFlagEnabled() && getService().getAppOpsManager().checkOpNoThrow(
                AppOpsManager.OP_SYSTEM_EXEMPT_FROM_ACTIVITY_BG_START_RESTRICTION,
                state.mCallingUid, state.mCallingPackage) == AppOpsManager.MODE_ALLOWED) {
            return new BalVerdict(BAL_ALLOW_PERMISSION, /*background*/ true,
            return new BalVerdict(BAL_ALLOW_PERMISSION,
                    "OP_SYSTEM_EXEMPT_FROM_ACTIVITY_BG_START_RESTRICTION appop is granted");
        }
        return BalVerdict.BLOCK;
@@ -1200,8 +1166,7 @@ public class BackgroundActivityStartController {
                || state.mAppSwitchState == APP_SWITCH_FG_ONLY
                || isHomeApp(state.mRealCallingUid, state.mRealCallingPackage);
        if (appSwitchAllowedOrFg && state.mRealCallingUidHasVisibleActivity) {
            return new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW,
                    /*background*/ false, "realCallingUid has visible window");
            return new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, "realCallingUid has visible window");
        }
        return BalVerdict.BLOCK;
    };
@@ -1209,7 +1174,7 @@ public class BackgroundActivityStartController {
    private final BalExemptionCheck mCheckRealCallerNonAppVisible = state -> {
        if (state.mRealCallingUidHasNonAppVisibleWindow) {
            return new BalVerdict(BAL_ALLOW_NON_APP_VISIBLE_WINDOW,
                    /*background*/ false, "realCallingUid has non-app visible window "
                    "realCallingUid has non-app visible window "
                            + getService().mActiveUids.getNonAppVisibleWindowDetails(
                            state.mRealCallingUid));
        }
@@ -1230,9 +1195,7 @@ public class BackgroundActivityStartController {
                == MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS;
        if (allowAlways
                && hasBalPermission(state.mRealCallingUid, state.mRealCallingPid)) {
            return new BalVerdict(BAL_ALLOW_PERMISSION,
                    /*background*/ false,
                    "realCallingUid has BAL permission.");
            return new BalVerdict(BAL_ALLOW_PERMISSION, "realCallingUid has BAL permission.");
        }
        return BalVerdict.BLOCK;
    };
@@ -1245,7 +1208,7 @@ public class BackgroundActivityStartController {
                && getService().hasSystemAlertWindowPermission(state.mRealCallingUid,
                state.mRealCallingPid, state.mRealCallingPackage)) {
            return new BalVerdict(BAL_ALLOW_SAW_PERMISSION,
                    /*background*/ true, "SYSTEM_ALERT_WINDOW permission is granted");
                    "SYSTEM_ALERT_WINDOW permission is granted");
        }
        return BalVerdict.BLOCK;
    };
@@ -1258,7 +1221,6 @@ public class BackgroundActivityStartController {
        if ((allowAlways || state.mAllowBalExemptionForSystemProcess)
                && state.mIsRealCallingUidPersistentSystemProcess) {
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_UID,
                    /*background*/ false,
                    "realCallingUid is persistent system process AND intent "
                            + "sender forced to allow.");
        }
@@ -1270,7 +1232,6 @@ public class BackgroundActivityStartController {
        if (getService().isAssociatedCompanionApp(
                UserHandle.getUserId(state.mRealCallingUid), state.mRealCallingUid)) {
            return new BalVerdict(BAL_ALLOW_ALLOWLISTED_COMPONENT,
                    /*background*/ false,
                    "realCallingUid is a companion app.");
        }
        return BalVerdict.BLOCK;
+5 −5
Original line number Diff line number Diff line
@@ -125,27 +125,27 @@ class BackgroundLaunchProcessController {
            long lastActivityFinishTime) {
        // Allow if the proc is instrumenting with background activity starts privs.
        if (checkConfiguration.checkOtherExemptions && hasBackgroundActivityStartPrivileges) {
            return new BalVerdict(BAL_ALLOW_PERMISSION, /*background*/ true,
            return new BalVerdict(BAL_ALLOW_PERMISSION, /*background*/
                    "process instrumenting with background activity starts privileges");
        }
        // Allow if the flag was explicitly set.
        if (checkConfiguration.checkOtherExemptions && isBackgroundStartAllowedByToken(uid,
                packageName, checkConfiguration.isCheckingForFgsStart)) {
            return new BalVerdict(balImprovedMetrics() ? BAL_ALLOW_TOKEN : BAL_ALLOW_PERMISSION,
                    /*background*/ true, "process allowed by token");
                    /*background*/  "process allowed by token");
        }
        // Allow if the caller is bound by a UID that's currently foreground.
        // But still respect the appSwitchState.
        if (checkConfiguration.checkVisibility && appSwitchState != APP_SWITCH_DISALLOW
                && isBoundByForegroundUid()) {
            return new BalVerdict(balImprovedMetrics() ? BAL_ALLOW_BOUND_BY_FOREGROUND
                    : BAL_ALLOW_VISIBLE_WINDOW, /*background*/ false,
                    : BAL_ALLOW_VISIBLE_WINDOW, /*background*/
                    "process bound by foreground uid");
        }
        // Allow if the caller has an activity in any foreground task.
        if (checkConfiguration.checkOtherExemptions && hasActivityInVisibleTask
                && appSwitchState != APP_SWITCH_DISALLOW) {
            return new BalVerdict(BAL_ALLOW_FOREGROUND, /*background*/ false,
            return new BalVerdict(BAL_ALLOW_FOREGROUND, /*background*/
                    "process has activity in foreground task");
        }

@@ -160,7 +160,7 @@ class BackgroundLaunchProcessController {
                long timeSinceLastStartOrFinish = now - Math.max(lastActivityLaunchTime,
                        lastActivityFinishTime);
                if (timeSinceLastStartOrFinish < checkConfiguration.gracePeriod) {
                    return new BalVerdict(BAL_ALLOW_GRACE_PERIOD, /*background*/ true,
                    return new BalVerdict(BAL_ALLOW_GRACE_PERIOD, /*background*/
                            "within " + checkConfiguration.gracePeriod + "ms grace period ("
                                    + timeSinceLastStartOrFinish + "ms)");
                }
+3 −3
Original line number Diff line number Diff line
@@ -486,7 +486,7 @@ public class BackgroundActivityStartControllerExemptionTests {

        // setup state
        when(mCallerApp.areBackgroundActivityStartsAllowed(anyInt(), any())).thenReturn(
                new BalVerdict(BAL_ALLOW_FOREGROUND, false, "allowed"));
                new BalVerdict(BAL_ALLOW_FOREGROUND, "allowed"));
        when(mService.getBalAppSwitchesState()).thenReturn(APP_SWITCH_ALLOW);

        // prepare call
@@ -523,7 +523,7 @@ public class BackgroundActivityStartControllerExemptionTests {
                mCallerApp);
        when(mService.getBalAppSwitchesState()).thenReturn(APP_SWITCH_ALLOW);
        when(mCallerApp.areBackgroundActivityStartsAllowed(anyInt(), any())).thenReturn(
                new BalVerdict(BAL_ALLOW_FOREGROUND, false, "allowed"));
                new BalVerdict(BAL_ALLOW_FOREGROUND, "allowed"));

        // prepare call
        PendingIntentRecord originatingPendingIntent = mPendingIntentRecord;
@@ -572,7 +572,7 @@ public class BackgroundActivityStartControllerExemptionTests {
        when(mCallerApp.areBackgroundActivityStartsAllowed(anyInt(), any())).thenReturn(
                BalVerdict.BLOCK);
        when(otherProcess.areBackgroundActivityStartsAllowed(anyInt(), any())).thenReturn(
                new BalVerdict(BAL_ALLOW_FOREGROUND, false, "allowed"));
                new BalVerdict(BAL_ALLOW_FOREGROUND, "allowed"));

        // prepare call
        PendingIntentRecord originatingPendingIntent = mPendingIntentRecord;
+9 −9
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ public class BackgroundActivityStartControllerLogTests {
    @Test
    public void intent_visible_noLog() {
        useIntent();
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, false, "visible");
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, "visible");
        mState.setResultForCaller(finalVerdict);
        mState.setResultForRealCaller(BalVerdict.BLOCK);
        assertThat(mController.shouldLogStats(finalVerdict, mState)).isFalse();
@@ -101,7 +101,7 @@ public class BackgroundActivityStartControllerLogTests {
    @Test
    public void intent_saw_log() {
        useIntent();
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_SAW_PERMISSION, false, "SAW");
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_SAW_PERMISSION, "SAW");
        mState.setResultForCaller(finalVerdict);
        mState.setResultForRealCaller(BalVerdict.BLOCK);
        assertThat(mController.shouldLogStats(finalVerdict, mState)).isTrue();
@@ -111,7 +111,7 @@ public class BackgroundActivityStartControllerLogTests {
    @Test
    public void pendingIntent_callerOnly_saw_log() {
        usePendingIntent();
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_SAW_PERMISSION, false, "SAW");
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_SAW_PERMISSION, "SAW");
        mState.setResultForCaller(finalVerdict);
        mState.setResultForRealCaller(BalVerdict.BLOCK);
        assertThat(mController.shouldLogStats(finalVerdict, mState)).isTrue();
@@ -121,7 +121,7 @@ public class BackgroundActivityStartControllerLogTests {
    @Test
    public void pendingIntent_realCallerOnly_saw_log() {
        usePendingIntent();
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_SAW_PERMISSION, false, "SAW")
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_SAW_PERMISSION, "SAW")
                .setBasedOnRealCaller();
        mState.setResultForCaller(BalVerdict.BLOCK);
        mState.setResultForRealCaller(finalVerdict);
@@ -131,7 +131,7 @@ public class BackgroundActivityStartControllerLogTests {

    @Test
    public void intent_shouldLogIntentActivity() {
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_SAW_PERMISSION, false, "SAW");
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_SAW_PERMISSION, "SAW");
        useIntent(APP1_UID);
        assertThat(mController.shouldLogIntentActivity(finalVerdict, mState)).isFalse();
        useIntent(SYSTEM_UID);
@@ -140,7 +140,7 @@ public class BackgroundActivityStartControllerLogTests {

    @Test
    public void pendingIntent_shouldLogIntentActivityForCaller() {
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_SAW_PERMISSION, false, "SAW");
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_SAW_PERMISSION, "SAW");
        usePendingIntent(APP1_UID, APP2_UID);
        assertThat(mController.shouldLogIntentActivity(finalVerdict, mState)).isFalse();
        usePendingIntent(SYSTEM_UID, SYSTEM_UID);
@@ -153,7 +153,7 @@ public class BackgroundActivityStartControllerLogTests {

    @Test
    public void pendingIntent_shouldLogIntentActivityForRealCaller() {
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_SAW_PERMISSION, false,
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_SAW_PERMISSION,
                "SAW").setBasedOnRealCaller();
        usePendingIntent(APP1_UID, APP2_UID);
        assertThat(mController.shouldLogIntentActivity(finalVerdict, mState)).isFalse();
@@ -168,7 +168,7 @@ public class BackgroundActivityStartControllerLogTests {
    @Test
    public void pendingIntent_realCallerOnly_visible_noLog() {
        usePendingIntent();
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, false,
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW,
                "visible").setBasedOnRealCaller();
        mState.setResultForCaller(BalVerdict.BLOCK);
        mState.setResultForRealCaller(finalVerdict);
@@ -178,7 +178,7 @@ public class BackgroundActivityStartControllerLogTests {
    @Test
    public void pendingIntent_callerOnly_visible_noLog() {
        usePendingIntent();
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, false, "visible");
        BalVerdict finalVerdict = new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, "visible");
        mState.setResultForCaller(finalVerdict);
        mState.setResultForRealCaller(BalVerdict.BLOCK);
        assertThat(mController.shouldLogStats(finalVerdict, mState)).isTrue();
+8 −10
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ public class BackgroundActivityStartControllerTests {
    @Test
    public void testRegularActivityStart_allowedByCaller_isAllowed() {
        // setup state
        BalVerdict callerVerdict = new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, false,
        BalVerdict callerVerdict = new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW,
                "CallerIsVisible");
        mController.setCallerVerdict(callerVerdict);
        mController.setRealCallerVerdict(BalVerdict.BLOCK);
@@ -340,7 +340,7 @@ public class BackgroundActivityStartControllerTests {
    @Test
    public void testRegularActivityStart_allowedByRealCaller_isAllowed() {
        // setup state
        BalVerdict realCallerVerdict = new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, false,
        BalVerdict realCallerVerdict = new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW,
                "RealCallerIsVisible");
        mController.setCallerVerdict(BalVerdict.BLOCK);
        mController.setRealCallerVerdict(realCallerVerdict);
@@ -373,9 +373,9 @@ public class BackgroundActivityStartControllerTests {
    public void testRegularActivityStart_allowedByCallerAndRealCaller_returnsCallerVerdict() {
        // setup state
        BalVerdict callerVerdict =
                new BalVerdict(BAL_ALLOW_PERMISSION, false, "CallerHasPermission");
                new BalVerdict(BAL_ALLOW_PERMISSION, "CallerHasPermission");
        BalVerdict realCallerVerdict =
                new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, false, "RealCallerIsVisible");
                new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, "RealCallerIsVisible");
        mController.setCallerVerdict(callerVerdict);
        mController.setRealCallerVerdict(realCallerVerdict);

@@ -411,9 +411,9 @@ public class BackgroundActivityStartControllerTests {
    public void testPendingIntent_allowedByCallerAndRealCallerButOptOut_isBlocked() {
        // setup state
        BalVerdict callerVerdict =
                new BalVerdict(BAL_ALLOW_PERMISSION, false, "CallerhasPermission");
                new BalVerdict(BAL_ALLOW_PERMISSION, "CallerhasPermission");
        BalVerdict realCallerVerdict =
                new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, false, "RealCallerIsVisible");
                new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, "RealCallerIsVisible");
        mController.setCallerVerdict(callerVerdict);
        mController.setRealCallerVerdict(realCallerVerdict);

@@ -452,7 +452,7 @@ public class BackgroundActivityStartControllerTests {
    public void testPendingIntent_allowedByCallerAndOptIn_isAllowed() {
        // setup state
        BalVerdict callerVerdict =
                new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, false, "CallerIsVisible");
                new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, "CallerIsVisible");
        mController.setCallerVerdict(callerVerdict);
        mController.setRealCallerVerdict(BalVerdict.BLOCK);

@@ -489,7 +489,7 @@ public class BackgroundActivityStartControllerTests {
    public void testPendingIntent_allowedByRealCallerAndOptIn_isAllowed() {
        // setup state
        BalVerdict realCallerVerdict =
                new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, false, "RealCallerIsVisible");
                new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, "RealCallerIsVisible");
        mController.setCallerVerdict(BalVerdict.BLOCK);
        mController.setRealCallerVerdict(realCallerVerdict);

@@ -571,7 +571,6 @@ public class BackgroundActivityStartControllerTests {
                        + "callerApp: mCallerApp; "
                        + "inVisibleTask: false; "
                        + "balAllowedByPiCreator: BSP.ALLOW_BAL; "
                        + "balAllowedByPiCreatorWithHardening: BSP.ALLOW_BAL; "
                        + "callerStartMode: MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED; "
                        + "hasRealCaller: true; "
                        + "isCallForResult: false; "
@@ -674,7 +673,6 @@ public class BackgroundActivityStartControllerTests {
                        + "callerApp: mCallerApp; "
                        + "inVisibleTask: false; "
                        + "balAllowedByPiCreator: BSP.NONE; "
                        + "balAllowedByPiCreatorWithHardening: BSP.NONE; "
                        + "callerStartMode: MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED; "
                        + "hasRealCaller: true; "
                        + "isCallForResult: false; "