diff options
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rwxr-xr-x | api/system-current.txt | 1 | ||||
| -rw-r--r-- | api/test-current.txt | 3 | ||||
| -rw-r--r-- | core/java/android/service/autofill/InlinePresentation.java | 19 | ||||
| -rw-r--r-- | core/java/android/service/autofill/augmented/FillResponse.java | 62 | ||||
| -rw-r--r-- | core/java/android/view/inputmethod/InlineSuggestionInfo.java | 35 | ||||
| -rw-r--r-- | services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java | 15 |
7 files changed, 114 insertions, 22 deletions
diff --git a/api/current.txt b/api/current.txt index a2f2c060428d..5bcb0100ffd3 100644 --- a/api/current.txt +++ b/api/current.txt @@ -56956,6 +56956,7 @@ package android.view.inputmethod { method @NonNull public android.view.inline.InlinePresentationSpec getPresentationSpec(); method @NonNull public String getSource(); method @NonNull public String getType(); + method public boolean isPinned(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.view.inputmethod.InlineSuggestionInfo> CREATOR; field public static final String SOURCE_AUTOFILL = "android:autofill"; diff --git a/api/system-current.txt b/api/system-current.txt index 3b95f3226341..9977ff11ce3a 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9939,6 +9939,7 @@ package android.service.autofill.augmented { method @NonNull public android.service.autofill.augmented.FillResponse build(); method @NonNull public android.service.autofill.augmented.FillResponse.Builder setClientState(@Nullable android.os.Bundle); method @NonNull public android.service.autofill.augmented.FillResponse.Builder setFillWindow(@Nullable android.service.autofill.augmented.FillWindow); + method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineActions(@Nullable java.util.List<android.service.autofill.InlinePresentation>); method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineSuggestions(@Nullable java.util.List<android.service.autofill.Dataset>); } diff --git a/api/test-current.txt b/api/test-current.txt index 0f8694f7435b..f25f10807753 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -3270,6 +3270,7 @@ package android.service.autofill.augmented { method @NonNull public android.service.autofill.augmented.FillResponse build(); method @NonNull public android.service.autofill.augmented.FillResponse.Builder setClientState(@Nullable android.os.Bundle); method @NonNull public android.service.autofill.augmented.FillResponse.Builder setFillWindow(@Nullable android.service.autofill.augmented.FillWindow); + method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineActions(@Nullable java.util.List<android.service.autofill.InlinePresentation>); method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineSuggestions(@Nullable java.util.List<android.service.autofill.Dataset>); } @@ -5211,7 +5212,7 @@ package android.view.inputmethod { } public final class InlineSuggestionInfo implements android.os.Parcelable { - method @NonNull public static android.view.inputmethod.InlineSuggestionInfo newInlineSuggestionInfo(@NonNull android.view.inline.InlinePresentationSpec, @NonNull String, @Nullable String[]); + method @NonNull public static android.view.inputmethod.InlineSuggestionInfo newInlineSuggestionInfo(@NonNull android.view.inline.InlinePresentationSpec, @NonNull String, @Nullable String[], @NonNull String, boolean); } public final class InlineSuggestionsResponse implements android.os.Parcelable { diff --git a/core/java/android/service/autofill/InlinePresentation.java b/core/java/android/service/autofill/InlinePresentation.java index fb8406e99fa0..a9addba375af 100644 --- a/core/java/android/service/autofill/InlinePresentation.java +++ b/core/java/android/service/autofill/InlinePresentation.java @@ -17,6 +17,7 @@ package android.service.autofill; import android.annotation.NonNull; +import android.annotation.Size; import android.app.slice.Slice; import android.os.Parcel; import android.os.Parcelable; @@ -24,6 +25,8 @@ import android.view.inline.InlinePresentationSpec; import com.android.internal.util.DataClass; +import java.util.List; + /** * Wrapper class holding a {@link Slice} and an {@link InlinePresentationSpec} for rendering UI * for an Inline Suggestion. @@ -50,6 +53,18 @@ public final class InlinePresentation implements Parcelable { */ private final boolean mPinned; + /** + * Returns the autofill hints set in the slice. + * + * @hide + */ + @NonNull + @Size(min = 0) + public String[] getAutofillHints() { + List<String> hints = mSlice.getHints(); + return hints.toArray(new String[hints.size()]); + } + // Code below generated by codegen v1.0.14. @@ -214,10 +229,10 @@ public final class InlinePresentation implements Parcelable { }; @DataClass.Generated( - time = 1579726472535L, + time = 1582753782651L, codegenVersion = "1.0.14", sourceFile = "frameworks/base/core/java/android/service/autofill/InlinePresentation.java", - inputSignatures = "private final @android.annotation.NonNull android.app.slice.Slice mSlice\nprivate final @android.annotation.NonNull android.view.inline.InlinePresentationSpec mInlinePresentationSpec\nprivate final boolean mPinned\nclass InlinePresentation extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstDefs=true, genEqualsHashCode=true)") + inputSignatures = "private final @android.annotation.NonNull android.app.slice.Slice mSlice\nprivate final @android.annotation.NonNull android.view.inline.InlinePresentationSpec mInlinePresentationSpec\nprivate final boolean mPinned\npublic @android.annotation.NonNull @android.annotation.Size(min=0L) java.lang.String[] getAutofillHints()\nclass InlinePresentation extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstDefs=true, genEqualsHashCode=true)") @Deprecated private void __metadata() {} diff --git a/core/java/android/service/autofill/augmented/FillResponse.java b/core/java/android/service/autofill/augmented/FillResponse.java index 68ba63ac35a8..b7fdf5ab337f 100644 --- a/core/java/android/service/autofill/augmented/FillResponse.java +++ b/core/java/android/service/autofill/augmented/FillResponse.java @@ -21,6 +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 com.android.internal.util.DataClass; @@ -52,6 +53,13 @@ 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. + */ + @DataClass.PluralOf("inlineAction") + private @Nullable List<InlinePresentation> mInlineActions; + + /** * The client state that {@link AugmentedAutofillService} implementation can put anything in to * identify the request and the response when calling * {@link AugmentedAutofillService#getFillEventHistory()}. @@ -66,6 +74,10 @@ public final class FillResponse { return null; } + private static List<InlinePresentation> defaultInlineActions() { + return null; + } + private static Bundle defaultClientState() { return null; } @@ -74,6 +86,7 @@ public final class FillResponse { /** @hide */ abstract static class BaseBuilder { abstract FillResponse.Builder addInlineSuggestion(@NonNull Dataset value); + abstract FillResponse.Builder addInlineAction(@NonNull InlinePresentation value); } @@ -95,9 +108,11 @@ public final class FillResponse { /* package-private */ FillResponse( @Nullable FillWindow fillWindow, @Nullable List<Dataset> inlineSuggestions, + @Nullable List<InlinePresentation> inlineActions, @Nullable Bundle clientState) { this.mFillWindow = fillWindow; this.mInlineSuggestions = inlineSuggestions; + this.mInlineActions = inlineActions; this.mClientState = clientState; // onConstructed(); // You can define this method to get a callback @@ -125,6 +140,17 @@ public final class FillResponse { } /** + * The {@link InlinePresentation}s representing the inline actions. Defaults to null if no + * inline actions are provided. + * + * @hide + */ + @DataClass.Generated.Member + public @Nullable List<InlinePresentation> getInlineActions() { + return mInlineActions; + } + + /** * The client state that {@link AugmentedAutofillService} implementation can put anything in to * identify the request and the response when calling * {@link AugmentedAutofillService#getFillEventHistory()}. @@ -145,6 +171,7 @@ public final class FillResponse { private @Nullable FillWindow mFillWindow; private @Nullable List<Dataset> mInlineSuggestions; + private @Nullable List<InlinePresentation> mInlineActions; private @Nullable Bundle mClientState; private long mBuilderFieldsSet = 0L; @@ -185,6 +212,27 @@ public final class FillResponse { } /** + * The {@link InlinePresentation}s representing the inline actions. Defaults to null if no + * inline actions are provided. + */ + @DataClass.Generated.Member + public @NonNull Builder setInlineActions(@Nullable List<InlinePresentation> value) { + checkNotUsed(); + mBuilderFieldsSet |= 0x4; + mInlineActions = value; + return this; + } + + /** @see #setInlineActions */ + @DataClass.Generated.Member + @Override + @NonNull FillResponse.Builder addInlineAction(@NonNull InlinePresentation value) { + if (mInlineActions == null) setInlineActions(new ArrayList<>()); + mInlineActions.add(value); + return this; + } + + /** * The client state that {@link AugmentedAutofillService} implementation can put anything in to * identify the request and the response when calling * {@link AugmentedAutofillService#getFillEventHistory()}. @@ -192,7 +240,7 @@ public final class FillResponse { @DataClass.Generated.Member public @NonNull Builder setClientState(@Nullable Bundle value) { checkNotUsed(); - mBuilderFieldsSet |= 0x4; + mBuilderFieldsSet |= 0x8; mClientState = value; return this; } @@ -200,7 +248,7 @@ public final class FillResponse { /** Builds the instance. This builder should not be touched after calling this! */ public @NonNull FillResponse build() { checkNotUsed(); - mBuilderFieldsSet |= 0x8; // Mark builder used + mBuilderFieldsSet |= 0x10; // Mark builder used if ((mBuilderFieldsSet & 0x1) == 0) { mFillWindow = defaultFillWindow(); @@ -209,17 +257,21 @@ public final class FillResponse { mInlineSuggestions = defaultInlineSuggestions(); } if ((mBuilderFieldsSet & 0x4) == 0) { + mInlineActions = defaultInlineActions(); + } + if ((mBuilderFieldsSet & 0x8) == 0) { mClientState = defaultClientState(); } FillResponse o = new FillResponse( mFillWindow, mInlineSuggestions, + mInlineActions, mClientState); return o; } private void checkNotUsed() { - if ((mBuilderFieldsSet & 0x8) != 0) { + if ((mBuilderFieldsSet & 0x10) != 0) { throw new IllegalStateException( "This Builder should not be reused. Use a new Builder instance instead"); } @@ -227,10 +279,10 @@ public final class FillResponse { } @DataClass.Generated( - time = 1580335256422L, + time = 1582682935951L, 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 @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 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)\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.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 []") @Deprecated private void __metadata() {} diff --git a/core/java/android/view/inputmethod/InlineSuggestionInfo.java b/core/java/android/view/inputmethod/InlineSuggestionInfo.java index 024de4de92e7..cb0320e966d1 100644 --- a/core/java/android/view/inputmethod/InlineSuggestionInfo.java +++ b/core/java/android/view/inputmethod/InlineSuggestionInfo.java @@ -69,6 +69,9 @@ public final class InlineSuggestionInfo implements Parcelable { /** The type of the UI. */ private final @NonNull @Type String mType; + /** Whether the suggestion should be pinned or not. */ + private final boolean mPinned; + /** * Creates a new {@link InlineSuggestionInfo}, for testing purpose. * @@ -79,8 +82,8 @@ public final class InlineSuggestionInfo implements Parcelable { public static InlineSuggestionInfo newInlineSuggestionInfo( @NonNull InlinePresentationSpec presentationSpec, @NonNull @Source String source, - @Nullable String[] autofillHints) { - return new InlineSuggestionInfo(presentationSpec, source, autofillHints, TYPE_SUGGESTION); + @Nullable String[] autofillHints, @NonNull @Type String type, boolean isPinned) { + return new InlineSuggestionInfo(presentationSpec, source, autofillHints, type, isPinned); } @@ -127,6 +130,8 @@ public final class InlineSuggestionInfo implements Parcelable { * Hints for the type of data being suggested. * @param type * The type of the UI. + * @param pinned + * Whether the suggestion should be pinned or not. * @hide */ @DataClass.Generated.Member @@ -134,7 +139,8 @@ public final class InlineSuggestionInfo implements Parcelable { @NonNull InlinePresentationSpec presentationSpec, @NonNull @Source String source, @Nullable String[] autofillHints, - @NonNull @Type String type) { + @NonNull @Type String type, + boolean pinned) { this.mPresentationSpec = presentationSpec; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mPresentationSpec); @@ -163,6 +169,7 @@ public final class InlineSuggestionInfo implements Parcelable { com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mType); + this.mPinned = pinned; // onConstructed(); // You can define this method to get a callback } @@ -199,6 +206,14 @@ public final class InlineSuggestionInfo implements Parcelable { return mType; } + /** + * Whether the suggestion should be pinned or not. + */ + @DataClass.Generated.Member + public boolean isPinned() { + return mPinned; + } + @Override @DataClass.Generated.Member public String toString() { @@ -209,7 +224,8 @@ public final class InlineSuggestionInfo implements Parcelable { "presentationSpec = " + mPresentationSpec + ", " + "source = " + mSource + ", " + "autofillHints = " + java.util.Arrays.toString(mAutofillHints) + ", " + - "type = " + mType + + "type = " + mType + ", " + + "pinned = " + mPinned + " }"; } @@ -229,7 +245,8 @@ public final class InlineSuggestionInfo implements Parcelable { && java.util.Objects.equals(mPresentationSpec, that.mPresentationSpec) && java.util.Objects.equals(mSource, that.mSource) && java.util.Arrays.equals(mAutofillHints, that.mAutofillHints) - && java.util.Objects.equals(mType, that.mType); + && java.util.Objects.equals(mType, that.mType) + && mPinned == that.mPinned; } @Override @@ -243,6 +260,7 @@ public final class InlineSuggestionInfo implements Parcelable { _hash = 31 * _hash + java.util.Objects.hashCode(mSource); _hash = 31 * _hash + java.util.Arrays.hashCode(mAutofillHints); _hash = 31 * _hash + java.util.Objects.hashCode(mType); + _hash = 31 * _hash + Boolean.hashCode(mPinned); return _hash; } @@ -253,6 +271,7 @@ public final class InlineSuggestionInfo implements Parcelable { // void parcelFieldName(Parcel dest, int flags) { ... } byte flg = 0; + if (mPinned) flg |= 0x10; if (mAutofillHints != null) flg |= 0x4; dest.writeByte(flg); dest.writeTypedObject(mPresentationSpec, flags); @@ -273,6 +292,7 @@ public final class InlineSuggestionInfo implements Parcelable { // static FieldType unparcelFieldName(Parcel in) { ... } byte flg = in.readByte(); + boolean pinned = (flg & 0x10) != 0; InlinePresentationSpec presentationSpec = (InlinePresentationSpec) in.readTypedObject(InlinePresentationSpec.CREATOR); String source = in.readString(); String[] autofillHints = (flg & 0x4) == 0 ? null : in.createStringArray(); @@ -306,6 +326,7 @@ public final class InlineSuggestionInfo implements Parcelable { com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mType); + this.mPinned = pinned; // onConstructed(); // You can define this method to get a callback } @@ -325,10 +346,10 @@ public final class InlineSuggestionInfo implements Parcelable { }; @DataClass.Generated( - time = 1579806757327L, + time = 1582753084046L, codegenVersion = "1.0.14", sourceFile = "frameworks/base/core/java/android/view/inputmethod/InlineSuggestionInfo.java", - inputSignatures = "public static final @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String SOURCE_AUTOFILL\npublic static final @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String SOURCE_PLATFORM\npublic static final @android.view.inputmethod.InlineSuggestionInfo.Type java.lang.String TYPE_SUGGESTION\npublic static final @android.annotation.SuppressLint({\"IntentName\"}) @android.view.inputmethod.InlineSuggestionInfo.Type java.lang.String TYPE_ACTION\nprivate final @android.annotation.NonNull android.view.inline.InlinePresentationSpec mPresentationSpec\nprivate final @android.annotation.NonNull @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String mSource\nprivate final @android.annotation.Nullable java.lang.String[] mAutofillHints\nprivate final @android.annotation.NonNull @android.view.inputmethod.InlineSuggestionInfo.Type java.lang.String mType\npublic static @android.annotation.TestApi @android.annotation.NonNull android.view.inputmethod.InlineSuggestionInfo newInlineSuggestionInfo(android.view.inline.InlinePresentationSpec,java.lang.String,java.lang.String[])\nclass InlineSuggestionInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genHiddenConstDefs=true, genHiddenConstructor=true)") + inputSignatures = "public static final @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String SOURCE_AUTOFILL\npublic static final @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String SOURCE_PLATFORM\npublic static final @android.view.inputmethod.InlineSuggestionInfo.Type java.lang.String TYPE_SUGGESTION\npublic static final @android.annotation.SuppressLint({\"IntentName\"}) @android.view.inputmethod.InlineSuggestionInfo.Type java.lang.String TYPE_ACTION\nprivate final @android.annotation.NonNull android.view.inline.InlinePresentationSpec mPresentationSpec\nprivate final @android.annotation.NonNull @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String mSource\nprivate final @android.annotation.Nullable java.lang.String[] mAutofillHints\nprivate final @android.annotation.NonNull @android.view.inputmethod.InlineSuggestionInfo.Type java.lang.String mType\nprivate final boolean mPinned\npublic static @android.annotation.TestApi @android.annotation.NonNull android.view.inputmethod.InlineSuggestionInfo newInlineSuggestionInfo(android.view.inline.InlinePresentationSpec,java.lang.String,java.lang.String[],java.lang.String,boolean)\nclass InlineSuggestionInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genHiddenConstDefs=true, genHiddenConstructor=true)") @Deprecated private void __metadata() {} 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 fef49d44bed0..b8051ddf9466 100644 --- a/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java +++ b/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java @@ -219,12 +219,12 @@ public final class InlineSuggestionFactory { @Nullable RemoteInlineSuggestionRenderService remoteRenderService, @NonNull Runnable onErrorCallback, @Nullable IBinder hostInputToken, int displayId) { - // TODO(b/146453195): fill in the autofill hint properly. final InlineSuggestionInfo inlineSuggestionInfo = new InlineSuggestionInfo( inlinePresentation.getInlinePresentationSpec(), isAugmented ? InlineSuggestionInfo.SOURCE_PLATFORM - : InlineSuggestionInfo.SOURCE_AUTOFILL, new String[]{""}, - InlineSuggestionInfo.TYPE_ACTION); + : InlineSuggestionInfo.SOURCE_AUTOFILL, + inlinePresentation.getAutofillHints(), + InlineSuggestionInfo.TYPE_ACTION, inlinePresentation.isPinned()); final Runnable onClickAction = () -> { Toast.makeText(context, "icon clicked", Toast.LENGTH_SHORT).show(); }; @@ -240,12 +240,12 @@ public final class InlineSuggestionFactory { @NonNull RemoteInlineSuggestionRenderService remoteRenderService, @NonNull Runnable onErrorCallback, @Nullable IBinder hostInputToken, int displayId) { - // TODO(b/146453195): fill in the autofill hint properly. final InlineSuggestionInfo inlineSuggestionInfo = new InlineSuggestionInfo( inlinePresentation.getInlinePresentationSpec(), isAugmented ? InlineSuggestionInfo.SOURCE_PLATFORM - : InlineSuggestionInfo.SOURCE_AUTOFILL, new String[]{""}, - InlineSuggestionInfo.TYPE_SUGGESTION); + : InlineSuggestionInfo.SOURCE_AUTOFILL, + inlinePresentation.getAutofillHints(), + InlineSuggestionInfo.TYPE_SUGGESTION, inlinePresentation.isPinned()); final InlineSuggestion inlineSuggestion = new InlineSuggestion(inlineSuggestionInfo, createInlineContentProvider(inlinePresentation, @@ -262,7 +262,8 @@ public final class InlineSuggestionFactory { @Nullable IBinder hostInputToken, int displayId) { final InlineSuggestionInfo inlineSuggestionInfo = new InlineSuggestionInfo( inlinePresentation.getInlinePresentationSpec(), - InlineSuggestionInfo.SOURCE_AUTOFILL, null, InlineSuggestionInfo.TYPE_SUGGESTION); + InlineSuggestionInfo.SOURCE_AUTOFILL, inlinePresentation.getAutofillHints(), + InlineSuggestionInfo.TYPE_SUGGESTION, inlinePresentation.isPinned()); return new InlineSuggestion(inlineSuggestionInfo, createInlineContentProvider(inlinePresentation, |