#include "device/bluetooth/floss/floss_adapter_client.h"
#include <algorithm>
#include <map>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/observer_list.h"
#include "base/strings/string_number_conversions.h"
#include "dbus/bus.h"
#include "dbus/exported_object.h"
#include "dbus/message.h"
#include "dbus/object_proxy.h"
#include "device/bluetooth/floss/floss_dbus_client.h"
namespace floss {
namespace {
void HandleExported(const std::string& method_name,
const std::string& interface_name,
const std::string& object_path,
bool success) { … }
}
constexpr char FlossAdapterClient::kErrorUnknownAdapter[] = …;
constexpr char FlossAdapterClient::kExportedCallbacksPath[] = …"/org/chromium/bluetooth/adapter/callback/lacros";
#else
"/org/chromium/bluetooth/adapter/callback";
#endif
static uint32_t callback_path_index_ = …;
void FlossAdapterClient::SetName(ResponseCallback<Void> callback,
const std::string& name) { … }
void FlossAdapterClient::SetDiscoverable(ResponseCallback<Void> callback,
bool discoverable) { … }
void FlossAdapterClient::SetDiscoverable(ResponseCallback<Void> callback,
BtDiscoverableMode mode,
uint32_t duration) { … }
void FlossAdapterClient::StartDiscovery(ResponseCallback<Void> callback) { … }
void FlossAdapterClient::CancelDiscovery(ResponseCallback<Void> callback) { … }
void FlossAdapterClient::CreateBond(ResponseCallback<bool> callback,
FlossDeviceId device,
BluetoothTransport transport) { … }
void FlossAdapterClient::CreateBond(
ResponseCallback<FlossDBusClient::BtifStatus> callback,
FlossDeviceId device,
BluetoothTransport transport) { … }
void FlossAdapterClient::CancelBondProcess(ResponseCallback<bool> callback,
FlossDeviceId device) { … }
void FlossAdapterClient::RemoveBond(ResponseCallback<bool> callback,
FlossDeviceId device) { … }
void FlossAdapterClient::GetRemoteType(
ResponseCallback<BluetoothDeviceType> callback,
FlossDeviceId device) { … }
void FlossAdapterClient::GetRemoteClass(ResponseCallback<uint32_t> callback,
FlossDeviceId device) { … }
void FlossAdapterClient::GetRemoteAppearance(
ResponseCallback<uint16_t> callback,
FlossDeviceId device) { … }
void FlossAdapterClient::GetConnectionState(ResponseCallback<uint32_t> callback,
const FlossDeviceId& device) { … }
void FlossAdapterClient::GetRemoteUuids(
ResponseCallback<device::BluetoothDevice::UUIDList> callback,
FlossDeviceId device) { … }
void FlossAdapterClient::FetchRemoteUuids(ResponseCallback<bool> callback,
FlossDeviceId device) { … }
void FlossAdapterClient::GetRemoteVendorProductInfo(
ResponseCallback<FlossAdapterClient::VendorProductInfo> callback,
FlossDeviceId device) { … }
void FlossAdapterClient::GetRemoteAddressType(
ResponseCallback<FlossAdapterClient::BtAddressType> callback,
FlossDeviceId device) { … }
void FlossAdapterClient::GetBondState(ResponseCallback<uint32_t> callback,
const FlossDeviceId& device) { … }
void FlossAdapterClient::ConnectAllEnabledProfiles(
ResponseCallback<Void> callback,
const FlossDeviceId& device) { … }
void FlossAdapterClient::ConnectAllEnabledProfiles(
ResponseCallback<FlossDBusClient::BtifStatus> callback,
const FlossDeviceId& device) { … }
void FlossAdapterClient::DisconnectAllEnabledProfiles(
ResponseCallback<Void> callback,
const FlossDeviceId& device) { … }
void FlossAdapterClient::SetPairingConfirmation(ResponseCallback<Void> callback,
const FlossDeviceId& device,
bool accept) { … }
void FlossAdapterClient::SetPin(ResponseCallback<Void> callback,
const FlossDeviceId& device,
bool accept,
const std::vector<uint8_t>& pin) { … }
void FlossAdapterClient::SetPasskey(ResponseCallback<Void> callback,
const FlossDeviceId& device,
bool accept,
const std::vector<uint8_t>& passkey) { … }
void FlossAdapterClient::GetBondedDevices() { … }
void FlossAdapterClient::GetConnectedDevices() { … }
void FlossAdapterClient::SdpSearch(ResponseCallback<bool> callback,
const FlossDeviceId& device,
device::BluetoothUUID uuid) { … }
void FlossAdapterClient::CreateSdpRecord(ResponseCallback<bool> callback,
const BtSdpRecord& record) { … }
void FlossAdapterClient::RemoveSdpRecord(ResponseCallback<bool> callback,
const int32_t& handle) { … }
void FlossAdapterClient::Init(dbus::Bus* bus,
const std::string& service_name,
const int adapter_index,
base::Version version,
base::OnceClosure on_ready) { … }
void FlossAdapterClient::OnAdapterPropertyChanged(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossAdapterClient::OnAddressChanged(const std::string& address) { … }
void FlossAdapterClient::OnNameChanged(const std::string& name) { … }
void FlossAdapterClient::OnDiscoverableChanged(const bool& discoverable) { … }
void FlossAdapterClient::OnDiscoveringChanged(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossAdapterClient::OnDeviceFound(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossAdapterClient::OnDeviceCleared(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossAdapterClient::OnDevicePropertiesChanged(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossAdapterClient::OnSspRequest(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossAdapterClient::OnPinDisplay(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossAdapterClient::OnPinRequest(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossAdapterClient::OnGetBondedDevices(
DBusResult<std::vector<FlossDeviceId>> ret) { … }
void FlossAdapterClient::OnGetConnectedDevices(
DBusResult<std::vector<FlossDeviceId>> ret) { … }
void FlossAdapterClient::OnBondStateChanged(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossAdapterClient::OnSdpSearchComplete(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossAdapterClient::OnSdpRecordCreated(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossAdapterClient::OnDeviceConnected(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossAdapterClient::OnDeviceDisconnected(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossAdapterClient::UpdateDiscoverableTimeout() { … }
void FlossAdapterClient::OnDiscoverableTimeout(DBusResult<uint32_t> ret) { … }
void FlossAdapterClient::OnRegisterCallback(DBusResult<uint32_t> ret) { … }
void FlossAdapterClient::OnRegisterConnectionCallback(
DBusResult<uint32_t> ret) { … }
void FlossAdapterClient::OnUnregisterCallbacks(DBusResult<bool> ret) { … }
FlossAdapterClient::FlossAdapterClient() = default;
FlossAdapterClient::~FlossAdapterClient() { … }
void FlossAdapterClient::AddObserver(FlossAdapterClient::Observer* observer) { … }
bool FlossAdapterClient::HasObserver(FlossAdapterClient::Observer* observer) { … }
void FlossAdapterClient::RemoveObserver(
FlossAdapterClient::Observer* observer) { … }
std::unique_ptr<FlossAdapterClient> FlossAdapterClient::Create() { … }
bool FlossAdapterClient::IsConnectionPaired(uint32_t connection_state) { … }
template <>
void FlossDBusClient::WriteDBusParam(
dbus::MessageWriter* writer,
const FlossAdapterClient::BluetoothTransport& data) { … }
template <>
void FlossDBusClient::WriteDBusParam(
dbus::MessageWriter* writer,
const FlossAdapterClient::BtDiscoverableMode& mode) { … }
template void FlossAdapterClient::CallAdapterMethod(
ResponseCallback<Void> callback,
const char* member);
template void FlossAdapterClient::CallAdapterMethod(
ResponseCallback<uint8_t> callback,
const char* member);
template void FlossAdapterClient::CallAdapterMethod(
ResponseCallback<std::string> callback,
const char* member,
const uint32_t& arg1);
template void FlossAdapterClient::CallAdapterMethod(
ResponseCallback<Void> callback,
const char* member,
const uint32_t& arg1,
const std::string& arg2);
}