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

Commit 76cdac9f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Enable IME to control the source of suggestions" into sc-dev

parents 52614689 7bb9eab0
Loading
Loading
Loading
Loading
+25 −7
Original line number Diff line number Diff line
@@ -450,7 +450,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                        return;
                    }
                    mPendingInlineSuggestionsRequest = inlineSuggestionsRequest;
                    maybeRequestFillLocked();
                    maybeRequestFillFromServiceLocked();
                    viewState.resetState(ViewState.STATE_PENDING_CREATE_INLINE_REQUEST);
                }
            } : null;
@@ -462,7 +462,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            mPendingInlineSuggestionsRequest = inlineRequest;
        }

        void maybeRequestFillLocked() {
        void maybeRequestFillFromServiceLocked() {
            if (mPendingFillRequest == null) {
                return;
            }
@@ -472,10 +472,13 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                    return;
                }

                if (mPendingInlineSuggestionsRequest.isServiceSupported()) {
                    mPendingFillRequest = new FillRequest(mPendingFillRequest.getId(),
                        mPendingFillRequest.getFillContexts(), mPendingFillRequest.getClientState(),
                            mPendingFillRequest.getFillContexts(),
                            mPendingFillRequest.getClientState(),
                            mPendingFillRequest.getFlags(), mPendingInlineSuggestionsRequest);
                }
            }

            mRemoteFillService.onFillRequest(mPendingFillRequest);
            mPendingInlineSuggestionsRequest = null;
@@ -581,7 +584,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                        /*inlineSuggestionsRequest=*/null);

                mPendingFillRequest = request;
                maybeRequestFillLocked();
                maybeRequestFillFromServiceLocked();
            }

            if (mActivityToken != null) {
@@ -3188,6 +3191,17 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            return false;
        }

        final InlineSuggestionsRequest request = inlineSuggestionsRequest.get();
        if (mSessionFlags.mClientSuggestionsEnabled && !request.isClientSupported()
                || !mSessionFlags.mClientSuggestionsEnabled && !request.isServiceSupported()) {
            if (sDebug) {
                Slog.d(TAG, "Inline suggestions not supported for "
                        + (mSessionFlags.mClientSuggestionsEnabled ? "client" : "service")
                        + ". Falling back to dropdown.");
            }
            return false;
        }

        final RemoteInlineSuggestionRenderService remoteRenderService =
                mService.getRemoteInlineSuggestionRenderServiceLocked();
        if (remoteRenderService == null) {
@@ -3196,7 +3210,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        }

        final InlineFillUi.InlineFillUiInfo inlineFillUiInfo =
                new InlineFillUi.InlineFillUiInfo(inlineSuggestionsRequest.get(), focusedId,
                new InlineFillUi.InlineFillUiInfo(request, focusedId,
                        filterText, remoteRenderService, userId, id);
        InlineFillUi inlineFillUi = InlineFillUi.forAutofill(inlineFillUiInfo, response,
                new InlineFillUi.InlineSuggestionUiCallback() {
@@ -3809,6 +3823,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            mContexts = new ArrayList<>(1);
        }

        if (inlineSuggestionsRequest != null && !inlineSuggestionsRequest.isClientSupported()) {
            inlineSuggestionsRequest = null;
        }

        mClientSuggestionsSession.onFillRequest(requestId, inlineSuggestionsRequest, mFlags);
    }