From 6be74a57ab8e9867d2bd2e7988c19634e42fd3b2 Mon Sep 17 00:00:00 2001 From: Adam He Date: Mon, 14 Sep 2020 18:11:25 -0700 Subject: [PATCH] Refactor and simplify InlineFillUi and InlineSuggestionFactory. * Create InlineFillUiInfo to encapsulate the numberous arguments passed into the factory. * Combine CreateInlineSuggestions API for regular and augmented autofill. Bug: 162357598 Test: atest CtsAutoFillServiceTestCases Change-Id: I64d5ca2aec510b9e04ebc3c499ca0029dc96925c --- .../RemoteAugmentedAutofillService.java | 23 ++- .../com/android/server/autofill/Session.java | 36 +++- .../server/autofill/ui/InlineFillUi.java | 114 +++++++---- .../autofill/ui/InlineSuggestionFactory.java | 189 +++++------------- .../RemoteInlineSuggestionViewConnector.java | 22 +- 5 files changed, 180 insertions(+), 204 deletions(-) diff --git a/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java b/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java index 533bbe68e274..92b8608f4f6c 100644 --- a/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java +++ b/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java @@ -261,9 +261,13 @@ final class RemoteAugmentedAutofillService focusedValue != null && focusedValue.isText() ? focusedValue.getTextValue().toString() : null; + final InlineFillUi.InlineFillUiInfo inlineFillUiInfo = + new InlineFillUi.InlineFillUiInfo(request, focusedId, filterText, + remoteRenderService, userId, sessionId); + final InlineFillUi inlineFillUi = InlineFillUi.forAugmentedAutofill( - request, inlineSuggestionsData, focusedId, filterText, + inlineFillUiInfo, inlineSuggestionsData, new InlineFillUi.InlineSuggestionUiCallback() { @Override public void autofill(Dataset dataset, int datasetIndex) { @@ -305,15 +309,24 @@ final class RemoteAugmentedAutofillService } @Override - public void startIntentSender(IntentSender intentSender, - Intent intent) { + public void authenticate(int requestId, int datasetIndex) { + Slog.e(TAG, "authenticate not implemented for augmented autofill"); + } + + @Override + public void startIntentSender(IntentSender intentSender) { try { - client.startIntentSender(intentSender, intent); + client.startIntentSender(intentSender, new Intent()); } catch (RemoteException e) { Slog.w(TAG, "RemoteException starting intent sender"); } } - }, onErrorCallback, remoteRenderService, userId, sessionId); + + @Override + public void onError() { + onErrorCallback.run(); + } + }); if (inlineSuggestionsCallback.apply(inlineFillUi)) { mCallbacks.logAugmentedAutofillShown(sessionId, clientState); diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index 1970b5774bbb..4d2e4f6ee486 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -3008,14 +3008,36 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return false; } - InlineFillUi inlineFillUi = InlineFillUi.forAutofill( - inlineSuggestionsRequest.get(), response, focusedId, filterText, - /*uiCallback*/this, /*onErrorCallback*/ () -> { - synchronized (mLock) { - mInlineSessionController.setInlineFillUiLocked( - InlineFillUi.emptyUi(focusedId)); + final InlineFillUi.InlineFillUiInfo inlineFillUiInfo = + new InlineFillUi.InlineFillUiInfo(inlineSuggestionsRequest.get(), focusedId, + filterText, remoteRenderService, userId, id); + InlineFillUi inlineFillUi = InlineFillUi.forAutofill(inlineFillUiInfo, response, + new InlineFillUi.InlineSuggestionUiCallback() { + @Override + public void autofill(@NonNull Dataset dataset, int datasetIndex) { + fill(response.getRequestId(), datasetIndex, dataset); } - }, remoteRenderService, userId, id); + + @Override + public void authenticate(int requestId, int datasetIndex) { + Session.this.authenticate(response.getRequestId(), datasetIndex, + response.getAuthentication(), response.getClientState(), + /* authenticateInline= */ true); + } + + @Override + public void startIntentSender(@NonNull IntentSender intentSender) { + Session.this.startIntentSender(intentSender, new Intent()); + } + + @Override + public void onError() { + synchronized (mLock) { + mInlineSessionController.setInlineFillUiLocked( + InlineFillUi.emptyUi(focusedId)); + } + } + }); return mInlineSessionController.setInlineFillUiLocked(inlineFillUi); } diff --git a/services/autofill/java/com/android/server/autofill/ui/InlineFillUi.java b/services/autofill/java/com/android/server/autofill/ui/InlineFillUi.java index 25e9d5c90764..ff175904fb61 100644 --- a/services/autofill/java/com/android/server/autofill/ui/InlineFillUi.java +++ b/services/autofill/java/com/android/server/autofill/ui/InlineFillUi.java @@ -20,7 +20,7 @@ import static com.android.server.autofill.Helper.sVerbose; import android.annotation.NonNull; import android.annotation.Nullable; -import android.content.Intent; +import android.annotation.UserIdInt; import android.content.IntentSender; import android.service.autofill.Dataset; import android.service.autofill.FillResponse; @@ -32,6 +32,7 @@ import android.util.SparseArray; import android.view.autofill.AutofillId; import android.view.autofill.AutofillValue; import android.view.inputmethod.InlineSuggestion; +import android.view.inputmethod.InlineSuggestionInfo; import android.view.inputmethod.InlineSuggestionsRequest; import android.view.inputmethod.InlineSuggestionsResponse; @@ -93,59 +94,72 @@ public final class InlineFillUi { */ @NonNull public static InlineFillUi emptyUi(@NonNull AutofillId autofillId) { - return new InlineFillUi(autofillId, new SparseArray<>(), null); + return new InlineFillUi(autofillId); + } + + /** + * Encapsulates various arguments used by {@link #forAutofill} and {@link #forAugmentedAutofill} + */ + public static class InlineFillUiInfo { + + public int mUserId; + public int mSessionId; + public InlineSuggestionsRequest mInlineRequest; + public AutofillId mFocusedId; + public String mFilterText; + public RemoteInlineSuggestionRenderService mRemoteRenderService; + + public InlineFillUiInfo(@NonNull InlineSuggestionsRequest inlineRequest, + @NonNull AutofillId focusedId, @NonNull String filterText, + @NonNull RemoteInlineSuggestionRenderService remoteRenderService, + @UserIdInt int userId, int sessionId) { + mUserId = userId; + mSessionId = sessionId; + mInlineRequest = inlineRequest; + mFocusedId = focusedId; + mFilterText = filterText; + mRemoteRenderService = remoteRenderService; + } } /** * Returns an inline autofill UI for a field based on an Autofilll response. */ @NonNull - public static InlineFillUi forAutofill(@NonNull InlineSuggestionsRequest request, + public static InlineFillUi forAutofill(@NonNull InlineFillUiInfo inlineFillUiInfo, @NonNull FillResponse response, - @NonNull AutofillId focusedViewId, @Nullable String filterText, - @NonNull AutoFillUI.AutoFillUiCallback uiCallback, - @NonNull Runnable onErrorCallback, - @Nullable RemoteInlineSuggestionRenderService remoteRenderService, - int userId, int sessionId) { - - if (InlineSuggestionFactory.responseNeedAuthentication(response)) { + @NonNull InlineSuggestionUiCallback uiCallback) { + if (response.getAuthentication() != null && response.getInlinePresentation() != null) { InlineSuggestion inlineAuthentication = - InlineSuggestionFactory.createInlineAuthentication(request, response, - uiCallback, onErrorCallback, remoteRenderService, userId, sessionId); - return new InlineFillUi(focusedViewId, inlineAuthentication, filterText); + InlineSuggestionFactory.createInlineAuthentication(inlineFillUiInfo, response, + uiCallback); + return new InlineFillUi(inlineFillUiInfo, inlineAuthentication); } else if (response.getDatasets() != null) { SparseArray> inlineSuggestions = - InlineSuggestionFactory.createAutofillInlineSuggestions(request, - response.getRequestId(), - response.getDatasets(), focusedViewId, uiCallback, onErrorCallback, - remoteRenderService, userId, sessionId); - return new InlineFillUi(focusedViewId, inlineSuggestions, filterText); + InlineSuggestionFactory.createInlineSuggestions(inlineFillUiInfo, + InlineSuggestionInfo.SOURCE_AUTOFILL, response.getDatasets(), + uiCallback); + return new InlineFillUi(inlineFillUiInfo, inlineSuggestions); } - return new InlineFillUi(focusedViewId, new SparseArray<>(), filterText); + return new InlineFillUi(inlineFillUiInfo, new SparseArray<>()); } /** * Returns an inline autofill UI for a field based on an Autofilll response. */ @NonNull - public static InlineFillUi forAugmentedAutofill(@NonNull InlineSuggestionsRequest request, + public static InlineFillUi forAugmentedAutofill(@NonNull InlineFillUiInfo inlineFillUiInfo, @NonNull List datasets, - @NonNull AutofillId focusedViewId, @Nullable String filterText, - @NonNull InlineSuggestionUiCallback uiCallback, - @NonNull Runnable onErrorCallback, - @Nullable RemoteInlineSuggestionRenderService remoteRenderService, - int userId, int sessionId) { + @NonNull InlineSuggestionUiCallback uiCallback) { SparseArray> inlineSuggestions = - InlineSuggestionFactory.createAugmentedAutofillInlineSuggestions(request, datasets, - focusedViewId, - uiCallback, onErrorCallback, remoteRenderService, userId, sessionId); - return new InlineFillUi(focusedViewId, inlineSuggestions, filterText); + InlineSuggestionFactory.createInlineSuggestions(inlineFillUiInfo, + InlineSuggestionInfo.SOURCE_PLATFORM, datasets, uiCallback); + return new InlineFillUi(inlineFillUiInfo, inlineSuggestions); } - InlineFillUi(@NonNull AutofillId autofillId, - @NonNull SparseArray> inlineSuggestions, - @Nullable String filterText) { - mAutofillId = autofillId; + private InlineFillUi(@Nullable InlineFillUiInfo inlineFillUiInfo, + @NonNull SparseArray> inlineSuggestions) { + mAutofillId = inlineFillUiInfo.mFocusedId; int size = inlineSuggestions.size(); mDatasets = new ArrayList<>(size); mInlineSuggestions = new ArrayList<>(size); @@ -154,16 +168,26 @@ public final class InlineFillUi { mDatasets.add(value.first); mInlineSuggestions.add(value.second); } - mFilterText = filterText; + mFilterText = inlineFillUiInfo.mFilterText; } - InlineFillUi(@NonNull AutofillId autofillId, InlineSuggestion inlineSuggestion, - @Nullable String filterText) { - mAutofillId = autofillId; + private InlineFillUi(@NonNull InlineFillUiInfo inlineFillUiInfo, + @NonNull InlineSuggestion inlineSuggestion) { + mAutofillId = inlineFillUiInfo.mFocusedId; mDatasets = null; mInlineSuggestions = new ArrayList<>(); mInlineSuggestions.add(inlineSuggestion); - mFilterText = filterText; + mFilterText = inlineFillUiInfo.mFilterText; + } + + /** + * Only used for constructing an empty InlineFillUi with {@link #emptyUi} + */ + private InlineFillUi(@NonNull AutofillId focusedId) { + mAutofillId = focusedId; + mDatasets = new ArrayList<>(0); + mInlineSuggestions = new ArrayList<>(0); + mFilterText = null; } @NonNull @@ -294,10 +318,22 @@ public final class InlineFillUi { */ void autofill(@NonNull Dataset dataset, int datasetIndex); + /** + * Callback to authenticate a dataset. + * + *

Only implemented by regular autofill for now.

+ */ + void authenticate(int requestId, int datasetIndex); + /** * Callback to start Intent in client app. */ - void startIntentSender(@NonNull IntentSender intentSender, @NonNull Intent intent); + void startIntentSender(@NonNull IntentSender intentSender); + + /** + * Callback on errors. + */ + void onError(); } /** diff --git a/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java b/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java index 8fcb8aa9393c..b15d07b0f1a9 100644 --- a/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java +++ b/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java @@ -20,184 +20,98 @@ import static com.android.server.autofill.Helper.sDebug; import android.annotation.NonNull; import android.annotation.Nullable; -import android.content.Intent; -import android.content.IntentSender; -import android.os.IBinder; import android.service.autofill.Dataset; import android.service.autofill.FillResponse; import android.service.autofill.InlinePresentation; import android.util.Pair; import android.util.Slog; import android.util.SparseArray; -import android.view.autofill.AutofillId; import android.view.autofill.AutofillManager; import android.view.inputmethod.InlineSuggestion; import android.view.inputmethod.InlineSuggestionInfo; import android.view.inputmethod.InlineSuggestionsRequest; -import android.view.inputmethod.InlineSuggestionsResponse; import android.widget.inline.InlinePresentationSpec; import com.android.internal.view.inline.IInlineContentProvider; -import com.android.server.autofill.RemoteInlineSuggestionRenderService; import java.util.List; -import java.util.function.BiConsumer; -import java.util.function.Consumer; final class InlineSuggestionFactory { private static final String TAG = "InlineSuggestionFactory"; - public static boolean responseNeedAuthentication(@NonNull FillResponse response) { - return response.getAuthentication() != null && response.getInlinePresentation() != null; - } - public static InlineSuggestion createInlineAuthentication( - @NonNull InlineSuggestionsRequest request, @NonNull FillResponse response, - @NonNull AutoFillUI.AutoFillUiCallback client, @NonNull Runnable onErrorCallback, - @Nullable RemoteInlineSuggestionRenderService remoteRenderService, int userId, - int sessionId) { - final BiConsumer onClickFactory = (dataset, datasetIndex) -> { - client.authenticate(response.getRequestId(), - datasetIndex, response.getAuthentication(), response.getClientState(), - /* authenticateInline= */ true); - }; - final Consumer intentSenderConsumer = (intentSender) -> - client.startIntentSender(intentSender, new Intent()); + @NonNull InlineFillUi.InlineFillUiInfo inlineFillUiInfo, @NonNull FillResponse response, + @NonNull InlineFillUi.InlineSuggestionUiCallback uiCallback) { InlinePresentation inlineAuthentication = response.getInlinePresentation(); - return createInlineAuthSuggestion( - mergedInlinePresentation(request, 0, inlineAuthentication), - remoteRenderService, userId, sessionId, - onClickFactory, onErrorCallback, intentSenderConsumer, - request.getHostInputToken(), request.getHostDisplayId()); + final int requestId = response.getRequestId(); + + return createInlineSuggestion(inlineFillUiInfo, InlineSuggestionInfo.SOURCE_AUTOFILL, + InlineSuggestionInfo.TYPE_ACTION, () -> uiCallback.authenticate(requestId, + AutofillManager.AUTHENTICATION_ID_DATASET_ID_UNDEFINED), + mergedInlinePresentation(inlineFillUiInfo.mInlineRequest, 0, inlineAuthentication), + uiCallback); } /** - * Creates an {@link InlineSuggestionsResponse} with the {@code datasets} provided by the - * autofill service, potentially filtering the datasets. + * Creates an array of {@link InlineSuggestion}s with the {@code datasets} provided by either + * regular/augmented autofill services. */ @Nullable - public static SparseArray> createAutofillInlineSuggestions( - @NonNull InlineSuggestionsRequest request, int requestId, + public static SparseArray> createInlineSuggestions( + @NonNull InlineFillUi.InlineFillUiInfo inlineFillUiInfo, + @NonNull @InlineSuggestionInfo.Source String suggestionSource, @NonNull List datasets, - @NonNull AutofillId autofillId, - @NonNull AutoFillUI.AutoFillUiCallback client, @NonNull Runnable onErrorCallback, - @Nullable RemoteInlineSuggestionRenderService remoteRenderService, - int userId, int sessionId) { - if (sDebug) Slog.d(TAG, "createInlineSuggestionsResponse called"); - final Consumer intentSenderConsumer = (intentSender) -> - client.startIntentSender(intentSender, new Intent()); - final BiConsumer onClickFactory = (dataset, datasetIndex) -> { - client.fill(requestId, datasetIndex, dataset); - }; + @NonNull InlineFillUi.InlineSuggestionUiCallback uiCallback) { + if (sDebug) Slog.d(TAG, "createInlineSuggestions(source=" + suggestionSource + ") called"); - return createInlineSuggestionsInternal(/* isAugmented= */ false, request, - datasets, autofillId, - onErrorCallback, onClickFactory, intentSenderConsumer, remoteRenderService, userId, - sessionId); - } - - /** - * Creates an {@link InlineSuggestionsResponse} with the {@code datasets} provided by augmented - * autofill service. - */ - @Nullable - public static SparseArray> - createAugmentedAutofillInlineSuggestions( - @NonNull InlineSuggestionsRequest request, @NonNull List datasets, - @NonNull AutofillId autofillId, - @NonNull InlineFillUi.InlineSuggestionUiCallback inlineSuggestionUiCallback, - @NonNull Runnable onErrorCallback, - @Nullable RemoteInlineSuggestionRenderService remoteRenderService, - int userId, int sessionId) { - if (sDebug) Slog.d(TAG, "createAugmentedInlineSuggestionsResponse called"); - return createInlineSuggestionsInternal(/* isAugmented= */ true, request, - datasets, autofillId, onErrorCallback, - (dataset, datasetIndex) -> - inlineSuggestionUiCallback.autofill(dataset, datasetIndex), - (intentSender) -> - inlineSuggestionUiCallback.startIntentSender(intentSender, new Intent()), - remoteRenderService, userId, sessionId); - } - - @Nullable - private static SparseArray> createInlineSuggestionsInternal( - boolean isAugmented, @NonNull InlineSuggestionsRequest request, - @NonNull List datasets, @NonNull AutofillId autofillId, - @NonNull Runnable onErrorCallback, @NonNull BiConsumer onClickFactory, - @NonNull Consumer intentSenderConsumer, - @Nullable RemoteInlineSuggestionRenderService remoteRenderService, - int userId, int sessionId) { + final InlineSuggestionsRequest request = inlineFillUiInfo.mInlineRequest; SparseArray> response = new SparseArray<>(datasets.size()); for (int datasetIndex = 0; datasetIndex < datasets.size(); datasetIndex++) { final Dataset dataset = datasets.get(datasetIndex); - final int fieldIndex = dataset.getFieldIds().indexOf(autofillId); + final int fieldIndex = dataset.getFieldIds().indexOf(inlineFillUiInfo.mFocusedId); if (fieldIndex < 0) { - Slog.w(TAG, "AutofillId=" + autofillId + " not found in dataset"); + Slog.w(TAG, "AutofillId=" + inlineFillUiInfo.mFocusedId + " not found in dataset"); continue; } - final InlinePresentation inlinePresentation = dataset.getFieldInlinePresentation( - fieldIndex); + + final InlinePresentation inlinePresentation = + dataset.getFieldInlinePresentation(fieldIndex); if (inlinePresentation == null) { Slog.w(TAG, "InlinePresentation not found in dataset"); continue; } - InlineSuggestion inlineSuggestion = createInlineSuggestion(isAugmented, dataset, - datasetIndex, + + final String suggestionType = + dataset.getAuthentication() == null ? InlineSuggestionInfo.TYPE_SUGGESTION + : InlineSuggestionInfo.TYPE_ACTION; + final int index = datasetIndex; + + InlineSuggestion inlineSuggestion = createInlineSuggestion( + inlineFillUiInfo, suggestionSource, suggestionType, + () -> uiCallback.autofill(dataset, index), mergedInlinePresentation(request, datasetIndex, inlinePresentation), - onClickFactory, remoteRenderService, userId, sessionId, - onErrorCallback, intentSenderConsumer, - request.getHostInputToken(), request.getHostDisplayId()); + uiCallback); response.append(datasetIndex, Pair.create(dataset, inlineSuggestion)); } + return response; } - private static InlineSuggestion createInlineSuggestion(boolean isAugmented, - @NonNull Dataset dataset, int datasetIndex, + private static InlineSuggestion createInlineSuggestion( + @NonNull InlineFillUi.InlineFillUiInfo inlineFillUiInfo, + @NonNull @InlineSuggestionInfo.Source String suggestionSource, + @NonNull @InlineSuggestionInfo.Type String suggestionType, + @NonNull Runnable onClickAction, @NonNull InlinePresentation inlinePresentation, - @NonNull BiConsumer onClickFactory, - @NonNull RemoteInlineSuggestionRenderService remoteRenderService, - int userId, int sessionId, - @NonNull Runnable onErrorCallback, @NonNull Consumer intentSenderConsumer, - @Nullable IBinder hostInputToken, - int displayId) { - final String suggestionSource = isAugmented ? InlineSuggestionInfo.SOURCE_PLATFORM - : InlineSuggestionInfo.SOURCE_AUTOFILL; - final String suggestionType = - dataset.getAuthentication() == null ? InlineSuggestionInfo.TYPE_SUGGESTION - : InlineSuggestionInfo.TYPE_ACTION; + @NonNull InlineFillUi.InlineSuggestionUiCallback uiCallback) { final InlineSuggestionInfo inlineSuggestionInfo = new InlineSuggestionInfo( inlinePresentation.getInlinePresentationSpec(), suggestionSource, inlinePresentation.getAutofillHints(), suggestionType, inlinePresentation.isPinned()); - final InlineSuggestion inlineSuggestion = new InlineSuggestion(inlineSuggestionInfo, - createInlineContentProvider(inlinePresentation, - () -> onClickFactory.accept(dataset, datasetIndex), onErrorCallback, - intentSenderConsumer, remoteRenderService, userId, sessionId, - hostInputToken, displayId)); - - return inlineSuggestion; - } - - private static InlineSuggestion createInlineAuthSuggestion( - @NonNull InlinePresentation inlinePresentation, - @NonNull RemoteInlineSuggestionRenderService remoteRenderService, - int userId, int sessionId, - @NonNull BiConsumer onClickFactory, @NonNull Runnable onErrorCallback, - @NonNull Consumer intentSenderConsumer, - @Nullable IBinder hostInputToken, int displayId) { - final InlineSuggestionInfo inlineSuggestionInfo = new InlineSuggestionInfo( - inlinePresentation.getInlinePresentationSpec(), - InlineSuggestionInfo.SOURCE_AUTOFILL, inlinePresentation.getAutofillHints(), - InlineSuggestionInfo.TYPE_ACTION, inlinePresentation.isPinned()); - return new InlineSuggestion(inlineSuggestionInfo, - createInlineContentProvider(inlinePresentation, - () -> onClickFactory.accept(null, - AutofillManager.AUTHENTICATION_ID_DATASET_ID_UNDEFINED), - onErrorCallback, intentSenderConsumer, remoteRenderService, userId, - sessionId, hostInputToken, displayId)); + createInlineContentProvider(inlineFillUiInfo, inlinePresentation, + onClickAction, uiCallback)); } /** @@ -216,25 +130,20 @@ final class InlineSuggestionFactory { inlinePresentation.getInlinePresentationSpec().getMinSize(), inlinePresentation.getInlinePresentationSpec().getMaxSize()).setStyle( specFromHost.getStyle()).build(); + return new InlinePresentation(inlinePresentation.getSlice(), mergedInlinePresentation, inlinePresentation.isPinned()); } private static IInlineContentProvider createInlineContentProvider( + @NonNull InlineFillUi.InlineFillUiInfo inlineFillUiInfo, @NonNull InlinePresentation inlinePresentation, @Nullable Runnable onClickAction, - @NonNull Runnable onErrorCallback, - @NonNull Consumer intentSenderConsumer, - @Nullable RemoteInlineSuggestionRenderService remoteRenderService, - int userId, int sessionId, - @Nullable IBinder hostInputToken, - int displayId) { - RemoteInlineSuggestionViewConnector - remoteInlineSuggestionViewConnector = new RemoteInlineSuggestionViewConnector( - remoteRenderService, userId, sessionId, inlinePresentation, hostInputToken, - displayId, onClickAction, onErrorCallback, intentSenderConsumer); - InlineContentProviderImpl inlineContentProvider = new InlineContentProviderImpl( - remoteInlineSuggestionViewConnector, null); - return inlineContentProvider; + @NonNull InlineFillUi.InlineSuggestionUiCallback uiCallback) { + RemoteInlineSuggestionViewConnector remoteInlineSuggestionViewConnector = + new RemoteInlineSuggestionViewConnector(inlineFillUiInfo, inlinePresentation, + onClickAction, uiCallback); + + return new InlineContentProviderImpl(remoteInlineSuggestionViewConnector, null); } private InlineSuggestionFactory() { diff --git a/services/autofill/java/com/android/server/autofill/ui/RemoteInlineSuggestionViewConnector.java b/services/autofill/java/com/android/server/autofill/ui/RemoteInlineSuggestionViewConnector.java index 7257255d1ee4..46d435d8811d 100644 --- a/services/autofill/java/com/android/server/autofill/ui/RemoteInlineSuggestionViewConnector.java +++ b/services/autofill/java/com/android/server/autofill/ui/RemoteInlineSuggestionViewConnector.java @@ -57,24 +57,20 @@ final class RemoteInlineSuggestionViewConnector { private final Consumer mStartIntentSenderFromClientApp; RemoteInlineSuggestionViewConnector( - @Nullable RemoteInlineSuggestionRenderService remoteRenderService, - int userId, int sessionId, + @NonNull InlineFillUi.InlineFillUiInfo inlineFillUiInfo, @NonNull InlinePresentation inlinePresentation, - @Nullable IBinder hostInputToken, - int displayId, @NonNull Runnable onAutofillCallback, - @NonNull Runnable onErrorCallback, - @NonNull Consumer startIntentSenderFromClientApp) { - mRemoteRenderService = remoteRenderService; + @NonNull InlineFillUi.InlineSuggestionUiCallback uiCallback) { + mRemoteRenderService = inlineFillUiInfo.mRemoteRenderService; mInlinePresentation = inlinePresentation; - mHostInputToken = hostInputToken; - mDisplayId = displayId; - mUserId = userId; - mSessionId = sessionId; + mHostInputToken = inlineFillUiInfo.mInlineRequest.getHostInputToken(); + mDisplayId = inlineFillUiInfo.mInlineRequest.getHostDisplayId(); + mUserId = inlineFillUiInfo.mUserId; + mSessionId = inlineFillUiInfo.mSessionId; mOnAutofillCallback = onAutofillCallback; - mOnErrorCallback = onErrorCallback; - mStartIntentSenderFromClientApp = startIntentSenderFromClientApp; + mOnErrorCallback = uiCallback::onError; + mStartIntentSenderFromClientApp = uiCallback::startIntentSender; } /**