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