Merge "Fix focus cleared and password keyboard shown during IME switching" into rvc-dev am: ec956ce538
Change-Id: I44728c8aa877aca7ac08ec4fd239730a47f84842
This commit is contained in:
@@ -166,11 +166,18 @@ class InsetsSourceProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
mTmpRect.set(mWin.getFrameLw());
|
||||
if (mFrameProvider != null) {
|
||||
mFrameProvider.accept(mWin.getDisplayContent().mDisplayFrames, mWin, mTmpRect);
|
||||
// Make sure we set the valid source frame only when server visible is true, because the
|
||||
// frame may not yet determined that server side doesn't think the window is ready to
|
||||
// visible. (i.e. No surface, pending insets that were given during layout, etc..)
|
||||
if (mServerVisible) {
|
||||
mTmpRect.set(mWin.getFrameLw());
|
||||
if (mFrameProvider != null) {
|
||||
mFrameProvider.accept(mWin.getDisplayContent().mDisplayFrames, mWin, mTmpRect);
|
||||
} else {
|
||||
mTmpRect.inset(mWin.mGivenContentInsets);
|
||||
}
|
||||
} else {
|
||||
mTmpRect.inset(mWin.mGivenContentInsets);
|
||||
mTmpRect.setEmpty();
|
||||
}
|
||||
mSource.setFrame(mTmpRect);
|
||||
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
|
||||
package com.android.server.wm;
|
||||
|
||||
import static android.view.InsetsState.ITYPE_IME;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -44,12 +46,17 @@ public class InsetsSourceProviderTest extends WindowTestsBase {
|
||||
|
||||
private InsetsSource mSource = new InsetsSource(ITYPE_STATUS_BAR);
|
||||
private InsetsSourceProvider mProvider;
|
||||
private InsetsSource mImeSource = new InsetsSource(ITYPE_IME);
|
||||
private InsetsSourceProvider mImeProvider;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mSource.setVisible(true);
|
||||
mProvider = new InsetsSourceProvider(mSource,
|
||||
mDisplayContent.getInsetsStateController(), mDisplayContent);
|
||||
mProvider.setServerVisible(true);
|
||||
mImeProvider = new InsetsSourceProvider(mImeSource,
|
||||
mDisplayContent.getInsetsStateController(), mDisplayContent);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -165,6 +172,30 @@ public class InsetsSourceProviderTest extends WindowTestsBase {
|
||||
assertNull(mProvider.getControl(target));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateSourceFrameForIme() {
|
||||
final WindowState inputMethod = createWindow(null, TYPE_INPUT_METHOD, "inputMethod");
|
||||
|
||||
inputMethod.getFrameLw().set(new Rect(0, 400, 500, 500));
|
||||
|
||||
mImeProvider.setWindow(inputMethod, null, null);
|
||||
mImeProvider.setServerVisible(false);
|
||||
mImeSource.setVisible(true);
|
||||
mImeProvider.updateSourceFrame();
|
||||
assertEquals(new Rect(0, 0, 0, 0), mImeSource.getFrame());
|
||||
Insets insets = mImeSource.calculateInsets(new Rect(0, 0, 500, 500),
|
||||
false /* ignoreVisibility */);
|
||||
assertEquals(Insets.of(0, 0, 0, 0), insets);
|
||||
|
||||
mImeProvider.setServerVisible(true);
|
||||
mImeSource.setVisible(true);
|
||||
mImeProvider.updateSourceFrame();
|
||||
assertEquals(inputMethod.getFrameLw(), mImeSource.getFrame());
|
||||
insets = mImeSource.calculateInsets(new Rect(0, 0, 500, 500),
|
||||
false /* ignoreVisibility */);
|
||||
assertEquals(Insets.of(0, 0, 0, 100), insets);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsetsModified() {
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
|
||||
Reference in New Issue
Block a user