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)); |