Loading services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java +18 −5 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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); Loading services/autofill/java/com/android/server/autofill/Session.java +29 −7 Original line number Diff line number Diff line Loading @@ -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*/ () -> { 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); } @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)); } }, remoteRenderService, userId, id); } }); return mInlineSessionController.setInlineFillUiLocked(inlineFillUi); } Loading services/autofill/java/com/android/server/autofill/ui/InlineFillUi.java +75 −39 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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<Pair<Dataset, InlineSuggestion>> 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<Dataset> datasets, @NonNull AutofillId focusedViewId, @Nullable String filterText, @NonNull InlineSuggestionUiCallback uiCallback, @NonNull Runnable onErrorCallback, @Nullable RemoteInlineSuggestionRenderService remoteRenderService, int userId, int sessionId) { @NonNull InlineSuggestionUiCallback uiCallback) { SparseArray<Pair<Dataset, InlineSuggestion>> 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<Pair<Dataset, InlineSuggestion>> inlineSuggestions, @Nullable String filterText) { mAutofillId = autofillId; private InlineFillUi(@Nullable InlineFillUiInfo inlineFillUiInfo, @NonNull SparseArray<Pair<Dataset, InlineSuggestion>> inlineSuggestions) { mAutofillId = inlineFillUiInfo.mFocusedId; int size = inlineSuggestions.size(); mDatasets = new ArrayList<>(size); mInlineSuggestions = new ArrayList<>(size); Loading @@ -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 Loading Loading @@ -294,10 +318,22 @@ public final class InlineFillUi { */ void autofill(@NonNull Dataset dataset, int datasetIndex); /** * Callback to authenticate a dataset. * * <p>Only implemented by regular autofill for now.</p> */ 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(); } /** Loading services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java +49 −140 File changed.Preview size limit exceeded, changes collapsed. Show changes services/autofill/java/com/android/server/autofill/ui/RemoteInlineSuggestionViewConnector.java +9 −13 Original line number Diff line number Diff line Loading @@ -57,24 +57,20 @@ final class RemoteInlineSuggestionViewConnector { private final Consumer<IntentSender> 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<IntentSender> 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; } /** Loading Loading
services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java +18 −5 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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); Loading
services/autofill/java/com/android/server/autofill/Session.java +29 −7 Original line number Diff line number Diff line Loading @@ -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*/ () -> { 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); } @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)); } }, remoteRenderService, userId, id); } }); return mInlineSessionController.setInlineFillUiLocked(inlineFillUi); } Loading
services/autofill/java/com/android/server/autofill/ui/InlineFillUi.java +75 −39 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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<Pair<Dataset, InlineSuggestion>> 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<Dataset> datasets, @NonNull AutofillId focusedViewId, @Nullable String filterText, @NonNull InlineSuggestionUiCallback uiCallback, @NonNull Runnable onErrorCallback, @Nullable RemoteInlineSuggestionRenderService remoteRenderService, int userId, int sessionId) { @NonNull InlineSuggestionUiCallback uiCallback) { SparseArray<Pair<Dataset, InlineSuggestion>> 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<Pair<Dataset, InlineSuggestion>> inlineSuggestions, @Nullable String filterText) { mAutofillId = autofillId; private InlineFillUi(@Nullable InlineFillUiInfo inlineFillUiInfo, @NonNull SparseArray<Pair<Dataset, InlineSuggestion>> inlineSuggestions) { mAutofillId = inlineFillUiInfo.mFocusedId; int size = inlineSuggestions.size(); mDatasets = new ArrayList<>(size); mInlineSuggestions = new ArrayList<>(size); Loading @@ -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 Loading Loading @@ -294,10 +318,22 @@ public final class InlineFillUi { */ void autofill(@NonNull Dataset dataset, int datasetIndex); /** * Callback to authenticate a dataset. * * <p>Only implemented by regular autofill for now.</p> */ 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(); } /** Loading
services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java +49 −140 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/autofill/java/com/android/server/autofill/ui/RemoteInlineSuggestionViewConnector.java +9 −13 Original line number Diff line number Diff line Loading @@ -57,24 +57,20 @@ final class RemoteInlineSuggestionViewConnector { private final Consumer<IntentSender> 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<IntentSender> 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; } /** Loading