chromium/device/bluetooth/BUILD.gn

# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/buildflag_header.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//device/bluetooth/cast_bluetooth.gni")
import("//device/bluetooth/emulation/buildflags.gni")

if (is_android) {
  import("//build/config/android/rules.gni")
  import("//third_party/jni_zero/jni_zero.gni")
}

config("bluetooth_config") {
  if (is_win) {
    ldflags = [
      "/DELAYLOAD:BluetoothApis.dll",

      # Despite MSDN stating that Bthprops.dll contains the
      # symbols declared by bthprops.lib, they actually reside here:
      "/DELAYLOAD:Bthprops.cpl",
      "/DELAYLOAD:setupapi.dll",
    ]
  }
  if (is_castos) {
    defines = [ "USE_CAST_BLUETOOTH_ADAPTER" ]
  }
}

config("bluetooth_emulation_config") {
  if (enable_bluetooth_emulation) {
    defines = [ "ENABLE_BLUETOOTH_EMULATION" ]
  }
}

# Experimental implementation not ready for production use yet. See
# public/mojom/README.md
source_set("deprecated_experimental_mojo") {
  sources = [
    "//device/bluetooth/public/mojom/connect_result_type_converter.h",
    "//device/bluetooth/public/mojom/gatt_result_type_converter.h",
    "adapter.cc",
    "adapter.h",
    "advertisement.cc",
    "advertisement.h",
    "device.cc",
    "device.h",
    "discovery_session.cc",
    "discovery_session.h",
    "gatt_service.cc",
    "gatt_service.h",
    "server_socket.cc",
    "server_socket.h",
    "socket.cc",
    "socket.h",
  ]

  if (is_chromeos || is_linux) {
    sources += [
      "bluez/metrics_recorder.cc",
      "bluez/metrics_recorder.h",
    ]
  }

  deps = [
    ":bluetooth",
    "//device/bluetooth/public/mojom:deprecated_experimental_interfaces",
    "//mojo/public/cpp/bindings",
    "//net",
  ]

  visibility = [
    # Experimental implementation not ready for production use yet. See
    # public/mojom/README.md

    # Approved clients:
    "//chrome/browser/ash/nearby:*",
    "//chrome/browser/ui/webui/bluetooth_internals:*",
    "//chrome/services/sharing/nearby/platform:*",

    # Implementation tests
    # Ideally only device_unittests, however android & fushia generate
    # additional targets with modified names and copy deps. gn can not wildcard
    # partial target names such as '//device:*device_unittests*'.
    "//device:*",
  ]
}

source_set("fake_bluetooth") {
  sources = [
    "emulation/fake_bluetooth.cc",
    "emulation/fake_bluetooth.h",
    "emulation/fake_central.cc",
    "emulation/fake_central.h",
    "emulation/fake_peripheral.cc",
    "emulation/fake_peripheral.h",
    "emulation/fake_read_response.cc",
    "emulation/fake_read_response.h",
    "emulation/fake_remote_gatt_characteristic.cc",
    "emulation/fake_remote_gatt_characteristic.h",
    "emulation/fake_remote_gatt_descriptor.cc",
    "emulation/fake_remote_gatt_descriptor.h",
    "emulation/fake_remote_gatt_service.cc",
    "emulation/fake_remote_gatt_service.h",
    "test/fake_bluetooth_socket.cc",
    "test/fake_bluetooth_socket.h",
    "test/fake_local_gatt_characteristic.cc",
    "test/fake_local_gatt_characteristic.h",
    "test/fake_local_gatt_service.cc",
    "test/fake_local_gatt_service.h",
  ]

  deps = [
    ":bluetooth",
    "//build:chromeos_buildflags",
    "//device/bluetooth/public/cpp",
    "//device/bluetooth/public/mojom:fake_bluetooth_interfaces",
    "//mojo/public/cpp/bindings",
    "//net",
  ]

  public_configs = [ ":bluetooth_emulation_config" ]
}

