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

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

Issue 1887523002: Record UMA for Physical Web state on debug actions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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 | no next file » | 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 867f56f1888fb831258f4726a1a69a8c97382ca3..780402e82d4db35dedff9ff55572f68fb474f8fe 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
@@ -53,6 +53,16 @@ public class PhysicalWebUma {
private static final String TOTAL_URLS_REFRESH_COUNTS =
"PhysicalWeb.TotalUrls.OnRefresh";
private static final String ACTIVITY_REFERRALS = "PhysicalWeb.ActivityReferral";
+ private static final String PHYSICAL_WEB_STATE = "PhysicalWeb.State";
+ private static final String LAUNCH_FROM_PREFERENCES = "LaunchFromPreferences";
+ private static final String LAUNCH_FROM_DIAGNOSTICS = "LaunchFromDiagnostics";
+ private static final String BLUETOOTH = "Bluetooth";
+ private static final String DATA_CONNECTION = "DataConnection";
+ private static final String LOCATION_PERMISSION = "LocationPermission";
+ private static final String LOCATION_SERVICES = "LocationServices";
+ private static final String PREFERENCE = "Preference";
+ private static final int BOOLEAN_BOUNDARY = 2;
+ private static final int TRISTATE_BOUNDARY = 3;
private static boolean sUploadAllowed = false;
/**
@@ -173,30 +183,56 @@ public class PhysicalWebUma {
* histograms.xml.
*/
public static void onActivityReferral(Context context, int referer) {
- if (sUploadAllowed) {
- RecordHistogram.recordEnumeratedHistogram(
- ACTIVITY_REFERRALS, referer, ListUrlsActivity.REFERER_BOUNDARY);
- } else {
- storeValue(context, ACTIVITY_REFERRALS, referer);
- }
- long delay;
+ handleEnum(context, ACTIVITY_REFERRALS, referer, ListUrlsActivity.REFERER_BOUNDARY);
switch (referer) {
case ListUrlsActivity.NOTIFICATION_REFERER:
- delay = UrlManager.getInstance(context).getTimeSinceNotificationUpdate();
- handleTime(context, STANDARD_NOTIFICATION_PRESS_DELAYS, delay,
+ handleTime(context, STANDARD_NOTIFICATION_PRESS_DELAYS,
+ UrlManager.getInstance(context).getTimeSinceNotificationUpdate(),
TimeUnit.MILLISECONDS);
break;
case ListUrlsActivity.OPTIN_REFERER:
- delay = UrlManager.getInstance(context).getTimeSinceNotificationUpdate();
- handleTime(context, OPT_IN_NOTIFICATION_PRESS_DELAYS, delay,
+ handleTime(context, OPT_IN_NOTIFICATION_PRESS_DELAYS,
+ UrlManager.getInstance(context).getTimeSinceNotificationUpdate(),
TimeUnit.MILLISECONDS);
break;
+ case ListUrlsActivity.PREFERENCE_REFERER:
+ recordPhysicalWebState(context, LAUNCH_FROM_PREFERENCES);
+ break;
+ case ListUrlsActivity.DIAGNOSTICS_REFERER:
+ recordPhysicalWebState(context, LAUNCH_FROM_DIAGNOSTICS);
+ break;
default:
break;
}
}
/**
+ * Calculate a Physical Web state.
+ * The Physical Web state includes:
+ * - The location provider
+ * - The location permission
+ * - The bluetooth status
+ * - The data connection status
+ * - The Physical Web preference status
+ */
+ public static void recordPhysicalWebState(Context context, String actionName) {
+ handleEnum(context, createStateString(LOCATION_SERVICES, actionName),
Yaron 2016/04/14 02:28:46 you need to add the new histograms to histograms.x
cco3 2016/04/15 22:12:56 They are already there. I didn't take them out wi
+ Utils.isLocationServicesEnabled(context) ? 1 : 0, BOOLEAN_BOUNDARY);
+ handleEnum(context, createStateString(LOCATION_PERMISSION, actionName),
+ Utils.isLocationPermissionGranted(context) ? 1 : 0, BOOLEAN_BOUNDARY);
+ handleEnum(context, createStateString(BLUETOOTH, actionName),
+ Utils.getBluetoothEnabledStatus(context), TRISTATE_BOUNDARY);
+ handleEnum(context, createStateString(DATA_CONNECTION, actionName),
+ Utils.isDataConnectionActive(context) ? 1 : 0, BOOLEAN_BOUNDARY);
+ int preferenceState = 2;
+ if (!PhysicalWeb.isOnboarding(context)) {
+ preferenceState = PhysicalWeb.isPhysicalWebPreferenceEnabled(context) ? 1 : 0;
+ }
+ handleEnum(context, createStateString(PREFERENCE, actionName),
+ preferenceState, TRISTATE_BOUNDARY);
+ }
+
+ /**
* Uploads metrics that we have deferred for uploading.
* Additionally, this method will cause future stat records not to be deferred and instead
* uploaded immediately.
@@ -212,6 +248,10 @@ public class PhysicalWebUma {
}
}
+ private static String createStateString(String stateName, String actionName) {
+ return PHYSICAL_WEB_STATE + "." + stateName + "." + actionName;
+ }
+
private static void storeAction(Context context, String key) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int count = prefs.getInt(key, 0);
@@ -256,6 +296,14 @@ public class PhysicalWebUma {
}
}
+ private static void handleEnum(Context context, String key, int value, int boundary) {
+ if (sUploadAllowed) {
+ RecordHistogram.recordEnumeratedHistogram(key, value, boundary);
+ } else {
+ storeValue(context, key, value);
+ }
+ }
+
private static class UmaUploader implements Runnable {
SharedPreferences mPrefs;
@@ -282,6 +330,22 @@ public class PhysicalWebUma {
uploadCounts(TOTAL_URLS_INITIAL_COUNTS);
uploadCounts(TOTAL_URLS_REFRESH_COUNTS);
uploadEnums(ACTIVITY_REFERRALS, ListUrlsActivity.REFERER_BOUNDARY);
+ uploadEnums(createStateString(LOCATION_SERVICES, LAUNCH_FROM_DIAGNOSTICS),
+ BOOLEAN_BOUNDARY);
+ uploadEnums(createStateString(LOCATION_PERMISSION, LAUNCH_FROM_DIAGNOSTICS),
+ BOOLEAN_BOUNDARY);
+ uploadEnums(createStateString(BLUETOOTH, LAUNCH_FROM_DIAGNOSTICS), TRISTATE_BOUNDARY);
+ uploadEnums(createStateString(DATA_CONNECTION, LAUNCH_FROM_DIAGNOSTICS),
+ BOOLEAN_BOUNDARY);
+ uploadEnums(createStateString(PREFERENCE, LAUNCH_FROM_DIAGNOSTICS), TRISTATE_BOUNDARY);
+ uploadEnums(createStateString(LOCATION_SERVICES, LAUNCH_FROM_PREFERENCES),
+ BOOLEAN_BOUNDARY);
+ uploadEnums(createStateString(LOCATION_PERMISSION, LAUNCH_FROM_PREFERENCES),
+ BOOLEAN_BOUNDARY);
+ uploadEnums(createStateString(BLUETOOTH, LAUNCH_FROM_PREFERENCES), TRISTATE_BOUNDARY);
+ uploadEnums(createStateString(DATA_CONNECTION, LAUNCH_FROM_PREFERENCES),
+ BOOLEAN_BOUNDARY);
+ uploadEnums(createStateString(PREFERENCE, LAUNCH_FROM_PREFERENCES), TRISTATE_BOUNDARY);
removePref(HAS_DEFERRED_METRICS_KEY);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698