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

Commit fe4d83ac authored by Jorge Gil's avatar Jorge Gil Committed by Android (Google) Code Review
Browse files

Merge "Always show caption in freeform even if apps are requesting immersive" into main

parents fb01df17 7d59b3c8
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -530,7 +530,14 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
     * Checks if task has entered/exited immersive mode and requires a change in caption visibility.
     */
    private void updateCaptionVisibility(View rootView) {
        mIsCaptionVisible = mIsStatusBarVisible && !mIsKeyguardVisibleAndOccluded;
        // Caption should always be visible in freeform mode. When not in freeform, align with the
        // status bar except when showing over keyguard (where it should not shown).
        //  TODO(b/356405803): Investigate how it's possible for the status bar visibility to be
        //   false while a freeform window is open if the status bar is always forcibly-shown. It
        //   may be that the InsetsState (from which |mIsStatusBarVisible| is set) still contains
        //   an invisible insets source in immersive cases even if the status bar is shown?
        mIsCaptionVisible = mTaskInfo.isFreeform()
                || (mIsStatusBarVisible && !mIsKeyguardVisibleAndOccluded);
        setCaptionVisibility(rootView, mIsCaptionVisible);
    }

+19 −2
Original line number Diff line number Diff line
@@ -901,8 +901,9 @@ public class WindowDecorationTests extends ShellTestCase {
    }

    @Test
    public void onStatusBarVisibilityChange_shownToHidden_hidesCaption() {
    public void onStatusBarVisibilityChange_fullscreen_shownToHidden_hidesCaption() {
        final ActivityManager.RunningTaskInfo task = createTaskInfo();
        task.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
        when(mMockDisplayController.getInsetsState(task.displayId))
                .thenReturn(createInsetsState(statusBars(), true /* visible */));
        final TestWindowDecoration decor = createWindowDecoration(task);
@@ -915,8 +916,9 @@ public class WindowDecorationTests extends ShellTestCase {
    }

    @Test
    public void onStatusBarVisibilityChange_hiddenToShown_showsCaption() {
    public void onStatusBarVisibilityChange_fullscreen_hiddenToShown_showsCaption() {
        final ActivityManager.RunningTaskInfo task = createTaskInfo();
        task.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
        when(mMockDisplayController.getInsetsState(task.displayId))
                .thenReturn(createInsetsState(statusBars(), false /* visible */));
        final TestWindowDecoration decor = createWindowDecoration(task);
@@ -928,6 +930,21 @@ public class WindowDecorationTests extends ShellTestCase {
        assertTrue(decor.mIsCaptionVisible);
    }

    @Test
    public void onStatusBarVisibilityChange_freeform_shownToHidden_keepsCaption() {
        final ActivityManager.RunningTaskInfo task = createTaskInfo();
        task.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM);
        when(mMockDisplayController.getInsetsState(task.displayId))
                .thenReturn(createInsetsState(statusBars(), true /* visible */));
        final TestWindowDecoration decor = createWindowDecoration(task);
        decor.relayout(task);
        assertTrue(decor.mIsCaptionVisible);

        decor.onInsetsStateChanged(createInsetsState(statusBars(), false /* visible */));

        assertTrue(decor.mIsCaptionVisible);
    }

    @Test
    public void onKeyguardStateChange_hiddenToShownAndOccluding_hidesCaption() {
        final ActivityManager.RunningTaskInfo task = createTaskInfo();