Merge "DO NOT MERGE - re-added P-specific IME commands to MockIme" into pie-cts-dev
diff --git a/tests/autofillservice/src/com/android/cts/mockime/MockIme.java b/tests/autofillservice/src/com/android/cts/mockime/MockIme.java
index 11068d1..52a1182 100644
--- a/tests/autofillservice/src/com/android/cts/mockime/MockIme.java
+++ b/tests/autofillservice/src/com/android/cts/mockime/MockIme.java
@@ -147,9 +147,7 @@
}
case "requestShowSelf": {
final int flags = command.getExtras().getInt("flags");
- // This method was added on P
- Log.w(TAG, "Ignoring requestShowFelf(" + flags +")");
- // requestShowSelf(flags);
+ requestShowSelf(flags);
break;
}
}
diff --git a/tests/autofillservice/src/com/android/cts/mockime/MockImeSession.java b/tests/autofillservice/src/com/android/cts/mockime/MockImeSession.java
index 099d6b3..727da2c 100644
--- a/tests/autofillservice/src/com/android/cts/mockime/MockImeSession.java
+++ b/tests/autofillservice/src/com/android/cts/mockime/MockImeSession.java
@@ -175,9 +175,19 @@
}
private void initialize(@Nullable ImeSettings.Builder imeSettings) throws Exception {
- // NOTE: on P we call 'ime reset', but it's not available on O, so we're just ignoring it -
- // we don't really need the IME and it will be effectively disabled after this APK is
- // uninstalled.
+ // Make sure that MockIME is not selected.
+ if (mContext.getSystemService(InputMethodManager.class)
+ .getInputMethodList()
+ .stream()
+ .anyMatch(info -> getMockImeComponentName().equals(info.getComponent()))) {
+ executeShellCommand(mUiAutomation, "ime reset");
+ }
+ if (mContext.getSystemService(InputMethodManager.class)
+ .getEnabledInputMethodList()
+ .stream()
+ .anyMatch(info -> getMockImeComponentName().equals(info.getComponent()))) {
+ throw new IllegalStateException();
+ }
writeMockImeSettings(mContext, mImeEventActionName, imeSettings);
@@ -228,9 +238,13 @@
* selected next is up to the system.
*/
public void close() throws Exception {
- // NOTE: on P we call 'ime reset', but it's not available on O, so we're just ignoring it -
- // we don't really need the IME and it will be effectively disabled after this APK is
- // uninstalled.
+ executeShellCommand(mUiAutomation, "ime reset");
+
+ PollingCheck.check("Make sure that MockIME becomes unavailable", TIMEOUT, () ->
+ mContext.getSystemService(InputMethodManager.class)
+ .getEnabledInputMethodList()
+ .stream()
+ .noneMatch(info -> getMockImeComponentName().equals(info.getComponent())));
mContext.unregisterReceiver(mEventReceiver);
mHandlerThread.quitSafely();