Merge "Implemented FillResponse.setIgnoredIds()." into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
bb21986b33
@@ -137,6 +137,7 @@ public final class FillResponse implements Parcelable {
|
||||
private final @Nullable RemoteViews mPresentation;
|
||||
private final @Nullable IntentSender mAuthentication;
|
||||
private final @Nullable AutofillId[] mAuthenticationIds;
|
||||
private final @Nullable AutofillId[] mIgnoredIds;
|
||||
|
||||
private FillResponse(@NonNull Builder builder) {
|
||||
mDatasets = builder.mDatasets;
|
||||
@@ -145,6 +146,7 @@ public final class FillResponse implements Parcelable {
|
||||
mPresentation = builder.mPresentation;
|
||||
mAuthentication = builder.mAuthentication;
|
||||
mAuthenticationIds = builder.mAuthenticationIds;
|
||||
mIgnoredIds = builder.mIgnoredIds;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@@ -177,6 +179,11 @@ public final class FillResponse implements Parcelable {
|
||||
return mAuthenticationIds;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public @Nullable AutofillId[] getIgnoredIds() {
|
||||
return mIgnoredIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder for {@link FillResponse} objects. You must to provide at least
|
||||
* one dataset or set an authentication intent with a presentation view.
|
||||
@@ -188,6 +195,7 @@ public final class FillResponse implements Parcelable {
|
||||
private RemoteViews mPresentation;
|
||||
private IntentSender mAuthentication;
|
||||
private AutofillId[] mAuthenticationIds;
|
||||
private AutofillId[] mIgnoredIds;
|
||||
private boolean mDestroyed;
|
||||
|
||||
/**
|
||||
@@ -265,7 +273,7 @@ public final class FillResponse implements Parcelable {
|
||||
* {@code EditText} representing a captcha.
|
||||
*/
|
||||
public Builder setIgnoredIds(AutofillId...ids) {
|
||||
// TODO: implement
|
||||
mIgnoredIds = ids;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -374,6 +382,8 @@ public final class FillResponse implements Parcelable {
|
||||
.append(", hasAuthentication=").append(mAuthentication != null)
|
||||
.append(", authenticationSize=").append(mAuthenticationIds != null
|
||||
? mAuthenticationIds.length : "N/A")
|
||||
.append(", ignoredIdsSize=").append(mIgnoredIds != null
|
||||
? mIgnoredIds.length : "N/A")
|
||||
.toString();
|
||||
}
|
||||
|
||||
@@ -394,6 +404,7 @@ public final class FillResponse implements Parcelable {
|
||||
parcel.writeParcelableArray(mAuthenticationIds, flags);
|
||||
parcel.writeParcelable(mAuthentication, flags);
|
||||
parcel.writeParcelable(mPresentation, flags);
|
||||
parcel.writeParcelableArray(mIgnoredIds, flags);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<FillResponse> CREATOR =
|
||||
@@ -410,9 +421,10 @@ public final class FillResponse implements Parcelable {
|
||||
builder.addDataset(datasets.get(i));
|
||||
}
|
||||
builder.setSaveInfo(parcel.readParcelable(null));
|
||||
builder.setExtras(parcel.readParcelable(null));
|
||||
builder.setClientState(parcel.readParcelable(null));
|
||||
builder.setAuthentication(parcel.readParcelableArray(null, AutofillId.class),
|
||||
parcel.readParcelable(null), parcel.readParcelable(null));
|
||||
builder.setIgnoredIds(parcel.readParcelableArray(null, AutofillId.class));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ import com.android.server.autofill.ui.AutoFillUI;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -602,7 +603,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
final int lastResponseIdx = getLastResponseIndex();
|
||||
final int requestId = mResponses.keyAt(lastResponseIdx);
|
||||
final FillContext fillContext = new FillContext(requestId, mStructure);
|
||||
final ArrayList fillContexts = new ArrayList(1);
|
||||
final ArrayList<FillContext> fillContexts = new ArrayList<>(1);
|
||||
fillContexts.add(fillContext);
|
||||
|
||||
final SaveRequest saveRequest = new SaveRequest(fillContexts, mClientState);
|
||||
@@ -620,6 +621,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
viewState = new ViewState(this, id, value, this, ViewState.STATE_INITIAL);
|
||||
mViewStates.put(id, viewState);
|
||||
} else if (mStructure != null && (flags & FLAG_VIEW_ENTERED) != 0) {
|
||||
if (isIgnoredLocked(id)) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "Not starting partition for ignored view id " + id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
viewState = startPartitionLocked(id, value);
|
||||
} else {
|
||||
if (VERBOSE) Slog.v(TAG, "Ignored " + getFlagAsString(flags) + " for " + id);
|
||||
@@ -931,6 +938,23 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isIgnoredLocked(@NonNull AutofillId id) {
|
||||
if (mResponses == null) return false;
|
||||
|
||||
for (int i = mResponses.size() - 1; i >= 0; i--) {
|
||||
final FillResponse response = mResponses.valueAt(i);
|
||||
final AutofillId[] ignoredIds = response.getIgnoredIds();
|
||||
if (ignoredIds == null) continue;
|
||||
for (int j = 0; j < ignoredIds.length; j++) {
|
||||
final AutofillId ignoredId = ignoredIds[j];
|
||||
if (ignoredId != null && ignoredId.equals(id)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void dumpLocked(String prefix, PrintWriter pw) {
|
||||
pw.print(prefix); pw.print("id: "); pw.println(id);
|
||||
pw.print(prefix); pw.print("uid: "); pw.println(uid);
|
||||
|
||||
Reference in New Issue
Block a user