Enable Bluetooth connection status track

PiperOrigin-RevId: 501334205
This commit is contained in:
Guogang Li
2023-01-11 11:31:27 -08:00
committed by Copybara-Service
parent 5326cec7ab
commit e261be1a16
2 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ class FeatureFlags {
bool enable_connection_timeout = false;
// Controls to enable or disable to track the status of Bluetooth classic
// conncetion.
bool enable_bluetooth_connection_status_track = false;
bool enable_bluetooth_connection_status_track = true;
};
static const FeatureFlags& GetInstance() {
@@ -39,6 +39,8 @@ BluetoothSocket::BluetoothSocket(StreamSocket streamSocket)
if (FeatureFlags::GetInstance()
.GetFlags()
.enable_bluetooth_connection_status_track) {
NEARBY_LOGS(INFO)
<< "Flag enable_bluetooth_connection_status_track is enabled.";
connection_status_changed_token_ =
native_bluetooth_device_.ConnectionStatusChanged(
{this, &BluetoothSocket::Listener_ConnectionStatusChanged});
@@ -143,9 +145,15 @@ bool BluetoothSocket::Connect(HostName connectionHostName,
windows_socket_.Information().RemoteHostName())
.get();
connection_status_changed_token_ =
native_bluetooth_device_.ConnectionStatusChanged(
{this, &BluetoothSocket::Listener_ConnectionStatusChanged});
if (FeatureFlags::GetInstance()
.GetFlags()
.enable_bluetooth_connection_status_track) {
NEARBY_LOGS(INFO)
<< "Flag enable_bluetooth_connection_status_track is enabled.";
connection_status_changed_token_ =
native_bluetooth_device_.ConnectionStatusChanged(
{this, &BluetoothSocket::Listener_ConnectionStatusChanged});
}
bluetooth_device_ =
std::make_unique<BluetoothDevice>(native_bluetooth_device_);