Hide SoftInput when INVALID_DISPLAY

We only prevent to show soft input in
IMMS#startInputUncheckedLocked when
DISPLAY_IME_POLICY_HIDE is set.

If a display with DISPLAY_IME_POLICY_HIDE,
we should hide the soft input anyway.

Bug: 199991634
Test: atest CtsInputMethodTestCases
Test: Verify as following steps:
1) adb shell wm size 800x1280
2) adb shell wm density 213
3) atest MultiDisplaySystemDecorationTests#\
   testDisplayPolicyImeHideImeNoSystemDecorations

Merged-In: I3ab03667c28ec5beb6c3332aceaae4a63cd7309a
Change-Id: I3ab03667c28ec5beb6c3332aceaae4a63cd7309a
(cherry picked from commit d41ac0605c)
This commit is contained in:
Wilson Wu
2021-09-17 00:20:55 +08:00
parent 5b73d12920
commit b9e5fc383d
3 changed files with 13 additions and 1 deletions

View File

@@ -236,6 +236,8 @@ public final class InputMethodDebug {
return "HIDE_TOGGLE_SOFT_INPUT";
case SoftInputShowHideReason.SHOW_SOFT_INPUT_BY_INSETS_API:
return "SHOW_SOFT_INPUT_BY_INSETS_API";
case SoftInputShowHideReason.HIDE_DISPLAY_IME_POLICY_HIDE:
return "HIDE_DISPLAY_IME_POLICY_HIDE";
default:
return "Unknown=" + reason;
}

View File

@@ -19,6 +19,7 @@ package com.android.internal.inputmethod;
import static java.lang.annotation.RetentionPolicy.SOURCE;
import android.annotation.IntDef;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import java.lang.annotation.Retention;
@@ -53,7 +54,8 @@ import java.lang.annotation.Retention;
SoftInputShowHideReason.SHOW_RESTORE_IME_VISIBILITY,
SoftInputShowHideReason.SHOW_TOGGLE_SOFT_INPUT,
SoftInputShowHideReason.HIDE_TOGGLE_SOFT_INPUT,
SoftInputShowHideReason.SHOW_SOFT_INPUT_BY_INSETS_API})
SoftInputShowHideReason.SHOW_SOFT_INPUT_BY_INSETS_API,
SoftInputShowHideReason.HIDE_DISPLAY_IME_POLICY_HIDE})
public @interface SoftInputShowHideReason {
/** Show soft input by {@link android.view.inputmethod.InputMethodManager#showSoftInput}. */
int SHOW_SOFT_INPUT = 0;
@@ -195,4 +197,10 @@ public @interface SoftInputShowHideReason {
* {@link android.view.InsetsController#show(int)};
*/
int SHOW_SOFT_INPUT_BY_INSETS_API = 25;
/**
* Hide soft input if Ime policy has been set to {@link WindowManager#DISPLAY_IME_POLICY_HIDE}.
* See also {@code InputMethodManagerService#mImeHiddenByDisplayPolicy}.
*/
int HIDE_DISPLAY_IME_POLICY_HIDE = 26;
}

View File

@@ -2356,6 +2356,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
if (displayIdToShowIme == INVALID_DISPLAY) {
mImeHiddenByDisplayPolicy = true;
hideCurrentInputLocked(mCurFocusedWindow, 0, null,
SoftInputShowHideReason.HIDE_DISPLAY_IME_POLICY_HIDE);
return InputBindResult.NO_IME;
}
mImeHiddenByDisplayPolicy = false;