Commit 55c175f0 authored by Jie Jiang's avatar Jie Jiang Committed by Commit Bot

arc: bluetooth: Fix reading RSSI for connected devices

Android use ReadRemoteRssi() to get the RSSI value for a connection.
Currently we are using GetInquiryRSSI(), which cannot get the correct
RSSI value for a connected device, and makes some Android apps unhappy.
This change uses GetConnectionInfo() instead.

BUG=b:147787450
TEST=Manually test with nRF and Fitbit. nRF can read RSSI value
correctly; Firmware update of Fitbit works well now.

Change-Id: I0dc13f58f430954772551165009d5ea7f26445c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2004429
Commit-Queue: Jie Jiang <jiejiang@chromium.org>
Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Reviewed-by: default avatarMiao-chen Chou <mcchou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736219}
parent bcc2327a
...@@ -412,6 +412,12 @@ std::vector<uint8_t> MakeCCCDValue(uint8_t value) { ...@@ -412,6 +412,12 @@ std::vector<uint8_t> MakeCCCDValue(uint8_t value) {
return {value, 0}; return {value, 0};
} }
void SendRssiOnGetConnectionInfoDone(
arc::ArcBluetoothBridge::ReadRemoteRssiCallback callback,
const device::BluetoothDevice::ConnectionInfo& conn_info) {
std::move(callback).Run(conn_info.rssi);
}
} // namespace } // namespace
namespace arc { namespace arc {
...@@ -1756,8 +1762,14 @@ void ArcBluetoothBridge::ReadRemoteRssi(mojom::BluetoothAddressPtr remote_addr, ...@@ -1756,8 +1762,14 @@ void ArcBluetoothBridge::ReadRemoteRssi(mojom::BluetoothAddressPtr remote_addr,
std::move(callback).Run(mojom::kUnknownPower); std::move(callback).Run(mojom::kUnknownPower);
return; return;
} }
std::move(callback).Run(
device->GetInquiryRSSI().value_or(mojom::kUnknownPower)); if (device->IsConnected()) {
device->GetConnectionInfo(base::AdaptCallbackForRepeating(
base::BindOnce(&SendRssiOnGetConnectionInfoDone, std::move(callback))));
} else {
std::move(callback).Run(
device->GetInquiryRSSI().value_or(mojom::kUnknownPower));
}
} }
void ArcBluetoothBridge::OpenBluetoothSocket( void ArcBluetoothBridge::OpenBluetoothSocket(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment