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

Commit f4aeb7ac authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Do not create/update status bar input layer when caption isn't visible

AppHandleViewHolder#bindData would only return early and not
create/update the input layer if the input layer did not exist. So, if
two relayouts happen when a task is in immersive, the first relayout
would cause the input layer to be disposed while the second would
recreate it.

Bug: 375246608
Flag: EXEMPT bugfix
Test: try to create handle menu when in immersive mode
Change-Id: I04412a613589ef9b6d2e8836f136c549f1228067
parent f723deaa
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ internal class AppHandleViewHolder(
        // If handle is not in status bar region(i.e., bottom stage in vertical split),
        // do not create an input layer
        if (position.y >= SystemBarUtils.getStatusBarHeight(context)) return
        if (!isCaptionVisible && statusBarInputLayerExists) {
        if (!isCaptionVisible) {
            disposeStatusBarInputLayer()
            return
        }
@@ -227,6 +227,7 @@ internal class AppHandleViewHolder(
     * is not visible.
     */
    fun disposeStatusBarInputLayer() {
        if (!statusBarInputLayerExists) return
        statusBarInputLayerExists = false
        handler.post {
            statusBarInputLayer?.releaseView()
+1 −13
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
    @Captor
    private ArgumentCaptor<Runnable> mCloseMaxMenuRunnable;

    private final InsetsState mInsetsState = new InsetsState();
    private final InsetsState mInsetsState = createInsetsState(statusBars(), /* visible= */true);
    private SurfaceControl.Transaction mMockTransaction;
    private StaticMockitoSession mMockitoSession;
    private TestableContext mTestableContext;
@@ -1408,8 +1408,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
    public void notifyCaptionStateChanged_flagDisabled_doNoNotify() {
        when(DesktopModeStatus.canEnterDesktopMode(mContext)).thenReturn(true);
        final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true);
        when(mMockDisplayController.getInsetsState(taskInfo.displayId))
                .thenReturn(createInsetsState(statusBars(), /* visible= */true));
        final DesktopModeWindowDecoration spyWindowDecor = spy(createWindowDecoration(taskInfo));
        taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN);

@@ -1423,8 +1421,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
    public void notifyCaptionStateChanged_inFullscreenMode_notifiesAppHandleVisible() {
        when(DesktopModeStatus.canEnterDesktopMode(mContext)).thenReturn(true);
        final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true);
        when(mMockDisplayController.getInsetsState(taskInfo.displayId))
                .thenReturn(createInsetsState(statusBars(), /* visible= */true));
        final DesktopModeWindowDecoration spyWindowDecor = spy(createWindowDecoration(taskInfo));
        taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
        ArgumentCaptor<CaptionState> captionStateArgumentCaptor = ArgumentCaptor.forClass(
@@ -1444,8 +1440,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
    public void notifyCaptionStateChanged_inWindowingMode_notifiesAppHeaderVisible() {
        when(DesktopModeStatus.canEnterDesktopMode(mContext)).thenReturn(true);
        final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true);
        when(mMockDisplayController.getInsetsState(taskInfo.displayId))
                .thenReturn(createInsetsState(statusBars(), /* visible= */true));
        when(mMockAppHeaderViewHolder.getAppChipLocationInWindow()).thenReturn(
                new Rect(/* left= */ 0, /* top= */ 1, /* right= */ 2, /* bottom= */ 3));
        final DesktopModeWindowDecoration spyWindowDecor = spy(createWindowDecoration(taskInfo));
@@ -1473,8 +1467,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
    public void notifyCaptionStateChanged_taskNotVisible_notifiesNoCaptionVisible() {
        when(DesktopModeStatus.canEnterDesktopMode(mContext)).thenReturn(true);
        final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ false);
        when(mMockDisplayController.getInsetsState(taskInfo.displayId))
                .thenReturn(createInsetsState(statusBars(), /* visible= */true));
        final DesktopModeWindowDecoration spyWindowDecor = spy(createWindowDecoration(taskInfo));
        taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_UNDEFINED);
        ArgumentCaptor<CaptionState> captionStateArgumentCaptor = ArgumentCaptor.forClass(
@@ -1493,8 +1485,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
    public void notifyCaptionStateChanged_captionHandleExpanded_notifiesHandleMenuExpanded() {
        when(DesktopModeStatus.canEnterDesktopMode(mContext)).thenReturn(true);
        final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true);
        when(mMockDisplayController.getInsetsState(taskInfo.displayId))
                .thenReturn(createInsetsState(statusBars(), /* visible= */true));
        final DesktopModeWindowDecoration spyWindowDecor = spy(createWindowDecoration(taskInfo));
        taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
        ArgumentCaptor<CaptionState> captionStateArgumentCaptor = ArgumentCaptor.forClass(
@@ -1518,8 +1508,6 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
    public void notifyCaptionStateChanged_captionHandleClosed_notifiesHandleMenuClosed() {
        when(DesktopModeStatus.canEnterDesktopMode(mContext)).thenReturn(true);
        final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true);
        when(mMockDisplayController.getInsetsState(taskInfo.displayId))
                .thenReturn(createInsetsState(statusBars(), /* visible= */true));
        final DesktopModeWindowDecoration spyWindowDecor = spy(createWindowDecoration(taskInfo));
        taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
        ArgumentCaptor<CaptionState> captionStateArgumentCaptor = ArgumentCaptor.forClass(