Merge "Remove the InlineActions API" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-03-19 01:10:39 +00:00
committed by Android (Google) Code Review
13 changed files with 37 additions and 402 deletions

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();
}