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

Commit 78ab8890 authored by Nikhil Ganta's avatar Nikhil Ganta Committed by Android (Google) Code Review
Browse files

Merge "Include last focused id to each Event in FillEventHistory." into main

parents 3161f3e1 8a285df4
Loading
Loading
Loading
Loading
+22 −7
Original line number Diff line number Diff line
@@ -170,6 +170,9 @@ public final class FillEventHistory implements Parcelable {
                }
                parcel.writeInt(event.mSaveDialogNotShowReason);
                parcel.writeInt(event.mUiType);
                if (Flags.addLastFocusedIdToFillEventHistory()) {
                    parcel.writeParcelable(event.mFocusedId, 0);
                }
            }
        }
    }
@@ -375,6 +378,8 @@ public final class FillEventHistory implements Parcelable {
        @UiType
        private final int mUiType;

        @Nullable private final AutofillId mFocusedId;

        /**
         * Returns the type of the event.
         *
@@ -388,7 +393,7 @@ public final class FillEventHistory implements Parcelable {
        @FlaggedApi(FLAG_AUTOFILL_W_METRICS)
        @Nullable
        public AutofillId getFocusedId() {
            return null;
            return mFocusedId;
        }

        /**
@@ -624,6 +629,7 @@ public final class FillEventHistory implements Parcelable {
         * @param manuallyFilledDatasetIds The ids of datasets that had values matching the
         * respective entry on {@code manuallyFilledFieldIds}.
         * @param detectedFieldClassifications the field classification matches.
         * @param focusedId the field which was focused at the time of event trigger
         *
         * @throws IllegalArgumentException If the length of {@code changedFieldIds} and
         * {@code changedDatasetIds} doesn't match.
@@ -640,11 +646,12 @@ public final class FillEventHistory implements Parcelable {
                @Nullable ArrayList<AutofillId> manuallyFilledFieldIds,
                @Nullable ArrayList<ArrayList<String>> manuallyFilledDatasetIds,
                @Nullable AutofillId[] detectedFieldIds,
                @Nullable FieldClassification[] detectedFieldClassifications) {
                @Nullable FieldClassification[] detectedFieldClassifications,
                @Nullable AutofillId focusedId) {
            this(eventType, datasetId, clientState, selectedDatasetIds, ignoredDatasetIds,
                    changedFieldIds, changedDatasetIds, manuallyFilledFieldIds,
                    manuallyFilledDatasetIds, detectedFieldIds, detectedFieldClassifications,
                    NO_SAVE_UI_REASON_NONE);
                    NO_SAVE_UI_REASON_NONE, focusedId);
        }

        /**
@@ -665,6 +672,7 @@ public final class FillEventHistory implements Parcelable {
         * respective entry on {@code manuallyFilledFieldIds}.
         * @param detectedFieldClassifications the field classification matches.
         * @param saveDialogNotShowReason The reason why a save dialog was not shown.
         * @param focusedId the field which was focused at the time of event trigger
         *
         * @throws IllegalArgumentException If the length of {@code changedFieldIds} and
         * {@code changedDatasetIds} doesn't match.
@@ -682,11 +690,12 @@ public final class FillEventHistory implements Parcelable {
                @Nullable ArrayList<ArrayList<String>> manuallyFilledDatasetIds,
                @Nullable AutofillId[] detectedFieldIds,
                @Nullable FieldClassification[] detectedFieldClassifications,
                int saveDialogNotShowReason) {
                int saveDialogNotShowReason,
                @Nullable AutofillId focusedId) {
            this(eventType, datasetId, clientState, selectedDatasetIds, ignoredDatasetIds,
                    changedFieldIds, changedDatasetIds, manuallyFilledFieldIds,
                    manuallyFilledDatasetIds, detectedFieldIds, detectedFieldClassifications,
                    saveDialogNotShowReason, UI_TYPE_UNKNOWN);
                    saveDialogNotShowReason, UI_TYPE_UNKNOWN, focusedId);
        }

        /**
@@ -708,6 +717,7 @@ public final class FillEventHistory implements Parcelable {
         * @param detectedFieldClassifications the field classification matches.
         * @param saveDialogNotShowReason The reason why a save dialog was not shown.
         * @param uiType The ui presentation type for fill suggestion.
         * @param focusedId the field which was focused at the time of event trigger
         *
         * @throws IllegalArgumentException If the length of {@code changedFieldIds} and
         * {@code changedDatasetIds} doesn't match.
@@ -725,7 +735,7 @@ public final class FillEventHistory implements Parcelable {
                @Nullable ArrayList<ArrayList<String>> manuallyFilledDatasetIds,
                @Nullable AutofillId[] detectedFieldIds,
                @Nullable FieldClassification[] detectedFieldClassifications,
                int saveDialogNotShowReason, int uiType) {
                int saveDialogNotShowReason, int uiType, @Nullable AutofillId focusedId) {
            mEventType = Preconditions.checkArgumentInRange(eventType, 0,
                    TYPE_VIEW_REQUESTED_AUTOFILL, "eventType");
            mDatasetId = datasetId;
@@ -756,6 +766,7 @@ public final class FillEventHistory implements Parcelable {
                    NO_SAVE_UI_REASON_NONE, NO_SAVE_UI_REASON_DATASET_MATCH,
                    "saveDialogNotShowReason");
            mUiType = uiType;
            mFocusedId = focusedId;
        }

        @Override
@@ -852,13 +863,17 @@ public final class FillEventHistory implements Parcelable {
                                : null;
                        final int saveDialogNotShowReason = parcel.readInt();
                        final int uiType = parcel.readInt();
                        AutofillId focusedId = null;
                        if (Flags.addLastFocusedIdToFillEventHistory()) {
                            focusedId = parcel.readParcelable(null, AutofillId.class);
                        }

                        selection.addEvent(new Event(eventType, datasetId, clientState,
                                selectedDatasetIds, ignoredDatasets,
                                changedFieldIds, changedDatasetIds,
                                manuallyFilledFieldIds, manuallyFilledDatasetIds,
                                detectedFieldIds, detectedFieldClassifications,
                                saveDialogNotShowReason, uiType));
                                saveDialogNotShowReason, uiType, focusedId));
                    }
                    return selection;
                }
+7 −0
Original line number Diff line number Diff line
@@ -37,3 +37,10 @@ flag {
    description: "Improvements for Fill Dialog, including deprecation of pre-trigger API's"
    bug: "336223371"
}

flag {
  name: "add_last_focused_id_to_fill_event_history"
  namespace: "autofill"
  description: "Adds focused id to each event that's part of the fill event history"
  bug: "334141398"
}
+19 −15
Original line number Diff line number Diff line
@@ -900,13 +900,13 @@ final class AutofillManagerServiceImpl
     * Updates the last fill selection when an authentication was selected.
     */
    void setAuthenticationSelected(int sessionId, @Nullable Bundle clientState,
            int uiType) {
            int uiType, @Nullable AutofillId focusedId) {
        synchronized (mLock) {
            if (isValidEventLocked("setAuthenticationSelected()", sessionId)) {
                mEventHistory.addEvent(
                        new Event(Event.TYPE_AUTHENTICATION_SELECTED, null, clientState, null, null,
                                null, null, null, null, null, null,
                                NO_SAVE_UI_REASON_NONE, uiType));
                                NO_SAVE_UI_REASON_NONE, uiType, focusedId));
            }
        }
    }
