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

Commit 6720745d authored by Louis Chang's avatar Louis Chang
Browse files

Do not move focus to top if dim surface is boosted on Task

The activity window on primary container may has a dim effect
showing on the entire task (across the two TFs). In that case,
the activity window should be the visually top-most window.
So do not move focus to the top activity in that case.

Bug: 328167429
Test: atest TaskFragmentTest
Change-Id: I15b13699a50cc59fb9de6793e0ff5191c6d04d08
parent bbc6941c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -3751,9 +3751,11 @@ class Task extends TaskFragment {
                // Boost the adjacent TaskFragment for dimmer if needed.
                final TaskFragment taskFragment = wc.asTaskFragment();
                if (taskFragment != null && taskFragment.isEmbedded()) {
                    taskFragment.mDimmerSurfaceBoosted = false;
                    final TaskFragment adjacentTf = taskFragment.getAdjacentTaskFragment();
                    if (adjacentTf != null && adjacentTf.shouldBoostDimmer()) {
                        adjacentTf.assignLayer(t, layer++);
                        adjacentTf.mDimmerSurfaceBoosted = true;
                    }
                }

+3 −0
Original line number Diff line number Diff line
@@ -216,6 +216,9 @@ class TaskFragment extends WindowContainer<WindowContainer> {
    Dimmer mDimmer = Dimmer.DIMMER_REFACTOR
            ? new SmoothDimmer(this) : new LegacyDimmer(this);

    /** {@code true} if the dimmer surface is boosted. {@code false} otherwise. */
    boolean mDimmerSurfaceBoosted;

    /** Apply the dim layer on the embedded TaskFragment. */
    static final int EMBEDDED_DIM_AREA_TASK_FRAGMENT = 0;

+5 −0
Original line number Diff line number Diff line
@@ -9214,6 +9214,11 @@ public class WindowManagerService extends IWindowManager.Stub
            return false;
        }

        if (taskFragment.mDimmerSurfaceBoosted) {
            // Skip if the TaskFragment currently has dimmer surface boosted.
            return false;
        }

        final ActivityRecord topActivity =
                taskFragment.getTask().topRunningActivity(true /* focusableOnly */);
        if (topActivity == null || topActivity == focusedWindow.mActivityRecord) {
+5 −0
Original line number Diff line number Diff line
@@ -896,6 +896,11 @@ public class TaskFragmentTest extends WindowTestsBase {
            assertFalse(mWm.moveFocusToTopEmbeddedWindow(winRightTop));
            // The focus should NOT change.
            assertEquals(winRightTop, mDisplayContent.mCurrentFocus);

            // Do not move focus if the dim is boosted.
            taskFragmentLeft.mDimmerSurfaceBoosted = true;
            assertFalse(mWm.moveFocusToTopEmbeddedWindow(winLeftTop));
            assertEquals(winRightTop, mDisplayContent.mCurrentFocus);
        }
    }