#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "device/bluetooth/floss/floss_dbus_client.h"
#include <string>
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "dbus/message.h"
#include "device/bluetooth/floss/floss_adapter_client.h"
#include "device/bluetooth/floss/floss_lescan_client.h"
namespace floss {
int kDBusTimeoutMs = …;
int kAdapterEnabledTimeoutMs = …;
namespace {
constexpr char kDeviceIdNameKey[] = …;
constexpr char kDeviceIdAddressKey[] = …;
}
Error::Error(const std::string& name, const std::string& message)
: … { … }
std::ostream& operator<<(std::ostream& os, const Error& error) { … }
std::string Error::ToString() { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const bool*) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const uint8_t*) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const int8_t*) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const uint16_t*) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const int16_t*) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const uint32_t*) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const int32_t*) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const uint64_t*) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const int64_t*) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const double*) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const std::string*) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const dbus::ObjectPath*) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const base::ScopedFD*) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const FlossDeviceId*) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(
const FlossAdapterClient::VendorProductInfo*) { … }
template <>
DEVICE_BLUETOOTH_EXPORT const DBusTypeInfo& GetDBusTypeInfo(
const device::BluetoothUUID*) { … }
FlossDBusClient::FlossDBusClient() = default;
FlossDBusClient::~FlossDBusClient() = default;
const char FlossDBusClient::kErrorDBus[] = …;
const char FlossDBusClient::kErrorNoResponse[] = …;
const char FlossDBusClient::kErrorInvalidParameters[] = …;
const char FlossDBusClient::kErrorInvalidReturn[] = …;
const char FlossDBusClient::kErrorDoesNotExist[] = …;
const char FlossDBusClient::kOptionalValueKey[] = …;
dbus::ObjectPath FlossDBusClient::GenerateAdapterPath(int adapter_index) { … }
dbus::ObjectPath FlossDBusClient::GenerateGattPath(int adapter_index) { … }
dbus::ObjectPath FlossDBusClient::GenerateBatteryManagerPath(
int adapter_index) { … }
dbus::ObjectPath FlossDBusClient::GenerateBluetoothTelephonyPath(
int adapter_index) { … }
dbus::ObjectPath FlossDBusClient::GenerateAdminPath(int adapter_index) { … }
dbus::ObjectPath FlossDBusClient::GenerateLoggingPath(int adapter_index) { … }
device::BluetoothDevice::ConnectErrorCode
FlossDBusClient::BtifStatusToConnectErrorCode(
FlossDBusClient::BtifStatus status) { … }
void FlossDBusClient::LogErrorResponse(const std::string& message,
dbus::ErrorResponse* error) { … }
Error FlossDBusClient::ErrorResponseToError(const std::string& default_name,
const std::string& default_message,
dbus::ErrorResponse* error) { … }
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader, Void* value) { … }
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader, bool* value) { … }
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader,
uint8_t* value) { … }
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader,
int8_t* value) { … }
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader,
uint16_t* value) { … }
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader,
uint32_t* value) { … }
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader,
uint64_t* value) { … }
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader,
int32_t* value) { … }
template bool FlossDBusClient::ReadDBusParam<int32_t>(
dbus::MessageReader* reader,
std::optional<int32_t>* value);
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader,
std::string* value) { … }
template bool FlossDBusClient::ReadDBusParam<std::string>(
dbus::MessageReader* reader,
std::optional<std::string>* value);
template <>
bool FlossDBusClient::ReadDBusParam(
dbus::MessageReader* reader,
FlossAdapterClient::BluetoothDeviceType* value) { … }
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader,
device::BluetoothUUID* uuid) { … }
template bool FlossDBusClient::ReadDBusParam<device::BluetoothUUID>(
dbus::MessageReader* reader,
std::optional<device::BluetoothUUID>* uuid);
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader,
FlossDBusClient::BtifStatus* status) { … }
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader,
base::ScopedFD* fd) { … }
template bool FlossDBusClient::ReadDBusParam<base::ScopedFD>(
dbus::MessageReader* reader,
std::optional<base::ScopedFD>* fd);
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader,
FlossDeviceId* device) { … }
template <>
bool FlossDBusClient::ReadDBusParam(
dbus::MessageReader* reader,
FlossAdapterClient::VendorProductInfo* vpi) { … }
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader,
FlossAdapterClient::BtAddressType* type) { … }
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader,
FlossAdapterClient::BtAdapterRole* type) { … }
template <>
void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
const FlossDeviceId& device) { … }
template <>
void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
const uint64_t& data) { … }
template <>
void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
const uint32_t& data) { … }
template <>
void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
const uint8_t& data) { … }
template <>
void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
const int8_t& data) { … }
template <>
void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
const uint16_t& data) { … }
template <>
void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
const int16_t& data) { … }
template void FlossDBusClient::WriteDBusParam<uint32_t>(
dbus::MessageWriter* writer,
const std::optional<uint32_t>& data);
template <>
void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
const int32_t& data) { … }
template <>
void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
const std::string& data) { … }
template <>
void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
const bool& data) { … }
template <>
void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
const std::vector<uint8_t>& data) { … }
template <>
DEVICE_BLUETOOTH_EXPORT void FlossDBusClient::WriteDBusParam(
dbus::MessageWriter* writer,
const device::BluetoothUUID& uuid) { … }
template <>
void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
const base::ScopedFD& fd) { … }
template <>
void FlossDBusClient::WriteDBusParam(dbus::MessageWriter* writer,
const dbus::ObjectPath& path) { … }
template <>
void FlossDBusClient::WriteDBusParam(
dbus::MessageWriter* writer,
const FlossDBusClient::BtifStatus& status) { … }
template void FlossDBusClient::DefaultResponseWithCallback(
ResponseCallback<bool> callback,
dbus::Response* response,
dbus::ErrorResponse* error_response);
template void FlossDBusClient::DefaultResponseWithCallback(
ResponseCallback<uint8_t> callback,
dbus::Response* response,
dbus::ErrorResponse* error_response);
template void FlossDBusClient::DefaultResponseWithCallback(
ResponseCallback<uint32_t> callback,
dbus::Response* response,
dbus::ErrorResponse* error_response);
template void FlossDBusClient::DefaultResponseWithCallback(
ResponseCallback<std::string> callback,
dbus::Response* response,
dbus::ErrorResponse* error_response);
template void FlossDBusClient::DefaultResponseWithCallback(
ResponseCallback<std::vector<FlossDeviceId>> callback,
dbus::Response* response,
dbus::ErrorResponse* error_response);
template void FlossDBusClient::DefaultResponseWithCallback(
ResponseCallback<FlossAdapterClient::BluetoothDeviceType> callback,
dbus::Response* response,
dbus::ErrorResponse* error_response);
template void FlossDBusClient::DefaultResponseWithCallback(
ResponseCallback<device::BluetoothDevice::UUIDList> callback,
dbus::Response* response,
dbus::ErrorResponse* error_response);
template void FlossDBusClient::DefaultResponseWithCallback(
ResponseCallback<FlossAdapterClient::VendorProductInfo> callback,
dbus::Response* response,
dbus::ErrorResponse* error_response);
template void FlossDBusClient::DefaultResponseWithCallback(
ResponseCallback<FlossAdapterClient::BtAddressType> callback,
dbus::Response* response,
dbus::ErrorResponse* error_response);
template void FlossDBusClient::DefaultResponseWithCallback(
ResponseCallback<FlossDBusClient::BtifStatus> callback,
dbus::Response* response,
dbus::ErrorResponse* error_response);
void FlossDBusClient::DefaultResponse(const std::string& caller,
dbus::Response* response,
dbus::ErrorResponse* error_response) { … }
}