Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c67328c authored by Simranjit Kohli's avatar Simranjit Kohli Committed by Automerger Merge Worker
Browse files

Merge "[Autofill PCC]: Fix Dataset creation from parcel. When creating Dataset...

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: 3c5860c8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21933819



Change-Id: I69c5d4b84b18c839a29fe9f95f197c9fd3c656db
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 0f4ed93e 3c5860c8
Loading
Loading
Loading
Loading
+44 −31
Original line number Diff line number Diff line
@@ -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,25 +1421,9 @@ 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 String datatype = autofillDatatypes.get(i);
                final AutofillValue value = values.get(i);
                final RemoteViews fieldPresentation = presentations.get(i);
                final RemoteViews fieldDialogPresentation = dialogPresentations.get(i);
@@ -1418,11 +1432,10 @@ public final class Dataset implements Parcelable {
                final InlinePresentation fieldInlineTooltipPresentation =
                        i < inlinePresentationsSize ? inlineTooltipPresentations.get(i) : null;
                final DatasetFieldFilter filter = filters.get(i);
                    builder.setLifeTheUniverseAndEverything(id, value, fieldPresentation,
                builder.createFromParcel(id, datatype, value, fieldPresentation,
                        fieldInlinePresentation, fieldInlineTooltipPresentation, filter,
                        fieldDialogPresentation);
            }
            }
            builder.setAuthentication(authentication);
            builder.setId(datasetId);
            Dataset dataset = builder.build();
+9 −5
Original line number Diff line number Diff line
@@ -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,10 +2948,12 @@ public final class AutofillManager {
                        mFillableIds = new ArraySet<>(fillableIds.length);
                    }
                    for (AutofillId id : fillableIds) {
                        if (id != null) {
                            id.resetSessionId();
                            mFillableIds.add(id);
                        }
                    }
                }

                if (mSaveTriggerId != null && !mSaveTriggerId.equals(saveTriggerId)) {
                    // Turn off trigger on previous view id.
@@ -2974,10 +2976,12 @@ public final class AutofillManager {
                }
                if (trackedIds != null) {
                    for (AutofillId id : trackedIds) {
                        if (id != null) {
                            id.resetSessionId();
                            allFillableIds.add(id);
                        }
                    }
                }

                if (!allFillableIds.isEmpty()) {
                    mTrackedViews = new TrackedViews(trackedIds, Helper.toArray(allFillableIds));
+4 −2
Original line number Diff line number Diff line
@@ -4351,12 +4351,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState

                for (int j = 0; j < fieldIds.size(); j++) {
                    final AutofillId id = fieldIds.get(j);
                    if (id != null) {
                        if (trackedViews == null || !trackedViews.contains(id)) {
                            fillableIds = ArrayUtils.add(fillableIds, id);
                        }
                    }
                }
            }
        }

        try {
            if (sVerbose) {