hid_detection_utils.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_COMPONENTS_HID_DETECTION_HID_DETECTION_UTILS_H_
  5. #define ASH_COMPONENTS_HID_DETECTION_HID_DETECTION_UTILS_H_
  6. #include "services/device/public/mojom/input_service.mojom.h"
  7. namespace ash::hid_detection {
  8. // This enum is tied directly to the HidType UMA enum defined in
  9. // //tools/metrics/histograms/enums.xml, and should always reflect it (do not
  10. // change one without changing the other).
  11. enum class HidType {
  12. kTouchscreen = 0,
  13. kUsbKeyboard = 1,
  14. kUsbPointer = 2,
  15. kSerialKeyboard = 3,
  16. kSerialPointer = 4,
  17. kBluetoothKeyboard = 5,
  18. kBluetoothPointer = 6,
  19. kUnknownKeyboard = 7,
  20. kUnknownPointer = 8,
  21. kMaxValue = kUnknownPointer
  22. };
  23. // This enum is tied directly to the HidsMissing UMA enum defined in
  24. // //tools/metrics/histograms/enums.xml, and should always reflect it (do not
  25. // change one without changing the other).
  26. enum class HidsMissing {
  27. kNone = 0,
  28. kPointer = 1,
  29. kKeyboard = 2,
  30. kPointerAndKeyboard = 3,
  31. kMaxValue = kPointerAndKeyboard
  32. };
  33. // Returns true if |device| is a HID with pointing capabilities (i.e. a mouse or
  34. // touchpad).
  35. bool IsDevicePointer(const device::mojom::InputDeviceInfo& device);
  36. // Returns true if |device| is a HID with touchscreen capabilities (i.e. a
  37. // touchscreen or tablet).
  38. bool IsDeviceTouchscreen(const device::mojom::InputDeviceInfo& device);
  39. // Record each HID that is connected while the HID detection screen is shown.
  40. void RecordHidConnected(const device::mojom::InputDeviceInfo& device);
  41. // Record each HID that is disconnected while the HID detection screen is shown.
  42. void RecordHidDisconnected(const device::mojom::InputDeviceInfo& device);
  43. // Record the total number of bluetooth pairing attempts while the HID detection
  44. // is shown.
  45. void RecordBluetoothPairingAttempts(size_t attempts);
  46. // Record the amount of time taken to pair with a Bluetooth device and the
  47. // result of the pairing process during the HID detection automatic pairing
  48. // process.
  49. void RecordBluetoothPairingResult(bool success,
  50. base::TimeDelta pairing_duration);
  51. // Record each HID that is missing when the HID detection screen is shown.
  52. void RecordInitialHidsMissing(const HidsMissing& hids_missing);
  53. } // namespace ash::hid_detection
  54. #endif // ASH_COMPONENTS_HID_DETECTION_HID_DETECTION_UTILS_H_