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

Commit 68f1b78b authored by satok's avatar satok
Browse files

Add an API to get the last used input method subtype

Bug: 4075039

- Voice input requires to know the last used input method subtype.

Change-Id: I603a4fb88a2af5195e52188adfa6585ad80304fa
parent c02c97ef
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22579,6 +22579,7 @@ package android.view.inputmethod {
    method public java.util.List<android.view.inputmethod.InputMethodInfo> getEnabledInputMethodList();
    method public java.util.List<android.view.inputmethod.InputMethodSubtype> getEnabledInputMethodSubtypeList(android.view.inputmethod.InputMethodInfo, boolean);
    method public java.util.List<android.view.inputmethod.InputMethodInfo> getInputMethodList();
    method public android.view.inputmethod.InputMethodSubtype getLastInputMethodSubtype();
    method public java.util.Map<android.view.inputmethod.InputMethodInfo, java.util.List<android.view.inputmethod.InputMethodSubtype>> getShortcutInputMethodsAndSubtypes();
    method public void hideSoftInputFromInputMethod(android.os.IBinder, int);
    method public boolean hideSoftInputFromWindow(android.os.IBinder, int);
+11 −0
Original line number Diff line number Diff line
@@ -1504,6 +1504,17 @@ public final class InputMethodManager {
        }
    }

    public InputMethodSubtype getLastInputMethodSubtype() {
        synchronized (mH) {
            try {
                return mService.getLastInputMethodSubtype();
            } catch (RemoteException e) {
                Log.w(TAG, "IME died: " + mCurId, e);
                return null;
            }
        }
    }

    void doDump(FileDescriptor fd, PrintWriter fout, String[] args) {
        final Printer p = new PrintWriterPrinter(fout);
        p.println("Input method client state for " + this + ":");
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ interface IInputMethodManager {
    List<InputMethodInfo> getEnabledInputMethodList();
    List<InputMethodSubtype> getEnabledInputMethodSubtypeList(in InputMethodInfo imi,
            boolean allowsImplicitlySelectedSubtypes);
    InputMethodSubtype getLastInputMethodSubtype();
    // TODO: We should change the return type from List to List<Parcelable>
    // Currently there is a bug that aidl doesn't accept List<Parcelable>
    List getShortcutInputMethodsAndSubtypes();
+18 −0
Original line number Diff line number Diff line
@@ -1399,6 +1399,24 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        }
    }

    public InputMethodSubtype getLastInputMethodSubtype() {
        synchronized (mMethodMap) {
            final Pair<String, String> lastIme = mSettings.getLastInputMethodAndSubtypeLocked();
            // TODO: Handle the case of the last IME with no subtypes
            if (lastIme == null || TextUtils.isEmpty(lastIme.first)
                    || TextUtils.isEmpty(lastIme.second)) return null;
            final InputMethodInfo lastImi = mMethodMap.get(lastIme.first);
            if (lastImi == null) return null;
            try {
                final int lastSubtypeHash = Integer.valueOf(lastIme.second);
                return lastImi.getSubtypeAt(getSubtypeIdFromHashCode(
                        lastImi, lastSubtypeHash));
            } catch (NumberFormatException e) {
                return null;
            }
        }
    }

    private void setInputMethodWithSubtypeId(IBinder token, String id, int subtypeId) {
        synchronized (mMethodMap) {
            if (token == null) {