Merge "[Autofill PCC]: Fix Dataset creation from parcel. When creating Dataset from parcel, it's possible to have null values in ids and datatypes. This was causing crash. This CL fixes that. Test: atest android.autofillservice.cts.unittests.DatasetTest Manually tested regular flows. Bug: 272405954" into udc-dev am: 3c5860c89d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21933819 Change-Id: I69c5d4b84b18c839a29fe9f95f197c9fd3c656db Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1260,6 +1260,36 @@ public final class Dataset implements Parcelable {
|
||||
return mFieldIds.size() - 1;
|
||||
}
|
||||
|
||||
private void createFromParcel(
|
||||
@Nullable AutofillId id, @Nullable String datatype,
|
||||
@Nullable AutofillValue value, @Nullable RemoteViews presentation,
|
||||
@Nullable InlinePresentation inlinePresentation,
|
||||
@Nullable InlinePresentation tooltip,
|
||||
@Nullable DatasetFieldFilter filter,
|
||||
@Nullable RemoteViews dialogPresentation) {
|
||||
if (id != null) {
|
||||
final int existingIdx = mFieldIds.indexOf(id);
|
||||
if (existingIdx >= 0) {
|
||||
mFieldValues.set(existingIdx, value);
|
||||
mFieldPresentations.set(existingIdx, presentation);
|
||||
mFieldDialogPresentations.set(existingIdx, dialogPresentation);
|
||||
mFieldInlinePresentations.set(existingIdx, inlinePresentation);
|
||||
mFieldInlineTooltipPresentations.set(existingIdx, tooltip);
|
||||
mFieldFilters.set(existingIdx, filter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
mFieldIds.add(id);
|
||||
mAutofillDatatypes.add(datatype);
|
||||
mFieldValues.add(value);
|
||||
mFieldPresentations.add(presentation);
|
||||
mFieldDialogPresentations.add(dialogPresentation);
|
||||
mFieldInlinePresentations.add(inlinePresentation);
|
||||
mFieldInlineTooltipPresentations.add(tooltip);
|
||||
mFieldFilters.add(filter);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Dataset} instance.
|
||||
*
|
||||
@@ -1391,37 +1421,20 @@ public final class Dataset implements Parcelable {
|
||||
builder.setContent(ids.get(0), fieldContent);
|
||||
}
|
||||
final int inlinePresentationsSize = inlinePresentations.size();
|
||||
|
||||
if (ids.size() == 0 && autofillDatatypes.size() > 0) {
|
||||
for (int i = 0; i < autofillDatatypes.size(); i++) {
|
||||
final String datatype = autofillDatatypes.get(i);
|
||||
final AutofillValue value = values.get(i);
|
||||
final RemoteViews fieldPresentation = presentations.get(i);
|
||||
final RemoteViews fieldDialogPresentation = dialogPresentations.get(i);
|
||||
final InlinePresentation fieldInlinePresentation =
|
||||
i < inlinePresentationsSize ? inlinePresentations.get(i) : null;
|
||||
final InlinePresentation fieldInlineTooltipPresentation =
|
||||
i < inlinePresentationsSize ? inlineTooltipPresentations.get(i) : null;
|
||||
final DatasetFieldFilter filter = filters.get(i);
|
||||
builder.setLifeTheUniverseAndEverything(
|
||||
datatype, value, fieldPresentation, fieldInlinePresentation,
|
||||
fieldInlineTooltipPresentation, filter, fieldDialogPresentation);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < ids.size(); i++) {
|
||||
final AutofillId id = ids.get(i);
|
||||
final AutofillValue value = values.get(i);
|
||||
final RemoteViews fieldPresentation = presentations.get(i);
|
||||
final RemoteViews fieldDialogPresentation = dialogPresentations.get(i);
|
||||
final InlinePresentation fieldInlinePresentation =
|
||||
i < inlinePresentationsSize ? inlinePresentations.get(i) : null;
|
||||
final InlinePresentation fieldInlineTooltipPresentation =
|
||||
i < inlinePresentationsSize ? inlineTooltipPresentations.get(i) : null;
|
||||
final DatasetFieldFilter filter = filters.get(i);
|
||||
builder.setLifeTheUniverseAndEverything(id, value, fieldPresentation,
|
||||
fieldInlinePresentation, fieldInlineTooltipPresentation, filter,
|
||||
fieldDialogPresentation);
|
||||
}
|
||||
for (int i = 0; i < ids.size(); i++) {
|
||||
final AutofillId id = ids.get(i);
|
||||
final String datatype = autofillDatatypes.get(i);
|
||||
final AutofillValue value = values.get(i);
|
||||
final RemoteViews fieldPresentation = presentations.get(i);
|
||||
final RemoteViews fieldDialogPresentation = dialogPresentations.get(i);
|
||||
final InlinePresentation fieldInlinePresentation =
|
||||
i < inlinePresentationsSize ? inlinePresentations.get(i) : null;
|
||||
final InlinePresentation fieldInlineTooltipPresentation =
|
||||
i < inlinePresentationsSize ? inlineTooltipPresentations.get(i) : null;
|
||||
final DatasetFieldFilter filter = filters.get(i);
|
||||
builder.createFromParcel(id, datatype, value, fieldPresentation,
|
||||
fieldInlinePresentation, fieldInlineTooltipPresentation, filter,
|
||||
fieldDialogPresentation);
|
||||
}
|
||||
builder.setAuthentication(authentication);
|
||||
builder.setId(datasetId);
|
||||
|
||||
@@ -1643,7 +1643,7 @@ public final class AutofillManager {
|
||||
mForAugmentedAutofillOnly = false;
|
||||
}
|
||||
|
||||
if ((flags & FLAG_SUPPORTS_FILL_DIALOG) != 0) {
|
||||
if ((flags & FLAG_SUPPORTS_FILL_DIALOG) != 0 && view != null) {
|
||||
flags |= FLAG_RESET_FILL_DIALOG_STATE;
|
||||
}
|
||||
|
||||
@@ -2948,8 +2948,10 @@ public final class AutofillManager {
|
||||
mFillableIds = new ArraySet<>(fillableIds.length);
|
||||
}
|
||||
for (AutofillId id : fillableIds) {
|
||||
id.resetSessionId();
|
||||
mFillableIds.add(id);
|
||||
if (id != null) {
|
||||
id.resetSessionId();
|
||||
mFillableIds.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2974,8 +2976,10 @@ public final class AutofillManager {
|
||||
}
|
||||
if (trackedIds != null) {
|
||||
for (AutofillId id : trackedIds) {
|
||||
id.resetSessionId();
|
||||
allFillableIds.add(id);
|
||||
if (id != null) {
|
||||
id.resetSessionId();
|
||||
allFillableIds.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4351,8 +4351,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
|
||||
for (int j = 0; j < fieldIds.size(); j++) {
|
||||
final AutofillId id = fieldIds.get(j);
|
||||
if (trackedViews == null || !trackedViews.contains(id)) {
|
||||
fillableIds = ArrayUtils.add(fillableIds, id);
|
||||
if (id != null) {
|
||||
if (trackedViews == null || !trackedViews.contains(id)) {
|
||||
fillableIds = ArrayUtils.add(fillableIds, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user