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

Commit 855b94d7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add the reason why a save dialog was not shown to FillEventHistory."

parents 6dd5f9c4 5518d647
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -43297,8 +43297,16 @@ package android.service.autofill {
    method @NonNull public java.util.Map<android.view.autofill.AutofillId,android.service.autofill.FieldClassification> getFieldsClassification();
    method @NonNull public java.util.Set<java.lang.String> getIgnoredDatasetIds();
    method @NonNull public java.util.Map<android.view.autofill.AutofillId,java.util.Set<java.lang.String>> getManuallyEnteredField();
    method public int getNoSaveReason();
    method @NonNull public java.util.Set<java.lang.String> getSelectedDatasetIds();
    method public int getType();
    field public static final int NO_SAVE_REASON_DATASET_MATCH = 6; // 0x6
    field public static final int NO_SAVE_REASON_FIELD_VALIDATION_FAILED = 5; // 0x5
    field public static final int NO_SAVE_REASON_HAS_EMPTY_REQUIRED = 3; // 0x3
    field public static final int NO_SAVE_REASON_NONE = 0; // 0x0
    field public static final int NO_SAVE_REASON_NO_SAVE_INFO = 1; // 0x1
    field public static final int NO_SAVE_REASON_NO_VALUE_CHANGED = 4; // 0x4
    field public static final int NO_SAVE_REASON_WITH_DELAY_SAVE_FLAG = 2; // 0x2
    field public static final int TYPE_AUTHENTICATION_SELECTED = 2; // 0x2
    field public static final int TYPE_CONTEXT_COMMITTED = 4; // 0x4
    field public static final int TYPE_DATASETS_SHOWN = 5; // 0x5
+99 −1
Original line number Diff line number Diff line
@@ -159,6 +159,7 @@ public final class FillEventHistory implements Parcelable {
                    FieldClassification.writeArrayToParcel(parcel,
                            event.mDetectedFieldClassifications);
                }
                parcel.writeInt(event.mSaveDialogNotShowReason);
            }
        }
    }
