| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.physicalweb; | 5 package org.chromium.chrome.browser.physicalweb; |
| 6 | 6 |
| 7 import android.content.SharedPreferences; | 7 import android.content.SharedPreferences; |
| 8 import android.os.AsyncTask; | 8 import android.os.AsyncTask; |
| 9 | 9 |
| 10 import org.json.JSONArray; | 10 import org.json.JSONArray; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * Centralizes UMA data collection for the Physical Web feature. | 25 * Centralizes UMA data collection for the Physical Web feature. |
| 26 */ | 26 */ |
| 27 @ThreadSafe | 27 @ThreadSafe |
| 28 public class PhysicalWebUma { | 28 public class PhysicalWebUma { |
| 29 private static final String TAG = "PhysicalWeb"; | 29 private static final String TAG = "PhysicalWeb"; |
| 30 private static final String HAS_DEFERRED_METRICS_KEY = "PhysicalWeb.HasDefer
redMetrics"; | 30 private static final String HAS_DEFERRED_METRICS_KEY = "PhysicalWeb.HasDefer
redMetrics"; |
| 31 private static final String OPT_IN_DECLINE_BUTTON_PRESS_COUNT = | 31 private static final String OPT_IN_DECLINE_BUTTON_PRESS_COUNT = |
| 32 "PhysicalWeb.OptIn.DeclineButtonPressed"; | 32 "PhysicalWeb.OptIn.DeclineButtonPressed"; |
| 33 private static final String OPT_IN_ENABLE_BUTTON_PRESS_COUNT = | 33 private static final String OPT_IN_ENABLE_BUTTON_PRESS_COUNT = |
| 34 "PhysicalWeb.OptIn.EnableButtonPressed"; | 34 "PhysicalWeb.OptIn.EnableButtonPressed"; |
| 35 private static final String OPT_IN_HIGH_PRIORITY_NOTIFICATION_COUNT = | |
| 36 "PhysicalWeb.OptIn.HighPriorityNotificationShown"; | |
| 37 private static final String OPT_IN_MIN_PRIORITY_NOTIFICATION_COUNT = | |
| 38 "PhysicalWeb.OptIn.MinPriorityNotificationShown"; | |
| 39 private static final String OPT_IN_NOTIFICATION_PRESS_COUNT = | |
| 40 "PhysicalWeb.OptIn.NotificationPressed"; | |
| 41 private static final String PREFS_FEATURE_DISABLED_COUNT = "PhysicalWeb.Pref
s.FeatureDisabled"; | 35 private static final String PREFS_FEATURE_DISABLED_COUNT = "PhysicalWeb.Pref
s.FeatureDisabled"; |
| 42 private static final String PREFS_FEATURE_ENABLED_COUNT = "PhysicalWeb.Prefs
.FeatureEnabled"; | 36 private static final String PREFS_FEATURE_ENABLED_COUNT = "PhysicalWeb.Prefs
.FeatureEnabled"; |
| 43 private static final String PREFS_LOCATION_DENIED_COUNT = "PhysicalWeb.Prefs
.LocationDenied"; | 37 private static final String PREFS_LOCATION_DENIED_COUNT = "PhysicalWeb.Prefs
.LocationDenied"; |
| 44 private static final String PREFS_LOCATION_GRANTED_COUNT = "PhysicalWeb.Pref
s.LocationGranted"; | 38 private static final String PREFS_LOCATION_GRANTED_COUNT = "PhysicalWeb.Pref
s.LocationGranted"; |
| 45 private static final String PWS_BACKGROUND_RESOLVE_TIMES = "PhysicalWeb.Reso
lveTime.Background"; | 39 private static final String PWS_BACKGROUND_RESOLVE_TIMES = "PhysicalWeb.Reso
lveTime.Background"; |
| 46 private static final String PWS_FOREGROUND_RESOLVE_TIMES = "PhysicalWeb.Reso
lveTime.Foreground"; | 40 private static final String PWS_FOREGROUND_RESOLVE_TIMES = "PhysicalWeb.Reso
lveTime.Foreground"; |
| 47 private static final String PWS_REFRESH_RESOLVE_TIMES = "PhysicalWeb.Resolve
Time.Refresh"; | 41 private static final String PWS_REFRESH_RESOLVE_TIMES = "PhysicalWeb.Resolve
Time.Refresh"; |
| 48 private static final String OPT_IN_NOTIFICATION_PRESS_DELAYS = | |
| 49 "PhysicalWeb.ReferralDelay.OptInNotification"; | |
| 50 private static final String STANDARD_NOTIFICATION_PRESS_DELAYS = | |
| 51 "PhysicalWeb.ReferralDelay.StandardNotification"; | |
| 52 private static final String URL_SELECTED_COUNT = "PhysicalWeb.UrlSelected"; | 42 private static final String URL_SELECTED_COUNT = "PhysicalWeb.UrlSelected"; |
| 53 private static final String TOTAL_URLS_INITIAL_COUNTS = | 43 private static final String TOTAL_URLS_INITIAL_COUNTS = |
| 54 "PhysicalWeb.TotalUrls.OnInitialDisplay"; | 44 "PhysicalWeb.TotalUrls.OnInitialDisplay"; |
| 55 private static final String TOTAL_URLS_REFRESH_COUNTS = | 45 private static final String TOTAL_URLS_REFRESH_COUNTS = |
| 56 "PhysicalWeb.TotalUrls.OnRefresh"; | 46 "PhysicalWeb.TotalUrls.OnRefresh"; |
| 57 private static final String ACTIVITY_REFERRALS = "PhysicalWeb.ActivityReferr
al"; | 47 private static final String ACTIVITY_REFERRALS = "PhysicalWeb.ActivityReferr
al"; |
| 58 private static final String PHYSICAL_WEB_STATE = "PhysicalWeb.State"; | 48 private static final String PHYSICAL_WEB_STATE = "PhysicalWeb.State"; |
| 59 private static final String LAUNCH_FROM_PREFERENCES = "LaunchFromPreferences
"; | 49 private static final String LAUNCH_FROM_PREFERENCES = "LaunchFromPreferences
"; |
| 60 private static final String LAUNCH_FROM_DIAGNOSTICS = "LaunchFromDiagnostics
"; | 50 private static final String LAUNCH_FROM_DIAGNOSTICS = "LaunchFromDiagnostics
"; |
| 61 private static final String BLUETOOTH = "Bluetooth"; | 51 private static final String BLUETOOTH = "Bluetooth"; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 81 } | 71 } |
| 82 | 72 |
| 83 /** | 73 /** |
| 84 * Records a tap on the opt-in enable button. | 74 * Records a tap on the opt-in enable button. |
| 85 */ | 75 */ |
| 86 public static void onOptInEnableButtonPressed() { | 76 public static void onOptInEnableButtonPressed() { |
| 87 handleAction(OPT_IN_ENABLE_BUTTON_PRESS_COUNT); | 77 handleAction(OPT_IN_ENABLE_BUTTON_PRESS_COUNT); |
| 88 } | 78 } |
| 89 | 79 |
| 90 /** | 80 /** |
| 91 * Records a display of a high priority opt-in notification. | |
| 92 */ | |
| 93 public static void onOptInHighPriorityNotificationShown() { | |
| 94 handleAction(OPT_IN_HIGH_PRIORITY_NOTIFICATION_COUNT); | |
| 95 } | |
| 96 | |
| 97 /** | |
| 98 * Records a display of a min priority opt-in notification. | |
| 99 */ | |
| 100 public static void onOptInMinPriorityNotificationShown() { | |
| 101 handleAction(OPT_IN_MIN_PRIORITY_NOTIFICATION_COUNT); | |
| 102 } | |
| 103 | |
| 104 /** | |
| 105 * Records a display of the opt-in activity. | |
| 106 */ | |
| 107 public static void onOptInNotificationPressed() { | |
| 108 handleAction(OPT_IN_NOTIFICATION_PRESS_COUNT); | |
| 109 } | |
| 110 | |
| 111 /** | |
| 112 * Records when the user disables the Physical Web fetaure. | 81 * Records when the user disables the Physical Web fetaure. |
| 113 */ | 82 */ |
| 114 public static void onPrefsFeatureDisabled() { | 83 public static void onPrefsFeatureDisabled() { |
| 115 handleAction(PREFS_FEATURE_DISABLED_COUNT); | 84 handleAction(PREFS_FEATURE_DISABLED_COUNT); |
| 116 } | 85 } |
| 117 | 86 |
| 118 /** | 87 /** |
| 119 * Records when the user enables the Physical Web fetaure. | 88 * Records when the user enables the Physical Web fetaure. |
| 120 */ | 89 */ |
| 121 public static void onPrefsFeatureEnabled() { | 90 public static void onPrefsFeatureEnabled() { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 } | 158 } |
| 190 | 159 |
| 191 /** | 160 /** |
| 192 * Records a ListUrlActivity referral. | 161 * Records a ListUrlActivity referral. |
| 193 * @param refer The type of referral. This enum is listed as PhysicalWebAct
ivityReferer in | 162 * @param refer The type of referral. This enum is listed as PhysicalWebAct
ivityReferer in |
| 194 * histograms.xml. | 163 * histograms.xml. |
| 195 */ | 164 */ |
| 196 public static void onActivityReferral(int referer) { | 165 public static void onActivityReferral(int referer) { |
| 197 handleEnum(ACTIVITY_REFERRALS, referer, ListUrlsActivity.REFERER_BOUNDAR
Y); | 166 handleEnum(ACTIVITY_REFERRALS, referer, ListUrlsActivity.REFERER_BOUNDAR
Y); |
| 198 switch (referer) { | 167 switch (referer) { |
| 199 case ListUrlsActivity.NOTIFICATION_REFERER: | |
| 200 handleTime(STANDARD_NOTIFICATION_PRESS_DELAYS, | |
| 201 UrlManager.getInstance().getTimeSinceNotificationUpdate(
), | |
| 202 TimeUnit.MILLISECONDS); | |
| 203 break; | |
| 204 case ListUrlsActivity.OPTIN_REFERER: | |
| 205 handleTime(OPT_IN_NOTIFICATION_PRESS_DELAYS, | |
| 206 UrlManager.getInstance().getTimeSinceNotificationUpdate(
), | |
| 207 TimeUnit.MILLISECONDS); | |
| 208 break; | |
| 209 case ListUrlsActivity.PREFERENCE_REFERER: | 168 case ListUrlsActivity.PREFERENCE_REFERER: |
| 210 recordPhysicalWebState(LAUNCH_FROM_PREFERENCES); | 169 recordPhysicalWebState(LAUNCH_FROM_PREFERENCES); |
| 211 break; | 170 break; |
| 212 case ListUrlsActivity.DIAGNOSTICS_REFERER: | 171 case ListUrlsActivity.DIAGNOSTICS_REFERER: |
| 213 recordPhysicalWebState(LAUNCH_FROM_DIAGNOSTICS); | 172 recordPhysicalWebState(LAUNCH_FROM_DIAGNOSTICS); |
| 214 break; | 173 break; |
| 215 default: | 174 default: |
| 216 break; | 175 break; |
| 217 } | 176 } |
| 218 } | 177 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 275 |
| 317 UmaUploader(SharedPreferences prefs) { | 276 UmaUploader(SharedPreferences prefs) { |
| 318 mPrefs = prefs; | 277 mPrefs = prefs; |
| 319 } | 278 } |
| 320 | 279 |
| 321 @Override | 280 @Override |
| 322 public void run() { | 281 public void run() { |
| 323 uploadActions(URL_SELECTED_COUNT); | 282 uploadActions(URL_SELECTED_COUNT); |
| 324 uploadActions(OPT_IN_DECLINE_BUTTON_PRESS_COUNT); | 283 uploadActions(OPT_IN_DECLINE_BUTTON_PRESS_COUNT); |
| 325 uploadActions(OPT_IN_ENABLE_BUTTON_PRESS_COUNT); | 284 uploadActions(OPT_IN_ENABLE_BUTTON_PRESS_COUNT); |
| 326 uploadActions(OPT_IN_HIGH_PRIORITY_NOTIFICATION_COUNT); | |
| 327 uploadActions(OPT_IN_MIN_PRIORITY_NOTIFICATION_COUNT); | |
| 328 uploadActions(OPT_IN_NOTIFICATION_PRESS_COUNT); | |
| 329 uploadActions(PREFS_FEATURE_DISABLED_COUNT); | 285 uploadActions(PREFS_FEATURE_DISABLED_COUNT); |
| 330 uploadActions(PREFS_FEATURE_ENABLED_COUNT); | 286 uploadActions(PREFS_FEATURE_ENABLED_COUNT); |
| 331 uploadActions(PREFS_LOCATION_DENIED_COUNT); | 287 uploadActions(PREFS_LOCATION_DENIED_COUNT); |
| 332 uploadActions(PREFS_LOCATION_GRANTED_COUNT); | 288 uploadActions(PREFS_LOCATION_GRANTED_COUNT); |
| 333 uploadTimes(PWS_BACKGROUND_RESOLVE_TIMES, TimeUnit.MILLISECONDS); | 289 uploadTimes(PWS_BACKGROUND_RESOLVE_TIMES, TimeUnit.MILLISECONDS); |
| 334 uploadTimes(PWS_FOREGROUND_RESOLVE_TIMES, TimeUnit.MILLISECONDS); | 290 uploadTimes(PWS_FOREGROUND_RESOLVE_TIMES, TimeUnit.MILLISECONDS); |
| 335 uploadTimes(PWS_REFRESH_RESOLVE_TIMES, TimeUnit.MILLISECONDS); | 291 uploadTimes(PWS_REFRESH_RESOLVE_TIMES, TimeUnit.MILLISECONDS); |
| 336 uploadTimes(STANDARD_NOTIFICATION_PRESS_DELAYS, TimeUnit.MILLISECOND
S); | |
| 337 uploadTimes(OPT_IN_NOTIFICATION_PRESS_DELAYS, TimeUnit.MILLISECONDS)
; | |
| 338 uploadCounts(TOTAL_URLS_INITIAL_COUNTS); | 292 uploadCounts(TOTAL_URLS_INITIAL_COUNTS); |
| 339 uploadCounts(TOTAL_URLS_REFRESH_COUNTS); | 293 uploadCounts(TOTAL_URLS_REFRESH_COUNTS); |
| 340 uploadEnums(ACTIVITY_REFERRALS, ListUrlsActivity.REFERER_BOUNDARY); | 294 uploadEnums(ACTIVITY_REFERRALS, ListUrlsActivity.REFERER_BOUNDARY); |
| 341 uploadEnums(createStateString(LOCATION_SERVICES, LAUNCH_FROM_DIAGNOS
TICS), | 295 uploadEnums(createStateString(LOCATION_SERVICES, LAUNCH_FROM_DIAGNOS
TICS), |
| 342 BOOLEAN_BOUNDARY); | 296 BOOLEAN_BOUNDARY); |
| 343 uploadEnums(createStateString(LOCATION_PERMISSION, LAUNCH_FROM_DIAGN
OSTICS), | 297 uploadEnums(createStateString(LOCATION_PERMISSION, LAUNCH_FROM_DIAGN
OSTICS), |
| 344 BOOLEAN_BOUNDARY); | 298 BOOLEAN_BOUNDARY); |
| 345 uploadEnums(createStateString(BLUETOOTH, LAUNCH_FROM_DIAGNOSTICS), T
RISTATE_BOUNDARY); | 299 uploadEnums(createStateString(BLUETOOTH, LAUNCH_FROM_DIAGNOSTICS), T
RISTATE_BOUNDARY); |
| 346 uploadEnums(createStateString(DATA_CONNECTION, LAUNCH_FROM_DIAGNOSTI
CS), | 300 uploadEnums(createStateString(DATA_CONNECTION, LAUNCH_FROM_DIAGNOSTI
CS), |
| 347 BOOLEAN_BOUNDARY); | 301 BOOLEAN_BOUNDARY); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 if (values == null) { | 399 if (values == null) { |
| 446 Log.e(TAG, "Error reporting " + key + " with values: " + jsonEnu
msStr); | 400 Log.e(TAG, "Error reporting " + key + " with values: " + jsonEnu
msStr); |
| 447 return; | 401 return; |
| 448 } | 402 } |
| 449 for (Integer value: values) { | 403 for (Integer value: values) { |
| 450 RecordHistogram.recordEnumeratedHistogram(key, value, boundary); | 404 RecordHistogram.recordEnumeratedHistogram(key, value, boundary); |
| 451 } | 405 } |
| 452 } | 406 } |
| 453 } | 407 } |
| 454 } | 408 } |
| OLD | NEW |