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

Commit a259306e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Enable IME to control the source of suggestions" into sc-dev am: 76cdac9f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14124572

Change-Id: Ib4461406e42e6809458fe2e33ad364a3065a0513
parents f0267c02 76cdac9f
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);
    }