mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Merge pull request #34 from hai007/cl-353971958
Roll forward up to Cl/353971958.
This commit is contained in:
@@ -153,15 +153,21 @@ void ClientProxy::OnEndpointFound(const std::string& service_id,
|
||||
endpoint_id.c_str(), service_id.c_str(),
|
||||
absl::BytesToHexString(endpoint_info.data()).c_str());
|
||||
if (!IsDiscoveringServiceId(service_id)) {
|
||||
NEARBY_LOG(INFO, "ClientProxy [Endpoint Found]: [no discovery] id=%s",
|
||||
NEARBY_LOG(INFO,
|
||||
"ClientProxy [Endpoint Found]: Ignoring event for id=%s because "
|
||||
"this client is not discovering",
|
||||
endpoint_id.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (discovered_endpoint_ids_.count(endpoint_id)) {
|
||||
NEARBY_LOG(INFO, "ClientProxy [Endpoint Found]: [duplicate] id=%s",
|
||||
NEARBY_LOG(WARNING,
|
||||
"ClientProxy [Endpoint Found]: Ignoring event for id=%s because "
|
||||
"this client already reported this endpoint as found",
|
||||
endpoint_id.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
discovered_endpoint_ids_.insert(endpoint_id);
|
||||
discovery_info_.listener.endpoint_found_cb(endpoint_id, endpoint_info,
|
||||
service_id);
|
||||
@@ -171,9 +177,25 @@ void ClientProxy::OnEndpointLost(const std::string& service_id,
|
||||
const std::string& endpoint_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (!IsDiscoveringServiceId(service_id)) return;
|
||||
NEARBY_LOG(INFO, "ClientProxy [Endpoint Lost]: [enter] id=%s; service=%s",
|
||||
endpoint_id.c_str(), service_id.c_str());
|
||||
if (!IsDiscoveringServiceId(service_id)) {
|
||||
NEARBY_LOG(INFO,
|
||||
"ClientProxy [Endpoint Lost]: Ignoring event for id=%s because "
|
||||
"this client is not discovering",
|
||||
endpoint_id.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
const auto it = discovered_endpoint_ids_.find(endpoint_id);
|
||||
if (it == discovered_endpoint_ids_.end()) return;
|
||||
if (it == discovered_endpoint_ids_.end()) {
|
||||
NEARBY_LOG(WARNING,
|
||||
"ClientProxy [Endpoint Lost]: Ignoring event for id=%s because "
|
||||
"this client has not yet reported this endpoint as found",
|
||||
endpoint_id.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
discovered_endpoint_ids_.erase(it);
|
||||
discovery_info_.listener.endpoint_lost_cb(endpoint_id);
|
||||
}
|
||||
|
||||
@@ -186,6 +186,12 @@ bool Ble::StartScanning(const std::string& service_id,
|
||||
const std::string& service_id,
|
||||
const ByteArray& medium_advertisement_bytes,
|
||||
bool fast_advertisement) {
|
||||
// Don't bother trying to parse zero byte advertisements.
|
||||
if (medium_advertisement_bytes.size() == 0) {
|
||||
NEARBY_LOGS(INFO) << "Skipping zero byte advertisement "
|
||||
<< "with service_id: " << service_id;
|
||||
return;
|
||||
}
|
||||
// Unwrap connection BleAdvertisement from medium
|
||||
// BleAdvertisement.
|
||||
auto connection_advertisement_bytes =
|
||||
|
||||
@@ -17,6 +17,8 @@ syntax = "proto2";
|
||||
package location.nearby.proto;
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
option (logs_proto.file_not_used_for_logging_except_enums) = true;
|
||||
option java_api_version = 2;
|
||||
option java_package = "com.google.location.nearby.proto";
|
||||
option java_outer_classname = "BootstrapEnums";
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ syntax = "proto2";
|
||||
package location.nearby.proto;
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
option (logs_proto.file_not_used_for_logging_except_enums) = true;
|
||||
option java_api_version = 2;
|
||||
option java_package = "com.google.location.nearby.proto";
|
||||
option java_outer_classname = "MagicPairEnums";
|
||||
option objc_class_prefix = "GNCP";
|
||||
|
||||
@@ -17,6 +17,8 @@ syntax = "proto2";
|
||||
package location.nearby.proto;
|
||||
|
||||
option optimize_for = LITE_RUNTIME;
|
||||
option (logs_proto.file_not_used_for_logging_except_enums) = true;
|
||||
option java_api_version = 2;
|
||||
option java_package = "com.google.location.nearby.proto";
|
||||
option java_outer_classname = "NearbyClientEnums";
|
||||
option objc_class_prefix = "GNCP";
|
||||
|
||||
Reference in New Issue
Block a user