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

Commit 10e8b939 authored by Satoshi Kataoka's avatar Satoshi Kataoka Committed by satok
Browse files

Fix a crash on a secondary user

Bug: 9054063
Change-Id: I092ab6e0077578d0aca57d2e41dfbc00b46e1ba4
parent b1e37e4a
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -54,6 +54,13 @@ public final class RichInputMethodManager {
        return sInstance;
    }

    // Caveat: This may cause IPC
    public static boolean isInputMethodManagerValidForUserOfThisProcess(final Context context) {
        // Basically called to check whether this IME has been triggered by the current user or not
        return !((InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE)).
                getInputMethodList().isEmpty();
    }

    public static void init(final Context context) {
        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        sInstance.initInternal(context, prefs);
+9 −2
Original line number Diff line number Diff line
@@ -68,8 +68,15 @@ public final class LauncherIconVisibilityManager extends BroadcastReceiver {
        // 1) the package has been re-installed, 2) the device has been booted,
        // 3) a multiuser has been created.
        // There is no good reason to keep the process alive if this IME isn't a current IME.
        final boolean isCurrentImeOfCurrentUser;
        if (RichInputMethodManager.isInputMethodManagerValidForUserOfThisProcess(context)) {
            RichInputMethodManager.init(context);
        if (!SetupActivity.isThisImeCurrent(context)) {
            isCurrentImeOfCurrentUser = SetupActivity.isThisImeCurrent(context);
        } else {
            isCurrentImeOfCurrentUser = false;
        }

        if (!isCurrentImeOfCurrentUser) {
            final int myPid = Process.myPid();
            Log.i(TAG, "Killing my process: pid=" + myPid);
            Process.killProcess(myPid);