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

Commit ce5c8023 authored by Adam He's avatar Adam He
Browse files

Don't start new inline autofill flow if one started already.

Also fixes missing lock in regular autofill inline callback in
getRendererInfo().

Fixes: 154150263
Test: atest CtsAutofillServiceTestCases
Change-Id: I475e4e8f23f41b51702a4d3dd819777938694447
parent c576f56c
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -325,7 +325,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        @GuardedBy("mLock")
        private CountDownLatch mCountDownLatch = new CountDownLatch(0);

        @Nullable Consumer<InlineSuggestionsRequest> newAutofillRequestLocked(
        @Nullable Consumer<InlineSuggestionsRequest> newAutofillRequestLocked(ViewState viewState,
                boolean isInlineRequest) {
            mCountDownLatch = new CountDownLatch(isInlineRequest ? 2 : 1);
            mPendingFillRequest = null;
@@ -338,6 +338,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                    mPendingInlineSuggestionsRequest = inlineSuggestionsRequest;
                    mCountDownLatch.countDown();
                    maybeRequestFillLocked();
                    viewState.resetState(ViewState.STATE_PENDING_CREATE_INLINE_REQUEST);
                }
            } : null;
        }
@@ -716,18 +717,23 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                mService.getRemoteInlineSuggestionRenderServiceLocked();
        if (isInlineSuggestionsEnabledByAutofillProviderLocked() && remoteRenderService != null) {
            Consumer<InlineSuggestionsRequest> inlineSuggestionsRequestConsumer =
                    mAssistReceiver.newAutofillRequestLocked(/*isInlineRequest=*/ true);
                    mAssistReceiver.newAutofillRequestLocked(viewState,
                            /*isInlineRequest=*/ true);
            if (inlineSuggestionsRequestConsumer != null) {
                final AutofillId focusedId = mCurrentViewId;
                remoteRenderService.getInlineSuggestionsRendererInfo(
                        new RemoteCallback((extras) -> {
                            synchronized (mLock) {
                                mInlineSessionController.onCreateInlineSuggestionsRequestLocked(
                                        focusedId, inlineSuggestionsRequestConsumer, extras);
                            }
                ));
                        }, mHandler)
                );
                viewState.setState(ViewState.STATE_PENDING_CREATE_INLINE_REQUEST);
            }
        } else {
            mAssistReceiver.newAutofillRequestLocked(/*isInlineRequest=*/ false);
            mAssistReceiver.newAutofillRequestLocked(viewState,
                    /*isInlineRequest=*/ false);
        }

        // Now request the assist structure data.
@@ -2368,7 +2374,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
     */
    @GuardedBy("mLock")
    private boolean shouldStartNewPartitionLocked(@NonNull AutofillId id) {
        if (mResponses == null) {
        final ViewState currentView = mViewStates.get(id);
        if (mResponses == null && currentView != null
                && (currentView.getState() & ViewState.STATE_PENDING_CREATE_INLINE_REQUEST) == 0) {
            return true;
        }

+2 −0
Original line number Diff line number Diff line
@@ -80,6 +80,8 @@ final class ViewState {
    public static final int STATE_CHAR_REMOVED = 0x4000;
    /** Showing inline suggestions is not allowed for this View. */
    public static final int STATE_INLINE_DISABLED = 0x8000;
    /** The View is waiting for an inline suggestions request from IME.*/
    public static final int STATE_PENDING_CREATE_INLINE_REQUEST = 0x10000;

    public final AutofillId id;