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

Commit df6ef44b authored by Tim Yu's avatar Tim Yu
Browse files

Autofill Presentation Logs 2

Add user interaction timestamps

Fixes: 339531513
Fixes: 339532416

Test: n/a, logging only change
Change-Id: I4e9dccd6e0f4f24ba732b93677004c32cf229e16
parent aa9ec856
Loading
Loading
Loading
Loading
+94 −21
Original line number Original line Diff line number Diff line
@@ -212,8 +212,10 @@ public final class PresentationStatsEventLogger {
            AUTOFILL_FILL_RESPONSE_REPORTED__DETECTION_PREFERENCE__DETECTION_PREFER_AUTOFILL_PROVIDER;
            AUTOFILL_FILL_RESPONSE_REPORTED__DETECTION_PREFERENCE__DETECTION_PREFER_AUTOFILL_PROVIDER;
    public static final int DETECTION_PREFER_PCC =
    public static final int DETECTION_PREFER_PCC =
            AUTOFILL_FILL_RESPONSE_REPORTED__DETECTION_PREFERENCE__DETECTION_PREFER_PCC;
            AUTOFILL_FILL_RESPONSE_REPORTED__DETECTION_PREFERENCE__DETECTION_PREFER_PCC;
    private final int mSessionId;


    private static final int DEFAULT_VALUE_INT = -1;

    private final int mSessionId;
    /**
    /**
     * For app_package_uid.
     * For app_package_uid.
     */
     */
@@ -399,7 +401,12 @@ public final class PresentationStatsEventLogger {


    public void maybeSetSuggestionPresentedTimestampMs(int timestamp) {
    public void maybeSetSuggestionPresentedTimestampMs(int timestamp) {
        mEventInternal.ifPresent(event -> {
        mEventInternal.ifPresent(event -> {
            // mSuggestionPresentedTimestampMs only tracks the first suggested timestamp.
            if (event.mSuggestionPresentedTimestampMs == DEFAULT_VALUE_INT) {
                event.mSuggestionPresentedTimestampMs = timestamp;
                event.mSuggestionPresentedTimestampMs = timestamp;
            }

            event.mSuggestionPresentedLastTimestampMs = timestamp;
        });
        });
    }
    }


@@ -411,6 +418,7 @@ public final class PresentationStatsEventLogger {
        mEventInternal.ifPresent(event -> {
        mEventInternal.ifPresent(event -> {
            event.mSelectedDatasetId = selectedDatasetId;
            event.mSelectedDatasetId = selectedDatasetId;
        });
        });
        setPresentationSelectedTimestamp();
    }
    }


    public void maybeSetDialogDismissed(boolean dialogDismissed) {
    public void maybeSetDialogDismissed(boolean dialogDismissed) {
@@ -553,6 +561,45 @@ public final class PresentationStatsEventLogger {
        });
        });
    }
    }


    /**
     * Set various timestamps whenever the ViewState is modified
     *
     * <p>If the ViewState contains ViewState.STATE_AUTOFILLED, sets field_autofilled_timestamp_ms
     * else, set field_first_modified_timestamp_ms (if unset) and field_last_modified_timestamp_ms
     */
    public void onFieldTextUpdated(ViewState state) {
        mEventInternal.ifPresent(
                event -> {
                    int timestamp = getElapsedTime();
                    // Focused id should be set before this is called
                    if (state.id != null && state.id.getViewId() != event.mFocusedId) {
                        // if these don't match, the currently field different than before
                        Slog.w(
                                TAG,
                                "current id: "
                                        + state.id.getViewId()
                                        + " is different than focused id: "
                                        + event.mFocusedId);
                        return;
                    }

                    if ((state.getState() & ViewState.STATE_AUTOFILLED) != 0) {
                        event.mAutofilledTimestampMs = timestamp;
                    } else {
                        if (event.mFieldModifiedFirstTimestampMs == DEFAULT_VALUE_INT) {
                            event.mFieldModifiedFirstTimestampMs = timestamp;
                        }
                        event.mFieldModifiedLastTimestampMs = timestamp;
                    }
                });
    }

    public void setPresentationSelectedTimestamp() {
        mEventInternal.ifPresent(event -> {
            event.mSelectionTimestamp = getElapsedTime();
        });
    }

    /**
    /**
     * Returns timestamp (relative to mSessionStartTimestamp)
     * Returns timestamp (relative to mSessionStartTimestamp)
     */
     */
