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

Commit 24bbec3e authored by Orhan Uysal's avatar Orhan Uysal
Browse files

If task is above IME, do nothing

If tasks' bottom bound is above IMEs' top bound, do nothing.

Test: atest DesktopImeHandlerTest
Bug: 388570293
Fix: 408168350
Flag: com.android.window.flags.enable_desktop_ime_bugfix
Change-Id: Id31eac60e4d50212bb9cd294a7994bef184523fd
parent 1ef99ff8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -125,6 +125,8 @@ class DesktopImeHandler(
                    finalTop = stableBounds.top
                    finalBottom = stableBounds.top + taskHeight
                }
            } else {
                return IME_ANIMATION_DEFAULT
            }

            val finalBounds = Rect(taskBounds.left, finalTop, taskBounds.right, finalBottom)
+28 −0
Original line number Diff line number Diff line
@@ -339,6 +339,34 @@ class DesktopImeHandlerTest : ShellTestCase() {
            .startTransition(eq(TRANSIT_CHANGE), wct.capture(), anyOrNull())
    }

    @Test
    @EnableFlags(
        Flags.FLAG_ENABLE_DESKTOP_IME_BUGFIX,
        Flags.FLAG_ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS,
    )
    fun onImeStartPositioning_taskAboveIme_noOp() {
        setUpLandscapeDisplay()
        val wct = ArgumentCaptor.forClass(WindowContainerTransaction::class.java)
        val taskBounds = Rect(0, 200, 500, 400)
        var freeformTask = createFreeformTask(DEFAULT_DISPLAY, taskBounds)
        freeformTask.isFocused = true
        whenever(focusTransitionObserver.globallyFocusedTaskId).thenReturn(freeformTask.taskId)
        whenever(shellTaskOrganizer.getRunningTaskInfo(freeformTask.taskId))
            .thenReturn(freeformTask)

        imeHandler.onImeStartPositioning(
            DEFAULT_DISPLAY,
            hiddenTop = DISPLAY_DIMENSION_SHORT,
            shownTop = IME_HEIGHT,
            showing = true,
            isFloating = false,
            t = mock(),
        )

        // Does not move the task
        verify(transitions, never()).startTransition(eq(TRANSIT_CHANGE), wct.capture(), anyOrNull())
    }

    private fun findBoundsChange(wct: WindowContainerTransaction, task: RunningTaskInfo): Rect? =
        wct.changes.entries
            .find { (token, change) ->