Merge "Remove activity name from autofill metrics logger." into sc-dev

This commit is contained in:
Adam He
2021-07-01 18:38:06 +00:00
committed by Android (Google) Code Review
4 changed files with 16 additions and 13 deletions

View File

@@ -32,9 +32,12 @@ public final class Helper {
*/ */
public static void logResponse(int type, @NonNull String servicePackageName, public static void logResponse(int type, @NonNull String servicePackageName,
@NonNull ComponentName componentName, int mSessionId, long durationMs) { @NonNull ComponentName componentName, int mSessionId, long durationMs) {
// Remove activity name from logging
final ComponentName sanitizedComponentName =
new ComponentName(componentName.getPackageName(), "");
final LogMaker log = new LogMaker(MetricsEvent.AUTOFILL_AUGMENTED_RESPONSE) final LogMaker log = new LogMaker(MetricsEvent.AUTOFILL_AUGMENTED_RESPONSE)
.setType(type) .setType(type)
.setComponentName(componentName) .setComponentName(sanitizedComponentName)
.addTaggedData(MetricsEvent.FIELD_AUTOFILL_SESSION_ID, mSessionId) .addTaggedData(MetricsEvent.FIELD_AUTOFILL_SESSION_ID, mSessionId)
.addTaggedData(MetricsEvent.FIELD_AUTOFILL_SERVICE, servicePackageName) .addTaggedData(MetricsEvent.FIELD_AUTOFILL_SERVICE, servicePackageName)
.addTaggedData(MetricsEvent.FIELD_AUTOFILL_DURATION, durationMs); .addTaggedData(MetricsEvent.FIELD_AUTOFILL_DURATION, durationMs);

View File

@@ -2459,7 +2459,10 @@ public final class AutofillManager {
// Client should never be null here, but it doesn't hurt to check... // Client should never be null here, but it doesn't hurt to check...
log.setPackageName(mContext.getPackageName()); log.setPackageName(mContext.getPackageName());
} else { } else {
log.setComponentName(client.autofillClientGetComponentName()); // Remove activity name from logging
final ComponentName sanitizedComponentName =
new ComponentName(client.autofillClientGetComponentName().getPackageName(), "");
log.setComponentName(sanitizedComponentName);
} }
return log; return log;
} }

View File

@@ -1515,16 +1515,10 @@ final class AutofillManagerServiceImpl
final int intDuration = duration > Integer.MAX_VALUE final int intDuration = duration > Integer.MAX_VALUE
? Integer.MAX_VALUE ? Integer.MAX_VALUE
: (int) duration; : (int) duration;
// NOTE: not using Helper.newLogMaker() because we're setting the componentName instead
// of package name final LogMaker log = Helper.newLogMaker(MetricsEvent.AUTOFILL_SERVICE_DISABLED_ACTIVITY,
final LogMaker log = new LogMaker(MetricsEvent.AUTOFILL_SERVICE_DISABLED_ACTIVITY) componentName, getServicePackageName(), sessionId, compatMode)
.setComponentName(componentName) .addTaggedData(MetricsEvent.FIELD_AUTOFILL_DURATION, intDuration);
.addTaggedData(MetricsEvent.FIELD_AUTOFILL_SERVICE, getServicePackageName())
.addTaggedData(MetricsEvent.FIELD_AUTOFILL_DURATION, intDuration)
.addTaggedData(MetricsEvent.FIELD_AUTOFILL_SESSION_ID, sessionId);
if (compatMode) {
log.addTaggedData(MetricsEvent.FIELD_AUTOFILL_COMPAT_MODE, 1);
}
mMetricsLogger.write(log); mMetricsLogger.write(log);
} }
} }

View File

@@ -127,8 +127,11 @@ public final class Helper {
@NonNull @NonNull
public static LogMaker newLogMaker(int category, @NonNull ComponentName componentName, public static LogMaker newLogMaker(int category, @NonNull ComponentName componentName,
@NonNull String servicePackageName, int sessionId, boolean compatMode) { @NonNull String servicePackageName, int sessionId, boolean compatMode) {
// Remove activity name from logging
final ComponentName sanitizedComponentName =
new ComponentName(componentName.getPackageName(), "");
return newLogMaker(category, servicePackageName, sessionId, compatMode) return newLogMaker(category, servicePackageName, sessionId, compatMode)
.setComponentName(componentName); .setComponentName(sanitizedComponentName);
} }
public static void printlnRedactedText(@NonNull PrintWriter pw, @Nullable CharSequence text) { public static void printlnRedactedText(@NonNull PrintWriter pw, @Nullable CharSequence text) {