@@ -243,6 +244,40 @@ public final class FillEventHistory implements Parcelable {
        @Retention(RetentionPolicy.SOURCE)
        @interface EventIds{}

        /** No reason for save dialog. */
        public static final int NO_SAVE_REASON_NONE = 0;

        /** The SaveInfo associated with the FillResponse is null. */
        public static final int NO_SAVE_REASON_NO_SAVE_INFO = 1;

        /** The service asked to delay save. */
        public static final int NO_SAVE_REASON_WITH_DELAY_SAVE_FLAG = 2;

        /** There was empty value for required ids. */
        public static final int NO_SAVE_REASON_HAS_EMPTY_REQUIRED = 3;

        /** No value has been changed. */
        public static final int NO_SAVE_REASON_NO_VALUE_CHANGED = 4;

        /** Fields failed validation. */
        public static final int NO_SAVE_REASON_FIELD_VALIDATION_FAILED = 5;

        /** All fields matched contents of datasets. */
        public static final int NO_SAVE_REASON_DATASET_MATCH = 6;

        /** @hide */
        @IntDef(prefix = { "NO_SAVE_REASON_" }, value = {
                NO_SAVE_REASON_NONE,
                NO_SAVE_REASON_NO_SAVE_INFO,
                NO_SAVE_REASON_WITH_DELAY_SAVE_FLAG,
                NO_SAVE_REASON_HAS_EMPTY_REQUIRED,
                NO_SAVE_REASON_NO_VALUE_CHANGED,
                NO_SAVE_REASON_FIELD_VALIDATION_FAILED,
                NO_SAVE_REASON_DATASET_MATCH
        })
        @Retention(RetentionPolicy.SOURCE)
        public @interface NoSaveReason{}

        @EventIds private final int mEventType;
        @Nullable private final String mDatasetId;
        @Nullable private final Bundle mClientState;
@@ -261,6 +296,8 @@ public final class FillEventHistory implements Parcelable {
        @Nullable private final AutofillId[] mDetectedFieldIds;
        @Nullable private final FieldClassification[] mDetectedFieldClassifications;

        @NoSaveReason private final int mSaveDialogNotShowReason;

        /**
         * Returns the type of the event.
         *
@@ -447,6 +484,18 @@ public final class FillEventHistory implements Parcelable {
            return manuallyFilledFields;
        }

        /**
         * Returns the reason why a save dialog was not shown.
         *
         * <p><b>Note: </b>Only set on events of type {@link #TYPE_CONTEXT_COMMITTED}. For the other
         * event types, the reason is set to NO_SAVE_REASON_NONE.
         *
         * @return The reason why a save dialog was not shown.
         */
        public int getNoSaveReason() {
            return mSaveDialogNotShowReason;
        }

        /**
         * Creates a new event.
         *
@@ -481,6 +530,48 @@ public final class FillEventHistory implements Parcelable {
                @Nullable ArrayList<ArrayList<String>> manuallyFilledDatasetIds,
                @Nullable AutofillId[] detectedFieldIds,
                @Nullable FieldClassification[] detectedFieldClassifications) {
            this(eventType, datasetId, clientState, selectedDatasetIds, ignoredDatasetIds,
                    changedFieldIds, changedDatasetIds, manuallyFilledFieldIds,
                    manuallyFilledDatasetIds, detectedFieldIds, detectedFieldClassifications,
                    NO_SAVE_REASON_NONE);
        }

        /**
         * Creates a new event.
         *
         * @param eventType The type of the event
         * @param datasetId The dataset the event was on, or {@code null} if the event was on the
         *                  whole response.
         * @param clientState The client state associated with the event.
         * @param selectedDatasetIds The ids of datasets selected by the user.
         * @param ignoredDatasetIds The ids of datasets NOT select by the user.
         * @param changedFieldIds The ids of fields changed by the user.
         * @param changedDatasetIds The ids of the datasets that havd values matching the
         * respective entry on {@code changedFieldIds}.
         * @param manuallyFilledFieldIds The ids of fields that were manually entered by the user
         * and belonged to datasets.
         * @param manuallyFilledDatasetIds The ids of datasets that had values matching the
         * respective entry on {@code manuallyFilledFieldIds}.
         * @param detectedFieldClassifications the field classification matches.
         * @param saveDialogNotShowReason The reason why a save dialog was not shown.
         *
         * @throws IllegalArgumentException If the length of {@code changedFieldIds} and
         * {@code changedDatasetIds} doesn't match.
         * @throws IllegalArgumentException If the length of {@code manuallyFilledFieldIds} and
         * {@code manuallyFilledDatasetIds} doesn't match.
         *
         * @hide
         */
        public Event(int eventType, @Nullable String datasetId, @Nullable Bundle clientState,
                @Nullable List<String> selectedDatasetIds,
                @Nullable ArraySet<String> ignoredDatasetIds,
                @Nullable ArrayList<AutofillId> changedFieldIds,
                @Nullable ArrayList<String> changedDatasetIds,
                @Nullable ArrayList<AutofillId> manuallyFilledFieldIds,
                @Nullable ArrayList<ArrayList<String>> manuallyFilledDatasetIds,
                @Nullable AutofillId[] detectedFieldIds,
                @Nullable FieldClassification[] detectedFieldClassifications,
                int saveDialogNotShowReason) {
            mEventType = Preconditions.checkArgumentInRange(eventType, 0, TYPE_DATASETS_SHOWN,
                    "eventType");
            mDatasetId = datasetId;
@@ -506,6 +597,10 @@ public final class FillEventHistory implements Parcelable {

            mDetectedFieldIds = detectedFieldIds;
            mDetectedFieldClassifications = detectedFieldClassifications;

            mSaveDialogNotShowReason = Preconditions.checkArgumentInRange(saveDialogNotShowReason,
                    NO_SAVE_REASON_NONE, NO_SAVE_REASON_DATASET_MATCH,
                    "saveDialogNotShowReason");
        }

        @Override
@@ -521,6 +616,7 @@ public final class FillEventHistory implements Parcelable {
                    + ", detectedFieldIds=" + Arrays.toString(mDetectedFieldIds)
                    + ", detectedFieldClassifications ="
                        + Arrays.toString(mDetectedFieldClassifications)
                    + ", saveDialogNotShowReason=" + mSaveDialogNotShowReason
                    + "]";
        }
    }
@@ -562,12 +658,14 @@ public final class FillEventHistory implements Parcelable {
                                (detectedFieldIds != null)
                                ? FieldClassification.readArrayFromParcel(parcel)
                                : null;
                        final int saveDialogNotShowReason = parcel.readInt();

                        selection.addEvent(new Event(eventType, datasetId, clientState,
                                selectedDatasetIds, ignoredDatasets,
                                changedFieldIds, changedDatasetIds,
                                manuallyFilledFieldIds, manuallyFilledDatasetIds,
                                detectedFieldIds, detectedFieldClassifications));
                                detectedFieldIds, detectedFieldClassifications,
                                saveDialogNotShowReason));
                    }
                    return selection;
                }
