tree: 7cbdd811e77e18041bfcb6bdc19811a8540d1321 [path history] [tgz]
  1. android/
  2. bluez/
  3. cast/
  4. chromeos/
  5. dbus/
  6. floss/
  7. public/
  8. strings/
  9. test/
  10. adapter.cc
  11. adapter.h
  12. adapter_unittest.cc
  13. advertisement.cc
  14. advertisement.h
  15. advertisement_unittest.cc
  16. bluetooth_adapter.cc
  17. bluetooth_adapter.h
  18. bluetooth_adapter_android.cc
  19. bluetooth_adapter_android.h
  20. bluetooth_adapter_android_unittest.cc
  21. bluetooth_adapter_chromeos.cc
  22. bluetooth_adapter_factory.cc
  23. bluetooth_adapter_factory.h
  24. bluetooth_adapter_ios.h
  25. bluetooth_adapter_ios.mm
  26. bluetooth_adapter_mac.h
  27. bluetooth_adapter_mac.mm
  28. bluetooth_adapter_mac_unittest.mm
  29. bluetooth_adapter_stub.cc
  30. bluetooth_adapter_unittest.cc
  31. bluetooth_adapter_win.cc
  32. bluetooth_adapter_win.h
  33. bluetooth_adapter_win_unittest.cc
  34. bluetooth_adapter_winrt.cc
  35. bluetooth_adapter_winrt.h
  36. bluetooth_advertisement.cc
  37. bluetooth_advertisement.h
  38. bluetooth_advertisement_mac.h
  39. bluetooth_advertisement_mac.mm
  40. bluetooth_advertisement_unittest.cc
  41. bluetooth_advertisement_winrt.cc
  42. bluetooth_advertisement_winrt.h
  43. bluetooth_channel_mac.h
  44. bluetooth_channel_mac.mm
  45. bluetooth_classic_device_mac.h
  46. bluetooth_classic_device_mac.mm
  47. bluetooth_classic_win.cc
  48. bluetooth_classic_win.h
  49. bluetooth_classic_win_fake.cc
  50. bluetooth_classic_win_fake.h
  51. bluetooth_common.h
  52. bluetooth_device.cc
  53. bluetooth_device.h
  54. bluetooth_device_android.cc
  55. bluetooth_device_android.h
  56. bluetooth_device_mac.h
  57. bluetooth_device_mac.mm
  58. bluetooth_device_unittest.cc
  59. bluetooth_device_win.cc
  60. bluetooth_device_win.h
  61. bluetooth_device_win_unittest.cc
  62. bluetooth_device_winrt.cc
  63. bluetooth_device_winrt.h
  64. bluetooth_discovery_filter.cc
  65. bluetooth_discovery_filter.h
  66. bluetooth_discovery_filter_unittest.cc
  67. bluetooth_discovery_manager_mac.h
  68. bluetooth_discovery_manager_mac.mm
  69. bluetooth_discovery_session.cc
  70. bluetooth_discovery_session.h
  71. bluetooth_discovery_session_outcome.h
  72. bluetooth_export.h
  73. bluetooth_gatt_characteristic.cc
  74. bluetooth_gatt_characteristic.h
  75. bluetooth_gatt_connection.cc
  76. bluetooth_gatt_connection.h
  77. bluetooth_gatt_descriptor.cc
  78. bluetooth_gatt_descriptor.h
  79. bluetooth_gatt_discoverer_winrt.cc
  80. bluetooth_gatt_discoverer_winrt.h
  81. bluetooth_gatt_notify_session.cc
  82. bluetooth_gatt_notify_session.h
  83. bluetooth_gatt_service.cc
  84. bluetooth_gatt_service.h
  85. bluetooth_init_win.cc
  86. bluetooth_init_win.h
  87. bluetooth_l2cap_channel_mac.h
  88. bluetooth_l2cap_channel_mac.mm
  89. bluetooth_local_gatt_characteristic.h
  90. bluetooth_local_gatt_characteristic_unittest.cc
  91. bluetooth_local_gatt_descriptor.cc
  92. bluetooth_local_gatt_descriptor.h
  93. bluetooth_local_gatt_descriptor_unittest.cc
  94. bluetooth_local_gatt_service.h
  95. bluetooth_low_energy_adapter_apple.h
  96. bluetooth_low_energy_adapter_apple.mm
  97. bluetooth_low_energy_adapter_apple_unittest.mm
  98. bluetooth_low_energy_advertisement_manager_mac.h
  99. bluetooth_low_energy_advertisement_manager_mac.mm
  100. bluetooth_low_energy_advertisement_manager_mac_unittest.mm
  101. bluetooth_low_energy_central_manager_delegate.h
  102. bluetooth_low_energy_central_manager_delegate.mm
  103. bluetooth_low_energy_device_mac.h
  104. bluetooth_low_energy_device_mac.mm
  105. bluetooth_low_energy_device_watcher_mac.h
  106. bluetooth_low_energy_device_watcher_mac.mm
  107. bluetooth_low_energy_discovery_manager_mac.h
  108. bluetooth_low_energy_discovery_manager_mac.mm
  109. bluetooth_low_energy_peripheral_delegate.h
  110. bluetooth_low_energy_peripheral_delegate.mm
  111. bluetooth_low_energy_peripheral_manager_delegate.h
  112. bluetooth_low_energy_peripheral_manager_delegate.mm
  113. bluetooth_low_energy_scan_filter.cc
  114. bluetooth_low_energy_scan_filter.h
  115. bluetooth_low_energy_scan_filter_unittest.cc
  116. bluetooth_low_energy_scan_session.cc
  117. bluetooth_low_energy_scan_session.h
  118. bluetooth_pairing_winrt.cc
  119. bluetooth_pairing_winrt.h
  120. bluetooth_remote_gatt_characteristic.cc
  121. bluetooth_remote_gatt_characteristic.h
  122. bluetooth_remote_gatt_characteristic_android.cc
  123. bluetooth_remote_gatt_characteristic_android.h
  124. bluetooth_remote_gatt_characteristic_mac.h
  125. bluetooth_remote_gatt_characteristic_mac.mm
  126. bluetooth_remote_gatt_characteristic_unittest.cc
  127. bluetooth_remote_gatt_characteristic_winrt.cc
  128. bluetooth_remote_gatt_characteristic_winrt.h
  129. bluetooth_remote_gatt_descriptor.cc
  130. bluetooth_remote_gatt_descriptor.h
  131. bluetooth_remote_gatt_descriptor_android.cc
  132. bluetooth_remote_gatt_descriptor_android.h
  133. bluetooth_remote_gatt_descriptor_mac.h
  134. bluetooth_remote_gatt_descriptor_mac.mm
  135. bluetooth_remote_gatt_descriptor_unittest.cc
  136. bluetooth_remote_gatt_descriptor_winrt.cc
  137. bluetooth_remote_gatt_descriptor_winrt.h
  138. bluetooth_remote_gatt_service.cc
  139. bluetooth_remote_gatt_service.h
  140. bluetooth_remote_gatt_service_android.cc
  141. bluetooth_remote_gatt_service_android.h
  142. bluetooth_remote_gatt_service_mac.h
  143. bluetooth_remote_gatt_service_mac.mm
  144. bluetooth_remote_gatt_service_unittest.cc
  145. bluetooth_remote_gatt_service_winrt.cc
  146. bluetooth_remote_gatt_service_winrt.h
  147. bluetooth_rfcomm_channel_mac.h
  148. bluetooth_rfcomm_channel_mac.mm
  149. bluetooth_service_record_win.cc
  150. bluetooth_service_record_win.h
  151. bluetooth_service_record_win_unittest.cc
  152. bluetooth_socket.cc
  153. bluetooth_socket.h
  154. bluetooth_socket_mac.h
  155. bluetooth_socket_mac.mm
  156. bluetooth_socket_net.cc
  157. bluetooth_socket_net.h
  158. bluetooth_socket_thread.cc
  159. bluetooth_socket_thread.h
  160. bluetooth_socket_win.cc
  161. bluetooth_socket_win.h
  162. bluetooth_strings.grd
  163. bluetooth_task_manager_win.cc
  164. bluetooth_task_manager_win.h
  165. bluetooth_task_manager_win_unittest.cc
  166. BUILD.gn
  167. cast_bluetooth.gni
  168. chromeos_platform_features.cc
  169. chromeos_platform_features.h
  170. DEPS
  171. device.cc
  172. device.h
  173. device_unittest.cc
  174. DIR_METADATA
  175. discovery_session.cc
  176. discovery_session.h
  177. event_utils_winrt.h
  178. gatt_service.cc
  179. gatt_service.h
  180. gatt_service_unittest.cc
  181. OWNERS
  182. README.md
  183. server_socket.cc
  184. server_socket.h
  185. server_socket_unittest.cc
  186. socket.cc
  187. socket.h
  188. socket_unittest.cc
  189. string_util_icu.cc
  190. string_util_icu.h
  191. string_util_icu_unittest.cc
