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

Unified Diff: device/bluetooth/bluetooth_adapter_android.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: Clean up 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_adapter_android.cc
diff --git a/device/bluetooth/bluetooth_adapter_android.cc b/device/bluetooth/bluetooth_adapter_android.cc
index 5905d49d41f19a3d63cced7de8fcb6bb577a7636..e36a81a76d1912f3ce637854ae7c2aa65d55bf58 100644
--- a/device/bluetooth/bluetooth_adapter_android.cc
+++ b/device/bluetooth/bluetooth_adapter_android.cc
@@ -184,8 +184,9 @@ void BluetoothAdapterAndroid::CreateOrUpdateDeviceOnScan(
const JavaParamRef<jstring>& address,
const JavaParamRef<jobject>&
bluetooth_device_wrapper, // Java Type: bluetoothDeviceWrapper
- const JavaParamRef<jobjectArray>&
- advertised_uuids) { // Java Type: String[]
+ int32_t rssi,
+ const JavaParamRef<jobjectArray>& advertised_uuids, // Java Type: String[]
+ int32_t tx_power) {
std::string device_address = ConvertJavaStringToUTF8(env, address);
DevicesMap::const_iterator iter = devices_.find(device_address);
@@ -207,14 +208,21 @@ void BluetoothAdapterAndroid::CreateOrUpdateDeviceOnScan(
std::vector<std::string> advertised_uuids_strings;
AppendJavaStringArrayToStringVector(env, advertised_uuids,
&advertised_uuids_strings);
-
BluetoothDevice::UUIDList advertised_bluetooth_uuids;
for (std::string& uuid : advertised_uuids_strings) {
advertised_bluetooth_uuids.push_back(BluetoothUUID(std::move(uuid)));
}
- device_android->UpdateAdvertisementData(std::move(advertised_bluetooth_uuids),
- {} /* service_data */);
+ // Android uses INT32_MIN to indicate no Advertised Tx Power.
Jeffrey Yasskin 2016/08/24 04:32:02 Link to https://developer.android.com/reference/an
ortuno 2016/08/24 21:29:09 Done.
+ base::Optional<int8_t> clamped_tx_power =
+ tx_power == INT32_MIN
+ ? base::nullopt
+ : base::make_optional<int8_t>(BluetoothDevice::ClampPower(tx_power));
+
+ device_android->UpdateAdvertisementData(
+ BluetoothDevice::ClampPower(rssi), std::move(advertised_bluetooth_uuids),
+ {} /* service_data */,
+ clamped_tx_power ? &clamped_tx_power.value() : nullptr);
Jeffrey Yasskin 2016/08/24 04:32:02 Should UpdateAdvertisementData take an optional, i
ortuno 2016/08/24 21:29:09 Hmmm I thought about passing an optional but base:
Jeffrey Yasskin 2016/08/24 22:32:07 As discussed over IM, it probably makes sense to s
ortuno 2016/08/25 16:42:34 Done.
if (is_new_device) {
devices_.add(device_address, std::move(device_android_owner));

Powered by Google App Engine
This is Rietveld 408576698