}
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;
}
/**
// 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;
// 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
// 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;
// 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;
// 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;
// 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;
// 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;
// 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;
// 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;
// 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;
// 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;
// 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;
// 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;
// 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;
// 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.
@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")
@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
+ ", manuallyFilledFieldIds=" + manuallyFilledFieldIds
+ ", detectedFieldIds=" + detectedFieldIdsList
+ ", detectedFieldClassifications=" + detectedFieldClassificationsList
+ + ", appComponentName=" + appComponentName.toShortString()
+ ", compatMode=" + compatMode);
}
AutofillId[] detectedFieldsIds = null;
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));
}
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));
}
}
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;
}
@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) {
mService.logContextCommittedLocked(id, mClientState, mSelectedDatasetIds,
ignoredDatasets, changedFieldIds, changedDatasetIds,
manuallyFilledFieldIds, manuallyFilledDatasetIds,
- mComponentName.getPackageName(), mCompatMode);
+ mComponentName, mCompatMode);
}
}
mService.logContextCommittedLocked(id, mClientState, mSelectedDatasetIds,
ignoredDatasets, changedFieldIds, changedDatasetIds,
manuallyFilledFieldIds, manuallyFilledDatasetIds,
- mComponentName.getPackageName(), mCompatMode);
+ mComponentName, mCompatMode);
return;
}
final Scores scores = result.getParcelable(EXTRA_SCORES);
mService.logContextCommittedLocked(id, mClientState, mSelectedDatasetIds,
ignoredDatasets, changedFieldIds, changedDatasetIds, manuallyFilledFieldIds,
manuallyFilledDatasetIds, detectedFieldIds, detectedFieldClassifications,
- mComponentName.getPackageName(), mCompatMode);
+ mComponentName, mCompatMode);
});
fcStrategy.getScores(callback, algorithm, algorithmArgs, currentValues, userValues);
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 {
}
getUiForShowing().showFillUi(filledId, response, filterText,
- mService.getServicePackageName(), mComponentName.getPackageName(),
+ mService.getServicePackageName(), mComponentName,
mService.getServiceLabel(), mService.getServiceIcon(), this, mCompatMode);
synchronized (mLock) {
}
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) {
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;
* @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())
*/
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);
}
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() {
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;
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) {
mListener = new OneTimeListener(listener);
mOverlayControl = overlayControl;
mServicePackageName = servicePackageName;
- mPackageName = packageName;
+ mComponentName = componentName;
mCompatMode = compatMode;
context = new ContextThemeWrapper(context, THEME_ID);
}
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) {
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();