device/bluetooth/README.md

Bluetooth

device/bluetooth abstracts Bluetooth Classic and Low Energy features across multiple platforms.

Classic and Low Energy based profiles differ substantially. Platform implementations may support only one or the other, even though several classes have interfaces for both, e.g. BluetoothAdapter & BluetoothDevice.

ClassicLow Energy
Androidnoyes
Chrome OSyesyes
Linuxyesyes
Macyesyes
Windowssomenearly

Chrome OS and Linux are supported via BlueZ, see *_bluez files.

Mojo interfaces in public/mojom have been started but are not ready for production use.

Maintainer History

Initial implementation OWNERS were youngki@chromium.org, keybuk@chromium.org, armansito@chromium.org, and rpaquay@chromium.org. They no longer contribute to chromium fulltime. They were responsible for support for Chrome OS Bluetooth features and the Chrome Apps APIs:

Active development in 2015 & 2016 focused on enabling GATT features for:

Future Work

The API and implementation have many known issues.

The initial API was heavily influenced by BlueZ. Low Energy GATT APIs are not consistent across platforms. Some of the high level abstractions built into device/bluetooth are difficult for clients. Several TODOs exist in the C++ header files, e.g. BluetoothAdapter::Observer.

Primarily, the API should be split into fundamental Bluetooth concepts and seperate, optional, high level utility classes.