@@ -685,7 +732,17 @@ public final class PresentationStatsEventLogger {
                    + " mViewFillFailureCount=" + event.mViewFillFailureCount
                    + " mViewFillFailureCount=" + event.mViewFillFailureCount
                    + " mFocusedId=" + event.mFocusedId
                    + " mFocusedId=" + event.mFocusedId
                    + " mViewFillSuccessCount=" + event.mViewFillSuccessCount
                    + " mViewFillSuccessCount=" + event.mViewFillSuccessCount
                    + " mViewFilledButUnexpectedCount=" + event.mViewFilledButUnexpectedCount);
                    + " mViewFilledButUnexpectedCount=" + event.mViewFilledButUnexpectedCount
                    + " event.mSelectionTimestamp=" + event.mSelectionTimestamp
                    + " event.mAutofilledTimestampMs=" + event.mAutofilledTimestampMs
                    + " event.mFieldModifiedFirstTimestampMs="
                    + event.mFieldModifiedFirstTimestampMs
                    + " event.mFieldModifiedLastTimestampMs=" + event.mFieldModifiedLastTimestampMs
                    + " event.mSuggestionPresentedLastTimestampMs="
                    + event.mSuggestionPresentedLastTimestampMs
                    + " event.mFocusedVirtualAutofillId=" + event.mFocusedVirtualAutofillId
                    + " event.mFieldFirstLength=" + event.mFieldFirstLength
                    + " event.mFieldLastLength=" + event.mFieldLastLength);
        }
        }


        // TODO(b/234185326): Distinguish empty responses from other no presentation reasons.
        // TODO(b/234185326): Distinguish empty responses from other no presentation reasons.
@@ -731,7 +788,15 @@ public final class PresentationStatsEventLogger {
                event.mViewFillFailureCount,
                event.mViewFillFailureCount,
                event.mFocusedId,
                event.mFocusedId,
                event.mViewFillSuccessCount,
                event.mViewFillSuccessCount,
                event.mViewFilledButUnexpectedCount);
                event.mViewFilledButUnexpectedCount,
                event.mSelectionTimestamp,
                event.mAutofilledTimestampMs,
                event.mFieldModifiedFirstTimestampMs,
                event.mFieldModifiedLastTimestampMs,
                event.mSuggestionPresentedLastTimestampMs,
                event.mFocusedVirtualAutofillId,
                event.mFieldFirstLength,
                event.mFieldLastLength);
        mEventInternal = Optional.empty();
        mEventInternal = Optional.empty();
    }
    }


