| 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.Context; | 7 import android.content.Context; |
| 8 import android.content.SharedPreferences; | 8 import android.content.SharedPreferences; |
| 9 import android.os.AsyncTask; | 9 import android.os.AsyncTask; |
| 10 | 10 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 /** | 190 /** |
| 191 * Records a ListUrlActivity referral. | 191 * Records a ListUrlActivity referral. |
| 192 * @param refer The type of referral. This enum is listed as PhysicalWebAct
ivityReferer in | 192 * @param refer The type of referral. This enum is listed as PhysicalWebAct
ivityReferer in |
| 193 * histograms.xml. | 193 * histograms.xml. |
| 194 */ | 194 */ |
| 195 public static void onActivityReferral(Context context, int referer) { | 195 public static void onActivityReferral(Context context, int referer) { |
| 196 handleEnum(context, ACTIVITY_REFERRALS, referer, ListUrlsActivity.REFERE
R_BOUNDARY); | 196 handleEnum(context, ACTIVITY_REFERRALS, referer, ListUrlsActivity.REFERE
R_BOUNDARY); |
| 197 switch (referer) { | 197 switch (referer) { |
| 198 case ListUrlsActivity.NOTIFICATION_REFERER: | 198 case ListUrlsActivity.NOTIFICATION_REFERER: |
| 199 handleTime(context, STANDARD_NOTIFICATION_PRESS_DELAYS, | 199 handleTime(context, STANDARD_NOTIFICATION_PRESS_DELAYS, |
| 200 UrlManager.getInstance(context).getTimeSinceNotification
Update(), | 200 UrlManager.getInstance().getTimeSinceNotificationUpdate(
), |
| 201 TimeUnit.MILLISECONDS); | 201 TimeUnit.MILLISECONDS); |
| 202 break; | 202 break; |
| 203 case ListUrlsActivity.OPTIN_REFERER: | 203 case ListUrlsActivity.OPTIN_REFERER: |
| 204 handleTime(context, OPT_IN_NOTIFICATION_PRESS_DELAYS, | 204 handleTime(context, OPT_IN_NOTIFICATION_PRESS_DELAYS, |
| 205 UrlManager.getInstance(context).getTimeSinceNotification
Update(), | 205 UrlManager.getInstance().getTimeSinceNotificationUpdate(
), |
| 206 TimeUnit.MILLISECONDS); | 206 TimeUnit.MILLISECONDS); |
| 207 break; | 207 break; |
| 208 case ListUrlsActivity.PREFERENCE_REFERER: | 208 case ListUrlsActivity.PREFERENCE_REFERER: |
| 209 recordPhysicalWebState(context, LAUNCH_FROM_PREFERENCES); | 209 recordPhysicalWebState(context, LAUNCH_FROM_PREFERENCES); |
| 210 break; | 210 break; |
| 211 case ListUrlsActivity.DIAGNOSTICS_REFERER: | 211 case ListUrlsActivity.DIAGNOSTICS_REFERER: |
| 212 recordPhysicalWebState(context, LAUNCH_FROM_DIAGNOSTICS); | 212 recordPhysicalWebState(context, LAUNCH_FROM_DIAGNOSTICS); |
| 213 break; | 213 break; |
| 214 default: | 214 default: |
| 215 break; | 215 break; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 228 public static void recordPhysicalWebState(Context context, String actionName
) { | 228 public static void recordPhysicalWebState(Context context, String actionName
) { |
| 229 handleEnum(context, createStateString(LOCATION_SERVICES, actionName), | 229 handleEnum(context, createStateString(LOCATION_SERVICES, actionName), |
| 230 Utils.isLocationServicesEnabled(context) ? 1 : 0, BOOLEAN_BOUNDA
RY); | 230 Utils.isLocationServicesEnabled(context) ? 1 : 0, BOOLEAN_BOUNDA
RY); |
| 231 handleEnum(context, createStateString(LOCATION_PERMISSION, actionName), | 231 handleEnum(context, createStateString(LOCATION_PERMISSION, actionName), |
| 232 Utils.isLocationPermissionGranted(context) ? 1 : 0, BOOLEAN_BOUN
DARY); | 232 Utils.isLocationPermissionGranted(context) ? 1 : 0, BOOLEAN_BOUN
DARY); |
| 233 handleEnum(context, createStateString(BLUETOOTH, actionName), | 233 handleEnum(context, createStateString(BLUETOOTH, actionName), |
| 234 Utils.getBluetoothEnabledStatus(context), TRISTATE_BOUNDARY); | 234 Utils.getBluetoothEnabledStatus(context), TRISTATE_BOUNDARY); |
| 235 handleEnum(context, createStateString(DATA_CONNECTION, actionName), | 235 handleEnum(context, createStateString(DATA_CONNECTION, actionName), |
| 236 Utils.isDataConnectionActive(context) ? 1 : 0, BOOLEAN_BOUNDARY)
; | 236 Utils.isDataConnectionActive(context) ? 1 : 0, BOOLEAN_BOUNDARY)
; |
| 237 int preferenceState = 2; | 237 int preferenceState = 2; |
| 238 if (!PhysicalWeb.isOnboarding(context)) { | 238 if (!PhysicalWeb.isOnboarding()) { |
| 239 preferenceState = PhysicalWeb.isPhysicalWebPreferenceEnabled(context
) ? 1 : 0; | 239 preferenceState = PhysicalWeb.isPhysicalWebPreferenceEnabled() ? 1 :
0; |
| 240 } | 240 } |
| 241 handleEnum(context, createStateString(PREFERENCE, actionName), | 241 handleEnum(context, createStateString(PREFERENCE, actionName), |
| 242 preferenceState, TRISTATE_BOUNDARY); | 242 preferenceState, TRISTATE_BOUNDARY); |
| 243 } | 243 } |
| 244 | 244 |
| 245 /** | 245 /** |
| 246 * Uploads metrics that we have deferred for uploading. | 246 * Uploads metrics that we have deferred for uploading. |
| 247 * Additionally, this method will cause future stat records not to be deferr
ed and instead | 247 * Additionally, this method will cause future stat records not to be deferr
ed and instead |
| 248 * uploaded immediately. | 248 * uploaded immediately. |
| 249 */ | 249 */ |
| 250 public static void uploadDeferredMetrics(Context context) { | 250 public static void uploadDeferredMetrics() { |
| 251 // If uploads have been explicitely requested, they are now allowed. | 251 // If uploads have been explicitely requested, they are now allowed. |
| 252 sUploadAllowed = true; | 252 sUploadAllowed = true; |
| 253 | 253 |
| 254 // Read the metrics. | 254 // Read the metrics. |
| 255 SharedPreferences prefs = ContextUtils.getAppSharedPreferences(); | 255 SharedPreferences prefs = ContextUtils.getAppSharedPreferences(); |
| 256 if (prefs.getBoolean(HAS_DEFERRED_METRICS_KEY, false)) { | 256 if (prefs.getBoolean(HAS_DEFERRED_METRICS_KEY, false)) { |
| 257 AsyncTask.THREAD_POOL_EXECUTOR.execute(new UmaUploader(prefs)); | 257 AsyncTask.THREAD_POOL_EXECUTOR.execute(new UmaUploader(prefs)); |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 | 260 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 if (values == null) { | 448 if (values == null) { |
| 449 Log.e(TAG, "Error reporting " + key + " with values: " + jsonEnu
msStr); | 449 Log.e(TAG, "Error reporting " + key + " with values: " + jsonEnu
msStr); |
| 450 return; | 450 return; |
| 451 } | 451 } |
| 452 for (Integer value: values) { | 452 for (Integer value: values) { |
| 453 RecordHistogram.recordEnumeratedHistogram(key, value, boundary); | 453 RecordHistogram.recordEnumeratedHistogram(key, value, boundary); |
| 454 } | 454 } |
| 455 } | 455 } |
| 456 } | 456 } |
| 457 } | 457 } |
| OLD | NEW |