diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-01-03 22:12:22 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-01-03 22:12:22 +0000 |
| commit | 950e55d4f249cb0c754ff7adc3414f957fe871f0 (patch) | |
| tree | 3cd305acf8236c0b2ec5c77646faca3988328195 /core/java/android | |
| parent | de12cc1af014597da075d7582989fe928a0de666 (diff) | |
| parent | 5bf0d2bc5e99c9bdb75c9c42b79dcee44b7a05de (diff) | |
Merge "Add server side implementation for inline augmented autofill request."
Diffstat (limited to 'core/java/android')
3 files changed, 30 insertions, 7 deletions
diff --git a/core/java/android/service/autofill/augmented/AugmentedAutofillService.java b/core/java/android/service/autofill/augmented/AugmentedAutofillService.java index 484eddc8c2f6..6334d9d765c8 100644 --- a/core/java/android/service/autofill/augmented/AugmentedAutofillService.java +++ b/core/java/android/service/autofill/augmented/AugmentedAutofillService.java @@ -38,6 +38,7 @@ import android.os.ICancellationSignal; import android.os.Looper; import android.os.RemoteException; import android.os.SystemClock; +import android.service.autofill.Dataset; import android.service.autofill.augmented.PresentationParams.SystemPopupPresentationParams; import android.util.Log; import android.util.Pair; @@ -47,6 +48,7 @@ import android.view.autofill.AutofillManager; import android.view.autofill.AutofillValue; import android.view.autofill.IAugmentedAutofillManagerClient; import android.view.autofill.IAutofillWindowPresenter; +import android.view.inputmethod.InlineSuggestionsRequest; import com.android.internal.annotations.GuardedBy; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; @@ -106,10 +108,11 @@ public abstract class AugmentedAutofillService extends Service { @Override public void onFillRequest(int sessionId, IBinder client, int taskId, ComponentName componentName, AutofillId focusedId, AutofillValue focusedValue, - long requestTime, IFillCallback callback) { + long requestTime, @Nullable InlineSuggestionsRequest inlineSuggestionsRequest, + IFillCallback callback) { mHandler.sendMessage(obtainMessage(AugmentedAutofillService::handleOnFillRequest, AugmentedAutofillService.this, sessionId, client, taskId, componentName, - focusedId, focusedValue, requestTime, callback)); + focusedId, focusedValue, requestTime, inlineSuggestionsRequest, callback)); } @Override @@ -212,6 +215,7 @@ public abstract class AugmentedAutofillService extends Service { private void handleOnFillRequest(int sessionId, @NonNull IBinder client, int taskId, @NonNull ComponentName componentName, @NonNull AutofillId focusedId, @Nullable AutofillValue focusedValue, long requestTime, + @Nullable InlineSuggestionsRequest inlineSuggestionsRequest, @NonNull IFillCallback callback) { if (mAutofillProxies == null) { mAutofillProxies = new SparseArray<>(); @@ -236,9 +240,8 @@ public abstract class AugmentedAutofillService extends Service { } catch (RemoteException e) { e.rethrowFromSystemServer(); } - // TODO(b/146453195): pass the inline suggestion request over. - onFillRequest(new FillRequest(proxy, /* inlineSuggestionsRequest= */null), - cancellationSignal, new FillController(proxy), new FillCallback(proxy)); + onFillRequest(new FillRequest(proxy, inlineSuggestionsRequest), cancellationSignal, + new FillController(proxy), new FillCallback(proxy)); } private void handleOnDestroyAllFillWindowsRequest() { @@ -484,6 +487,14 @@ public abstract class AugmentedAutofillService extends Service { } } + public void onInlineSuggestionsDataReady(@NonNull List<Dataset> inlineSuggestionsData) { + try { + mCallback.onSuccess(inlineSuggestionsData.toArray(new Dataset[]{})); + } catch (RemoteException e) { + Log.e(TAG, "Error calling back with the inline suggestions data: " + e); + } + } + // Used (mostly) for metrics. public void report(@ReportEvent int event) { if (sVerbose) Log.v(TAG, "report(): " + event); diff --git a/core/java/android/service/autofill/augmented/FillCallback.java b/core/java/android/service/autofill/augmented/FillCallback.java index 0251386bd7ce..b767799847d7 100644 --- a/core/java/android/service/autofill/augmented/FillCallback.java +++ b/core/java/android/service/autofill/augmented/FillCallback.java @@ -21,9 +21,12 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.TestApi; +import android.service.autofill.Dataset; import android.service.autofill.augmented.AugmentedAutofillService.AutofillProxy; import android.util.Log; +import java.util.List; + /** * Callback used to indicate at {@link FillRequest} has been fulfilled. * @@ -45,7 +48,7 @@ public final class FillCallback { * Sets the response associated with the request. * * @param response response associated with the request, or {@code null} if the service - * could not provide autofill for the request. + * could not provide autofill for the request. */ public void onSuccess(@Nullable FillResponse response) { if (sDebug) Log.d(TAG, "onSuccess(): " + response); @@ -55,6 +58,12 @@ public final class FillCallback { return; } + List<Dataset> inlineSuggestions = response.getInlineSuggestions(); + if (inlineSuggestions != null && !inlineSuggestions.isEmpty()) { + mProxy.onInlineSuggestionsDataReady(inlineSuggestions); + return; + } + final FillWindow fillWindow = response.getFillWindow(); if (fillWindow != null) { fillWindow.show(); diff --git a/core/java/android/service/autofill/augmented/IAugmentedAutofillService.aidl b/core/java/android/service/autofill/augmented/IAugmentedAutofillService.aidl index 103fc4d7dfcf..4911348c692f 100644 --- a/core/java/android/service/autofill/augmented/IAugmentedAutofillService.aidl +++ b/core/java/android/service/autofill/augmented/IAugmentedAutofillService.aidl @@ -22,6 +22,7 @@ import android.os.IBinder; import android.service.autofill.augmented.IFillCallback; import android.view.autofill.AutofillId; import android.view.autofill.AutofillValue; +import android.view.inputmethod.InlineSuggestionsRequest; import java.util.List; @@ -35,7 +36,9 @@ oneway interface IAugmentedAutofillService { void onDisconnected(); void onFillRequest(int sessionId, in IBinder autofillManagerClient, int taskId, in ComponentName activityComponent, in AutofillId focusedId, - in AutofillValue focusedValue, long requestTime, in IFillCallback callback); + in AutofillValue focusedValue, long requestTime, + in InlineSuggestionsRequest inlineSuggestionsRequest, + in IFillCallback callback); void onDestroyAllFillWindowsRequest(); } |
