#include "device/bluetooth/bluez/bluetooth_socket_bluez.h"
#include <stdint.h>
#include <memory>
#include <queue>
#include <string>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/scoped_blocking_call.h"
#include "dbus/bus.h"
#include "dbus/object_path.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/bluetooth_socket.h"
#include "device/bluetooth/bluetooth_socket_net.h"
#include "device/bluetooth/bluetooth_socket_thread.h"
#include "device/bluetooth/bluez/bluetooth_adapter_bluez.h"
#include "device/bluetooth/bluez/bluetooth_adapter_profile_bluez.h"
#include "device/bluetooth/bluez/bluetooth_device_bluez.h"
#include "device/bluetooth/dbus/bluetooth_device_client.h"
#include "device/bluetooth/dbus/bluetooth_profile_manager_client.h"
#include "device/bluetooth/dbus/bluetooth_profile_service_provider.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
BluetoothAdapter;
BluetoothDevice;
BluetoothSocketThread;
BluetoothUUID;
namespace {
const char kAcceptFailed[] = …;
const char kInvalidUUID[] = …;
const char kSocketNotListening[] = …;
}
namespace bluez {
scoped_refptr<BluetoothSocketBlueZ> BluetoothSocketBlueZ::CreateBluetoothSocket(
scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
scoped_refptr<BluetoothSocketThread> socket_thread) { … }
BluetoothSocketBlueZ::AcceptRequest::AcceptRequest() = default;
BluetoothSocketBlueZ::AcceptRequest::~AcceptRequest() = default;
BluetoothSocketBlueZ::ConnectionRequest::ConnectionRequest()
: … { … }
BluetoothSocketBlueZ::ConnectionRequest::~ConnectionRequest() = default;
BluetoothSocketBlueZ::BluetoothSocketBlueZ(
scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
scoped_refptr<BluetoothSocketThread> socket_thread)
: … { … }
BluetoothSocketBlueZ::~BluetoothSocketBlueZ() { … }
void BluetoothSocketBlueZ::Connect(const BluetoothDeviceBlueZ* device,
const BluetoothUUID& uuid,
SecurityLevel security_level,
base::OnceClosure success_callback,
ErrorCompletionCallback error_callback) { … }
void BluetoothSocketBlueZ::Listen(
scoped_refptr<BluetoothAdapter> adapter,
SocketType socket_type,
const BluetoothUUID& uuid,
const BluetoothAdapter::ServiceOptions& service_options,
base::OnceClosure success_callback,
ErrorCompletionCallback error_callback) { … }
void BluetoothSocketBlueZ::Disconnect(base::OnceClosure callback) { … }
void BluetoothSocketBlueZ::Accept(AcceptCompletionCallback success_callback,
ErrorCompletionCallback error_callback) { … }
void BluetoothSocketBlueZ::RegisterProfile(
BluetoothAdapterBlueZ* adapter,
base::OnceClosure success_callback,
ErrorCompletionCallback error_callback) { … }
void BluetoothSocketBlueZ::OnRegisterProfile(
base::OnceClosure success_callback,
ErrorCompletionCallback error_callback,
BluetoothAdapterProfileBlueZ* profile) { … }
void BluetoothSocketBlueZ::OnRegisterProfileError(
ErrorCompletionCallback error_callback,
const std::string& error_message) { … }
void BluetoothSocketBlueZ::OnConnectProfile(
base::OnceClosure success_callback) { … }
void BluetoothSocketBlueZ::OnConnectProfileError(
ErrorCompletionCallback error_callback,
const std::string& error_name,
const std::string& error_message) { … }
void BluetoothSocketBlueZ::AdapterPresentChanged(BluetoothAdapter* adapter,
bool present) { … }
void BluetoothSocketBlueZ::OnInternalRegisterProfile(
BluetoothAdapterProfileBlueZ* profile) { … }
void BluetoothSocketBlueZ::OnInternalRegisterProfileError(
const std::string& error_message) { … }
void BluetoothSocketBlueZ::Released() { … }
void BluetoothSocketBlueZ::NewConnection(
const dbus::ObjectPath& device_path,
base::ScopedFD fd,
const bluez::BluetoothProfileServiceProvider::Delegate::Options& options,
ConfirmationCallback callback) { … }
void BluetoothSocketBlueZ::RequestDisconnection(
const dbus::ObjectPath& device_path,
ConfirmationCallback callback) { … }
void BluetoothSocketBlueZ::Cancel() { … }
void BluetoothSocketBlueZ::AcceptConnectionRequest() { … }
void BluetoothSocketBlueZ::DoNewConnection(
const dbus::ObjectPath& device_path,
base::ScopedFD fd,
const bluez::BluetoothProfileServiceProvider::Delegate::Options& options,
ConfirmationCallback callback) { … }
void BluetoothSocketBlueZ::OnNewConnection(
scoped_refptr<BluetoothSocket> socket,
ConfirmationCallback callback,
Status status) { … }
void BluetoothSocketBlueZ::UnregisterProfile() { … }
}