#include "device/bluetooth/floss/fake_floss_socket_manager.h"
#include <fcntl.h>
#include <stddef.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include "base/containers/contains.h"
#include "base/logging.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/types/expected.h"
#include "device/bluetooth/floss/floss_dbus_client.h"
namespace floss {
namespace {
constexpr char kNotImplemented[] = …;
constexpr char kUnsupportedUuid[] = …;
void EchoServer(int fd) { … }
int SimulateSocket() { … }
}
const char FakeFlossSocketManager::kRfcommUuid[] = …;
FakeFlossSocketManager::FakeFlossSocketManager() = default;
FakeFlossSocketManager::~FakeFlossSocketManager() = default;
void FakeFlossSocketManager::Init(dbus::Bus* bus,
const std::string& service_name,
const int adapter_index,
base::Version version,
base::OnceClosure on_ready) { … }
void FakeFlossSocketManager::ListenUsingL2cap(
const Security security_level,
ResponseCallback<BtifStatus> callback,
ConnectionStateChanged ready_cb,
ConnectionAccepted new_connection_cb) { … }
void FakeFlossSocketManager::ListenUsingL2capLe(
const Security security_level,
ResponseCallback<BtifStatus> callback,
ConnectionStateChanged ready_cb,
ConnectionAccepted new_connection_cb) { … }
void FakeFlossSocketManager::ListenUsingRfcomm(
const std::string& name,
const device::BluetoothUUID& uuid,
const Security security_level,
ResponseCallback<BtifStatus> callback,
ConnectionStateChanged ready_cb,
ConnectionAccepted new_connection_cb) { … }
void FakeFlossSocketManager::ConnectUsingL2cap(
const FlossDeviceId& remote_device,
const int psm,
const Security security_level,
ConnectionCompleted callback) { … }
void FakeFlossSocketManager::ConnectUsingL2capLe(
const FlossDeviceId& remote_device,
const int psm,
const Security security_level,
ConnectionCompleted callback) { … }
void FakeFlossSocketManager::ConnectUsingRfcomm(
const FlossDeviceId& remote_device,
const device::BluetoothUUID& uuid,
const Security security_level,
ConnectionCompleted callback) { … }
void FakeFlossSocketManager::Accept(const SocketId id,
std::optional<uint32_t> timeout_ms,
ResponseCallback<BtifStatus> callback) { … }
void FakeFlossSocketManager::Close(const SocketId id,
ResponseCallback<BtifStatus> callback) { … }
void FakeFlossSocketManager::SendSocketReady(const SocketId id,
const device::BluetoothUUID& uuid,
const BtifStatus status) { … }
void FakeFlossSocketManager::SendSocketClosed(const SocketId id,
const BtifStatus status) { … }
void FakeFlossSocketManager::SendIncomingConnection(
const SocketId listener_id,
const FlossDeviceId& remote_device,
const device::BluetoothUUID& uuid) { … }
}