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

Commit eeaeee24 authored by Vladimir Komsiyski's avatar Vladimir Komsiyski
Browse files

Fix the "ime set <imeId>" workaround

Taking the deviceId into account.

Bug: 354782333
Change-Id: Ie3a5ebe58d6fca652560ccca6f0cdda235ce8fa6
Fix: 357868762
Test: presubmit, atest VirtualDeviceImeTest
Flag: TEST_ONLY
parent 2ea93073
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -6789,6 +6789,28 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                        out.print(imeId);
                        out.print(" selected for user #");
                        out.println(userId);

                        // Workaround for b/354782333.
                        final InputMethodSettings settings =
                                InputMethodSettingsRepository.get(userId);
                        final var bindingController = getInputMethodBindingController(userId);
                        final int deviceId = bindingController.getDeviceIdToShowIme();
                        final String settingsValue;
                        if (deviceId == DEVICE_ID_DEFAULT) {
                            settingsValue = settings.getSelectedInputMethod();
                        } else {
                            settingsValue = settings.getSelectedDefaultDeviceInputMethod();
                        }
                        if (!TextUtils.equals(settingsValue, imeId)) {
                            Slog.w(TAG, "DEFAULT_INPUT_METHOD=" + settingsValue
                                    + " is not updated. Fixing it up to " + imeId
                                    + " See b/354782333.");
                            if (deviceId == DEVICE_ID_DEFAULT) {
                                settings.putSelectedInputMethod(imeId);
                            } else {
                                settings.putSelectedDefaultDeviceInputMethod(imeId);
                            }
                        }
                    }
                    hasFailed |= failedToSelectUnknownIme;
                }