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

Commit f22bf2cb authored by Louis Chang's avatar Louis Chang
Browse files

Avoid moving visible task to front

In desktop mode, rapidly opening two apps with banners causes
the first app launched to move to the foreground and gain focus.
This occurs because the second app starts a new activity within
the same task, bringing the initial app to the front.

Bug: 399860102
Test: rapidly launch two apps
Flag: com.android.window.flags.fix_moving_unfocused_task
Change-Id: Ia4db4ff8411997d7b46f5ec220b44581c17a95b9
parent c3f4e8ba
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -205,3 +205,14 @@ flag {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    namespace: "windowing_sdk"
    name: "fix_moving_unfocused_task"
    description: "Avoid moving the visible and unfocused multi-window mode Task to front"
    bug: "399860102"
    is_fixed_read_only: true
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
 No newline at end of file
+10 −0
Original line number Diff line number Diff line
@@ -274,6 +274,8 @@ class ActivityStarter {
    private static final int MOVE_TO_FRONT_AVOID_PI_ONLY_CREATOR_ALLOWS = 1;
    // Avoid a task move to front because of all other legacy reasons.
    private static final int MOVE_TO_FRONT_AVOID_LEGACY = 2;
    // Avoid a task move to front because it was requested from a visible multiple window.
    private static final int MOVE_TO_FRONT_AVOID_VISIBLE_MULTI_WINDOW = 3;
    private @MoveToFrontCode int mCanMoveToFrontCode = MOVE_TO_FRONT_ALLOWED;
    private boolean mFrozeTaskList;
    private boolean mTransientLaunch;
@@ -1982,6 +1984,14 @@ class ActivityStarter {
                    && r.mTransitionController.isTransientHide(targetTask)) {
                mCanMoveToFrontCode = MOVE_TO_FRONT_AVOID_LEGACY;
            }
            // To prevent interruption of the user's current focus, if a launch request
            // originates from activities within the same visible task, the task should not be
            // moved to the front, or an unfocused Task could be moved to top unexpectedly.
            if (com.android.window.flags.Flags.fixMovingUnfocusedTask() && !avoidMoveToFront()
                    && sourceRecord != null && sourceRecord.getTask() == targetTask
                    && targetTask.isVisible() && targetTask.inMultiWindowMode()) {
                mCanMoveToFrontCode = MOVE_TO_FRONT_AVOID_VISIBLE_MULTI_WINDOW;
            }
            // If the activity is started by sending a pending intent and only its creator has the
            // privilege to allow BAL (its sender does not), avoid move it to the front. Only do
            // this when it is not a new task and not already been marked as avoid move to front.