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

Unified Diff: chromeos/components/tether/ble_connection_manager.cc

Issue 2804123002: BleConnectionManager: Check when receiving BLE advertisements if a SecureChannel already exists. No… (Closed)
Patch Set: khorimoto@ comments. Created 3 years, 8 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: chromeos/components/tether/ble_connection_manager.cc
diff --git a/chromeos/components/tether/ble_connection_manager.cc b/chromeos/components/tether/ble_connection_manager.cc
index b4860790fab1d11a1c24be2a5e6bbc61ff2a2715..745607b3e4c13ca0f8275aa8c6898015dc46a775 100644
--- a/chromeos/components/tether/ble_connection_manager.cc
+++ b/chromeos/components/tether/ble_connection_manager.cc
@@ -101,6 +101,10 @@ void BleConnectionManager::ConnectionMetadata::OnConnectionAttemptTimeout() {
manager_->OnConnectionAttemptTimeout(remote_device_);
}
+bool BleConnectionManager::ConnectionMetadata::HasSecureChannel() {
+ return secure_channel_ != nullptr;
+}
+
void BleConnectionManager::ConnectionMetadata::SetSecureChannel(
std::unique_ptr<cryptauth::SecureChannel> secure_channel) {
DCHECK(!secure_channel_);
@@ -314,7 +318,17 @@ void BleConnectionManager::OnReceivedAdvertisementFromDevice(
// ignore it.
PA_LOG(WARNING) << "Received an advertisement from a device which is not "
<< "registered. Bluetooth address: " << device_address
- << ", Remote Device ID: " << remote_device.GetDeviceId();
+ << ", Remote Device ID: "
+ << remote_device.GetTruncatedDeviceIdForLogs();
+ return;
+ }
+
+ if (connection_metadata->HasSecureChannel()) {
+ PA_LOG(WARNING) << "Received another advertisement from a registered "
+ << "device which is already being actively communicated "
+ << "with. Bluetooth address: " << device_address
+ << ", Remote Device ID: "
+ << remote_device.GetTruncatedDeviceIdForLogs();
return;
}
« no previous file with comments | « chromeos/components/tether/ble_connection_manager.h ('k') | chromeos/components/tether/ble_connection_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698