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

Commit b0b5b174 authored by satok's avatar satok Committed by Android (Google) Code Review
Browse files

Merge "Add a function to switch back to the last used IME"

parents c930e1f7 735cf38b
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -219363,6 +219363,19 @@
<parameter name="iconId" type="int">
</parameter>
</method>
<method name="switchToLastInputMethod"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="imeToken" type="android.os.IBinder">
</parameter>
</method>
<method name="toggleSoftInput"
 return="void"
 abstract="false"
+11 −0
Original line number Diff line number Diff line
@@ -1432,6 +1432,17 @@ public final class InputMethodManager {
        }
    }

    public boolean switchToLastInputMethod(IBinder imeToken) {
        synchronized (mH) {
            try {
                return mService.switchToLastInputMethod(imeToken);
            } catch (RemoteException e) {
                Log.w(TAG, "IME died: " + mCurId, e);
                return false;
            }
        }
    }

    void doDump(FileDescriptor fd, PrintWriter fout, String[] args) {
        final Printer p = new PrintWriterPrinter(fout);
        p.println("Input method client state for " + this + ":");
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ interface IInputMethodManager {
    void updateStatusIcon(in IBinder token, String packageName, int iconId);
    void setIMEButtonVisible(in IBinder token, boolean visible);
    InputMethodSubtype getCurrentInputMethodSubtype();
    boolean switchToLastInputMethod(in IBinder token);
    
    boolean setInputMethodEnabled(String id, boolean enabled);
}
+15 −0
Original line number Diff line number Diff line
@@ -1279,6 +1279,21 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        setInputMethodWithSubtype(token, id, NOT_A_SUBTYPE_ID);
    }

    public boolean switchToLastInputMethod(IBinder token) {
        synchronized (mMethodMap) {
            Pair<String, String> lastIme = mSettings.getLastInputMethodAndSubtypeLocked();
            if (lastIme != null) {
                InputMethodInfo imi = mMethodMap.get(lastIme.first);
                if (imi != null) {
                    setInputMethodWithSubtype(token, lastIme.first, getSubtypeIdFromHashCode(
                            imi, Integer.valueOf(lastIme.second)));
                    return true;
                }
            }
            return false;
        }
    }

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