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

Commit 20c0911a authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Clarify userId handling in #onCreateInlineSuggestionsRequest()

This is a mechanical code cleanup before making
AutofillSuggestionsController per-user.

There must be no semantic and observable behavior change.

Bug: 339358344
Test: presubmit
Change-Id: I475cf8b3f949eac95b3d5905186cd3d872b65db5
parent e03efadb
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")