diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-03-10 04:15:36 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-03-10 04:15:36 +0000 |
| commit | e5150ded925f67e146777823823f4bc72ab9209e (patch) | |
| tree | d042e0ba2d1b272a142e5064f23724e3fff4a8b8 /core/java/android | |
| parent | 46863709351d271ff271c2254d179b1777a2973f (diff) | |
| parent | 88872971a7da6b828a32140a2cf2a5cc3b7222b2 (diff) | |
Merge "Create InlineAction class to wrap the IntentSender and the presentation" into rvc-dev
Diffstat (limited to 'core/java/android')
6 files changed, 250 insertions, 32 deletions
diff --git a/core/java/android/service/autofill/FillResponse.java b/core/java/android/service/autofill/FillResponse.java index e8e1223a29d0..06b5fa07a554 100644 --- a/core/java/android/service/autofill/FillResponse.java +++ b/core/java/android/service/autofill/FillResponse.java @@ -89,7 +89,7 @@ public final class FillResponse implements Parcelable { private final @Nullable int[] mCancelIds; private final boolean mSupportsInlineSuggestions; // TODO(b/149240554): revert back to use ParceledListSlice after the bug is resolved. - private final @Nullable ArrayList<InlinePresentation> mInlineActions; + private final @Nullable ArrayList<InlineAction> mInlineActions; private FillResponse(@NonNull Builder builder) { mDatasets = (builder.mDatasets != null) ? new ParceledListSlice<>(builder.mDatasets) : null; @@ -213,7 +213,7 @@ public final class FillResponse implements Parcelable { } /** @hide */ - public @Nullable List<InlinePresentation> getInlineActions() { + public @Nullable List<InlineAction> getInlineActions() { return mInlineActions; } @@ -239,7 +239,7 @@ public final class FillResponse implements Parcelable { private UserData mUserData; private int[] mCancelIds; private boolean mSupportsInlineSuggestions; - private ArrayList<InlinePresentation> mInlineActions; + private ArrayList<InlineAction> mInlineActions; /** * Triggers a custom UI before before autofilling the screen with any data set in this @@ -656,15 +656,12 @@ public final class FillResponse implements Parcelable { } /** - * Adds a new {@link InlinePresentation} to this response representing an action UI. - * - * <p> For example, the UI can be associated with an intent which can open an activity for - * the user to manage the Autofill provider settings. + * Adds a new {@link InlineAction} to this response representing an action UI. * * @return This builder. */ @NonNull - public Builder addInlineAction(@NonNull InlinePresentation inlineAction) { + public Builder addInlineAction(@NonNull InlineAction inlineAction) { throwIfDestroyed(); throwIfAuthenticationCalled(); if (mInlineActions == null) { @@ -881,10 +878,10 @@ public final class FillResponse implements Parcelable { final int[] cancelIds = parcel.createIntArray(); builder.setPresentationCancelIds(cancelIds); - final List<InlinePresentation> inlineActions = parcel.createTypedArrayList( - InlinePresentation.CREATOR); + final List<InlineAction> inlineActions = parcel.createTypedArrayList( + InlineAction.CREATOR); if (inlineActions != null) { - for (InlinePresentation inlineAction : inlineActions) { + for (InlineAction inlineAction : inlineActions) { builder.addInlineAction(inlineAction); } } diff --git a/core/java/android/service/autofill/InlineAction.aidl b/core/java/android/service/autofill/InlineAction.aidl new file mode 100644 index 000000000000..7f8511825d73 --- /dev/null +++ b/core/java/android/service/autofill/InlineAction.aidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2020 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 InlineAction; diff --git a/core/java/android/service/autofill/InlineAction.java b/core/java/android/service/autofill/InlineAction.java new file mode 100644 index 000000000000..17c4b33ba96b --- /dev/null +++ b/core/java/android/service/autofill/InlineAction.java @@ -0,0 +1,205 @@ +/* + * Copyright (C) 2020 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; + +import android.annotation.NonNull; +import android.content.IntentSender; +import android.os.Parcelable; + +import com.android.internal.util.DataClass; + +/** + * Represents an inline action as part of the autofill/augmented autofill response. + * + * <p> It includes both the action intent and the UI presentation. For example, the UI can be + * associated with an intent which can open an activity for the user to manage the Autofill provider + * settings. + */ +@DataClass( + genToString = true, + genHiddenConstDefs = true, + genEqualsHashCode = true) +public final class InlineAction implements Parcelable { + + /** + * Representation of the inline action. + */ + private final @NonNull InlinePresentation mInlinePresentation; + + /** + * The associated intent which will be triggered when the action is selected. It will only be + * called by the OS. + */ + private final @NonNull IntentSender mAction; + + + + // Code below generated by codegen v1.0.15. + // + // DO NOT MODIFY! + // CHECKSTYLE:OFF Generated code + // + // To regenerate run: + // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/autofill/InlineAction.java + // + // To exclude the generated code from IntelliJ auto-formatting enable (one-time): + // Settings > Editor > Code Style > Formatter Control + //@formatter:off + + + /** + * Creates a new InlineAction. + * + * @param inlinePresentation + * Representation of the inline action. + * @param action + * The associated intent which will be triggered when the action is selected. It will only be + * invoked by the OS. + */ + @DataClass.Generated.Member + public InlineAction( + @NonNull InlinePresentation inlinePresentation, + @NonNull IntentSender action) { + this.mInlinePresentation = inlinePresentation; + com.android.internal.util.AnnotationValidations.validate( + NonNull.class, null, mInlinePresentation); + this.mAction = action; + com.android.internal.util.AnnotationValidations.validate( + NonNull.class, null, mAction); + + // onConstructed(); // You can define this method to get a callback + } + + /** + * Representation of the inline action. + */ + @DataClass.Generated.Member + public @NonNull InlinePresentation getInlinePresentation() { + return mInlinePresentation; + } + + /** + * The associated intent which will be triggered when the action is selected. It will only be + * invoked by the OS. + */ + @DataClass.Generated.Member + public @NonNull IntentSender getAction() { + return mAction; + } + + @Override + @DataClass.Generated.Member + public String toString() { + // You can override field toString logic by defining methods like: + // String fieldNameToString() { ... } + + return "InlineAction { " + + "inlinePresentation = " + mInlinePresentation + ", " + + "action = " + mAction + + " }"; + } + + @Override + @DataClass.Generated.Member + public boolean equals(@android.annotation.Nullable Object o) { + // You can override field equality logic by defining either of the methods like: + // boolean fieldNameEquals(InlineAction other) { ... } + // boolean fieldNameEquals(FieldType otherValue) { ... } + + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + @SuppressWarnings("unchecked") + InlineAction that = (InlineAction) o; + //noinspection PointlessBooleanExpression + return true + && java.util.Objects.equals(mInlinePresentation, that.mInlinePresentation) + && java.util.Objects.equals(mAction, that.mAction); + } + + @Override + @DataClass.Generated.Member + public int hashCode() { + // You can override field hashCode logic by defining methods like: + // int fieldNameHashCode() { ... } + + int _hash = 1; + _hash = 31 * _hash + java.util.Objects.hashCode(mInlinePresentation); + _hash = 31 * _hash + java.util.Objects.hashCode(mAction); + return _hash; + } + + @Override + @DataClass.Generated.Member + public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { + // You can override field parcelling by defining methods like: + // void parcelFieldName(Parcel dest, int flags) { ... } + + dest.writeTypedObject(mInlinePresentation, flags); + dest.writeTypedObject(mAction, flags); + } + + @Override + @DataClass.Generated.Member + public int describeContents() { return 0; } + + /** @hide */ + @SuppressWarnings({"unchecked", "RedundantCast"}) + @DataClass.Generated.Member + /* package-private */ InlineAction(@NonNull android.os.Parcel in) { + // You can override field unparcelling by defining methods like: + // static FieldType unparcelFieldName(Parcel in) { ... } + + InlinePresentation inlinePresentation = (InlinePresentation) in.readTypedObject(InlinePresentation.CREATOR); + IntentSender action = (IntentSender) in.readTypedObject(IntentSender.CREATOR); + + this.mInlinePresentation = inlinePresentation; + com.android.internal.util.AnnotationValidations.validate( + NonNull.class, null, mInlinePresentation); + this.mAction = action; + com.android.internal.util.AnnotationValidations.validate( + NonNull.class, null, mAction); + + // onConstructed(); // You can define this method to get a callback + } + + @DataClass.Generated.Member + public static final @NonNull Parcelable.Creator<InlineAction> CREATOR + = new Parcelable.Creator<InlineAction>() { + @Override + public InlineAction[] newArray(int size) { + return new InlineAction[size]; + } + + @Override + public InlineAction createFromParcel(@NonNull android.os.Parcel in) { + return new InlineAction(in); + } + }; + + @DataClass.Generated( + time = 1583798182424L, + codegenVersion = "1.0.15", + sourceFile = "frameworks/base/core/java/android/service/autofill/InlineAction.java", + inputSignatures = "private final @android.annotation.NonNull android.service.autofill.InlinePresentation mInlinePresentation\nprivate final @android.annotation.NonNull android.content.IntentSender mAction\nclass InlineAction extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstDefs=true, genEqualsHashCode=true)") + @Deprecated + private void __metadata() {} + + + //@formatter:on + // End of generated code + +} diff --git a/core/java/android/service/autofill/augmented/AugmentedAutofillService.java b/core/java/android/service/autofill/augmented/AugmentedAutofillService.java index fe792b1efd9f..ed27dd568823 100644 --- a/core/java/android/service/autofill/augmented/AugmentedAutofillService.java +++ b/core/java/android/service/autofill/augmented/AugmentedAutofillService.java @@ -40,7 +40,7 @@ import android.os.RemoteException; import android.os.SystemClock; import android.service.autofill.Dataset; import android.service.autofill.FillEventHistory; -import android.service.autofill.InlinePresentation; +import android.service.autofill.InlineAction; import android.service.autofill.augmented.PresentationParams.SystemPopupPresentationParams; import android.util.Log; import android.util.Pair; @@ -559,7 +559,7 @@ public abstract class AugmentedAutofillService extends Service { } void reportResult(@Nullable List<Dataset> inlineSuggestionsData, - @Nullable List<InlinePresentation> inlineActions) { + @Nullable List<InlineAction> inlineActions) { try { mCallback.onSuccess(inlineSuggestionsData, inlineActions); } catch (RemoteException e) { diff --git a/core/java/android/service/autofill/augmented/FillResponse.java b/core/java/android/service/autofill/augmented/FillResponse.java index 37d75aa5d502..f564b3ba616a 100644 --- a/core/java/android/service/autofill/augmented/FillResponse.java +++ b/core/java/android/service/autofill/augmented/FillResponse.java @@ -21,7 +21,7 @@ import android.annotation.SystemApi; import android.annotation.TestApi; import android.os.Bundle; import android.service.autofill.Dataset; -import android.service.autofill.InlinePresentation; +import android.service.autofill.InlineAction; import com.android.internal.util.DataClass; @@ -53,11 +53,10 @@ public final class FillResponse { private @Nullable List<Dataset> mInlineSuggestions; /** - * The {@link InlinePresentation}s representing the inline actions. Defaults to null if no - * inline actions are provided. + * Defaults to null if no inline actions are provided. */ @DataClass.PluralOf("inlineAction") - private @Nullable List<InlinePresentation> mInlineActions; + private @Nullable List<InlineAction> mInlineActions; /** * The client state that {@link AugmentedAutofillService} implementation can put anything in to @@ -74,7 +73,7 @@ public final class FillResponse { return null; } - private static List<InlinePresentation> defaultInlineActions() { + private static List<InlineAction> defaultInlineActions() { return null; } @@ -86,7 +85,7 @@ public final class FillResponse { /** @hide */ abstract static class BaseBuilder { abstract FillResponse.Builder addInlineSuggestion(@NonNull Dataset value); - abstract FillResponse.Builder addInlineAction(@NonNull InlinePresentation value); + abstract FillResponse.Builder addInlineAction(@NonNull InlineAction value); } @@ -108,7 +107,7 @@ public final class FillResponse { /* package-private */ FillResponse( @Nullable FillWindow fillWindow, @Nullable List<Dataset> inlineSuggestions, - @Nullable List<InlinePresentation> inlineActions, + @Nullable List<InlineAction> inlineActions, @Nullable Bundle clientState) { this.mFillWindow = fillWindow; this.mInlineSuggestions = inlineSuggestions; @@ -140,13 +139,12 @@ public final class FillResponse { } /** - * The {@link InlinePresentation}s representing the inline actions. Defaults to null if no - * inline actions are provided. + * Defaults to null if no inline actions are provided. * * @hide */ @DataClass.Generated.Member - public @Nullable List<InlinePresentation> getInlineActions() { + public @Nullable List<InlineAction> getInlineActions() { return mInlineActions; } @@ -171,7 +169,7 @@ public final class FillResponse { private @Nullable FillWindow mFillWindow; private @Nullable List<Dataset> mInlineSuggestions; - private @Nullable List<InlinePresentation> mInlineActions; + private @Nullable List<InlineAction> mInlineActions; private @Nullable Bundle mClientState; private long mBuilderFieldsSet = 0L; @@ -212,11 +210,10 @@ public final class FillResponse { } /** - * The {@link InlinePresentation}s representing the inline actions. Defaults to null if no - * inline actions are provided. + * Defaults to null if no inline actions are provided. */ @DataClass.Generated.Member - public @NonNull Builder setInlineActions(@NonNull List<InlinePresentation> value) { + public @NonNull Builder setInlineActions(@NonNull List<InlineAction> value) { checkNotUsed(); mBuilderFieldsSet |= 0x4; mInlineActions = value; @@ -226,7 +223,7 @@ public final class FillResponse { /** @see #setInlineActions */ @DataClass.Generated.Member @Override - @NonNull FillResponse.Builder addInlineAction(@NonNull InlinePresentation value) { + @NonNull FillResponse.Builder addInlineAction(@NonNull InlineAction value) { if (mInlineActions == null) setInlineActions(new ArrayList<>()); mInlineActions.add(value); return this; @@ -279,10 +276,10 @@ public final class FillResponse { } @DataClass.Generated( - time = 1583780042587L, + time = 1583793032373L, codegenVersion = "1.0.15", 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 @com.android.internal.util.DataClass.PluralOf(\"inlineAction\") @android.annotation.Nullable java.util.List<android.service.autofill.InlinePresentation> mInlineActions\nprivate @android.annotation.Nullable android.os.Bundle mClientState\nprivate static android.service.autofill.augmented.FillWindow defaultFillWindow()\nprivate static java.util.List<android.service.autofill.Dataset> defaultInlineSuggestions()\nprivate static java.util.List<android.service.autofill.InlinePresentation> defaultInlineActions()\nprivate static android.os.Bundle defaultClientState()\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)\nabstract android.service.autofill.augmented.FillResponse.Builder addInlineAction(android.service.autofill.InlinePresentation)\nclass BaseBuilder extends java.lang.Object implements []") + 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 @com.android.internal.util.DataClass.PluralOf(\"inlineAction\") @android.annotation.Nullable java.util.List<android.service.autofill.InlineAction> mInlineActions\nprivate @android.annotation.Nullable android.os.Bundle mClientState\nprivate static android.service.autofill.augmented.FillWindow defaultFillWindow()\nprivate static java.util.List<android.service.autofill.Dataset> defaultInlineSuggestions()\nprivate static java.util.List<android.service.autofill.InlineAction> defaultInlineActions()\nprivate static android.os.Bundle defaultClientState()\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)\nabstract android.service.autofill.augmented.FillResponse.Builder addInlineAction(android.service.autofill.InlineAction)\nclass BaseBuilder extends java.lang.Object implements []") @Deprecated private void __metadata() {} diff --git a/core/java/android/service/autofill/augmented/IFillCallback.aidl b/core/java/android/service/autofill/augmented/IFillCallback.aidl index bf0adcd54ab1..545dab284067 100644 --- a/core/java/android/service/autofill/augmented/IFillCallback.aidl +++ b/core/java/android/service/autofill/augmented/IFillCallback.aidl @@ -20,7 +20,7 @@ import android.os.Bundle; import android.os.ICancellationSignal; import android.service.autofill.Dataset; -import android.service.autofill.InlinePresentation; +import android.service.autofill.InlineAction; import java.util.List; @@ -32,7 +32,7 @@ import java.util.List; interface IFillCallback { void onCancellable(in ICancellationSignal cancellation); void onSuccess(in @nullable List<Dataset> inlineSuggestionsData, - in @nullable List<InlinePresentation> inlineActions); + in @nullable List<InlineAction> inlineActions); boolean isCompleted(); void cancel(); } |
