Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1727)

Unified Diff: device/bluetooth/bluetooth_device.cc

Issue 2248913002: bluetooth: Implement RSSI and Tx Power on macOS and Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-refactor-adv-data
Patch Set: Address jyasskin's comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_device.cc
diff --git a/device/bluetooth/bluetooth_device.cc b/device/bluetooth/bluetooth_device.cc
index bf193707b0b9b4168b256dcb52536ee214fabef8..0ce77dce7025ae9d34f6f55526e1e211627710cb 100644
--- a/device/bluetooth/bluetooth_device.cc
+++ b/device/bluetooth/bluetooth_device.cc
@@ -311,6 +311,14 @@ const std::vector<uint8_t>* BluetoothDevice::GetServiceDataForUUID(
return nullptr;
}
+base::Optional<int8_t> BluetoothDevice::GetInquiryRSSI() const {
+ return inquiry_rssi_;
+}
+
+base::Optional<int8_t> BluetoothDevice::GetInquiryTxPower() const {
+ return inquiry_tx_power_;
+}
+
void BluetoothDevice::CreateGattConnection(
const GattConnectionCallback& callback,
const ConnectErrorCallback& error_callback) {
@@ -381,16 +389,29 @@ std::string BluetoothDevice::CanonicalizeAddress(const std::string& address) {
std::string BluetoothDevice::GetIdentifier() const { return GetAddress(); }
-void BluetoothDevice::UpdateAdvertisementData(UUIDList advertised_uuids,
- ServiceDataMap service_data) {
+void BluetoothDevice::UpdateAdvertisementData(int8_t rssi,
+ UUIDList advertised_uuids,
+ ServiceDataMap service_data,
+ const int8_t* tx_power) {
UpdateTimestamp();
+
+ inquiry_rssi_ = rssi;
+
device_uuids_.ReplaceAdvertisedUUIDs(std::move(advertised_uuids));
service_data_ = std::move(service_data);
+
+ if (tx_power != nullptr) {
+ inquiry_tx_power_ = *tx_power;
+ } else {
+ inquiry_tx_power_ = base::nullopt;
+ }
}
void BluetoothDevice::ClearAdvertisementData() {
+ inquiry_rssi_ = base::nullopt;
device_uuids_.ClearAdvertisedUUIDs();
service_data_.clear();
+ inquiry_tx_power_ = base::nullopt;
GetAdapter()->NotifyDeviceChanged(this);
}
@@ -457,4 +478,15 @@ void BluetoothDevice::UpdateTimestamp() {
last_update_time_ = base::Time::NowFromSystemTime();
}
+// static
+int8_t BluetoothDevice::ClampPower(int power) {
+ if (power < INT8_MIN) {
+ return INT8_MIN;
+ }
+ if (power > INT8_MAX) {
+ return INT8_MAX;
+ }
+ return static_cast<int8_t>(power);
+}
+
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698