Fix unexpected starting window removal timeout when in fixed-rotation
Not aware in DC#mayImeShowOnLaunchingActivity has an issue that
it uses findMainWindow() to check its softInputMode visiblity state
but always got 0 because the returned main window is the starting window
vs. the app's base application window, which is not expected.
This problematic logic leads to when CL[1] merged, the starting window
removal mode and timout always set to DEFER_MODE_ROTATION (3 secs)
vs. DEFER_MODE_NONE (100ms) if the warm launching activity's softInputMode
is hidden during fixed-rotation.
Ensure finding the main window with excluding the starting window in
DC#mayImeShowOnLaunchingActivity to fix this case.
[1]: Ie476e89a57f2f64d4d66e722fedeeb1719d9de55
Bug: 268627602
Test: atest FlickerTests:\
ShowImeOnAppStartWhenLaunchingAppFromFixedOrientationTest
Test: atest DisplayContentTests#\
testMayImeShowOnLaunchingActivity_negativeWhenSoftInputModeHidden
Change-Id: I3fa33daf20734b673fd89328dca6a8fd432f2969
This commit is contained in:
@@ -1884,7 +1884,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
|
||||
/** Returns {@code true} if the IME is possible to show on the launching activity. */
|
||||
boolean mayImeShowOnLaunchingActivity(@NonNull ActivityRecord r) {
|
||||
final WindowState win = r.findMainWindow();
|
||||
final WindowState win = r.findMainWindow(false /* exclude starting window */);
|
||||
if (win == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_M
|
||||
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
|
||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION;
|
||||
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN;
|
||||
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||
@@ -2827,6 +2829,26 @@ public class DisplayContentTests extends WindowTestsBase {
|
||||
mDisplayContent.getKeepClearAreas());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMayImeShowOnLaunchingActivity_negativeWhenSoftInputModeHidden() {
|
||||
final ActivityRecord app = createActivityRecord(mDisplayContent);
|
||||
final WindowState appWin = createWindow(null, TYPE_BASE_APPLICATION, app, "appWin");
|
||||
createWindow(null, TYPE_APPLICATION_STARTING, app, "startingWin");
|
||||
app.mStartingData = mock(SnapshotStartingData.class);
|
||||
// Assume the app has shown IME before and warm launching with a snapshot window.
|
||||
doReturn(true).when(app.mStartingData).hasImeSurface();
|
||||
|
||||
// Expect true when this IME focusable activity will show IME during launching.
|
||||
assertTrue(WindowManager.LayoutParams.mayUseInputMethod(appWin.mAttrs.flags));
|
||||
assertTrue(mDisplayContent.mayImeShowOnLaunchingActivity(app));
|
||||
|
||||
// Not expect IME will be shown during launching if the app's softInputMode is hidden.
|
||||
appWin.mAttrs.softInputMode = SOFT_INPUT_STATE_ALWAYS_HIDDEN;
|
||||
assertFalse(mDisplayContent.mayImeShowOnLaunchingActivity(app));
|
||||
appWin.mAttrs.softInputMode = SOFT_INPUT_STATE_HIDDEN;
|
||||
assertFalse(mDisplayContent.mayImeShowOnLaunchingActivity(app));
|
||||
}
|
||||
|
||||
private void removeRootTaskTests(Runnable runnable) {
|
||||
final TaskDisplayArea taskDisplayArea = mRootWindowContainer.getDefaultTaskDisplayArea();
|
||||
final Task rootTask1 = taskDisplayArea.createRootTask(WINDOWING_MODE_FULLSCREEN,
|
||||
|
||||
Reference in New Issue
Block a user