E.g. receiving advertising packets should be routed directly to clients allowing contents of the individual packet to be inspected. Caching of known devices should not exist in the fundamental API, but be offered as utility classes.

See also the Refactoring meta issue.

Android

The android implementation requires crossing from C++ to Java using JNI.

Object ownership is rooted in the C++ classes, starting with the Adapter, which owns Devices, Services, etc. Java counter parts interface with the Android Bluetooth objects. E.g.

For testing, the Android objects are wrapped in: android/java/src/org/chromium/device/bluetooth/Wrappers.java.
and fakes implemented in: test/android/java/src/org/chromium/device/bluetooth/Fakes.java.

Thus:

  • bluetooth_adapter_android.h owns:
    • android/.../ChromeBluetoothAdapter.java uses:
      • android/.../Wrappers.java: BluetoothAdapterWrapper
        • Which under test is a FakeBluetoothAdapter
    • bluetooth_device_android.h owns:
      • android/.../ChromeBluetoothDevice.java uses:
        • android/.../Wrappers.java: BluetoothDeviceWrapper
          • Which under test is a FakeBluetoothDevice
      • bluetooth_gatt_service_android.h owns:
        • android/.../ChromeBluetoothService.java uses:
          • android/.../Wrappers.java: BluetoothServiceWrapper
            • Which under test is a FakeBluetoothService
        • ... and so on for characteristics and descriptors.

Fake objects are controlled by bluetooth_test_android.cc.

See also: Class Diagram of Web Bluetooth through Bluetooth Android

ChromeOS

Within this directory, BluetoothAdapter exposes Bluetooth stack agnostic APIs for performing various operations and this is implemented by various platform specific classes. For ChromeOS, BluetoothAdapter is implemented by BluetoothAdapterFloss and [BluetoothAdapterBluez] (https://source.chromium.org/chromium/chromium/src/+/main:device/bluetooth/bluez/bluetooth_adapter_bluez.h;drc=d8468bb60e224d8797b843ee9d0258862bcbe87f).

In addition to above classes, we have BluetoothConnectionLogger and BluetoothUtils classes for recording metrics on Bluetooth operations. BluetoothUtils is also used for ChromeOS-specific functionality such as filtering out Bluetooth devices of certain classes (ex: Phones) from the UI.

Bluetooth stacks

Bluez and Fluoride are bluetooth stacks used in ChromeOS and Android respectively. Given the relatively small market segment for ChromeOS when compared to Android, device manufacturers do not always go through interoperability testing and validation on devices running ChromeOS.

To ease this, a project has been undertaken to make the Android Bluetooth stack multiplatform and migrate ChromeOS from Bluez to Fluoride. This project is titled Floss and is currently underway.

CrosBluetoothConfig

Various Bluetooth UI surfaces in ChromeOS perform their operations by using APIs defined in [CrosBluetoothConfig] (https://source.chromium.org/chromium/chromium/src/+/main:chromeos/ash/services/bluetooth_config/cros_bluetooth_config.h;drc=d8468bb60e224d8797b843ee9d0258862bcbe87f)

CrosBluetoothConfig in turn utilizes classes in this directory to interact with the Bluetooth stack. It is usually preferrerd to use CrosBluetoothConfig API for performing Bluetooth related operations and direct interaction with adapters in this directory should only be necessary if more granular functionality is required.

Testing

See test/README.md

Design Documents

  • Bluetooth Notifications 2016-08-26
    • Web Bluetooth through Android implementation details, class diagram and call flow.