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

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

Remove BAL risk toasts

These toast break CTS tests and are in general not useful as they happen
far too often for 3P apps that cannot be fixed by us.

Test: atest BackgroundActivityLaunchTest
Bug: 308059069
Change-Id: Idfec933e585f31fdabfdf0d3536c289fd3cefa9a
parent a56db095
Loading
Loading
Loading
Loading
+2 −11
Original line number Diff line number Diff line
@@ -18,10 +18,10 @@ package com.android.server.wm;

import static android.Manifest.permission.START_ACTIVITIES_FROM_BACKGROUND;
import static android.app.ActivityManager.PROCESS_STATE_NONEXISTENT;
import static android.app.ActivityOptions.BackgroundActivityStartMode;
import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED;
import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_DENIED;
import static android.app.ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED;
import static android.app.ActivityOptions.BackgroundActivityStartMode;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE;
@@ -37,12 +37,11 @@ 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.server.wm.PendingRemoteAnimationRegistry.TIMEOUT_MS;
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;
import static com.android.window.flags.Flags.balShowToastsBlocked;
import static com.android.server.wm.PendingRemoteAnimationRegistry.TIMEOUT_MS;

import static java.lang.annotation.RetentionPolicy.SOURCE;
import static java.util.Objects.requireNonNull;
@@ -752,7 +751,6 @@ public class BackgroundActivityStartController {
                Slog.wtf(TAG, "With Android 15 BAL hardening this activity start may be blocked"
                        + " if the PI creator upgrades target_sdk to 35+! "
                        + " (missing opt in by PI creator)!" + state.dump());
                showBalRiskToast();
                return allowBasedOnCaller(state);
            }
        }
@@ -762,7 +760,6 @@ public class BackgroundActivityStartController {
                Slog.wtf(TAG, "With Android 14 BAL hardening this activity start will be blocked"
                        + " if the PI sender upgrades target_sdk to 34+! "
                        + " (missing opt in by PI sender)!" + state.dump());
                showBalRiskToast();
                return allowBasedOnRealCaller(state);
            }
        }
@@ -1198,12 +1195,6 @@ public class BackgroundActivityStartController {
        }
    }

    private void showBalRiskToast() {
        if (balShowToasts()) {
            showToast("BAL allowed in compat mode. go/debug-bal");
        }
    }

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