Merge "Only notify insets changed caused by z-order under some conditions" into rvc-dev am: 0d145e89c6 am: 4b164573c9 am: 0131bc669e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11947521 Change-Id: Ib0ce059bb3d21f6f74b5f824b37e4ccae9c9866f
This commit is contained in:
@@ -729,7 +729,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
|
|||||||
// Sets mBehindIme for each window. Windows behind IME can get IME insets.
|
// Sets mBehindIme for each window. Windows behind IME can get IME insets.
|
||||||
if (w.mBehindIme != mTmpWindowsBehindIme) {
|
if (w.mBehindIme != mTmpWindowsBehindIme) {
|
||||||
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) {
|
if (w == mInputMethodWindow) {
|
||||||
mTmpWindowsBehindIme = true;
|
mTmpWindowsBehindIme = true;
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ class InsetsStateController {
|
|||||||
// (e.g., z-order) have changed. They can affect the insets states that we dispatch to
|
// (e.g., z-order) have changed. They can affect the insets states that we dispatch to
|
||||||
// the clients.
|
// the clients.
|
||||||
for (int i = winInsetsChanged.size() - 1; i >= 0; i--) {
|
for (int i = winInsetsChanged.size() - 1; i >= 0; i--) {
|
||||||
winInsetsChanged.get(i).notifyInsetsChanged();
|
mDispatchInsetsChanged.accept(winInsetsChanged.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
winInsetsChanged.clear();
|
winInsetsChanged.clear();
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -41,7 +40,6 @@ import static org.mockito.Mockito.verify;
|
|||||||
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.platform.test.annotations.Presubmit;
|
import android.platform.test.annotations.Presubmit;
|
||||||
import android.view.InsetsSource;
|
|
||||||
import android.view.InsetsSourceControl;
|
import android.view.InsetsSourceControl;
|
||||||
import android.view.InsetsState;
|
import android.view.InsetsState;
|
||||||
import android.view.test.InsetsModeSession;
|
import android.view.test.InsetsModeSession;
|
||||||
@@ -188,13 +186,23 @@ public class InsetsStateControllerTest extends WindowTestsBase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStripForDispatch_imeOrderChanged() {
|
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.
|
// Make IME and stay visible during the test.
|
||||||
createWindow(null, TYPE_APPLICATION, "base");
|
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.
|
// Send our spy window (app) into the system so that we can detect the invocation.
|
||||||
final WindowState win = createWindow(null, TYPE_APPLICATION, "app");
|
final WindowState win = createWindow(null, TYPE_APPLICATION, "app");
|
||||||
|
win.setHasSurface(true);
|
||||||
final WindowToken parent = win.mToken;
|
final WindowToken parent = win.mToken;
|
||||||
parent.removeChild(win);
|
parent.removeChild(win);
|
||||||
final WindowState app = spy(win);
|
final WindowState app = spy(win);
|
||||||
@@ -206,7 +214,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
|
|||||||
mDisplayContent.applySurfaceChangesTransaction();
|
mDisplayContent.applySurfaceChangesTransaction();
|
||||||
|
|
||||||
// app won't get visible IME insets while above IME even when IME is visible.
|
// 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());
|
assertFalse(getController().getInsetsForDispatch(app).getSource(ITYPE_IME).isVisible());
|
||||||
|
|
||||||
// Reset invocation counter.
|
// Reset invocation counter.
|
||||||
@@ -220,8 +228,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
|
|||||||
// Make sure app got notified.
|
// Make sure app got notified.
|
||||||
verify(app, atLeast(1)).notifyInsetsChanged();
|
verify(app, atLeast(1)).notifyInsetsChanged();
|
||||||
|
|
||||||
// app will get visible IME insets while below IME when IME is visible.
|
// app will get visible IME insets while below IME.
|
||||||
getController().getRawInsetsState().setSourceVisible(ITYPE_IME, true);
|
|
||||||
assertTrue(getController().getInsetsForDispatch(app).getSource(ITYPE_IME).isVisible());
|
assertTrue(getController().getInsetsForDispatch(app).getSource(ITYPE_IME).isVisible());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user