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

Commit a3033851 authored by Felipe Leme's avatar Felipe Leme
Browse files

Initial metrics for Augmented Autofill.

Test: atest CtsAutoFillServiceTestCases:android.autofillservice.cts.augmented.AugmentedLoginActivityTest
Test: adb shell logcat -b events | grep sysui

Bug: 122858578
Bug: 112192360

Change-Id: If2a1ac06584f238688d96bbc680abb6b7cee12db
parent 065aac1a
Loading
Loading
Loading
Loading
+16 −0
Original line number Original line Diff line number Diff line
@@ -4049,6 +4049,8 @@ message MetricsEvent {
    // - AUTOFILL_INVALID_DATASET_AUTHENTICATION
    // - AUTOFILL_INVALID_DATASET_AUTHENTICATION
    // NOTE: starting on OS Q, it also added the following fields:
    // 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_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;
    AUTOFILL_REQUEST = 907;


    // Tag of a field for a package of an autofill service
    // Tag of a field for a package of an autofill service
@@ -6824,6 +6826,20 @@ message MetricsEvent {
    // OS: Q
    // OS: Q
    SETTINGS_ADAPTIVE_SLEEP = 1628;
    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;

    // ---- End Q Constants, all Q constants go above this line ----
    // ---- End Q Constants, all Q constants go above this line ----
    // Add new aosp constants above this line.
    // Add new aosp constants above this line.
    // END OF AOSP CONSTANTS
    // END OF AOSP CONSTANTS
+46 −8
Original line number Original line Diff line number Diff line
@@ -260,6 +260,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
    @Nullable
    @Nullable
    private Runnable mAugmentedAutofillDestroyer;
    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}.
     * Receiver of assist data from the app's {@link Activity}.
     */
     */
@@ -2541,8 +2547,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        }
        }
        mService.resetLastResponse();
        mService.resetLastResponse();


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


        if (sVerbose) {
        if (sVerbose) {
            Slog.v(TAG, "calling IntelligenseService on view " + mCurrentViewId
            Slog.v(TAG, "calling Augmented Autofill Service ("
                    + " using suggestion mode " + smartSuggestionFlagsToString(mode)
                    + remoteService.getComponentName().toShortString() + ") on view "
                    + mCurrentViewId + " using suggestion mode "
                    + smartSuggestionFlagsToString(mode)
                    + " when server returned null for session " + this.id);
                    + " 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();
        final AutofillValue currentValue = mViewStates.get(mCurrentViewId).getCurrentValue();


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

        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,
        remoteService.onRequestAutofillLocked(id, mClient, taskId, mComponentName, mCurrentViewId,
                currentValue);
                currentValue);


@@ -2912,6 +2927,11 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        if (mAugmentedAutofillDestroyer != null) {
        if (mAugmentedAutofillDestroyer != null) {
            pw.print(prefix); pw.println("has mAugmentedAutofillDestroyer");
            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);
        mRemoteFillService.dump(prefix, pw);
    }
    }


@@ -3053,8 +3073,26 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                mMetricsLogger.write(log);
                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;
        return mRemoteFillService;
    }
    }