summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Achim Thesmann <achim@google.com> 2023-11-07 18:44:31 +0000
committer Achim Thesmann <achim@google.com> 2023-11-07 19:40:54 +0000
commit17407daf59c79c4c5adc07fae30c7ec4e33bccf7 (patch)
tree3c5583520a812ea46704bc7902bfa075fb0977fb
parent7ca8de8c8790f6f3cc3d07f99a316e383f01eb3f (diff)
Split logs for actual BAL blocks vs potential blocks
Enabling the feature for potential blocks (i.e. reporting blocks that would happen when the app is upgrading the target SDK without any code change) is too annoying in staging. Bug: 25198068 Test: atest BackgroundActivityLaunchTest Change-Id: I3f700e025166647e8d86d725cd0ec165b0666c89
-rw-r--r--core/java/android/window/flags/responsible_apis.aconfig7
-rw-r--r--services/core/java/com/android/server/wm/BackgroundActivityStartController.java21
2 files changed, 22 insertions, 6 deletions
diff --git a/core/java/android/window/flags/responsible_apis.aconfig b/core/java/android/window/flags/responsible_apis.aconfig
index 4bfb17700a76..94e6009f4cd6 100644
--- a/core/java/android/window/flags/responsible_apis.aconfig
+++ b/core/java/android/window/flags/responsible_apis.aconfig
@@ -19,4 +19,11 @@ flag {
namespace: "responsible_apis"
description: "Enable toasts to indicate (potential) BAL blocking."
bug: "308059069"
+}
+
+flag {
+ name: "bal_show_toasts_blocked"
+ namespace: "responsible_apis"
+ description: "Enable toasts to indicate actual BAL blocking."
+ bug: "308059069"
} \ No newline at end of file
diff --git a/services/core/java/com/android/server/wm/BackgroundActivityStartController.java b/services/core/java/com/android/server/wm/BackgroundActivityStartController.java
index 9605d5167b04..d72544f5b8f3 100644
--- a/services/core/java/com/android/server/wm/BackgroundActivityStartController.java
+++ b/services/core/java/com/android/server/wm/BackgroundActivityStartController.java
@@ -30,6 +30,7 @@ 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.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;
@@ -472,7 +473,7 @@ public class BackgroundActivityStartController {
// anything that has fallen through would currently be aborted
Slog.w(TAG, "Background activity launch blocked! "
+ state.dump(resultForCaller));
- showBalToast("BAL blocked", state);
+ showBalBlockedToast("BAL blocked", state);
return statsLog(BalVerdict.BLOCK, state);
}
@@ -515,7 +516,7 @@ public class BackgroundActivityStartController {
"With Android 15 BAL hardening this activity start would be blocked"
+ " (missing opt in by PI creator)! "
+ state.dump(resultForCaller, resultForRealCaller));
- showBalToast("BAL would be blocked", state);
+ showBalRiskToast("BAL would be blocked", state);
// return the realCaller result for backwards compatibility
return statsLog(resultForRealCaller, state);
}
@@ -527,7 +528,7 @@ public class BackgroundActivityStartController {
"With Android 15 BAL hardening this activity start would be blocked"
+ " (missing opt in by PI creator)! "
+ state.dump(resultForCaller, resultForRealCaller));
- showBalToast("BAL would be blocked", state);
+ showBalRiskToast("BAL would be blocked", state);
return statsLog(resultForCaller, state);
}
if (resultForRealCaller.allows()
@@ -539,7 +540,7 @@ public class BackgroundActivityStartController {
"With Android 14 BAL hardening this activity start would be blocked"
+ " (missing opt in by PI sender)! "
+ state.dump(resultForCaller, resultForRealCaller));
- showBalToast("BAL would be blocked", state);
+ showBalBlockedToast("BAL would be blocked", state);
return statsLog(resultForRealCaller, state);
}
Slog.wtf(TAG, "Without Android 14 BAL hardening this activity start would be allowed"
@@ -550,7 +551,7 @@ public class BackgroundActivityStartController {
// anything that has fallen through would currently be aborted
Slog.w(TAG, "Background activity launch blocked! "
+ state.dump(resultForCaller, resultForRealCaller));
- showBalToast("BAL blocked", state);
+ showBalBlockedToast("BAL blocked", state);
return statsLog(BalVerdict.BLOCK, state);
}
@@ -925,7 +926,15 @@ public class BackgroundActivityStartController {
return true;
}
- private void showBalToast(String toastText, BalState state) {
+ private void showBalBlockedToast(String toastText, BalState state) {
+ if (balShowToastsBlocked()) {
+ showToast(toastText
+ + " caller:" + state.mCallingPackage
+ + " realCaller:" + state.mRealCallingPackage);
+ }
+ }
+
+ private void showBalRiskToast(String toastText, BalState state) {
if (balShowToasts()) {
showToast(toastText
+ " caller:" + state.mCallingPackage