Make TEST_INPUT_METHOD @TestAPI
This is a follow up CL to my previous CL [1], which introduced
android.permission.TEST_INPUT_METHO
to protect several @TestApi methods in InputMethodManager.
This CL makes the permission itself as @TestApi so that it can be
included as an API constant in test-current.txt. This also enables us
to minimize special permission while running CTS as follows.
SystemUtil.runWithShellPermissionIdentity(() -> {
// do something.
}, Manifest.permission.TEST_INPUT_METHOD);
There must be no user observable behavior change in this CL.
[1]: Ie79a3e9d41ce22605ae083594d639c37d08b7def
b869c783808c4d4937727a1672b2fac81bace368
Bug: 256239860
Test: presubmit
Change-Id: I1fd3ceda9a1b641e63c7633a223a9a806e78cd2d
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index ef74a3e..80da6c1 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -47,6 +47,7 @@
field public static final String SET_KEYBOARD_LAYOUT = "android.permission.SET_KEYBOARD_LAYOUT";
field public static final String SUSPEND_APPS = "android.permission.SUSPEND_APPS";
field public static final String TEST_BIOMETRIC = "android.permission.TEST_BIOMETRIC";
+ field public static final String TEST_INPUT_METHOD = "android.permission.TEST_INPUT_METHOD";
field public static final String TEST_MANAGE_ROLLBACKS = "android.permission.TEST_MANAGE_ROLLBACKS";
field public static final String UPGRADE_RUNTIME_PERMISSIONS = "android.permission.UPGRADE_RUNTIME_PERMISSIONS";
field public static final String WRITE_DEVICE_CONFIG = "android.permission.WRITE_DEVICE_CONFIG";
@@ -3160,8 +3161,8 @@
method public int getDisplayId();
method @NonNull @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public java.util.List<android.view.inputmethod.InputMethodInfo> getInputMethodListAsUser(int);
method public boolean hasActiveInputConnection(@Nullable android.view.View);
- method public boolean isInputMethodPickerShown();
- method @RequiresPermission("android.permission.TEST_INPUT_METHOD") public void setStylusWindowIdleTimeoutForTest(long);
+ method @RequiresPermission(android.Manifest.permission.TEST_INPUT_METHOD) public boolean isInputMethodPickerShown();
+ method @RequiresPermission(android.Manifest.permission.TEST_INPUT_METHOD) public void setStylusWindowIdleTimeoutForTest(long);
field public static final long CLEAR_SHOW_FORCED_FLAG_WHEN_LEAVING = 214016041L; // 0xcc1a029L
}
diff --git a/core/java/android/view/inputmethod/IInputMethodManagerGlobalInvoker.java b/core/java/android/view/inputmethod/IInputMethodManagerGlobalInvoker.java
index aeff37c..7f859d6 100644
--- a/core/java/android/view/inputmethod/IInputMethodManagerGlobalInvoker.java
+++ b/core/java/android/view/inputmethod/IInputMethodManagerGlobalInvoker.java
@@ -16,6 +16,7 @@
package android.view.inputmethod;
+import android.Manifest;
import android.annotation.AnyThread;
import android.annotation.DurationMillisLong;
import android.annotation.NonNull;
@@ -353,6 +354,7 @@
}
@AnyThread
+ @RequiresPermission(Manifest.permission.TEST_INPUT_METHOD)
static boolean isInputMethodPickerShownForTest() {
final IInputMethodManager service = getService();
if (service == null) {
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 53d77e1..f2ce739 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -3459,6 +3459,7 @@
* @hide
*/
@TestApi
+ @RequiresPermission(Manifest.permission.TEST_INPUT_METHOD)
public boolean isInputMethodPickerShown() {
return IInputMethodManagerGlobalInvoker.isInputMethodPickerShownForTest();
}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 62c5848..2b97a34 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -4127,7 +4127,8 @@
android:protectionLevel="signature" />
<!-- Allows access to Test APIs defined in {@link android.view.inputmethod.InputMethodManager}.
- @hide -->
+ @hide
+ @TestApi -->
<permission android:name="android.permission.TEST_INPUT_METHOD"
android:protectionLevel="signature" />