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 |
11 import org.chromium.base.ContextUtils; | 11 import org.chromium.base.ContextUtils; |
12 import org.chromium.base.Log; | 12 import org.chromium.base.Log; |
13 import org.chromium.base.metrics.RecordHistogram; | 13 import org.chromium.base.metrics.RecordHistogram; |
14 import org.chromium.base.metrics.RecordUserAction; | 14 import org.chromium.base.metrics.RecordUserAction; |
15 import org.chromium.components.location.LocationUtils; | |
16 import org.json.JSONArray; | 15 import org.json.JSONArray; |
17 import org.json.JSONException; | 16 import org.json.JSONException; |
18 | 17 |
19 import java.util.concurrent.TimeUnit; | 18 import java.util.concurrent.TimeUnit; |
20 | 19 |
21 import javax.annotation.concurrent.ThreadSafe; | 20 import javax.annotation.concurrent.ThreadSafe; |
22 | 21 |
23 /** | 22 /** |
24 * Centralizes UMA data collection for the Physical Web feature. | 23 * Centralizes UMA data collection for the Physical Web feature. |
25 */ | 24 */ |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 /** | 219 /** |
221 * Calculate a Physical Web state. | 220 * Calculate a Physical Web state. |
222 * The Physical Web state includes: | 221 * The Physical Web state includes: |
223 * - The location provider | 222 * - The location provider |
224 * - The location permission | 223 * - The location permission |
225 * - The bluetooth status | 224 * - The bluetooth status |
226 * - The data connection status | 225 * - The data connection status |
227 * - The Physical Web preference status | 226 * - The Physical Web preference status |
228 */ | 227 */ |
229 public static void recordPhysicalWebState(Context context, String actionName
) { | 228 public static void recordPhysicalWebState(Context context, String actionName
) { |
230 LocationUtils locationUtils = LocationUtils.getInstance(); | |
231 handleEnum(context, createStateString(LOCATION_SERVICES, actionName), | 229 handleEnum(context, createStateString(LOCATION_SERVICES, actionName), |
232 locationUtils.isSystemLocationSettingEnabled(context) ? 1 : 0, B
OOLEAN_BOUNDARY); | 230 Utils.isLocationServicesEnabled(context) ? 1 : 0, BOOLEAN_BOUNDA
RY); |
233 handleEnum(context, createStateString(LOCATION_PERMISSION, actionName), | 231 handleEnum(context, createStateString(LOCATION_PERMISSION, actionName), |
234 locationUtils.hasAndroidLocationPermission(context) ? 1 : 0, BOO
LEAN_BOUNDARY); | 232 Utils.isLocationPermissionGranted(context) ? 1 : 0, BOOLEAN_BOUN
DARY); |
235 handleEnum(context, createStateString(BLUETOOTH, actionName), | 233 handleEnum(context, createStateString(BLUETOOTH, actionName), |
236 Utils.getBluetoothEnabledStatus(context), TRISTATE_BOUNDARY); | 234 Utils.getBluetoothEnabledStatus(context), TRISTATE_BOUNDARY); |
237 handleEnum(context, createStateString(DATA_CONNECTION, actionName), | 235 handleEnum(context, createStateString(DATA_CONNECTION, actionName), |
238 Utils.isDataConnectionActive(context) ? 1 : 0, BOOLEAN_BOUNDARY)
; | 236 Utils.isDataConnectionActive(context) ? 1 : 0, BOOLEAN_BOUNDARY)
; |
239 int preferenceState = 2; | 237 int preferenceState = 2; |
240 if (!PhysicalWeb.isOnboarding(context)) { | 238 if (!PhysicalWeb.isOnboarding(context)) { |
241 preferenceState = PhysicalWeb.isPhysicalWebPreferenceEnabled(context
) ? 1 : 0; | 239 preferenceState = PhysicalWeb.isPhysicalWebPreferenceEnabled(context
) ? 1 : 0; |
242 } | 240 } |
243 handleEnum(context, createStateString(PREFERENCE, actionName), | 241 handleEnum(context, createStateString(PREFERENCE, actionName), |
244 preferenceState, TRISTATE_BOUNDARY); | 242 preferenceState, TRISTATE_BOUNDARY); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 if (values == null) { | 448 if (values == null) { |
451 Log.e(TAG, "Error reporting " + key + " with values: " + jsonEnu
msStr); | 449 Log.e(TAG, "Error reporting " + key + " with values: " + jsonEnu
msStr); |
452 return; | 450 return; |
453 } | 451 } |
454 for (Integer value: values) { | 452 for (Integer value: values) { |
455 RecordHistogram.recordEnumeratedHistogram(key, value, boundary); | 453 RecordHistogram.recordEnumeratedHistogram(key, value, boundary); |
456 } | 454 } |
457 } | 455 } |
458 } | 456 } |
459 } | 457 } |
OLD | NEW |