Use CtsInputMethodTestCases to test instant apps

Bug: 79484568
Test: cts-tradefed run cts-instant -m CtsInputMethodTestCases
Change-Id: If9b68860e521736775fa981fe84f16a63e480e4e
diff --git a/tests/inputmethod/AndroidManifest.xml b/tests/inputmethod/AndroidManifest.xml
index a5bc532..b9c0ef4 100644
--- a/tests/inputmethod/AndroidManifest.xml
+++ b/tests/inputmethod/AndroidManifest.xml
@@ -16,7 +16,8 @@
 -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="android.view.inputmethod.cts">
+    package="android.view.inputmethod.cts"
+    android:targetSandboxVersion="2">
 
     <application
         android:label="CtsInputMethodTestCases"
diff --git a/tests/inputmethod/AndroidTest.xml b/tests/inputmethod/AndroidTest.xml
index f69fff5..f749065 100644
--- a/tests/inputmethod/AndroidTest.xml
+++ b/tests/inputmethod/AndroidTest.xml
@@ -28,6 +28,10 @@
         -->
         <option name="test-file-name" value="CtsInputMethodTestCases.apk" />
     </target_preparer>
+    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+        <option name="run-command" value="cmd input_method set-bind-instant-service-allowed true" />
+        <option name="teardown-command" value="cmd input_method set-bind-instant-service-allowed false" />
+    </target_preparer>
     <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
         <option name="package" value="android.view.inputmethod.cts" />
         <option name="runtime-hint" value="1m0s" />
diff --git a/tests/inputmethod/src/android/view/inputmethod/cts/InputMethodManagerTest.java b/tests/inputmethod/src/android/view/inputmethod/cts/InputMethodManagerTest.java
index b923c66..8400c53 100644
--- a/tests/inputmethod/src/android/view/inputmethod/cts/InputMethodManagerTest.java
+++ b/tests/inputmethod/src/android/view/inputmethod/cts/InputMethodManagerTest.java
@@ -18,7 +18,6 @@
 
 import static android.content.Intent.ACTION_CLOSE_SYSTEM_DIALOGS;
 import static android.content.Intent.FLAG_RECEIVER_FOREGROUND;
-import static android.view.inputmethod.cts.util.TestUtils.runOnMainSync;
 import static android.view.inputmethod.cts.util.TestUtils.waitOnMainUntil;
 
 import static org.junit.Assert.assertFalse;
@@ -30,6 +29,7 @@
 import android.content.Context;
 import android.content.Intent;
 import androidx.annotation.NonNull;
+import android.platform.test.annotations.AppModeFull;
 import android.support.test.InstrumentationRegistry;
 import android.support.test.filters.MediumTest;
 import android.support.test.runner.AndroidJUnit4;
@@ -165,6 +165,7 @@
         }).collect(Collectors.joining(", ")) + "]";
     }
 
+    @AppModeFull(reason = "Instant apps cannot rely on ACTION_CLOSE_SYSTEM_DIALOGS")
     @Test
     public void testShowInputMethodPicker() throws Exception {
         TestActivity.startSync(activity -> {