Internal change

PiperOrigin-RevId: 364353126
This commit is contained in:
hai007
2021-03-22 10:38:20 -07:00
committed by Copybara-Service
parent c648983d52
commit ae283c7cb6
14 changed files with 277 additions and 43 deletions
@@ -18,6 +18,7 @@
#include <string>
#include "platform/api/bluetooth_classic.h"
#include "platform/base/cancellation_flag_listener.h"
#include "platform/base/logging.h"
#include "platform/base/medium_environment.h"
#include "platform/impl/g3/bluetooth_adapter.h"
@@ -234,6 +235,11 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
return {};
}
CancellationFlagListener listener(cancellation_flag, [&server_socket]() {
NEARBY_LOGS(INFO) << "G3 Bluetooth Cancel Connect.";
if (server_socket != nullptr) server_socket->Close();
});
auto socket = std::make_unique<BluetoothSocket>(&GetAdapter());
// Finally, Request to connect to this socket.
if (!server_socket->Connect(*socket)) {