Merge "Only notify insets changed caused by z-order under some conditions" into rvc-dev am: 0d145e89c6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11947521

Change-Id: Ib920759454d583ff7116617c05c1aa48629beb2e
This commit is contained in:
Tiger Huang
2020-06-22 13:57:34 +00:00
committed by Automerger Merge Worker
3 changed files with 21 additions and 10 deletions

View File

@@ -729,7 +729,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
// Sets mBehindIme for each window. Windows behind IME can get IME insets.
if (w.mBehindIme != mTmpWindowsBehindIme) {
w.mBehindIme = mTmpWindowsBehindIme;
mWinInsetsChanged.add(w);
if (getInsetsStateController().getRawInsetsState().getSourceOrDefaultVisibility(
ITYPE_IME)) {
// If IME is invisible, behind IME or not doesn't make the insets different.
mWinInsetsChanged.add(w);
}
}
if (w == mInputMethodWindow) {
mTmpWindowsBehindIme = true;

View File

@@ -246,7 +246,7 @@ class InsetsStateController {
// (e.g., z-order) have changed. They can affect the insets states that we dispatch to
// the clients.
for (int i = winInsetsChanged.size() - 1; i >= 0; i--) {
winInsetsChanged.get(i).notifyInsetsChanged();
mDispatchInsetsChanged.accept(winInsetsChanged.get(i));
}
}
winInsetsChanged.clear();

View File

@@ -30,7 +30,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -41,7 +40,6 @@ import static org.mockito.Mockito.verify;
import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;
import android.view.InsetsSource;
import android.view.InsetsSourceControl;
import android.view.InsetsState;
import android.view.test.InsetsModeSession;
@@ -188,13 +186,23 @@ public class InsetsStateControllerTest extends WindowTestsBase {
@Test
public void testStripForDispatch_imeOrderChanged() {
getController().getSourceProvider(ITYPE_IME).setWindow(mImeWindow, null, null);
// This can be the IME z-order target while app cannot be the IME z-order target.
// This is also the only IME control target in this test, so IME won't be invisible caused
// by the control-target change.
mDisplayContent.mInputMethodInputTarget = createWindow(null, TYPE_APPLICATION, "base");
// This window can be the IME target while app cannot be the IME target.
createWindow(null, TYPE_APPLICATION, "base");
// Make IME and stay visible during the test.
mImeWindow.setHasSurface(true);
getController().getSourceProvider(ITYPE_IME).setWindow(mImeWindow, null, null);
getController().onImeControlTargetChanged(mDisplayContent.mInputMethodInputTarget);
final InsetsState requestedState = new InsetsState();
requestedState.getSource(ITYPE_IME).setVisible(true);
mDisplayContent.mInputMethodInputTarget.updateRequestedInsetsState(requestedState);
getController().onInsetsModified(mDisplayContent.mInputMethodInputTarget, requestedState);
// Send our spy window (app) into the system so that we can detect the invocation.
final WindowState win = createWindow(null, TYPE_APPLICATION, "app");
win.setHasSurface(true);
final WindowToken parent = win.mToken;
parent.removeChild(win);
final WindowState app = spy(win);
@@ -206,7 +214,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
mDisplayContent.applySurfaceChangesTransaction();
// app won't get visible IME insets while above IME even when IME is visible.
getController().getRawInsetsState().setSourceVisible(ITYPE_IME, true);
assertTrue(getController().getRawInsetsState().getSourceOrDefaultVisibility(ITYPE_IME));
assertFalse(getController().getInsetsForDispatch(app).getSource(ITYPE_IME).isVisible());
// Reset invocation counter.
@@ -220,8 +228,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
// Make sure app got notified.
verify(app, atLeast(1)).notifyInsetsChanged();
// app will get visible IME insets while below IME when IME is visible.
getController().getRawInsetsState().setSourceVisible(ITYPE_IME, true);
// app will get visible IME insets while below IME.
assertTrue(getController().getInsetsForDispatch(app).getSource(ITYPE_IME).isVisible());
}