mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Format all the files in CL786733783
PiperOrigin-RevId: 786873870
This commit is contained in:
@@ -65,8 +65,7 @@ bool BleServerSocket::Connect(BleSocket& socket) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (closed_) return false;
|
||||
if (socket.IsConnected()) {
|
||||
LOG(ERROR)
|
||||
<< "Failed to connect to Ble server socket: already connected";
|
||||
LOG(ERROR) << "Failed to connect to Ble server socket: already connected";
|
||||
return true; // already connected.
|
||||
}
|
||||
// add client socket to the pending list
|
||||
@@ -128,7 +127,7 @@ BleMedium::~BleMedium() {
|
||||
|
||||
accept_loops_runner_.Shutdown();
|
||||
LOG(INFO) << "BleMedium dtor advertising_accept_thread_running_ = "
|
||||
<< acceptance_thread_running_.load();
|
||||
<< acceptance_thread_running_.load();
|
||||
// If acceptance thread is still running, wait to finish.
|
||||
if (acceptance_thread_running_) {
|
||||
while (acceptance_thread_running_) {
|
||||
@@ -143,11 +142,11 @@ bool BleMedium::StartAdvertising(
|
||||
const std::string& service_id, const ByteArray& advertisement_bytes,
|
||||
const std::string& fast_advertisement_service_uuid) {
|
||||
LOG(INFO) << "G3 Ble StartAdvertising: service_id=" << service_id
|
||||
<< ", advertisement bytes="
|
||||
<< absl::BytesToHexString(std::string(advertisement_bytes))
|
||||
<< "(" << advertisement_bytes.size() << "),"
|
||||
<< ", fast advertisement service uuid="
|
||||
<< absl::BytesToHexString(fast_advertisement_service_uuid);
|
||||
<< ", advertisement bytes="
|
||||
<< absl::BytesToHexString(std::string(advertisement_bytes)) << "("
|
||||
<< advertisement_bytes.size() << "),"
|
||||
<< ", fast advertisement service uuid="
|
||||
<< absl::BytesToHexString(fast_advertisement_service_uuid);
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
auto& peripheral = adapter_->GetPeripheral();
|
||||
peripheral.SetAdvertisementBytes(service_id, advertisement_bytes);
|
||||
@@ -181,7 +180,7 @@ bool BleMedium::StopAdvertising(const std::string& service_id) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (advertising_info_.Empty()) {
|
||||
LOG(INFO) << "G3 Ble StopAdvertising: Can't stop advertising "
|
||||
"because we never started advertising.";
|
||||
"because we never started advertising.";
|
||||
return false;
|
||||
}
|
||||
advertising_info_.Clear();
|
||||
@@ -194,8 +193,8 @@ bool BleMedium::StopAdvertising(const std::string& service_id) {
|
||||
accept_loops_runner_.Shutdown();
|
||||
if (server_socket_ == nullptr) {
|
||||
LOG(ERROR) << "G3 Ble StopAdvertising: Failed to find Ble Server "
|
||||
"socket: service_id="
|
||||
<< service_id;
|
||||
"socket: service_id="
|
||||
<< service_id;
|
||||
// Fall through for server socket not found.
|
||||
return true;
|
||||
}
|
||||
@@ -231,7 +230,7 @@ bool BleMedium::StopScanning(const std::string& service_id) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (scanning_info_.Empty()) {
|
||||
LOG(INFO) << "G3 Ble StopDiscovery: Can't stop scanning because "
|
||||
"we never started scanning.";
|
||||
"we never started scanning.";
|
||||
return false;
|
||||
}
|
||||
scanning_info_.Clear();
|
||||
@@ -244,8 +243,7 @@ bool BleMedium::StopScanning(const std::string& service_id) {
|
||||
|
||||
bool BleMedium::StartAcceptingConnections(const std::string& service_id,
|
||||
AcceptedConnectionCallback callback) {
|
||||
LOG(INFO) << "G3 Ble StartAcceptingConnections: service_id="
|
||||
<< service_id;
|
||||
LOG(INFO) << "G3 Ble StartAcceptingConnections: service_id=" << service_id;
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateBleMediumForAcceptedConnection(*this, service_id,
|
||||
std::move(callback));
|
||||
@@ -253,8 +251,7 @@ bool BleMedium::StartAcceptingConnections(const std::string& service_id,
|
||||
}
|
||||
|
||||
bool BleMedium::StopAcceptingConnections(const std::string& service_id) {
|
||||
LOG(INFO) << "G3 Ble StopAcceptingConnections: service_id="
|
||||
<< service_id;
|
||||
LOG(INFO) << "G3 Ble StopAcceptingConnections: service_id=" << service_id;
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateBleMediumForAcceptedConnection(*this, service_id, {});
|
||||
return true;
|
||||
@@ -264,9 +261,9 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
api::BlePeripheral& remote_peripheral, const std::string& service_id,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
LOG(INFO) << "G3 Ble Connect [self]: medium=" << this
|
||||
<< ", adapter=" << &GetAdapter()
|
||||
<< ", peripheral=" << &GetAdapter().GetPeripheral()
|
||||
<< ", service_id=" << service_id;
|
||||
<< ", adapter=" << &GetAdapter()
|
||||
<< ", peripheral=" << &GetAdapter().GetPeripheral()
|
||||
<< ", service_id=" << service_id;
|
||||
// First, find an instance of remote medium, that exposed this peripheral.
|
||||
auto& adapter = static_cast<BlePeripheral&>(remote_peripheral).GetAdapter();
|
||||
auto* medium = static_cast<BleMedium*>(adapter.GetBleMedium());
|
||||
@@ -275,9 +272,8 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
|
||||
BleServerSocket* remote_server_socket = nullptr;
|
||||
LOG(INFO) << "G3 Ble Connect [peer]: medium=" << medium
|
||||
<< ", adapter=" << &adapter
|
||||
<< ", peripheral=" << &remote_peripheral
|
||||
<< ", service_id=" << service_id;
|
||||
<< ", adapter=" << &adapter << ", peripheral=" << &remote_peripheral
|
||||
<< ", service_id=" << service_id;
|
||||
// Then, find our server socket context in this medium.
|
||||
{
|
||||
absl::MutexLock medium_lock(&medium->mutex_);
|
||||
@@ -292,8 +288,8 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
LOG(ERROR) << "G3 BLE Connect: Has been cancelled: "
|
||||
"service_id="
|
||||
<< service_id;
|
||||
"service_id="
|
||||
<< service_id;
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -307,8 +303,8 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
// Finally, Request to connect to this socket.
|
||||
if (!remote_server_socket->Connect(*socket)) {
|
||||
LOG(ERROR) << "G3 Ble Connect: Failed to connect to existing Ble "
|
||||
"Server socket: service_id="
|
||||
<< service_id;
|
||||
"Server socket: service_id="
|
||||
<< service_id;
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -65,8 +65,7 @@ bool BluetoothServerSocket::Connect(BluetoothSocket& socket) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (closed_) return false;
|
||||
if (socket.IsConnected()) {
|
||||
LOG(ERROR)
|
||||
<< "Failed to connect to BT server socket: already connected";
|
||||
LOG(ERROR) << "Failed to connect to BT server socket: already connected";
|
||||
return true; // already connected.
|
||||
}
|
||||
// add client socket to the pending list
|
||||
@@ -172,8 +171,8 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
|
||||
api::BluetoothDevice& remote_device, const std::string& service_uuid,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
LOG(INFO) << "G3 ConnectToService [self]: medium=" << this
|
||||
<< ", adapter=" << &GetAdapter()
|
||||
<< ", device=" << &GetAdapter().GetDevice();
|
||||
<< ", adapter=" << &GetAdapter()
|
||||
<< ", device=" << &GetAdapter().GetDevice();
|
||||
// First, find an instance of remote medium, that exposed this device.
|
||||
auto& adapter = static_cast<BluetoothDevice&>(remote_device).GetAdapter();
|
||||
auto* medium =
|
||||
@@ -183,24 +182,23 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
|
||||
|
||||
BluetoothServerSocket* server_socket = nullptr;
|
||||
LOG(INFO) << "G3 ConnectToService [peer]: medium=" << medium
|
||||
<< ", adapter=" << &adapter << ", device=" << &remote_device
|
||||
<< ", uuid=" << service_uuid.c_str();
|
||||
<< ", adapter=" << &adapter << ", device=" << &remote_device
|
||||
<< ", uuid=" << service_uuid;
|
||||
// Then, find our server socket context in this medium.
|
||||
{
|
||||
absl::MutexLock medium_lock(&medium->mutex_);
|
||||
auto item = medium->sockets_.find(service_uuid);
|
||||
server_socket = item != medium->sockets_.end() ? item->second : nullptr;
|
||||
if (server_socket == nullptr) {
|
||||
LOG(ERROR) << "Failed to find BT Server socket: uuid="
|
||||
<< service_uuid;
|
||||
LOG(ERROR) << "Failed to find BT Server socket: uuid=" << service_uuid;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
LOG(ERROR) << "G3 Bluetooth Connect: Has been cancelled: "
|
||||
"service_uuid="
|
||||
<< service_uuid;
|
||||
"service_uuid="
|
||||
<< service_uuid;
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -212,23 +210,20 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
|
||||
auto socket = std::make_unique<BluetoothSocket>(&GetAdapter());
|
||||
// Finally, Request to connect to this socket.
|
||||
if (!server_socket->Connect(*socket)) {
|
||||
LOG(ERROR)
|
||||
<< "Failed to connect to existing BT Server socket: uuid="
|
||||
<< service_uuid;
|
||||
LOG(ERROR) << "Failed to connect to existing BT Server socket: uuid="
|
||||
<< service_uuid;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
LOG(ERROR)
|
||||
<< "G3 Bluetooth Connect: Has been cancelled after connected: "
|
||||
"service_uuid="
|
||||
<< service_uuid;
|
||||
LOG(ERROR) << "G3 Bluetooth Connect: Has been cancelled after connected: "
|
||||
"service_uuid="
|
||||
<< service_uuid;
|
||||
socket->Close();
|
||||
return {};
|
||||
}
|
||||
|
||||
LOG(INFO) << "G3 ConnectToService: connected: socket="
|
||||
<< socket.get();
|
||||
LOG(INFO) << "G3 ConnectToService: connected: socket=" << socket.get();
|
||||
return socket;
|
||||
}
|
||||
|
||||
@@ -240,8 +235,7 @@ BluetoothClassicMedium::ListenForService(const std::string& service_name,
|
||||
absl::MutexLock lock(&mutex_);
|
||||
sockets_.erase(uuid);
|
||||
});
|
||||
LOG(INFO) << "Adding service: medium=" << this
|
||||
<< ", uuid=" << service_uuid;
|
||||
LOG(INFO) << "Adding service: medium=" << this << ", uuid=" << service_uuid;
|
||||
absl::MutexLock lock(&mutex_);
|
||||
sockets_.emplace(service_uuid, socket.get());
|
||||
return socket;
|
||||
|
||||
@@ -64,24 +64,20 @@ void CredentialStorageImpl::SaveCredentials(
|
||||
}
|
||||
if (private_credentials.empty()) {
|
||||
LOG(INFO) << "There are no Private Credentials for account: ["
|
||||
<< account_name << "], manager app ID:[" << manager_app_id
|
||||
<< "]";
|
||||
<< account_name << "], manager app ID:[" << manager_app_id << "]";
|
||||
} else {
|
||||
LOG(INFO) << "G3 Save Private Credentials for account: ["
|
||||
<< account_name << "], manager app ID:[" << manager_app_id
|
||||
<< "]";
|
||||
LOG(INFO) << "G3 Save Private Credentials for account: [" << account_name
|
||||
<< "], manager app ID:[" << manager_app_id << "]";
|
||||
SaveLocalCredentialsLocked(manager_app_id, account_name,
|
||||
private_credentials);
|
||||
}
|
||||
|
||||
if (public_credentials.empty()) {
|
||||
LOG(INFO) << "There are no Public Credentials for account: ["
|
||||
<< account_name << "], manager app ID:[" << manager_app_id
|
||||
<< "]";
|
||||
<< account_name << "], manager app ID:[" << manager_app_id << "]";
|
||||
} else {
|
||||
LOG(INFO) << "G3 Save Public Credentials for account: ["
|
||||
<< account_name << "], manager app ID:[" << manager_app_id
|
||||
<< "]";
|
||||
LOG(INFO) << "G3 Save Public Credentials for account: [" << account_name
|
||||
<< "], manager app ID:[" << manager_app_id << "]";
|
||||
PublicCredentialKey key = CreatePublicCredentialKey(
|
||||
manager_app_id, account_name, public_credential_type);
|
||||
auto public_result =
|
||||
@@ -111,9 +107,8 @@ void CredentialStorageImpl::SaveLocalCredentialsLocked(
|
||||
void CredentialStorageImpl::UpdateLocalCredential(
|
||||
absl::string_view manager_app_id, absl::string_view account_name,
|
||||
LocalCredential credential, SaveCredentialsResultCallback callback) {
|
||||
LOG(INFO) << "G3 Update Private Credential for for account: ["
|
||||
<< account_name << "], manager app ID:[" << manager_app_id
|
||||
<< "]";
|
||||
LOG(INFO) << "G3 Update Private Credential for for account: [" << account_name
|
||||
<< "], manager app ID:[" << manager_app_id << "]";
|
||||
absl::StatusOr<std::vector<LocalCredential>> credentials =
|
||||
GetLocalCredentialsLocked(CredentialSelector{
|
||||
.manager_app_id = std::string(manager_app_id),
|
||||
@@ -150,7 +145,7 @@ CredentialStorageImpl::GetLocalCredentialsLocked(
|
||||
credential_selector.manager_app_id, credential_selector.account_name);
|
||||
if (private_credentials_map_.find(key) == private_credentials_map_.end()) {
|
||||
LOG(WARNING) << "There are no Private Credentials stored for key:"
|
||||
<< std::get<0>(key) << ", " << std::get<1>(key);
|
||||
<< std::get<0>(key) << ", " << std::get<1>(key);
|
||||
return absl::NotFoundError(
|
||||
absl::StrFormat("No private credentials for %v", credential_selector));
|
||||
}
|
||||
@@ -174,8 +169,8 @@ void CredentialStorageImpl::GetPublicCredentials(
|
||||
public_credential_type);
|
||||
if (public_credentials_map_.find(key) == public_credentials_map_.end()) {
|
||||
LOG(WARNING) << "There are no Public Credentials stored for key:"
|
||||
<< std::get<0>(key) << ", " << std::get<1>(key) << ", "
|
||||
<< std::get<2>(key);
|
||||
<< std::get<0>(key) << ", " << std::get<1>(key) << ", "
|
||||
<< std::get<2>(key);
|
||||
std::move(callback.credentials_fetched_cb)(absl::NotFoundError(
|
||||
absl::StrFormat("No public credentials for %v", credential_selector)));
|
||||
return;
|
||||
|
||||
@@ -131,7 +131,7 @@ bool WifiDirectMedium::StartWifiDirect(
|
||||
wifi_direct_credentials->SetPassword(password);
|
||||
|
||||
LOG(INFO) << "G3 StartWifiDirect GO: ssid=" << ssid
|
||||
<< ", password:" << password;
|
||||
<< ", password:" << password;
|
||||
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateWifiDirectMediumForStartOrConnect(*this, wifi_direct_credentials,
|
||||
@@ -156,8 +156,8 @@ bool WifiDirectMedium::ConnectWifiDirect(
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
LOG(INFO) << "G3 ConnectWifiDirect : ssid="
|
||||
<< wifi_direct_credentials->GetSSID()
|
||||
<< ", password:" << wifi_direct_credentials->GetPassword();
|
||||
<< wifi_direct_credentials->GetSSID()
|
||||
<< ", password:" << wifi_direct_credentials->GetPassword();
|
||||
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
auto* remote_medium = static_cast<WifiDirectMedium*>(
|
||||
@@ -192,7 +192,7 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
|
||||
CancellationFlag* cancellation_flag) {
|
||||
std::string socket_name = WifiDirectServerSocket::GetName(ip_address, port);
|
||||
LOG(INFO) << "G3 WifiDirect ConnectToService [self]: medium=" << this
|
||||
<< ", ip address + port=" << socket_name;
|
||||
<< ", ip address + port=" << socket_name;
|
||||
// First, find an instance of remote medium, that exposed this service.
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
auto* remote_medium =
|
||||
@@ -202,9 +202,8 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
|
||||
}
|
||||
|
||||
WifiDirectServerSocket* server_socket = nullptr;
|
||||
LOG(INFO) << "G3 WifiDirect ConnectToService [peer]: medium="
|
||||
<< remote_medium
|
||||
<< ", remote ip address + port=" << socket_name;
|
||||
LOG(INFO) << "G3 WifiDirect ConnectToService [peer]: medium=" << remote_medium
|
||||
<< ", remote ip address + port=" << socket_name;
|
||||
// Then, find our server socket context in this medium.
|
||||
{
|
||||
absl::MutexLock medium_lock(&remote_medium->mutex_);
|
||||
@@ -213,16 +212,15 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
|
||||
item != remote_medium->server_sockets_.end() ? item->second : nullptr;
|
||||
if (server_socket == nullptr) {
|
||||
LOG(ERROR) << "G3 WifiDirect Failed to find WifiDirect Server "
|
||||
"socket: socket_name="
|
||||
<< socket_name;
|
||||
"socket: socket_name="
|
||||
<< socket_name;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
LOG(ERROR)
|
||||
<< "G3 WifiDirect Connect: Has been cancelled: socket_name="
|
||||
<< socket_name;
|
||||
LOG(ERROR) << "G3 WifiDirect Connect: Has been cancelled: socket_name="
|
||||
<< socket_name;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -231,7 +229,7 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
|
||||
|
||||
server_socket->Connect(*socket);
|
||||
LOG(INFO) << "G3 WifiDirect GC ConnectToService: connected: socket="
|
||||
<< socket.get();
|
||||
<< socket.get();
|
||||
return socket;
|
||||
}
|
||||
|
||||
@@ -257,7 +255,7 @@ std::unique_ptr<api::WifiDirectServerSocket> WifiDirectMedium::ListenForService(
|
||||
server_sockets_.erase(socket_name);
|
||||
});
|
||||
LOG(INFO) << "G3 WifiDirect GO Adding server socket: medium=" << this
|
||||
<< ", socket_name=" << socket_name;
|
||||
<< ", socket_name=" << socket_name;
|
||||
absl::MutexLock lock(&mutex_);
|
||||
server_sockets_.insert({socket_name, server_socket.get()});
|
||||
return server_socket;
|
||||
|
||||
@@ -134,7 +134,7 @@ bool WifiHotspotMedium::StartWifiHotspot(
|
||||
hotspot_credentials->SetPassword(password);
|
||||
|
||||
LOG(INFO) << "G3 StartWifiHotspot: ssid=" << ssid
|
||||
<< ", password:" << password;
|
||||
<< ", password:" << password;
|
||||
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateWifiHotspotMediumForStartOrConnect(*this, hotspot_credentials,
|
||||
@@ -161,9 +161,8 @@ bool WifiHotspotMedium::ConnectWifiHotspot(
|
||||
HotspotCredentials* hotspot_credentials) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
LOG(INFO) << "G3 ConnectWifiHotspot: ssid="
|
||||
<< hotspot_credentials->GetSSID()
|
||||
<< ", password:" << hotspot_credentials->GetPassword();
|
||||
LOG(INFO) << "G3 ConnectWifiHotspot: ssid=" << hotspot_credentials->GetSSID()
|
||||
<< ", password:" << hotspot_credentials->GetPassword();
|
||||
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
auto* remote_medium = static_cast<WifiHotspotMedium*>(
|
||||
@@ -198,7 +197,7 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
|
||||
CancellationFlag* cancellation_flag) {
|
||||
std::string socket_name = WifiHotspotServerSocket::GetName(ip_address, port);
|
||||
LOG(INFO) << "G3 WifiHotspot ConnectToService [self]: medium=" << this
|
||||
<< ", ip address + port=" << socket_name;
|
||||
<< ", ip address + port=" << socket_name;
|
||||
// First, find an instance of remote medium, that exposed this service.
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
auto* remote_medium =
|
||||
@@ -209,8 +208,7 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
|
||||
|
||||
WifiHotspotServerSocket* server_socket = nullptr;
|
||||
LOG(INFO) << "G3 WifiHotspot ConnectToService [peer]: medium="
|
||||
<< remote_medium
|
||||
<< ", remote ip address + port=" << socket_name;
|
||||
<< remote_medium << ", remote ip address + port=" << socket_name;
|
||||
// Then, find our server socket context in this medium.
|
||||
{
|
||||
absl::MutexLock medium_lock(&remote_medium->mutex_);
|
||||
@@ -219,16 +217,15 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
|
||||
item != remote_medium->server_sockets_.end() ? item->second : nullptr;
|
||||
if (server_socket == nullptr) {
|
||||
LOG(ERROR) << "G3 WifiHotspot Failed to find WifiHotspot Server "
|
||||
"socket: socket_name="
|
||||
<< socket_name;
|
||||
"socket: socket_name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
LOG(ERROR)
|
||||
<< "G3 WifiHotspot Connect: Has been cancelled: socket_name="
|
||||
<< socket_name;
|
||||
LOG(ERROR) << "G3 WifiHotspot Connect: Has been cancelled: socket_name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -242,14 +239,13 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
|
||||
auto socket = std::make_unique<WifiHotspotSocket>();
|
||||
// Finally, Request to connect to this socket.
|
||||
if (!server_socket->Connect(*socket)) {
|
||||
LOG(ERROR)
|
||||
<< "G3 WifiHotspot Failed to connect to existing WifiHotspot "
|
||||
"Server socket: name="
|
||||
<< socket_name;
|
||||
LOG(ERROR) << "G3 WifiHotspot Failed to connect to existing WifiHotspot "
|
||||
"Server socket: name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
}
|
||||
LOG(INFO) << "G3 WifiHotspot ConnectToService: connected: socket="
|
||||
<< socket.get();
|
||||
<< socket.get();
|
||||
return socket;
|
||||
}
|
||||
|
||||
@@ -276,7 +272,7 @@ WifiHotspotMedium::ListenForService(int port) {
|
||||
server_sockets_.erase(socket_name);
|
||||
});
|
||||
LOG(INFO) << "G3 WifiHotspot Adding server socket: medium=" << this
|
||||
<< ", socket_name=" << socket_name;
|
||||
<< ", socket_name=" << socket_name;
|
||||
absl::MutexLock lock(&mutex_);
|
||||
server_sockets_.insert({socket_name, server_socket.get()});
|
||||
return server_socket;
|
||||
|
||||
@@ -130,9 +130,9 @@ WifiLanMedium::~WifiLanMedium() {
|
||||
bool WifiLanMedium::StartAdvertising(const NsdServiceInfo& nsd_service_info) {
|
||||
std::string service_type = nsd_service_info.GetServiceType();
|
||||
LOG(INFO) << "G3 WifiLan StartAdvertising: nsd_service_info="
|
||||
<< &nsd_service_info
|
||||
<< ", service_name=" << nsd_service_info.GetServiceName()
|
||||
<< ", service_type=" << service_type;
|
||||
<< &nsd_service_info
|
||||
<< ", service_name=" << nsd_service_info.GetServiceName()
|
||||
<< ", service_type=" << service_type;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (advertising_info_.Existed(service_type)) {
|
||||
@@ -156,16 +156,15 @@ bool WifiLanMedium::StartAdvertising(const NsdServiceInfo& nsd_service_info) {
|
||||
bool WifiLanMedium::StopAdvertising(const NsdServiceInfo& nsd_service_info) {
|
||||
std::string service_type = nsd_service_info.GetServiceType();
|
||||
LOG(INFO) << "G3 WifiLan StopAdvertising: nsd_service_info="
|
||||
<< &nsd_service_info
|
||||
<< ", service_name=" << nsd_service_info.GetServiceName()
|
||||
<< ", service_type=" << service_type;
|
||||
<< &nsd_service_info
|
||||
<< ", service_name=" << nsd_service_info.GetServiceName()
|
||||
<< ", service_type=" << service_type;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (!advertising_info_.Existed(service_type)) {
|
||||
LOG(INFO)
|
||||
<< "G3 WifiLan StopAdvertising: Can't stop advertising because "
|
||||
"we never started advertising for service_type="
|
||||
<< service_type;
|
||||
LOG(INFO) << "G3 WifiLan StopAdvertising: Can't stop advertising because "
|
||||
"we never started advertising for service_type="
|
||||
<< service_type;
|
||||
return false;
|
||||
}
|
||||
advertising_info_.Remove(service_type);
|
||||
@@ -178,15 +177,13 @@ bool WifiLanMedium::StopAdvertising(const NsdServiceInfo& nsd_service_info) {
|
||||
|
||||
bool WifiLanMedium::StartDiscovery(const std::string& service_type,
|
||||
DiscoveredServiceCallback callback) {
|
||||
LOG(INFO) << "G3 WifiLan StartDiscovery: service_type="
|
||||
<< service_type;
|
||||
LOG(INFO) << "G3 WifiLan StartDiscovery: service_type=" << service_type;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (discovering_info_.Existed(service_type)) {
|
||||
LOG(INFO)
|
||||
<< "G3 WifiLan StartDiscovery: Can't start discovery because "
|
||||
"service_type="
|
||||
<< service_type << " has started already.";
|
||||
LOG(INFO) << "G3 WifiLan StartDiscovery: Can't start discovery because "
|
||||
"service_type="
|
||||
<< service_type << " has started already.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -201,8 +198,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_type,
|
||||
}
|
||||
|
||||
bool WifiLanMedium::StopDiscovery(const std::string& service_type) {
|
||||
LOG(INFO) << "G3 WifiLan StopDiscovery: service_type="
|
||||
<< service_type;
|
||||
LOG(INFO) << "G3 WifiLan StopDiscovery: service_type=" << service_type;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (!discovering_info_.Existed(service_type)) {
|
||||
@@ -223,7 +219,7 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
CancellationFlag* cancellation_flag) {
|
||||
std::string service_type = remote_service_info.GetServiceType();
|
||||
LOG(INFO) << "G3 WifiLan ConnectToService [self]: medium=" << this
|
||||
<< ", service_type=" << service_type;
|
||||
<< ", service_type=" << service_type;
|
||||
return ConnectToService(remote_service_info.GetIPAddress(),
|
||||
remote_service_info.GetPort(), cancellation_flag);
|
||||
}
|
||||
@@ -233,7 +229,7 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
CancellationFlag* cancellation_flag) {
|
||||
std::string socket_name = WifiLanServerSocket::GetName(ip_address, port);
|
||||
LOG(INFO) << "G3 WifiLan ConnectToService [self]: medium=" << this
|
||||
<< ", ip address + port=" << socket_name;
|
||||
<< ", ip address + port=" << socket_name;
|
||||
// First, find an instance of remote medium, that exposed this service.
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
auto* remote_medium =
|
||||
@@ -243,9 +239,8 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
}
|
||||
|
||||
WifiLanServerSocket* server_socket = nullptr;
|
||||
LOG(INFO) << "G3 WifiLan ConnectToService [peer]: medium="
|
||||
<< remote_medium
|
||||
<< ", remote ip address + port=" << socket_name;
|
||||
LOG(INFO) << "G3 WifiLan ConnectToService [peer]: medium=" << remote_medium
|
||||
<< ", remote ip address + port=" << socket_name;
|
||||
// Then, find our server socket context in this medium.
|
||||
{
|
||||
absl::MutexLock medium_lock(&remote_medium->mutex_);
|
||||
@@ -262,7 +257,7 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
LOG(ERROR) << "G3 WifiLan Connect: Has been cancelled: socket_name="
|
||||
<< socket_name;
|
||||
<< socket_name;
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -277,12 +272,12 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
// Finally, Request to connect to this socket.
|
||||
if (!server_socket->Connect(*socket)) {
|
||||
LOG(ERROR) << "G3 WifiLan Failed to connect to existing WifiLan "
|
||||
"Server socket: name="
|
||||
<< socket_name;
|
||||
"Server socket: name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
}
|
||||
LOG(INFO) << "G3 WifiLan ConnectToService: connected: socket="
|
||||
<< socket.get();
|
||||
<< socket.get();
|
||||
return socket;
|
||||
}
|
||||
|
||||
@@ -299,7 +294,7 @@ std::unique_ptr<api::WifiLanServerSocket> WifiLanMedium::ListenForService(
|
||||
server_sockets_.erase(socket_name);
|
||||
});
|
||||
LOG(INFO) << "G3 WifiLan Adding server socket: medium=" << this
|
||||
<< ", socket_name=" << socket_name;
|
||||
<< ", socket_name=" << socket_name;
|
||||
absl::MutexLock lock(&mutex_);
|
||||
server_sockets_.insert({socket_name, server_socket.get()});
|
||||
return server_socket;
|
||||
|
||||
@@ -123,7 +123,7 @@ bool WifiLanMdns::StartMdnsService(
|
||||
|
||||
if (status != DNS_REQUEST_PENDING) {
|
||||
LOG(ERROR) << "Failed to start mDNS advertising for service type ="
|
||||
<< service_type;
|
||||
<< service_type;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user