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

Commit 2958d174 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Make IMM#getCurrentInputMethod{Info,Subtype} consistent

Since it was originall introduced [1],

  InputMethodManager#getCurrentInputMethodInfo()

has been built by using

  Settings.Secure.DEFAULT_INPUT_METHOD

as the source of truth when determinig the currently selected IME for
the given user.

On the other hand,

  InputMethodManager#getCurrentInputMethodSubtype()

uses

  InputMethodBindingController#getCurrentInputMethodSubtype()

as the source of truth when determing the currently selected subtype
for the given user.

With this CL #getCurrentInputMethodInfo() starts using
InputMethodBindingController as the source of truth as well, because
that's what InputMethodManagerService actually does when establishing
a connection.

The new behavior is guarged with a build time flag.

 [1]: I60a0f67bf7d261d3a4a733adcb8a022ceac6e1db
      2422bcff

Bug: 355034523
Test: presubmit
Flag: build.consistent_get_current_input_method_info
Change-Id: I83716695094a58ee6ceab1a26c6d514c49cb4c15
parent 1054f4ec
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -72,6 +72,17 @@ flag {
    }
}

flag {
    name: "consistent_get_current_input_method_info"
    namespace: "input_method"
    description: "Use BindingController as the source of truth in getCurrentInputMethodInfo"
    bug: "355034523"
    is_fixed_read_only: true
    metadata {
      purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "ime_switcher_revamp"
    is_exported: true
+10 −1
Original line number Diff line number Diff line
@@ -1470,7 +1470,16 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    Manifest.permission.INTERACT_ACROSS_USERS_FULL, null);
        }
        final InputMethodSettings settings = InputMethodSettingsRepository.get(userId);
        return settings.getMethodMap().get(settings.getSelectedInputMethod());
        final String selectedImeId;
        if (Flags.consistentGetCurrentInputMethodInfo()) {
            final var bindingController = getInputMethodBindingController(userId);
            synchronized (ImfLock.class) {
                selectedImeId = bindingController.getSelectedMethodId();
            }
        } else {
            selectedImeId = settings.getSelectedInputMethod();
        }
        return settings.getMethodMap().get(selectedImeId);
    }

    @BinderThread