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

Commit 8c6f03fa authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Do not hide IME when waiting for drawn by toggling screen

This removed outdated logic of [1].
It was needed because the IME container was put on top of display.
[1]: Ife93bdfde8ba2914930497356c0e16ebd629c507

Since DisplayArea is introduced, the corresponding ImePlaceholder
will never have higher z-order then AOD unless itself is the IME
target. Also since insets leash is introduced, the leash surface
will be hidden if the control target is not visible. So the logic
is no longer needed.

Otherwise if WindowState#hide is called for IME, it will clear
visibility flag and cause WindowState#isGoneForLayout to return
true. Then IME won't receive new size in time when the display is
resizing with turning off/on screen.

Bug: 289995722
Test: Fold/unfold device when "Stay unlocked on fold" is enabled
      and the current app is showing IME. The IME won't show a
      few frames in old size.
Change-Id: I697e1ec679be37388eefb0fa265d9e9a084458cf
parent 7f052ad3
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -6524,14 +6524,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        return (mDisplayInfo.flags & Display.FLAG_ROTATES_WITH_CONTENT) == 0;
    }

    /**
     * @return whether AOD is showing on this display
     */
    boolean isAodShowing() {
        return mRootWindowContainer.mTaskSupervisor
                .getKeyguardController().isAodShowing(mDisplayId);
    }

    /**
     * @return whether this display maintains its own focus and touch mode.
     */
+0 −12
Original line number Diff line number Diff line
@@ -1665,18 +1665,6 @@ public class DisplayPolicy {
    }

    private boolean shouldBeHiddenByKeyguard(WindowState win, WindowState imeTarget) {
        // If AOD is showing, the IME should be hidden. However, sometimes the AOD is considered
        // hidden because it's in the process of hiding, but it's still being shown on screen.
        // In that case, we want to continue hiding the IME until the windows have completed
        // drawing. This way, we know that the IME can be safely shown since the other windows are
        // now shown.
        final boolean hideIme = win.mIsImWindow
                && (mDisplayContent.isAodShowing()
                        || (mDisplayContent.isDefaultDisplay && !mWindowManagerDrawComplete));
        if (hideIme) {
            return true;
        }

        if (!mDisplayContent.isDefaultDisplay || !isKeyguardShowing()) {
            return false;
        }
+8 −6
Original line number Diff line number Diff line
@@ -242,26 +242,27 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase {
        displayInfo.copyFrom(mDisplayInfo);
        displayInfo.type = Display.TYPE_VIRTUAL;
        DisplayContent virtualDisplay = createNewDisplay(displayInfo);
        final KeyguardController keyguardController = mSupervisor.getKeyguardController();

        // Make sure we're starting out with 2 unlocked displays
        assertEquals(2, mRootWindowContainer.getChildCount());
        mRootWindowContainer.forAllDisplays(displayContent -> {
            assertFalse(displayContent.isKeyguardLocked());
            assertFalse(displayContent.isAodShowing());
            assertFalse(keyguardController.isAodShowing(displayContent.mDisplayId));
        });

        // Check that setLockScreenShown locks both displays
        mAtm.setLockScreenShown(true, true);
        mRootWindowContainer.forAllDisplays(displayContent -> {
            assertTrue(displayContent.isKeyguardLocked());
            assertTrue(displayContent.isAodShowing());
            assertTrue(keyguardController.isAodShowing(displayContent.mDisplayId));
        });

        // Check setLockScreenShown unlocking both displays
        mAtm.setLockScreenShown(false, false);
        mRootWindowContainer.forAllDisplays(displayContent -> {
            assertFalse(displayContent.isKeyguardLocked());
            assertFalse(displayContent.isAodShowing());
            assertFalse(keyguardController.isAodShowing(displayContent.mDisplayId));
        });
    }

@@ -275,25 +276,26 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase {
        displayInfo.displayGroupId = Display.DEFAULT_DISPLAY_GROUP + 1;
        displayInfo.flags = Display.FLAG_OWN_DISPLAY_GROUP | Display.FLAG_ALWAYS_UNLOCKED;
        DisplayContent newDisplay = createNewDisplay(displayInfo);
        final KeyguardController keyguardController = mSupervisor.getKeyguardController();

        // Make sure we're starting out with 2 unlocked displays
        assertEquals(2, mRootWindowContainer.getChildCount());
        mRootWindowContainer.forAllDisplays(displayContent -> {
            assertFalse(displayContent.isKeyguardLocked());
            assertFalse(displayContent.isAodShowing());
            assertFalse(keyguardController.isAodShowing(displayContent.mDisplayId));
        });

        // setLockScreenShown should only lock the default display, not the virtual one
        mAtm.setLockScreenShown(true, true);

        assertTrue(mDefaultDisplay.isKeyguardLocked());
        assertTrue(mDefaultDisplay.isAodShowing());
        assertTrue(keyguardController.isAodShowing(mDefaultDisplay.mDisplayId));

        DisplayContent virtualDisplay = mRootWindowContainer.getDisplayContent(
                newDisplay.getDisplayId());
        assertNotEquals(Display.DEFAULT_DISPLAY, virtualDisplay.getDisplayId());
        assertFalse(virtualDisplay.isKeyguardLocked());
        assertFalse(virtualDisplay.isAodShowing());
        assertFalse(keyguardController.isAodShowing(virtualDisplay.mDisplayId));
    }

    /*