Remove the InlineActions API

* Use the original authentication instead
* Also support sending intent from augmented autofill, with the
  limitation of not supporting sending back the FillResponse or
  Dataset from the activity result

Test: manual
Test: atest android.autofillservice.cts.inline
Test: atest android.autofillservice.cts.FillResponseTest
Test: atest android.autofillservice.cts.augmented
Test: atest android.autofillservice.cts.LoginActivityTest
Bug: 150499490

Change-Id: I81031ff456adb4c07f530188dda80e97cc84b707
This commit is contained in:
Feng Cao
2020-03-17 20:27:19 -07:00
parent a8a123c1ea
commit bc6900480d
13 changed files with 37 additions and 402 deletions

View File

@@ -43118,7 +43118,6 @@ 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.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);
@@ -43148,15 +43147,6 @@ 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();

View File

@@ -9802,7 +9802,6 @@ 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.InlineAction>);
method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineSuggestions(@NonNull java.util.List<android.service.autofill.Dataset>);
}

View File

@@ -3263,7 +3263,6 @@ 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.InlineAction>);
method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineSuggestions(@NonNull java.util.List<android.service.autofill.Dataset>);
}

View File

@@ -88,8 +88,6 @@ public final class FillResponse implements Parcelable {
private final @Nullable UserData mUserData;
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<InlineAction> mInlineActions;
private FillResponse(@NonNull Builder builder) {
mDatasets = (builder.mDatasets != null) ? new ParceledListSlice<>(builder.mDatasets) : null;
@@ -109,7 +107,6 @@ public final class FillResponse implements Parcelable {
mUserData = builder.mUserData;
mCancelIds = builder.mCancelIds;
mSupportsInlineSuggestions = builder.mSupportsInlineSuggestions;
mInlineActions = builder.mInlineActions;
}
/** @hide */
@@ -212,11 +209,6 @@ public final class FillResponse implements Parcelable {
return mSupportsInlineSuggestions;
}
/** @hide */
public @Nullable List<InlineAction> getInlineActions() {
return mInlineActions;
}
/**
* Builder for {@link FillResponse} objects. You must to provide at least
* one dataset or set an authentication intent with a presentation view.
@@ -239,7 +231,6 @@ public final class FillResponse implements Parcelable {
private UserData mUserData;
private int[] mCancelIds;
private boolean mSupportsInlineSuggestions;
private ArrayList<InlineAction> mInlineActions;
/**
* Triggers a custom UI before before autofilling the screen with any data set in this
@@ -655,22 +646,6 @@ public final class FillResponse implements Parcelable {
return this;
}
/**
* Adds a new {@link InlineAction} to this response representing an action UI.
*
* @return This builder.
*/
@NonNull
public Builder addInlineAction(@NonNull InlineAction inlineAction) {
throwIfDestroyed();
throwIfAuthenticationCalled();
if (mInlineActions == null) {
mInlineActions = new ArrayList<>();
}
mInlineActions.add(inlineAction);
return this;
}
/**
* Builds a new {@link FillResponse} instance.
*
@@ -788,9 +763,6 @@ public final class FillResponse implements Parcelable {
builder.append(", mCancelIds=").append(mCancelIds.length);
}
builder.append(", mSupportInlinePresentations=").append(mSupportsInlineSuggestions);
if (mInlineActions != null) {
builder.append(", mInlineActions=" + mInlineActions);
}
return builder.append("]").toString();
}
@@ -820,7 +792,6 @@ public final class FillResponse implements Parcelable {
parcel.writeParcelableArray(mFieldClassificationIds, flags);
parcel.writeInt(mFlags);
parcel.writeIntArray(mCancelIds);
parcel.writeTypedList(mInlineActions, flags);
parcel.writeInt(mRequestId);
}
@@ -878,14 +849,6 @@ public final class FillResponse implements Parcelable {
final int[] cancelIds = parcel.createIntArray();
builder.setPresentationCancelIds(cancelIds);
final List<InlineAction> inlineActions = parcel.createTypedArrayList(
InlineAction.CREATOR);
if (inlineActions != null) {
for (InlineAction inlineAction : inlineActions) {
builder.addInlineAction(inlineAction);
}
}
final FillResponse response = builder.build();
response.setRequestId(parcel.readInt());

View File

@@ -1,19 +0,0 @@
/*
* 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;

View File

@@ -1,205 +0,0 @@
/*
* 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
}

View File

@@ -40,7 +40,6 @@ import android.os.RemoteException;
import android.os.SystemClock;
import android.service.autofill.Dataset;
import android.service.autofill.FillEventHistory;
import android.service.autofill.InlineAction;
import android.service.autofill.augmented.PresentationParams.SystemPopupPresentationParams;
import android.util.Log;
import android.util.Pair;
@@ -559,10 +558,9 @@ public abstract class AugmentedAutofillService extends Service {
}
}
void reportResult(@Nullable List<Dataset> inlineSuggestionsData,
@Nullable List<InlineAction> inlineActions) {
void reportResult(@Nullable List<Dataset> inlineSuggestionsData) {
try {
mCallback.onSuccess(inlineSuggestionsData, inlineActions);
mCallback.onSuccess(inlineSuggestionsData);
} catch (RemoteException e) {
Log.e(TAG, "Error calling back with the inline suggestions data: " + e);
}

View File

@@ -55,14 +55,14 @@ public final class FillCallback {
if (response == null) {
mProxy.logEvent(AutofillProxy.REPORT_EVENT_NO_RESPONSE);
mProxy.reportResult(/* inlineSuggestionsData */ null, /* inlineActions */null);
mProxy.reportResult(/* inlineSuggestionsData */ null);
return;
}
List<Dataset> inlineSuggestions = response.getInlineSuggestions();
if (inlineSuggestions != null && !inlineSuggestions.isEmpty()) {
mProxy.logEvent(AutofillProxy.REPORT_EVENT_INLINE_RESPONSE);
mProxy.reportResult(inlineSuggestions, response.getInlineActions());
mProxy.reportResult(inlineSuggestions);
return;
}

