summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java14
-rw-r--r--services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceWindowGainedFocusTest.java103
2 files changed, 91 insertions, 26 deletions
diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java
index 9a25104e1e42..3af5db9841ea 100644
--- a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java
+++ b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java
@@ -53,6 +53,7 @@ import android.os.ServiceManager;
import android.util.ArraySet;
import android.view.InputChannel;
import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.ImeTracker;
import android.window.ImeOnBackInvokedDispatcher;
import androidx.test.platform.app.InstrumentationRegistry;
@@ -260,6 +261,11 @@ public class InputMethodManagerServiceTestBase {
unusedUserId -> mMockInputMethodBindingController);
spyOn(mInputMethodManagerService);
+ synchronized (ImfLock.class) {
+ doReturn(true).when(mInputMethodManagerService).setImeVisibilityOnFocusedWindowClient(
+ anyBoolean(), any(UserData.class), any(ImeTracker.Token.class));
+ }
+
// Start a InputMethodManagerService.Lifecycle to publish and manage the lifecycle of
// InputMethodManagerService, which is closer to the real situation.
InputMethodManagerService.Lifecycle lifecycle =
@@ -347,6 +353,14 @@ public class InputMethodManagerServiceTestBase {
anyInt() /* flags */, any() /* resultReceiver */);
}
+ protected void verifySetImeVisibility(boolean setVisible, boolean invoked) {
+ synchronized (ImfLock.class) {
+ verify(mInputMethodManagerService,
+ times(invoked ? 1 : 0)).setImeVisibilityOnFocusedWindowClient(eq(setVisible),
+ any(UserData.class), any(ImeTracker.Token.class));
+ }
+ }
+
protected void createSessionForClient(IInputMethodClient client) {
synchronized (ImfLock.class) {
ClientState cs = mInputMethodManagerService.getClientStateLocked(client);
diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceWindowGainedFocusTest.java b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceWindowGainedFocusTest.java
index c5b5668c67bc..4d956b2df273 100644
--- a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceWindowGainedFocusTest.java
+++ b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceWindowGainedFocusTest.java
@@ -125,27 +125,52 @@ public class InputMethodManagerServiceWindowGainedFocusTest
case SOFT_INPUT_STATE_UNSPECIFIED:
boolean showSoftInput =
(mSoftInputAdjustment == SOFT_INPUT_ADJUST_RESIZE) || mIsLargeScreen;
- verifyShowSoftInput(
- showSoftInput /* setVisible */, showSoftInput /* showSoftInput */);
- // Soft input was hidden by default, so it doesn't need to call
- // {@code IMS#hideSoftInput()}.
- verifyHideSoftInput(!showSoftInput /* setNotVisible */, false /* hideSoftInput */);
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ verifySetImeVisibility(true /* setVisible */, showSoftInput /* invoked */);
+ // A hide can only be triggered if there is no editorFocused, which this test
+ // always sets.
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(showSoftInput /* setVisible */,
+ showSoftInput /* showSoftInput */);
+ // Soft input was hidden by default, so it doesn't need to call
+ // {@code IMS#hideSoftInput()}.
+ verifyHideSoftInput(!showSoftInput /* setNotVisible */,
+ false /* hideSoftInput */);
+ }
break;
case SOFT_INPUT_STATE_VISIBLE:
case SOFT_INPUT_STATE_ALWAYS_VISIBLE:
- verifyShowSoftInput(true /* setVisible */, true /* showSoftInput */);
- verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ verifySetImeVisibility(true /* setVisible */, true /* invoked */);
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(true /* setVisible */, true /* showSoftInput */);
+ verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ }
break;
- case SOFT_INPUT_STATE_UNCHANGED: // Do nothing
- verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
- verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ case SOFT_INPUT_STATE_UNCHANGED:
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ verifySetImeVisibility(true /* setVisible */, false /* invoked */);
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
+ verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ }
break;
case SOFT_INPUT_STATE_HIDDEN:
case SOFT_INPUT_STATE_ALWAYS_HIDDEN:
- verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
- // Soft input was hidden by default, so it doesn't need to call
- // {@code IMS#hideSoftInput()}.
- verifyHideSoftInput(true /* setNotVisible */, false /* hideSoftInput */);
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ verifySetImeVisibility(true /* setVisible */, false /* invoked */);
+ // In this case, we don't have to manipulate the requested visible types of
+ // the WindowState, as they're already in the correct state
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
+ // Soft input was hidden by default, so it doesn't need to call
+ // {@code IMS#hideSoftInput()}.
+ verifyHideSoftInput(true /* setNotVisible */, false /* hideSoftInput */);
+ }
break;
default:
throw new IllegalStateException(
@@ -167,26 +192,52 @@ public class InputMethodManagerServiceWindowGainedFocusTest
case SOFT_INPUT_STATE_UNSPECIFIED:
boolean hideSoftInput =
(mSoftInputAdjustment != SOFT_INPUT_ADJUST_RESIZE) && !mIsLargeScreen;
- verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
- // Soft input was hidden by default, so it doesn't need to call
- // {@code IMS#hideSoftInput()}.
- verifyHideSoftInput(hideSoftInput /* setNotVisible */, false /* hideSoftInput */);
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ // A show can only be triggered in forward navigation
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ // A hide can only be triggered if there is no editorFocused, which this test
+ // always sets.
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
+ // Soft input was hidden by default, so it doesn't need to call
+ // {@code IMS#hideSoftInput()}.
+ verifyHideSoftInput(hideSoftInput /* setNotVisible */,
+ false /* hideSoftInput */);
+ }
break;
case SOFT_INPUT_STATE_VISIBLE:
case SOFT_INPUT_STATE_HIDDEN:
case SOFT_INPUT_STATE_UNCHANGED: // Do nothing
- verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
- verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ verifySetImeVisibility(true /* setVisible */, false /* invoked */);
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
+ verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ }
break;
case SOFT_INPUT_STATE_ALWAYS_VISIBLE:
- verifyShowSoftInput(true /* setVisible */, true /* showSoftInput */);
- verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ verifySetImeVisibility(true /* setVisible */, true /* invoked */);
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(true /* setVisible */, true /* showSoftInput */);
+ verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ }
break;
case SOFT_INPUT_STATE_ALWAYS_HIDDEN:
- verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
- // Soft input was hidden by default, so it doesn't need to call
- // {@code IMS#hideSoftInput()}.
- verifyHideSoftInput(true /* setNotVisible */, false /* hideSoftInput */);
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ verifySetImeVisibility(true /* setVisible */, false /* invoked */);
+ // In this case, we don't have to manipulate the requested visible types of
+ // the WindowState, as they're already in the correct state
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
+ // Soft input was hidden by default, so it doesn't need to call
+ // {@code IMS#hideSoftInput()}.
+ verifyHideSoftInput(true /* setNotVisible */, false /* hideSoftInput */);
+ }
break;
default:
throw new IllegalStateException(