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

Commit 764f21e2 authored by Felipe Leme's avatar Felipe Leme Committed by Android (Google) Code Review
Browse files

Merge "Added the class name of activity being autofilled on (most) autofill metrics."

parents f0993dfe b838a09a
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -1899,10 +1899,17 @@ public final class AutofillManager {
    }

    private LogMaker newLog(int category) {
        return new LogMaker(category)
                .setPackageName(mContext.getPackageName())
        final LogMaker log = new LogMaker(category)
                .addTaggedData(MetricsEvent.FIELD_AUTOFILL_COMPAT_MODE,
                        isCompatibilityModeEnabledLocked() ? 1 : 0);
        final AutofillClient client = getClient();
        if (client == null) {
            // Client should never be null here, but it doesn't hurt to check...
            log.setPackageName(mContext.getPackageName());
        } else {
            log.setComponentName(client.autofillClientGetComponentName());
        }
        return log;
    }

    /**
+25 −10
Original line number Diff line number Diff line
@@ -3992,6 +3992,7 @@ message MetricsEvent {
    // NOTE: starting on OS MR1, it also added the following field:
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    // NOTE: starting on OS P, it also added the following field:
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFIL_FLAGS - Flags used to start the session
    // Type FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_SESSION_STARTED = 906;
@@ -4005,6 +4006,7 @@ message MetricsEvent {
    // the service returned a null response
    // NOTE: starting on OS P, it also added the following fields:
    // TYPE_CLOSE: request timed out before service called a FillCallback method
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFILL_REQUEST_ORDINAL: sequence number of the request inside a session; starts
    //     with 1.
    // Tag FIELD_AUTOFILL_FLAGS: flags used to request autofill
@@ -4036,7 +4038,8 @@ message MetricsEvent {
    // Package: Package of app that was autofilled
    // Tag FIELD_AUTOFILL_FILTERTEXT_LEN: The length of the filter text
    // Tag FIELD_AUTOFILL_NUM_DATASETS: The number of datasets shown
    // NOTE: starting on OS P, it also added the following field:
    // NOTE: starting on OS P, it also added the following fields:
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_FILL_UI = 910;
@@ -4054,7 +4057,8 @@ message MetricsEvent {
    // Package: Package of app that is autofilled
    // Tag FIELD_AUTOFILL_NUM_VALUES: Number of values that were suggested to be autofilled
    // Tag FIELD_AUTOFILL_NUM_VIEWS_FILLED: Number of views that could be filled
    // NOTE: starting on OS P, it also added the following field:
    // NOTE: starting on OS P, it also added the following fields:
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_DATASET_APPLIED = 913;

@@ -4070,7 +4074,8 @@ message MetricsEvent {
    // Type TYPE_ACTION: data was saved
    // Package: Package of app that was autofilled
    // Tag FIELD_AUTOFILL_NUM_IDS: The number of ids that are saved
    // NOTE: starting on OS P, it also added the following field:
    // NOTE: starting on OS P, it also added the following fields:
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_SAVE_UI = 916;
@@ -4084,7 +4089,8 @@ message MetricsEvent {
    // Type TYPE_FAILURE: The request failed
    // Package: Package of app that was autofilled
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    // NOTE: starting on OS P, it also added the following field:
    // NOTE: starting on OS P, it also added the following fields:
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_DATA_SAVE_REQUEST = 918;

@@ -4680,7 +4686,8 @@ message MetricsEvent {
    // OS: O MR
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    // Tag FIELD_AUTOFILL_PREVIOUS_LENGTH: the previous length of the value
    // NOTE: starting on OS P, it also added the following field:
    // NOTE: starting on OS P, it also added the following fields:
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_VALUE_RESET = 1124;

@@ -4713,7 +4720,8 @@ message MetricsEvent {
    // OS: O MR
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    // Tag FIELD_AUTOFILL_SAVE_TYPE: Type of save object passed by the service
    // NOTE: starting on OS P, it also added the following field:
    // NOTE: starting on OS P, it also added the following fields:
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_SAVE_CUSTOM_DESCRIPTION = 1129;

@@ -4726,7 +4734,8 @@ message MetricsEvent {
    // OS: O MR
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    // Tag FIELD_AUTOFILL_SAVE_TYPE: Type of save object passed by the service
    // NOTE: starting on OS P, it also added the following field:
    // NOTE: starting on OS P, it also added the following fields:
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_SAVE_CUSTOM_SUBTITLE = 1131;

@@ -4738,7 +4747,8 @@ message MetricsEvent {
    // Type TYPE_FAILURE: The link could not launc an activity
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    // Tag FIELD_AUTOFILL_SAVE_TYPE: Type of save object passed by the service
    // NOTE: starting on OS P, it also added the following field:
    // NOTE: starting on OS P, it also added the following fields:
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_SAVE_LINK_TAPPED = 1132;

@@ -4750,7 +4760,8 @@ message MetricsEvent {
    // Type TYPE_DISMISS: The validation failed
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    // Tag FIELD_AUTOFILL_SAVE_TYPE: Type of save object passed by the service
    // NOTE: starting on OS P, it also added the following field:
    // NOTE: starting on OS P, it also added the following fields:
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_SAVE_VALIDATION = 1133;

@@ -4761,7 +4772,8 @@ message MetricsEvent {
    // Type TYPE_OPEN: The autofill save UI was restored
    // Type TYPE_DISMISS: The autofill save UI was destroyed
    // Type TYPE_FAILURE: An invalid opperation was reported by the app's AutofillManager
    // NOTE: starting on OS P, it also added the following field:
    // NOTE: starting on OS P, it also added the following fields:
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_PENDING_SAVE_UI_OPERATION = 1134;

@@ -4942,6 +4954,7 @@ message MetricsEvent {
    // An autofill service explicitly defined which view should commit the autofill context
    // Package: Package of app that is autofilled
    // OS: P
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_EXPLICIT_SAVE_TRIGGER_DEFINITION = 1228;
@@ -4950,6 +4963,7 @@ message MetricsEvent {
    // service as committing it
    // Package: Package of app that is autofilled
    // OS: P
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_SAVE_EXPLICITLY_TRIGGERED = 1229;

@@ -5182,6 +5196,7 @@ message MetricsEvent {
    // Package: Package of app that is autofilled
    // Counter: number of matches found
    // OS: P
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    // Tag FIELD_AUTOFILL_MATCH_SCORE: Average score of the matches, in the range of 0 to 100
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
+10 −7
Original line number Diff line number Diff line
@@ -780,10 +780,10 @@ final class AutofillManagerServiceImpl {
            @Nullable ArrayList<String> changedDatasetIds,
            @Nullable ArrayList<AutofillId> manuallyFilledFieldIds,
            @Nullable ArrayList<ArrayList<String>> manuallyFilledDatasetIds,
            @NonNull String appPackageName, boolean compatMode) {
            @NonNull ComponentName appComponentName, boolean compatMode) {
        logContextCommittedLocked(sessionId, clientState, selectedDatasets, ignoredDatasets,
                changedFieldIds, changedDatasetIds, manuallyFilledFieldIds,
                manuallyFilledDatasetIds, null, null, appPackageName, compatMode);
                manuallyFilledDatasetIds, null, null, appComponentName, compatMode);
    }

    @GuardedBy("mLock")
@@ -796,7 +796,7 @@ final class AutofillManagerServiceImpl {
            @Nullable ArrayList<ArrayList<String>> manuallyFilledDatasetIds,
            @Nullable ArrayList<AutofillId> detectedFieldIdsList,
            @Nullable ArrayList<FieldClassification> detectedFieldClassificationsList,
            @NonNull String appPackageName, boolean compatMode) {
            @NonNull ComponentName appComponentName, boolean compatMode) {
        if (isValidEventLocked("logDatasetNotSelected()", sessionId)) {
            if (sVerbose) {
                Slog.v(TAG, "logContextCommitted() with FieldClassification: id=" + sessionId
@@ -807,6 +807,7 @@ final class AutofillManagerServiceImpl {
                        + ", manuallyFilledFieldIds=" + manuallyFilledFieldIds
                        + ", detectedFieldIds=" + detectedFieldIdsList
                        + ", detectedFieldClassifications=" + detectedFieldClassificationsList
                        + ", appComponentName=" + appComponentName.toShortString()
                        + ", compatMode=" + compatMode);
            }
            AutofillId[] detectedFieldsIds = null;
@@ -834,7 +835,7 @@ final class AutofillManagerServiceImpl {
                final int averageScore = (int) ((totalScore * 100) / totalSize);
                mMetricsLogger.write(Helper
                        .newLogMaker(MetricsEvent.AUTOFILL_FIELD_CLASSIFICATION_MATCHES,
                                appPackageName, getServicePackageName(), compatMode)
                                appComponentName, getServicePackageName(), compatMode)
                        .setCounterValue(numberFields)
                        .addTaggedData(MetricsEvent.FIELD_AUTOFILL_MATCH_SCORE,
                                averageScore));
@@ -889,9 +890,11 @@ final class AutofillManagerServiceImpl {
            }
            mUserData = userData;
            // Log it
            int numberFields = mUserData == null ? 0: mUserData.getCategoryIds().length;
            mMetricsLogger.write(Helper.newLogMaker(MetricsEvent.AUTOFILL_USERDATA_UPDATED,
                    getServicePackageName(), null)
            final int numberFields = mUserData == null ? 0: mUserData.getCategoryIds().length;
            // NOTE: contrary to most metrics, the service name is logged as the main package name
            // here, not as MetricsEvent.FIELD_AUTOFILL_SERVICE
            mMetricsLogger.write(new LogMaker(MetricsEvent.AUTOFILL_USERDATA_UPDATED)
                    .setPackageName(getServicePackageName())
                    .addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUM_VALUES, numberFields));
        }
    }
+17 −12
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.assist.AssistStructure;
import android.app.assist.AssistStructure.ViewNode;
import android.content.ComponentName;
import android.metrics.LogMaker;
import android.service.autofill.Dataset;
import android.util.ArrayMap;
@@ -109,23 +110,27 @@ public final class Helper {
    }

    @NonNull
    public static LogMaker newLogMaker(int category, String packageName,
            String servicePackageName) {
        final LogMaker log = new LogMaker(category).setPackageName(packageName);
        if (servicePackageName != null) {
            log.addTaggedData(MetricsEvent.FIELD_AUTOFILL_SERVICE, servicePackageName);
    private static LogMaker newLogMaker(int category, @NonNull String servicePackageName,
            boolean compatMode) {
        final LogMaker log = new LogMaker(category)
                .addTaggedData(MetricsEvent.FIELD_AUTOFILL_SERVICE, servicePackageName);
        if (compatMode) {
            log.addTaggedData(MetricsEvent.FIELD_AUTOFILL_COMPAT_MODE, 1);
        }
        return log;
    }

    @NonNull
    public static LogMaker newLogMaker(int category, String packageName,
            String servicePackageName, boolean compatMode) {
        final LogMaker log = newLogMaker(category, packageName, servicePackageName);
        if (compatMode) {
            log.addTaggedData(MetricsEvent.FIELD_AUTOFILL_COMPAT_MODE, 1);
    public static LogMaker newLogMaker(int category, @NonNull String packageName,
            @NonNull String servicePackageName, boolean compatMode) {
        return newLogMaker(category, servicePackageName, compatMode).setPackageName(packageName);
    }
        return log;

    @NonNull
    public static LogMaker newLogMaker(int category, @NonNull ComponentName componentName,
            @NonNull String servicePackageName, boolean compatMode) {
        return newLogMaker(category, servicePackageName, compatMode)
                .setComponentName(componentName);
    }

    public static void printlnRedactedText(@NonNull PrintWriter pw, @Nullable CharSequence text) {
+6 −7
Original line number Diff line number Diff line
@@ -1299,7 +1299,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            mService.logContextCommittedLocked(id, mClientState, mSelectedDatasetIds,
                    ignoredDatasets, changedFieldIds, changedDatasetIds,
                    manuallyFilledFieldIds, manuallyFilledDatasetIds,
                    mComponentName.getPackageName(), mCompatMode);
                    mComponentName, mCompatMode);
        }
    }

@@ -1354,7 +1354,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                mService.logContextCommittedLocked(id, mClientState, mSelectedDatasetIds,
                        ignoredDatasets, changedFieldIds, changedDatasetIds,
                        manuallyFilledFieldIds, manuallyFilledDatasetIds,
                        mComponentName.getPackageName(), mCompatMode);
                        mComponentName, mCompatMode);
                return;
            }
            final Scores scores = result.getParcelable(EXTRA_SCORES);
@@ -1419,7 +1419,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            mService.logContextCommittedLocked(id, mClientState, mSelectedDatasetIds,
                    ignoredDatasets, changedFieldIds, changedDatasetIds, manuallyFilledFieldIds,
                    manuallyFilledDatasetIds, detectedFieldIds, detectedFieldClassifications,
                    mComponentName.getPackageName(), mCompatMode);
                    mComponentName, mCompatMode);
        });

        fcStrategy.getScores(callback, algorithm, algorithmArgs, currentValues, userValues);
@@ -1649,7 +1649,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                mPendingSaveUi = new PendingUi(mActivityToken, id, client);
                getUiForShowing().showSaveUi(mService.getServiceLabel(), mService.getServiceIcon(),
                        mService.getServicePackageName(), saveInfo, this,
                        mComponentName.getPackageName(), this,
                        mComponentName, this,
                        mPendingSaveUi, mCompatMode);
                if (client != null) {
                    try {
@@ -2127,7 +2127,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        }

        getUiForShowing().showFillUi(filledId, response, filterText,
                mService.getServicePackageName(), mComponentName.getPackageName(),
                mService.getServicePackageName(), mComponentName,
                mService.getServiceLabel(), mService.getServiceIcon(), this, mCompatMode);

        synchronized (mLock) {
@@ -2834,8 +2834,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
    }

    private LogMaker newLogMaker(int category, String servicePackageName) {
        return Helper.newLogMaker(category, mComponentName.getPackageName(), servicePackageName,
                mCompatMode);
        return Helper.newLogMaker(category, mComponentName, servicePackageName, mCompatMode);
    }

    private void writeLog(int category) {
Loading