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

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

Added more metrics for Autofill:

- AUTOFILL_VALUE_RESET
- FIELD_AUTOFILL_PREVIOUS_LENGTH
- AUTOFILL_DATASET_AUTHENTICATED
- AUTOFILL_INVALID_DATASET_AUTHENTICATION
- AUTOFILL_INVALID_AUTHENTICATION
- FIELD_AUTOFILL_SAVE_TYPE
- AUTOFILL_SAVE_CUSTOM_DESCRIPTION
- AUTOFILL_SAVE_CUSTOM_SUBTITLE
- AUTOFILL_SAVE_LINK_TAPPED
- AUTOFILL_SAVE_VALIDATION
- AUTOFILL_PENDING_SAVE_UI_OPERATION

Also tagged all metrics with FIELD_AUTOFILL_SERVICE, and added missing
package name on AUTOFILL_DATASET_APPLIED.

Test: CtsAutoFillServiceTestCases pass

Bug: 65118073
Bug: 65376559
Bug: 65697068

Change-Id: I678193c99d9d1b2dac56a62a88dcf20043d1b401
parent 0fe3b1aa
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ import android.view.View;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;

import java.io.PrintWriter;
import java.lang.annotation.Retention;
@@ -1245,10 +1245,10 @@ public final class AutofillManager {
                }
            }

            final LogMaker log = new LogMaker(MetricsProto.MetricsEvent.AUTOFILL_DATASET_APPLIED);
            log.addTaggedData(MetricsProto.MetricsEvent.FIELD_AUTOFILL_NUM_VALUES, itemCount);
            log.addTaggedData(MetricsProto.MetricsEvent.FIELD_AUTOFILL_NUM_VIEWS_FILLED,
                    numApplied);
            final LogMaker log = new LogMaker(MetricsEvent.AUTOFILL_DATASET_APPLIED)
                    .setPackageName(mContext.getPackageName())
                    .addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUM_VALUES, itemCount)
                    .addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUM_VIEWS_FILLED, numApplied);
            mMetricsLogger.write(log);
        }
    }
+76 −0
Original line number Diff line number Diff line
@@ -4451,6 +4451,82 @@ message MetricsEvent {
    // OS: O MR
    FIELD_SELECTION_SMART_RANGE = 1123;

    // The value of an autofillable and savable view was reset
    // Package: Package of app that was autofilled
    // 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
    AUTOFILL_VALUE_RESET = 1124;

    // Tag of AUTOFILL_VALUE_RESET
    // OS: O MR
    FIELD_AUTOFILL_PREVIOUS_LENGTH = 1125;

    // An autofill dataset authentification succeeded
    // Package: Package of app that was autofilled
    // OS: O MR
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    AUTOFILL_DATASET_AUTHENTICATED = 1126;

    // An autofill service provided an invalid dataset authentification
    // Package: Package of app that was autofilled
    // OS: O MR
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    AUTOFILL_INVALID_DATASET_AUTHENTICATION = 1127;

    // An autofill service provided an invalid authentification extra
    // Package: Package of app that was autofilled
    // OS: O MR
    // Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
    AUTOFILL_INVALID_AUTHENTICATION = 1128;

    // An autofill service used a custom description (using RemoteViews) in the Save affordance
    // Package: Package of app that is autofilled
    // 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
    AUTOFILL_SAVE_CUSTOM_DESCRIPTION = 1129;

    // FIELD - Type of save object passed by the service when the Save UI is shown
    // OS: O MR
    FIELD_AUTOFILL_SAVE_TYPE = 1130;

    // An autofill service used a custom subtitle (String) in the Save affordance
    // Package: Package of app that is autofilled
    // 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
    AUTOFILL_SAVE_CUSTOM_SUBTITLE = 1131;

    // User tapped a link in the custom description of the Save affordance provided by an autofill service
    // Package: Package of app that is autofilled
    // OS: O MR
    // Type TYPE_UNKNOWN: The link was not properly set by the service
    // Type TYPE_OPEN: The link launched an activity
    // 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
    AUTOFILL_SAVE_LINK_TAPPED = 1132;

    // Result of the validation on save when an autofill service provided a validator
    // Package: Package of app that is autofilled
    // OS: O MR
    // Type TYPE_FAILURE: The validation could not be performed due to an error
    // Type TYPE_SUCCESS: The validation passed
    // 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
    AUTOFILL_SAVE_VALIDATION = 1133;

    // Result of an operation in the autofill save affordance after the user tapped a link in the custom description
    // provided by the autofill service
    // Package: Package of app that is autofilled
    // OS: O MR
    // Type TYPE_OPEN: The save affordance was restored
    // Type TYPE_DISMISS: The save affordcance was destroyed
    // Type TYPE_FAILURE: An invalid opperation was reported by the app's AutofillManager
    AUTOFILL_PENDING_SAVE_UI_OPERATION = 1134;

    // ---- End O-MR1 Constants, all O-MR1 constants go above this line ----

    // Add new aosp constants above this line.
+1 −1
Original line number Diff line number Diff line
@@ -650,7 +650,7 @@ public final class AutofillManagerService extends SystemService {
            synchronized (mLock) {
                final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
                if (service == null) return false;
                return Objects.equals(packageName, service.getPackageName());
                return Objects.equals(packageName, service.getServicePackageName());
            }
        }

+4 −2
Original line number Diff line number Diff line
@@ -146,8 +146,9 @@ final class AutofillManagerServiceImpl {
        updateLocked(disabled);
    }

    @Nullable
    CharSequence getServiceName() {
        final String packageName = getPackageName();
        final String packageName = getServicePackageName();
        if (packageName == null) {
            return null;
        }
@@ -162,7 +163,8 @@ final class AutofillManagerServiceImpl {
        }
    }

    String getPackageName() {
    @Nullable
    String getServicePackageName() {
        final ComponentName serviceComponent = getServiceComponentName();
        if (serviceComponent != null) {
            return serviceComponent.getPackageName();
+13 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.autofill;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.metrics.LogMaker;
import android.os.Bundle;
import android.service.autofill.Dataset;
import android.util.ArrayMap;
@@ -25,6 +26,8 @@ import android.util.ArraySet;
import android.view.autofill.AutofillId;
import android.view.autofill.AutofillValue;

import com.android.internal.logging.nano.MetricsProto.MetricsEvent;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
@@ -99,4 +102,14 @@ public final class Helper {
        }
        return fields;
    }

    @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);
        }
        return log;
    }
}
Loading