component("bluetooth") {
  sources = [
    "bluetooth_adapter.cc",
    "bluetooth_adapter.h",
    "bluetooth_adapter_factory.cc",
    "bluetooth_adapter_factory.h",
    "bluetooth_advertisement.cc",
    "bluetooth_advertisement.h",
    "bluetooth_common.h",
    "bluetooth_device.cc",
    "bluetooth_device.h",
    "bluetooth_discovery_filter.cc",
    "bluetooth_discovery_filter.h",
    "bluetooth_discovery_session.cc",
    "bluetooth_discovery_session.h",
    "bluetooth_discovery_session_outcome.h",
    "bluetooth_export.h",
    "bluetooth_gatt_characteristic.cc",
    "bluetooth_gatt_characteristic.h",
    "bluetooth_gatt_connection.cc",
    "bluetooth_gatt_connection.h",
    "bluetooth_gatt_descriptor.cc",
    "bluetooth_gatt_descriptor.h",
    "bluetooth_gatt_notify_session.cc",
    "bluetooth_gatt_notify_session.h",
    "bluetooth_gatt_service.cc",
    "bluetooth_gatt_service.h",
    "bluetooth_local_gatt_characteristic.h",
    "bluetooth_local_gatt_descriptor.cc",
    "bluetooth_local_gatt_descriptor.h",
    "bluetooth_local_gatt_service.h",
    "bluetooth_low_energy_scan_filter.cc",
    "bluetooth_low_energy_scan_filter.h",
    "bluetooth_low_energy_scan_session.cc",
    "bluetooth_low_energy_scan_session.h",
    "bluetooth_remote_gatt_characteristic.cc",
    "bluetooth_remote_gatt_characteristic.h",
    "bluetooth_remote_gatt_descriptor.cc",
    "bluetooth_remote_gatt_descriptor.h",
    "bluetooth_remote_gatt_service.cc",
    "bluetooth_remote_gatt_service.h",
    "bluetooth_socket.cc",
    "bluetooth_socket.h",
    "bluetooth_socket_net.cc",
    "bluetooth_socket_net.h",
    "bluetooth_socket_thread.cc",
    "bluetooth_socket_thread.h",
    "string_util_icu.cc",
    "string_util_icu.h",
  ]

  defines = [ "DEVICE_BLUETOOTH_IMPLEMENTATION" ]

  all_dependent_configs = [ ":bluetooth_config" ]

  deps = [
    "//base",
    "//build:chromeos_buildflags",
    "//components/device_event_log",
    "//components/prefs",
    "//crypto",
    "//device/base",
    "//device/bluetooth/strings",
    "//ipc",
    "//net",
    "//third_party/re2",
    "//ui/base",
  ]

  public_deps = [ "//device/bluetooth/public/cpp" ]

  if (is_android) {
    sources += [
      "android/wrappers.cc",
      "android/wrappers.h",
      "bluetooth_adapter_android.cc",
      "bluetooth_adapter_android.h",
      "bluetooth_device_android.cc",
      "bluetooth_device_android.h",
      "bluetooth_remote_gatt_characteristic_android.cc",
      "bluetooth_remote_gatt_characteristic_android.h",
      "bluetooth_remote_gatt_descriptor_android.cc",
      "bluetooth_remote_gatt_descriptor_android.h",
      "bluetooth_remote_gatt_service_android.cc",
      "bluetooth_remote_gatt_service_android.h",
    ]
    deps += [ ":jni_headers" ]
  }

  if (is_chromeos) {
    deps += [ "//chromeos/constants" ]
  }

  if (is_chromeos_ash) {
    deps += [
      "//ash/constants",
      "//chromeos/ash/services/nearby/public/cpp/",
      "//chromeos/ash/services/secure_channel/public/cpp/shared",
    ]
  }

  if (is_apple) {
    sources += [
      "bluetooth_advertisement_mac.h",
      "bluetooth_advertisement_mac.mm",
      "bluetooth_device_mac.h",
      "bluetooth_device_mac.mm",
      "bluetooth_low_energy_adapter_apple.h",
      "bluetooth_low_energy_adapter_apple.mm",
      "bluetooth_low_energy_advertisement_manager_mac.h",
      "bluetooth_low_energy_advertisement_manager_mac.mm",
      "bluetooth_low_energy_central_manager_delegate.h",
      "bluetooth_low_energy_central_manager_delegate.mm",
      "bluetooth_low_energy_device_mac.h",
      "bluetooth_low_energy_device_mac.mm",
      "bluetooth_low_energy_device_watcher_mac.h",
      "bluetooth_low_energy_device_watcher_mac.mm",
      "bluetooth_low_energy_discovery_manager_mac.h",
      "bluetooth_low_energy_discovery_manager_mac.mm",
      "bluetooth_low_energy_peripheral_delegate.h",
      "bluetooth_low_energy_peripheral_delegate.mm",
      "bluetooth_low_energy_peripheral_manager_delegate.h",
      "bluetooth_low_energy_peripheral_manager_delegate.mm",
      "bluetooth_remote_gatt_characteristic_mac.h",
      "bluetooth_remote_gatt_characteristic_mac.mm",
      "bluetooth_remote_gatt_descriptor_mac.h",
      "bluetooth_remote_gatt_descriptor_mac.mm",
      "bluetooth_remote_gatt_service_mac.h",
      "bluetooth_remote_gatt_service_mac.mm",
    ]
    frameworks = [
      "CoreBluetooth.framework",
      "IOKit.framework",
      "Foundation.framework",
    ]
  }

  if (is_mac) {
    sources += [
      "bluetooth_adapter_mac.h",
      "bluetooth_adapter_mac.mm",
      "bluetooth_channel_mac.h",
      "bluetooth_channel_mac.mm",
      "bluetooth_classic_device_mac.h",
      "bluetooth_classic_device_mac.mm",
      "bluetooth_discovery_manager_mac.h",
      "bluetooth_discovery_manager_mac.mm",
      "bluetooth_l2cap_channel_mac.h",
      "bluetooth_l2cap_channel_mac.mm",
      "bluetooth_rfcomm_channel_mac.h",
      "bluetooth_rfcomm_channel_mac.mm",
      "bluetooth_socket_mac.h",
      "bluetooth_socket_mac.mm",
    ]
    frameworks += [ "IOBluetooth.framework" ]
  }

  if (is_ios) {
    sources += [
      "bluetooth_adapter_ios.h",
      "bluetooth_adapter_ios.mm",
    ]
  }

  if (is_win) {
    sources += [
      "bluetooth_adapter_win.cc",
      "bluetooth_adapter_win.h",
      "bluetooth_adapter_winrt.cc",
      "bluetooth_adapter_winrt.h",
      "bluetooth_advertisement_winrt.cc",
      "bluetooth_advertisement_winrt.h",
      "bluetooth_classic_win.cc",
      "bluetooth_classic_win.h",
      "bluetooth_device_win.cc",
      "bluetooth_device_win.h",
      "bluetooth_device_winrt.cc",
      "bluetooth_device_winrt.h",
      "bluetooth_gatt_discoverer_winrt.cc",
      "bluetooth_gatt_discoverer_winrt.h",
      "bluetooth_init_win.cc",
      "bluetooth_init_win.h",
      "bluetooth_pairing_winrt.cc",
      "bluetooth_pairing_winrt.h",
      "bluetooth_remote_gatt_characteristic_winrt.cc",
      "bluetooth_remote_gatt_characteristic_winrt.h",
      "bluetooth_remote_gatt_descriptor_winrt.cc",
      "bluetooth_remote_gatt_descriptor_winrt.h",
      "bluetooth_remote_gatt_service_winrt.cc",
      "bluetooth_remote_gatt_service_winrt.h",
      "bluetooth_service_record_win.cc",
      "bluetooth_service_record_win.h",
      "bluetooth_socket_win.cc",
      "bluetooth_socket_win.h",
      "bluetooth_task_manager_win.cc",
      "bluetooth_task_manager_win.h",
      "event_utils_winrt.h",
    ]

    libs = [
      # Bthprops must be listed before BluetoothApis or else delay loading
      # crashes.
      "Bthprops.lib",
      "BluetoothApis.lib",
      "setupapi.lib",
    ]
  }

  if (is_chromeos || is_linux) {
    if (use_bluez) {
      if (!force_cast_bluetooth) {
        sources += [ "bluetooth_adapter_chromeos.cc" ]
      }
      sources += [
        "bluez/bluetooth_adapter_bluez.cc",
        "bluez/bluetooth_adapter_bluez.h",
        "bluez/bluetooth_adapter_profile_bluez.cc",
        "bluez/bluetooth_adapter_profile_bluez.h",
        "bluez/bluetooth_advertisement_bluez.cc",
        "bluez/bluetooth_advertisement_bluez.h",
        "bluez/bluetooth_device_bluez.cc",
        "bluez/bluetooth_device_bluez.h",
        "bluez/bluetooth_gatt_characteristic_bluez.cc",
        "bluez/bluetooth_gatt_characteristic_bluez.h",
        "bluez/bluetooth_gatt_connection_bluez.cc",
        "bluez/bluetooth_gatt_connection_bluez.h",
        "bluez/bluetooth_gatt_descriptor_bluez.cc",
        "bluez/bluetooth_gatt_descriptor_bluez.h",
        "bluez/bluetooth_gatt_service_bluez.cc",
        "bluez/bluetooth_gatt_service_bluez.h",
        "bluez/bluetooth_local_gatt_characteristic_bluez.cc",
        "bluez/bluetooth_local_gatt_characteristic_bluez.h",
        "bluez/bluetooth_local_gatt_descriptor_bluez.cc",
        "bluez/bluetooth_local_gatt_descriptor_bluez.h",
        "bluez/bluetooth_local_gatt_service_bluez.cc",
        "bluez/bluetooth_local_gatt_service_bluez.h",
        "bluez/bluetooth_low_energy_scan_session_bluez.cc",
        "bluez/bluetooth_low_energy_scan_session_bluez.h",
        "bluez/bluetooth_pairing_bluez.cc",
        "bluez/bluetooth_pairing_bluez.h",
        "bluez/bluetooth_remote_gatt_characteristic_bluez.cc",
        "bluez/bluetooth_remote_gatt_characteristic_bluez.h",
        "bluez/bluetooth_remote_gatt_descriptor_bluez.cc",
        "bluez/bluetooth_remote_gatt_descriptor_bluez.h",
        "bluez/bluetooth_remote_gatt_service_bluez.cc",
        "bluez/bluetooth_remote_gatt_service_bluez.h",
        "bluez/bluetooth_service_attribute_value_bluez.cc",
        "bluez/bluetooth_service_attribute_value_bluez.h",
        "bluez/bluetooth_service_record_bluez.cc",
        "bluez/bluetooth_service_record_bluez.h",
        "bluez/bluetooth_socket_bluez.cc",
        "bluez/bluetooth_socket_bluez.h",
        "bluez/bluez_features.cc",
        "bluez/bluez_features.h",
        "bluez/metrics_recorder.cc",
        "bluez/metrics_recorder.h",
        "dbus/bluetooth_adapter_client.cc",
        "dbus/bluetooth_adapter_client.h",
        "dbus/bluetooth_admin_policy_client.cc",
        "dbus/bluetooth_admin_policy_client.h",
        "dbus/bluetooth_advertisement_monitor_application_service_provider.cc",
        "dbus/bluetooth_advertisement_monitor_application_service_provider.h",
        "dbus/bluetooth_advertisement_monitor_application_service_provider_impl.cc",
        "dbus/bluetooth_advertisement_monitor_application_service_provider_impl.h",
        "dbus/bluetooth_advertisement_monitor_manager_client.cc",
        "dbus/bluetooth_advertisement_monitor_manager_client.h",
        "dbus/bluetooth_advertisement_monitor_service_provider.cc",
        "dbus/bluetooth_advertisement_monitor_service_provider.h",
        "dbus/bluetooth_advertisement_monitor_service_provider_impl.cc",
        "dbus/bluetooth_advertisement_monitor_service_provider_impl.h",
        "dbus/bluetooth_agent_manager_client.cc",
        "dbus/bluetooth_agent_manager_client.h",
        "dbus/bluetooth_agent_service_provider.cc",
        "dbus/bluetooth_agent_service_provider.h",
        "dbus/bluetooth_battery_client.cc",
        "dbus/bluetooth_battery_client.h",
        "dbus/bluetooth_dbus_client_bundle.cc",
        "dbus/bluetooth_dbus_client_bundle.h",
        "dbus/bluetooth_debug_manager_client.cc",
        "dbus/bluetooth_debug_manager_client.h",
        "dbus/bluetooth_device_client.cc",
        "dbus/bluetooth_device_client.h",
        "dbus/bluetooth_gatt_application_service_provider.cc",
        "dbus/bluetooth_gatt_application_service_provider.h",
        "dbus/bluetooth_gatt_application_service_provider_impl.cc",
        "dbus/bluetooth_gatt_application_service_provider_impl.h",
        "dbus/bluetooth_gatt_attribute_helpers.cc",
        "dbus/bluetooth_gatt_attribute_helpers.h",
        "dbus/bluetooth_gatt_attribute_value_delegate.cc",
        "dbus/bluetooth_gatt_attribute_value_delegate.h",
        "dbus/bluetooth_gatt_characteristic_client.cc",
        "dbus/bluetooth_gatt_characteristic_client.h",
        "dbus/bluetooth_gatt_characteristic_delegate_wrapper.cc",
        "dbus/bluetooth_gatt_characteristic_delegate_wrapper.h",
        "dbus/bluetooth_gatt_characteristic_service_provider.cc",
        "dbus/bluetooth_gatt_characteristic_service_provider.h",
        "dbus/bluetooth_gatt_characteristic_service_provider_impl.cc",
        "dbus/bluetooth_gatt_characteristic_service_provider_impl.h",
        "dbus/bluetooth_gatt_descriptor_client.cc",
        "dbus/bluetooth_gatt_descriptor_client.h",
        "dbus/bluetooth_gatt_descriptor_delegate_wrapper.cc",
        "dbus/bluetooth_gatt_descriptor_delegate_wrapper.h",
        "dbus/bluetooth_gatt_descriptor_service_provider.cc",
        "dbus/bluetooth_gatt_descriptor_service_provider.h",
        "dbus/bluetooth_gatt_descriptor_service_provider_impl.cc",
        "dbus/bluetooth_gatt_descriptor_service_provider_impl.h",
        "dbus/bluetooth_gatt_manager_client.cc",
        "dbus/bluetooth_gatt_manager_client.h",
        "dbus/bluetooth_gatt_service_client.cc",
        "dbus/bluetooth_gatt_service_client.h",
        "dbus/bluetooth_gatt_service_service_provider.cc",
        "dbus/bluetooth_gatt_service_service_provider.h",
        "dbus/bluetooth_gatt_service_service_provider_impl.cc",
        "dbus/bluetooth_gatt_service_service_provider_impl.h",
        "dbus/bluetooth_input_client.cc",
        "dbus/bluetooth_input_client.h",
        "dbus/bluetooth_le_advertisement_service_provider.cc",
        "dbus/bluetooth_le_advertisement_service_provider.h",
        "dbus/bluetooth_le_advertising_manager_client.cc",
        "dbus/bluetooth_le_advertising_manager_client.h",
        "dbus/bluetooth_metrics_helper.cc",
        "dbus/bluetooth_metrics_helper.h",
        "dbus/bluetooth_profile_manager_client.cc",
        "dbus/bluetooth_profile_manager_client.h",
        "dbus/bluetooth_profile_service_provider.cc",
        "dbus/bluetooth_profile_service_provider.h",
        "dbus/bluez_dbus_client.h",
        "dbus/bluez_dbus_manager.cc",
        "dbus/bluez_dbus_manager.h",
        "dbus/bluez_dbus_thread_manager.cc",
        "dbus/bluez_dbus_thread_manager.h",
        "dbus/dbus_bluez_manager_wrapper_linux.cc",
        "dbus/dbus_bluez_manager_wrapper_linux.h",
        "dbus/fake_bluetooth_adapter_client.cc",
        "dbus/fake_bluetooth_adapter_client.h",
        "dbus/fake_bluetooth_admin_policy_client.cc",
        "dbus/fake_bluetooth_admin_policy_client.h",
        "dbus/fake_bluetooth_advertisement_monitor_application_service_provider.cc",
        "dbus/fake_bluetooth_advertisement_monitor_application_service_provider.h",
        "dbus/fake_bluetooth_advertisement_monitor_manager_client.cc",
        "dbus/fake_bluetooth_advertisement_monitor_manager_client.h",
        "dbus/fake_bluetooth_advertisement_monitor_service_provider.cc",
        "dbus/fake_bluetooth_advertisement_monitor_service_provider.h",
        "dbus/fake_bluetooth_agent_manager_client.cc",
        "dbus/fake_bluetooth_agent_manager_client.h",
        "dbus/fake_bluetooth_agent_service_provider.cc",
        "dbus/fake_bluetooth_agent_service_provider.h",
        "dbus/fake_bluetooth_battery_client.cc",
        "dbus/fake_bluetooth_battery_client.h",
        "dbus/fake_bluetooth_debug_manager_client.cc",
        "dbus/fake_bluetooth_debug_manager_client.h",
        "dbus/fake_bluetooth_device_client.cc",
        "dbus/fake_bluetooth_device_client.h",
        "dbus/fake_bluetooth_gatt_application_service_provider.cc",
        "dbus/fake_bluetooth_gatt_application_service_provider.h",
        "dbus/fake_bluetooth_gatt_characteristic_client.cc",
        "dbus/fake_bluetooth_gatt_characteristic_client.h",
        "dbus/fake_bluetooth_gatt_characteristic_service_provider.cc",
        "dbus/fake_bluetooth_gatt_characteristic_service_provider.h",
        "dbus/fake_bluetooth_gatt_descriptor_client.cc",
        "dbus/fake_bluetooth_gatt_descriptor_client.h",
        "dbus/fake_bluetooth_gatt_descriptor_service_provider.cc",
        "dbus/fake_bluetooth_gatt_descriptor_service_provider.h",
        "dbus/fake_bluetooth_gatt_manager_client.cc",
        "dbus/fake_bluetooth_gatt_manager_client.h",
        "dbus/fake_bluetooth_gatt_service_client.cc",
        "dbus/fake_bluetooth_gatt_service_client.h",
        "dbus/fake_bluetooth_gatt_service_service_provider.cc",
        "dbus/fake_bluetooth_gatt_service_service_provider.h",
        "dbus/fake_bluetooth_input_client.cc",
        "dbus/fake_bluetooth_input_client.h",
        "dbus/fake_bluetooth_le_advertisement_service_provider.cc",
        "dbus/fake_bluetooth_le_advertisement_service_provider.h",
        "dbus/fake_bluetooth_le_advertising_manager_client.cc",
        "dbus/fake_bluetooth_le_advertising_manager_client.h",
        "dbus/fake_bluetooth_profile_manager_client.cc",
        "dbus/fake_bluetooth_profile_manager_client.h",
        "dbus/fake_bluetooth_profile_service_provider.cc",
        "dbus/fake_bluetooth_profile_service_provider.h",
        "floss/bluetooth_adapter_floss.cc",
        "floss/bluetooth_adapter_floss.h",
        "floss/bluetooth_advertisement_floss.cc",
        "floss/bluetooth_advertisement_floss.h",
        "floss/bluetooth_device_floss.cc",
        "floss/bluetooth_device_floss.h",
        "floss/bluetooth_gatt_characteristic_floss.cc",
        "floss/bluetooth_gatt_characteristic_floss.h",
        "floss/bluetooth_gatt_connection_floss.cc",
        "floss/bluetooth_gatt_connection_floss.h",
        "floss/bluetooth_gatt_service_floss.cc",
        "floss/bluetooth_gatt_service_floss.h",
        "floss/bluetooth_local_gatt_characteristic_floss.cc",
        "floss/bluetooth_local_gatt_characteristic_floss.h",
        "floss/bluetooth_local_gatt_descriptor_floss.cc",
        "floss/bluetooth_local_gatt_descriptor_floss.h",
        "floss/bluetooth_local_gatt_service_floss.cc",
        "floss/bluetooth_local_gatt_service_floss.h",
        "floss/bluetooth_low_energy_scan_session_floss.cc",
        "floss/bluetooth_low_energy_scan_session_floss.h",
        "floss/bluetooth_pairing_floss.cc",
        "floss/bluetooth_pairing_floss.h",
        "floss/bluetooth_remote_gatt_characteristic_floss.cc",
        "floss/bluetooth_remote_gatt_characteristic_floss.h",
        "floss/bluetooth_remote_gatt_descriptor_floss.cc",
        "floss/bluetooth_remote_gatt_descriptor_floss.h",
        "floss/bluetooth_remote_gatt_service_floss.cc",
        "floss/bluetooth_remote_gatt_service_floss.h",
        "floss/bluetooth_socket_floss.cc",
        "floss/bluetooth_socket_floss.h",
        "floss/exported_callback_manager.h",
        "floss/fake_floss_adapter_client.cc",
        "floss/fake_floss_adapter_client.h",
        "floss/fake_floss_admin_client.cc",
        "floss/fake_floss_admin_client.h",
        "floss/fake_floss_advertiser_client.cc",
        "floss/fake_floss_advertiser_client.h",
        "floss/fake_floss_battery_manager_client.cc",
        "floss/fake_floss_battery_manager_client.h",
        "floss/fake_floss_bluetooth_telephony_client.cc",
        "floss/fake_floss_bluetooth_telephony_client.h",
        "floss/fake_floss_gatt_manager_client.cc",
        "floss/fake_floss_gatt_manager_client.h",
        "floss/fake_floss_lescan_client.cc",
        "floss/fake_floss_lescan_client.h",
        "floss/fake_floss_logging_client.cc",
        "floss/fake_floss_logging_client.h",
        "floss/fake_floss_manager_client.cc",
        "floss/fake_floss_manager_client.h",
        "floss/fake_floss_socket_manager.cc",
        "floss/fake_floss_socket_manager.h",
        "floss/floss_adapter_client.cc",
        "floss/floss_adapter_client.h",
        "floss/floss_admin_client.cc",
        "floss/floss_admin_client.h",
        "floss/floss_advertiser_client.cc",
        "floss/floss_advertiser_client.h",
        "floss/floss_battery_manager_client.cc",
        "floss/floss_battery_manager_client.h",
        "floss/floss_bluetooth_telephony_client.cc",
        "floss/floss_bluetooth_telephony_client.h",
        "floss/floss_dbus_client.cc",
        "floss/floss_dbus_client.h",
        "floss/floss_dbus_manager.cc",
        "floss/floss_dbus_manager.h",
        "floss/floss_features.cc",
        "floss/floss_features.h",
        "floss/floss_gatt_manager_client.cc",
        "floss/floss_gatt_manager_client.h",
        "floss/floss_lescan_client.cc",
        "floss/floss_lescan_client.h",
        "floss/floss_logging_client.cc",
        "floss/floss_logging_client.h",
        "floss/floss_manager_client.cc",
        "floss/floss_manager_client.h",
        "floss/floss_sdp_types.cc",
        "floss/floss_sdp_types.h",
        "floss/floss_socket_manager.cc",
        "floss/floss_socket_manager.h",
        "floss/floss_version.cc",
        "floss/floss_version.h",
        "floss/test_helpers.h",
      ]
      if (is_chromeos) {
        import("//chromeos/dbus/config/use_real_dbus_clients.gni")
        configs += [ "//chromeos/dbus/config:use_real_dbus_clients_config" ]
        sources += [
          "chromeos/bluetooth_connection_logger.cc",
          "chromeos/bluetooth_connection_logger.h",
          "chromeos/bluetooth_utils.cc",
          "chromeos/bluetooth_utils.h",
          "chromeos_platform_features.cc",
          "chromeos_platform_features.h",
        ]
        deps += [ "//services/data_decoder/public/mojom" ]
        if (is_chromeos_lacros) {
          deps += [
            "//chromeos/lacros",
            "//chromeos/startup",
          ]
        }
      }
      if (use_dbus) {
        public_deps += [ "//dbus" ]
      }
    } else {  # !use_bluez
      defines += [ "LINUX_WITHOUT_DBUS" ]
      sources += [
        "dbus/dbus_bluez_manager_wrapper_linux.h",
        "dbus/dbus_bluez_manager_wrapper_stub_linux.cc",
      ]
    }

    # force_cast_bluetooth is used to compile with both cast & BlueZ, by
    # omitting the stubs that would otherwise be added in.
    if (!use_bluez || force_cast_bluetooth) {
      if (is_castos) {
        sources += [
          "cast/bluetooth_adapter_cast.cc",
          "cast/bluetooth_adapter_cast.h",
          "cast/bluetooth_device_cast.cc",
          "cast/bluetooth_device_cast.h",
          "cast/bluetooth_remote_gatt_characteristic_cast.cc",
          "cast/bluetooth_remote_gatt_characteristic_cast.h",
          "cast/bluetooth_remote_gatt_descriptor_cast.cc",
          "cast/bluetooth_remote_gatt_descriptor_cast.h",
          "cast/bluetooth_remote_gatt_service_cast.cc",
          "cast/bluetooth_remote_gatt_service_cast.h",
          "cast/bluetooth_utils.cc",
          "cast/bluetooth_utils.h",
        ]

        public_deps += [ "//chromecast/public" ]

        deps += [
          "//chromecast/device/bluetooth:util",
          "//chromecast/device/bluetooth/le",
        ]
      } else {
        sources += [ "bluetooth_adapter_stub.cc" ]
      }
    }
  }
}

