chromium/device/bluetooth/bluetooth_device.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "device/bluetooth/bluetooth_device.h"

#include <array>
#include <cstdint>
#include <iterator>
#include <memory>
#include <string>
#include <utility>

#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_gatt_connection.h"
#include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
#include "device/bluetooth/bluetooth_remote_gatt_descriptor.h"
#include "device/bluetooth/bluetooth_remote_gatt_service.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
#include "device/bluetooth/string_util_icu.h"
#include "device/bluetooth/strings/grit/bluetooth_strings.h"
#include "ui/base/l10n/l10n_util.h"

#if BUILDFLAG(IS_CHROMEOS)
#include "base/no_destructor.h"
#endif  // BUILDFLAG(IS_CHROMEOS)

namespace device {

#if BUILDFLAG(IS_CHROMEOS)
// See Bluetooth Assigned Numbers - 3.3 SDP Service Class and Profile
// Identifiers
const base::NoDestructor<std::vector<BluetoothUUID>> kAudioUUIDs([] {
  return std::vector<BluetoothUUID>({
      BluetoothUUID("0x110B"),  // Audio sink
      BluetoothUUID("0x111E"),  // Hands free
  });
}());
#endif  // BUILDFLAG(IS_CHROMEOS)

BatteryInfo;
BatteryType;

BluetoothDevice::DeviceUUIDs::DeviceUUIDs() = default;

BluetoothDevice::DeviceUUIDs::~DeviceUUIDs() = default;

BluetoothDevice::DeviceUUIDs::DeviceUUIDs(const DeviceUUIDs& other) = default;

BluetoothDevice::DeviceUUIDs& BluetoothDevice::DeviceUUIDs::operator=(
    const DeviceUUIDs& other) = default;

void BluetoothDevice::DeviceUUIDs::ReplaceAdvertisedUUIDs(
    UUIDList new_advertised_uuids) {}

void BluetoothDevice::DeviceUUIDs::ClearAdvertisedUUIDs() {}

void BluetoothDevice::DeviceUUIDs::ReplaceServiceUUIDs(
    const GattServiceMap& gatt_services) {}

void BluetoothDevice::DeviceUUIDs::ReplaceServiceUUIDs(
    UUIDList new_service_uuids) {}

void BluetoothDevice::DeviceUUIDs::ClearServiceUUIDs() {}

const BluetoothDevice::UUIDSet& BluetoothDevice::DeviceUUIDs::GetUUIDs() const {}

void BluetoothDevice::DeviceUUIDs::UpdateDeviceUUIDs() {}

BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter)
    :{}

BluetoothDevice::~BluetoothDevice() {}

BluetoothDevice::ConnectionInfo::ConnectionInfo()
    :{}

BluetoothDevice::ConnectionInfo::ConnectionInfo(int rssi,
                                                int transmit_power,
                                                int max_transmit_power)
    :{}

BluetoothDevice::ConnectionInfo::~ConnectionInfo() = default;

BatteryInfo::BatteryInfo() :{}

BatteryInfo::BatteryInfo(BatteryType type, std::optional<uint8_t> percentage)
    :{}

BatteryInfo::BatteryInfo(BatteryType type,
                         std::optional<uint8_t> percentage,
                         ChargeState charge_state)
    :{}

BatteryInfo::BatteryInfo(const BatteryInfo&) = default;

BatteryInfo& BatteryInfo::operator=(const BatteryInfo&) = default;

BatteryInfo::BatteryInfo(BatteryInfo&&) = default;

BatteryInfo& BatteryInfo::operator=(BatteryInfo&&) = default;

bool BatteryInfo::operator==(const BatteryInfo& other) {}

BatteryInfo::~BatteryInfo() = default;

std::u16string BluetoothDevice::GetNameForDisplay() const {}

std::u16string BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() const {}

BluetoothDeviceType BluetoothDevice::GetDeviceType() const {}

bool BluetoothDevice::IsPairable() const {}

BluetoothDevice::UUIDSet BluetoothDevice::GetUUIDs() const {}

