Merge "Create InlineAction class to wrap the IntentSender and the presentation" into rvc-dev am: e5150ded92 am: ab80e7c6b0 am: 44bde9eb7b
Change-Id: If6e2544d35ac0e530e8624e1b3e885df5becd0f6
This commit is contained in:
@@ -43108,7 +43108,7 @@ package android.service.autofill {
|
||||
public static final class FillResponse.Builder {
|
||||
ctor public FillResponse.Builder();
|
||||
method @NonNull public android.service.autofill.FillResponse.Builder addDataset(@Nullable android.service.autofill.Dataset);
|
||||
method @NonNull public android.service.autofill.FillResponse.Builder addInlineAction(@NonNull android.service.autofill.InlinePresentation);
|
||||
method @NonNull public android.service.autofill.FillResponse.Builder addInlineAction(@NonNull android.service.autofill.InlineAction);
|
||||
method @NonNull public android.service.autofill.FillResponse build();
|
||||
method @NonNull public android.service.autofill.FillResponse.Builder disableAutofill(long);
|
||||
method @NonNull public android.service.autofill.FillResponse.Builder setAuthentication(@NonNull android.view.autofill.AutofillId[], @Nullable android.content.IntentSender, @Nullable android.widget.RemoteViews);
|
||||
@@ -43138,6 +43138,15 @@ package android.service.autofill {
|
||||
method public android.service.autofill.ImageTransformation build();
|
||||
}
|
||||
|
||||
public final class InlineAction implements android.os.Parcelable {
|
||||
ctor public InlineAction(@NonNull android.service.autofill.InlinePresentation, @NonNull android.content.IntentSender);
|
||||
method public int describeContents();
|
||||
method @NonNull public android.content.IntentSender getAction();
|
||||
method @NonNull public android.service.autofill.InlinePresentation getInlinePresentation();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.service.autofill.InlineAction> CREATOR;
|
||||
}
|
||||
|
||||
public final class InlinePresentation implements android.os.Parcelable {
|
||||
ctor public InlinePresentation(@NonNull android.app.slice.Slice, @NonNull android.view.inline.InlinePresentationSpec, boolean);
|
||||
method public int describeContents();
|
||||
|
||||
@@ -9864,7 +9864,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(@NonNull android.os.Bundle);
|
||||
method @NonNull public android.service.autofill.augmented.FillResponse.Builder setFillWindow(@NonNull android.service.autofill.augmented.FillWindow);
|
||||
method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineActions(@NonNull java.util.List<android.service.autofill.InlinePresentation>);
|
||||
method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineActions(@NonNull java.util.List<android.service.autofill.InlineAction>);
|
||||
method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineSuggestions(@NonNull java.util.List<android.service.autofill.Dataset>);
|
||||
}
|
||||
|
||||
|
||||
@@ -3244,7 +3244,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(@NonNull android.os.Bundle);
|
||||
method @NonNull public android.service.autofill.augmented.FillResponse.Builder setFillWindow(@NonNull android.service.autofill.augmented.FillWindow);
|
||||
method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineActions(@NonNull java.util.List<android.service.autofill.InlinePresentation>);
|
||||
method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineActions(@NonNull java.util.List<android.service.autofill.InlineAction>);
|
||||
method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineSuggestions(@NonNull java.util.List<android.service.autofill.Dataset>);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
19
core/java/android/service/autofill/InlineAction.aidl
Normal file
19
core/java/android/service/autofill/InlineAction.aidl
Normal file
@@ -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;
|
||||
205
core/java/android/service/autofill/InlineAction.java
Normal file
205
core/java/android/service/autofill/InlineAction.java
Normal file
@@ -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
|
||||
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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() {}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import android.os.ICancellationSignal;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemClock;
|
||||
import android.service.autofill.Dataset;
|
||||
import android.service.autofill.InlinePresentation;
|
||||
import android.service.autofill.InlineAction;
|
||||
import android.service.autofill.augmented.AugmentedAutofillService;
|
||||
import android.service.autofill.augmented.IAugmentedAutofillService;
|
||||
import android.service.autofill.augmented.IFillCallback;
|
||||
@@ -167,7 +167,7 @@ final class RemoteAugmentedAutofillService
|
||||
new IFillCallback.Stub() {
|
||||
@Override
|
||||
public void onSuccess(@Nullable List<Dataset> inlineSuggestionsData,
|
||||
@Nullable List<InlinePresentation> inlineActions) {
|
||||
@Nullable List<InlineAction> inlineActions) {
|
||||
mCallbacks.resetLastResponse();
|
||||
maybeRequestShowInlineSuggestions(sessionId,
|
||||
inlineSuggestionsRequest, inlineSuggestionsData,
|
||||
@@ -237,7 +237,7 @@ final class RemoteAugmentedAutofillService
|
||||
private void maybeRequestShowInlineSuggestions(int sessionId,
|
||||
@Nullable InlineSuggestionsRequest request,
|
||||
@Nullable List<Dataset> inlineSuggestionsData,
|
||||
@Nullable List<InlinePresentation> inlineActions, @NonNull AutofillId focusedId,
|
||||
@Nullable List<InlineAction> inlineActions, @NonNull AutofillId focusedId,
|
||||
@Nullable Function<InlineSuggestionsResponse, Boolean> inlineSuggestionsCallback,
|
||||
@NonNull IAutoFillManagerClient client, @NonNull Runnable onErrorCallback,
|
||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
|
||||
@@ -250,7 +250,7 @@ final class RemoteAugmentedAutofillService
|
||||
|
||||
final InlineSuggestionsResponse inlineSuggestionsResponse =
|
||||
InlineSuggestionFactory.createAugmentedInlineSuggestionsResponse(
|
||||
request, inlineSuggestionsData, inlineActions, focusedId, mContext,
|
||||
request, inlineSuggestionsData, inlineActions, focusedId,
|
||||
dataset -> {
|
||||
mCallbacks.logAugmentedAutofillSelected(sessionId,
|
||||
dataset.getId());
|
||||
|
||||
@@ -137,7 +137,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
private final Handler mHandler;
|
||||
private final Object mLock;
|
||||
private final AutoFillUI mUi;
|
||||
private final Context mContext;
|
||||
|
||||
private final MetricsLogger mMetricsLogger = new MetricsLogger();
|
||||
|
||||
@@ -695,7 +694,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
mLock = lock;
|
||||
mUi = ui;
|
||||
mHandler = handler;
|
||||
mContext = context;
|
||||
mRemoteFillService = serviceComponentName == null ? null
|
||||
: new RemoteFillService(context, serviceComponentName, userId, this,
|
||||
bindInstantServiceAllowed);
|
||||
@@ -2680,7 +2678,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
InlineSuggestionsResponse inlineSuggestionsResponse =
|
||||
InlineSuggestionFactory.createInlineSuggestionsResponse(
|
||||
inlineSuggestionsRequest.get(),
|
||||
response, filterText, response.getInlineActions(), mCurrentViewId, mContext,
|
||||
response, filterText, response.getInlineActions(), mCurrentViewId,
|
||||
this, () -> {
|
||||
synchronized (mLock) {
|
||||
requestHideFillUi(mCurrentViewId);
|
||||
|
||||
@@ -21,12 +21,13 @@ import static com.android.server.autofill.Helper.sVerbose;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.content.IntentSender;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.service.autofill.Dataset;
|
||||
import android.service.autofill.FillResponse;
|
||||
import android.service.autofill.IInlineSuggestionUiCallback;
|
||||
import android.service.autofill.InlineAction;
|
||||
import android.service.autofill.InlinePresentation;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Slog;
|
||||
@@ -39,7 +40,6 @@ import android.view.inputmethod.InlineSuggestion;
|
||||
import android.view.inputmethod.InlineSuggestionInfo;
|
||||
import android.view.inputmethod.InlineSuggestionsRequest;
|
||||
import android.view.inputmethod.InlineSuggestionsResponse;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.internal.view.inline.IInlineContentCallback;
|
||||
import com.android.internal.view.inline.IInlineContentProvider;
|
||||
@@ -73,8 +73,8 @@ public final class InlineSuggestionFactory {
|
||||
@Nullable
|
||||
public static InlineSuggestionsResponse createInlineSuggestionsResponse(
|
||||
@NonNull InlineSuggestionsRequest request, @NonNull FillResponse response,
|
||||
@Nullable String filterText, @Nullable List<InlinePresentation> inlineActions,
|
||||
@NonNull AutofillId autofillId, @NonNull Context context,
|
||||
@Nullable String filterText, @Nullable List<InlineAction> inlineActions,
|
||||
@NonNull AutofillId autofillId,
|
||||
@NonNull AutoFillUI.AutoFillUiCallback client, @NonNull Runnable onErrorCallback,
|
||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
|
||||
if (sDebug) Slog.d(TAG, "createInlineSuggestionsResponse called");
|
||||
@@ -97,7 +97,7 @@ public final class InlineSuggestionFactory {
|
||||
response.getAuthentication() == null ? null : response.getInlinePresentation();
|
||||
return createInlineSuggestionsResponseInternal(/* isAugmented= */ false, request,
|
||||
response.getDatasets(), filterText, inlineAuthentication, inlineActions, autofillId,
|
||||
context, onErrorCallback, onClickFactory, remoteRenderService);
|
||||
onErrorCallback, onClickFactory, remoteRenderService);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,15 +107,14 @@ public final class InlineSuggestionFactory {
|
||||
@Nullable
|
||||
public static InlineSuggestionsResponse createAugmentedInlineSuggestionsResponse(
|
||||
@NonNull InlineSuggestionsRequest request, @NonNull List<Dataset> datasets,
|
||||
@Nullable List<InlinePresentation> inlineActions,
|
||||
@NonNull AutofillId autofillId, @NonNull Context context,
|
||||
@Nullable List<InlineAction> inlineActions, @NonNull AutofillId autofillId,
|
||||
@NonNull InlineSuggestionUiCallback inlineSuggestionUiCallback,
|
||||
@NonNull Runnable onErrorCallback,
|
||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
|
||||
if (sDebug) Slog.d(TAG, "createAugmentedInlineSuggestionsResponse called");
|
||||
return createInlineSuggestionsResponseInternal(/* isAugmented= */ true, request,
|
||||
datasets, /* filterText= */ null, /* inlineAuthentication= */ null,
|
||||
inlineActions, autofillId, context, onErrorCallback,
|
||||
inlineActions, autofillId, onErrorCallback,
|
||||
(dataset, datasetIndex) ->
|
||||
inlineSuggestionUiCallback.autofill(dataset), remoteRenderService);
|
||||
}
|
||||
@@ -125,9 +124,8 @@ public final class InlineSuggestionFactory {
|
||||
boolean isAugmented, @NonNull InlineSuggestionsRequest request,
|
||||
@Nullable List<Dataset> datasets, @Nullable String filterText,
|
||||
@Nullable InlinePresentation inlineAuthentication,
|
||||
@Nullable List<InlinePresentation> inlineActions, @NonNull AutofillId autofillId,
|
||||
@NonNull Context context, @NonNull Runnable onErrorCallback,
|
||||
@NonNull BiConsumer<Dataset, Integer> onClickFactory,
|
||||
@Nullable List<InlineAction> inlineActions, @NonNull AutofillId autofillId,
|
||||
@NonNull Runnable onErrorCallback, @NonNull BiConsumer<Dataset, Integer> onClickFactory,
|
||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
|
||||
|
||||
final ArrayList<InlineSuggestion> inlineSuggestions = new ArrayList<>();
|
||||
@@ -171,12 +169,13 @@ public final class InlineSuggestionFactory {
|
||||
}
|
||||
// We should only add inline actions if there is at least one suggestion.
|
||||
if (!inlineSuggestions.isEmpty() && inlineActions != null) {
|
||||
for (InlinePresentation inlinePresentation : inlineActions) {
|
||||
final InlineSuggestion inlineAction = createInlineAction(isAugmented, context,
|
||||
mergedInlinePresentation(request, 0, inlinePresentation),
|
||||
for (InlineAction inlineAction : inlineActions) {
|
||||
final InlineSuggestion inlineActionSuggestion = createInlineAction(isAugmented,
|
||||
mergedInlinePresentation(request, 0, inlineAction.getInlinePresentation()),
|
||||
inlineAction.getAction(),
|
||||
remoteRenderService, onErrorCallback, request.getHostInputToken(),
|
||||
request.getHostDisplayId());
|
||||
inlineSuggestions.add(inlineAction);
|
||||
inlineSuggestions.add(inlineActionSuggestion);
|
||||
}
|
||||
}
|
||||
return new InlineSuggestionsResponse(inlineSuggestions);
|
||||
@@ -215,22 +214,30 @@ public final class InlineSuggestionFactory {
|
||||
|
||||
|
||||
private static InlineSuggestion createInlineAction(boolean isAugmented,
|
||||
@NonNull Context context,
|
||||
@NonNull InlinePresentation inlinePresentation,
|
||||
@NonNull InlinePresentation presentation,
|
||||
@NonNull IntentSender action,
|
||||
@Nullable RemoteInlineSuggestionRenderService remoteRenderService,
|
||||
@NonNull Runnable onErrorCallback, @Nullable IBinder hostInputToken,
|
||||
int displayId) {
|
||||
final InlineSuggestionInfo inlineSuggestionInfo = new InlineSuggestionInfo(
|
||||
inlinePresentation.getInlinePresentationSpec(),
|
||||
presentation.getInlinePresentationSpec(),
|
||||
isAugmented ? InlineSuggestionInfo.SOURCE_PLATFORM
|
||||
: InlineSuggestionInfo.SOURCE_AUTOFILL,
|
||||
inlinePresentation.getAutofillHints(),
|
||||
InlineSuggestionInfo.TYPE_ACTION, inlinePresentation.isPinned());
|
||||
presentation.getAutofillHints(), InlineSuggestionInfo.TYPE_ACTION,
|
||||
presentation.isPinned());
|
||||
final Runnable onClickAction = () -> {
|
||||
Toast.makeText(context, "icon clicked", Toast.LENGTH_SHORT).show();
|
||||
try {
|
||||
// TODO(b/150499490): route the intent to the client app to have it fired there,
|
||||
// so that it will appear as a part of the same task as the client app (similar
|
||||
// to the authentication flow).
|
||||
action.sendIntent(null, 0, null, null, null);
|
||||
} catch (IntentSender.SendIntentException e) {
|
||||
onErrorCallback.run();
|
||||
Slog.w(TAG, "Error sending inline action intent");
|
||||
}
|
||||
};
|
||||
return new InlineSuggestion(inlineSuggestionInfo,
|
||||
createInlineContentProvider(inlinePresentation, onClickAction, onErrorCallback,
|
||||
createInlineContentProvider(presentation, onClickAction, onErrorCallback,
|
||||
remoteRenderService, hostInputToken, displayId));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user