diff options
Diffstat (limited to 'core/java')
5 files changed, 251 insertions, 49 deletions
diff --git a/core/java/android/service/autofill/Dataset.aidl b/core/java/android/service/autofill/Dataset.aidl new file mode 100644 index 000000000000..6fe7dd6119e7 --- /dev/null +++ b/core/java/android/service/autofill/Dataset.aidl @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2019, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.service.autofill; + +parcelable Dataset; diff --git a/core/java/android/service/autofill/augmented/AugmentedAutofillService.java b/core/java/android/service/autofill/augmented/AugmentedAutofillService.java index 66c3e1966134..484eddc8c2f6 100644 --- a/core/java/android/service/autofill/augmented/AugmentedAutofillService.java +++ b/core/java/android/service/autofill/augmented/AugmentedAutofillService.java @@ -236,9 +236,9 @@ public abstract class AugmentedAutofillService extends Service { } catch (RemoteException e) { e.rethrowFromSystemServer(); } - - onFillRequest(new FillRequest(proxy), cancellationSignal, new FillController(proxy), - new FillCallback(proxy)); + // TODO(b/146453195): pass the inline suggestion request over. + onFillRequest(new FillRequest(proxy, /* inlineSuggestionsRequest= */null), + cancellationSignal, new FillController(proxy), new FillCallback(proxy)); } private void handleOnDestroyAllFillWindowsRequest() { @@ -500,7 +500,7 @@ public abstract class AugmentedAutofillService extends Service { } } try { - mCallback.onSuccess(); + mCallback.onSuccess(/* mInlineSuggestionsData= */null); } catch (RemoteException e) { Log.e(TAG, "Error reporting success: " + e); } diff --git a/core/java/android/service/autofill/augmented/FillRequest.java b/core/java/android/service/autofill/augmented/FillRequest.java index 0b44470670de..ca49e7daf054 100644 --- a/core/java/android/service/autofill/augmented/FillRequest.java +++ b/core/java/android/service/autofill/augmented/FillRequest.java @@ -23,6 +23,9 @@ import android.content.ComponentName; import android.service.autofill.augmented.AugmentedAutofillService.AutofillProxy; import android.view.autofill.AutofillId; import android.view.autofill.AutofillValue; +import android.view.inputmethod.InlineSuggestionsRequest; + +import com.android.internal.util.DataClass; /** * Represents a request to augment-fill an activity. @@ -31,14 +34,20 @@ import android.view.autofill.AutofillValue; @SystemApi // TODO(b/123100811): pass a requestId and/or sessionId? @TestApi +@DataClass( + genToString = true, + genBuilder = false, + genHiddenConstructor = true) +@DataClass.Suppress({"getProxy"}) public final class FillRequest { - final AutofillProxy mProxy; + private final @NonNull AutofillProxy mProxy; - /** @hide */ - FillRequest(@NonNull AutofillProxy proxy) { - mProxy = proxy; - } + //TODO(b/146901891): add detailed docs once we have stable APIs. + /** + * An optional request for inline suggestions. + */ + private final @Nullable InlineSuggestionsRequest mInlineSuggestionsRequest; /** * Gets the task of the activity associated with this request. @@ -81,10 +90,76 @@ public final class FillRequest { return mProxy.getSmartSuggestionParams(); } - @NonNull - @Override - public String toString() { + String proxyToString() { return "FillRequest[act=" + getActivityComponent().flattenToShortString() + ", id=" + mProxy.getFocusedId() + "]"; } + + + + + // Code below generated by codegen v1.0.14. + // + // DO NOT MODIFY! + // CHECKSTYLE:OFF Generated code + // + // To regenerate run: + // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/autofill/augmented/FillRequest.java + // + // To exclude the generated code from IntelliJ auto-formatting enable (one-time): + // Settings > Editor > Code Style > Formatter Control + //@formatter:off + + + /** + * Creates a new FillRequest. + * + * @param inlineSuggestionsRequest + * An optional request for inline suggestions. + * @hide + */ + @DataClass.Generated.Member + public FillRequest( + @NonNull AutofillProxy proxy, + @Nullable InlineSuggestionsRequest inlineSuggestionsRequest) { + this.mProxy = proxy; + com.android.internal.util.AnnotationValidations.validate( + NonNull.class, null, mProxy); + this.mInlineSuggestionsRequest = inlineSuggestionsRequest; + + // onConstructed(); // You can define this method to get a callback + } + + /** + * An optional request for inline suggestions. + */ + @DataClass.Generated.Member + public @Nullable InlineSuggestionsRequest getInlineSuggestionsRequest() { + return mInlineSuggestionsRequest; + } + + @Override + @DataClass.Generated.Member + public String toString() { + // You can override field toString logic by defining methods like: + // String fieldNameToString() { ... } + + return "FillRequest { " + + "proxy = " + proxyToString() + ", " + + "inlineSuggestionsRequest = " + mInlineSuggestionsRequest + + " }"; + } + + @DataClass.Generated( + time = 1577399314707L, + codegenVersion = "1.0.14", + sourceFile = "frameworks/base/core/java/android/service/autofill/augmented/FillRequest.java", + inputSignatures = "private final @android.annotation.NonNull android.service.autofill.augmented.AugmentedAutofillService.AutofillProxy mProxy\nprivate final @android.annotation.Nullable android.view.inputmethod.InlineSuggestionsRequest mInlineSuggestionsRequest\npublic int getTaskId()\npublic @android.annotation.NonNull android.content.ComponentName getActivityComponent()\npublic @android.annotation.NonNull android.view.autofill.AutofillId getFocusedId()\npublic @android.annotation.NonNull android.view.autofill.AutofillValue getFocusedValue()\npublic @android.annotation.Nullable android.service.autofill.augmented.PresentationParams getPresentationParams()\n java.lang.String proxyToString()\nclass FillRequest extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genToString=true, genBuilder=false, genHiddenConstructor=true)") + @Deprecated + private void __metadata() {} + + + //@formatter:on + // End of generated code + } diff --git a/core/java/android/service/autofill/augmented/FillResponse.java b/core/java/android/service/autofill/augmented/FillResponse.java index 48a3c1b18334..e8e6ff05da03 100644 --- a/core/java/android/service/autofill/augmented/FillResponse.java +++ b/core/java/android/service/autofill/augmented/FillResponse.java @@ -19,6 +19,12 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.TestApi; +import android.service.autofill.Dataset; + +import com.android.internal.util.DataClass; + +import java.util.ArrayList; +import java.util.List; /** * Response to a {@link FillRequest}. @@ -27,65 +33,165 @@ import android.annotation.TestApi; */ @SystemApi @TestApi +@DataClass( + genBuilder = true, + genHiddenGetters = true) public final class FillResponse { - private final FillWindow mFillWindow; + /** + * The {@link FillWindow} used to display the Autofill UI. + */ + private @Nullable FillWindow mFillWindow; - private FillResponse(@NonNull Builder builder) { - mFillWindow = builder.mFillWindow; + /** + * The {@link Dataset}s representing the inline suggestions data. Defaults to null if no + * inline suggestions are available from the service. + */ + @DataClass.PluralOf("inlineSuggestion") + private @Nullable List<Dataset> mInlineSuggestions; + + private static FillWindow defaultFillWindow() { + return null; + } + + private static List<Dataset> defaultInlineSuggestions() { + return null; } + /** @hide */ - @Nullable - FillWindow getFillWindow() { + abstract static class BaseBuilder { + abstract FillResponse.Builder addInlineSuggestion(@NonNull Dataset value); + } + + + + // Code below generated by codegen v1.0.14. + // + // DO NOT MODIFY! + // CHECKSTYLE:OFF Generated code + // + // To regenerate run: + // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/autofill/augmented/FillResponse.java + // + // To exclude the generated code from IntelliJ auto-formatting enable (one-time): + // Settings > Editor > Code Style > Formatter Control + //@formatter:off + + + @DataClass.Generated.Member + /* package-private */ FillResponse( + @Nullable FillWindow fillWindow, + @Nullable List<Dataset> inlineSuggestions) { + this.mFillWindow = fillWindow; + this.mInlineSuggestions = inlineSuggestions; + + // onConstructed(); // You can define this method to get a callback + } + + /** + * The {@link FillWindow} used to display the Autofill UI. + * + * @hide + */ + @DataClass.Generated.Member + public @Nullable FillWindow getFillWindow() { return mFillWindow; } /** - * Builder for {@link FillResponse} objects. + * The {@link Dataset}s representing the inline suggestions data. Defaults to null if no + * inline suggestions are available from the service. * * @hide */ - @SystemApi - @TestApi - public static final class Builder { + @DataClass.Generated.Member + public @Nullable List<Dataset> getInlineSuggestions() { + return mInlineSuggestions; + } + + /** + * A builder for {@link FillResponse} + */ + @SuppressWarnings("WeakerAccess") + @DataClass.Generated.Member + public static final class Builder extends BaseBuilder { - private FillWindow mFillWindow; + private @Nullable FillWindow mFillWindow; + private @Nullable List<Dataset> mInlineSuggestions; + + private long mBuilderFieldsSet = 0L; + + public Builder() { + } /** - * Sets the {@link FillWindow} used to display the Autofill UI. - * - * <p>Must be called when the service is handling the request so the Android System can - * properly synchronize the UI. - * - * @return this builder + * The {@link FillWindow} used to display the Autofill UI. */ - @NonNull - public Builder setFillWindow(@NonNull FillWindow fillWindow) { - // TODO(b/123100712): check not null / unit test / throw exception if FillWindow not - // updated yet - mFillWindow = fillWindow; + @DataClass.Generated.Member + public @NonNull Builder setFillWindow(@Nullable FillWindow value) { + checkNotUsed(); + mBuilderFieldsSet |= 0x1; + mFillWindow = value; return this; } /** - * Builds a new {@link FillResponse} instance. - * - * @throws IllegalStateException if any of the following conditions occur: - * <ol> - * <li>{@link #build()} was already called. - * <li>No call was made to {@link #setFillWindow(FillWindow)} or - * {@ling #setIgnoredIds(List<AutofillId>)}. - * </ol> - * - * @return A built response. + * The {@link Dataset}s representing the inline suggestions data. Defaults to null if no + * inline suggestions are available from the service. */ - @NonNull - public FillResponse build() { - // TODO(b/123100712): check conditions / add unit test - return new FillResponse(this); + @DataClass.Generated.Member + public @NonNull Builder setInlineSuggestions(@Nullable List<Dataset> value) { + checkNotUsed(); + mBuilderFieldsSet |= 0x2; + mInlineSuggestions = value; + return this; + } + + /** @see #setInlineSuggestions */ + @DataClass.Generated.Member + @Override + @NonNull FillResponse.Builder addInlineSuggestion(@NonNull Dataset value) { + if (mInlineSuggestions == null) setInlineSuggestions(new ArrayList<>()); + mInlineSuggestions.add(value); + return this; + } + + /** Builds the instance. This builder should not be touched after calling this! */ + public @NonNull FillResponse build() { + checkNotUsed(); + mBuilderFieldsSet |= 0x4; // Mark builder used + + if ((mBuilderFieldsSet & 0x1) == 0) { + mFillWindow = defaultFillWindow(); + } + if ((mBuilderFieldsSet & 0x2) == 0) { + mInlineSuggestions = defaultInlineSuggestions(); + } + FillResponse o = new FillResponse( + mFillWindow, + mInlineSuggestions); + return o; + } + + private void checkNotUsed() { + if ((mBuilderFieldsSet & 0x4) != 0) { + throw new IllegalStateException( + "This Builder should not be reused. Use a new Builder instance instead"); + } } } - // TODO(b/123100811): implement to String + @DataClass.Generated( + time = 1577476012370L, + codegenVersion = "1.0.14", + sourceFile = "frameworks/base/core/java/android/service/autofill/augmented/FillResponse.java", + inputSignatures = "private @android.annotation.Nullable android.service.autofill.augmented.FillWindow mFillWindow\nprivate @com.android.internal.util.DataClass.PluralOf(\"inlineSuggestion\") @android.annotation.Nullable java.util.List<android.service.autofill.Dataset> mInlineSuggestions\nprivate static android.service.autofill.augmented.FillWindow defaultFillWindow()\nprivate static java.util.List<android.service.autofill.Dataset> defaultInlineSuggestions()\nclass FillResponse extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genBuilder=true, genHiddenGetters=true)\nabstract android.service.autofill.augmented.FillResponse.Builder addInlineSuggestion(android.service.autofill.Dataset)\nclass BaseBuilder extends java.lang.Object implements []") + @Deprecated + private void __metadata() {} + + + //@formatter:on + // End of generated code + } diff --git a/core/java/android/service/autofill/augmented/IFillCallback.aidl b/core/java/android/service/autofill/augmented/IFillCallback.aidl index 88baa878f118..3ccb3114a10f 100644 --- a/core/java/android/service/autofill/augmented/IFillCallback.aidl +++ b/core/java/android/service/autofill/augmented/IFillCallback.aidl @@ -18,6 +18,8 @@ package android.service.autofill.augmented; import android.os.ICancellationSignal; +import android.service.autofill.Dataset; + /** * Interface to receive the result of an autofill request. * @@ -25,7 +27,7 @@ import android.os.ICancellationSignal; */ interface IFillCallback { void onCancellable(in ICancellationSignal cancellation); - void onSuccess(); + void onSuccess(in @nullable Dataset[] mInlineSuggestionsData); boolean isCompleted(); void cancel(); } |
