Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(998)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebUma.java

Issue 1547543003: Record UMA for Physical Web settings fragment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add UMA for location permission request Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PhysicalWebPreferenceFragment.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebUma.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebUma.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebUma.java
index 9c6d6f50dbdfd2a54bb06719f0ad5a183ab7f6a5..43a3aa1feb7d3154378d8d628be0f92ace876b75 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebUma.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebUma.java
@@ -24,9 +24,13 @@ import javax.annotation.concurrent.ThreadSafe;
* Centralizes UMA data collection for the Physical Web feature.
*/
@ThreadSafe
-class PhysicalWebUma {
+public class PhysicalWebUma {
private static final String TAG = "PhysicalWeb";
private static final String NOTIFICATION_PRESS_COUNT = "PhysicalWeb.NotificationPressed";
+ private static final String PREFS_FEATURE_DISABLED_COUNT = "PhysicalWeb.Prefs.FeatureDisabled";
+ private static final String PREFS_FEATURE_ENABLED_COUNT = "PhysicalWeb.Prefs.FeatureEnabled";
+ private static final String PREFS_LOCATION_DENIED_COUNT = "PhysicalWeb.Prefs.LocationDenied";
+ private static final String PREFS_LOCATION_GRANTED_COUNT = "PhysicalWeb.Prefs.LocationGranted";
private static final String PWS_BACKGROUND_RESOLVE_TIMES = "PhysicalWeb.ResolveTime.Background";
private static final String PWS_FOREGROUND_RESOLVE_TIMES = "PhysicalWeb.ResolveTime.Foreground";
private static final String URL_SELECTED_COUNT = "PhysicalWeb.UrlSelected";
@@ -48,6 +52,36 @@ class PhysicalWebUma {
}
/**
+ * Records when the user disables the Physical Web fetaure.
+ */
+ public static void onPrefsFeatureDisabled(Context context) {
+ handleAction(context, PREFS_FEATURE_DISABLED_COUNT);
+ }
+
+ /**
+ * Records when the user enables the Physical Web fetaure.
+ */
+ public static void onPrefsFeatureEnabled(Context context) {
+ handleAction(context, PREFS_FEATURE_ENABLED_COUNT);
+ }
+
+ /**
+ * Records when the user denies the location permission when enabling the Physical Web from the
+ * privacy settings menu.
+ */
+ public static void onPrefsLocationDenied(Context context) {
+ handleAction(context, PREFS_LOCATION_DENIED_COUNT);
+ }
+
+ /**
+ * Records when the user grants the location permission when enabling the Physical Web from the
+ * privacy settings menu.
+ */
+ public static void onPrefsLocationGranted(Context context) {
+ handleAction(context, PREFS_LOCATION_GRANTED_COUNT);
+ }
+
+ /**
* Records a response time from PWS for a resolution during a background scan.
* @param duration The length of time PWS took to respond.
*/
@@ -89,6 +123,10 @@ class PhysicalWebUma {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
uploader.notificationPressCount = prefs.getInt(NOTIFICATION_PRESS_COUNT, 0);
uploader.urlSelectedCount = prefs.getInt(URL_SELECTED_COUNT, 0);
+ uploader.prefsFeatureDisabledCount = prefs.getInt(PREFS_FEATURE_DISABLED_COUNT, 0);
+ uploader.prefsFeatureEnabledCount = prefs.getInt(PREFS_FEATURE_ENABLED_COUNT, 0);
+ uploader.prefsLocationDeniedCount = prefs.getInt(PREFS_LOCATION_DENIED_COUNT, 0);
+ uploader.prefsLocationGrantedCount = prefs.getInt(PREFS_LOCATION_GRANTED_COUNT, 0);
uploader.pwsBackgroundResolveTimes = prefs.getString(PWS_BACKGROUND_RESOLVE_TIMES, "[]");
uploader.pwsForegroundResolveTimes = prefs.getString(PWS_FOREGROUND_RESOLVE_TIMES, "[]");
uploader.urlsDisplayedCounts = prefs.getString(URLS_DISPLAYED_COUNTS, "[]");
@@ -102,6 +140,10 @@ class PhysicalWebUma {
prefs.edit()
.remove(NOTIFICATION_PRESS_COUNT)
.remove(URL_SELECTED_COUNT)
+ .remove(PREFS_FEATURE_DISABLED_COUNT)
+ .remove(PREFS_FEATURE_ENABLED_COUNT)
+ .remove(PREFS_LOCATION_DENIED_COUNT)
+ .remove(PREFS_LOCATION_GRANTED_COUNT)
.remove(PWS_BACKGROUND_RESOLVE_TIMES)
.remove(PWS_FOREGROUND_RESOLVE_TIMES)
.remove(URLS_DISPLAYED_COUNTS)
@@ -152,6 +194,10 @@ class PhysicalWebUma {
private static class UmaUploader implements Runnable {
public int notificationPressCount;
public int urlSelectedCount;
+ public int prefsFeatureDisabledCount;
+ public int prefsFeatureEnabledCount;
+ public int prefsLocationDeniedCount;
+ public int prefsLocationGrantedCount;
public String pwsBackgroundResolveTimes;
public String pwsForegroundResolveTimes;
public String urlsDisplayedCounts;
@@ -159,6 +205,10 @@ class PhysicalWebUma {
public boolean isEmpty() {
return notificationPressCount == 0
&& urlSelectedCount == 0
+ && prefsFeatureDisabledCount == 0
+ && prefsFeatureEnabledCount == 0
+ && prefsLocationDeniedCount == 0
+ && prefsLocationGrantedCount == 0
&& pwsBackgroundResolveTimes.equals("[]")
&& pwsForegroundResolveTimes.equals("[]")
&& urlsDisplayedCounts.equals("[]");
@@ -171,6 +221,10 @@ class PhysicalWebUma {
public void run() {
uploadActions(notificationPressCount, NOTIFICATION_PRESS_COUNT);
uploadActions(urlSelectedCount, URL_SELECTED_COUNT);
+ uploadActions(prefsFeatureDisabledCount, PREFS_FEATURE_DISABLED_COUNT);
+ uploadActions(prefsFeatureEnabledCount, PREFS_FEATURE_ENABLED_COUNT);
+ uploadActions(prefsLocationDeniedCount, PREFS_LOCATION_DENIED_COUNT);
+ uploadActions(prefsLocationGrantedCount, PREFS_LOCATION_GRANTED_COUNT);
uploadTimes(pwsBackgroundResolveTimes, PWS_BACKGROUND_RESOLVE_TIMES,
TimeUnit.MILLISECONDS);
uploadTimes(pwsForegroundResolveTimes, PWS_FOREGROUND_RESOLVE_TIMES,
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PhysicalWebPreferenceFragment.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698