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

Commit 2d63f4a2 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Inline InputMethodSettings#isSubtypeSelected()

This CL simplifies

  InputMethodManagerService#getCurrentInputMethodSubtypeLocked()

a bit by inlining

  InputMethodSettings#isSubtypeSelected()

without changing any observable behavior.

Bug: 346658341
Test: presubmit
Flag: EXEMPT refactor
Change-Id: Id2633171bc56591e70054c5ffe8dc5f0dac29bb5
parent b5532377
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -5503,17 +5503,19 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
     */
    @GuardedBy("ImfLock.class")
    InputMethodSubtype getCurrentInputMethodSubtypeLocked() {
        String selectedMethodId = getSelectedMethodIdLocked();
        final int userId = mCurrentUserId;
        final var selectedMethodId = getInputMethodBindingController(userId).getSelectedMethodId();
        if (selectedMethodId == null) {
            return null;
        }
        final InputMethodSettings settings = InputMethodSettingsRepository.get(mCurrentUserId);
        final boolean subtypeIsSelected = settings.isSubtypeSelected();
        final InputMethodSettings settings = InputMethodSettingsRepository.get(userId);
        final InputMethodInfo imi = settings.getMethodMap().get(selectedMethodId);
        if (imi == null || imi.getSubtypeCount() == 0) {
            return null;
        }
        if (!subtypeIsSelected || mCurrentSubtype == null
        final int currentSubtypeHashCode = SecureSettingsWrapper.getInt(
                Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE, NOT_A_SUBTYPE_ID, userId);
        if (currentSubtypeHashCode == NOT_A_SUBTYPE_ID || mCurrentSubtype == null
                || !SubtypeUtils.isValidSubtypeId(imi, mCurrentSubtype.hashCode())) {
            int subtypeId = settings.getSelectedInputMethodSubtypeId(selectedMethodId);
            if (subtypeId == NOT_A_SUBTYPE_ID) {
@@ -5527,8 +5529,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                if (explicitlyOrImplicitlyEnabledSubtypes.size() == 1) {
                    mCurrentSubtype = explicitlyOrImplicitlyEnabledSubtypes.get(0);
                } else if (explicitlyOrImplicitlyEnabledSubtypes.size() > 1) {
                    final String locale = SystemLocaleWrapper.get(settings.getUserId())
                            .get(0).toString();
                    final String locale = SystemLocaleWrapper.get(userId).get(0).toString();
                    mCurrentSubtype = SubtypeUtils.findLastResortApplicableSubtype(
                            explicitlyOrImplicitlyEnabledSubtypes,
                            SubtypeUtils.SUBTYPE_MODE_KEYBOARD, locale, true);
+0 −4
Original line number Diff line number Diff line
@@ -528,10 +528,6 @@ final class InputMethodSettings {
        return imi;
    }

    boolean isSubtypeSelected() {
        return getSelectedInputMethodSubtypeHashCode() != NOT_A_SUBTYPE_ID;
    }

    private int getSelectedInputMethodSubtypeHashCode() {
        return getInt(Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE,
                NOT_A_SUBTYPE_ID);