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

Commit e0a48b2f authored by Taran Singh's avatar Taran Singh Committed by Android (Google) Code Review
Browse files

Merge "Introduce IMM#getCurrentInputMethodInfo(userId)"

parents 5e9010e2 2422bcff
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -54830,6 +54830,7 @@ package android.view.inputmethod {
  public final class InputMethodManager {
    method public void dispatchKeyEventFromInputMethod(@Nullable android.view.View, @NonNull android.view.KeyEvent);
    method public void displayCompletions(android.view.View, android.view.inputmethod.CompletionInfo[]);
    method @Nullable public android.view.inputmethod.InputMethodInfo getCurrentInputMethodInfo();
    method @Nullable public android.view.inputmethod.InputMethodSubtype getCurrentInputMethodSubtype();
    method @NonNull public java.util.List<android.view.inputmethod.InputMethodInfo> getEnabledInputMethodList();
    method @NonNull public java.util.List<android.view.inputmethod.InputMethodSubtype> getEnabledInputMethodSubtypeList(@Nullable android.view.inputmethod.InputMethodInfo, boolean);
+8 −0
Original line number Diff line number Diff line
@@ -16633,6 +16633,14 @@ package android.view.displayhash {
}
package android.view.inputmethod {
  public final class InputMethodManager {
    method @Nullable @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public android.view.inputmethod.InputMethodInfo getCurrentInputMethodInfoAsUser(@NonNull android.os.UserHandle);
  }
}
package android.view.translation {
  public final class TranslationCapability implements android.os.Parcelable {
+15 −0
Original line number Diff line number Diff line
@@ -214,6 +214,21 @@ final class IInputMethodManagerGlobalInvoker {
        }
    }

    @AnyThread
    @Nullable
    @RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
    static InputMethodInfo getCurrentInputMethodInfoAsUser(@UserIdInt int userId) {
        final IInputMethodManager service = getService();
        if (service == null) {
            return null;
        }
        try {
            return service.getCurrentInputMethodInfoAsUser(userId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    @AnyThread
    @NonNull
    @RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)
+22 −0
Original line number Diff line number Diff line
@@ -339,6 +339,28 @@ public final class InputMethodInfo implements Parcelable {
        mIsVrOnly = isVrOnly;
    }

    /**
     * @hide
     */
    public InputMethodInfo(InputMethodInfo source) {
        mId = source.mId;
        mSettingsActivityName = source.mSettingsActivityName;
        mIsDefaultResId = source.mIsDefaultResId;
        mIsAuxIme = source.mIsAuxIme;
        mSupportsSwitchingToNextInputMethod = source.mSupportsSwitchingToNextInputMethod;
        mInlineSuggestionsEnabled = source.mInlineSuggestionsEnabled;
        mSupportsInlineSuggestionsWithTouchExploration =
                source.mSupportsInlineSuggestionsWithTouchExploration;
        mSuppressesSpellChecker = source.mSuppressesSpellChecker;
        mShowInInputMethodPicker = source.mShowInInputMethodPicker;
        mIsVrOnly = source.mIsVrOnly;
        mService = source.mService;
        mSubtypes = source.mSubtypes;
        mHandledConfigChanges = source.mHandledConfigChanges;
        mSupportsStylusHandwriting = source.mSupportsStylusHandwriting;
        mForceDefault = source.mForceDefault;
    }

    InputMethodInfo(Parcel source) {
        mId = source.readString();
        mSettingsActivityName = source.readString();
+33 −0
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresFeature;
import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.UiThread;
@@ -1597,6 +1599,37 @@ public final class InputMethodManager {
        return IInputMethodManagerGlobalInvoker.getInputMethodList(userId, directBootAwareness);
    }

    /**
     * Returns the {@link InputMethodInfo} of the currently selected input method (for the process's
     * user).
     *
     * <p>On multi user environment, this API returns a result for the calling process user.</p>
     */
    @Nullable
    public InputMethodInfo getCurrentInputMethodInfo() {
        // We intentionally do not use UserHandle.getCallingUserId() here because for system
        // services InputMethodManagerInternal.getCurrentInputMethodInfoForUser() should be used
        // instead.
        return IInputMethodManagerGlobalInvoker.getCurrentInputMethodInfoAsUser(
                UserHandle.myUserId());
    }

    /**
     * Returns the {@link InputMethodInfo} for currently selected input method for the given user.
     *
     * @param user user to query.
     * @hide
     */
    @RequiresPermission(value = Manifest.permission.INTERACT_ACROSS_USERS_FULL)
    @Nullable
    @SystemApi
    @SuppressLint("UserHandle")
    public InputMethodInfo getCurrentInputMethodInfoAsUser(@NonNull UserHandle user) {
        Objects.requireNonNull(user);
        return IInputMethodManagerGlobalInvoker.getCurrentInputMethodInfoAsUser(
                user.getIdentifier());
    }

    /**
     * Returns the list of enabled input methods.
     *
Loading