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