Merge "Fix updateAboveInsetsState may not apply IME window in some cases"

This commit is contained in:
TreeHugger Robot
2022-12-02 16:41:05 +00:00
committed by Android (Google) Code Review
3 changed files with 41 additions and 1 deletions

View File

@@ -4927,7 +4927,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
// animation on the keyguard but seeing the IME window that originally on the app
// which behinds the keyguard.
final WindowState imeInputTarget = getImeInputTarget();
if (imeInputTarget != null && !(imeInputTarget.isDrawn() || imeInputTarget.isVisible())) {
if (imeInputTarget != null
&& !(imeInputTarget.isDrawn() || imeInputTarget.isVisibleRequested())) {
return false;
}
return mDisplayContent.forAllImeWindows(callback, traverseTopToBottom);

View File

@@ -442,6 +442,44 @@ public class InsetsStateControllerTest extends WindowTestsBase {
verify(navBar, atLeastOnce()).notifyInsetsChanged();
}
@Test
public void testUpdateAboveInsetsState_imeTargetOnScreenBehavior() {
final WindowToken imeToken = createTestWindowToken(TYPE_INPUT_METHOD, mDisplayContent);
final WindowState ime = createWindow(null, TYPE_INPUT_METHOD, imeToken, "ime");
final WindowState app = createTestWindow("app");
getController().getSourceProvider(ITYPE_IME).setWindowContainer(ime, null, null);
ime.getControllableInsetProvider().setServerVisible(true);
app.mActivityRecord.setVisibility(true);
mDisplayContent.setImeLayeringTarget(app);
mDisplayContent.updateImeInputAndControlTarget(app);
app.setRequestedVisibleTypes(ime(), ime());
getController().onInsetsModified(app);
assertTrue(ime.getControllableInsetProvider().getSource().isVisible());
getController().updateAboveInsetsState(true /* notifyInsetsChange */);
assertNotNull(app.getInsetsState().peekSource(ITYPE_IME));
verify(app, atLeastOnce()).notifyInsetsChanged();
// Expect the app will still get IME insets even when the app was invisible.
// (i.e. app invisible after locking the device)
app.mActivityRecord.setVisible(false);
app.setHasSurface(false);
getController().updateAboveInsetsState(true /* notifyInsetsChange */);
assertNotNull(app.getInsetsState().peekSource(ITYPE_IME));
verify(app, atLeastOnce()).notifyInsetsChanged();
// Expect the app will get IME insets when the app is requesting visible.
// (i.e. app is going to visible when unlocking the device)
app.mActivityRecord.setVisibility(true);
assertTrue(app.isVisibleRequested());
getController().updateAboveInsetsState(true /* notifyInsetsChange */);
assertNotNull(app.getInsetsState().peekSource(ITYPE_IME));
verify(app, atLeastOnce()).notifyInsetsChanged();
}
@Test
public void testDispatchGlobalInsets() {
final WindowState navBar = createWindow(null, TYPE_APPLICATION, "navBar");

View File

@@ -772,6 +772,7 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
// Simulating now win1 is being covered by the lockscreen which has no surface,
// and then launching an activity win2 with the remote animation
win1.mHasSurface = false;
win1.mActivityRecord.setVisibility(false);
mDisplayContent.mOpeningApps.add(win2.mActivityRecord);
final AnimationAdapter adapter = mController.createRemoteAnimationRecord(
win2.mActivityRecord, new Point(50, 100), null,