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

Commit 33d5d471 authored by Ming-Shin Lu's avatar Ming-Shin Lu Committed by Android (Google) Code Review
Browse files

Merge "Fix WIC#hide(ime()) no-op when IME insets not controllable"

parents 9eeb7100 e3a3cd83
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -1180,7 +1180,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            final InsetsSourceConsumer consumer = getSourceConsumer(internalTypes.valueAt(i));
            boolean show = animationType == ANIMATION_TYPE_SHOW
                    || animationType == ANIMATION_TYPE_USER;
            boolean canRun = false;
            boolean canRun = true;
            if (show) {
                // Show request
                if (fromIme) {
@@ -1190,7 +1190,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                }
                switch(consumer.requestShow(fromIme)) {
                    case ShowResult.SHOW_IMMEDIATELY:
                        canRun = true;
                        break;
                    case ShowResult.IME_SHOW_DELAYED:
                        imeReady = false;
@@ -1201,6 +1200,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                                + fromIme);
                        // IME cannot be shown (since it didn't have focus), proceed
                        // with animation of other types.
                        canRun = false;
                        break;
                }
            } else {
@@ -1210,7 +1210,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                if (!fromIme) {
                    consumer.notifyHidden();
                }
                canRun = true;
            }
            if (!canRun) {
                if (WARN) Log.w(TAG, String.format(
+17 −0
Original line number Diff line number Diff line
@@ -929,6 +929,23 @@ public class InsetsControllerTest {
        });
    }

    @Test
    public void testImeRequestedVisibleWhenImeNotControllable() {
        InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
            // Simulate IME insets is not controllable
            mController.onControlsChanged(new InsetsSourceControl[0]);
            final InsetsSourceConsumer imeInsetsConsumer = mController.getSourceConsumer(ITYPE_IME);
            assertNull(imeInsetsConsumer.getControl());

            // Verify IME requested visibility should be updated to IME consumer from controller.
            mController.show(ime());
            assertTrue(imeInsetsConsumer.isRequestedVisible());

            mController.hide(ime());
            assertFalse(imeInsetsConsumer.isRequestedVisible());
        });
    }

    private void waitUntilNextFrame() throws Exception {
        final CountDownLatch latch = new CountDownLatch(1);
        Choreographer.getMainThreadInstance().postCallback(Choreographer.CALLBACK_COMMIT,