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

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

Merge "New Autofill field: FIELD_AUTOFILL_SESSION_ID"

parents a006c0be 833c99b9
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -1900,8 +1900,11 @@ public final class AutofillManager {

    private LogMaker newLog(int category) {
        final LogMaker log = new LogMaker(category)
                .addTaggedData(MetricsEvent.FIELD_AUTOFILL_COMPAT_MODE,
                        isCompatibilityModeEnabledLocked() ? 1 : 0);
                .addTaggedData(MetricsEvent.FIELD_AUTOFILL_SESSION_ID, mSessionId);

        if (isCompatibilityModeEnabledLocked()) {
            log.addTaggedData(MetricsEvent.FIELD_AUTOFILL_COMPAT_MODE, 1);
        }
        final AutofillClient client = getClient();
        if (client == null) {
            // Client should never be null here, but it doesn't hurt to check...
+24 −2
Original line number Diff line number Diff line
@@ -3993,8 +3993,9 @@ message MetricsEvent {
    // 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.
    // Tag FIELD_AUTOFIL_FLAGS: flags used to start the session.
    // Tag FIELD_AUTOFILL_SESSION_ID: id of the autofill session started.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_SESSION_STARTED = 906;

    // An autofill request was processed by a service
@@ -4015,6 +4016,7 @@ message MetricsEvent {
    // Tag FIELD_AUTOFILL_AUTHENTICATION_STATUS: status of authenticated datasets or responses.
    // Tag FIELD_AUTOFILL_NUM_FIELD_CLASSIFICATION_IDS: if service requested field classification,
    //     number of entries field ids in 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.
    // NOTE: Prior to P, some of the fields above were logged by 5 different metrics:
    // - AUTOFILL_UI_LATENCY
@@ -4041,6 +4043,7 @@ message MetricsEvent {
    // 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_SESSION_ID: id of the autofill session associated with this metric.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_FILL_UI = 910;

@@ -4059,6 +4062,7 @@ message MetricsEvent {
    // Tag FIELD_AUTOFILL_NUM_VIEWS_FILLED: Number of views that could be filled
    // 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_SESSION_ID: id of the autofill session associated with this metric.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_DATASET_APPLIED = 913;

@@ -4077,6 +4081,7 @@ message MetricsEvent {
    // 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_SESSION_ID: id of the autofill session associated with this metric.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_SAVE_UI = 916;

@@ -4091,6 +4096,7 @@ message MetricsEvent {
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    // 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_SESSION_ID: id of the autofill session associated with this metric.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_DATA_SAVE_REQUEST = 918;

@@ -4099,6 +4105,7 @@ message MetricsEvent {
    // Package: Package of app that was autofilled
    // NOTE: starting on OS P, it also added the following fields:
    // Tag FIELD_AUTOFILL_SERVICE: Package of 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.
    // Tag FIELD_AUTOFILL_NUMBER_REQUESTS: number of requests made to the service (each request
    //     is logged by a separate AUTOFILL_REQUEST metric)
@@ -4688,6 +4695,7 @@ message MetricsEvent {
    // Tag FIELD_AUTOFILL_PREVIOUS_LENGTH: the previous length of the value
    // 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_SESSION_ID: id of the autofill session associated with this metric.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_VALUE_RESET = 1124;

@@ -4722,6 +4730,7 @@ message MetricsEvent {
    // Tag FIELD_AUTOFILL_SAVE_TYPE: Type of save object passed by the service
    // 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_SESSION_ID: id of the autofill session associated with this metric.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_SAVE_CUSTOM_DESCRIPTION = 1129;

@@ -4736,6 +4745,7 @@ message MetricsEvent {
    // Tag FIELD_AUTOFILL_SAVE_TYPE: Type of save object passed by the service
    // 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_SESSION_ID: id of the autofill session associated with this metric.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_SAVE_CUSTOM_SUBTITLE = 1131;

@@ -4749,6 +4759,7 @@ message MetricsEvent {
    // Tag FIELD_AUTOFILL_SAVE_TYPE: Type of save object passed by the service
    // 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_SESSION_ID: id of the autofill session associated with this metric.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_SAVE_LINK_TAPPED = 1132;

@@ -4762,6 +4773,7 @@ message MetricsEvent {
    // Tag FIELD_AUTOFILL_SAVE_TYPE: Type of save object passed by the service
    // 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_SESSION_ID: id of the autofill session associated with this metric.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_SAVE_VALIDATION = 1133;

@@ -4774,6 +4786,7 @@ message MetricsEvent {
    // Type TYPE_FAILURE: An invalid opperation was reported by the app's AutofillManager
    // 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_SESSION_ID: id of the autofill session associated with this metric.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_PENDING_SAVE_UI_OPERATION = 1134;

@@ -4956,6 +4969,7 @@ message MetricsEvent {
    // 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_SESSION_ID: id of the autofill session associated with this metric.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_EXPLICIT_SAVE_TRIGGER_DEFINITION = 1228;

@@ -4964,6 +4978,7 @@ message MetricsEvent {
    // Package: Package of app that is autofilled
    // OS: P
    // Tag FIELD_CLASS_NAME: Class name of the activity that is autofilled.
    // 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_SAVE_EXPLICITLY_TRIGGERED = 1229;

@@ -4977,6 +4992,7 @@ message MetricsEvent {
    // OS: P
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    // Tag FIELD_AUTOFILL_DURATION: duration (in ms) that autofill will be disabled
    // 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_SERVICE_DISABLED_APP = 1231;

@@ -4986,6 +5002,7 @@ message MetricsEvent {
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    // Tag FIELD_CLASS_NAME: Class name of the activity that is being disabled for autofill
    // Tag FIELD_AUTOFILL_DURATION: duration (in ms) that autofill will be disabled
    // 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_SERVICE_DISABLED_ACTIVITY = 1232;

@@ -5199,6 +5216,7 @@ message MetricsEvent {
    // 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_SESSION_ID: id of the autofill session associated with this metric.
    // Tag FIELD_AUTOFILL_COMPAT_MODE: package is being autofilled on compatibility mode.
    AUTOFILL_FIELD_CLASSIFICATION_MATCHES = 1273;

@@ -6094,6 +6112,10 @@ message MetricsEvent {
    // OS: P
    FIELD_AUTOFILL_NUMBER_REQUESTS = 1455;

    // FIELD: Id of the autofill session associated with this metric.
    // OS: P
    FIELD_AUTOFILL_SESSION_ID = 1456;

    // ---- End P Constants, all P constants go above this line ----

    // First Q constant in master goes here:
+24 −11
Original line number Diff line number Diff line
@@ -537,11 +537,17 @@ final class AutofillManagerServiceImpl {
            final String callingPackage = packages != null ? packages[0] : "uid-" + callingUid;
            Slog.w(TAG, "App (package=" + callingPackage + ", UID=" + callingUid
                    + ") passed component (" + componentName + ") owned by UID " + packageUid);
            mMetricsLogger.write(
                    Helper.newLogMaker(MetricsEvent.AUTOFILL_FORGED_COMPONENT_ATTEMPT,
                            callingPackage, getServicePackageName(), compatMode)

            // NOTE: not using Helper.newLogMaker() because we don't have the session id
            final LogMaker log = new LogMaker(MetricsEvent.AUTOFILL_FORGED_COMPONENT_ATTEMPT)
                    .setPackageName(callingPackage)
                    .addTaggedData(MetricsEvent.FIELD_AUTOFILL_SERVICE, getServicePackageName())
                    .addTaggedData(MetricsEvent.FIELD_AUTOFILL_FORGED_COMPONENT_NAME,
                            componentName == null ? "null" : componentName.flattenToShortString()));
                            componentName == null ? "null" : componentName.flattenToShortString());
            if (compatMode) {
                log.addTaggedData(MetricsEvent.FIELD_AUTOFILL_COMPAT_MODE, 1);
            }
            mMetricsLogger.write(log);

            throw new SecurityException("Invalid component: " + componentName);
        }
@@ -835,7 +841,7 @@ final class AutofillManagerServiceImpl {
                final int averageScore = (int) ((totalScore * 100) / totalSize);
                mMetricsLogger.write(Helper
                        .newLogMaker(MetricsEvent.AUTOFILL_FIELD_CLASSIFICATION_MATCHES,
                                appComponentName, getServicePackageName(), compatMode)
                                appComponentName, getServicePackageName(), sessionId, compatMode)
                        .setCounterValue(numberFields)
                        .addTaggedData(MetricsEvent.FIELD_AUTOFILL_MATCH_SCORE,
                                averageScore));
@@ -1133,7 +1139,8 @@ final class AutofillManagerServiceImpl {
    /**
     * Called by {@link Session} when service asked to disable autofill for an app.
     */
    void disableAutofillForApp(@NonNull String packageName, long duration, boolean compatMode) {
    void disableAutofillForApp(@NonNull String packageName, long duration, int sessionId,
            boolean compatMode) {
        synchronized (mLock) {
            if (mDisabledApps == null) {
                mDisabledApps = new ArrayMap<>(1);
@@ -1146,7 +1153,7 @@ final class AutofillManagerServiceImpl {
            mDisabledApps.put(packageName, expiration);
            int intDuration = duration > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) duration;
            mMetricsLogger.write(Helper.newLogMaker(MetricsEvent.AUTOFILL_SERVICE_DISABLED_APP,
                    packageName, getServicePackageName(), compatMode)
                    packageName, getServicePackageName(), sessionId, compatMode)
                    .addTaggedData(MetricsEvent.FIELD_AUTOFILL_DURATION, intDuration));
        }
    }
@@ -1155,7 +1162,7 @@ final class AutofillManagerServiceImpl {
     * Called by {@link Session} when service asked to disable autofill an app.
     */
    void disableAutofillForActivity(@NonNull ComponentName componentName, long duration,
            boolean compatMode) {
            int sessionId, boolean compatMode) {
        synchronized (mLock) {
            if (mDisabledActivities == null) {
                mDisabledActivities = new ArrayMap<>(1);
@@ -1166,14 +1173,20 @@ final class AutofillManagerServiceImpl {
                expiration = Long.MAX_VALUE;
            }
            mDisabledActivities.put(componentName, expiration);
            final int intDuration = duration > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) duration;
            final int intDuration = duration > Integer.MAX_VALUE
                    ? Integer.MAX_VALUE
                    : (int) duration;
            // NOTE: not using Helper.newLogMaker() because we're setting the componentName instead
            // of package name
            mMetricsLogger.write(new LogMaker(MetricsEvent.AUTOFILL_SERVICE_DISABLED_ACTIVITY)
            final LogMaker log = new LogMaker(MetricsEvent.AUTOFILL_SERVICE_DISABLED_ACTIVITY)
                    .setComponentName(componentName)
                    .addTaggedData(MetricsEvent.FIELD_AUTOFILL_SERVICE, getServicePackageName())
                    .addTaggedData(MetricsEvent.FIELD_AUTOFILL_DURATION, intDuration)
                    .addTaggedData(MetricsEvent.FIELD_AUTOFILL_COMPAT_MODE, compatMode ? 1 : 0));
                    .addTaggedData(MetricsEvent.FIELD_AUTOFILL_SESSION_ID, sessionId);
            if (compatMode) {
                log.addTaggedData(MetricsEvent.FIELD_AUTOFILL_COMPAT_MODE, 1);
            }
            mMetricsLogger.write(log);
        }
    }

+8 −6
Original line number Diff line number Diff line
@@ -111,9 +111,10 @@ public final class Helper {

    @NonNull
    private static LogMaker newLogMaker(int category, @NonNull String servicePackageName,
            boolean compatMode) {
            int sessionId, boolean compatMode) {
        final LogMaker log = new LogMaker(category)
                .addTaggedData(MetricsEvent.FIELD_AUTOFILL_SERVICE, servicePackageName);
                .addTaggedData(MetricsEvent.FIELD_AUTOFILL_SERVICE, servicePackageName)
                .addTaggedData(MetricsEvent.FIELD_AUTOFILL_SESSION_ID, sessionId);
        if (compatMode) {
            log.addTaggedData(MetricsEvent.FIELD_AUTOFILL_COMPAT_MODE, 1);
        }
@@ -122,14 +123,15 @@ public final class Helper {

    @NonNull
    public static LogMaker newLogMaker(int category, @NonNull String packageName,
            @NonNull String servicePackageName, boolean compatMode) {
        return newLogMaker(category, servicePackageName, compatMode).setPackageName(packageName);
            @NonNull String servicePackageName, int sessionId, boolean compatMode) {
        return newLogMaker(category, servicePackageName, sessionId, compatMode)
                .setPackageName(packageName);
    }

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

+6 −6
Original line number Diff line number Diff line
@@ -672,10 +672,11 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                Slog.d(TAG, message.toString());
            }
            if ((flags & FillResponse.FLAG_DISABLE_ACTIVITY_ONLY) != 0) {
                mService.disableAutofillForActivity(mComponentName, disableDuration, mCompatMode);
                mService.disableAutofillForActivity(mComponentName, disableDuration,
                        id, mCompatMode);
            } else {
                mService.disableAutofillForApp(mComponentName.getPackageName(), disableDuration,
                        mCompatMode);
                        id, mCompatMode);
            }
            sessionFinishedState = AutofillManager.STATE_DISABLED_BY_SERVICE;
        }
@@ -1649,8 +1650,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, this,
                        mPendingSaveUi, mCompatMode);
                        mComponentName, this, mPendingSaveUi, mCompatMode);
                if (client != null) {
                    try {
                        client.setSaveUiState(id, true);
@@ -2128,7 +2128,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState

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

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

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

    private void writeLog(int category) {
Loading