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

This commit is contained in:
TreeHugger Robot
2018-05-25 00:55:42 +00:00
committed by Android (Google) Code Review
7 changed files with 84 additions and 51 deletions

View File

@@ -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;
}
/**

View File

@@ -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.

View File

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

View File

@@ -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);
}
return log;
public static LogMaker newLogMaker(int category, @NonNull String packageName,
@NonNull String servicePackageName, boolean compatMode) {
return newLogMaker(category, servicePackageName, compatMode).setPackageName(packageName);
}
@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) {

View File

@@ -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) {

View File

@@ -20,6 +20,7 @@ import static com.android.server.autofill.Helper.sVerbose;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.ComponentName;
import android.content.Context;
import android.content.IntentSender;
import android.graphics.drawable.Drawable;
@@ -162,21 +163,21 @@ public final class AutoFillUI {
* @param response the current fill response
* @param filterText text of the view to be filled
* @param servicePackageName package name of the autofill service filling the activity
* @param packageName package name of the activity that is filled
* @param componentName component name of the activity that is filled
* @param serviceLabel label of autofill service
* @param serviceIcon icon of autofill service
* @param callback Identifier for the caller
*/
public void showFillUi(@NonNull AutofillId focusedId, @NonNull FillResponse response,
@Nullable String filterText, @Nullable String servicePackageName,
@NonNull String packageName, @NonNull CharSequence serviceLabel,
@NonNull ComponentName componentName, @NonNull CharSequence serviceLabel,
@NonNull Drawable serviceIcon, @NonNull AutoFillUiCallback callback, boolean compatMode) {
if (sDebug) {
final int size = filterText == null ? 0 : filterText.length();
Slog.d(TAG, "showFillUi(): id=" + focusedId + ", filter=" + size + " chars");
}
final LogMaker log = Helper
.newLogMaker(MetricsEvent.AUTOFILL_FILL_UI, packageName, servicePackageName,
.newLogMaker(MetricsEvent.AUTOFILL_FILL_UI, componentName, servicePackageName,
compatMode)
.addTaggedData(MetricsEvent.FIELD_AUTOFILL_FILTERTEXT_LEN,
filterText == null ? 0 : filterText.length())
@@ -262,16 +263,18 @@ public final class AutoFillUI {
*/
public void showSaveUi(@NonNull CharSequence serviceLabel, @NonNull Drawable serviceIcon,
@Nullable String servicePackageName, @NonNull SaveInfo info,
@NonNull ValueFinder valueFinder, @NonNull String packageName,
@NonNull ValueFinder valueFinder, @NonNull ComponentName componentName,
@NonNull AutoFillUiCallback callback, @NonNull PendingUi pendingSaveUi,
boolean compatMode) {
if (sVerbose) Slog.v(TAG, "showSaveUi() for " + packageName + ": " + info);
if (sVerbose) {
Slog.v(TAG, "showSaveUi() for " + componentName.toShortString() + ": " + info);
}
int numIds = 0;
numIds += info.getRequiredIds() == null ? 0 : info.getRequiredIds().length;
numIds += info.getOptionalIds() == null ? 0 : info.getOptionalIds().length;
final LogMaker log = Helper
.newLogMaker(MetricsEvent.AUTOFILL_SAVE_UI, packageName, servicePackageName,
.newLogMaker(MetricsEvent.AUTOFILL_SAVE_UI, componentName, servicePackageName,
compatMode)
.addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUM_IDS, numIds);
@@ -281,7 +284,7 @@ public final class AutoFillUI {
}
hideAllUiThread(callback);
mSaveUi = new SaveUi(mContext, pendingSaveUi, serviceLabel, serviceIcon,
servicePackageName, packageName, info, valueFinder, mOverlayControl,
servicePackageName, componentName, info, valueFinder, mOverlayControl,
new SaveUi.OnSaveListener() {
@Override
public void onSave() {

View File

@@ -23,6 +23,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.Dialog;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
@@ -133,14 +134,14 @@ final class SaveUi {
private final CharSequence mSubTitle;
private final PendingUi mPendingUi;
private final String mServicePackageName;
private final String mPackageName;
private final ComponentName mComponentName;
private final boolean mCompatMode;
private boolean mDestroyed;
SaveUi(@NonNull Context context, @NonNull PendingUi pendingUi,
@NonNull CharSequence serviceLabel, @NonNull Drawable serviceIcon,
@Nullable String servicePackageName, @NonNull String packageName,
@Nullable String servicePackageName, @NonNull ComponentName componentName,
@NonNull SaveInfo info, @NonNull ValueFinder valueFinder,
@NonNull OverlayControl overlayControl, @NonNull OnSaveListener listener,
boolean compatMode) {
@@ -148,7 +149,7 @@ final class SaveUi {
mListener = new OneTimeListener(listener);
mOverlayControl = overlayControl;
mServicePackageName = servicePackageName;
mPackageName = packageName;
mComponentName = componentName;
mCompatMode = compatMode;
context = new ContextThemeWrapper(context, THEME_ID);
@@ -412,12 +413,12 @@ final class SaveUi {
}
private LogMaker newLogMaker(int category, int saveType) {
return Helper.newLogMaker(category, mPackageName, mServicePackageName, mCompatMode)
return Helper.newLogMaker(category, mComponentName, mServicePackageName, mCompatMode)
.addTaggedData(MetricsEvent.FIELD_AUTOFILL_SAVE_TYPE, saveType);
}
private LogMaker newLogMaker(int category) {
return Helper.newLogMaker(category, mPackageName, mServicePackageName, mCompatMode);
return Helper.newLogMaker(category, mComponentName, mServicePackageName, mCompatMode);
}
private void writeLog(int category, int saveType) {
@@ -505,7 +506,7 @@ final class SaveUi {
pw.print(prefix); pw.print("subtitle: "); pw.println(mSubTitle);
pw.print(prefix); pw.print("pendingUi: "); pw.println(mPendingUi);
pw.print(prefix); pw.print("service: "); pw.println(mServicePackageName);
pw.print(prefix); pw.print("app: "); pw.println(mPackageName);
pw.print(prefix); pw.print("app: "); pw.println(mComponentName.toShortString());
pw.print(prefix); pw.print("compat mode: "); pw.println(mCompatMode);
final View view = mDialog.getWindow().getDecorView();