@@ -915,13 +915,13 @@ final class AutofillManagerServiceImpl
     * Updates the last fill selection when an dataset authentication was selected.
     */
    void logDatasetAuthenticationSelected(@Nullable String selectedDataset, int sessionId,
            @Nullable Bundle clientState, int uiType) {
            @Nullable Bundle clientState, int uiType, @Nullable AutofillId focusedId) {
        synchronized (mLock) {
            if (isValidEventLocked("logDatasetAuthenticationSelected()", sessionId)) {
                mEventHistory.addEvent(
                        new Event(Event.TYPE_DATASET_AUTHENTICATION_SELECTED, selectedDataset,
                                clientState, null, null, null, null, null, null, null, null,
                                NO_SAVE_UI_REASON_NONE, uiType));
                                NO_SAVE_UI_REASON_NONE, uiType, focusedId));
            }
        }
    }
@@ -933,7 +933,7 @@ final class AutofillManagerServiceImpl
        synchronized (mLock) {
            if (isValidEventLocked("logSaveShown()", sessionId)) {
                mEventHistory.addEvent(new Event(Event.TYPE_SAVE_SHOWN, null, clientState, null,
                        null, null, null, null, null, null, null));
                        null, null, null, null, null, null, null, /* focusedId= */ null));
            }
        }
    }
