Merge "Add missing @RequiresPermission to IMM"
This commit is contained in:
@@ -107,8 +107,8 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
* @param where where the information is coming from.
|
||||
* @param exceptionHandler an optional {@link RemoteException} handler.
|
||||
*/
|
||||
@RequiresNoPermission
|
||||
@AnyThread
|
||||
@RequiresNoPermission
|
||||
static void startProtoDump(byte[] protoDump, int source, String where,
|
||||
@Nullable Consumer<RemoteException> exceptionHandler) {
|
||||
final IInputMethodManager service = getService();
|
||||
@@ -127,8 +127,8 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
*
|
||||
* @param exceptionHandler an optional {@link RemoteException} handler.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING)
|
||||
@AnyThread
|
||||
@RequiresPermission(Manifest.permission.CONTROL_UI_TRACING)
|
||||
static void startImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) {
|
||||
final IInputMethodManager service = getService();
|
||||
if (service == null) {
|
||||
@@ -146,8 +146,8 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
*
|
||||
* @param exceptionHandler an optional {@link RemoteException} handler.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING)
|
||||
@AnyThread
|
||||
@RequiresPermission(Manifest.permission.CONTROL_UI_TRACING)
|
||||
static void stopImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) {
|
||||
final IInputMethodManager service = getService();
|
||||
if (service == null) {
|
||||
@@ -165,8 +165,8 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
*
|
||||
* @return The return value of {@link IInputMethodManager#isImeTraceEnabled()}.
|
||||
*/
|
||||
@RequiresNoPermission
|
||||
@AnyThread
|
||||
@RequiresNoPermission
|
||||
static boolean isImeTraceEnabled() {
|
||||
final IInputMethodManager service = getService();
|
||||
if (service == null) {
|
||||
@@ -182,8 +182,8 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
/**
|
||||
* Invokes {@link IInputMethodManager#removeImeSurface()}
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.INTERNAL_SYSTEM_WINDOW)
|
||||
@AnyThread
|
||||
@RequiresPermission(Manifest.permission.INTERNAL_SYSTEM_WINDOW)
|
||||
static void removeImeSurface(@Nullable Consumer<RemoteException> exceptionHandler) {
|
||||
final IInputMethodManager service = getService();
|
||||
if (service == null) {
|
||||
@@ -228,6 +228,7 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
|
||||
@AnyThread
|
||||
@NonNull
|
||||
@RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
|
||||
static List<InputMethodInfo> getEnabledInputMethodList(@UserIdInt int userId) {
|
||||
final IInputMethodManager service = getService();
|
||||
if (service == null) {
|
||||
@@ -242,6 +243,7 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
|
||||
@AnyThread
|
||||
@NonNull
|
||||
@RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
|
||||
static List<InputMethodSubtype> getEnabledInputMethodSubtypeList(@Nullable String imiId,
|
||||
boolean allowsImplicitlyEnabledSubtypes, @UserIdInt int userId) {
|
||||
final IInputMethodManager service = getService();
|
||||
@@ -258,6 +260,7 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
|
||||
@AnyThread
|
||||
@Nullable
|
||||
@RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
|
||||
static InputMethodSubtype getLastInputMethodSubtype(@UserIdInt int userId) {
|
||||
final IInputMethodManager service = getService();
|
||||
if (service == null) {
|
||||
@@ -303,6 +306,7 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
|
||||
@AnyThread
|
||||
@NonNull
|
||||
@RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
|
||||
static InputBindResult startInputOrWindowGainedFocus(@StartInputReason int startInputReason,
|
||||
@NonNull IInputMethodClient client, @Nullable IBinder windowToken,
|
||||
@StartInputFlags int startInputFlags,
|
||||
@@ -341,6 +345,7 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
@RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
|
||||
static void showInputMethodPickerFromSystem(@NonNull IInputMethodClient client,
|
||||
int auxiliarySubtypeMode, int displayId) {
|
||||
final IInputMethodManager service = getService();
|
||||
@@ -370,6 +375,7 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
|
||||
@AnyThread
|
||||
@Nullable
|
||||
@RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
|
||||
static InputMethodSubtype getCurrentInputMethodSubtype(@UserIdInt int userId) {
|
||||
final IInputMethodManager service = getService();
|
||||
if (service == null) {
|
||||
@@ -383,6 +389,7 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
@RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
|
||||
static void setAdditionalInputMethodSubtypes(@NonNull String imeId,
|
||||
@NonNull InputMethodSubtype[] subtypes, @UserIdInt int userId) {
|
||||
final IInputMethodManager service = getService();
|
||||
@@ -397,6 +404,7 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
@RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
|
||||
static void setExplicitlyEnabledInputMethodSubtypes(@NonNull String imeId,
|
||||
@NonNull int[] subtypeHashCodes, @UserIdInt int userId) {
|
||||
final IInputMethodManager service = getService();
|
||||
@@ -477,6 +485,7 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
@RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
|
||||
static boolean isStylusHandwritingAvailableAsUser(@UserIdInt int userId) {
|
||||
final IInputMethodManager service = getService();
|
||||
if (service == null) {
|
||||
@@ -504,6 +513,7 @@ final class IInputMethodManagerGlobalInvoker {
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
@RequiresPermission(Manifest.permission.TEST_INPUT_METHOD)
|
||||
static void setStylusWindowIdleTimeoutForTest(
|
||||
IInputMethodClient client, @DurationMillisLong long timeout) {
|
||||
final IInputMethodManager service = getService();
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package android.view.inputmethod;
|
||||
|
||||
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
|
||||
import static android.Manifest.permission.WRITE_SECURE_SETTINGS;
|
||||
import static android.view.inputmethod.InputConnection.CURSOR_UPDATE_IMMEDIATE;
|
||||
import static android.view.inputmethod.InputConnection.CURSOR_UPDATE_MONITOR;
|
||||
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.DISPLAY_ID;
|
||||
@@ -1525,12 +1523,18 @@ public final class InputMethodManager {
|
||||
/**
|
||||
* Returns {@code true} if currently selected IME supports Stylus handwriting & is enabled for
|
||||
* the given userId.
|
||||
* If the method returns {@code false}, {@link #startStylusHandwriting(View)} shouldn't be
|
||||
* called and Stylus touch should continue as normal touch input.
|
||||
*
|
||||
* <p>If the method returns {@code false}, {@link #startStylusHandwriting(View)} shouldn't be
|
||||
* called and Stylus touch should continue as normal touch input.</p>
|
||||
*
|
||||
* <p>{@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.</p>
|
||||
*
|
||||
* @see #startStylusHandwriting(View)
|
||||
* @param userId user ID to query.
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
|
||||
public boolean isStylusHandwritingAvailableAsUser(@UserIdInt int userId) {
|
||||
final Context fallbackContext = ActivityThread.currentApplication();
|
||||
if (fallbackContext == null) {
|
||||
@@ -1567,14 +1571,17 @@ public final class InputMethodManager {
|
||||
/**
|
||||
* Returns the list of installed input methods for the specified user.
|
||||
*
|
||||
* <p>{@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.</p>
|
||||
*
|
||||
* @param userId user ID to query
|
||||
* @param directBootAwareness {@code true} if caller want to query installed input methods list
|
||||
* on user locked state.
|
||||
* @return {@link List} of {@link InputMethodInfo}.
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(INTERACT_ACROSS_USERS_FULL)
|
||||
@NonNull
|
||||
@RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
|
||||
public List<InputMethodInfo> getInputMethodListAsUser(@UserIdInt int userId,
|
||||
@DirectBootAwareness int directBootAwareness) {
|
||||
return IInputMethodManagerGlobalInvoker.getInputMethodList(userId, directBootAwareness);
|
||||
@@ -1598,11 +1605,14 @@ public final class InputMethodManager {
|
||||
/**
|
||||
* Returns the list of enabled input methods for the specified user.
|
||||
*
|
||||
* <p>{@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.</p>
|
||||
*
|
||||
* @param userId user ID to query
|
||||
* @return {@link List} of {@link InputMethodInfo}.
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(INTERACT_ACROSS_USERS_FULL)
|
||||
@RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
|
||||
public List<InputMethodInfo> getEnabledInputMethodListAsUser(@UserIdInt int userId) {
|
||||
return IInputMethodManagerGlobalInvoker.getEnabledInputMethodList(userId);
|
||||
}
|
||||
@@ -2355,7 +2365,11 @@ public final class InputMethodManager {
|
||||
* Starts an input connection from the served view that gains the window focus.
|
||||
* Note that this method should *NOT* be called inside of {@code mH} lock to prevent start input
|
||||
* background thread may blocked by other methods which already inside {@code mH} lock.
|
||||
*
|
||||
* <p>{@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.</p>
|
||||
*/
|
||||
@RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
|
||||
private boolean startInputInner(@StartInputReason int startInputReason,
|
||||
@Nullable IBinder windowGainingFocus, @StartInputFlags int startInputFlags,
|
||||
@SoftInputModeFlags int softInputMode, int windowFlags) {
|
||||
@@ -2612,8 +2626,8 @@ public final class InputMethodManager {
|
||||
* @param timeout to set in milliseconds. To reset to default, use a value <= zero.
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(Manifest.permission.TEST_INPUT_METHOD)
|
||||
@TestApi
|
||||
@RequiresPermission(Manifest.permission.TEST_INPUT_METHOD)
|
||||
public void setStylusWindowIdleTimeoutForTest(@DurationMillisLong long timeout) {
|
||||
synchronized (mH) {
|
||||
IInputMethodManagerGlobalInvoker.setStylusWindowIdleTimeoutForTest(mClient, timeout);
|
||||
@@ -3092,7 +3106,7 @@ public final class InputMethodManager {
|
||||
*
|
||||
* <p>On Android {@link Build.VERSION_CODES#Q} and later devices, the undocumented behavior that
|
||||
* token can be {@code null} when the caller has
|
||||
* {@link android.Manifest.permission#WRITE_SECURE_SETTINGS} is deprecated. Instead, update
|
||||
* {@link Manifest.permission#WRITE_SECURE_SETTINGS} is deprecated. Instead, update
|
||||
* {@link android.provider.Settings.Secure#DEFAULT_INPUT_METHOD} and
|
||||
* {@link android.provider.Settings.Secure#SELECTED_INPUT_METHOD_SUBTYPE} directly.</p>
|
||||
*
|
||||
@@ -3124,7 +3138,7 @@ public final class InputMethodManager {
|
||||
if (fallbackContext == null) {
|
||||
return;
|
||||
}
|
||||
if (fallbackContext.checkSelfPermission(WRITE_SECURE_SETTINGS)
|
||||
if (fallbackContext.checkSelfPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
return;
|
||||
}
|
||||
@@ -3161,7 +3175,7 @@ public final class InputMethodManager {
|
||||
* from an application or a service which has a token of the currently active input method.
|
||||
*
|
||||
* <p>On Android {@link Build.VERSION_CODES#Q} and later devices, {@code token} cannot be
|
||||
* {@code null} even with {@link android.Manifest.permission#WRITE_SECURE_SETTINGS}. Instead,
|
||||
* {@code null} even with {@link Manifest.permission#WRITE_SECURE_SETTINGS}. Instead,
|
||||
* update {@link android.provider.Settings.Secure#DEFAULT_INPUT_METHOD} and
|
||||
* {@link android.provider.Settings.Secure#SELECTED_INPUT_METHOD_SUBTYPE} directly.</p>
|
||||
*
|
||||
@@ -3443,7 +3457,7 @@ public final class InputMethodManager {
|
||||
* @param displayId The ID of the display where the chooser dialog should be shown.
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(WRITE_SECURE_SETTINGS)
|
||||
@RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
|
||||
public void showInputMethodPickerFromSystem(boolean showAuxiliarySubtypes, int displayId) {
|
||||
final int mode = showAuxiliarySubtypes
|
||||
? SHOW_IM_PICKER_MODE_INCLUDE_AUXILIARY_SUBTYPES
|
||||
@@ -3522,11 +3536,11 @@ public final class InputMethodManager {
|
||||
* {@link InputMethodService#switchInputMethod(String, InputMethodSubtype)}, which
|
||||
* does not require any permission as long as the caller is the current IME.
|
||||
* If the calling process is some privileged app that already has
|
||||
* {@link android.Manifest.permission#WRITE_SECURE_SETTINGS} permission, just
|
||||
* {@link Manifest.permission#WRITE_SECURE_SETTINGS} permission, just
|
||||
* directly update {@link Settings.Secure#SELECTED_INPUT_METHOD_SUBTYPE}.
|
||||
*/
|
||||
@Deprecated
|
||||
@RequiresPermission(WRITE_SECURE_SETTINGS)
|
||||
@RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
|
||||
public boolean setCurrentInputMethodSubtype(InputMethodSubtype subtype) {
|
||||
if (Process.myUid() == Process.SYSTEM_UID) {
|
||||
Log.w(TAG, "System process should not call setCurrentInputMethodSubtype() because "
|
||||
@@ -3543,7 +3557,7 @@ public final class InputMethodManager {
|
||||
if (fallbackContext == null) {
|
||||
return false;
|
||||
}
|
||||
if (fallbackContext.checkSelfPermission(WRITE_SECURE_SETTINGS)
|
||||
if (fallbackContext.checkSelfPermission(Manifest.permission.WRITE_SECURE_SETTINGS)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.view.inputmethod;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.AnyThread;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.RequiresNoPermission;
|
||||
@@ -51,8 +52,8 @@ public class InputMethodManagerGlobal {
|
||||
* @param where where the information is coming from.
|
||||
* @param exceptionHandler an optional {@link RemoteException} handler.
|
||||
*/
|
||||
@RequiresNoPermission
|
||||
@AnyThread
|
||||
@RequiresNoPermission
|
||||
public static void startProtoDump(byte[] protoDump, int source, String where,
|
||||
@Nullable Consumer<RemoteException> exceptionHandler) {
|
||||
IInputMethodManagerGlobalInvoker.startProtoDump(protoDump, source, where, exceptionHandler);
|
||||
@@ -63,8 +64,8 @@ public class InputMethodManagerGlobal {
|
||||
*
|
||||
* @param exceptionHandler an optional {@link RemoteException} handler.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING)
|
||||
@AnyThread
|
||||
@RequiresPermission(Manifest.permission.CONTROL_UI_TRACING)
|
||||
public static void startImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) {
|
||||
IInputMethodManagerGlobalInvoker.startImeTrace(exceptionHandler);
|
||||
}
|
||||
@@ -74,8 +75,8 @@ public class InputMethodManagerGlobal {
|
||||
*
|
||||
* @param exceptionHandler an optional {@link RemoteException} handler.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING)
|
||||
@AnyThread
|
||||
@RequiresPermission(Manifest.permission.CONTROL_UI_TRACING)
|
||||
public static void stopImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) {
|
||||
IInputMethodManagerGlobalInvoker.stopImeTrace(exceptionHandler);
|
||||
}
|
||||
@@ -85,8 +86,8 @@ public class InputMethodManagerGlobal {
|
||||
*
|
||||
* @return The return value of {@link IInputMethodManager#isImeTraceEnabled()}.
|
||||
*/
|
||||
@RequiresNoPermission
|
||||
@AnyThread
|
||||
@RequiresNoPermission
|
||||
public static boolean isImeTraceEnabled() {
|
||||
return IInputMethodManagerGlobalInvoker.isImeTraceEnabled();
|
||||
}
|
||||
@@ -96,8 +97,8 @@ public class InputMethodManagerGlobal {
|
||||
*
|
||||
* @param exceptionHandler an optional {@link RemoteException} handler.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.INTERNAL_SYSTEM_WINDOW)
|
||||
@AnyThread
|
||||
@RequiresPermission(Manifest.permission.INTERNAL_SYSTEM_WINDOW)
|
||||
public static void removeImeSurface(@Nullable Consumer<RemoteException> exceptionHandler) {
|
||||
IInputMethodManagerGlobalInvoker.removeImeSurface(exceptionHandler);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user