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

Commit 67ddf9cb authored by satok's avatar satok
Browse files

Add a function to get enabledInputMethodAndSubtype

Change-Id: Ie97635343249aa63e33028c2843cab103125ca92
parent 4f3c25f3
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -219268,6 +219268,19 @@
 visibility="public"
>
</method>
<method name="getEnabledInputMethodSubtypeList"
 return="java.util.List&lt;android.view.inputmethod.InputMethodSubtype&gt;"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="imi" type="android.view.inputmethod.InputMethodInfo">
</parameter>
</method>
<method name="getInputMethodList"
 return="java.util.List&lt;android.view.inputmethod.InputMethodInfo&gt;"
 abstract="false"
@@ -246844,7 +246857,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="t" type="T">
<parameter name="arg0" type="T">
</parameter>
</method>
</interface>
+9 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.ServiceManager;
import android.util.Log;
import android.util.Pair;
import android.util.PrintWriterPrinter;
import android.util.Printer;
import android.view.KeyEvent;
@@ -502,6 +503,14 @@ public final class InputMethodManager {
        }
    }

    public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(InputMethodInfo imi) {
        try {
            return mService.getEnabledInputMethodSubtypeList(imi);
        } catch (RemoteException e) {
            throw new RuntimeException(e);
        }
    }

    public void showStatusIcon(IBinder imeToken, String packageName, int iconId) {
        try {
            mService.updateStatusIcon(imeToken, packageName, iconId);
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ import com.android.internal.view.IInputMethodClient;
interface IInputMethodManager {
    List<InputMethodInfo> getInputMethodList();
    List<InputMethodInfo> getEnabledInputMethodList();
    
    List<InputMethodSubtype> getEnabledInputMethodSubtypeList(in InputMethodInfo imi);
    void addClient(in IInputMethodClient client,
            in IInputContext inputContext, int uid, int pid);
    void removeClient(in IInputMethodClient client);
+33 −4
Original line number Diff line number Diff line
@@ -555,6 +555,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        }
    }

    public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(InputMethodInfo imi) {
        synchronized (mMethodMap) {
            return mSettings.getEnabledInputMethodSubtypeListLocked(imi);
        }
    }

    public void addClient(IInputMethodClient client,
            IInputContext inputContext, int uid, int pid) {
        synchronized (mMethodMap) {
@@ -1607,7 +1613,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub

        synchronized (mMethodMap) {
            final List<Pair<InputMethodInfo, ArrayList<String>>> immis =
                    mSettings.getEnabledInputMethodAndSubtypeListLocked();
                    mSettings.getEnabledInputMethodAndSubtypeHashCodeListLocked();
            ArrayList<Integer> subtypeIds = new ArrayList<Integer>();

            if (immis == null || immis.size() == 0) {
@@ -2026,11 +2032,34 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        }

        public List<Pair<InputMethodInfo, ArrayList<String>>>
                getEnabledInputMethodAndSubtypeListLocked() {
            return createEnabledInputMethodAndSubtypeListLocked(
                getEnabledInputMethodAndSubtypeHashCodeListLocked() {
            return createEnabledInputMethodAndSubtypeHashCodeListLocked(
                    getEnabledInputMethodsAndSubtypeListLocked());
        }

        public List<InputMethodSubtype> getEnabledInputMethodSubtypeListLocked(
                InputMethodInfo imi) {
            List<Pair<String, ArrayList<String>>> imsList =
                    getEnabledInputMethodsAndSubtypeListLocked();
            ArrayList<InputMethodSubtype> enabledSubtypes =
                    new ArrayList<InputMethodSubtype>();
            for (Pair<String, ArrayList<String>> imsPair : imsList) {
                InputMethodInfo info = mMethodMap.get(imsPair.first);
                if (info != null && info.getId().equals(imi.getId())) {
                    ArrayList<InputMethodSubtype> subtypes = info.getSubtypes();
                    for (InputMethodSubtype ims: subtypes) {
                        for (String s: imsPair.second) {
                            if (String.valueOf(ims.hashCode()).equals(s)) {
                                enabledSubtypes.add(ims);
                            }
                        }
                    }
                    break;
                }
            }
            return enabledSubtypes;
        }

        // At the initial boot, the settings for input methods are not set,
        // so we need to enable IME in that case.
        public void enableAllIMEsIfThereIsNoEnabledIME() {
@@ -2128,7 +2157,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        }

        private List<Pair<InputMethodInfo, ArrayList<String>>>
                createEnabledInputMethodAndSubtypeListLocked(
                createEnabledInputMethodAndSubtypeHashCodeListLocked(
                        List<Pair<String, ArrayList<String>>> imsList) {
            final ArrayList<Pair<InputMethodInfo, ArrayList<String>>> res
                    = new ArrayList<Pair<InputMethodInfo, ArrayList<String>>>();