summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nan Wu <wnan@google.com> 2023-12-07 14:03:25 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-12-07 14:03:25 +0000
commit5bcecbf4d5146e5d9d0ad0fa17b970cd125d40cc (patch)
tree39bb4d9ee7dd16013ea079087a1cfb333cc519b8
parent452830a3900f4daa9b95c021ffa375bd345ec15f (diff)
parentadd81472873560e06f26e1149ff3258b86c83a2b (diff)
Merge "Prevent BAL when app switch state is BAL disallow" into main
-rw-r--r--core/java/android/window/flags/responsible_apis.aconfig7
-rw-r--r--services/core/java/com/android/server/wm/BackgroundLaunchProcessController.java13
2 files changed, 16 insertions, 4 deletions
diff --git a/core/java/android/window/flags/responsible_apis.aconfig b/core/java/android/window/flags/responsible_apis.aconfig
index f828cff14e88..ad0e9a487c53 100644
--- a/core/java/android/window/flags/responsible_apis.aconfig
+++ b/core/java/android/window/flags/responsible_apis.aconfig
@@ -41,3 +41,10 @@ flag {
description: "Prevent a task to restart based on a visible window during task switch."
bug: "171459802"
}
+
+flag {
+ name: "bal_respect_app_switch_state_when_check_bound_by_foreground_uid"
+ namespace: "responsible_apis"
+ description: "Prevent BAL based on it is bound by foreground Uid but the app switch is stopped."
+ bug: "171459802"
+}
diff --git a/services/core/java/com/android/server/wm/BackgroundLaunchProcessController.java b/services/core/java/com/android/server/wm/BackgroundLaunchProcessController.java
index 9a32dc8d9190..478524b7bd1c 100644
--- a/services/core/java/com/android/server/wm/BackgroundLaunchProcessController.java
+++ b/services/core/java/com/android/server/wm/BackgroundLaunchProcessController.java
@@ -22,7 +22,7 @@ import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.ActivityTaskManagerService.ACTIVITY_BG_START_GRACE_PERIOD_MS;
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.ActivityTaskManagerService.APP_SWITCH_DISALLOW;
import static com.android.server.wm.BackgroundActivityStartController.BAL_ALLOW_FOREGROUND;
import static com.android.server.wm.BackgroundActivityStartController.BAL_ALLOW_GRACE_PERIOD;
import static com.android.server.wm.BackgroundActivityStartController.BAL_ALLOW_PERMISSION;
@@ -49,6 +49,7 @@ import android.util.Slog;
import com.android.internal.annotations.GuardedBy;
import com.android.server.wm.BackgroundActivityStartController.BalVerdict;
+import com.android.window.flags.Flags;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -113,13 +114,17 @@ class BackgroundLaunchProcessController {
"process allowed by token");
}
// Allow if the caller is bound by a UID that's currently foreground.
- if (isBoundByForegroundUid()) {
+ // But still respect the appSwitchState.
+ boolean allowBoundByForegroundUid =
+ Flags.balRespectAppSwitchStateWhenCheckBoundByForegroundUid()
+ ? appSwitchState != APP_SWITCH_DISALLOW && isBoundByForegroundUid()
+ : isBoundByForegroundUid();
+ if (allowBoundByForegroundUid) {
return new BalVerdict(BAL_ALLOW_VISIBLE_WINDOW, /*background*/ false,
"process bound by foreground uid");
}
// Allow if the caller has an activity in any foreground task.
- if (hasActivityInVisibleTask
- && (appSwitchState == APP_SWITCH_ALLOW || appSwitchState == APP_SWITCH_FG_ONLY)) {
+ if (hasActivityInVisibleTask && appSwitchState != APP_SWITCH_DISALLOW) {
return new BalVerdict(BAL_ALLOW_FOREGROUND, /*background*/ false,
"process has activity in foreground task");
}