From 89d683f2cfec03b1f244d9b64c151de893d4daf5 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Fri, 28 Oct 2022 19:41:18 -0700 Subject: [PATCH] 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 --- core/api/test-current.txt | 5 +++-- .../view/inputmethod/IInputMethodManagerGlobalInvoker.java | 2 ++ core/java/android/view/inputmethod/InputMethodManager.java | 1 + core/res/AndroidManifest.xml | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/api/test-current.txt b/core/api/test-current.txt index ef74a3ef6c205..80da6c13e02a1 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -47,6 +47,7 @@ package android { 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 @@ package android.view.inputmethod { method public int getDisplayId(); method @NonNull @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public java.util.List 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 aeff37c67444a..7f859d6b4bf4c 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 @@ final class IInputMethodManagerGlobalInvoker { } @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 53d77e146d891..f2ce739cdbeda 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -3459,6 +3459,7 @@ public final class InputMethodManager { * @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 62c584847c0f2..2b97a345c11d1 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -4127,7 +4127,8 @@ android:protectionLevel="signature" /> + @hide + @TestApi -->