#include "device/bluetooth/emulation/fake_peripheral.h"
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/weak_ptr.h"
#include "base/notimplemented.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "device/bluetooth/emulation/fake_remote_gatt_service.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
namespace bluetooth {
FakePeripheral::FakePeripheral(FakeCentral* fake_central,
const std::string& address)
: … { … }
FakePeripheral::~FakePeripheral() = default;
void FakePeripheral::SetName(std::optional<std::string> name) { … }
void FakePeripheral::SetSystemConnected(bool connected) { … }
void FakePeripheral::SetServiceUUIDs(UUIDSet service_uuids) { … }
void FakePeripheral::SetManufacturerData(
ManufacturerDataMap manufacturer_data) { … }
void FakePeripheral::SetNextGATTConnectionResponse(uint16_t code) { … }
void FakePeripheral::SetNextGATTDiscoveryResponse(uint16_t code) { … }
bool FakePeripheral::AllResponsesConsumed() { … }
void FakePeripheral::SimulateGATTDisconnection() { … }
std::string FakePeripheral::AddFakeService(
const device::BluetoothUUID& service_uuid) { … }
bool FakePeripheral::RemoveFakeService(const std::string& identifier) { … }
uint32_t FakePeripheral::GetBluetoothClass() const { … }
#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX)
device::BluetoothTransport FakePeripheral::GetType() const { … }
#endif
std::string FakePeripheral::GetIdentifier() const { … }
std::string FakePeripheral::GetAddress() const { … }
device::BluetoothDevice::AddressType FakePeripheral::GetAddressType() const { … }
device::BluetoothDevice::VendorIDSource FakePeripheral::GetVendorIDSource()
const { … }
uint16_t FakePeripheral::GetVendorID() const { … }
uint16_t FakePeripheral::GetProductID() const { … }
uint16_t FakePeripheral::GetDeviceID() const { … }
uint16_t FakePeripheral::GetAppearance() const { … }
std::optional<std::string> FakePeripheral::GetName() const { … }
std::u16string FakePeripheral::GetNameForDisplay() const { … }
bool FakePeripheral::IsPaired() const { … }
#if BUILDFLAG(IS_CHROMEOS)
bool FakePeripheral::IsBonded() const {
NOTREACHED_IN_MIGRATION();
return false;
}
#endif
bool FakePeripheral::IsConnected() const { … }
bool FakePeripheral::IsGattConnected() const { … }
bool FakePeripheral::IsConnectable() const { … }
bool FakePeripheral::IsConnecting() const { … }
bool FakePeripheral::ExpectingPinCode() const { … }
bool FakePeripheral::ExpectingPasskey() const { … }
bool FakePeripheral::ExpectingConfirmation() const { … }
void FakePeripheral::GetConnectionInfo(ConnectionInfoCallback callback) { … }
void FakePeripheral::SetConnectionLatency(ConnectionLatency connection_latency,
base::OnceClosure callback,
ErrorCallback error_callback) { … }
void FakePeripheral::Connect(PairingDelegate* pairing_delegate,
ConnectCallback callback) { … }
#if BUILDFLAG(IS_CHROMEOS)
void FakePeripheral::ConnectClassic(PairingDelegate* pairing_delegate,
ConnectCallback callback) {
NOTREACHED_IN_MIGRATION();
}
#endif
void FakePeripheral::SetPinCode(const std::string& pincode) { … }
void FakePeripheral::SetPasskey(uint32_t passkey) { … }
void FakePeripheral::ConfirmPairing() { … }
void FakePeripheral::RejectPairing() { … }
void FakePeripheral::CancelPairing() { … }
void FakePeripheral::Disconnect(base::OnceClosure callback,
ErrorCallback error_callback) { … }
void FakePeripheral::Forget(base::OnceClosure callback,
ErrorCallback error_callback) { … }
void FakePeripheral::ConnectToService(
const device::BluetoothUUID& uuid,
ConnectToServiceCallback callback,
ConnectToServiceErrorCallback error_callback) { … }
void FakePeripheral::ConnectToServiceInsecurely(
const device::BluetoothUUID& uuid,
ConnectToServiceCallback callback,
ConnectToServiceErrorCallback error_callback) { … }
void FakePeripheral::CreateGattConnection(
GattConnectionCallback callback,
std::optional<device::BluetoothUUID> service_uuid) { … }
bool FakePeripheral::IsGattServicesDiscoveryComplete() const { … }
#if BUILDFLAG(IS_APPLE)
bool FakePeripheral::IsLowEnergyDevice() {
NOTIMPLEMENTED();
return true;
}
#endif
void FakePeripheral::CreateGattConnectionImpl(
std::optional<device::BluetoothUUID>) { … }
void FakePeripheral::DispatchConnectionResponse() { … }
void FakePeripheral::DispatchDiscoveryResponse() { … }
void FakePeripheral::DisconnectGatt() { … }
#if BUILDFLAG(IS_CHROMEOS)
void FakePeripheral::ExecuteWrite(base::OnceClosure callback,
ExecuteWriteErrorCallback error_callback) {
NOTIMPLEMENTED();
}
void FakePeripheral::AbortWrite(base::OnceClosure callback,
AbortWriteErrorCallback error_callback) {
NOTIMPLEMENTED();
}
#endif
}