Merge "Deflake InputMethodServiceTest" into main
diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java
index 2029b71..8f630af 100644
--- a/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java
+++ b/services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java
@@ -99,6 +99,12 @@
                     InputMethodServiceWrapper.getInputMethodServiceWrapperForTesting();
             assertThat(mInputMethodService).isNotNull();
 
+            // The activity gets focus.
+            assertThat(mActivity.hasWindowFocus()).isTrue();
+            assertThat(mInputMethodService.getCurrentInputEditorInfo()).isNotNull();
+            assertThat(mInputMethodService.getCurrentInputEditorInfo().packageName)
+                    .isEqualTo(mTargetPackageName);
+
             // The editor won't bring up keyboard by default.
             assertThat(mInputMethodService.getCurrentInputStarted()).isTrue();
             assertThat(mInputMethodService.getCurrentInputViewStarted()).isFalse();
diff --git a/services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/src/com/android/apps/inputmethod/simpleime/ims/InputMethodServiceWrapper.java b/services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/src/com/android/apps/inputmethod/simpleime/ims/InputMethodServiceWrapper.java
index b706a65..67212b6 100644
--- a/services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/src/com/android/apps/inputmethod/simpleime/ims/InputMethodServiceWrapper.java
+++ b/services/tests/InputMethodSystemServerTests/test-apps/SimpleTestIme/src/com/android/apps/inputmethod/simpleime/ims/InputMethodServiceWrapper.java
@@ -53,13 +53,14 @@
 
     @Override
     public void onStartInput(EditorInfo info, boolean restarting) {
-        Log.i(TAG, "onStartInput() editor=" + info + ", restarting=" + restarting);
+        Log.i(TAG, "onStartInput() editor=" + dumpEditorInfo(info) + ", restarting=" + restarting);
         super.onStartInput(info, restarting);
     }
 
     @Override
     public void onStartInputView(EditorInfo info, boolean restarting) {
-        Log.i(TAG, "onStartInputView() editor=" + info + ", restarting=" + restarting);
+        Log.i(TAG, "onStartInputView() editor=" + dumpEditorInfo(info)
+                + ", restarting=" + restarting);
         super.onStartInputView(info, restarting);
         mInputViewStarted = true;
         if (mCountDownLatchForTesting != null) {
@@ -99,4 +100,14 @@
             mCountDownLatchForTesting.countDown();
         }
     }
+
+    private String dumpEditorInfo(EditorInfo info) {
+        var sb = new StringBuilder();
+        sb.append("EditorInfo{packageName=").append(info.packageName);
+        sb.append(" fieldId=").append(info.fieldId);
+        sb.append(" hintText=").append(info.hintText);
+        sb.append(" privateImeOptions=").append(info.privateImeOptions);
+        sb.append("}");
+        return sb.toString();
+    }
 }