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

Commit a3402b18 authored by Antonio Kantek's avatar Antonio Kantek
Browse files

Retrieve the caller's selected method id in start input

For beter user consistency in startInput, this CL also paramaterize
computeCurrentDeviceMethodIdLocked by passing the user id.

This CL represents an internal refactoring and shouldn't introduce any
observable breakage.

Bug: 325515685
Bug: 341558132
Test: atest CtsInputMethodTestCases
Test: atest FrameworksServicesTests
Test: atest --host FrameworksInputMethodSystemServerTestsRavenwood
Test: presubmit

Change-Id: I910ae5641f14464881da6c3916fb6f5d6418c709
parent 75b05a59
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -2049,8 +2049,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.

        // Potentially override the selected input method if the new display belongs to a virtual
        // device with a custom IME.
        String selectedMethodId = getSelectedMethodIdLocked();
        final String deviceMethodId = computeCurrentDeviceMethodIdLocked(selectedMethodId);
        String selectedMethodId = bindingController.getSelectedMethodId();
        final String deviceMethodId = computeCurrentDeviceMethodIdLocked(bindingController.mUserId,
                selectedMethodId);
        if (deviceMethodId == null) {
            mVisibilityStateComputer.getImePolicy().setImeHiddenByDisplayPolicy(true);
        } else if (!Objects.equals(deviceMethodId, selectedMethodId)) {
@@ -2156,7 +2157,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
     * <p>4. Otherwise keep the current imeId.</p>
     */
    @GuardedBy("ImfLock.class")
    private String computeCurrentDeviceMethodIdLocked(String currentMethodId) {
    private String computeCurrentDeviceMethodIdLocked(@UserIdInt int userId,
            String currentMethodId) {
        if (mVdmInternal == null) {
            mVdmInternal = LocalServices.getService(VirtualDeviceManagerInternal.class);
        }
@@ -2164,7 +2166,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            return currentMethodId;
        }

        final InputMethodSettings settings = InputMethodSettingsRepository.get(mCurrentUserId);
        final InputMethodSettings settings = InputMethodSettingsRepository.get(userId);
        final int oldDeviceId = mDeviceIdToShowIme;
        mDeviceIdToShowIme = mVdmInternal.getDeviceIdForDisplayId(mDisplayIdToShowIme);
        if (mDeviceIdToShowIme == DEVICE_ID_DEFAULT) {