mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
nearby_connections: proto: analytics: sync protos and add unit test for proto ConnectionsLog.
PiperOrigin-RevId: 394164605
This commit is contained in:
committed by
Copybara-Service
parent
fd938a745c
commit
2a629b2c1b
+3
-2
@@ -24,6 +24,7 @@ cc_library(
|
||||
compatible_with = ["//buildenv/target:non_prod"],
|
||||
visibility = [
|
||||
"//core:__subpackages__",
|
||||
"//proto/analytics:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//absl/container:btree",
|
||||
@@ -34,7 +35,7 @@ cc_library(
|
||||
"//platform/public:logging",
|
||||
"//platform/public:types",
|
||||
"//proto:connections_enums_portable_proto",
|
||||
"//third_party/nearby_connections/proto/analytics:connections_log_cc_proto",
|
||||
"//proto/analytics:connections_log_cc_proto",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -53,6 +54,6 @@ cc_test(
|
||||
"//platform/public:logging",
|
||||
"//platform/public:types",
|
||||
"//proto:connections_enums_portable_proto",
|
||||
"//third_party/nearby_connections/proto/analytics:connections_log_cc_proto",
|
||||
"//proto/analytics:connections_log_cc_proto",
|
||||
],
|
||||
)
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ cc_library(
|
||||
"//third_party/nearby_connections/cpp/analytics:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//third_party/nearby_connections/proto/analytics:connections_log_cc_proto",
|
||||
"//proto/analytics:connections_log_cc_proto",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ cc_library(
|
||||
"//core:__subpackages__",
|
||||
"//platform:__subpackages__",
|
||||
"//platform/api:__subpackages__",
|
||||
"//proto/analytics:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//absl/container:flat_hash_map",
|
||||
|
||||
@@ -109,6 +109,7 @@ cc_library(
|
||||
"//third_party/nearby_connections/cpp/analytics:__subpackages__",
|
||||
"//core:__subpackages__",
|
||||
"//platform:__subpackages__",
|
||||
"//proto/analytics:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
":comm",
|
||||
|
||||
@@ -114,6 +114,7 @@ cc_library(
|
||||
"//third_party/nearby_connections/cpp/analytics:__subpackages__",
|
||||
"//core:__subpackages__",
|
||||
"//platform:__subpackages__",
|
||||
"//proto/analytics:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"//platform/base:logging",
|
||||
|
||||
@@ -36,7 +36,8 @@ cc_proto_library(
|
||||
name = "connections_log_cc_proto",
|
||||
compatible_with = ["//buildenv/target:non_prod"],
|
||||
visibility = [
|
||||
"//third_party/nearby_connections:__subpackages__",
|
||||
"//third_party/nearby_connections/cpp/analytics:__subpackages__",
|
||||
"//core:__subpackages__",
|
||||
],
|
||||
deps = [":connections_log_proto"],
|
||||
)
|
||||
|
||||
@@ -83,6 +83,11 @@ message ConnectionsLog {
|
||||
|
||||
// Attempts to upgrade a connection from one medium to another.
|
||||
repeated BandwidthUpgradeAttempt upgrade_attempt = 9;
|
||||
|
||||
// The build version of the user's device (Same value as the Build number in
|
||||
// Settings -> about phone).
|
||||
optional string build_version = 10
|
||||
[(datapol.semantic_type) = ST_SOFTWARE_ID];
|
||||
}
|
||||
|
||||
// Encapsulates activity during a period of discovery.
|
||||
@@ -181,6 +186,9 @@ message ConnectionsLog {
|
||||
|
||||
// The ReceivingEvent flow id.
|
||||
optional int64 client_flow_id = 4 [(datapol.semantic_type) = ST_SESSION_ID];
|
||||
|
||||
// Encapsulates additional advertising information.
|
||||
optional AdvertisingMetadata advertising_metadata = 5;
|
||||
}
|
||||
|
||||
// A request to connect, corresponding to the API's concept of
|
||||
@@ -235,6 +243,9 @@ message ConnectionsLog {
|
||||
// The token used to identify this connection pair.
|
||||
optional string connection_token = 7
|
||||
[(datapol.semantic_type) = ST_SESSION_ID];
|
||||
|
||||
// Encapsulates additional connection information.
|
||||
optional ConnectionAttemptMetadata connection_attempt_metadata = 8;
|
||||
}
|
||||
|
||||
// A successfully-established connection over a particular medium.
|
||||
@@ -353,5 +364,54 @@ message ConnectionsLog {
|
||||
optional string connection_token = 16
|
||||
[(datapol.semantic_type) = ST_SESSION_ID];
|
||||
}
|
||||
|
||||
// Some additional information to keep with the advertising phase.
|
||||
message AdvertisingMetadata {
|
||||
// The bluetooth low energy extended advertisement support status.
|
||||
optional bool supports_extended_ble_advertisements = 1;
|
||||
}
|
||||
|
||||
// Some additional information to keep with the connection attempt.
|
||||
message ConnectionAttemptMetadata {
|
||||
// The technology used by the mediums.
|
||||
optional location.nearby.proto.connections.ConnectionTechnology technology =
|
||||
1;
|
||||
|
||||
// The wifi band used by the wifi mediums.
|
||||
optional location.nearby.proto.connections.ConnectionBand band = 2;
|
||||
|
||||
// The frequency used by the wifi mediums.
|
||||
optional int32 frequency = 3;
|
||||
|
||||
// The MCC (Mobile country code) MNC (Mobile network code) of the network
|
||||
// operator.
|
||||
optional string network_operator = 4
|
||||
[(datapol.semantic_type) = ST_LOCATION];
|
||||
|
||||
// The upper-case ISO 3166-1 alpha-2 country code of the current registered
|
||||
// operator's MCC (Mobile Country Code), or the country code of the default
|
||||
// Locale if not available.
|
||||
optional string country_code = 5 [(datapol.semantic_type) = ST_LOCATION];
|
||||
|
||||
// The TDLS status used by the wifi lan medium,
|
||||
// TDLS, shortened from Tunneled Direct Link Setup, is "a seamless way to
|
||||
// stream media and other data faster between devices already on the same
|
||||
// Wi-Fi network." Devices using it communicate directly with one another,
|
||||
// without involving the wireless network's router.
|
||||
optional bool is_tdls_used = 6;
|
||||
|
||||
// The try times for this hosted group or connection operation.
|
||||
optional int32 try_counts = 7;
|
||||
|
||||
// The enabled status of the wifi hotspot(tethering) when doing this
|
||||
// connection attempt.
|
||||
optional bool wifi_hotspot_status = 8;
|
||||
|
||||
// The MAX supported TX link speed (Mbps).
|
||||
optional int32 max_tx_speed = 9;
|
||||
|
||||
// The MAX supported RX link speed (Mbps).
|
||||
optional int32 max_rx_speed = 10;
|
||||
}
|
||||
}
|
||||
// LINT.ThenChange()
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
// Copyright 2020 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "logs/proto/location/nearby/nearby_client_log.proto.h"
|
||||
#include "google/protobuf/descriptor.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "platform/public/logging.h"
|
||||
#include "proto/analytics/connections_log.proto.h"
|
||||
#include "proto/connections_enums.proto.h"
|
||||
|
||||
namespace location {
|
||||
namespace nearby {
|
||||
namespace analytics {
|
||||
namespace proto {
|
||||
|
||||
namespace {
|
||||
|
||||
using G3ConnectionsLog = ::location::nearby::logs::ConnectionsLog;
|
||||
using P3ConnectionsLog = ::location::nearby::analytics::proto::ConnectionsLog;
|
||||
|
||||
using ::proto2::Descriptor;
|
||||
using ::proto2::FieldDescriptor;
|
||||
|
||||
// Forward declaration.
|
||||
bool Compare(const Descriptor* desc1, const Descriptor* desc2);
|
||||
|
||||
// Compares the two field descriptors and return false if name, number, label,
|
||||
// or type is different.
|
||||
bool Compare(const FieldDescriptor* field1, const FieldDescriptor* field2) {
|
||||
if (field1->name() != field2->name()) {
|
||||
NEARBY_LOGS(WARNING) << "Field name diff: " << field1->name() << " <=> "
|
||||
<< field2->name();
|
||||
return false;
|
||||
}
|
||||
if (field1->number() != field2->number()) {
|
||||
NEARBY_LOGS(WARNING) << "Field " << field1->name()
|
||||
<< " number diff: " << field1->number() << " <=> "
|
||||
<< field2->number();
|
||||
return false;
|
||||
}
|
||||
if (field1->label() != field2->label()) {
|
||||
NEARBY_LOGS(WARNING) << "Field " << field1->name()
|
||||
<< " label diff: " << field1->label() << " <=> "
|
||||
<< field2->label();
|
||||
return false;
|
||||
}
|
||||
bool bRet = false;
|
||||
if (field1->type() != field2->type()) {
|
||||
NEARBY_LOGS(WARNING) << "Field " << field1->name()
|
||||
<< " type diff: " << field1->type() << " <=> "
|
||||
<< field2->type();
|
||||
return bRet;
|
||||
} else if (field1->type() == FieldDescriptor::TYPE_MESSAGE) {
|
||||
const Descriptor* msg1 = field1->message_type();
|
||||
const Descriptor* msg2 = field2->message_type();
|
||||
|
||||
bRet = Compare(msg1, msg2);
|
||||
} else {
|
||||
bRet = true;
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
// Compares the two descriptors and return false immediately if different.
|
||||
bool Compare(const Descriptor* desc1, const Descriptor* desc2) {
|
||||
NEARBY_LOGS(INFO) << "Descriptor1 full name: " << desc1->full_name()
|
||||
<< " <=> " << desc2->full_name();
|
||||
for (int i = 0; i < desc1->field_count(); ++i) {
|
||||
const FieldDescriptor* field1 = desc1->field(i);
|
||||
const FieldDescriptor* field2 = desc2->FindFieldByName(field1->name());
|
||||
|
||||
bool bRet = false;
|
||||
if (field2) {
|
||||
bRet = Compare(field1, field2);
|
||||
} else {
|
||||
NEARBY_LOGS(ERROR) << "Descriptor1 full name: " << desc1->full_name()
|
||||
<< "=> Extra field1 name=" << field1->name()
|
||||
<< ", number=" << field1->number()
|
||||
<< ", label=" << field1->label()
|
||||
<< ", type=" << field1->type();
|
||||
}
|
||||
if (!bRet) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < desc2->field_count(); ++i) {
|
||||
const FieldDescriptor* field2 = desc2->field(i);
|
||||
const FieldDescriptor* field1 = desc1->FindFieldByName(field2->name());
|
||||
if (!field1) {
|
||||
NEARBY_LOGS(ERROR) << "Descriptor2 full name: " << desc2->full_name()
|
||||
<< "=> Extra field2 name=" << field2->name()
|
||||
<< ", number=" << field2->number()
|
||||
<< ", label=" << field2->label()
|
||||
<< ", type=" << field2->type();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TEST(ConnectionsLogTest, TwoMessagesAreIdentical) {
|
||||
const proto2::Descriptor* descriptor1 = G3ConnectionsLog::descriptor();
|
||||
const proto2::Descriptor* descriptor2 = P3ConnectionsLog::descriptor();
|
||||
|
||||
EXPECT_TRUE(Compare(descriptor1, descriptor2));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace proto
|
||||
} // namespace analytics
|
||||
} // namespace nearby
|
||||
} // namespace location
|
||||
Reference in New Issue
Block a user