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

Commit 7d59b3c8 authored by Jorge Gil's avatar Jorge Gil
Browse files

Always show caption in freeform even if apps are requesting immersive

The caption view visibility prior to this change was synced to the
status bar visibility because the App Handle should not be shown when in
immersive mode. However, when in freeform, InsetsState may still briefly
report an invisible status bar even though the status bar is
forcibly-shown in the desktop. For this reason, the App Header would
sometimes be removed to follow the (incorrect) status bar inset source.
This change forces the caption view to always be shown in freeform mode,
regardless of if the status bar is reported as not visible.

Flag: EXEMPT bugfix
Bug: 356405803
Test: open immersive app in freeform (e.g. Call of Duty), launch Gmail
on top, verify App Headers dont disappear (briefly or indefinitely).

Change-Id: I27dd7952e9e5b783eea6217df1e84c9053a72fab
parent 73b0b482
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();