1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_BLUETOOTH_CHROMEOS_BLUETOOTH_UTILS_H_
#define DEVICE_BLUETOOTH_CHROMEOS_BLUETOOTH_UTILS_H_
#include "base/optional.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_export.h"
namespace base {
class TimeDelta;
} // namespace base
// This file contains common utilities, including filtering bluetooth devices
// based on the filter criteria.
namespace device {
enum class BluetoothFilterType {
// No filtering, all bluetooth devices will be returned.
ALL = 0,
// Return bluetooth devices that are known to the UI.
// I.e. bluetooth device type != UNKNOWN
KNOWN,
};
enum class BluetoothUiSurface {
kSettings,
kSystemTray,
};
// This enum is tied directly to a UMA enum defined in
// //tools/metrics/histograms/enums.xml, and should always reflect it (do not
// change one without changing the other).
enum class ConnectionFailureReason {
kUnknownError = 0,
kSystemError = 1,
kAuthFailed = 2,
kAuthTimeout = 3,
kFailed = 4,
kUnknownConnectionError = 5,
kUnsupportedDevice = 6,
kNotConnectable = 7,
kMaxValue = kNotConnectable
};
// Return filtered devices based on the filter type and max number of devices.
DEVICE_BLUETOOTH_EXPORT device::BluetoothAdapter::DeviceList
FilterBluetoothDeviceList(const BluetoothAdapter::DeviceList& devices,
BluetoothFilterType filter_type,
int max_devices);
// Record outcome of user attempting to pair to a device.
DEVICE_BLUETOOTH_EXPORT void RecordPairingResult(
base::Optional<ConnectionFailureReason> failure_reason,
BluetoothTransport transport,
base::TimeDelta duration);
// Record outcome of user attempting to reconnect to a previously paired device.
DEVICE_BLUETOOTH_EXPORT void RecordUserInitiatedReconnectionAttemptResult(
base::Optional<ConnectionFailureReason> failure_reason,
BluetoothUiSurface surface);
// Record how long it took for a user to find and select the device they wished
// to connect to.
DEVICE_BLUETOOTH_EXPORT void RecordDeviceSelectionDuration(
base::TimeDelta duration,
BluetoothUiSurface surface,
bool was_paired,
BluetoothTransport transport);
} // namespace device
#endif // DEVICE_BLUETOOTH_CHROMEOS_BLUETOOTH_UTILS_H_
|