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

Commit 6a111456 authored by Yohei Yukawa's avatar Yohei Yukawa Committed by Android (Google) Code Review
Browse files

Merge "Clarify userId handling in #onCreateInlineSuggestionsRequest()" into main

parents 979f5663 20c0911a
Loading
Loading
Loading
Loading
+26 −19
Original line number Diff line number Diff line
@@ -102,11 +102,21 @@ final class AutofillSuggestionsController {
            boolean touchExplorationEnabled) {
        clearPendingInlineSuggestionsRequest();
        mInlineSuggestionsRequestCallback = callback;
        final InputMethodInfo imi = mService.queryInputMethodForCurrentUserLocked(
                mService.getSelectedMethodIdLocked());

        if (userId == mService.getCurrentImeUserIdLocked()
                && imi != null && isInlineSuggestionsEnabled(imi, touchExplorationEnabled)) {
        if (userId != mService.getCurrentImeUserIdLocked()) {
            callback.onInlineSuggestionsUnsupported();
            return;
        }

        // Note that current user ID is guaranteed to be userId.
        final var imeId = mService.getSelectedMethodIdLocked();
        final InputMethodInfo imi = InputMethodSettingsRepository.get(userId).getMethodMap()
                .get(imeId);
        if (imi == null || !isInlineSuggestionsEnabled(imi, touchExplorationEnabled)) {
            callback.onInlineSuggestionsUnsupported();
            return;
        }

        mPendingInlineSuggestionsRequest = new CreateInlineSuggestionsRequest(
                requestInfo, callback, imi.getPackageName());
        if (mService.getCurMethodLocked() != null) {
@@ -120,9 +130,6 @@ final class AutofillSuggestionsController {
                Slog.d(TAG, "IME not connected. Delaying inline suggestions request.");
            }
        }
        } else {
            callback.onInlineSuggestionsUnsupported();
        }
    }

    @GuardedBy("ImfLock.class")