@@ -942,13 +942,13 @@ final class AutofillManagerServiceImpl
     * Updates the last fill response when a dataset was selected.
     */
    void logDatasetSelected(@Nullable String selectedDataset, int sessionId,
            @Nullable Bundle clientState,  int uiType) {
            @Nullable Bundle clientState,  int uiType, @Nullable AutofillId focusedId) {
        synchronized (mLock) {
            if (isValidEventLocked("logDatasetSelected()", sessionId)) {
                mEventHistory.addEvent(
                        new Event(Event.TYPE_DATASET_SELECTED, selectedDataset, clientState, null,
                                null, null, null, null, null, null, null, NO_SAVE_UI_REASON_NONE,
                                uiType));
                                uiType, focusedId));
            }
        }
    }
@@ -956,13 +956,14 @@ final class AutofillManagerServiceImpl
    /**
     * Updates the last fill response when a dataset is shown.
     */
    void logDatasetShown(int sessionId, @Nullable Bundle clientState, int uiType) {
    void logDatasetShown(int sessionId, @Nullable Bundle clientState, int uiType,
            @Nullable AutofillId focusedId) {
        synchronized (mLock) {
            if (isValidEventLocked("logDatasetShown", sessionId)) {
                mEventHistory.addEvent(
                        new Event(Event.TYPE_DATASETS_SHOWN, null, clientState, null, null, null,
                                null, null, null, null, null, NO_SAVE_UI_REASON_NONE,
                                uiType));
                                uiType, focusedId));
            }
        }
    }
@@ -970,7 +971,8 @@ final class AutofillManagerServiceImpl
    /**
     * Updates the last fill response when a view was entered.
     */
    void logViewEntered(int sessionId, @Nullable Bundle clientState) {
    void logViewEntered(int sessionId, @Nullable Bundle clientState,
            @Nullable AutofillId focusedId) {
        synchronized (mLock) {
            if (!isValidEventLocked("logViewEntered", sessionId)) {
                return;
@@ -988,7 +990,7 @@ final class AutofillManagerServiceImpl

            mEventHistory.addEvent(
                    new Event(Event.TYPE_VIEW_REQUESTED_AUTOFILL, null, clientState, null,
                            null, null, null, null, null, null, null));
                            null, null, null, null, null, null, null, focusedId));
        }
    }

@@ -1001,7 +1003,8 @@ final class AutofillManagerServiceImpl
            }
            mAugmentedAutofillEventHistory.addEvent(
                    new Event(Event.TYPE_DATASET_AUTHENTICATION_SELECTED, selectedDataset,
                            clientState, null, null, null, null, null, null, null, null));
                            clientState, null, null, null, null, null, null, null, null,
                            /* focusedId= */ null));
        }
    }

@@ -1014,7 +1017,7 @@ final class AutofillManagerServiceImpl
            }
            mAugmentedAutofillEventHistory.addEvent(
                    new Event(Event.TYPE_DATASET_SELECTED, suggestionId, clientState, null, null,
                            null, null, null, null, null, null));
                            null, null, null, null, null, null, /* focusedId= */ null));
        }
    }

