summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/InsetsController.java5
-rw-r--r--core/tests/coretests/src/android/view/InsetsControllerTest.java17
2 files changed, 19 insertions, 3 deletions
diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java
index 0e3bcd1b6842..4a72a62b7a8d 100644
--- a/core/java/android/view/InsetsController.java
+++ b/core/java/android/view/InsetsController.java
@@ -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(
diff --git a/core/tests/coretests/src/android/view/InsetsControllerTest.java b/core/tests/coretests/src/android/view/InsetsControllerTest.java
index 6e59b83810e1..cc68fcee9f32 100644
--- a/core/tests/coretests/src/android/view/InsetsControllerTest.java
+++ b/core/tests/coretests/src/android/view/InsetsControllerTest.java
@@ -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,