@@ -745,31 +810,39 @@ public final class PresentationStatsEventLogger {
        int mCountNotShownImePresentationNotDrawn;
        int mCountNotShownImePresentationNotDrawn;
        int mCountNotShownImeUserNotSeen;
        int mCountNotShownImeUserNotSeen;
        int mDisplayPresentationType = AUTOFILL_PRESENTATION_EVENT_REPORTED__DISPLAY_PRESENTATION_TYPE__UNKNOWN_AUTOFILL_DISPLAY_PRESENTATION_TYPE;
        int mDisplayPresentationType = AUTOFILL_PRESENTATION_EVENT_REPORTED__DISPLAY_PRESENTATION_TYPE__UNKNOWN_AUTOFILL_DISPLAY_PRESENTATION_TYPE;
        int mAutofillServiceUid = -1;
        int mAutofillServiceUid = DEFAULT_VALUE_INT;
        int mInlineSuggestionHostUid = -1;
        int mInlineSuggestionHostUid = DEFAULT_VALUE_INT;
        boolean mIsRequestTriggered;
        boolean mIsRequestTriggered;
        int mFillRequestSentTimestampMs;
        int mFillRequestSentTimestampMs = DEFAULT_VALUE_INT;
        int mFillResponseReceivedTimestampMs;
        int mFillResponseReceivedTimestampMs = DEFAULT_VALUE_INT;
        int mSuggestionSentTimestampMs;
        int mSuggestionSentTimestampMs = DEFAULT_VALUE_INT;
        int mSuggestionPresentedTimestampMs;
        int mSuggestionPresentedTimestampMs = DEFAULT_VALUE_INT;
        int mSelectedDatasetId = -1;
        int mSelectedDatasetId = DEFAULT_VALUE_INT;
        boolean mDialogDismissed = false;
        boolean mDialogDismissed = false;
        boolean mNegativeCtaButtonClicked = false;
        boolean mNegativeCtaButtonClicked = false;
        boolean mPositiveCtaButtonClicked = false;
        boolean mPositiveCtaButtonClicked = false;
        int mAuthenticationType = AUTHENTICATION_TYPE_UNKNOWN;
        int mAuthenticationType = AUTHENTICATION_TYPE_UNKNOWN;
        int mAuthenticationResult = AUTHENTICATION_RESULT_UNKNOWN;
        int mAuthenticationResult = AUTHENTICATION_RESULT_UNKNOWN;
        int mLatencyAuthenticationUiDisplayMillis = -1;
        int mLatencyAuthenticationUiDisplayMillis = DEFAULT_VALUE_INT;
        int mLatencyDatasetDisplayMillis = -1;
        int mLatencyDatasetDisplayMillis = DEFAULT_VALUE_INT;
        int mAvailablePccCount = -1;
        int mAvailablePccCount = DEFAULT_VALUE_INT;
        int mAvailablePccOnlyCount = -1;
        int mAvailablePccOnlyCount = DEFAULT_VALUE_INT;
        @DatasetPickedReason int mSelectedDatasetPickedReason = PICK_REASON_UNKNOWN;
        @DatasetPickedReason int mSelectedDatasetPickedReason = PICK_REASON_UNKNOWN;
        @DetectionPreference int mDetectionPreference = DETECTION_PREFER_UNKNOWN;
        @DetectionPreference int mDetectionPreference = DETECTION_PREFER_UNKNOWN;
        int mFieldClassificationRequestId = -1;
        int mFieldClassificationRequestId = DEFAULT_VALUE_INT;
        boolean mIsCredentialRequest = false;
        boolean mIsCredentialRequest = false;
        boolean mWebviewRequestedCredential = false;
        boolean mWebviewRequestedCredential = false;
        int mViewFillableTotalCount = -1;
        int mViewFillableTotalCount = DEFAULT_VALUE_INT;
        int mViewFillFailureCount = -1;
        int mViewFillFailureCount = DEFAULT_VALUE_INT;
        int mFocusedId = -1;
        int mFocusedId = DEFAULT_VALUE_INT;
        int mSelectionTimestamp = DEFAULT_VALUE_INT;
        int mAutofilledTimestampMs = DEFAULT_VALUE_INT;
        int mFieldModifiedFirstTimestampMs = DEFAULT_VALUE_INT;
        int mFieldModifiedLastTimestampMs = DEFAULT_VALUE_INT;
        int mSuggestionPresentedLastTimestampMs = DEFAULT_VALUE_INT;
        int mFocusedVirtualAutofillId = DEFAULT_VALUE_INT;
        int mFieldFirstLength = DEFAULT_VALUE_INT;
        int mFieldLastLength = DEFAULT_VALUE_INT;


        // Default value for success count is set to 0 explicitly. Setting it to -1 for
        // Default value for success count is set to 0 explicitly. Setting it to -1 for
        // uninitialized doesn't help much, as this would be non-zero only if callback is received.
        // uninitialized doesn't help much, as this would be non-zero only if callback is received.
+1 −1
Original line number Original line Diff line number Diff line
@@ -4778,7 +4778,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        updateFilteringStateOnValueChangedLocked(textValue, viewState);
        updateFilteringStateOnValueChangedLocked(textValue, viewState);


        viewState.setCurrentValue(value);
        viewState.setCurrentValue(value);

        final String filterText = textValue;
        final String filterText = textValue;


        final AutofillValue filledValue = viewState.getAutofilledValue();
        final AutofillValue filledValue = viewState.getAutofilledValue();
@@ -4805,6 +4804,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                currentView.maybeCallOnFillReady(flags);
                currentView.maybeCallOnFillReady(flags);
            }
            }
        }
        }
        mPresentationStatsEventLogger.onFieldTextUpdated(viewState);


        if (viewState.id.equals(this.mCurrentViewId)
        if (viewState.id.equals(this.mCurrentViewId)
                && (viewState.getState() & ViewState.STATE_INLINE_SHOWN) != 0) {
                && (viewState.getState() & ViewState.STATE_INLINE_SHOWN) != 0) {