Skip to content

Commit

Permalink
Adds autofill provider package name logging for WebView
Browse files Browse the repository at this point in the history
This CL adds recognition for AwG, Samsung Pass and Last Pass.

(cherry picked from commit f126971)

Bug: 1448099
Low-Coverage-Reason: Only adding metrics
Change-Id: Id4400999014acf452823054ba1dd111ce3eca470
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4556886
Reviewed-by: Weilun Shi <sweilun@chromium.org>
Commit-Queue: Alex Mitra <alexmitra@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Auto-Submit: Alex Mitra <alexmitra@chromium.org>
Reviewed-by: Peter Conn <peconn@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1148453}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4567732
Cr-Commit-Position: refs/branch-heads/5790@{#140}
Cr-Branched-From: 1d71a33-refs/heads/main@{#1148114}
  • Loading branch information
AlexMitraChromium authored and Chromium LUCI CQ committed May 30, 2023
1 parent 8b3aac4 commit a2496ae
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
Expand Up @@ -91,6 +91,7 @@ public AutofillManagerWrapper(Context context) {
if (componentName != null) {
mIsAwGCurrentAutofillService =
AWG_COMPONENT_NAME.equals(componentName.flattenToString());
AutofillProviderUMA.logCurrentProvider(componentName.getPackageName());
} else {
mIsAwGCurrentAutofillService = false;
}
Expand Down
Expand Up @@ -95,6 +95,22 @@ public class AutofillProviderUMA {
private static final long MAX_TIME_MILLIS = TimeUnit.SECONDS.toMillis(2);
private static final int NUM_OF_BUCKETS = 50;

// The package name of the autofill provider.
// To add a new provider, add a String for the provider's package name and an int equal to
// AUTOFILL_PROVIDER_MAX for the provider then increment AUTOFILL_PROVIDER_MAX.
// Make sure to update tools/metrics/histograms/enums.xml with the new entry. Lastly, add a case
// to the switch statement in logCurrentProvider for that provider.
private static final String UMA_AUTOFILL_PROVIDER = "Autofill.WebView.Provider.PackageName";
private static final int AUTOFILL_PROVIDER_UNKNOWN = 0;
private static final String AWG_PACKAGE_NAME = "com.google.android.gms";
private static final int AUTOFILL_PROVIDER_AWG = 1;
private static final String SAMSUNG_PASS_PACKAGE_NAME =
"com.samsung.android.samsungpassautofill";
private static final int AUTOFILL_PROVIDER_SAMSUNG_PASS = 2;
private static final String LASTPASS_PACKAGE_NAME = "com.lastpass.lpandroid";
private static final int AUTOFILL_PROVIDER_LAST_PASS = 3;
private static final int AUTOFILL_PROVIDER_MAX = 4;

private static void recordTimesHistogram(String name, long durationMillis) {
RecordHistogram.recordCustomTimesHistogram(
name, durationMillis, MIN_TIME_MILLIS, MAX_TIME_MILLIS, NUM_OF_BUCKETS);
Expand Down Expand Up @@ -334,6 +350,28 @@ public void onServerTypeAvailable(FormData formData, boolean afterSessionStarted
mRecorder.onServerTypeAvailable(formData, afterSessionStarted);
}

static void logCurrentProvider(String packageName) {
switch (packageName) {
case AWG_PACKAGE_NAME:
recordUmaAutofillProvider(AUTOFILL_PROVIDER_AWG);
break;
case SAMSUNG_PASS_PACKAGE_NAME:
recordUmaAutofillProvider(AUTOFILL_PROVIDER_SAMSUNG_PASS);
break;
case LASTPASS_PACKAGE_NAME:
recordUmaAutofillProvider(AUTOFILL_PROVIDER_LAST_PASS);
break;
default:
recordUmaAutofillProvider(AUTOFILL_PROVIDER_UNKNOWN);
break;
}
}

private static void recordUmaAutofillProvider(int autofillProvider) {
RecordHistogram.recordEnumeratedHistogram(
UMA_AUTOFILL_PROVIDER, autofillProvider, AUTOFILL_PROVIDER_MAX);
}

private void recordSession() {
if (mAutofillDisabled != null && !mAutofillDisabled.booleanValue() && mRecorder != null) {
mRecorder.recordHistogram();
Expand Down
7 changes: 7 additions & 0 deletions tools/metrics/histograms/enums.xml
Expand Up @@ -9495,6 +9495,13 @@ others/histograms.xml -->
<int value="3" label="Upload / conflict resolution in initial sync"/>
</enum>

<enum name="AutofillProviderPackageName">
<int value="0" label="Unknown"/>
<int value="1" label="Autofill with Google"/>
<int value="2" label="Samsung Pass"/>
<int value="3" label="LastPass"/>
</enum>

<enum name="AutofillQualitiyMetricType">
<int value="0" label="TYPE_SUBMISSION"/>
<int value="1" label="TYPE_NO_SUBMISSION"/>
Expand Down
12 changes: 12 additions & 0 deletions tools/metrics/histograms/metadata/autofill/histograms.xml
Expand Up @@ -5442,6 +5442,18 @@ chromium-metrics-reviews@google.com.
<token key="AutofillFormType" variants="AutofillFormType"/>
</histogram>

<histogram name="Autofill.WebView.Provider.PackageName"
enum="AutofillProviderPackageName" expires_after="2024-05-23">
<owner>alexmitra@chromium.org</owner>
<owner>src/android_webview/OWNERS</owner>
<summary>
Records the Autofill provider on the device if it matches a fixed list of
package names or unknown otherwise. This is recorded once for a given
AwContents. It is recorded on AutofillProvider initialization. Only recorded
in Android P and beyond.
</summary>
</histogram>

<histogram name="Autofill.WebView.ServerPrediction.AwGSuggestionAvailability"
enum="AutofillAwGSuggestionAvailability" expires_after="2023-12-12">
<owner>battre@chromium.org</owner>
Expand Down

0 comments on commit a2496ae

Please sign in to comment.