#if BUILDFLAG(IS_CHROMEOS)
void BluetoothDevice::SetIsBlockedByPolicy(bool is_blocked_by_policy) {
  if (is_blocked_by_policy_ == is_blocked_by_policy) {
    return;
  }
  is_blocked_by_policy_ = is_blocked_by_policy;
  GetAdapter()->NotifyDeviceIsBlockedByPolicyChanged(this,
                                                     is_blocked_by_policy);
}

bool BluetoothDevice::IsBlockedByPolicy() const {
  return is_blocked_by_policy_;
}
#endif

const BluetoothDevice::ServiceDataMap& BluetoothDevice::GetServiceData() const {}

BluetoothDevice::UUIDSet BluetoothDevice::GetServiceDataUUIDs() const {}

const std::vector<uint8_t>* BluetoothDevice::GetServiceDataForUUID(
    const BluetoothUUID& uuid) const {}

const BluetoothDevice::ManufacturerDataMap&
BluetoothDevice::GetManufacturerData() const {}

BluetoothDevice::ManufacturerIDSet BluetoothDevice::GetManufacturerDataIDs()
    const {}

const std::vector<uint8_t>* BluetoothDevice::GetManufacturerDataForID(
    const ManufacturerId manufacturerID) const {}

std::optional<int8_t> BluetoothDevice::GetInquiryRSSI() const {}

std::optional<uint8_t> BluetoothDevice::GetAdvertisingDataFlags() const {}

std::optional<int8_t> BluetoothDevice::GetInquiryTxPower() const {}

void BluetoothDevice::CreateGattConnection(
    GattConnectionCallback callback,
    std::optional<BluetoothUUID> service_uuid) {}

void BluetoothDevice::SetGattServicesDiscoveryComplete(bool complete) {}

bool BluetoothDevice::IsGattServicesDiscoveryComplete() const {}

std::vector<BluetoothRemoteGattService*> BluetoothDevice::GetGattServices()
    const {}

BluetoothRemoteGattService* BluetoothDevice::GetGattService(
    const std::string& identifier) const {}

std::string BluetoothDevice::GetIdentifier() const {}

std::string BluetoothDevice::GetOuiPortionOfBluetoothAddress() const {}

void BluetoothDevice::UpdateAdvertisementData(
    int8_t rssi,
    std::optional<uint8_t> flags,
    UUIDList advertised_uuids,
    std::optional<int8_t> tx_power,
    ServiceDataMap service_data,
    ManufacturerDataMap manufacturer_data) {}

void BluetoothDevice::ClearAdvertisementData() {}

std::vector<BluetoothRemoteGattService*> BluetoothDevice::GetPrimaryServices() {}

std::vector<BluetoothRemoteGattService*>
BluetoothDevice::GetPrimaryServicesByUUID(const BluetoothUUID& service_uuid) {}

#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX)
void BluetoothDevice::SetBatteryInfo(const BatteryInfo& info) {}

bool BluetoothDevice::RemoveBatteryInfo(const BatteryType& type) {}

std::optional<BatteryInfo> BluetoothDevice::GetBatteryInfo(
    const BatteryType& type) const {}

std::vector<BatteryType> BluetoothDevice::GetAvailableBatteryTypes() {}
#endif

bool BluetoothDevice::supports_service_specific_discovery() const {}

void BluetoothDevice::UpgradeToFullDiscovery() {}

std::unique_ptr<BluetoothGattConnection>
BluetoothDevice::CreateBluetoothGattConnectionObject() {}

void BluetoothDevice::DidConnectGatt(std::optional<ConnectErrorCode> error) {}

void BluetoothDevice::DidDisconnectGatt() {}

void BluetoothDevice::AddGattConnection(BluetoothGattConnection* connection) {}

void BluetoothDevice::RemoveGattConnection(
    BluetoothGattConnection* connection) {}

void BluetoothDevice::SetAsExpiredForTesting() {}

void BluetoothDevice::Pair(PairingDelegate* pairing_delegate,
                           ConnectCallback callback) {}

void BluetoothDevice::UpdateTimestamp() {}

base::Time BluetoothDevice::GetLastUpdateTime() const {}

// static
int8_t BluetoothDevice::ClampPower(int power) {}

}  // namespace device