Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 616ffd0f authored by Felix Stern's avatar Felix Stern
Browse files

Adding InputMethodManager @TestApi annotations to use with migrated cts tests

Migrated hostside tests to android.view.inputmethod.cts.installtests.MultiUserTest, that will need to access some more IMM methods to call.

Test: atest android.view.inputmethod.cts.installtests.MultiUserTest
Fix: 283765791
Change-Id: Ib9e4fd68536fca0cd4c42bece51a847fc2828813
parent 69cbc0c6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -3856,11 +3856,14 @@ 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(value=android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional=true) public java.util.List<android.view.inputmethod.InputMethodInfo> getEnabledInputMethodListAsUser(@NonNull android.os.UserHandle);
    method @NonNull @RequiresPermission(value=android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional=true) public java.util.List<android.view.inputmethod.InputMethodSubtype> getEnabledInputMethodSubtypeListAsUser(@NonNull String, boolean, @NonNull android.os.UserHandle);
    method @NonNull @RequiresPermission(value=android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional=true) public java.util.List<android.view.inputmethod.InputMethodInfo> getInputMethodListAsUser(int);
    method public boolean hasActiveInputConnection(@Nullable android.view.View);
    method @RequiresPermission(android.Manifest.permission.TEST_INPUT_METHOD) public boolean hasPendingImeVisibilityRequests();
    method @RequiresPermission(android.Manifest.permission.TEST_INPUT_METHOD) public boolean isCurrentRootView(@NonNull android.view.View);
    method @RequiresPermission(android.Manifest.permission.TEST_INPUT_METHOD) public boolean isInputMethodPickerShown();
    method @NonNull @RequiresPermission(value=android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional=true) public boolean isStylusHandwritingAvailableAsUser(@NonNull android.os.UserHandle);
    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
  }
+23 −13
Original line number Diff line number Diff line
@@ -1571,7 +1571,7 @@ public final class InputMethodManager {
     * @see #startStylusHandwriting(View)
     */
    public boolean isStylusHandwritingAvailable() {
        return isStylusHandwritingAvailableAsUser(UserHandle.myUserId());
        return isStylusHandwritingAvailableAsUser(UserHandle.of(UserHandle.myUserId()));
    }

    /**
@@ -1582,14 +1582,17 @@ public final class InputMethodManager {
     * 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>
     * {@code user} is different from the user of the current process.</p>
     *
     * @see #startStylusHandwriting(View)
     * @param userId user ID to query.
     * @param user UserHandle to query.
     * @hide
     */
    @NonNull
    @RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
    public boolean isStylusHandwritingAvailableAsUser(@UserIdInt int userId) {
    @TestApi
    @SuppressLint("UserHandle")
    public boolean isStylusHandwritingAvailableAsUser(@NonNull UserHandle user) {
        final Context fallbackContext = ActivityThread.currentApplication();
        if (fallbackContext == null) {
            return false;
@@ -1606,7 +1609,7 @@ public final class InputMethodManager {
                    }
                };
            }
            isAvailable = mStylusHandwritingAvailableCache.query(userId);
            isAvailable = mStylusHandwritingAvailableCache.query(user.getIdentifier());
        }
        return isAvailable;
    }
@@ -1698,16 +1701,19 @@ 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>
     * {@code user} is different from the user of the current process.</p>
     *
     * @param userId user ID to query
     * @param user UserHandle to query
     * @return {@link List} of {@link InputMethodInfo}.
     * @see #getEnabledInputMethodSubtypeListAsUser(String, boolean, int)
     * @see #getEnabledInputMethodSubtypeListAsUser(String, boolean, UserHandle)
     * @hide
     */
    @NonNull
    @RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
    public List<InputMethodInfo> getEnabledInputMethodListAsUser(@UserIdInt int userId) {
        return IInputMethodManagerGlobalInvoker.getEnabledInputMethodList(userId);
    @TestApi
    @SuppressLint("UserHandle")
    public List<InputMethodInfo> getEnabledInputMethodListAsUser(@NonNull UserHandle user) {
        return IInputMethodManagerGlobalInvoker.getEnabledInputMethodList(user.getIdentifier());
    }

    /**
@@ -1736,7 +1742,7 @@ public final class InputMethodManager {
     *
     * @param imeId IME ID to be queried about.
     * @param allowsImplicitlyEnabledSubtypes {@code true} to include implicitly enabled subtypes.
     * @param userId user ID to be queried about.
     * @param user UserHandle to be queried about.
     *               {@link Manifest.permission#INTERACT_ACROSS_USERS_FULL} is required if this is
     *               different from the calling process user ID.
     * @return {@link List} of {@link InputMethodSubtype}.
@@ -1745,10 +1751,14 @@ public final class InputMethodManager {
     */
    @NonNull
    @RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
    @TestApi
    @SuppressLint("UserHandle")
    public List<InputMethodSubtype> getEnabledInputMethodSubtypeListAsUser(
            @NonNull String imeId, boolean allowsImplicitlyEnabledSubtypes, @UserIdInt int userId) {
            @NonNull String imeId, boolean allowsImplicitlyEnabledSubtypes,
            @NonNull UserHandle user) {
        return IInputMethodManagerGlobalInvoker.getEnabledInputMethodSubtypeList(
                Objects.requireNonNull(imeId), allowsImplicitlyEnabledSubtypes, userId);
                Objects.requireNonNull(imeId), allowsImplicitlyEnabledSubtypes,
                user.getIdentifier());
    }

    /**
+1 −2
Original line number Diff line number Diff line
@@ -13202,9 +13202,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        if (mTextOperationUser == null) {
            return super.isStylusHandwritingAvailable();
        }
        final int userId = mTextOperationUser.getIdentifier();
        final InputMethodManager imm = getInputMethodManager();
        return imm.isStylusHandwritingAvailableAsUser(userId);
        return imm.isStylusHandwritingAvailableAsUser(mTextOperationUser);
    }
    @Nullable
+2 −1
Original line number Diff line number Diff line
@@ -265,7 +265,8 @@ public class KeyguardPasswordViewController
    private boolean hasMultipleEnabledIMEsOrSubtypes(InputMethodManager imm,
            final boolean shouldIncludeAuxiliarySubtypes) {
        final List<InputMethodInfo> enabledImis =
                imm.getEnabledInputMethodListAsUser(KeyguardUpdateMonitor.getCurrentUser());
                imm.getEnabledInputMethodListAsUser(
                        UserHandle.of(KeyguardUpdateMonitor.getCurrentUser()));

        // Number of the filtered IMEs
        int filteredImisCount = 0;