+8 −0
Original line number Diff line number Diff line
@@ -41431,8 +41431,16 @@ package android.service.autofill {
    method @NonNull public java.util.Map<android.view.autofill.AutofillId,android.service.autofill.FieldClassification> getFieldsClassification();
    method @NonNull public java.util.Set<java.lang.String> getIgnoredDatasetIds();
    method @NonNull public java.util.Map<android.view.autofill.AutofillId,java.util.Set<java.lang.String>> getManuallyEnteredField();
    method public int getNoSaveReason();
    method @NonNull public java.util.Set<java.lang.String> getSelectedDatasetIds();
    method public int getType();
    field public static final int NO_SAVE_REASON_DATASET_MATCH = 6; // 0x6
    field public static final int NO_SAVE_REASON_FIELD_VALIDATION_FAILED = 5; // 0x5
    field public static final int NO_SAVE_REASON_HAS_EMPTY_REQUIRED = 3; // 0x3
    field public static final int NO_SAVE_REASON_NONE = 0; // 0x0
    field public static final int NO_SAVE_REASON_NO_SAVE_INFO = 1; // 0x1
    field public static final int NO_SAVE_REASON_NO_VALUE_CHANGED = 4; // 0x4
    field public static final int NO_SAVE_REASON_WITH_DELAY_SAVE_FLAG = 2; // 0x2
    field public static final int TYPE_AUTHENTICATION_SELECTED = 2; // 0x2
    field public static final int TYPE_CONTEXT_COMMITTED = 4; // 0x4
    field public static final int TYPE_DATASETS_SHOWN = 5; // 0x5
+17 −6
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import android.service.autofill.FieldClassification;
import android.service.autofill.FieldClassification.Match;
import android.service.autofill.FillEventHistory;
import android.service.autofill.FillEventHistory.Event;
import android.service.autofill.FillEventHistory.Event.NoSaveReason;
import android.service.autofill.FillResponse;
import android.service.autofill.IAutoFillService;
import android.service.autofill.InlineSuggestionRenderService;
@@ -429,9 +430,15 @@ final class AutofillManagerServiceImpl
            return;
        }

        session.logContextCommitted();
        final Session.SaveResult saveResult = session.showSaveLocked();

        final boolean finished = session.showSaveLocked();
        session.logContextCommitted(saveResult.getNoSaveReason());

        if (saveResult.isLogSaveShown()) {
            session.logSaveUiShown();
        }

        final boolean finished = saveResult.isRemoveSession();
        if (sVerbose) Slog.v(TAG, "finishSessionLocked(): session finished on save? " + finished);

        if (finished) {
@@ -868,7 +875,9 @@ final class AutofillManagerServiceImpl
            @NonNull ComponentName appComponentName, boolean compatMode) {
        logContextCommittedLocked(sessionId, clientState, selectedDatasets, ignoredDatasets,
                changedFieldIds, changedDatasetIds, manuallyFilledFieldIds,
                manuallyFilledDatasetIds, null, null, appComponentName, compatMode);
                manuallyFilledDatasetIds, /* detectedFieldIdsList= */ null,
                /* detectedFieldClassificationsList= */ null, appComponentName, compatMode,
                Event.NO_SAVE_REASON_NONE);
    }

    @GuardedBy("mLock")
@@ -881,7 +890,8 @@ final class AutofillManagerServiceImpl
            @Nullable ArrayList<ArrayList<String>> manuallyFilledDatasetIds,
            @Nullable ArrayList<AutofillId> detectedFieldIdsList,
            @Nullable ArrayList<FieldClassification> detectedFieldClassificationsList,
            @NonNull ComponentName appComponentName, boolean compatMode) {
            @NonNull ComponentName appComponentName, boolean compatMode,
            @NoSaveReason int saveDialogNotShowReason) {
        if (isValidEventLocked("logDatasetNotSelected()", sessionId)) {
            if (sVerbose) {
                Slog.v(TAG, "logContextCommitted() with FieldClassification: id=" + sessionId
@@ -893,7 +903,8 @@ final class AutofillManagerServiceImpl
                        + ", detectedFieldIds=" + detectedFieldIdsList
                        + ", detectedFieldClassifications=" + detectedFieldClassificationsList
                        + ", appComponentName=" + appComponentName.toShortString()
                        + ", compatMode=" + compatMode);
                        + ", compatMode=" + compatMode
                        + ", saveDialogNotShowReason=" + saveDialogNotShowReason);
            }
            AutofillId[] detectedFieldsIds = null;
            FieldClassification[] detectedFieldClassifications = null;
@@ -929,7 +940,7 @@ final class AutofillManagerServiceImpl
                    clientState, selectedDatasets, ignoredDatasets,
                    changedFieldIds, changedDatasetIds,
                    manuallyFilledFieldIds, manuallyFilledDatasetIds,
                    detectedFieldsIds, detectedFieldClassifications));
                    detectedFieldsIds, detectedFieldClassifications, saveDialogNotShowReason));
        }
    }

+163 −31

File changed.

Preview size limit exceeded, changes collapsed.