From 05e924b2ab80d1b6eb8bd8b7cb4c50669fb3c8af Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Tue, 1 Nov 2022 13:08:35 -0700 Subject: [PATCH] Clarify required permission in IMM#getInputMethodListAsUser() This is a follow up CL to our previous CL [1], which exposed InputMethodManager#getInputMethodListAsUser(int userId) [2] as an @TestApi. One thing to clarify is that INTERACT_ACROSS_USERS_FULL permission is required when and only when "userId" is different from the one of the calling process. To make it clear, this CL adds "conditional = true" like other @RequiresPermission usages in InputMethodManager. This is just about (Test) API annotation. There must be no observable behavior change. [1]: I4b73d9374d7a2ce4c9dfc48682a43d5d48b39042 ec8b1449f257337dab95c8e4c4957c749b1291d8 [2]: I5b50b5fe143c74c87b331bda3e5bcc4d6248436e d20eef826c879c3be3be1d22322e51ee92880561 Bug: 256239860 Test: presubmit Change-Id: I14867e528d4292f1f8713b1d9b491fc5ed6c1abb --- core/api/test-current.txt | 2 +- .../view/inputmethod/IInputMethodManagerGlobalInvoker.java | 1 + core/java/android/view/inputmethod/InputMethodManager.java | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/api/test-current.txt b/core/api/test-current.txt index 8461fc1b7ae5e..df07ee351bbc1 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -3159,7 +3159,7 @@ package android.view.inputmethod { public final class InputMethodManager { method @RequiresPermission(android.Manifest.permission.TEST_INPUT_METHOD) public void addVirtualStylusIdForTestSession(); method public int getDisplayId(); - method @NonNull @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public java.util.List getInputMethodListAsUser(int); + method @NonNull @RequiresPermission(value=android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional=true) public java.util.List getInputMethodListAsUser(int); method public boolean hasActiveInputConnection(@Nullable android.view.View); method @RequiresPermission(android.Manifest.permission.TEST_INPUT_METHOD) public boolean isInputMethodPickerShown(); method @RequiresPermission(android.Manifest.permission.TEST_INPUT_METHOD) public void setStylusWindowIdleTimeoutForTest(long); diff --git a/core/java/android/view/inputmethod/IInputMethodManagerGlobalInvoker.java b/core/java/android/view/inputmethod/IInputMethodManagerGlobalInvoker.java index 1afa98769a5a8..eb0f540fc0759 100644 --- a/core/java/android/view/inputmethod/IInputMethodManagerGlobalInvoker.java +++ b/core/java/android/view/inputmethod/IInputMethodManagerGlobalInvoker.java @@ -212,6 +212,7 @@ final class IInputMethodManagerGlobalInvoker { @AnyThread @NonNull + @RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true) static List getInputMethodList(@UserIdInt int userId, @DirectBootAwareness int directBootAwareness) { final IInputMethodManager service = getService(); diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 2bc4f5ecb0d04..a0ce65ca09c0b 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -1549,13 +1549,16 @@ public final class InputMethodManager { /** * Returns the list of installed input methods for the specified user. * + *

{@link Manifest.permission#INTERACT_ACROSS_USERS_FULL} is required when and only when + * {@code userId} is different from the user id of the current process.

+ * * @param userId user ID to query * @return {@link List} of {@link InputMethodInfo}. * @hide */ @TestApi - @RequiresPermission(INTERACT_ACROSS_USERS_FULL) @NonNull + @RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true) public List getInputMethodListAsUser(@UserIdInt int userId) { return IInputMethodManagerGlobalInvoker.getInputMethodList(userId, DirectBootAwareness.AUTO);