View File

@@ -21,7 +21,6 @@ import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.os.Bundle;
import android.service.autofill.Dataset;
import android.service.autofill.InlineAction;
import com.android.internal.util.DataClass;
@@ -52,12 +51,6 @@ public final class FillResponse {
@DataClass.PluralOf("inlineSuggestion")
private @Nullable List<Dataset> mInlineSuggestions;
/**
* Defaults to null if no inline actions are provided.
*/
@DataClass.PluralOf("inlineAction")
private @Nullable List<InlineAction> mInlineActions;
/**
* The client state that {@link AugmentedAutofillService} implementation can put anything in to
* identify the request and the response when calling
@@ -73,10 +66,6 @@ public final class FillResponse {
return null;
}
private static List<InlineAction> defaultInlineActions() {
return null;
}
private static Bundle defaultClientState() {
return null;
}
@@ -85,7 +74,6 @@ public final class FillResponse {
/** @hide */
abstract static class BaseBuilder {
abstract FillResponse.Builder addInlineSuggestion(@NonNull Dataset value);
abstract FillResponse.Builder addInlineAction(@NonNull InlineAction value);
}
@@ -107,11 +95,9 @@ public final class FillResponse {
/* package-private */ FillResponse(
@Nullable FillWindow fillWindow,
@Nullable List<Dataset> inlineSuggestions,
@Nullable List<InlineAction> 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
@@ -138,16 +124,6 @@ public final class FillResponse {
return mInlineSuggestions;
}
/**
* Defaults to null if no inline actions are provided.
*
* @hide
*/
@DataClass.Generated.Member
public @Nullable List<InlineAction> getInlineActions() {
return mInlineActions;
}
/**
* The client state that {@link AugmentedAutofillService} implementation can put anything in to
* identify the request and the response when calling
@@ -169,7 +145,6 @@ public final class FillResponse {
private @Nullable FillWindow mFillWindow;
private @Nullable List<Dataset> mInlineSuggestions;
private @Nullable List<InlineAction> mInlineActions;
private @Nullable Bundle mClientState;
private long mBuilderFieldsSet = 0L;
@@ -209,26 +184,6 @@ public final class FillResponse {
return this;
}
/**
* Defaults to null if no inline actions are provided.
*/
@DataClass.Generated.Member
public @NonNull Builder setInlineActions(@NonNull List<InlineAction> value) {
checkNotUsed();
mBuilderFieldsSet |= 0x4;
mInlineActions = value;
return this;
}
/** @see #setInlineActions */
@DataClass.Generated.Member
@Override
@NonNull FillResponse.Builder addInlineAction(@NonNull InlineAction 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
@@ -237,7 +192,7 @@ public final class FillResponse {
@DataClass.Generated.Member
public @NonNull Builder setClientState(@NonNull Bundle value) {
checkNotUsed();
mBuilderFieldsSet |= 0x8;
mBuilderFieldsSet |= 0x4;
mClientState = value;
return this;
}
@@ -245,7 +200,7 @@ public final class FillResponse {
/** Builds the instance. This builder should not be touched after calling this! */
public @NonNull FillResponse build() {
checkNotUsed();
mBuilderFieldsSet |= 0x10; // Mark builder used
mBuilderFieldsSet |= 0x8; // Mark builder used
if ((mBuilderFieldsSet & 0x1) == 0) {
mFillWindow = defaultFillWindow();
@@ -254,21 +209,17 @@ 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 & 0x10) != 0) {
if ((mBuilderFieldsSet & 0x8) != 0) {
throw new IllegalStateException(
"This Builder should not be reused. Use a new Builder instance instead");
}
@@ -276,10 +227,10 @@ public final class FillResponse {
}
@DataClass.Generated(
time = 1583793032373L,
time = 1584480900526L,
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.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 []")
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 []")
@Deprecated
private void __metadata() {}

View File

@@ -20,7 +20,6 @@ import android.os.Bundle;
import android.os.ICancellationSignal;
import android.service.autofill.Dataset;
import android.service.autofill.InlineAction;
import java.util.List;
@@ -31,8 +30,7 @@ import java.util.List;
*/
interface IFillCallback {
void onCancellable(in ICancellationSignal cancellation);
void onSuccess(in @nullable List<Dataset> inlineSuggestionsData,
in @nullable List<InlineAction> inlineActions);
void onSuccess(in @nullable List<Dataset> inlineSuggestionsData);
boolean isCompleted();
void cancel();
}

View File

@@ -37,7 +37,6 @@ import android.os.ICancellationSignal;
import android.os.RemoteException;
import android.os.SystemClock;
import android.service.autofill.Dataset;
import android.service.autofill.InlineAction;
import android.service.autofill.augmented.AugmentedAutofillService;
import android.service.autofill.augmented.IAugmentedAutofillService;
import android.service.autofill.augmented.IFillCallback;
@@ -167,12 +166,12 @@ final class RemoteAugmentedAutofillService
focusedId, focusedValue, requestTime, inlineSuggestionsRequest,
new IFillCallback.Stub() {
@Override
public void onSuccess(@Nullable List<Dataset> inlineSuggestionsData,
@Nullable List<InlineAction> inlineActions) {
public void onSuccess(
@Nullable List<Dataset> inlineSuggestionsData) {
mCallbacks.resetLastResponse();
maybeRequestShowInlineSuggestions(sessionId,
inlineSuggestionsRequest, inlineSuggestionsData,
inlineActions, focusedId, inlineSuggestionsCallback,
focusedId, inlineSuggestionsCallback,
client, onErrorCallback, remoteRenderService);
requestAutofill.complete(null);
}
@@ -237,8 +236,7 @@ final class RemoteAugmentedAutofillService
private void maybeRequestShowInlineSuggestions(int sessionId,
@Nullable InlineSuggestionsRequest request,
@Nullable List<Dataset> inlineSuggestionsData,
@Nullable List<InlineAction> inlineActions, @NonNull AutofillId focusedId,
@Nullable List<Dataset> inlineSuggestionsData, @NonNull AutofillId focusedId,
@Nullable Function<InlineSuggestionsResponse, Boolean> inlineSuggestionsCallback,
@NonNull IAutoFillManagerClient client, @NonNull Runnable onErrorCallback,
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
@@ -251,7 +249,7 @@ final class RemoteAugmentedAutofillService
final InlineSuggestionsResponse inlineSuggestionsResponse =
InlineSuggestionFactory.createAugmentedInlineSuggestionsResponse(
request, inlineSuggestionsData, inlineActions, focusedId,
request, inlineSuggestionsData, focusedId,
dataset -> {
mCallbacks.logAugmentedAutofillSelected(sessionId,
dataset.getId());
@@ -260,8 +258,13 @@ final class RemoteAugmentedAutofillService
final int size = fieldIds.size();
final boolean hideHighlight = size == 1
&& fieldIds.get(0).equals(focusedId);
client.autofill(sessionId, fieldIds, dataset.getFieldValues(),
hideHighlight);
if (dataset.getAuthentication() != null) {
client.startIntentSender(dataset.getAuthentication(),
new Intent());
} else {
client.autofill(sessionId, fieldIds, dataset.getFieldValues(),
hideHighlight);
}
} catch (RemoteException e) {
Slog.w(TAG, "Encounter exception autofilling the values");
}

View File

@@ -2726,8 +2726,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
InlineSuggestionsResponse inlineSuggestionsResponse =
InlineSuggestionFactory.createInlineSuggestionsResponse(
inlineSuggestionsRequest.get(),
response, filterText, response.getInlineActions(), mCurrentViewId,
inlineSuggestionsRequest.get(), response, filterText, mCurrentViewId,
this, () -> {
synchronized (mLock) {
mInlineSuggestionSession.hideInlineSuggestionsUi(mCurrentViewId);

View File

@@ -21,13 +21,11 @@ import static com.android.server.autofill.Helper.sVerbose;
import android.annotation.NonNull;
import android.annotation.Nullable;
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;
@@ -73,8 +71,7 @@ public final class InlineSuggestionFactory {
@Nullable
public static InlineSuggestionsResponse createInlineSuggestionsResponse(
@NonNull InlineSuggestionsRequest request, @NonNull FillResponse response,
@Nullable String filterText, @Nullable List<InlineAction> inlineActions,
@NonNull AutofillId autofillId,
@Nullable String filterText, @NonNull AutofillId autofillId,
@NonNull AutoFillUI.AutoFillUiCallback client, @NonNull Runnable onErrorCallback,
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
if (sDebug) Slog.d(TAG, "createInlineSuggestionsResponse called");
@@ -96,7 +93,7 @@ public final class InlineSuggestionFactory {
final InlinePresentation inlineAuthentication =
response.getAuthentication() == null ? null : response.getInlinePresentation();
return createInlineSuggestionsResponseInternal(/* isAugmented= */ false, request,
response.getDatasets(), filterText, inlineAuthentication, inlineActions, autofillId,
response.getDatasets(), filterText, inlineAuthentication, autofillId,
onErrorCallback, onClickFactory, remoteRenderService);
}
@@ -107,15 +104,14 @@ public final class InlineSuggestionFactory {
@Nullable
public static InlineSuggestionsResponse createAugmentedInlineSuggestionsResponse(
@NonNull InlineSuggestionsRequest request, @NonNull List<Dataset> datasets,
@Nullable List<InlineAction> inlineActions, @NonNull AutofillId autofillId,
@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, onErrorCallback,
(dataset, datasetIndex) ->
autofillId, onErrorCallback, (dataset, datasetIndex) ->
inlineSuggestionUiCallback.autofill(dataset), remoteRenderService);
}
@@ -123,8 +119,7 @@ public final class InlineSuggestionFactory {
private static InlineSuggestionsResponse createInlineSuggestionsResponseInternal(
boolean isAugmented, @NonNull InlineSuggestionsRequest request,
@Nullable List<Dataset> datasets, @Nullable String filterText,
@Nullable InlinePresentation inlineAuthentication,
@Nullable List<InlineAction> inlineActions, @NonNull AutofillId autofillId,
@Nullable InlinePresentation inlineAuthentication, @NonNull AutofillId autofillId,
@NonNull Runnable onErrorCallback, @NonNull BiConsumer<Dataset, Integer> onClickFactory,
@Nullable RemoteInlineSuggestionRenderService remoteRenderService) {
@@ -167,16 +162,6 @@ public final class InlineSuggestionFactory {
inlineSuggestions.add(inlineSuggestion);
}
if (inlineActions != null) {
for (InlineAction inlineAction : inlineActions) {
final InlineSuggestion inlineActionSuggestion = createInlineAction(isAugmented,
mergedInlinePresentation(request, 0, inlineAction.getInlinePresentation()),
inlineAction.getAction(),
remoteRenderService, onErrorCallback, request.getHostInputToken(),
request.getHostDisplayId());
inlineSuggestions.add(inlineActionSuggestion);
}
}
return new InlineSuggestionsResponse(inlineSuggestions);
}
@@ -211,35 +196,6 @@ public final class InlineSuggestionFactory {
return valueText.toLowerCase().startsWith(constraintLowerCase);
}
private static InlineSuggestion createInlineAction(boolean isAugmented,
@NonNull InlinePresentation presentation,
@NonNull IntentSender action,
@Nullable RemoteInlineSuggestionRenderService remoteRenderService,
@NonNull Runnable onErrorCallback, @Nullable IBinder hostInputToken,
int displayId) {
final InlineSuggestionInfo inlineSuggestionInfo = new InlineSuggestionInfo(
presentation.getInlinePresentationSpec(),
isAugmented ? InlineSuggestionInfo.SOURCE_PLATFORM
: InlineSuggestionInfo.SOURCE_AUTOFILL,
presentation.getAutofillHints(), InlineSuggestionInfo.TYPE_ACTION,
presentation.isPinned());
final Runnable onClickAction = () -> {
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(presentation, onClickAction, onErrorCallback,
remoteRenderService, hostInputToken, displayId));
}
private static InlineSuggestion createInlineSuggestion(boolean isAugmented,
@NonNull Dataset dataset, int datasetIndex,
@NonNull InlinePresentation inlinePresentation,
@@ -247,12 +203,15 @@ public final class InlineSuggestionFactory {
@NonNull RemoteInlineSuggestionRenderService remoteRenderService,
@NonNull Runnable onErrorCallback, @Nullable IBinder hostInputToken,
int displayId) {
final String suggestionSource = isAugmented ? InlineSuggestionInfo.SOURCE_PLATFORM
: InlineSuggestionInfo.SOURCE_AUTOFILL;
final String suggestionType =
dataset.getAuthentication() == null ? InlineSuggestionInfo.TYPE_SUGGESTION
: InlineSuggestionInfo.TYPE_ACTION;
final InlineSuggestionInfo inlineSuggestionInfo = new InlineSuggestionInfo(
inlinePresentation.getInlinePresentationSpec(),
isAugmented ? InlineSuggestionInfo.SOURCE_PLATFORM
: InlineSuggestionInfo.SOURCE_AUTOFILL,
inlinePresentation.getAutofillHints(),
InlineSuggestionInfo.TYPE_SUGGESTION, inlinePresentation.isPinned());
inlinePresentation.getInlinePresentationSpec(), suggestionSource,
inlinePresentation.getAutofillHints(), suggestionType,
inlinePresentation.isPinned());
final InlineSuggestion inlineSuggestion = new InlineSuggestion(inlineSuggestionInfo,
createInlineContentProvider(inlinePresentation,
@@ -270,7 +229,7 @@ public final class InlineSuggestionFactory {
final InlineSuggestionInfo inlineSuggestionInfo = new InlineSuggestionInfo(
inlinePresentation.getInlinePresentationSpec(),
InlineSuggestionInfo.SOURCE_AUTOFILL, inlinePresentation.getAutofillHints(),
InlineSuggestionInfo.TYPE_SUGGESTION, inlinePresentation.isPinned());
InlineSuggestionInfo.TYPE_ACTION, inlinePresentation.isPinned());
return new InlineSuggestion(inlineSuggestionInfo,
createInlineContentProvider(inlinePresentation,