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

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

Only show toast if it not unconditionally blocked

Showing a toast when opting in the caller/real caller would not change
the outcome of the BAL logic only confuses users. With this change we
no longer show toasts in cases that are blocked in Android T or before,
where all opt-ins were granted automatically.

Test: atest BackgroundActivityLaunchTest
Bug: 308059069
Change-Id: Ic6538a51473dd8c17cbd5577df023d39e6759269
parent e7739b9f
Loading
Loading
Loading
Loading
+5 −7
Original line number Original line Diff line number Diff line
@@ -790,7 +790,11 @@ public class BackgroundActivityStartController {
    private BalVerdict abortLaunch(BalState state) {
    private BalVerdict abortLaunch(BalState state) {
        Slog.wtf(TAG, "Background activity launch blocked! "
        Slog.wtf(TAG, "Background activity launch blocked! "
                + state.dump());
                + state.dump());
        showBalBlockedToast();
        if (balShowToastsBlocked()
                && (state.mResultForCaller.allows() || state.mResultForRealCaller.allows())) {
            // only show a toast if either caller or real caller could launch if they opted in
            showToast("BAL blocked. go/debug-bal");
        }
        return statsLog(BalVerdict.BLOCK, state);
        return statsLog(BalVerdict.BLOCK, state);
    }
    }


@@ -1189,12 +1193,6 @@ public class BackgroundActivityStartController {
        return true;
        return true;
    }
    }


    private void showBalBlockedToast() {
        if (balShowToastsBlocked()) {
            showToast("BAL blocked. go/debug-bal");
        }
    }

    @VisibleForTesting void showToast(String toastText) {
    @VisibleForTesting void showToast(String toastText) {
        UiThread.getHandler().post(() -> Toast.makeText(mService.mContext,
        UiThread.getHandler().post(() -> Toast.makeText(mService.mContext,
                toastText, Toast.LENGTH_LONG).show());
                toastText, Toast.LENGTH_LONG).show());