@@ -1029,7 +1032,7 @@ final class AutofillManagerServiceImpl
            mAugmentedAutofillEventHistory.addEvent(
                    new Event(Event.TYPE_DATASETS_SHOWN, null, clientState, null, null, null,
                            null, null, null, null, null, NO_SAVE_UI_REASON_NONE,
                            UI_TYPE_INLINE));
                            UI_TYPE_INLINE, /* focusedId= */ null));

        }
    }
@@ -1113,7 +1116,8 @@ final class AutofillManagerServiceImpl
                    clientState, selectedDatasets, ignoredDatasets,
                    changedFieldIds, changedDatasetIds,
                    manuallyFilledFieldIds, manuallyFilledDatasetIds,
                    detectedFieldsIds, detectedFieldClassifications, saveDialogNotShowReason));
                    detectedFieldsIds, detectedFieldClassifications, saveDialogNotShowReason,
                    /* focusedId= */ null));
        }
    }

+9 −7
Original line number Diff line number Diff line
@@ -1871,7 +1871,7 @@ final class Session

            if (mLogViewEntered) {
                mLogViewEntered = false;
                mService.logViewEntered(id, null);
                mService.logViewEntered(id, null, mCurrentViewId);
            }
        }

@@ -2775,9 +2775,9 @@ final class Session
                forceRemoveFromServiceLocked();
                return;
            }
            mService.setAuthenticationSelected(id, mClientState, uiType, mCurrentViewId);
        }

        mService.setAuthenticationSelected(id, mClientState, uiType);

        final int authenticationId = AutofillManager.makeAuthenticationId(requestId, datasetIndex);
        mHandler.sendMessage(
@@ -2850,7 +2850,7 @@ final class Session
                if (!mLoggedInlineDatasetShown) {
                    // Chip inflation already logged, do not log again.
                    // This is needed because every chip inflation will call this.
                    mService.logDatasetShown(this.id, mClientState, uiType);
                    mService.logDatasetShown(this.id, mClientState, uiType, mCurrentViewId);
                    Slog.d(TAG, "onShown(): " + uiType + ", " + numDatasetsShown);
                }
                mLoggedInlineDatasetShown = true;
@@ -2858,7 +2858,7 @@ final class Session
                mPresentationStatsEventLogger.logWhenDatasetShown(numDatasetsShown);
                // Explicitly sets maybeSetSuggestionPresentedTimestampMs
                mPresentationStatsEventLogger.maybeSetSuggestionPresentedTimestampMs();
                mService.logDatasetShown(this.id, mClientState, uiType);
                mService.logDatasetShown(this.id, mClientState, uiType, mCurrentViewId);
                Slog.d(TAG, "onShown(): " + uiType + ", " + numDatasetsShown);
            }
        }
@@ -5139,7 +5139,7 @@ final class Session
                        // so this calling logViewEntered will be a nop.
                        // Calling logViewEntered() twice will only log it once
                        // TODO(271181979): this is broken for multiple partitions
                        mService.logViewEntered(this.id, null);
                        mService.logViewEntered(this.id, null, mCurrentViewId);
                    }

                    // If this is the first time view is entered for inline, the last
@@ -6657,7 +6657,8 @@ final class Session
            // Autofill it directly...
            if (dataset.getAuthentication() == null) {
                if (generateEvent) {
                    mService.logDatasetSelected(dataset.getId(), id, mClientState, uiType);
                    mService.logDatasetSelected(dataset.getId(), id, mClientState, uiType,
                            mCurrentViewId);
                }
                if (mCurrentViewId != null) {
                    mInlineSessionController.hideInlineSuggestionsUiLocked(mCurrentViewId);
@@ -6667,7 +6668,8 @@ final class Session
            }

            // ...or handle authentication.
            mService.logDatasetAuthenticationSelected(dataset.getId(), id, mClientState, uiType);
            mService.logDatasetAuthenticationSelected(dataset.getId(), id, mClientState, uiType,
                        mCurrentViewId);
            mPresentationStatsEventLogger.maybeSetAuthenticationType(
                    AUTHENTICATION_TYPE_DATASET_AUTHENTICATION);
            // does not matter the value of isPrimary because null response won't be overridden.