static_library("mocks") {
  testonly = true
  sources = [
    "test/mock_bluetooth_adapter.cc",
    "test/mock_bluetooth_adapter.h",
    "test/mock_bluetooth_advertisement.cc",
    "test/mock_bluetooth_advertisement.h",
    "test/mock_bluetooth_device.cc",
    "test/mock_bluetooth_device.h",
    "test/mock_bluetooth_gatt_characteristic.cc",
    "test/mock_bluetooth_gatt_characteristic.h",
    "test/mock_bluetooth_gatt_connection.cc",
    "test/mock_bluetooth_gatt_connection.h",
    "test/mock_bluetooth_gatt_descriptor.cc",
    "test/mock_bluetooth_gatt_descriptor.h",
    "test/mock_bluetooth_gatt_notify_session.cc",
    "test/mock_bluetooth_gatt_notify_session.h",
    "test/mock_bluetooth_gatt_service.cc",
    "test/mock_bluetooth_gatt_service.h",
    "test/mock_bluetooth_socket.cc",
    "test/mock_bluetooth_socket.h",
  ]

  if (is_chromeos) {
    sources += [
      "test/mock_bluetooth_low_energy_scan_session.cc",
      "test/mock_bluetooth_low_energy_scan_session.h",
    ]
  }

  public_deps = [
    ":bluetooth",
    "//base",
    "//device/bluetooth/public/cpp",
    "//net",
    "//testing/gmock",
  ]

  deps = [ "//build:chromeos_buildflags" ]
}

if (is_android) {
  java_sources_needing_jni = [
    "android/java/src/org/chromium/device/bluetooth/ChromeBluetoothAdapter.java",
    "android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java",
    "android/java/src/org/chromium/device/bluetooth/ChromeBluetoothRemoteGattCharacteristic.java",
    "android/java/src/org/chromium/device/bluetooth/ChromeBluetoothRemoteGattDescriptor.java",
    "android/java/src/org/chromium/device/bluetooth/ChromeBluetoothRemoteGattService.java",
    "android/java/src/org/chromium/device/bluetooth/ChromeBluetoothScanFilterBuilder.java",
    "android/java/src/org/chromium/device/bluetooth/ChromeBluetoothScanFilterList.java",
    "android/java/src/org/chromium/device/bluetooth/Wrappers.java",
  ]

  generate_jni("jni_headers") {
    sources = java_sources_needing_jni
  }

  android_library("java") {
    srcjar_deps = [ ":jni_headers" ]
    sources = java_sources_needing_jni
    deps = [
      "//base:base_java",
      "//build/android:build_java",
      "//components/location/android:location_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]
  }
}