| 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..27909718acdda03933f809f3e0e0053eb76f4832 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,22 @@ 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.
|
| + // https://developer.android.com/reference/android/bluetooth/le/ScanRecord.html#getTxPowerLevel()
|
| + 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);
|
|
|
| if (is_new_device) {
|
| devices_.add(device_address, std::move(device_android_owner));
|
|
|