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

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

Merge "Initial metrics for Augmented Autofill."

parents 1a73f739 a3033851
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -4064,6 +4064,8 @@ message MetricsEvent {
    // - AUTOFILL_INVALID_DATASET_AUTHENTICATION
    // NOTE: starting on OS Q, it also added the following fields:
    // Tag FIELD_AUTOFILL_TEXT_LEN: length of the error message provided by the service
    // Tag FIELD_AUTOFILL_NUMBER_AUGMENTED_REQUESTS: number of requests made to the augmented
    //     autofill service
    AUTOFILL_REQUEST = 907;

    // Tag of a field for a package of an autofill service
@@ -6839,6 +6841,20 @@ message MetricsEvent {
    // OS: Q
    SETTINGS_ADAPTIVE_SLEEP = 1628;
    
    // The autofill system made request to the system-provided augmented autofill service.
    // OS: Q
    // Package: Package of app that is autofilled
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFILL_SERVICE: Package of the augmented autofill service that processed the
    // request
    // Tag FIELD_AUTOFILL_SESSION_ID: id of the autofill session associated with this metric.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_AUGMENTED_REQUEST = 1629;

    // Tag of a field for the number of augmented autofill requests in a session
    // OS: Q
    FIELD_AUTOFILL_NUMBER_AUGMENTED_REQUESTS = 1630;

    // Tagged data for SMART_REPLY_VISIBLE and NOTIFICATION_ITEM_ACTION.
    // The UI location of the notification containing the smart suggestions.
    // This is a NotificationLocation object (see the NotificationLocation
+46 −8
Original line number Diff line number Diff line
@@ -260,6 +260,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
    @Nullable
    private Runnable mAugmentedAutofillDestroyer;

    /**
     * List of {@link MetricsEvent#AUTOFILL_AUGMENTED_REQUEST} metrics.
     */
    @GuardedBy("mLock")
    private ArrayList<LogMaker> mAugmentedRequestsLogs;

    /**
     * Receiver of assist data from the app's {@link Activity}.
     */
@@ -2541,8 +2547,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        }
        mService.resetLastResponse();

        // The default autofill service cannot fullfill the request, let's check if the intelligence
        // service can.
        // The default autofill service cannot fullfill the request, let's check if the augmented
        // autofill service can.
        mAugmentedAutofillDestroyer = triggerAugmentedAutofillLocked();
        if (mAugmentedAutofillDestroyer == null) {
            if (sVerbose) {
@@ -2605,8 +2611,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        }

        if (sVerbose) {
            Slog.v(TAG, "calling IntelligenseService on view " + mCurrentViewId
                    + " using suggestion mode " + smartSuggestionFlagsToString(mode)
            Slog.v(TAG, "calling Augmented Autofill Service ("
                    + remoteService.getComponentName().toShortString() + ") on view "
                    + mCurrentViewId + " using suggestion mode "
                    + smartSuggestionFlagsToString(mode)
                    + " when server returned null for session " + this.id);
        }

@@ -2620,8 +2628,15 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        final AutofillValue currentValue = mViewStates.get(mCurrentViewId).getCurrentValue();

        // TODO(b/111330312): we might need to add a new state in the AutofillManager to optimize
        // furgher AFM -> AFMS calls.
        // TODO(b/119638958): add CTS tests
        // further AFM -> AFMS calls.

        if (mAugmentedRequestsLogs == null) {
            mAugmentedRequestsLogs = new ArrayList<>();
        }
        final LogMaker log = newLogMaker(MetricsEvent.AUTOFILL_AUGMENTED_REQUEST,
                remoteService.getComponentName().getPackageName());
        mAugmentedRequestsLogs.add(log);

        remoteService.onRequestAutofillLocked(id, mClient, taskId, mComponentName, mCurrentViewId,
                currentValue);

@@ -2912,6 +2927,11 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        if (mAugmentedAutofillDestroyer != null) {
            pw.print(prefix); pw.println("has mAugmentedAutofillDestroyer");
        }
        if (mAugmentedRequestsLogs != null) {
            pw.print(prefix); pw.print("number augmented requests: ");
            pw.println(mAugmentedRequestsLogs.size());
        }

        mRemoteFillService.dump(prefix, pw);
    }

@@ -3053,8 +3073,26 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                mMetricsLogger.write(log);
            }
        }
        mMetricsLogger.write(newLogMaker(MetricsEvent.AUTOFILL_SESSION_FINISHED)
                .addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUMBER_REQUESTS, totalRequests));

        final int totalAugmentedRequests = mAugmentedRequestsLogs == null ? 0
                : mAugmentedRequestsLogs.size();
        if (totalAugmentedRequests > 0) {
            if (sVerbose) {
                Slog.v(TAG, "destroyLocked(): logging " + totalRequests + " augmented requests");
            }
            for (int i = 0; i < totalAugmentedRequests; i++) {
                final LogMaker log = mAugmentedRequestsLogs.get(i);
                mMetricsLogger.write(log);
            }
        }

        final LogMaker log = newLogMaker(MetricsEvent.AUTOFILL_SESSION_FINISHED)
                .addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUMBER_REQUESTS, totalRequests);
        if (totalAugmentedRequests > 0) {
            log.addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUMBER_AUGMENTED_REQUESTS,
                    totalAugmentedRequests);
        }
        mMetricsLogger.write(log);

        return mRemoteFillService;
    }