return;
}
- for (auto arg : args) {
+ for (const auto& arg : args) {
if (arg == "-d") {
dump_scan_record = true;
} else if (arg == "-h") {
const char kExecuteLong[] = "exec";
const char kExecuteShort[] = "e";
-bool ExecuteCommand(sp<IBluetooth> bt_iface, std::string &command) {
+bool ExecuteCommand(const sp<IBluetooth>& bt_iface, std::string &command) {
vector<string> args =
base::SplitString(command, " ", base::TRIM_WHITESPACE,
base::SPLIT_WANT_ALL);
class BluetoothGattCharacteristic : public Parcelable, public ::bluetooth::Characteristic {
public:
BluetoothGattCharacteristic() = default;
- BluetoothGattCharacteristic(const ::bluetooth::Characteristic& characteristic)
+ BluetoothGattCharacteristic(const ::bluetooth::Characteristic& characteristic) // NOLINT(implicit)
: ::bluetooth::Characteristic(characteristic){};
~BluetoothGattCharacteristic() = default;
class BluetoothGattDescriptor : public Parcelable, public ::bluetooth::Descriptor {
public:
BluetoothGattDescriptor() = default;
- BluetoothGattDescriptor(const ::bluetooth::Descriptor& characteristic)
+ BluetoothGattDescriptor(const ::bluetooth::Descriptor& characteristic) // NOLINT(implicit)
: ::bluetooth::Descriptor(characteristic){};
~BluetoothGattDescriptor() = default;
class BluetoothGattIncludedService : public Parcelable {
public:
BluetoothGattIncludedService() = default;
- BluetoothGattIncludedService(const ::bluetooth::Service& service)
+ BluetoothGattIncludedService(const ::bluetooth::Service& service) // NOLINT(implicit)
: handle_(service.handle()), uuid_(service.uuid()),
primary_(service.primary()) {};
~BluetoothGattIncludedService() = default;
class BluetoothGattService : public Parcelable, public ::bluetooth::Service {
public:
BluetoothGattService() = default;
- BluetoothGattService(const ::bluetooth::Service& service) : ::bluetooth::Service(service){};
- BluetoothGattService(const BluetoothGattIncludedService& includedService)
+ BluetoothGattService(const ::bluetooth::Service& service) : ::bluetooth::Service(service){}; // NOLINT(implicit)
+ BluetoothGattService(const BluetoothGattIncludedService& includedService) // NOLINT(implicit)
: ::bluetooth::Service(includedService.handle(), includedService.primary(),
includedService.uuid(), {}, {}) {};
~BluetoothGattService() = default;
namespace bluetooth {
ScanResult::ScanResult(const std::string& device_address,
- const std::vector<uint8_t> scan_record,
+ const std::vector<uint8_t>& scan_record,
int rssi)
: device_address_(device_address),
scan_record_(scan_record),
class ScanResult {
public:
ScanResult(const std::string& device_address,
- const std::vector<uint8_t> scan_record,
+ const std::vector<uint8_t>& scan_record,
int rssi);
ScanResult() = default;
~ScanResult() = default;
}
std::shared_ptr<Connection> connection;
- for (auto tmp : iter->second) {
+ for (const auto& tmp : iter->second) {
if (tmp->request_id_to_handle.find(request_id) ==
tmp->request_id_to_handle.end())
continue;
// Send the notification/indication on all matching connections.
int send_count = 0;
- for (auto conn : conn_iter->second) {
+ for (const auto& conn : conn_iter->second) {
// Make sure that one isn't already pending for this connection.
if (pending_indications_.find(conn->conn_id) !=
pending_indications_.end()) {
const std::vector<uint8_t>& manufacturer_data,
bool transmit_name) {
std::vector<uint8_t> id_data;
- auto mutable_manufacturer_data = manufacturer_data;
- auto mutable_service_data = service_data;
+ const auto& mutable_manufacturer_data = manufacturer_data;
+ const auto& mutable_service_data = service_data;
for (const UUID &id : ids) {
const auto le_id = id.GetFullLittleEndian();
const std::vector<uint8_t>& manufacturer_data,
bool transmit_name) {
std::vector<uint8_t> id_data;
- auto mutable_manufacturer_data = manufacturer_data;
- auto mutable_service_data = service_data;
+ const auto& mutable_manufacturer_data = manufacturer_data;
+ const auto& mutable_service_data = service_data;
for (const UUID &id : ids) {
const auto le_id = id.GetFullLittleEndian();
RegisterClientCallback(g_interface, status, client_if, *app_uuid));
}
-void ScanResultCallback(bt_bdaddr_t* bda, int rssi, vector<uint8_t> adv_data) {
+void ScanResultCallback(bt_bdaddr_t* bda, int rssi, vector<uint8_t> adv_data) { // NOLINT(pass-by-value)
shared_lock<shared_timed_mutex> lock(g_instance_lock);
VERIFY_INTERFACE_OR_RETURN();
CHECK(bda);
void ServiceAddedCallback(
int status,
int server_if,
- vector<btgatt_db_element_t> service) {
+ vector<btgatt_db_element_t> service) { // NOLINT(pass-by-value)
shared_lock<shared_timed_mutex> lock(g_instance_lock);
VLOG(2) << __func__ << " - status: " << status << " server_if: " << server_if
<< " count: " << service.size();
bt_bdaddr_t* bda,
int attr_handle, int offset,
bool need_rsp, bool is_prep,
- vector<uint8_t> value) {
+ vector<uint8_t> value) { // NOLINT(pass-by-value)
shared_lock<shared_timed_mutex> lock(g_instance_lock);
VLOG(2) << __func__ << " - conn_id: " << conn_id << " trans_id: " << trans_id
<< " attr_handle: " << attr_handle << " offset: " << offset
BluetoothGattInterface* /* gatt_iface */,
const bt_bdaddr_t& /* bda */,
int /* rssi */,
- vector<uint8_t> /* adv_data */) {
+ vector<uint8_t> /* adv_data */) { // NOLINT(pass-by-value)
// Do Nothing.
}
BluetoothGattInterface* /* gatt_iface */,
int /* status */,
int /* server_if */,
- vector<btgatt_db_element_t> /* service */) {
+ vector<btgatt_db_element_t> /* service */) { // NOLINT(pass-by-value)
// Do nothing.
}
int /* offset */,
bool /* need_rsp */,
bool /* is_prep */,
- vector<uint8_t> /* value */) {
+ vector<uint8_t> /* value */) { // NOLINT(pass-by-value)
// Do nothing.
}
int /* offset */,
bool /* need_rsp */,
bool /* is_prep */,
- vector<uint8_t> /* value */) {
+ vector<uint8_t> /* value */) { // NOLINT(pass-by-value)
// Do nothing.
}
virtual void ScanResultCallback(
BluetoothGattInterface* gatt_iface,
const bt_bdaddr_t& bda, int rssi,
- vector<uint8_t> adv_data);
+ vector<uint8_t> adv_data); // NOLINT(pass-by-value)
virtual void ConnectCallback(
BluetoothGattInterface* gatt_iface,
virtual void ServiceAddedCallback(
BluetoothGattInterface* gatt_iface,
int status, int server_if,
- vector<btgatt_db_element_t> service);
+ vector<btgatt_db_element_t> service); // NOLINT(pass-by-value)
virtual void ServiceStoppedCallback(
BluetoothGattInterface* gatt_iface,
const bt_bdaddr_t& bda,
int attr_handle, int offset,
bool need_rsp, bool is_prep,
- vector<uint8_t> value);
+ vector<uint8_t> value); // NOLINT(pass-by-value)
virtual void RequestWriteDescriptorCallback(
BluetoothGattInterface* gatt_iface,
const bt_bdaddr_t& bda,
int attr_handle, int offset,
bool need_rsp, bool is_prep,
- vector<uint8_t> value);
+ vector<uint8_t> value); // NOLINT(pass-by-alue)
virtual void RequestExecWriteCallback(
BluetoothGattInterface* gatt_iface,
bt_status_t FakeMultiAdvSetInstData(
int client_if, bool set_scan_rsp, bool include_name, bool incl_txpower,
- int appearance, vector<uint8_t> manufacturer_data,
- vector<uint8_t> service_data,
- vector<uint8_t> service_uuid) {
+ int appearance, vector<uint8_t> manufacturer_data, // NOLINT(pass-by-value)
+ vector<uint8_t> service_data, // NOLINT(pass-by-value)
+ vector<uint8_t> service_uuid) { // NOLINT(pass-by-value)
if (g_client_handler)
return g_client_handler->MultiAdvSetInstData(
client_if, set_scan_rsp, include_name, incl_txpower, appearance,
}
void FakeBluetoothGattInterface::NotifyScanResultCallback(
- const bt_bdaddr_t& bda, int rssi, vector<uint8_t> adv_data) {
+ const bt_bdaddr_t& bda, int rssi, const vector<uint8_t>& adv_data) {
FOR_EACH_OBSERVER(ClientObserver, client_observers_,
ScanResultCallback(this, bda, rssi, adv_data));
}
}
void FakeBluetoothGattInterface::NotifyServerConnectionCallback(
- int conn_id, int server_if, int connected, const bt_bdaddr_t& bda) {
+ int conn_id, int server_if, int connected, bt_bdaddr_t bda) { // NOLINT(pass-by-value)
FOR_EACH_OBSERVER(
ServerObserver, server_observers_,
ConnectionCallback(this, conn_id, server_if, connected, bda));
void FakeBluetoothGattInterface::NotifyServiceAddedCallback(
int status, int server_if,
- vector<btgatt_db_element_t> service) {
+ vector<btgatt_db_element_t> service) { // NOLINT(pass-by-value)
FOR_EACH_OBSERVER(
ServerObserver, server_observers_,
ServiceAddedCallback(this, status, server_if, service));
void FakeBluetoothGattInterface::NotifyRequestWriteCharacteristicCallback(
int conn_id, int trans_id, const bt_bdaddr_t& bda, int attr_handle,
- int offset, bool need_rsp, bool is_prep, vector<uint8_t> value) {
+ int offset, bool need_rsp, bool is_prep, vector<uint8_t> value) { // NOLINT(pass-by-value)
FOR_EACH_OBSERVER(
ServerObserver, server_observers_,
RequestWriteCharacteristicCallback(
int conn_id, int trans_id,
const bt_bdaddr_t& bda, int attr_handle,
int offset, bool need_rsp, bool is_prep,
- vector<uint8_t> value) {
+ vector<uint8_t> value) { // NOLINT(pass-by-value)
FOR_EACH_OBSERVER(
ServerObserver, server_observers_,
RequestWriteDescriptorCallback(
void NotifyDisconnectCallback(int conn_id, int status, int client_if,
const bt_bdaddr_t& bda);
void NotifyScanResultCallback(const bt_bdaddr_t& bda, int rssi,
- vector<uint8_t> adv_data);
+ const vector<uint8_t>& adv_data);
void NotifyMultiAdvEnableCallback(int client_if, int status);
void NotifyMultiAdvDataCallback(int client_if, int status);
void NotifyMultiAdvDisableCallback(int client_if, int status);
const bt_uuid_t& app_uuid);
void NotifyServerConnectionCallback(int conn_id, int server_if,
int connected,
- const bt_bdaddr_t& bda);
+ bt_bdaddr_t bda); // NOLINT(pass-by-value)
void NotifyServiceAddedCallback(int status, int server_if,
- vector<btgatt_db_element_t> srvc);
+ vector<btgatt_db_element_t> srvc); // NOLINT(pass-by-value)
void NotifyCharacteristicAddedCallback(int status, int server_if,
const bt_uuid_t& uuid,
int srvc_handle, int char_handle);
void NotifyRequestWriteCharacteristicCallback(int conn_id, int trans_id,
const bt_bdaddr_t& bda, int attr_handle,
int offset, bool need_rsp, bool is_prep,
- vector<uint8_t> value);
+ vector<uint8_t> value); // NOLINT(pass-by-value)
void NotifyRequestWriteDescriptorCallback(int conn_id, int trans_id,
const bt_bdaddr_t& bda, int attr_handle,
int offset, bool need_rsp, bool is_prep,
- vector<uint8_t> value);
+ vector<uint8_t> value); // NOLINT(pass-by-value)
void NotifyRequestExecWriteCallback(int conn_id, int trans_id,
const bt_bdaddr_t& bda, int exec_write);
void NotifyIndicationSentCallback(int conn_id, int status);
VLOG(2) << __func__ << " called with fd " << fd;
if (args.size() > 0) {
// TODO (jamuraa): Parse arguments and switch on --proto, --proto_text
- for (auto x : args) {
+ for (const auto& x : args) {
VLOG(2) << __func__ << "argument: " << x.string();
}
}
}
std::vector<bluetooth::ScanFilter> flt;
- for (auto filter : filters) {
+ for (const auto& filter : filters) {
flt.push_back(filter);
}
// Create a weak pointer and pass that to the callback to prevent a potential
// use after free.
android::wp<BluetoothLowEnergyBinderServer> weak_ptr_to_this(this);
- auto settings_copy = settings;
+ const auto& settings_copy = settings;
auto callback = [=](bluetooth::BLEStatus status) {
auto sp_to_this = weak_ptr_to_this.promote();
if (!sp_to_this.get()) {
StopScan();
}
-bool LowEnergyClient::Connect(std::string address, bool is_direct) {
+bool LowEnergyClient::Connect(const std::string& address, bool is_direct) {
VLOG(2) << __func__ << "Address: " << address << " is_direct: " << is_direct;
bt_bdaddr_t bda;
return true;
}
-bool LowEnergyClient::Disconnect(std::string address) {
+bool LowEnergyClient::Disconnect(const std::string& address) {
VLOG(2) << __func__ << "Address: " << address;
bt_bdaddr_t bda;
return true;
}
-bool LowEnergyClient::SetMtu(std::string address, int mtu) {
+bool LowEnergyClient::SetMtu(const std::string& address, int mtu) {
VLOG(2) << __func__ << "Address: " << address
<< " MTU: " << mtu;
// Initiates a BLE connection do device with address |address|. If
// |is_direct| is set, use direct connect procedure. Return true on success
//, false otherwise.
- bool Connect(std::string address, bool is_direct);
+ bool Connect(const std::string& address, bool is_direct);
// Disconnect from previously connected BLE device with address |address|.
// Return true on success, false otherwise.
- bool Disconnect(std::string address);
+ bool Disconnect(const std::string& address);
// Sends request to set MTU to |mtu| for device with address |address|.
// Return true on success, false otherwise.
- bool SetMtu(std::string address, int mtu);
+ bool SetMtu(const std::string& address, int mtu);
// Initiates a BLE device scan for this client using the given |settings| and
// |filters|. See the documentation for ScanSettings and ScanFilter for how
MOCK_METHOD7(MultiAdvEnable, bt_status_t(int, int, int, int, int, int, int));
MOCK_METHOD7(
MultiAdvSetInstDataMock,
- bt_status_t(bool, bool, bool, int, vector<uint8_t>, vector<uint8_t>,
- vector<uint8_t>));
+ bt_status_t(bool, bool, bool, int, const vector<uint8_t>&, const vector<uint8_t>&,
+ const vector<uint8_t>&));
MOCK_METHOD1(MultiAdvDisable, bt_status_t(int));
// GMock has macros for up to 10 arguments (11 is really just too many...).
}
void RegisterTestClient(
- const std::function<void(std::unique_ptr<LowEnergyClient> client)>
+ const std::function<void(std::unique_ptr<LowEnergyClient> client)>&
callback) {
UUID uuid = UUID::GetRandom();
auto api_callback = [&](BLEStatus status, const UUID& in_uuid,
ASSERT_FALSE(le_client_->IsStoppingAdvertising());
}
- void AdvertiseDataTestHelper(AdvertiseData data, std::function<void(BLEStatus)> callback) {
+ void AdvertiseDataTestHelper(const AdvertiseData& data, const std::function<void(BLEStatus)>& callback) {
AdvertiseSettings settings;
EXPECT_TRUE(le_client_->StartAdvertising(
settings, data, AdvertiseData(), callback));
// TODO(dennischeng): Once PostDelayedTask works, get rid of this and only use
// |RegisterDelayedEventChannel|.
void RegisterEventChannel(
- std::function<void(std::unique_ptr<EventPacket>)> send_event);
+ const std::function<void(std::unique_ptr<EventPacket>)>& send_event);
void RegisterDelayedEventChannel(
- std::function<void(std::unique_ptr<EventPacket>,
- std::chrono::milliseconds)> send_event);
+ const std::function<void(std::unique_ptr<EventPacket>,
+ std::chrono::milliseconds)>& send_event);
// Controller commands. For error codes, see the Bluetooth Core Specification,
// Version 4.2, Volume 2, Part D (page 370).
// Bluetooth Core Specification Version 4.2, Volume 2, Part E, Section 7.3.12
static std::unique_ptr<EventPacket> CreateCommandCompleteReadLocalName(
- const uint8_t status, const std::string local_name);
+ const uint8_t status, const std::string& local_name);
// Bluetooth Core Specification Version 4.2, Volume 2, Part E, Section 7.4.1
static std::unique_ptr<EventPacket>
// Sets the callback that is run when command packets are received.
void RegisterCommandHandler(
- std::function<void(std::unique_ptr<CommandPacket>)> callback);
+ const std::function<void(std::unique_ptr<CommandPacket>)>& callback);
// Sets the callback that is to schedule events.
void RegisterEventScheduler(
- std::function<void(std::chrono::milliseconds, const TaskCallback&)>
+ const std::function<void(std::chrono::milliseconds, const TaskCallback&)>&
evtScheduler);
// Sets the callback that is to schedule events.
void RegisterPeriodicEventScheduler(
- std::function<void(std::chrono::milliseconds,
+ const std::function<void(std::chrono::milliseconds,
std::chrono::milliseconds,
- const TaskCallback&)> periodicEvtScheduler);
+ const TaskCallback&)>& periodicEvtScheduler);
// Posts the event onto |outbound_events_| to be written sometime in the
// future when the vendor file descriptor is ready for writing.
// Sets the callback that fires when data is read in
// |OnFileCanReadWithoutBlocking|.
void RegisterCommandHandler(
- std::function<void(const std::string&, const vector<std::string>&)>
+ const std::function<void(const std::string&, const vector<std::string>&)>&
callback);
void OnFileCanReadWithoutBlocking(int fd);
AsyncTaskManager(const AsyncTaskManager&) = delete;
AsyncTaskManager& operator=(const AsyncTaskManager&) = delete;
- AsyncTaskId scheduleTask(std::shared_ptr<Task> task) {
+ AsyncTaskId scheduleTask(const std::shared_ptr<Task>& task) {
AsyncTaskId task_id = kInvalidTaskId;
{
std::unique_lock<std::mutex> guard(internal_mutex_);
}
void DualModeController::RegisterEventChannel(
- std::function<void(std::unique_ptr<EventPacket>)> callback) {
+ const std::function<void(std::unique_ptr<EventPacket>)>& callback) {
send_event_ = callback;
}
void DualModeController::RegisterDelayedEventChannel(
- std::function<void(std::unique_ptr<EventPacket>, std::chrono::milliseconds)>
+ const std::function<void(std::unique_ptr<EventPacket>, std::chrono::milliseconds)>&
callback) {
send_delayed_event_ = callback;
SetEventDelay(0);
// Bluetooth Core Specification Version 4.2, Volume 2, Part E, Section 7.3.12
std::unique_ptr<EventPacket> EventPacket::CreateCommandCompleteReadLocalName(
- const uint8_t status, const std::string local_name) {
+ const uint8_t status, const std::string& local_name) {
std::unique_ptr<EventPacket> evt_ptr =
EventPacket::CreateCommandCompleteOnlyStatusEvent(HCI_READ_LOCAL_NAME,
status);
}
void HciTransport::RegisterCommandHandler(
- std::function<void(std::unique_ptr<CommandPacket>)> callback) {
+ const std::function<void(std::unique_ptr<CommandPacket>)>& callback) {
command_handler_ = callback;
}
void HciTransport::RegisterEventScheduler(
- std::function<void(std::chrono::milliseconds, const TaskCallback&)>
+ const std::function<void(std::chrono::milliseconds, const TaskCallback&)>&
evtScheduler) {
schedule_event_ = evtScheduler;
}
void HciTransport::RegisterPeriodicEventScheduler(
- std::function<void(std::chrono::milliseconds,
+ const std::function<void(std::chrono::milliseconds,
std::chrono::milliseconds,
- const TaskCallback&)> periodicEvtScheduler) {
+ const TaskCallback&)>& periodicEvtScheduler) {
schedule_periodic_event_ = periodicEvtScheduler;
}
}
void TestChannelTransport::RegisterCommandHandler(
- std::function<void(const std::string&, const vector<std::string>&)>
+ const std::function<void(const std::string&, const vector<std::string>&)>&
callback) {
command_handler_ = callback;
}