diff --git a/.bazelrc b/.bazelrc
index eee8fe04..ad54b2bd 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -1,4 +1,10 @@
build --action_env=BAZEL_CXXOPTS=-"std=c++20" --repo_env=BAZEL_CONLYOPTS="-std=gnu17"
+build --action_env=CC=/usr/bin/clang
+build --action_env=CXX=/usr/bin/clang++
+build --check_visibility=false --spawn_strategy=standalone --verbose_failures
+build --cxxopt=-std=c++20
+build --cxxopt='-fvisibility-inlines-hidden'
+build --host_cxxopt=-std=c++20
# Definition of --config=memcheck
build:memcheck --strip=never --test_timeout=3600
common --enable_bzlmod
diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml
index cafc5b01..dbc820b6 100644
--- a/.github/workflows/validate.yaml
+++ b/.github/workflows/validate.yaml
@@ -69,14 +69,8 @@ jobs:
- name: Build Connections
run: |
bazel build \
- --check_visibility=false \
- --spawn_strategy=standalone \
- --cxxopt=-std=c++20 \
- --host_cxxopt=-std=c++20 \
--@com_google_protobuf//bazel/toolchains:prefer_prebuilt_protoc=true \
--copt='-DGITHUB_BUILD' \
- --copt='-fvisibility=hidden' \
- --cxxopt='-fvisibility-inlines-hidden' \
//connections:core
# - name: Build Presence
@@ -92,27 +86,21 @@ jobs:
# --cxxopt='-fvisibility-inlines-hidden' \
# //presence
- - name: Build Nearby Sharing Linux shared API
+ - name: Build Nearby Sharing Linux
run: |
bazel build \
- --check_visibility=false \
- --spawn_strategy=standalone \
- --cxxopt=-std=c++20 \
- --host_cxxopt=-std=c++20 \
--@com_google_protobuf//bazel/toolchains:prefer_prebuilt_protoc=true \
--copt='-DGITHUB_BUILD' \
- --copt='-fvisibility=hidden' \
- --cxxopt='-fvisibility-inlines-hidden' \
- //sharing/linux:nearby_sharing_api_shared
+ //sharing/linux:nearby_sharing_cli
- build-rust-linux:
- name: Build Rust on Linux
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v6
- with:
- submodules: recursive
+ #build-rust-linux:
+ # name: Build Rust on Linux
+ # runs-on: ubuntu-latest
+ # steps:
+ # - name: Checkout
+ # uses: actions/checkout@v6
+ # with:
+ # submodules: recursive
- - name: Build FPP
- run: cargo build --manifest-path presence/fpp/fpp/Cargo.toml
+ # - name: Build FPP
+ # run: cargo build --manifest-path presence/fpp/fpp/Cargo.toml
diff --git a/sharing/proto/analytics/BUILD b/BUILD.bazel
similarity index 57%
rename from sharing/proto/analytics/BUILD
rename to BUILD.bazel
index 3a8e26d8..82473d02 100644
--- a/sharing/proto/analytics/BUILD
+++ b/BUILD.bazel
@@ -1,4 +1,4 @@
-# Copyright 2022 Google LLC
+# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,25 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
-load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
-
-licenses(["notice"])
+load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
package(default_visibility = ["//visibility:public"])
-proto_library(
- name = "sharing_log_proto",
- srcs = [
- "nearby_sharing_log.proto",
- ],
- deps = [
- "//proto:sharing_enums_proto",
- "@com_google_protobuf//:duration_proto",
- ],
+licenses(["notice"])
+
+bool_flag(
+ name = "enable_webrtc",
+ build_setting_default = False,
)
-cc_proto_library(
- name = "sharing_log_cc_proto",
- deps = [":sharing_log_proto"],
+config_setting(
+ name = "webrtc_enabled",
+ flag_values = {":enable_webrtc": "True"},
)
diff --git a/MODULE.bazel b/MODULE.bazel
index a465e98b..5bfd7f6e 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -11,6 +11,10 @@ bazel_dep(name = "googletest", version = "1.17.0.bcr.2", repo_name = "com_google
bazel_dep(name = "boringssl", version = "0.20251124.0")
bazel_dep(name = "rules_foreign_cc", version = "0.15.1")
+# for linux TUI
+# Should update to 7.0.0
+bazel_dep(name = "ftxui", version = "6.1.9")
+
git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
@@ -190,10 +194,11 @@ cmake(
"CMAKE_C_STANDARD": "17",
"CMAKE_C_STANDARD_REQUIRED": "ON",
"CMAKE_C_EXTENSIONS": "ON",
+ "CMAKE_INSTALL_LIBDIR": "lib",
},
env = {
# CMake still needs pkg-config to pass its internal configuration checks for systemd
- "PKG_CONFIG_PATH": "/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig",
+ "PKG_CONFIG_PATH": "/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib64/pkgconfig:/usr/share/pkgconfig",
},
# Link the systemd dependency you defined in your WORKSPACE
deps = ["@libsystemd//:libsystemd"],
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock
index a4169fee..382d442e 100644
--- a/MODULE.bazel.lock
+++ b/MODULE.bazel.lock
@@ -63,6 +63,8 @@
"https://bcr.bazel.build/modules/boringssl/0.20251124.0/source.json": "2f325a76db6c6e14c4db923a26aa9a4bfbbd03e61b9256311f460c18bfba6013",
"https://bcr.bazel.build/modules/buildozer/8.5.1/MODULE.bazel": "a35d9561b3fc5b18797c330793e99e3b834a473d5fbd3d7d7634aafc9bdb6f8f",
"https://bcr.bazel.build/modules/buildozer/8.5.1/source.json": "e3386e6ff4529f2442800dee47ad28d3e6487f36a1f75ae39ae56c70f0cd2fbd",
+ "https://bcr.bazel.build/modules/ftxui/6.1.9/MODULE.bazel": "cc9326c084f535dab294bc7aaea0be08ceedd7623c421e09e7ab16f921f4fcb7",
+ "https://bcr.bazel.build/modules/ftxui/6.1.9/source.json": "401772aaf4b1dc988ffe03a8280e94927bd4e318b98724ba309f41000c41283e",
"https://bcr.bazel.build/modules/google_benchmark/1.8.2/MODULE.bazel": "a70cf1bba851000ba93b58ae2f6d76490a9feb74192e57ab8e8ff13c34ec50cb",
"https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4",
"https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "22c31a561553727960057361aa33bf20fb2e98584bc4fec007906e27053f80c6",
@@ -152,8 +154,8 @@
"https://bcr.bazel.build/modules/rules_java/8.3.2/MODULE.bazel": "7336d5511ad5af0b8615fdc7477535a2e4e723a357b6713af439fe8cf0195017",
"https://bcr.bazel.build/modules/rules_java/8.5.1/MODULE.bazel": "d8a9e38cc5228881f7055a6079f6f7821a073df3744d441978e7a43e20226939",
"https://bcr.bazel.build/modules/rules_java/8.6.1/MODULE.bazel": "f4808e2ab5b0197f094cabce9f4b006a27766beb6a9975931da07099560ca9c2",
- "https://bcr.bazel.build/modules/rules_java/9.1.0/MODULE.bazel": "ee63f27e36a3fada80342869361182f120a9819c74320e8e65b1e04ba0cd7a9d",
- "https://bcr.bazel.build/modules/rules_java/9.1.0/source.json": "da589573c1dee2c9ac4a568b301269a2e8191110ff0345c1a959fa7ea6c4dfd6",
+ "https://bcr.bazel.build/modules/rules_java/9.0.3/MODULE.bazel": "1f98ed015f7e744a745e0df6e898a7c5e83562d6b759dfd475c76456dda5ccea",
+ "https://bcr.bazel.build/modules/rules_java/9.0.3/source.json": "b038c0c07e12e658135bbc32cc1a2ded6e33785105c9d41958014c592de4593e",
"https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7",
"https://bcr.bazel.build/modules/rules_jvm_external/5.1/MODULE.bazel": "33f6f999e03183f7d088c9be518a63467dfd0be94a11d0055fe2d210f89aa909",
"https://bcr.bazel.build/modules/rules_jvm_external/5.2/MODULE.bazel": "d9351ba35217ad0de03816ef3ed63f89d411349353077348a45348b096615036",
@@ -220,7 +222,7 @@
"moduleExtensions": {
"@@rules_kotlin+//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": {
"general": {
- "bzlTransitiveDigest": "Ga4z8lQy1YQ5rAMy+dOl0dqcCEBnYNCXku8x3YQmDZI=",
+ "bzlTransitiveDigest": "ABI1D/sbS1ovwaW/kHDoj8nnXjQ0oKU9fzmzEG4iT8o=",
"usagesDigest": "QI2z8ZUR+mqtbwsf2fLqYdJAkPOHdOV+tF2yVAUgRzw=",
"recordedInputs": [
"REPO_MAPPING:rules_kotlin+,bazel_tools bazel_tools"
diff --git a/Package.swift b/Package.swift
index 6d3d5326..d96c9aa4 100644
--- a/Package.swift
+++ b/Package.swift
@@ -92,7 +92,7 @@ let package = Package(
.target(
name: "protobuf-utf8",
dependencies: [
- .product(name: "abseil", package: "abseil-cpp-SwiftPM"),
+ .product(name: "abseil", package: "abseil-cpp-SwiftPM")
],
path: "third_party/protobuf/third_party/utf8_range",
sources: [
@@ -102,13 +102,13 @@ let package = Package(
],
publicHeadersPath: ".",
cSettings: [
- .headerSearchPath("./"),
+ .headerSearchPath("./")
],
),
.target(
name: "protobuf",
dependencies: [
- "protobuf-utf8",
+ "protobuf-utf8"
],
path: "third_party/protobuf/src",
exclude: [
@@ -282,11 +282,11 @@ let package = Package(
"google/protobuf/io/zero_copy_sink_test.cc",
],
sources: [
- "google/protobuf",
+ "google/protobuf"
],
publicHeadersPath: ".",
cSettings: [
- .headerSearchPath("./"),
+ .headerSearchPath("./")
]
),
.target(
@@ -321,7 +321,6 @@ let package = Package(
"connections/implementation/flags/BUILD",
"connections/implementation/mediums/advertisements/BUILD",
"connections/implementation/mediums/ble/BUILD",
- "connections/implementation/mediums/multiplex/BUILD",
"connections/implementation/mediums/BUILD",
"connections/implementation/BUILD",
"connections/implementation/fuzzers",
@@ -346,7 +345,6 @@ let package = Package(
"internal/platform/implementation/apple/Mediums/WiFiCommon/BUILD",
"internal/platform/implementation/BUILD",
"internal/platform/BUILD",
- "internal/analytics/BUILD",
"internal/flags/BUILD",
"internal/network/BUILD",
"internal/rpc/BUILD",
@@ -369,16 +367,12 @@ let package = Package(
"connections/implementation/payload_manager_test.cc",
"connections/implementation/offline_frames_validator_test.cc",
"connections/implementation/service_controller_router_test.cc",
- "connections/implementation/bluetooth_bwu_test.cc",
- "connections/implementation/wifi_direct_bwu_test.cc",
- "connections/implementation/wifi_hotspot_bwu_test.cc",
- "connections/implementation/wifi_lan_bwu_handler_test.cc",
- "connections/implementation/analytics/analytics_recorder_test.cc",
- "connections/implementation/analytics/throughput_recorder_test.cc",
+ "connections/implementation/analytics/analytics_recorder_impl_test.cc",
"connections/implementation/mediums/advertisements/data_element_test.cc",
"connections/implementation/mediums/advertisements/dct_advertisement_test.cc",
"connections/implementation/mediums/advertisements/advertisement_util_test.cc",
"connections/implementation/mediums/awdl_test.cc",
+ "connections/implementation/mediums/awdl_bwu_handler_test.cc",
"connections/implementation/mediums/ble_test.cc",
"connections/implementation/mediums/ble/bloom_filter_test.cc",
"connections/implementation/mediums/ble/ble_l2cap_packet_test.cc",
@@ -391,18 +385,19 @@ let package = Package(
"connections/implementation/mediums/ble/discovered_peripheral_tracker_test.cc",
"connections/implementation/mediums/ble/instant_on_lost_advertisement_test.cc",
"connections/implementation/mediums/ble/instant_on_lost_manager_test.cc",
- "connections/implementation/mediums/multiplex/multiplex_frames_test.cc",
- "connections/implementation/mediums/multiplex/multiplex_socket_test.cc",
- "connections/implementation/mediums/multiplex/multiplex_output_stream_test.cc",
- "connections/implementation/mediums/webrtc_peer_id_test.cc",
- "connections/implementation/mediums/wifi_lan_test.cc",
- "connections/implementation/mediums/bluetooth_classic_test.cc",
"connections/implementation/mediums/ble_test.cc",
- "connections/implementation/mediums/webrtc_test.cc",
- "connections/implementation/mediums/lost_entity_tracker_test.cc",
+ "connections/implementation/mediums/bluetooth_bwu_handler_test.cc",
+ "connections/implementation/mediums/bluetooth_classic_test.cc",
"connections/implementation/mediums/bluetooth_radio_test.cc",
+ "connections/implementation/mediums/lost_entity_tracker_test.cc",
+ "connections/implementation/mediums/webrtc_peer_id_test.cc",
+ "connections/implementation/mediums/webrtc_test.cc",
+ "connections/implementation/mediums/wifi_direct_bwu_handler_test.cc",
"connections/implementation/mediums/wifi_direct_test.cc",
+ "connections/implementation/mediums/wifi_hotspot_bwu_handler_test.cc",
"connections/implementation/mediums/wifi_hotspot_test.cc",
+ "connections/implementation/mediums/wifi_lan_bwu_handler_test.cc",
+ "connections/implementation/mediums/wifi_lan_test.cc",
"connections/implementation/mediums/wifi_test.cc",
"connections/implementation/endpoint_channel_manager_test.cc",
"connections/implementation/bwu_manager_test.cc",
@@ -437,13 +432,13 @@ let package = Package(
"internal/encoding/base85_test.cc",
"internal/data/leveldb_data_set_test.cc",
"internal/flags/nearby_flags_test.cc",
- "internal/proto/analytics/connections_log_test.cc",
"internal/platform/feature_flags_test.cc",
"internal/platform/file_test.cc",
"internal/platform/cancelable_alarm_test.cc",
"internal/platform/crypto_test.cc",
"internal/platform/byte_array_test.cc",
"internal/platform/credential_storage_impl_test.cc",
+ "internal/platform/implementation/device_info_test.cc",
"internal/platform/implementation/g3/awdl_test.cc",
"internal/platform/implementation/g3/ble_test.cc",
"internal/platform/input_stream_test.cc",
@@ -478,6 +473,7 @@ let package = Package(
"internal/platform/implementation/apple/mutex_test.cc",
"internal/platform/implementation/apple/atomic_boolean_test.cc",
"internal/platform/implementation/apple/atomic_uint32_test.cc",
+ "internal/platform/implementation/apple/webrtc_platform.mm",
"internal/platform/implementation/shared/file_test.cc",
"internal/platform/implementation/wifi_utils_test.cc",
"internal/platform/atomic_boolean_test.cc",
@@ -500,7 +496,6 @@ let package = Package(
"internal/network/http_client_impl_test.cc",
"internal/network/http_status_code_test.cc",
"internal/test/fake_clock_test.cc",
- "internal/test/fake_webrtc.cc",
"internal/test/fake_timer_test.cc",
"internal/test/fake_device_info_test.cc",
"internal/test/fake_task_runner_test.cc",
@@ -522,16 +517,9 @@ let package = Package(
"proto",
"internal/data/leveldb_data_set_test.proto",
// webrtc
- "connections/implementation/webrtc_bwu_handler.cc",
- "connections/implementation/webrtc_endpoint_channel.cc",
- "connections/implementation/mediums/webrtc.cc",
- "connections/implementation/mediums/webrtc_peer_id.cc",
- "connections/implementation/mediums/webrtc",
- "internal/platform/tachyon_express_signaling_messenger.cc",
- "internal/platform/tachyon_express_signaling_messenger.h",
"internal/platform/implementation/apple/webrtc.h",
"internal/platform/implementation/apple/webrtc.mm",
- // This breaks the build, but seems to work fine without it?
+ // Only used in tests
"internal/platform/medium_environment.cc",
],
sources: [
@@ -564,6 +552,7 @@ let package = Package(
.headerSearchPath("./"),
.headerSearchPath("compiled_proto/"),
.define("NO_WEBRTC"),
+ .define("NC_OSS_BUILD"),
]
),
.target(
diff --git a/README.md b/README.md
index 3265eece..1b1c8e1f 100644
--- a/README.md
+++ b/README.md
@@ -16,14 +16,13 @@
https://github.com/user-attachments/assets/048afa1e-40a4-4351-a859-c81b642fc6e3
## What
-This repo consists of the entirety of google's open source nearby library. Currently, it is seperated into 3 sections.
+This repo consists of the entirety of google's open source nearby library. Currently, it is seperated into 3 (now 2) sections.
- Sharing
- Connections
-- ~Presence~ ( Build fails for some reason. Haven't had time to investigate. Maybe something minor. Check the validate.yaml for build steps and see why its faiing )
+- ~Presence~ ( *Was removed by google from their repo. RIP :(* )
Linux specific implementation and compatibility shims are provided for building **Sharing** and **Connections**.
-Nearby presence may or may not build.
## Why
This repo could've been a PR on the official repo. All I've done is implement the platform abstraction layer google has provided for a linux specific environment.
@@ -34,10 +33,8 @@ Moreover, all I've wanted was seamless file sharing between my android devices a
it accomplishes that goal perfectly. This repo wasn't created out of any altruistic goals or out of the goodness of my heart. I had a problem. I solved it. Simple as that.
-## How
-### How to use
-Proper documentation is coming I swear. University's getting pretty hectic so docs is on the backburner. The wiki has some more information but it's nowhere near a proper documentation. It has some good brief
-overviews and where generally everything is located if you're thinking about contributing.
+## Documentation
+Docs is on the backburner for now
If you want any clarification on anything, feel free to open an issue. I'll get back to you ASAP.
@@ -78,80 +75,45 @@ sudo dnf install -y \
Currently there are no prebuilt shared library or headers. You'll have to build them yourself
### How to build
-~Check the [wiki](https://github.com/kidfromjupiter/nearby/wiki/Development-Environment-and-Building)~
-Wiki isn't built yet. Best place to consult would be the Github actions and workflows.
-### How to contribute
-~Check the [wiki](https://github.com/kidfromjupiter/nearby/wiki/Development-Environment-and-Building)~
+Best place to consult would be the Github actions and workflows.
+
## TODO
-> **Development is paused until my next break (around mid-June.)**
+### WIP
+
+- [ ] **Transition from QT to a TUI**
+
+ We're moving away from a GUI application to TUI application. On top of this, I've made a nearby sharing daemon with socket based IPC so that even if anyone wants to create a GUI application, it is trivial without them needing to link with nearby sharing libraries.
+
+ This change was done to decouple the UI from the library itself since the previous implementation was difficult to work with
+
---
-### 🔴 P0 — Critical / Core Functionality
-
-> Issues that break core functionality. These should be addressed immediately.
-
-- **Merge latest upstream changes**
-
-
-- **Bluetooth classic bandwidth**
+### BUGS
+- [ ] **Bluetooth classic bandwidth**
File transfer on bluetooth classic is painfully slow. Bandwidth close to 20KB/s. ~May be a regression issue after bluetooth socket refactor~. May be an issue with sending back acknowledgements. Issue is present on pre-refactor versions. ~Look into Multiplexing maybe~ Multiplexing did not fix it : (?
-- **~Linux → Android~ file sharing is unreliable** after the newest Android Quick Share updates.
- Investigate why and fix it. ~Possibly related to proprietary certificate changes~. Should probably add unit tests and integration tests for each medium. Everything is so fucking buggy it makes me wanna rip my fucking eyes out. Might be related to recent upstream changes. I could probably properly test linux -> linux bidirectional sharing. Will need to simulate a lot of hardware stuff though. Since there's no stable reference platform to write automatic tests against writing linux to linux tests could be like clown to clown communication
-
-
-
-
-- **QR code scanning does not work.**
- Likely related to the Linux → Android sharing issue above. I did get it working once in a very old build. So it shouldn't impossible. Unless google changed something
-
----
-
-### 🟠 P1 — Important Annoyances
-
-> Problems that are not fully blocking, but noticeably affect usability.
-
-- **Investigate why Bluetooth connection requests pairing.**
+- [ ] **Investigate why Bluetooth connection requests pairing.**
+
Both the L2CAP socket and Bluetooth profile should be unauthenticated.
-- **Handle existing files when receiving.**
+- [ ] **Handle existing files when receiving.**
+
Currently, files are not overwritten if they already exist. Decide whether to overwrite, rename, or skip.
----
-
-### 🟡 P2 — Quality of Life / Cleanup
-
-> Improvements that would make the project cleaner, smoother, or easier to maintain.
-
-- **Bluetooth Classic transfer progress issue.**
+- [ ] **Bluetooth Classic transfer progress issue.**
+
When transferring Android → Linux, Android shows 100% transferred but still says `Sending...`, while Linux lags behind. Could be a bottleneck or Android-side issue.
-- **Add tests for basically everything.**
-- **Clean up `implementation/linux`.**
- Linux-specific implementation files are currently all in one directory. This matches the other platforms, but creates visual bloat.
-- **Document basically everything.**
- This would be a large project on its own.
-- **Resolve random crashes in the Quick Share application.**
---
-### 🔵 P3 — New Features
+### New Features
-> Non-essential features and future improvements.
-
-- **Support fast initiation.**
-- Upstream has been slowly adding webrtc support. Should we support it?
-
-
-## Apologies
-I may have done things in *incredibly* stupid and overcomplicated ways. It doesn't certainly help that this was the way I decided to learn C++. Blessed be my naive soul. I also do not have much experience working with such
-enormous codebases.
-
-If you see any such stupidities, feel free to berate me in the most shameless of manners in an issue. I look forward to learning how to do it the proper way and to improve my atrocious code quality.
+- [ ] Upstream has been slowly adding webrtc support. Should we support it?
## Special thanks
diff --git a/compiled_proto/connections/implementation/proto/offline_wire_formats.pb.cc b/compiled_proto/connections/implementation/proto/offline_wire_formats.pb.cc
index 5c907238..2da3e87d 100644
--- a/compiled_proto/connections/implementation/proto/offline_wire_formats.pb.cc
+++ b/compiled_proto/connections/implementation/proto/offline_wire_formats.pb.cc
@@ -562,6 +562,9 @@ inline constexpr BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCred
pin_(
&::google::protobuf::internal::fixed_address_empty_string,
::_pbi::ConstantInitialized()),
+ device_name_(
+ &::google::protobuf::internal::fixed_address_empty_string,
+ ::_pbi::ConstantInitialized()),
port_{0},
frequency_{0} {}
@@ -2056,44 +2059,47 @@ bool AutoReconnectFrame_EventType_Parse(::absl::string_view name, AutoReconnectF
return success;
}
PROTOBUF_CONSTINIT const uint32_t MediumMetadata_WifiDirectAuthType_internal_data_[] = {
- 196608u, 0u, };
+ 262144u, 0u, };
static ::google::protobuf::internal::ExplicitlyConstructed<::std::string>
- MediumMetadata_WifiDirectAuthType_strings[3] = {};
+ MediumMetadata_WifiDirectAuthType_strings[4] = {};
static const char MediumMetadata_WifiDirectAuthType_names[] = {
"WIFI_DIRECT_TYPE_UNKNOWN"
+ "WIFI_DIRECT_WITH_DEVICE_NAME"
"WIFI_DIRECT_WITH_PASSWORD"
"WIFI_DIRECT_WITH_PIN"
};
static const ::google::protobuf::internal::EnumEntry MediumMetadata_WifiDirectAuthType_entries[] = {
{{&MediumMetadata_WifiDirectAuthType_names[0], 24}, 0},
- {{&MediumMetadata_WifiDirectAuthType_names[24], 25}, 1},
- {{&MediumMetadata_WifiDirectAuthType_names[49], 20}, 2},
+ {{&MediumMetadata_WifiDirectAuthType_names[24], 28}, 3},
+ {{&MediumMetadata_WifiDirectAuthType_names[52], 25}, 1},
+ {{&MediumMetadata_WifiDirectAuthType_names[77], 20}, 2},
};
static const int MediumMetadata_WifiDirectAuthType_entries_by_number[] = {
0, // 0 -> WIFI_DIRECT_TYPE_UNKNOWN
- 1, // 1 -> WIFI_DIRECT_WITH_PASSWORD
- 2, // 2 -> WIFI_DIRECT_WITH_PIN
+ 2, // 1 -> WIFI_DIRECT_WITH_PASSWORD
+ 3, // 2 -> WIFI_DIRECT_WITH_PIN
+ 1, // 3 -> WIFI_DIRECT_WITH_DEVICE_NAME
};
const ::std::string& MediumMetadata_WifiDirectAuthType_Name(MediumMetadata_WifiDirectAuthType value) {
static const bool kDummy = ::google::protobuf::internal::InitializeEnumStrings(
- MediumMetadata_WifiDirectAuthType_entries, MediumMetadata_WifiDirectAuthType_entries_by_number, 3,
+ MediumMetadata_WifiDirectAuthType_entries, MediumMetadata_WifiDirectAuthType_entries_by_number, 4,
MediumMetadata_WifiDirectAuthType_strings);
(void)kDummy;
int idx = ::google::protobuf::internal::LookUpEnumName(MediumMetadata_WifiDirectAuthType_entries,
MediumMetadata_WifiDirectAuthType_entries_by_number,
- 3, value);
+ 4, value);
return idx == -1 ? ::google::protobuf::internal::GetEmptyString() : MediumMetadata_WifiDirectAuthType_strings[idx].get();
}
bool MediumMetadata_WifiDirectAuthType_Parse(::absl::string_view name, MediumMetadata_WifiDirectAuthType* PROTOBUF_NONNULL value) {
int int_value;
bool success = ::google::protobuf::internal::LookUpEnumValue(
- MediumMetadata_WifiDirectAuthType_entries, 3, name, &int_value);
+ MediumMetadata_WifiDirectAuthType_entries, 4, name, &int_value);
if (success) {
*value = static_cast(int_value);
}
@@ -7696,7 +7702,8 @@ PROTOBUF_NDEBUG_INLINE BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDire
gateway_(arena, from.gateway_, _i_give_permission_to_break_this_code_default_gateway_),
ip_v6_address_(arena, from.ip_v6_address_),
service_name_(arena, from.service_name_),
- pin_(arena, from.pin_) {}
+ pin_(arena, from.pin_),
+ device_name_(arena, from.device_name_) {}
BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials(
::google::protobuf::Arena* PROTOBUF_NULLABLE arena,
@@ -7730,7 +7737,8 @@ PROTOBUF_NDEBUG_INLINE BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDire
gateway_(arena, Impl_::_i_give_permission_to_break_this_code_default_gateway_),
ip_v6_address_(arena),
service_name_(arena),
- pin_(arena) {}
+ pin_(arena),
+ device_name_(arena) {}
inline void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::SharedCtor(::_pb::Arena* PROTOBUF_NULLABLE arena) {
new (&_impl_) Impl_(internal_visibility(), arena);
@@ -7758,6 +7766,7 @@ inline void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentia
this_._impl_.ip_v6_address_.Destroy();
this_._impl_.service_name_.Destroy();
this_._impl_.pin_.Destroy();
+ this_._impl_.device_name_.Destroy();
this_._impl_.~Impl_();
}
@@ -7801,16 +7810,16 @@ BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::GetClass
return BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials_class_data_.base();
}
PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
-const ::_pbi::TcParseTable<3, 8, 0, 0, 2>
+const ::_pbi::TcParseTable<4, 9, 0, 0, 2>
BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::_table_ = {
{
PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_._has_bits_),
0, // no _extensions_
- 8, 56, // max_field_number, fast_idx_mask
+ 9, 120, // max_field_number, fast_idx_mask
offsetof(decltype(_table_), field_lookup_table),
- 4294967040, // skipmap
+ 4294966784, // skipmap
offsetof(decltype(_table_), field_entries),
- 8, // num_field_entries
+ 9, // num_field_entries
0, // num_aux_entries
offsetof(decltype(_table_), field_names), // no aux_entries
BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials_class_data_.base(),
@@ -7820,10 +7829,7 @@ BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::_table_
::_pbi::TcParser::GetTable<::location::nearby::connections::BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials>(), // to_prefetch
#endif // PROTOBUF_PREFETCH_PARSE_TABLE
}, {{
- // optional string pin = 8;
- {::_pbi::TcParser::FastBS1,
- {66, 5, 0,
- PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.pin_)}},
+ {::_pbi::TcParser::MiniParse, {}},
// optional string ssid = 1;
{::_pbi::TcParser::FastBS1,
{10, 0, 0,
@@ -7834,11 +7840,11 @@ BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::_table_
PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.password_)}},
// optional int32 port = 3;
{::_pbi::TcParser::FastV32S1,
- {24, 6, 0,
+ {24, 7, 0,
PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.port_)}},
// optional int32 frequency = 4;
{::_pbi::TcParser::FastV32S1,
- {32, 7, 0,
+ {32, 8, 0,
PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.frequency_)}},
// optional string gateway = 5 [default = "0.0.0.0"];
{::_pbi::TcParser::FastBS1,
@@ -7848,10 +7854,24 @@ BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::_table_
{::_pbi::TcParser::FastBS1,
{50, 3, 0,
PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.ip_v6_address_)}},
- // optional string service_name = 7;
+ // optional string service_name = 7 [deprecated = true];
{::_pbi::TcParser::FastBS1,
{58, 4, 0,
PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.service_name_)}},
+ // optional string pin = 8;
+ {::_pbi::TcParser::FastBS1,
+ {66, 5, 0,
+ PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.pin_)}},
+ // optional string device_name = 9;
+ {::_pbi::TcParser::FastBS1,
+ {74, 6, 0,
+ PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.device_name_)}},
+ {::_pbi::TcParser::MiniParse, {}},
+ {::_pbi::TcParser::MiniParse, {}},
+ {::_pbi::TcParser::MiniParse, {}},
+ {::_pbi::TcParser::MiniParse, {}},
+ {::_pbi::TcParser::MiniParse, {}},
+ {::_pbi::TcParser::MiniParse, {}},
}}, {{
65535, 65535
}}, {{
@@ -7860,17 +7880,19 @@ BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::_table_
// optional string password = 2;
{PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.password_), _Internal::kHasBitsOffset + 1, 0, (0 | ::_fl::kFcOptional | ::_fl::kBytes | ::_fl::kRepAString)},
// optional int32 port = 3;
- {PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.port_), _Internal::kHasBitsOffset + 6, 0, (0 | ::_fl::kFcOptional | ::_fl::kInt32)},
+ {PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.port_), _Internal::kHasBitsOffset + 7, 0, (0 | ::_fl::kFcOptional | ::_fl::kInt32)},
// optional int32 frequency = 4;
- {PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.frequency_), _Internal::kHasBitsOffset + 7, 0, (0 | ::_fl::kFcOptional | ::_fl::kInt32)},
+ {PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.frequency_), _Internal::kHasBitsOffset + 8, 0, (0 | ::_fl::kFcOptional | ::_fl::kInt32)},
// optional string gateway = 5 [default = "0.0.0.0"];
{PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.gateway_), _Internal::kHasBitsOffset + 2, 0, (0 | ::_fl::kFcOptional | ::_fl::kBytes | ::_fl::kRepAString)},
// optional bytes ip_v6_address = 6;
{PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.ip_v6_address_), _Internal::kHasBitsOffset + 3, 0, (0 | ::_fl::kFcOptional | ::_fl::kBytes | ::_fl::kRepAString)},
- // optional string service_name = 7;
+ // optional string service_name = 7 [deprecated = true];
{PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.service_name_), _Internal::kHasBitsOffset + 4, 0, (0 | ::_fl::kFcOptional | ::_fl::kBytes | ::_fl::kRepAString)},
// optional string pin = 8;
{PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.pin_), _Internal::kHasBitsOffset + 5, 0, (0 | ::_fl::kFcOptional | ::_fl::kBytes | ::_fl::kRepAString)},
+ // optional string device_name = 9;
+ {PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.device_name_), _Internal::kHasBitsOffset + 6, 0, (0 | ::_fl::kFcOptional | ::_fl::kBytes | ::_fl::kRepAString)},
}},
// no aux_entries
{{
@@ -7884,7 +7906,7 @@ PROTOBUF_NOINLINE void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDire
(void) cached_has_bits;
cached_has_bits = _impl_._has_bits_[0];
- if (BatchCheckHasBit(cached_has_bits, 0x0000003fU)) {
+ if (BatchCheckHasBit(cached_has_bits, 0x0000007fU)) {
if (CheckHasBit(cached_has_bits, 0x00000001U)) {
_impl_.ssid_.ClearNonDefaultToEmpty();
}
@@ -7903,12 +7925,12 @@ PROTOBUF_NOINLINE void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDire
if (CheckHasBit(cached_has_bits, 0x00000020U)) {
_impl_.pin_.ClearNonDefaultToEmpty();
}
+ if (CheckHasBit(cached_has_bits, 0x00000040U)) {
+ _impl_.device_name_.ClearNonDefaultToEmpty();
+ }
}
- if (BatchCheckHasBit(cached_has_bits, 0x000000c0U)) {
- ::memset(&_impl_.port_, 0, static_cast<::size_t>(
- reinterpret_cast(&_impl_.frequency_) -
- reinterpret_cast(&_impl_.port_)) + sizeof(_impl_.frequency_));
- }
+ _impl_.port_ = 0;
+ _impl_.frequency_ = 0;
_impl_._has_bits_.Clear();
_internal_metadata_.Clear<::std::string>();
}
@@ -7945,14 +7967,14 @@ PROTOBUF_NOINLINE void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDire
}
// optional int32 port = 3;
- if (CheckHasBit(cached_has_bits, 0x00000040U)) {
+ if (CheckHasBit(cached_has_bits, 0x00000080U)) {
target =
::google::protobuf::internal::WireFormatLite::WriteInt32ToArrayWithField<3>(
stream, this_._internal_port(), target);
}
// optional int32 frequency = 4;
- if (CheckHasBit(cached_has_bits, 0x00000080U)) {
+ if (CheckHasBit(cached_has_bits, 0x00000100U)) {
target =
::google::protobuf::internal::WireFormatLite::WriteInt32ToArrayWithField<4>(
stream, this_._internal_frequency(), target);
@@ -7970,7 +7992,7 @@ PROTOBUF_NOINLINE void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDire
target = stream->WriteBytesMaybeAliased(6, _s, target);
}
- // optional string service_name = 7;
+ // optional string service_name = 7 [deprecated = true];
if (CheckHasBit(cached_has_bits, 0x00000010U)) {
const ::std::string& _s = this_._internal_service_name();
target = stream->WriteStringMaybeAliased(7, _s, target);
@@ -7982,6 +8004,12 @@ PROTOBUF_NOINLINE void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDire
target = stream->WriteStringMaybeAliased(8, _s, target);
}
+ // optional string device_name = 9;
+ if (CheckHasBit(cached_has_bits, 0x00000040U)) {
+ const ::std::string& _s = this_._internal_device_name();
+ target = stream->WriteStringMaybeAliased(9, _s, target);
+ }
+
if (ABSL_PREDICT_FALSE(this_._internal_metadata_.have_unknown_fields())) {
target = stream->WriteRaw(
this_._internal_metadata_.unknown_fields<::std::string>(::google::protobuf::internal::GetEmptyString).data(),
@@ -8028,7 +8056,7 @@ PROTOBUF_NOINLINE void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDire
total_size += 1 + ::google::protobuf::internal::WireFormatLite::BytesSize(
this_._internal_ip_v6_address());
}
- // optional string service_name = 7;
+ // optional string service_name = 7 [deprecated = true];
if (CheckHasBit(cached_has_bits, 0x00000010U)) {
total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize(
this_._internal_service_name());
@@ -8038,13 +8066,20 @@ PROTOBUF_NOINLINE void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDire
total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize(
this_._internal_pin());
}
- // optional int32 port = 3;
+ // optional string device_name = 9;
if (CheckHasBit(cached_has_bits, 0x00000040U)) {
+ total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize(
+ this_._internal_device_name());
+ }
+ // optional int32 port = 3;
+ if (CheckHasBit(cached_has_bits, 0x00000080U)) {
total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
this_._internal_port());
}
+ }
+ {
// optional int32 frequency = 4;
- if (CheckHasBit(cached_has_bits, 0x00000080U)) {
+ if (CheckHasBit(cached_has_bits, 0x00000100U)) {
total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(
this_._internal_frequency());
}
@@ -8090,12 +8125,15 @@ void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::Mer
_this->_internal_set_pin(from._internal_pin());
}
if (CheckHasBit(cached_has_bits, 0x00000040U)) {
- _this->_impl_.port_ = from._impl_.port_;
+ _this->_internal_set_device_name(from._internal_device_name());
}
if (CheckHasBit(cached_has_bits, 0x00000080U)) {
- _this->_impl_.frequency_ = from._impl_.frequency_;
+ _this->_impl_.port_ = from._impl_.port_;
}
}
+ if (CheckHasBit(cached_has_bits, 0x00000100U)) {
+ _this->_impl_.frequency_ = from._impl_.frequency_;
+ }
_this->_impl_._has_bits_[0] |= cached_has_bits;
_this->_internal_metadata_.MergeFrom<::std::string>(
from._internal_metadata_);
@@ -8121,6 +8159,7 @@ void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::Int
::_pbi::ArenaStringPtr::InternalSwap(&_impl_.ip_v6_address_, &other->_impl_.ip_v6_address_, arena);
::_pbi::ArenaStringPtr::InternalSwap(&_impl_.service_name_, &other->_impl_.service_name_, arena);
::_pbi::ArenaStringPtr::InternalSwap(&_impl_.pin_, &other->_impl_.pin_, arena);
+ ::_pbi::ArenaStringPtr::InternalSwap(&_impl_.device_name_, &other->_impl_.device_name_, arena);
::google::protobuf::internal::memswap<
PROTOBUF_FIELD_OFFSET(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials, _impl_.frequency_)
+ sizeof(BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::_impl_.frequency_)
@@ -13302,7 +13341,7 @@ MediumMetadata::_table_ = {
PROTOBUF_FIELD_OFFSET(MediumMetadata, _impl_.medium_role_)}},
// repeated .location.nearby.connections.MediumMetadata.WifiDirectAuthType supported_wifi_direct_auth_types = 13 [packed = true];
{::_pbi::TcParser::FastEr0P1,
- {106, 0, 2,
+ {106, 0, 3,
PROTOBUF_FIELD_OFFSET(MediumMetadata, _impl_.supported_wifi_direct_auth_types_)}},
{::_pbi::TcParser::MiniParse, {}},
{::_pbi::TcParser::MiniParse, {}},
@@ -13343,7 +13382,7 @@ MediumMetadata::_table_ = {
{::_pbi::TcParser::GetTable<::location::nearby::connections::WifiAwareUsableChannels>()},
{::_pbi::TcParser::GetTable<::location::nearby::connections::WifiHotspotStaUsableChannels>()},
{::_pbi::TcParser::GetTable<::location::nearby::connections::MediumRole>()},
- {0, 2},
+ {0, 3},
}},
{{
}},
diff --git a/compiled_proto/connections/implementation/proto/offline_wire_formats.pb.h b/compiled_proto/connections/implementation/proto/offline_wire_formats.pb.h
index 9c8cf9cb..4441f499 100644
--- a/compiled_proto/connections/implementation/proto/offline_wire_formats.pb.h
+++ b/compiled_proto/connections/implementation/proto/offline_wire_formats.pb.h
@@ -722,18 +722,19 @@ bool AutoReconnectFrame_EventType_Parse(
enum MediumMetadata_WifiDirectAuthType : int {
MediumMetadata_WifiDirectAuthType_WIFI_DIRECT_TYPE_UNKNOWN = 0,
MediumMetadata_WifiDirectAuthType_WIFI_DIRECT_WITH_PASSWORD = 1,
- MediumMetadata_WifiDirectAuthType_WIFI_DIRECT_WITH_PIN = 2,
+ MediumMetadata_WifiDirectAuthType_WIFI_DIRECT_WITH_PIN [[deprecated]] = 2,
+ MediumMetadata_WifiDirectAuthType_WIFI_DIRECT_WITH_DEVICE_NAME = 3,
};
extern const uint32_t MediumMetadata_WifiDirectAuthType_internal_data_[];
inline constexpr MediumMetadata_WifiDirectAuthType MediumMetadata_WifiDirectAuthType_WifiDirectAuthType_MIN =
static_cast(0);
inline constexpr MediumMetadata_WifiDirectAuthType MediumMetadata_WifiDirectAuthType_WifiDirectAuthType_MAX =
- static_cast(2);
+ static_cast(3);
inline bool MediumMetadata_WifiDirectAuthType_IsValid(int value) {
- return 0 <= value && value <= 2;
+ return 0 <= value && value <= 3;
}
-inline constexpr int MediumMetadata_WifiDirectAuthType_WifiDirectAuthType_ARRAYSIZE = 2 + 1;
+inline constexpr int MediumMetadata_WifiDirectAuthType_WifiDirectAuthType_ARRAYSIZE = 3 + 1;
const ::std::string& MediumMetadata_WifiDirectAuthType_Name(MediumMetadata_WifiDirectAuthType value);
template
const ::std::string& MediumMetadata_WifiDirectAuthType_Name(T value) {
@@ -4914,6 +4915,7 @@ class BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials fin
kIpV6AddressFieldNumber = 6,
kServiceNameFieldNumber = 7,
kPinFieldNumber = 8,
+ kDeviceNameFieldNumber = 9,
kPortFieldNumber = 3,
kFrequencyFieldNumber = 4,
};
@@ -4981,15 +4983,15 @@ class BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials fin
::std::string* PROTOBUF_NONNULL _internal_mutable_ip_v6_address();
public:
- // optional string service_name = 7;
- bool has_service_name() const;
- void clear_service_name() ;
- const ::std::string& service_name() const;
+ // optional string service_name = 7 [deprecated = true];
+ [[deprecated]] bool has_service_name() const;
+ [[deprecated]] void clear_service_name() ;
+ [[deprecated]] const ::std::string& service_name() const;
template
- void set_service_name(Arg_&& arg, Args_... args);
- ::std::string* PROTOBUF_NONNULL mutable_service_name();
- [[nodiscard]] ::std::string* PROTOBUF_NULLABLE release_service_name();
- void set_allocated_service_name(::std::string* PROTOBUF_NULLABLE value);
+ [[deprecated]] void set_service_name(Arg_&& arg, Args_... args);
+ [[deprecated]] ::std::string* PROTOBUF_NONNULL mutable_service_name();
+ [[deprecated]] [[nodiscard]] ::std::string* PROTOBUF_NULLABLE release_service_name();
+ [[deprecated]] void set_allocated_service_name(::std::string* PROTOBUF_NULLABLE value);
private:
const ::std::string& _internal_service_name() const;
@@ -5012,6 +5014,22 @@ class BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials fin
PROTOBUF_ALWAYS_INLINE void _internal_set_pin(const ::std::string& value);
::std::string* PROTOBUF_NONNULL _internal_mutable_pin();
+ public:
+ // optional string device_name = 9;
+ bool has_device_name() const;
+ void clear_device_name() ;
+ const ::std::string& device_name() const;
+ template
+ void set_device_name(Arg_&& arg, Args_... args);
+ ::std::string* PROTOBUF_NONNULL mutable_device_name();
+ [[nodiscard]] ::std::string* PROTOBUF_NULLABLE release_device_name();
+ void set_allocated_device_name(::std::string* PROTOBUF_NULLABLE value);
+
+ private:
+ const ::std::string& _internal_device_name() const;
+ PROTOBUF_ALWAYS_INLINE void _internal_set_device_name(const ::std::string& value);
+ ::std::string* PROTOBUF_NONNULL _internal_mutable_device_name();
+
public:
// optional int32 port = 3;
bool has_port() const;
@@ -5039,7 +5057,7 @@ class BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials fin
private:
class _Internal;
friend class ::google::protobuf::internal::TcParser;
- static const ::google::protobuf::internal::TcParseTable<3, 8,
+ static const ::google::protobuf::internal::TcParseTable<4, 9,
0, 0,
2>
_table_;
@@ -5068,6 +5086,7 @@ class BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials fin
::google::protobuf::internal::ArenaStringPtr ip_v6_address_;
::google::protobuf::internal::ArenaStringPtr service_name_;
::google::protobuf::internal::ArenaStringPtr pin_;
+ ::google::protobuf::internal::ArenaStringPtr device_name_;
::int32_t port_;
::int32_t frequency_;
PROTOBUF_TSAN_DECLARE_MEMBER
@@ -7679,7 +7698,8 @@ class MediumMetadata final : public ::google::protobuf::MessageLite
using WifiDirectAuthType = MediumMetadata_WifiDirectAuthType;
static constexpr WifiDirectAuthType WIFI_DIRECT_TYPE_UNKNOWN = MediumMetadata_WifiDirectAuthType_WIFI_DIRECT_TYPE_UNKNOWN;
static constexpr WifiDirectAuthType WIFI_DIRECT_WITH_PASSWORD = MediumMetadata_WifiDirectAuthType_WIFI_DIRECT_WITH_PASSWORD;
- static constexpr WifiDirectAuthType WIFI_DIRECT_WITH_PIN = MediumMetadata_WifiDirectAuthType_WIFI_DIRECT_WITH_PIN;
+ [[deprecated]] static constexpr WifiDirectAuthType WIFI_DIRECT_WITH_PIN = MediumMetadata_WifiDirectAuthType_WIFI_DIRECT_WITH_PIN;
+ static constexpr WifiDirectAuthType WIFI_DIRECT_WITH_DEVICE_NAME = MediumMetadata_WifiDirectAuthType_WIFI_DIRECT_WITH_DEVICE_NAME;
static inline bool WifiDirectAuthType_IsValid(int value) {
return MediumMetadata_WifiDirectAuthType_IsValid(value);
}
@@ -15574,14 +15594,14 @@ inline void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentia
// optional int32 port = 3;
inline bool BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::has_port() const {
- bool value = CheckHasBit(_impl_._has_bits_[0], 0x00000040U);
+ bool value = CheckHasBit(_impl_._has_bits_[0], 0x00000080U);
return value;
}
inline void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::clear_port() {
::google::protobuf::internal::TSanWrite(&_impl_);
_impl_.port_ = 0;
ClearHasBit(_impl_._has_bits_[0],
- 0x00000040U);
+ 0x00000080U);
}
inline ::int32_t BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::port() const {
// @@protoc_insertion_point(field_get:location.nearby.connections.BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials.port)
@@ -15589,7 +15609,7 @@ inline ::int32_t BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCred
}
inline void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::set_port(::int32_t value) {
_internal_set_port(value);
- SetHasBit(_impl_._has_bits_[0], 0x00000040U);
+ SetHasBit(_impl_._has_bits_[0], 0x00000080U);
// @@protoc_insertion_point(field_set:location.nearby.connections.BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials.port)
}
inline ::int32_t BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::_internal_port() const {
@@ -15603,14 +15623,14 @@ inline void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentia
// optional int32 frequency = 4;
inline bool BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::has_frequency() const {
- bool value = CheckHasBit(_impl_._has_bits_[0], 0x00000080U);
+ bool value = CheckHasBit(_impl_._has_bits_[0], 0x00000100U);
return value;
}
inline void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::clear_frequency() {
::google::protobuf::internal::TSanWrite(&_impl_);
_impl_.frequency_ = 0;
ClearHasBit(_impl_._has_bits_[0],
- 0x00000080U);
+ 0x00000100U);
}
inline ::int32_t BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::frequency() const {
// @@protoc_insertion_point(field_get:location.nearby.connections.BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials.frequency)
@@ -15618,7 +15638,7 @@ inline ::int32_t BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCred
}
inline void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::set_frequency(::int32_t value) {
_internal_set_frequency(value);
- SetHasBit(_impl_._has_bits_[0], 0x00000080U);
+ SetHasBit(_impl_._has_bits_[0], 0x00000100U);
// @@protoc_insertion_point(field_set:location.nearby.connections.BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials.frequency)
}
inline ::int32_t BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::_internal_frequency() const {
@@ -15764,7 +15784,7 @@ inline void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentia
// @@protoc_insertion_point(field_set_allocated:location.nearby.connections.BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials.ip_v6_address)
}
-// optional string service_name = 7;
+// optional string service_name = 7 [deprecated = true];
inline bool BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::has_service_name() const {
bool value = CheckHasBit(_impl_._has_bits_[0], 0x00000010U);
return value;
@@ -15833,6 +15853,75 @@ inline void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentia
// @@protoc_insertion_point(field_set_allocated:location.nearby.connections.BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials.service_name)
}
+// optional string device_name = 9;
+inline bool BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::has_device_name() const {
+ bool value = CheckHasBit(_impl_._has_bits_[0], 0x00000040U);
+ return value;
+}
+inline void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::clear_device_name() {
+ ::google::protobuf::internal::TSanWrite(&_impl_);
+ _impl_.device_name_.ClearToEmpty();
+ ClearHasBit(_impl_._has_bits_[0],
+ 0x00000040U);
+}
+inline const ::std::string& BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::device_name() const
+ ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ // @@protoc_insertion_point(field_get:location.nearby.connections.BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials.device_name)
+ return _internal_device_name();
+}
+template
+PROTOBUF_ALWAYS_INLINE void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::set_device_name(Arg_&& arg, Args_... args) {
+ ::google::protobuf::internal::TSanWrite(&_impl_);
+ SetHasBit(_impl_._has_bits_[0], 0x00000040U);
+ _impl_.device_name_.Set(static_cast(arg), args..., GetArena());
+ // @@protoc_insertion_point(field_set:location.nearby.connections.BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials.device_name)
+}
+inline ::std::string* PROTOBUF_NONNULL BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::mutable_device_name()
+ ABSL_ATTRIBUTE_LIFETIME_BOUND {
+ SetHasBit(_impl_._has_bits_[0], 0x00000040U);
+ ::std::string* _s = _internal_mutable_device_name();
+ // @@protoc_insertion_point(field_mutable:location.nearby.connections.BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials.device_name)
+ return _s;
+}
+inline const ::std::string& BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::_internal_device_name() const {
+ ::google::protobuf::internal::TSanRead(&_impl_);
+ return _impl_.device_name_.Get();
+}
+inline void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::_internal_set_device_name(const ::std::string& value) {
+ ::google::protobuf::internal::TSanWrite(&_impl_);
+ _impl_.device_name_.Set(value, GetArena());
+}
+inline ::std::string* PROTOBUF_NONNULL BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::_internal_mutable_device_name() {
+ ::google::protobuf::internal::TSanWrite(&_impl_);
+ return _impl_.device_name_.Mutable( GetArena());
+}
+inline ::std::string* PROTOBUF_NULLABLE BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::release_device_name() {
+ ::google::protobuf::internal::TSanWrite(&_impl_);
+ // @@protoc_insertion_point(field_release:location.nearby.connections.BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials.device_name)
+ if (!CheckHasBit(_impl_._has_bits_[0], 0x00000040U)) {
+ return nullptr;
+ }
+ ClearHasBit(_impl_._has_bits_[0], 0x00000040U);
+ auto* released = _impl_.device_name_.Release();
+ if (::google::protobuf::internal::DebugHardenForceCopyDefaultString()) {
+ _impl_.device_name_.Set("", GetArena());
+ }
+ return released;
+}
+inline void BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::set_allocated_device_name(::std::string* PROTOBUF_NULLABLE value) {
+ ::google::protobuf::internal::TSanWrite(&_impl_);
+ if (value != nullptr) {
+ SetHasBit(_impl_._has_bits_[0], 0x00000040U);
+ } else {
+ ClearHasBit(_impl_._has_bits_[0], 0x00000040U);
+ }
+ _impl_.device_name_.SetAllocated(value, GetArena());
+ if (::google::protobuf::internal::DebugHardenForceCopyDefaultString() && _impl_.device_name_.IsDefault()) {
+ _impl_.device_name_.Set("", GetArena());
+ }
+ // @@protoc_insertion_point(field_set_allocated:location.nearby.connections.BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials.device_name)
+}
+
// optional string pin = 8;
inline bool BandwidthUpgradeNegotiationFrame_UpgradePathInfo_WifiDirectCredentials::has_pin() const {
bool value = CheckHasBit(_impl_._has_bits_[0], 0x00000020U);
diff --git a/compiled_proto/proto/connections_enums.pb.cc b/compiled_proto/proto/connections_enums.pb.cc
index bf00c0c3..cd26feb2 100644
--- a/compiled_proto/proto/connections_enums.pb.cc
+++ b/compiled_proto/proto/connections_enums.pb.cc
@@ -263,44 +263,47 @@ bool Medium_Parse(::absl::string_view name, Medium* PROTOBUF_NONNULL value) {
return success;
}
PROTOBUF_CONSTINIT const uint32_t WifiDirectAuthType_internal_data_[] = {
- 196608u, 0u, };
+ 262144u, 0u, };
static ::google::protobuf::internal::ExplicitlyConstructed<::std::string>
- WifiDirectAuthType_strings[3] = {};
+ WifiDirectAuthType_strings[4] = {};
static const char WifiDirectAuthType_names[] = {
"WIFI_DIRECT_TYPE_UNKNOWN"
+ "WIFI_DIRECT_WITH_DEVICE_NAME"
"WIFI_DIRECT_WITH_PASSWORD"
"WIFI_DIRECT_WITH_PIN"
};
static const ::google::protobuf::internal::EnumEntry WifiDirectAuthType_entries[] = {
{{&WifiDirectAuthType_names[0], 24}, 0},
- {{&WifiDirectAuthType_names[24], 25}, 1},
- {{&WifiDirectAuthType_names[49], 20}, 2},
+ {{&WifiDirectAuthType_names[24], 28}, 3},
+ {{&WifiDirectAuthType_names[52], 25}, 1},
+ {{&WifiDirectAuthType_names[77], 20}, 2},
};
static const int WifiDirectAuthType_entries_by_number[] = {
0, // 0 -> WIFI_DIRECT_TYPE_UNKNOWN
- 1, // 1 -> WIFI_DIRECT_WITH_PASSWORD
- 2, // 2 -> WIFI_DIRECT_WITH_PIN
+ 2, // 1 -> WIFI_DIRECT_WITH_PASSWORD
+ 3, // 2 -> WIFI_DIRECT_WITH_PIN
+ 1, // 3 -> WIFI_DIRECT_WITH_DEVICE_NAME
};
const ::std::string& WifiDirectAuthType_Name(WifiDirectAuthType value) {
static const bool kDummy = ::google::protobuf::internal::InitializeEnumStrings(
- WifiDirectAuthType_entries, WifiDirectAuthType_entries_by_number, 3,
+ WifiDirectAuthType_entries, WifiDirectAuthType_entries_by_number, 4,
WifiDirectAuthType_strings);
(void)kDummy;
int idx = ::google::protobuf::internal::LookUpEnumName(WifiDirectAuthType_entries,
WifiDirectAuthType_entries_by_number,
- 3, value);
+ 4, value);
return idx == -1 ? ::google::protobuf::internal::GetEmptyString() : WifiDirectAuthType_strings[idx].get();
}
bool WifiDirectAuthType_Parse(::absl::string_view name, WifiDirectAuthType* PROTOBUF_NONNULL value) {
int int_value;
bool success = ::google::protobuf::internal::LookUpEnumValue(
- WifiDirectAuthType_entries, 3, name, &int_value);
+ WifiDirectAuthType_entries, 4, name, &int_value);
if (success) {
*value = static_cast(int_value);
}
@@ -1352,9 +1355,9 @@ bool OperationResultCategory_Parse(::absl::string_view name, OperationResultCate
return success;
}
PROTOBUF_CONSTINIT const uint32_t OperationResultCode_internal_data_[] = {
- 131072u, 5024u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4294705152u, 4095u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1984u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4227858432u, 4294967295u, 1023u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4294950912u, 2097151u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 524284u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4290772992u, 31u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4294966272u, 4294967295u, 4294967295u, 33554431u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4294705152u, 4294967295u, 4294967295u, 4294967295u, 7u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 2147483584u, };
+ 131072u, 5088u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4294705152u, 4095u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1984u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4227858432u, 4294967295u, 1023u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4294950912u, 2097151u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 524284u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4290772992u, 31u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4294966272u, 4294967295u, 4294967295u, 33554431u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4294705152u, 4294967295u, 4294967295u, 4294967295u, 7u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 4294967232u, 4294967295u, 15u, };
static ::google::protobuf::internal::ExplicitlyConstructed<::std::string>
- OperationResultCode_strings[401] = {};
+ OperationResultCode_strings[438] = {};
static const char OperationResultCode_names[] = {
"CLIENT_ALREADY_CONNECTED_TO_ENDPOINT"
@@ -1537,6 +1540,7 @@ static const char OperationResultCode_names[] = {
"DCT_ERROR_BLE_DISABLED"
"DCT_ERROR_BLE_SCAN_FAILED"
"DCT_ERROR_CAPABILITY_MISMATCH"
+ "DCT_ERROR_CHECKIN_FAILURE"
"DCT_ERROR_CONTROL_MESSAGE_EXCHANGE"
"DCT_ERROR_ESTABLISHED_CONNECTION_LOST"
"DCT_ERROR_HIGH_SPEED_MEDIUM_UNAVAILABLE"
@@ -1545,14 +1549,50 @@ static const char OperationResultCode_names[] = {
"DCT_ERROR_KEEPALIVE_TIMEOUT"
"DCT_ERROR_L2CAP_CLIENT_FAILED"
"DCT_ERROR_L2CAP_SERVER_FAILED"
+ "DCT_ERROR_LOCAL_ATTESTATION_PLAY_INTEGRITY_UNAVAILABLE"
+ "DCT_ERROR_LOCAL_ATTESTATION_TIMEOUT"
"DCT_ERROR_MDNS_DISCOVERY_TIMEOUT"
"DCT_ERROR_MDNS_REGISTER_SERVICE"
+ "DCT_ERROR_PARALLEL_ATTESTATION_TIMEOUT"
+ "DCT_ERROR_REMOTE_ATTESTATION_APPLE_INTEGRITY_UNAVAILABLE"
+ "DCT_ERROR_REMOTE_ATTESTATION_HASH_TOO_SHORT"
+ "DCT_ERROR_REMOTE_ATTESTATION_NULL_PACKET"
+ "DCT_ERROR_REMOTE_ATTESTATION_STATUS_NOT_AVAILABLE"
+ "DCT_ERROR_REMOTE_ATTESTATION_TIMEOUT"
+ "DCT_ERROR_REMOTE_CAPABILITY_MISMATCH"
+ "DCT_ERROR_REMOTE_CONTROL_MESSAGE_EXCHANGE"
+ "DCT_ERROR_REMOTE_HIGH_SPEED_MEDIUM_UNAVAILABLE"
+ "DCT_ERROR_REMOTE_MDNS_DISCOVERY_TIMEOUT"
+ "DCT_ERROR_REMOTE_MDNS_REGISTER_SERVICE"
+ "DCT_ERROR_REMOTE_REQUEST_FAILED"
+ "DCT_ERROR_REMOTE_RESPONSE_FAILED"
+ "DCT_ERROR_REMOTE_SERVICE_CANCELLED"
+ "DCT_ERROR_REMOTE_UNVERIFIED_INTEGRITY"
+ "DCT_ERROR_REMOTE_UPGRADE_HIGH_SPEED_MEDIUM_FAILED"
+ "DCT_ERROR_REMOTE_USER_CANCELLED"
+ "DCT_ERROR_REMOTE_WIFI_CREDENTIAL_TRANSFER"
+ "DCT_ERROR_REMOTE_WIFI_DISABLED"
+ "DCT_ERROR_REMOTE_WIFI_DISCONNECTED"
+ "DCT_ERROR_REMOTE_WIFI_INTERNET_CONNECTION"
"DCT_ERROR_REQUEST_FAILED"
"DCT_ERROR_RESPONSE_FAILED"
"DCT_ERROR_SERVICE_CANCELLED"
"DCT_ERROR_SUBSEQUENT_TLS_SPAKE"
"DCT_ERROR_UNVERIFIED_INTEGRITY"
"DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED"
+ "DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_CONNECTION"
+ "DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_HOST_NETWORK_NOT_AVAILABLE"
+ "DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_HOST_NOT_STARTED"
+ "DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_INTERRUPTED"
+ "DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_LOW_SPEED"
+ "DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_MDNS_DISCOVERY_NOT_STARTED"
+ "DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_MEDIUM_NEGOTIATION"
+ "DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_NO_INCOMING_HTTP_CONNECTION"
+ "DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_NO_MEDIUM"
+ "DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_USB_NETWORK_NOT_STARTED"
+ "DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_USB_NOT_HOST"
+ "DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_USB_NOT_PLUGGED"
+ "DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_USB_NO_CONNECTED_DEVICE"
"DCT_ERROR_USER_CANCELLED"
"DCT_ERROR_WIFI_CREDENTIAL_TRANSFER"
"DCT_ERROR_WIFI_DISABLED"
@@ -1941,232 +1981,269 @@ static const ::google::protobuf::internal::EnumEntry OperationResultCode_entries
{{&OperationResultCode_names[8024], 22}, 5000},
{{&OperationResultCode_names[8046], 25}, 5002},
{{&OperationResultCode_names[8071], 29}, 5012},
- {{&OperationResultCode_names[8100], 34}, 5011},
- {{&OperationResultCode_names[8134], 37}, 5020},
- {{&OperationResultCode_names[8171], 39}, 5013},
- {{&OperationResultCode_names[8210], 28}, 5024},
- {{&OperationResultCode_names[8238], 27}, 5007},
- {{&OperationResultCode_names[8265], 27}, 5019},
- {{&OperationResultCode_names[8292], 29}, 5004},
- {{&OperationResultCode_names[8321], 29}, 5003},
- {{&OperationResultCode_names[8350], 32}, 5005},
- {{&OperationResultCode_names[8382], 31}, 5006},
- {{&OperationResultCode_names[8413], 24}, 5009},
- {{&OperationResultCode_names[8437], 25}, 5010},
- {{&OperationResultCode_names[8462], 27}, 5022},
- {{&OperationResultCode_names[8489], 30}, 5008},
- {{&OperationResultCode_names[8519], 30}, 5023},
- {{&OperationResultCode_names[8549], 42}, 5018},
- {{&OperationResultCode_names[8591], 24}, 5021},
- {{&OperationResultCode_names[8615], 34}, 5016},
- {{&OperationResultCode_names[8649], 23}, 5014},
- {{&OperationResultCode_names[8672], 27}, 5015},
- {{&OperationResultCode_names[8699], 34}, 5017},
- {{&OperationResultCode_names[8733], 14}, 1},
- {{&OperationResultCode_names[8747], 14}, 0},
- {{&OperationResultCode_names[8761], 46}, 1000},
- {{&OperationResultCode_names[8807], 39}, 1001},
- {{&OperationResultCode_names[8846], 30}, 1002},
- {{&OperationResultCode_names[8876], 36}, 1003},
- {{&OperationResultCode_names[8912], 35}, 1004},
- {{&OperationResultCode_names[8947], 27}, 3005},
- {{&OperationResultCode_names[8974], 33}, 3006},
- {{&OperationResultCode_names[9007], 26}, 3007},
- {{&OperationResultCode_names[9033], 27}, 3009},
- {{&OperationResultCode_names[9060], 27}, 3013},
- {{&OperationResultCode_names[9087], 27}, 3014},
- {{&OperationResultCode_names[9114], 31}, 3008},
- {{&OperationResultCode_names[9145], 34}, 3012},
- {{&OperationResultCode_names[9179], 35}, 3010},
- {{&OperationResultCode_names[9214], 36}, 3011},
- {{&OperationResultCode_names[9250], 21}, 3000},
- {{&OperationResultCode_names[9271], 21}, 3001},
- {{&OperationResultCode_names[9292], 21}, 3002},
- {{&OperationResultCode_names[9313], 24}, 3003},
- {{&OperationResultCode_names[9337], 29}, 3004},
- {{&OperationResultCode_names[9366], 51}, 1534},
- {{&OperationResultCode_names[9417], 60}, 1535},
- {{&OperationResultCode_names[9477], 37}, 1547},
- {{&OperationResultCode_names[9514], 47}, 1515},
- {{&OperationResultCode_names[9561], 36}, 1505},
- {{&OperationResultCode_names[9597], 42}, 1507},
- {{&OperationResultCode_names[9639], 40}, 1546},
- {{&OperationResultCode_names[9679], 46}, 1516},
- {{&OperationResultCode_names[9725], 45}, 1501},
- {{&OperationResultCode_names[9770], 45}, 1541},
- {{&OperationResultCode_names[9815], 38}, 1506},
- {{&OperationResultCode_names[9853], 30}, 1544},
- {{&OperationResultCode_names[9883], 47}, 1517},
- {{&OperationResultCode_names[9930], 36}, 1513},
- {{&OperationResultCode_names[9966], 54}, 1532},
- {{&OperationResultCode_names[10020], 49}, 1503},
- {{&OperationResultCode_names[10069], 52}, 1504},
- {{&OperationResultCode_names[10121], 37}, 1543},
- {{&OperationResultCode_names[10158], 47}, 1518},
- {{&OperationResultCode_names[10205], 36}, 1512},
- {{&OperationResultCode_names[10241], 36}, 1542},
- {{&OperationResultCode_names[10277], 30}, 1545},
- {{&OperationResultCode_names[10307], 60}, 1536},
- {{&OperationResultCode_names[10367], 43}, 1533},
- {{&OperationResultCode_names[10410], 38}, 1502},
- {{&OperationResultCode_names[10448], 39}, 1539},
- {{&OperationResultCode_names[10487], 37}, 1540},
- {{&OperationResultCode_names[10524], 41}, 1537},
- {{&OperationResultCode_names[10565], 55}, 1526},
- {{&OperationResultCode_names[10620], 54}, 1530},
- {{&OperationResultCode_names[10674], 57}, 1527},
- {{&OperationResultCode_names[10731], 55}, 1529},
- {{&OperationResultCode_names[10786], 55}, 1531},
- {{&OperationResultCode_names[10841], 59}, 1528},
- {{&OperationResultCode_names[10900], 47}, 1519},
- {{&OperationResultCode_names[10947], 36}, 1514},
- {{&OperationResultCode_names[10983], 51}, 1520},
- {{&OperationResultCode_names[11034], 40}, 1508},
- {{&OperationResultCode_names[11074], 38}, 1538},
- {{&OperationResultCode_names[11112], 54}, 1521},
- {{&OperationResultCode_names[11166], 43}, 1509},
- {{&OperationResultCode_names[11209], 52}, 1500},
- {{&OperationResultCode_names[11261], 55}, 1523},
- {{&OperationResultCode_names[11316], 44}, 1511},
- {{&OperationResultCode_names[11360], 57}, 1525},
- {{&OperationResultCode_names[11417], 56}, 1522},
- {{&OperationResultCode_names[11473], 45}, 1510},
- {{&OperationResultCode_names[11518], 58}, 1524},
- {{&OperationResultCode_names[11576], 38}, 2503},
- {{&OperationResultCode_names[11614], 51}, 2514},
- {{&OperationResultCode_names[11665], 41}, 2500},
- {{&OperationResultCode_names[11706], 59}, 2510},
- {{&OperationResultCode_names[11765], 37}, 2505},
- {{&OperationResultCode_names[11802], 40}, 2504},
- {{&OperationResultCode_names[11842], 33}, 2501},
- {{&OperationResultCode_names[11875], 48}, 2513},
- {{&OperationResultCode_names[11923], 52}, 2511},
- {{&OperationResultCode_names[11975], 38}, 2515},
- {{&OperationResultCode_names[12013], 55}, 2512},
- {{&OperationResultCode_names[12068], 45}, 2506},
- {{&OperationResultCode_names[12113], 46}, 2507},
- {{&OperationResultCode_names[12159], 56}, 2502},
- {{&OperationResultCode_names[12215], 47}, 2509},
- {{&OperationResultCode_names[12262], 43}, 2508},
- {{&OperationResultCode_names[12305], 31}, 2516},
- {{&OperationResultCode_names[12336], 29}, 4568},
- {{&OperationResultCode_names[12365], 38}, 4611},
- {{&OperationResultCode_names[12403], 45}, 4612},
- {{&OperationResultCode_names[12448], 60}, 4609},
- {{&OperationResultCode_names[12508], 45}, 4500},
- {{&OperationResultCode_names[12553], 37}, 4571},
- {{&OperationResultCode_names[12590], 44}, 4504},
- {{&OperationResultCode_names[12634], 42}, 4572},
- {{&OperationResultCode_names[12676], 49}, 4515},
- {{&OperationResultCode_names[12725], 29}, 4518},
- {{&OperationResultCode_names[12754], 30}, 4579},
- {{&OperationResultCode_names[12784], 38}, 4536},
- {{&OperationResultCode_names[12822], 43}, 4570},
- {{&OperationResultCode_names[12865], 36}, 4578},
- {{&OperationResultCode_names[12901], 48}, 4501},
- {{&OperationResultCode_names[12949], 44}, 4585},
- {{&OperationResultCode_names[12993], 35}, 4592},
- {{&OperationResultCode_names[13028], 43}, 4506},
- {{&OperationResultCode_names[13071], 35}, 4530},
- {{&OperationResultCode_names[13106], 23}, 4520},
- {{&OperationResultCode_names[13129], 37}, 4538},
- {{&OperationResultCode_names[13166], 41}, 4563},
- {{&OperationResultCode_names[13207], 37}, 4602},
- {{&OperationResultCode_names[13244], 31}, 4610},
- {{&OperationResultCode_names[13275], 38}, 4606},
- {{&OperationResultCode_names[13313], 37}, 4591},
- {{&OperationResultCode_names[13350], 25}, 4567},
- {{&OperationResultCode_names[13375], 27}, 4605},
- {{&OperationResultCode_names[13402], 32}, 4503},
- {{&OperationResultCode_names[13434], 35}, 4514},
- {{&OperationResultCode_names[13469], 48}, 4588},
- {{&OperationResultCode_names[13517], 45}, 4552},
- {{&OperationResultCode_names[13562], 40}, 4532},
- {{&OperationResultCode_names[13602], 40}, 4535},
- {{&OperationResultCode_names[13642], 48}, 4547},
- {{&OperationResultCode_names[13690], 60}, 4556},
- {{&OperationResultCode_names[13750], 56}, 4558},
- {{&OperationResultCode_names[13806], 60}, 4557},
- {{&OperationResultCode_names[13866], 56}, 4553},
- {{&OperationResultCode_names[13922], 52}, 4555},
- {{&OperationResultCode_names[13974], 56}, 4554},
- {{&OperationResultCode_names[14030], 43}, 4559},
- {{&OperationResultCode_names[14073], 43}, 4560},
- {{&OperationResultCode_names[14116], 37}, 4561},
- {{&OperationResultCode_names[14153], 41}, 4562},
- {{&OperationResultCode_names[14194], 49}, 4586},
- {{&OperationResultCode_names[14243], 46}, 4505},
- {{&OperationResultCode_names[14289], 26}, 4519},
- {{&OperationResultCode_names[14315], 40}, 4537},
- {{&OperationResultCode_names[14355], 29}, 4566},
- {{&OperationResultCode_names[14384], 44}, 4507},
- {{&OperationResultCode_names[14428], 36}, 4531},
- {{&OperationResultCode_names[14464], 24}, 4525},
- {{&OperationResultCode_names[14488], 38}, 4539},
- {{&OperationResultCode_names[14526], 41}, 4593},
- {{&OperationResultCode_names[14567], 28}, 4594},
- {{&OperationResultCode_names[14595], 42}, 4564},
- {{&OperationResultCode_names[14637], 30}, 4569},
- {{&OperationResultCode_names[14667], 31}, 4607},
- {{&OperationResultCode_names[14698], 27}, 4587},
- {{&OperationResultCode_names[14725], 37}, 4573},
- {{&OperationResultCode_names[14762], 44}, 4508},
- {{&OperationResultCode_names[14806], 30}, 4577},
- {{&OperationResultCode_names[14836], 24}, 4522},
- {{&OperationResultCode_names[14860], 35}, 4601},
- {{&OperationResultCode_names[14895], 56}, 4608},
- {{&OperationResultCode_names[14951], 29}, 4603},
- {{&OperationResultCode_names[14980], 28}, 4604},
- {{&OperationResultCode_names[15008], 35}, 4590},
- {{&OperationResultCode_names[15043], 37}, 4576},
- {{&OperationResultCode_names[15080], 44}, 4513},
- {{&OperationResultCode_names[15124], 30}, 4582},
- {{&OperationResultCode_names[15154], 24}, 4521},
- {{&OperationResultCode_names[15178], 30}, 4583},
- {{&OperationResultCode_names[15208], 35}, 4502},
- {{&OperationResultCode_names[15243], 48}, 4512},
- {{&OperationResultCode_names[15291], 34}, 4584},
- {{&OperationResultCode_names[15325], 38}, 4589},
- {{&OperationResultCode_names[15363], 28}, 4524},
- {{&OperationResultCode_names[15391], 42}, 4540},
- {{&OperationResultCode_names[15433], 37}, 4599},
- {{&OperationResultCode_names[15470], 44}, 4575},
- {{&OperationResultCode_names[15514], 51}, 4509},
- {{&OperationResultCode_names[15565], 37}, 4581},
- {{&OperationResultCode_names[15602], 31}, 4523},
- {{&OperationResultCode_names[15633], 45}, 4541},
- {{&OperationResultCode_names[15678], 42}, 4600},
- {{&OperationResultCode_names[15720], 52}, 4511},
- {{&OperationResultCode_names[15772], 39}, 4516},
- {{&OperationResultCode_names[15811], 41}, 4533},
- {{&OperationResultCode_names[15852], 32}, 4527},
- {{&OperationResultCode_names[15884], 32}, 4529},
- {{&OperationResultCode_names[15916], 28}, 4528},
- {{&OperationResultCode_names[15944], 46}, 4546},
- {{&OperationResultCode_names[15990], 48}, 4549},
- {{&OperationResultCode_names[16038], 48}, 4551},
- {{&OperationResultCode_names[16086], 51}, 4596},
- {{&OperationResultCode_names[16137], 43}, 4595},
- {{&OperationResultCode_names[16180], 54}, 4545},
- {{&OperationResultCode_names[16234], 54}, 4542},
- {{&OperationResultCode_names[16288], 53}, 4510},
- {{&OperationResultCode_names[16341], 40}, 4517},
- {{&OperationResultCode_names[16381], 52}, 4544},
- {{&OperationResultCode_names[16433], 44}, 4534},
- {{&OperationResultCode_names[16477], 33}, 4526},
- {{&OperationResultCode_names[16510], 49}, 4548},
- {{&OperationResultCode_names[16559], 49}, 4550},
- {{&OperationResultCode_names[16608], 52}, 4598},
- {{&OperationResultCode_names[16660], 44}, 4597},
- {{&OperationResultCode_names[16704], 55}, 4543},
- {{&OperationResultCode_names[16759], 42}, 4574},
- {{&OperationResultCode_names[16801], 35}, 4580},
- {{&OperationResultCode_names[16836], 32}, 4565},
+ {{&OperationResultCode_names[8100], 25}, 5025},
+ {{&OperationResultCode_names[8125], 34}, 5011},
+ {{&OperationResultCode_names[8159], 37}, 5020},
+ {{&OperationResultCode_names[8196], 39}, 5013},
+ {{&OperationResultCode_names[8235], 28}, 5024},
+ {{&OperationResultCode_names[8263], 27}, 5007},
+ {{&OperationResultCode_names[8290], 27}, 5019},
+ {{&OperationResultCode_names[8317], 29}, 5004},
+ {{&OperationResultCode_names[8346], 29}, 5003},
+ {{&OperationResultCode_names[8375], 54}, 5031},
+ {{&OperationResultCode_names[8429], 35}, 5032},
+ {{&OperationResultCode_names[8464], 32}, 5005},
+ {{&OperationResultCode_names[8496], 31}, 5006},
+ {{&OperationResultCode_names[8527], 38}, 5033},
+ {{&OperationResultCode_names[8565], 56}, 5030},
+ {{&OperationResultCode_names[8621], 43}, 5029},
+ {{&OperationResultCode_names[8664], 40}, 5027},
+ {{&OperationResultCode_names[8704], 49}, 5028},
+ {{&OperationResultCode_names[8753], 36}, 5026},
+ {{&OperationResultCode_names[8789], 36}, 5039},
+ {{&OperationResultCode_names[8825], 41}, 5038},
+ {{&OperationResultCode_names[8866], 46}, 5040},
+ {{&OperationResultCode_names[8912], 39}, 5034},
+ {{&OperationResultCode_names[8951], 38}, 5035},
+ {{&OperationResultCode_names[8989], 31}, 5036},
+ {{&OperationResultCode_names[9020], 32}, 5037},
+ {{&OperationResultCode_names[9052], 34}, 5047},
+ {{&OperationResultCode_names[9086], 37}, 5048},
+ {{&OperationResultCode_names[9123], 49}, 5045},
+ {{&OperationResultCode_names[9172], 31}, 5046},
+ {{&OperationResultCode_names[9203], 41}, 5043},
+ {{&OperationResultCode_names[9244], 30}, 5041},
+ {{&OperationResultCode_names[9274], 34}, 5042},
+ {{&OperationResultCode_names[9308], 41}, 5044},
+ {{&OperationResultCode_names[9349], 24}, 5009},
+ {{&OperationResultCode_names[9373], 25}, 5010},
+ {{&OperationResultCode_names[9398], 27}, 5022},
+ {{&OperationResultCode_names[9425], 30}, 5008},
+ {{&OperationResultCode_names[9455], 30}, 5023},
+ {{&OperationResultCode_names[9485], 42}, 5018},
+ {{&OperationResultCode_names[9527], 53}, 5050},
+ {{&OperationResultCode_names[9580], 69}, 5058},
+ {{&OperationResultCode_names[9649], 59}, 5057},
+ {{&OperationResultCode_names[9708], 54}, 5061},
+ {{&OperationResultCode_names[9762], 52}, 5049},
+ {{&OperationResultCode_names[9814], 69}, 5053},
+ {{&OperationResultCode_names[9883], 61}, 5056},
+ {{&OperationResultCode_names[9944], 70}, 5059},
+ {{&OperationResultCode_names[10014], 52}, 5054},
+ {{&OperationResultCode_names[10066], 66}, 5055},
+ {{&OperationResultCode_names[10132], 55}, 5052},
+ {{&OperationResultCode_names[10187], 58}, 5051},
+ {{&OperationResultCode_names[10245], 66}, 5060},
+ {{&OperationResultCode_names[10311], 24}, 5021},
+ {{&OperationResultCode_names[10335], 34}, 5016},
+ {{&OperationResultCode_names[10369], 23}, 5014},
+ {{&OperationResultCode_names[10392], 27}, 5015},
+ {{&OperationResultCode_names[10419], 34}, 5017},
+ {{&OperationResultCode_names[10453], 14}, 1},
+ {{&OperationResultCode_names[10467], 14}, 0},
+ {{&OperationResultCode_names[10481], 46}, 1000},
+ {{&OperationResultCode_names[10527], 39}, 1001},
+ {{&OperationResultCode_names[10566], 30}, 1002},
+ {{&OperationResultCode_names[10596], 36}, 1003},
+ {{&OperationResultCode_names[10632], 35}, 1004},
+ {{&OperationResultCode_names[10667], 27}, 3005},
+ {{&OperationResultCode_names[10694], 33}, 3006},
+ {{&OperationResultCode_names[10727], 26}, 3007},
+ {{&OperationResultCode_names[10753], 27}, 3009},
+ {{&OperationResultCode_names[10780], 27}, 3013},
+ {{&OperationResultCode_names[10807], 27}, 3014},
+ {{&OperationResultCode_names[10834], 31}, 3008},
+ {{&OperationResultCode_names[10865], 34}, 3012},
+ {{&OperationResultCode_names[10899], 35}, 3010},
+ {{&OperationResultCode_names[10934], 36}, 3011},
+ {{&OperationResultCode_names[10970], 21}, 3000},
+ {{&OperationResultCode_names[10991], 21}, 3001},
+ {{&OperationResultCode_names[11012], 21}, 3002},
+ {{&OperationResultCode_names[11033], 24}, 3003},
+ {{&OperationResultCode_names[11057], 29}, 3004},
+ {{&OperationResultCode_names[11086], 51}, 1534},
+ {{&OperationResultCode_names[11137], 60}, 1535},
+ {{&OperationResultCode_names[11197], 37}, 1547},
+ {{&OperationResultCode_names[11234], 47}, 1515},
+ {{&OperationResultCode_names[11281], 36}, 1505},
+ {{&OperationResultCode_names[11317], 42}, 1507},
+ {{&OperationResultCode_names[11359], 40}, 1546},
+ {{&OperationResultCode_names[11399], 46}, 1516},
+ {{&OperationResultCode_names[11445], 45}, 1501},
+ {{&OperationResultCode_names[11490], 45}, 1541},
+ {{&OperationResultCode_names[11535], 38}, 1506},
+ {{&OperationResultCode_names[11573], 30}, 1544},
+ {{&OperationResultCode_names[11603], 47}, 1517},
+ {{&OperationResultCode_names[11650], 36}, 1513},
+ {{&OperationResultCode_names[11686], 54}, 1532},
+ {{&OperationResultCode_names[11740], 49}, 1503},
+ {{&OperationResultCode_names[11789], 52}, 1504},
+ {{&OperationResultCode_names[11841], 37}, 1543},
+ {{&OperationResultCode_names[11878], 47}, 1518},
+ {{&OperationResultCode_names[11925], 36}, 1512},
+ {{&OperationResultCode_names[11961], 36}, 1542},
+ {{&OperationResultCode_names[11997], 30}, 1545},
+ {{&OperationResultCode_names[12027], 60}, 1536},
+ {{&OperationResultCode_names[12087], 43}, 1533},
+ {{&OperationResultCode_names[12130], 38}, 1502},
+ {{&OperationResultCode_names[12168], 39}, 1539},
+ {{&OperationResultCode_names[12207], 37}, 1540},
+ {{&OperationResultCode_names[12244], 41}, 1537},
+ {{&OperationResultCode_names[12285], 55}, 1526},
+ {{&OperationResultCode_names[12340], 54}, 1530},
+ {{&OperationResultCode_names[12394], 57}, 1527},
+ {{&OperationResultCode_names[12451], 55}, 1529},
+ {{&OperationResultCode_names[12506], 55}, 1531},
+ {{&OperationResultCode_names[12561], 59}, 1528},
+ {{&OperationResultCode_names[12620], 47}, 1519},
+ {{&OperationResultCode_names[12667], 36}, 1514},
+ {{&OperationResultCode_names[12703], 51}, 1520},
+ {{&OperationResultCode_names[12754], 40}, 1508},
+ {{&OperationResultCode_names[12794], 38}, 1538},
+ {{&OperationResultCode_names[12832], 54}, 1521},
+ {{&OperationResultCode_names[12886], 43}, 1509},
+ {{&OperationResultCode_names[12929], 52}, 1500},
+ {{&OperationResultCode_names[12981], 55}, 1523},
+ {{&OperationResultCode_names[13036], 44}, 1511},
+ {{&OperationResultCode_names[13080], 57}, 1525},
+ {{&OperationResultCode_names[13137], 56}, 1522},
+ {{&OperationResultCode_names[13193], 45}, 1510},
+ {{&OperationResultCode_names[13238], 58}, 1524},
+ {{&OperationResultCode_names[13296], 38}, 2503},
+ {{&OperationResultCode_names[13334], 51}, 2514},
+ {{&OperationResultCode_names[13385], 41}, 2500},
+ {{&OperationResultCode_names[13426], 59}, 2510},
+ {{&OperationResultCode_names[13485], 37}, 2505},
+ {{&OperationResultCode_names[13522], 40}, 2504},
+ {{&OperationResultCode_names[13562], 33}, 2501},
+ {{&OperationResultCode_names[13595], 48}, 2513},
+ {{&OperationResultCode_names[13643], 52}, 2511},
+ {{&OperationResultCode_names[13695], 38}, 2515},
+ {{&OperationResultCode_names[13733], 55}, 2512},
+ {{&OperationResultCode_names[13788], 45}, 2506},
+ {{&OperationResultCode_names[13833], 46}, 2507},
+ {{&OperationResultCode_names[13879], 56}, 2502},
+ {{&OperationResultCode_names[13935], 47}, 2509},
+ {{&OperationResultCode_names[13982], 43}, 2508},
+ {{&OperationResultCode_names[14025], 31}, 2516},
+ {{&OperationResultCode_names[14056], 29}, 4568},
+ {{&OperationResultCode_names[14085], 38}, 4611},
+ {{&OperationResultCode_names[14123], 45}, 4612},
+ {{&OperationResultCode_names[14168], 60}, 4609},
+ {{&OperationResultCode_names[14228], 45}, 4500},
+ {{&OperationResultCode_names[14273], 37}, 4571},
+ {{&OperationResultCode_names[14310], 44}, 4504},
+ {{&OperationResultCode_names[14354], 42}, 4572},
+ {{&OperationResultCode_names[14396], 49}, 4515},
+ {{&OperationResultCode_names[14445], 29}, 4518},
+ {{&OperationResultCode_names[14474], 30}, 4579},
+ {{&OperationResultCode_names[14504], 38}, 4536},
+ {{&OperationResultCode_names[14542], 43}, 4570},
+ {{&OperationResultCode_names[14585], 36}, 4578},
+ {{&OperationResultCode_names[14621], 48}, 4501},
+ {{&OperationResultCode_names[14669], 44}, 4585},
+ {{&OperationResultCode_names[14713], 35}, 4592},
+ {{&OperationResultCode_names[14748], 43}, 4506},
+ {{&OperationResultCode_names[14791], 35}, 4530},
+ {{&OperationResultCode_names[14826], 23}, 4520},
+ {{&OperationResultCode_names[14849], 37}, 4538},
+ {{&OperationResultCode_names[14886], 41}, 4563},
+ {{&OperationResultCode_names[14927], 37}, 4602},
+ {{&OperationResultCode_names[14964], 31}, 4610},
+ {{&OperationResultCode_names[14995], 38}, 4606},
+ {{&OperationResultCode_names[15033], 37}, 4591},
+ {{&OperationResultCode_names[15070], 25}, 4567},
+ {{&OperationResultCode_names[15095], 27}, 4605},
+ {{&OperationResultCode_names[15122], 32}, 4503},
+ {{&OperationResultCode_names[15154], 35}, 4514},
+ {{&OperationResultCode_names[15189], 48}, 4588},
+ {{&OperationResultCode_names[15237], 45}, 4552},
+ {{&OperationResultCode_names[15282], 40}, 4532},
+ {{&OperationResultCode_names[15322], 40}, 4535},
+ {{&OperationResultCode_names[15362], 48}, 4547},
+ {{&OperationResultCode_names[15410], 60}, 4556},
+ {{&OperationResultCode_names[15470], 56}, 4558},
+ {{&OperationResultCode_names[15526], 60}, 4557},
+ {{&OperationResultCode_names[15586], 56}, 4553},
+ {{&OperationResultCode_names[15642], 52}, 4555},
+ {{&OperationResultCode_names[15694], 56}, 4554},
+ {{&OperationResultCode_names[15750], 43}, 4559},
+ {{&OperationResultCode_names[15793], 43}, 4560},
+ {{&OperationResultCode_names[15836], 37}, 4561},
+ {{&OperationResultCode_names[15873], 41}, 4562},
+ {{&OperationResultCode_names[15914], 49}, 4586},
+ {{&OperationResultCode_names[15963], 46}, 4505},
+ {{&OperationResultCode_names[16009], 26}, 4519},
+ {{&OperationResultCode_names[16035], 40}, 4537},
+ {{&OperationResultCode_names[16075], 29}, 4566},
+ {{&OperationResultCode_names[16104], 44}, 4507},
+ {{&OperationResultCode_names[16148], 36}, 4531},
+ {{&OperationResultCode_names[16184], 24}, 4525},
+ {{&OperationResultCode_names[16208], 38}, 4539},
+ {{&OperationResultCode_names[16246], 41}, 4593},
+ {{&OperationResultCode_names[16287], 28}, 4594},
+ {{&OperationResultCode_names[16315], 42}, 4564},
+ {{&OperationResultCode_names[16357], 30}, 4569},
+ {{&OperationResultCode_names[16387], 31}, 4607},
+ {{&OperationResultCode_names[16418], 27}, 4587},
+ {{&OperationResultCode_names[16445], 37}, 4573},
+ {{&OperationResultCode_names[16482], 44}, 4508},
+ {{&OperationResultCode_names[16526], 30}, 4577},
+ {{&OperationResultCode_names[16556], 24}, 4522},
+ {{&OperationResultCode_names[16580], 35}, 4601},
+ {{&OperationResultCode_names[16615], 56}, 4608},
+ {{&OperationResultCode_names[16671], 29}, 4603},
+ {{&OperationResultCode_names[16700], 28}, 4604},
+ {{&OperationResultCode_names[16728], 35}, 4590},
+ {{&OperationResultCode_names[16763], 37}, 4576},
+ {{&OperationResultCode_names[16800], 44}, 4513},
+ {{&OperationResultCode_names[16844], 30}, 4582},
+ {{&OperationResultCode_names[16874], 24}, 4521},
+ {{&OperationResultCode_names[16898], 30}, 4583},
+ {{&OperationResultCode_names[16928], 35}, 4502},
+ {{&OperationResultCode_names[16963], 48}, 4512},
+ {{&OperationResultCode_names[17011], 34}, 4584},
+ {{&OperationResultCode_names[17045], 38}, 4589},
+ {{&OperationResultCode_names[17083], 28}, 4524},
+ {{&OperationResultCode_names[17111], 42}, 4540},
+ {{&OperationResultCode_names[17153], 37}, 4599},
+ {{&OperationResultCode_names[17190], 44}, 4575},
+ {{&OperationResultCode_names[17234], 51}, 4509},
+ {{&OperationResultCode_names[17285], 37}, 4581},
+ {{&OperationResultCode_names[17322], 31}, 4523},
+ {{&OperationResultCode_names[17353], 45}, 4541},
+ {{&OperationResultCode_names[17398], 42}, 4600},
+ {{&OperationResultCode_names[17440], 52}, 4511},
+ {{&OperationResultCode_names[17492], 39}, 4516},
+ {{&OperationResultCode_names[17531], 41}, 4533},
+ {{&OperationResultCode_names[17572], 32}, 4527},
+ {{&OperationResultCode_names[17604], 32}, 4529},
+ {{&OperationResultCode_names[17636], 28}, 4528},
+ {{&OperationResultCode_names[17664], 46}, 4546},
+ {{&OperationResultCode_names[17710], 48}, 4549},
+ {{&OperationResultCode_names[17758], 48}, 4551},
+ {{&OperationResultCode_names[17806], 51}, 4596},
+ {{&OperationResultCode_names[17857], 43}, 4595},
+ {{&OperationResultCode_names[17900], 54}, 4545},
+ {{&OperationResultCode_names[17954], 54}, 4542},
+ {{&OperationResultCode_names[18008], 53}, 4510},
+ {{&OperationResultCode_names[18061], 40}, 4517},
+ {{&OperationResultCode_names[18101], 52}, 4544},
+ {{&OperationResultCode_names[18153], 44}, 4534},
+ {{&OperationResultCode_names[18197], 33}, 4526},
+ {{&OperationResultCode_names[18230], 49}, 4548},
+ {{&OperationResultCode_names[18279], 49}, 4550},
+ {{&OperationResultCode_names[18328], 52}, 4598},
+ {{&OperationResultCode_names[18380], 44}, 4597},
+ {{&OperationResultCode_names[18424], 55}, 4543},
+ {{&OperationResultCode_names[18479], 42}, 4574},
+ {{&OperationResultCode_names[18521], 35}, 4580},
+ {{&OperationResultCode_names[18556], 32}, 4565},
};
static const int OperationResultCode_entries_by_number[] = {
- 202, // 0 -> DETAIL_UNKNOWN
- 201, // 1 -> DETAIL_SUCCESS
+ 239, // 0 -> DETAIL_UNKNOWN
+ 238, // 1 -> DETAIL_SUCCESS
28, // 500 -> CLIENT_CANCELLATION_REMOTE_IN_CANCELED_STATE
24, // 501 -> CLIENT_CANCELLATION_LOCAL_CANCEL_PAYLOAD
26, // 502 -> CLIENT_CANCELLATION_REMOTE_CANCEL_PAYLOAD
@@ -2193,59 +2270,59 @@ static const int OperationResultCode_entries_by_number[] = {
27, // 523 -> CLIENT_CANCELLATION_REMOTE_DISCONNECT
9, // 524 -> CLIENT_CANCELLATION_AWDL_SERVER_SOCKET_CREATION
11, // 525 -> CLIENT_CANCELLATION_CANCEL_AWDL_OUTGOING_CONNECTION
- 203, // 1000 -> DEVICE_STATE_ERROR_UNFINISHED_UPGRADE_ATTEMPTS
- 204, // 1001 -> DEVICE_STATE_ERROR_USER_HOTSPOT_ENABLED
- 205, // 1002 -> DEVICE_STATE_LOCATION_DISABLED
- 206, // 1003 -> DEVICE_STATE_RADIO_DISABLING_FAILURE
- 207, // 1004 -> DEVICE_STATE_RADIO_ENABLING_FAILURE
- 264, // 1500 -> MEDIUM_UNAVAILABLE_WIFI_AWARE_RESOURCE_NOT_AVAILABLE
- 231, // 1501 -> MEDIUM_UNAVAILABLE_DIRECT_HOTSPOT_NOT_SUPPORT
- 247, // 1502 -> MEDIUM_UNAVAILABLE_SOFT_AP_NOT_SUPPORT
- 238, // 1503 -> MEDIUM_UNAVAILABLE_LOCAL_ONLY_HOTSPOT_NOT_SUPPORT
- 239, // 1504 -> MEDIUM_UNAVAILABLE_LOCAL_ONLY_HOTSPOT_NOT_SUPPORT_5G
- 227, // 1505 -> MEDIUM_UNAVAILABLE_BLE_NOT_AVAILABLE
- 233, // 1506 -> MEDIUM_UNAVAILABLE_L2CAP_NOT_AVAILABLE
- 228, // 1507 -> MEDIUM_UNAVAILABLE_BLUETOOTH_NOT_AVAILABLE
- 260, // 1508 -> MEDIUM_UNAVAILABLE_WEB_RTC_NOT_AVAILABLE
- 263, // 1509 -> MEDIUM_UNAVAILABLE_WIFI_AWARE_NOT_AVAILABLE
- 269, // 1510 -> MEDIUM_UNAVAILABLE_WIFI_HOTSPOT_NOT_AVAILABLE
- 266, // 1511 -> MEDIUM_UNAVAILABLE_WIFI_DIRECT_NOT_AVAILABLE
- 242, // 1512 -> MEDIUM_UNAVAILABLE_NFC_NOT_AVAILABLE
- 236, // 1513 -> MEDIUM_UNAVAILABLE_LAN_NOT_AVAILABLE
- 258, // 1514 -> MEDIUM_UNAVAILABLE_USB_NOT_AVAILABLE
- 226, // 1515 -> MEDIUM_UNAVAILABLE_BLE_NC_LOGICAL_NOT_AVAILABLE
- 230, // 1516 -> MEDIUM_UNAVAILABLE_BT_NC_LOGICAL_NOT_AVAILABLE
- 235, // 1517 -> MEDIUM_UNAVAILABLE_LAN_NC_LOGICAL_NOT_AVAILABLE
- 241, // 1518 -> MEDIUM_UNAVAILABLE_NFC_NC_LOGICAL_NOT_AVAILABLE
- 257, // 1519 -> MEDIUM_UNAVAILABLE_USB_NC_LOGICAL_NOT_AVAILABLE
- 259, // 1520 -> MEDIUM_UNAVAILABLE_WEB_RTC_NC_LOGICAL_NOT_AVAILABLE
- 262, // 1521 -> MEDIUM_UNAVAILABLE_WIFI_AWARE_NC_LOGICAL_NOT_AVAILABLE
- 268, // 1522 -> MEDIUM_UNAVAILABLE_WIFI_HOTSPOT_NC_LOGICAL_NOT_AVAILABLE
- 265, // 1523 -> MEDIUM_UNAVAILABLE_WIFI_DIRECT_NC_LOGICAL_NOT_AVAILABLE
- 270, // 1524 -> MEDIUM_UNAVAILABLE_WIFI_HOTSPOT_P2P_RESOURCE_NOT_AVAILABLE
- 267, // 1525 -> MEDIUM_UNAVAILABLE_WIFI_DIRECT_P2P_RESOURCE_NOT_AVAILABLE
- 251, // 1526 -> MEDIUM_UNAVAILABLE_UPGRADE_SKIP_BLE_LOW_QUALITY_MEDIUMS
- 253, // 1527 -> MEDIUM_UNAVAILABLE_UPGRADE_SKIP_L2CAP_LOW_QUALITY_MEDIUMS
- 256, // 1528 -> MEDIUM_UNAVAILABLE_UPGRADE_SKIP_WEB_RTC_LOW_QUALITY_MEDIUMS
- 254, // 1529 -> MEDIUM_UNAVAILABLE_UPGRADE_SKIP_LAN_LOW_QUALITY_MEDIUMS
- 252, // 1530 -> MEDIUM_UNAVAILABLE_UPGRADE_SKIP_BT_LOW_QUALITY_MEDIUMS
- 255, // 1531 -> MEDIUM_UNAVAILABLE_UPGRADE_SKIP_USB_LOW_QUALITY_MEDIUMS
- 237, // 1532 -> MEDIUM_UNAVAILABLE_LOCAL_ONLY_HOTSPOT_DISRUPTIVE_FALSE
- 246, // 1533 -> MEDIUM_UNAVAILABLE_SOFT_AP_DISRUPTIVE_FALSE
- 223, // 1534 -> MEDIUM_UNAVAILABLE_ALREADY_HAVE_A_WIFI_DIRECT_GROUP
- 224, // 1535 -> MEDIUM_UNAVAILABLE_ALREADY_HOSTING_HOTSPOT_FOR_OTHER_CLIENTS
- 245, // 1536 -> MEDIUM_UNAVAILABLE_REJECT_L2CAP_ON_GATT_MULTIPLEX_CONNECTION
- 250, // 1537 -> MEDIUM_UNAVAILABLE_UPGRADE_ON_SAME_MEDIUM
- 261, // 1538 -> MEDIUM_UNAVAILABLE_WEB_RTC_NO_INTERNET
- 248, // 1539 -> MEDIUM_UNAVAILABLE_STA_DISRUPTIVE_FALSE
- 249, // 1540 -> MEDIUM_UNAVAILABLE_STA_USER_NOT_ALLOW
- 232, // 1541 -> MEDIUM_UNAVAILABLE_DUPLICATE_FAST_ADVERTISING
- 243, // 1542 -> MEDIUM_UNAVAILABLE_NSD_NOT_AVAILABLE
- 240, // 1543 -> MEDIUM_UNAVAILABLE_MDNS_NOT_AVAILABLE
- 234, // 1544 -> MEDIUM_UNAVAILABLE_LAN_BLOCKED
- 244, // 1545 -> MEDIUM_UNAVAILABLE_POOR_SIGNAL
- 229, // 1546 -> MEDIUM_UNAVAILABLE_BT_MULTIPLEX_DISABLED
- 225, // 1547 -> MEDIUM_UNAVAILABLE_AWDL_NOT_AVAILABLE
+ 240, // 1000 -> DEVICE_STATE_ERROR_UNFINISHED_UPGRADE_ATTEMPTS
+ 241, // 1001 -> DEVICE_STATE_ERROR_USER_HOTSPOT_ENABLED
+ 242, // 1002 -> DEVICE_STATE_LOCATION_DISABLED
+ 243, // 1003 -> DEVICE_STATE_RADIO_DISABLING_FAILURE
+ 244, // 1004 -> DEVICE_STATE_RADIO_ENABLING_FAILURE
+ 301, // 1500 -> MEDIUM_UNAVAILABLE_WIFI_AWARE_RESOURCE_NOT_AVAILABLE
+ 268, // 1501 -> MEDIUM_UNAVAILABLE_DIRECT_HOTSPOT_NOT_SUPPORT
+ 284, // 1502 -> MEDIUM_UNAVAILABLE_SOFT_AP_NOT_SUPPORT
+ 275, // 1503 -> MEDIUM_UNAVAILABLE_LOCAL_ONLY_HOTSPOT_NOT_SUPPORT
+ 276, // 1504 -> MEDIUM_UNAVAILABLE_LOCAL_ONLY_HOTSPOT_NOT_SUPPORT_5G
+ 264, // 1505 -> MEDIUM_UNAVAILABLE_BLE_NOT_AVAILABLE
+ 270, // 1506 -> MEDIUM_UNAVAILABLE_L2CAP_NOT_AVAILABLE
+ 265, // 1507 -> MEDIUM_UNAVAILABLE_BLUETOOTH_NOT_AVAILABLE
+ 297, // 1508 -> MEDIUM_UNAVAILABLE_WEB_RTC_NOT_AVAILABLE
+ 300, // 1509 -> MEDIUM_UNAVAILABLE_WIFI_AWARE_NOT_AVAILABLE
+ 306, // 1510 -> MEDIUM_UNAVAILABLE_WIFI_HOTSPOT_NOT_AVAILABLE
+ 303, // 1511 -> MEDIUM_UNAVAILABLE_WIFI_DIRECT_NOT_AVAILABLE
+ 279, // 1512 -> MEDIUM_UNAVAILABLE_NFC_NOT_AVAILABLE
+ 273, // 1513 -> MEDIUM_UNAVAILABLE_LAN_NOT_AVAILABLE
+ 295, // 1514 -> MEDIUM_UNAVAILABLE_USB_NOT_AVAILABLE
+ 263, // 1515 -> MEDIUM_UNAVAILABLE_BLE_NC_LOGICAL_NOT_AVAILABLE
+ 267, // 1516 -> MEDIUM_UNAVAILABLE_BT_NC_LOGICAL_NOT_AVAILABLE
+ 272, // 1517 -> MEDIUM_UNAVAILABLE_LAN_NC_LOGICAL_NOT_AVAILABLE
+ 278, // 1518 -> MEDIUM_UNAVAILABLE_NFC_NC_LOGICAL_NOT_AVAILABLE
+ 294, // 1519 -> MEDIUM_UNAVAILABLE_USB_NC_LOGICAL_NOT_AVAILABLE
+ 296, // 1520 -> MEDIUM_UNAVAILABLE_WEB_RTC_NC_LOGICAL_NOT_AVAILABLE
+ 299, // 1521 -> MEDIUM_UNAVAILABLE_WIFI_AWARE_NC_LOGICAL_NOT_AVAILABLE
+ 305, // 1522 -> MEDIUM_UNAVAILABLE_WIFI_HOTSPOT_NC_LOGICAL_NOT_AVAILABLE
+ 302, // 1523 -> MEDIUM_UNAVAILABLE_WIFI_DIRECT_NC_LOGICAL_NOT_AVAILABLE
+ 307, // 1524 -> MEDIUM_UNAVAILABLE_WIFI_HOTSPOT_P2P_RESOURCE_NOT_AVAILABLE
+ 304, // 1525 -> MEDIUM_UNAVAILABLE_WIFI_DIRECT_P2P_RESOURCE_NOT_AVAILABLE
+ 288, // 1526 -> MEDIUM_UNAVAILABLE_UPGRADE_SKIP_BLE_LOW_QUALITY_MEDIUMS
+ 290, // 1527 -> MEDIUM_UNAVAILABLE_UPGRADE_SKIP_L2CAP_LOW_QUALITY_MEDIUMS
+ 293, // 1528 -> MEDIUM_UNAVAILABLE_UPGRADE_SKIP_WEB_RTC_LOW_QUALITY_MEDIUMS
+ 291, // 1529 -> MEDIUM_UNAVAILABLE_UPGRADE_SKIP_LAN_LOW_QUALITY_MEDIUMS
+ 289, // 1530 -> MEDIUM_UNAVAILABLE_UPGRADE_SKIP_BT_LOW_QUALITY_MEDIUMS
+ 292, // 1531 -> MEDIUM_UNAVAILABLE_UPGRADE_SKIP_USB_LOW_QUALITY_MEDIUMS
+ 274, // 1532 -> MEDIUM_UNAVAILABLE_LOCAL_ONLY_HOTSPOT_DISRUPTIVE_FALSE
+ 283, // 1533 -> MEDIUM_UNAVAILABLE_SOFT_AP_DISRUPTIVE_FALSE
+ 260, // 1534 -> MEDIUM_UNAVAILABLE_ALREADY_HAVE_A_WIFI_DIRECT_GROUP
+ 261, // 1535 -> MEDIUM_UNAVAILABLE_ALREADY_HOSTING_HOTSPOT_FOR_OTHER_CLIENTS
+ 282, // 1536 -> MEDIUM_UNAVAILABLE_REJECT_L2CAP_ON_GATT_MULTIPLEX_CONNECTION
+ 287, // 1537 -> MEDIUM_UNAVAILABLE_UPGRADE_ON_SAME_MEDIUM
+ 298, // 1538 -> MEDIUM_UNAVAILABLE_WEB_RTC_NO_INTERNET
+ 285, // 1539 -> MEDIUM_UNAVAILABLE_STA_DISRUPTIVE_FALSE
+ 286, // 1540 -> MEDIUM_UNAVAILABLE_STA_USER_NOT_ALLOW
+ 269, // 1541 -> MEDIUM_UNAVAILABLE_DUPLICATE_FAST_ADVERTISING
+ 280, // 1542 -> MEDIUM_UNAVAILABLE_NSD_NOT_AVAILABLE
+ 277, // 1543 -> MEDIUM_UNAVAILABLE_MDNS_NOT_AVAILABLE
+ 271, // 1544 -> MEDIUM_UNAVAILABLE_LAN_BLOCKED
+ 281, // 1545 -> MEDIUM_UNAVAILABLE_POOR_SIGNAL
+ 266, // 1546 -> MEDIUM_UNAVAILABLE_BT_MULTIPLEX_DISABLED
+ 262, // 1547 -> MEDIUM_UNAVAILABLE_AWDL_NOT_AVAILABLE
60, // 2000 -> CLIENT_WIFI_DIRECT_ALREADY_HOSTING_DIRECT_GROUP_FOR_THIS_CLIENT
61, // 2001 -> CLIENT_WIFI_HOTSPOT_ALREADY_HOSTING_HOTSPOT_FOR_THIS_CLIENT
37, // 2002 -> CLIENT_DUPLICATE_ACCEPTING_BLE_CONNECTION_REQUEST
@@ -2285,38 +2362,38 @@ static const int OperationResultCode_entries_by_number[] = {
2, // 2036 -> CLIENT_AWDL_DUPLICATE_ADVERTISING
3, // 2037 -> CLIENT_AWDL_DUPLICATE_DISCOVERING
36, // 2038 -> CLIENT_DUPLICATE_ACCEPTING_AWDL_CONNECTION_REQUEST
- 273, // 2500 -> MISCELLEANEOUS_BLUETOOTH_MAC_ADDRESS_NULL
- 277, // 2501 -> MISCELLEANEOUS_MOVE_TO_NEW_MEDIUM
- 284, // 2502 -> MISCELLEANEOUS_WIFI_HOTSPOT_SOFT_AP_BLOCKED_BY_PROVISION
- 271, // 2503 -> MISCELLEANEOUS_BLE_SYSTEM_SERVICE_NULL
- 276, // 2504 -> MISCELLEANEOUS_L2CAP_SYSTEM_SERVICE_NULL
- 275, // 2505 -> MISCELLEANEOUS_BT_SYSTEM_SERVICE_NULL
- 282, // 2506 -> MISCELLEANEOUS_WIFI_AWARE_SYSTEM_SERVICE_NULL
- 283, // 2507 -> MISCELLEANEOUS_WIFI_DIRECT_SYSTEM_SERVICE_NULL
- 286, // 2508 -> MISCELLEANEOUS_WIFI_LAN_SYSTEM_SERVICE_NULL
- 285, // 2509 -> MISCELLEANEOUS_WIFI_HOTSPOT_SYSTEM_SERVICE_NULL
- 274, // 2510 -> MISCELLEANEOUS_BT_NOT_ACCEPTING_CONNECTION_FOR_WORK_PROFILE
- 279, // 2511 -> MISCELLEANEOUS_WEB_RTC_GET_DROIDGUARD_RESULT_FAILURE
- 281, // 2512 -> MISCELLEANEOUS_WEB_RTC_TACHYON_SIGNALING_MESSENGER_NULL
- 278, // 2513 -> MISCELLEANEOUS_WEB_RTC_FAILED_TO_RECEIVE_MESSAGE
- 272, // 2514 -> MISCELLEANEOUS_BLUETOOTH_CHANGE_DEVICE_NAME_FAILURE
- 280, // 2515 -> MISCELLEANEOUS_WEB_RTC_ICE_SERVER_NULL
- 287, // 2516 -> MISCELLEANEOUS_WORK_SOURCE_NULL
- 218, // 3000 -> IO_FILE_OPENING_ERROR
- 219, // 3001 -> IO_FILE_READING_ERROR
- 220, // 3002 -> IO_FILE_WRITING_ERROR
- 221, // 3003 -> IO_FOLDER_CREATION_ERROR
- 222, // 3004 -> IO_STREAM_CREATE_PIPE_FAILURE
- 208, // 3005 -> IO_ENDPOINT_IO_ERROR_ON_BLE
- 209, // 3006 -> IO_ENDPOINT_IO_ERROR_ON_BLE_L2CAP
- 210, // 3007 -> IO_ENDPOINT_IO_ERROR_ON_BT
- 214, // 3008 -> IO_ENDPOINT_IO_ERROR_ON_WEB_RTC
- 211, // 3009 -> IO_ENDPOINT_IO_ERROR_ON_LAN
- 216, // 3010 -> IO_ENDPOINT_IO_ERROR_ON_WIFI_DIRECT
- 217, // 3011 -> IO_ENDPOINT_IO_ERROR_ON_WIFI_HOTSPOT
- 215, // 3012 -> IO_ENDPOINT_IO_ERROR_ON_WIFI_AWARE
- 212, // 3013 -> IO_ENDPOINT_IO_ERROR_ON_NFC
- 213, // 3014 -> IO_ENDPOINT_IO_ERROR_ON_USB
+ 310, // 2500 -> MISCELLEANEOUS_BLUETOOTH_MAC_ADDRESS_NULL
+ 314, // 2501 -> MISCELLEANEOUS_MOVE_TO_NEW_MEDIUM
+ 321, // 2502 -> MISCELLEANEOUS_WIFI_HOTSPOT_SOFT_AP_BLOCKED_BY_PROVISION
+ 308, // 2503 -> MISCELLEANEOUS_BLE_SYSTEM_SERVICE_NULL
+ 313, // 2504 -> MISCELLEANEOUS_L2CAP_SYSTEM_SERVICE_NULL
+ 312, // 2505 -> MISCELLEANEOUS_BT_SYSTEM_SERVICE_NULL
+ 319, // 2506 -> MISCELLEANEOUS_WIFI_AWARE_SYSTEM_SERVICE_NULL
+ 320, // 2507 -> MISCELLEANEOUS_WIFI_DIRECT_SYSTEM_SERVICE_NULL
+ 323, // 2508 -> MISCELLEANEOUS_WIFI_LAN_SYSTEM_SERVICE_NULL
+ 322, // 2509 -> MISCELLEANEOUS_WIFI_HOTSPOT_SYSTEM_SERVICE_NULL
+ 311, // 2510 -> MISCELLEANEOUS_BT_NOT_ACCEPTING_CONNECTION_FOR_WORK_PROFILE
+ 316, // 2511 -> MISCELLEANEOUS_WEB_RTC_GET_DROIDGUARD_RESULT_FAILURE
+ 318, // 2512 -> MISCELLEANEOUS_WEB_RTC_TACHYON_SIGNALING_MESSENGER_NULL
+ 315, // 2513 -> MISCELLEANEOUS_WEB_RTC_FAILED_TO_RECEIVE_MESSAGE
+ 309, // 2514 -> MISCELLEANEOUS_BLUETOOTH_CHANGE_DEVICE_NAME_FAILURE
+ 317, // 2515 -> MISCELLEANEOUS_WEB_RTC_ICE_SERVER_NULL
+ 324, // 2516 -> MISCELLEANEOUS_WORK_SOURCE_NULL
+ 255, // 3000 -> IO_FILE_OPENING_ERROR
+ 256, // 3001 -> IO_FILE_READING_ERROR
+ 257, // 3002 -> IO_FILE_WRITING_ERROR
+ 258, // 3003 -> IO_FOLDER_CREATION_ERROR
+ 259, // 3004 -> IO_STREAM_CREATE_PIPE_FAILURE
+ 245, // 3005 -> IO_ENDPOINT_IO_ERROR_ON_BLE
+ 246, // 3006 -> IO_ENDPOINT_IO_ERROR_ON_BLE_L2CAP
+ 247, // 3007 -> IO_ENDPOINT_IO_ERROR_ON_BT
+ 251, // 3008 -> IO_ENDPOINT_IO_ERROR_ON_WEB_RTC
+ 248, // 3009 -> IO_ENDPOINT_IO_ERROR_ON_LAN
+ 253, // 3010 -> IO_ENDPOINT_IO_ERROR_ON_WIFI_DIRECT
+ 254, // 3011 -> IO_ENDPOINT_IO_ERROR_ON_WIFI_HOTSPOT
+ 252, // 3012 -> IO_ENDPOINT_IO_ERROR_ON_WIFI_AWARE
+ 249, // 3013 -> IO_ENDPOINT_IO_ERROR_ON_NFC
+ 250, // 3014 -> IO_ENDPOINT_IO_ERROR_ON_USB
135, // 3500 -> CONNECTIVITY_WIFI_AWARE_ATTACH_FAILURE
78, // 3501 -> CONNECTIVITY_BLUETOOTH_DEVICE_OBTAIN_FAILURE
71, // 3502 -> CONNECTIVITY_BLE_CLIENT_SOCKET_CREATION_FAILURE
@@ -2428,162 +2505,199 @@ static const int OperationResultCode_entries_by_number[] = {
138, // 3608 -> CONNECTIVITY_WIFI_AWARE_DISCOVER_PEER_NULL_SCREEN_OFF
139, // 3609 -> CONNECTIVITY_WIFI_AWARE_DISCOVER_PEER_NULL_TIMEOUT
144, // 3610 -> CONNECTIVITY_WIFI_AWARE_JOIN_NETWORK_FAILED
- 292, // 4500 -> NEARBY_BLE_ADVERTISEMENT_MAPPING_TO_MAC_ERROR
- 302, // 4501 -> NEARBY_BLUETOOTH_MAC_ADDRESS_INVALID_FOR_CONNECT
- 362, // 4502 -> NEARBY_WEB_RTC_CONNECTION_FLOW_NULL
- 316, // 4503 -> NEARBY_GENERIC_CONNECTION_CLOSED
- 294, // 4504 -> NEARBY_BLE_ENDPOINT_CHANNEL_CREATION_FAILURE
- 334, // 4505 -> NEARBY_L2CAP_ENDPOINT_CHANNEL_CREATION_FAILURE
- 305, // 4506 -> NEARBY_BT_ENDPOINT_CHANNEL_CREATION_FAILURE
- 338, // 4507 -> NEARBY_LAN_ENDPOINT_CHANNEL_CREATION_FAILURE
- 349, // 4508 -> NEARBY_NFC_ENDPOINT_CHANNEL_CREATION_FAILURE
- 370, // 4509 -> NEARBY_WIFI_AWARE_ENDPOINT_CHANNEL_CREATION_FAILURE
- 388, // 4510 -> NEARBY_WIFI_HOTSPOT_ENDPOINT_CHANNEL_CREATION_FAILURE
- 375, // 4511 -> NEARBY_WIFI_DIRECT_ENDPOINT_CHANNEL_CREATION_FAILURE
- 363, // 4512 -> NEARBY_WEB_RTC_ENDPOINT_CHANNEL_CREATION_FAILURE
- 358, // 4513 -> NEARBY_USB_ENDPOINT_CHANNEL_CREATION_FAILURE
- 317, // 4514 -> NEARBY_GENERIC_ENDPOINT_UNENCRYPTED
- 296, // 4515 -> NEARBY_BLE_GATT_ADVERTISEMENT_NULL_FOR_CONNECTION
- 376, // 4516 -> NEARBY_WIFI_DIRECT_HOST_ON_SRD_CHANNELS
- 389, // 4517 -> NEARBY_WIFI_HOTSPOT_HOST_ON_SRD_CHANNELS
- 297, // 4518 -> NEARBY_BLE_GATT_NULL_CALLBACK
- 335, // 4519 -> NEARBY_L2CAP_NULL_CALLBACK
- 307, // 4520 -> NEARBY_BT_NULL_CALLBACK
- 360, // 4521 -> NEARBY_USB_NULL_CALLBACK
- 351, // 4522 -> NEARBY_NFC_NULL_CALLBACK
- 372, // 4523 -> NEARBY_WIFI_AWARE_NULL_CALLBACK
- 366, // 4524 -> NEARBY_WEB_RTC_NULL_CALLBACK
- 340, // 4525 -> NEARBY_LAN_NULL_CALLBACK
- 392, // 4526 -> NEARBY_WIFI_HOTSPOT_NULL_CALLBACK
- 378, // 4527 -> NEARBY_WIFI_DIRECT_NULL_CALLBACK
- 380, // 4528 -> NEARBY_WIFI_DIRECT_NULL_SSID
- 379, // 4529 -> NEARBY_WIFI_DIRECT_NULL_PASSWORD
- 306, // 4530 -> NEARBY_BT_MULTIPLEX_SOCKET_DISABLED
- 339, // 4531 -> NEARBY_LAN_MULTIPLEX_SOCKET_DISABLED
- 320, // 4532 -> NEARBY_GENERIC_NEW_ENDPOINT_CHANNEL_NULL
- 377, // 4533 -> NEARBY_WIFI_DIRECT_NO_GROUP_FOR_LISTENING
- 391, // 4534 -> NEARBY_WIFI_HOTSPOT_NO_HOTSPOT_FOR_LISTENING
- 321, // 4535 -> NEARBY_GENERIC_OLD_ENDPOINT_CHANNEL_NULL
- 299, // 4536 -> NEARBY_BLE_OPERATION_REGISTERED_FAILED
- 336, // 4537 -> NEARBY_L2CAP_OPERATION_REGISTERED_FAILED
- 308, // 4538 -> NEARBY_BT_OPERATION_REGISTERED_FAILED
- 341, // 4539 -> NEARBY_LAN_OPERATION_REGISTERED_FAILED
- 367, // 4540 -> NEARBY_WEB_RTC_OPERATION_REGISTERED_FAILED
- 373, // 4541 -> NEARBY_WIFI_AWARE_OPERATION_REGISTERED_FAILED
- 387, // 4542 -> NEARBY_WIFI_HOTSPOT_DIRECT_OPERATION_REGISTERED_FAILED
- 397, // 4543 -> NEARBY_WIFI_HOTSPOT_SOFT_AP_OPERATION_REGISTERED_FAILED
- 390, // 4544 -> NEARBY_WIFI_HOTSPOT_LOHS_OPERATION_REGISTERED_FAILED
- 386, // 4545 -> NEARBY_WIFI_HOTSPOT_CLIENT_OPERATION_REGISTERED_FAILED
- 381, // 4546 -> NEARBY_WIFI_DIRECT_OPERATION_REGISTERED_FAILED
- 322, // 4547 -> NEARBY_GENERIC_OUTGOING_PAYLOAD_CREATION_FAILURE
- 393, // 4548 -> NEARBY_WIFI_HOTSPOT_P2P_NON_DBS_WANT_2G_BUT_AP_5G
- 382, // 4549 -> NEARBY_WIFI_DIRECT_P2P_NON_DBS_WANT_2G_BUT_AP_5G
- 394, // 4550 -> NEARBY_WIFI_HOTSPOT_P2P_NON_DBS_WANT_5G_BUT_AP_2G
- 383, // 4551 -> NEARBY_WIFI_DIRECT_P2P_NON_DBS_WANT_5G_BUT_AP_2G
- 319, // 4552 -> NEARBY_GENERIC_INCOMING_PAYLOAD_NOT_DATA_TYPE
- 326, // 4553 -> NEARBY_GENERIC_READ_CLIENT_INTRODUCTION_EVENT_TYPE_ERROR
- 328, // 4554 -> NEARBY_GENERIC_READ_CLIENT_INTRODUCTION_FRAME_TYPE_ERROR
- 327, // 4555 -> NEARBY_GENERIC_READ_CLIENT_INTRODUCTION_FORMAT_ERROR
- 323, // 4556 -> NEARBY_GENERIC_READ_CLIENT_INTRODUCTION_ACK_EVENT_TYPE_ERROR
- 325, // 4557 -> NEARBY_GENERIC_READ_CLIENT_INTRODUCTION_ACK_FRAME_TYPE_ERROR
- 324, // 4558 -> NEARBY_GENERIC_READ_CLIENT_INTRODUCTION_ACK_FORMAT_ERROR
- 329, // 4559 -> NEARBY_GENERIC_REMOTE_ENDPOINT_STATUS_ERROR
- 330, // 4560 -> NEARBY_GENERIC_REMOTE_REPORT_PAYLOADS_ERROR
- 331, // 4561 -> NEARBY_GENERIC_REMOTE_UPGRADE_FAILURE
- 332, // 4562 -> NEARBY_GENERIC_SEND_PAYLOAD_EXECUTOR_NULL
- 309, // 4563 -> NEARBY_BT_VIRTUAL_SOCKET_CREATION_FAILURE
- 344, // 4564 -> NEARBY_LAN_VIRTUAL_SOCKET_CREATION_FAILURE
- 400, // 4565 -> NEARBY_WIFI_LAN_IP_ADDRESS_ERROR
- 337, // 4566 -> NEARBY_L2CAP_PSM_NOT_POSITIVE
- 314, // 4567 -> NEARBY_ENCRYPTION_FAILURE
- 288, // 4568 -> NEARBY_AUTHENTICATION_FAILURE
- 345, // 4569 -> NEARBY_LAN_VIRTUAL_SOCKET_NULL
- 300, // 4570 -> NEARBY_BLUETOOTH_ADVERTISE_TO_BYTES_FAILURE
- 293, // 4571 -> NEARBY_BLE_ADVERTISE_TO_BYTES_FAILURE
- 295, // 4572 -> NEARBY_BLE_FAST_ADVERTISE_TO_BYTES_FAILURE
- 348, // 4573 -> NEARBY_NFC_ADVERTISE_TO_BYTES_FAILURE
- 398, // 4574 -> NEARBY_WIFI_LAN_ADVERTISE_TO_BYTES_FAILURE
- 369, // 4575 -> NEARBY_WIFI_AWARE_ADVERTISE_TO_BYTES_FAILURE
- 357, // 4576 -> NEARBY_USB_ADVERTISE_TO_BYTES_FAILURE
- 350, // 4577 -> NEARBY_NFC_INVALID_PCP_OPTIONS
- 301, // 4578 -> NEARBY_BLUETOOTH_INVALID_PCP_OPTIONS
- 298, // 4579 -> NEARBY_BLE_INVALID_PCP_OPTIONS
- 399, // 4580 -> NEARBY_WIFI_LAN_INVALID_PCP_OPTIONS
- 371, // 4581 -> NEARBY_WIFI_AWARE_INVALID_PCP_OPTIONS
- 359, // 4582 -> NEARBY_USB_INVALID_PCP_OPTIONS
- 361, // 4583 -> NEARBY_UWB_INVALID_PCP_OPTIONS
- 364, // 4584 -> NEARBY_WEB_RTC_INVALID_PCP_OPTIONS
- 303, // 4585 -> NEARBY_BLUETOOTH_NO_CLIENT_REGISTER_FOR_SCAN
- 333, // 4586 -> NEARBY_INSTANT_CONNECTION_WRONG_CONNECTIVITY_INFO
- 347, // 4587 -> NEARBY_NEED_METHOD_OVERRIDE
- 318, // 4588 -> NEARBY_GENERIC_INCOMING_PAYLOAD_CREATION_FAILURE
- 365, // 4589 -> NEARBY_WEB_RTC_NO_LISTENING_PEER_FOUND
- 356, // 4590 -> NEARBY_UPGRADE_PATH_ON_WRONG_MEDIUM
- 313, // 4591 -> NEARBY_CONNECT_TO_ALL_MEDIUMS_FAILURE
- 304, // 4592 -> NEARBY_BLUETOOTH_RECONNECT_MAC_NULL
- 342, // 4593 -> NEARBY_LAN_RECONNECT_CONNECTION_INFO_NULL
- 343, // 4594 -> NEARBY_LAN_RECONNECT_IP_NULL
- 385, // 4595 -> NEARBY_WIFI_DIRECT_RECONNECT_META_DATA_NULL
- 384, // 4596 -> NEARBY_WIFI_DIRECT_RECONNECT_CONNECT_META_DATA_NULL
- 396, // 4597 -> NEARBY_WIFI_HOTSPOT_RECONNECT_META_DATA_NULL
- 395, // 4598 -> NEARBY_WIFI_HOTSPOT_RECONNECT_CONNECT_META_DATA_NULL
- 368, // 4599 -> NEARBY_WEB_RTC_RECONNECT_PEER_ID_NULL
- 374, // 4600 -> NEARBY_WIFI_AWARE_RECONNECT_META_DATA_NULL
- 352, // 4601 -> NEARBY_NOT_ADVERTISING_OR_LISTENING
- 310, // 4602 -> NEARBY_CAN_NOT_OBTAIN_DEVICE_PROVIDER
- 354, // 4603 -> NEARBY_SETUP_STRATEGY_FAILURE
- 355, // 4604 -> NEARBY_TX_ADVERTISEMENT_NULL
- 315, // 4605 -> NEARBY_ENDPOINT_ID_MISMATCH
- 312, // 4606 -> NEARBY_CONNECTIVITY_INFO_NULL_OR_WRONG
- 346, // 4607 -> NEARBY_LOCAL_CLIENT_STATE_WRONG
- 353, // 4608 -> NEARBY_REMOTE_EXCEPTION_WHEN_PROCESSING_RECEIVED_PAYLOAD
- 291, // 4609 -> NEARBY_BAD_FILE_DESCRIPTION_WHEN_PROCESSING_RECEIVED_PAYLOAD
- 311, // 4610 -> NEARBY_CONNECTION_LISTENER_NULL
- 289, // 4611 -> NEARBY_AWDL_ADVERTISE_TO_BYTES_FAILURE
- 290, // 4612 -> NEARBY_AWDL_ENDPOINT_CHANNEL_CREATION_FAILURE
+ 329, // 4500 -> NEARBY_BLE_ADVERTISEMENT_MAPPING_TO_MAC_ERROR
+ 339, // 4501 -> NEARBY_BLUETOOTH_MAC_ADDRESS_INVALID_FOR_CONNECT
+ 399, // 4502 -> NEARBY_WEB_RTC_CONNECTION_FLOW_NULL
+ 353, // 4503 -> NEARBY_GENERIC_CONNECTION_CLOSED
+ 331, // 4504 -> NEARBY_BLE_ENDPOINT_CHANNEL_CREATION_FAILURE
+ 371, // 4505 -> NEARBY_L2CAP_ENDPOINT_CHANNEL_CREATION_FAILURE
+ 342, // 4506 -> NEARBY_BT_ENDPOINT_CHANNEL_CREATION_FAILURE
+ 375, // 4507 -> NEARBY_LAN_ENDPOINT_CHANNEL_CREATION_FAILURE
+ 386, // 4508 -> NEARBY_NFC_ENDPOINT_CHANNEL_CREATION_FAILURE
+ 407, // 4509 -> NEARBY_WIFI_AWARE_ENDPOINT_CHANNEL_CREATION_FAILURE
+ 425, // 4510 -> NEARBY_WIFI_HOTSPOT_ENDPOINT_CHANNEL_CREATION_FAILURE
+ 412, // 4511 -> NEARBY_WIFI_DIRECT_ENDPOINT_CHANNEL_CREATION_FAILURE
+ 400, // 4512 -> NEARBY_WEB_RTC_ENDPOINT_CHANNEL_CREATION_FAILURE
+ 395, // 4513 -> NEARBY_USB_ENDPOINT_CHANNEL_CREATION_FAILURE
+ 354, // 4514 -> NEARBY_GENERIC_ENDPOINT_UNENCRYPTED
+ 333, // 4515 -> NEARBY_BLE_GATT_ADVERTISEMENT_NULL_FOR_CONNECTION
+ 413, // 4516 -> NEARBY_WIFI_DIRECT_HOST_ON_SRD_CHANNELS
+ 426, // 4517 -> NEARBY_WIFI_HOTSPOT_HOST_ON_SRD_CHANNELS
+ 334, // 4518 -> NEARBY_BLE_GATT_NULL_CALLBACK
+ 372, // 4519 -> NEARBY_L2CAP_NULL_CALLBACK
+ 344, // 4520 -> NEARBY_BT_NULL_CALLBACK
+ 397, // 4521 -> NEARBY_USB_NULL_CALLBACK
+ 388, // 4522 -> NEARBY_NFC_NULL_CALLBACK
+ 409, // 4523 -> NEARBY_WIFI_AWARE_NULL_CALLBACK
+ 403, // 4524 -> NEARBY_WEB_RTC_NULL_CALLBACK
+ 377, // 4525 -> NEARBY_LAN_NULL_CALLBACK
+ 429, // 4526 -> NEARBY_WIFI_HOTSPOT_NULL_CALLBACK
+ 415, // 4527 -> NEARBY_WIFI_DIRECT_NULL_CALLBACK
+ 417, // 4528 -> NEARBY_WIFI_DIRECT_NULL_SSID
+ 416, // 4529 -> NEARBY_WIFI_DIRECT_NULL_PASSWORD
+ 343, // 4530 -> NEARBY_BT_MULTIPLEX_SOCKET_DISABLED
+ 376, // 4531 -> NEARBY_LAN_MULTIPLEX_SOCKET_DISABLED
+ 357, // 4532 -> NEARBY_GENERIC_NEW_ENDPOINT_CHANNEL_NULL
+ 414, // 4533 -> NEARBY_WIFI_DIRECT_NO_GROUP_FOR_LISTENING
+ 428, // 4534 -> NEARBY_WIFI_HOTSPOT_NO_HOTSPOT_FOR_LISTENING
+ 358, // 4535 -> NEARBY_GENERIC_OLD_ENDPOINT_CHANNEL_NULL
+ 336, // 4536 -> NEARBY_BLE_OPERATION_REGISTERED_FAILED
+ 373, // 4537 -> NEARBY_L2CAP_OPERATION_REGISTERED_FAILED
+ 345, // 4538 -> NEARBY_BT_OPERATION_REGISTERED_FAILED
+ 378, // 4539 -> NEARBY_LAN_OPERATION_REGISTERED_FAILED
+ 404, // 4540 -> NEARBY_WEB_RTC_OPERATION_REGISTERED_FAILED
+ 410, // 4541 -> NEARBY_WIFI_AWARE_OPERATION_REGISTERED_FAILED
+ 424, // 4542 -> NEARBY_WIFI_HOTSPOT_DIRECT_OPERATION_REGISTERED_FAILED
+ 434, // 4543 -> NEARBY_WIFI_HOTSPOT_SOFT_AP_OPERATION_REGISTERED_FAILED
+ 427, // 4544 -> NEARBY_WIFI_HOTSPOT_LOHS_OPERATION_REGISTERED_FAILED
+ 423, // 4545 -> NEARBY_WIFI_HOTSPOT_CLIENT_OPERATION_REGISTERED_FAILED
+ 418, // 4546 -> NEARBY_WIFI_DIRECT_OPERATION_REGISTERED_FAILED
+ 359, // 4547 -> NEARBY_GENERIC_OUTGOING_PAYLOAD_CREATION_FAILURE
+ 430, // 4548 -> NEARBY_WIFI_HOTSPOT_P2P_NON_DBS_WANT_2G_BUT_AP_5G
+ 419, // 4549 -> NEARBY_WIFI_DIRECT_P2P_NON_DBS_WANT_2G_BUT_AP_5G
+ 431, // 4550 -> NEARBY_WIFI_HOTSPOT_P2P_NON_DBS_WANT_5G_BUT_AP_2G
+ 420, // 4551 -> NEARBY_WIFI_DIRECT_P2P_NON_DBS_WANT_5G_BUT_AP_2G
+ 356, // 4552 -> NEARBY_GENERIC_INCOMING_PAYLOAD_NOT_DATA_TYPE
+ 363, // 4553 -> NEARBY_GENERIC_READ_CLIENT_INTRODUCTION_EVENT_TYPE_ERROR
+ 365, // 4554 -> NEARBY_GENERIC_READ_CLIENT_INTRODUCTION_FRAME_TYPE_ERROR
+ 364, // 4555 -> NEARBY_GENERIC_READ_CLIENT_INTRODUCTION_FORMAT_ERROR
+ 360, // 4556 -> NEARBY_GENERIC_READ_CLIENT_INTRODUCTION_ACK_EVENT_TYPE_ERROR
+ 362, // 4557 -> NEARBY_GENERIC_READ_CLIENT_INTRODUCTION_ACK_FRAME_TYPE_ERROR
+ 361, // 4558 -> NEARBY_GENERIC_READ_CLIENT_INTRODUCTION_ACK_FORMAT_ERROR
+ 366, // 4559 -> NEARBY_GENERIC_REMOTE_ENDPOINT_STATUS_ERROR
+ 367, // 4560 -> NEARBY_GENERIC_REMOTE_REPORT_PAYLOADS_ERROR
+ 368, // 4561 -> NEARBY_GENERIC_REMOTE_UPGRADE_FAILURE
+ 369, // 4562 -> NEARBY_GENERIC_SEND_PAYLOAD_EXECUTOR_NULL
+ 346, // 4563 -> NEARBY_BT_VIRTUAL_SOCKET_CREATION_FAILURE
+ 381, // 4564 -> NEARBY_LAN_VIRTUAL_SOCKET_CREATION_FAILURE
+ 437, // 4565 -> NEARBY_WIFI_LAN_IP_ADDRESS_ERROR
+ 374, // 4566 -> NEARBY_L2CAP_PSM_NOT_POSITIVE
+ 351, // 4567 -> NEARBY_ENCRYPTION_FAILURE
+ 325, // 4568 -> NEARBY_AUTHENTICATION_FAILURE
+ 382, // 4569 -> NEARBY_LAN_VIRTUAL_SOCKET_NULL
+ 337, // 4570 -> NEARBY_BLUETOOTH_ADVERTISE_TO_BYTES_FAILURE
+ 330, // 4571 -> NEARBY_BLE_ADVERTISE_TO_BYTES_FAILURE
+ 332, // 4572 -> NEARBY_BLE_FAST_ADVERTISE_TO_BYTES_FAILURE
+ 385, // 4573 -> NEARBY_NFC_ADVERTISE_TO_BYTES_FAILURE
+ 435, // 4574 -> NEARBY_WIFI_LAN_ADVERTISE_TO_BYTES_FAILURE
+ 406, // 4575 -> NEARBY_WIFI_AWARE_ADVERTISE_TO_BYTES_FAILURE
+ 394, // 4576 -> NEARBY_USB_ADVERTISE_TO_BYTES_FAILURE
+ 387, // 4577 -> NEARBY_NFC_INVALID_PCP_OPTIONS
+ 338, // 4578 -> NEARBY_BLUETOOTH_INVALID_PCP_OPTIONS
+ 335, // 4579 -> NEARBY_BLE_INVALID_PCP_OPTIONS
+ 436, // 4580 -> NEARBY_WIFI_LAN_INVALID_PCP_OPTIONS
+ 408, // 4581 -> NEARBY_WIFI_AWARE_INVALID_PCP_OPTIONS
+ 396, // 4582 -> NEARBY_USB_INVALID_PCP_OPTIONS
+ 398, // 4583 -> NEARBY_UWB_INVALID_PCP_OPTIONS
+ 401, // 4584 -> NEARBY_WEB_RTC_INVALID_PCP_OPTIONS
+ 340, // 4585 -> NEARBY_BLUETOOTH_NO_CLIENT_REGISTER_FOR_SCAN
+ 370, // 4586 -> NEARBY_INSTANT_CONNECTION_WRONG_CONNECTIVITY_INFO
+ 384, // 4587 -> NEARBY_NEED_METHOD_OVERRIDE
+ 355, // 4588 -> NEARBY_GENERIC_INCOMING_PAYLOAD_CREATION_FAILURE
+ 402, // 4589 -> NEARBY_WEB_RTC_NO_LISTENING_PEER_FOUND
+ 393, // 4590 -> NEARBY_UPGRADE_PATH_ON_WRONG_MEDIUM
+ 350, // 4591 -> NEARBY_CONNECT_TO_ALL_MEDIUMS_FAILURE
+ 341, // 4592 -> NEARBY_BLUETOOTH_RECONNECT_MAC_NULL
+ 379, // 4593 -> NEARBY_LAN_RECONNECT_CONNECTION_INFO_NULL
+ 380, // 4594 -> NEARBY_LAN_RECONNECT_IP_NULL
+ 422, // 4595 -> NEARBY_WIFI_DIRECT_RECONNECT_META_DATA_NULL
+ 421, // 4596 -> NEARBY_WIFI_DIRECT_RECONNECT_CONNECT_META_DATA_NULL
+ 433, // 4597 -> NEARBY_WIFI_HOTSPOT_RECONNECT_META_DATA_NULL
+ 432, // 4598 -> NEARBY_WIFI_HOTSPOT_RECONNECT_CONNECT_META_DATA_NULL
+ 405, // 4599 -> NEARBY_WEB_RTC_RECONNECT_PEER_ID_NULL
+ 411, // 4600 -> NEARBY_WIFI_AWARE_RECONNECT_META_DATA_NULL
+ 389, // 4601 -> NEARBY_NOT_ADVERTISING_OR_LISTENING
+ 347, // 4602 -> NEARBY_CAN_NOT_OBTAIN_DEVICE_PROVIDER
+ 391, // 4603 -> NEARBY_SETUP_STRATEGY_FAILURE
+ 392, // 4604 -> NEARBY_TX_ADVERTISEMENT_NULL
+ 352, // 4605 -> NEARBY_ENDPOINT_ID_MISMATCH
+ 349, // 4606 -> NEARBY_CONNECTIVITY_INFO_NULL_OR_WRONG
+ 383, // 4607 -> NEARBY_LOCAL_CLIENT_STATE_WRONG
+ 390, // 4608 -> NEARBY_REMOTE_EXCEPTION_WHEN_PROCESSING_RECEIVED_PAYLOAD
+ 328, // 4609 -> NEARBY_BAD_FILE_DESCRIPTION_WHEN_PROCESSING_RECEIVED_PAYLOAD
+ 348, // 4610 -> NEARBY_CONNECTION_LISTENER_NULL
+ 326, // 4611 -> NEARBY_AWDL_ADVERTISE_TO_BYTES_FAILURE
+ 327, // 4612 -> NEARBY_AWDL_ENDPOINT_CHANNEL_CREATION_FAILURE
177, // 5000 -> DCT_ERROR_BLE_DISABLED
176, // 5001 -> DCT_ERROR_BLE_ADV_FAILED
178, // 5002 -> DCT_ERROR_BLE_SCAN_FAILED
- 187, // 5003 -> DCT_ERROR_L2CAP_SERVER_FAILED
- 186, // 5004 -> DCT_ERROR_L2CAP_CLIENT_FAILED
- 188, // 5005 -> DCT_ERROR_MDNS_DISCOVERY_TIMEOUT
- 189, // 5006 -> DCT_ERROR_MDNS_REGISTER_SERVICE
- 184, // 5007 -> DCT_ERROR_INITIAL_TLS_SPAKE
- 193, // 5008 -> DCT_ERROR_SUBSEQUENT_TLS_SPAKE
- 190, // 5009 -> DCT_ERROR_REQUEST_FAILED
- 191, // 5010 -> DCT_ERROR_RESPONSE_FAILED
- 180, // 5011 -> DCT_ERROR_CONTROL_MESSAGE_EXCHANGE
+ 188, // 5003 -> DCT_ERROR_L2CAP_SERVER_FAILED
+ 187, // 5004 -> DCT_ERROR_L2CAP_CLIENT_FAILED
+ 191, // 5005 -> DCT_ERROR_MDNS_DISCOVERY_TIMEOUT
+ 192, // 5006 -> DCT_ERROR_MDNS_REGISTER_SERVICE
+ 185, // 5007 -> DCT_ERROR_INITIAL_TLS_SPAKE
+ 217, // 5008 -> DCT_ERROR_SUBSEQUENT_TLS_SPAKE
+ 214, // 5009 -> DCT_ERROR_REQUEST_FAILED
+ 215, // 5010 -> DCT_ERROR_RESPONSE_FAILED
+ 181, // 5011 -> DCT_ERROR_CONTROL_MESSAGE_EXCHANGE
179, // 5012 -> DCT_ERROR_CAPABILITY_MISMATCH
- 182, // 5013 -> DCT_ERROR_HIGH_SPEED_MEDIUM_UNAVAILABLE
- 198, // 5014 -> DCT_ERROR_WIFI_DISABLED
- 199, // 5015 -> DCT_ERROR_WIFI_DISCONNECTED
- 197, // 5016 -> DCT_ERROR_WIFI_CREDENTIAL_TRANSFER
- 200, // 5017 -> DCT_ERROR_WIFI_INTERNET_CONNECTION
- 195, // 5018 -> DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED
- 185, // 5019 -> DCT_ERROR_KEEPALIVE_TIMEOUT
- 181, // 5020 -> DCT_ERROR_ESTABLISHED_CONNECTION_LOST
- 196, // 5021 -> DCT_ERROR_USER_CANCELLED
- 192, // 5022 -> DCT_ERROR_SERVICE_CANCELLED
- 194, // 5023 -> DCT_ERROR_UNVERIFIED_INTEGRITY
- 183, // 5024 -> DCT_ERROR_HTTP_SERVER_CLOSED
+ 183, // 5013 -> DCT_ERROR_HIGH_SPEED_MEDIUM_UNAVAILABLE
+ 235, // 5014 -> DCT_ERROR_WIFI_DISABLED
+ 236, // 5015 -> DCT_ERROR_WIFI_DISCONNECTED
+ 234, // 5016 -> DCT_ERROR_WIFI_CREDENTIAL_TRANSFER
+ 237, // 5017 -> DCT_ERROR_WIFI_INTERNET_CONNECTION
+ 219, // 5018 -> DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED
+ 186, // 5019 -> DCT_ERROR_KEEPALIVE_TIMEOUT
+ 182, // 5020 -> DCT_ERROR_ESTABLISHED_CONNECTION_LOST
+ 233, // 5021 -> DCT_ERROR_USER_CANCELLED
+ 216, // 5022 -> DCT_ERROR_SERVICE_CANCELLED
+ 218, // 5023 -> DCT_ERROR_UNVERIFIED_INTEGRITY
+ 184, // 5024 -> DCT_ERROR_HTTP_SERVER_CLOSED
+ 180, // 5025 -> DCT_ERROR_CHECKIN_FAILURE
+ 198, // 5026 -> DCT_ERROR_REMOTE_ATTESTATION_TIMEOUT
+ 196, // 5027 -> DCT_ERROR_REMOTE_ATTESTATION_NULL_PACKET
+ 197, // 5028 -> DCT_ERROR_REMOTE_ATTESTATION_STATUS_NOT_AVAILABLE
+ 195, // 5029 -> DCT_ERROR_REMOTE_ATTESTATION_HASH_TOO_SHORT
+ 194, // 5030 -> DCT_ERROR_REMOTE_ATTESTATION_APPLE_INTEGRITY_UNAVAILABLE
+ 189, // 5031 -> DCT_ERROR_LOCAL_ATTESTATION_PLAY_INTEGRITY_UNAVAILABLE
+ 190, // 5032 -> DCT_ERROR_LOCAL_ATTESTATION_TIMEOUT
+ 193, // 5033 -> DCT_ERROR_PARALLEL_ATTESTATION_TIMEOUT
+ 202, // 5034 -> DCT_ERROR_REMOTE_MDNS_DISCOVERY_TIMEOUT
+ 203, // 5035 -> DCT_ERROR_REMOTE_MDNS_REGISTER_SERVICE
+ 204, // 5036 -> DCT_ERROR_REMOTE_REQUEST_FAILED
+ 205, // 5037 -> DCT_ERROR_REMOTE_RESPONSE_FAILED
+ 200, // 5038 -> DCT_ERROR_REMOTE_CONTROL_MESSAGE_EXCHANGE
+ 199, // 5039 -> DCT_ERROR_REMOTE_CAPABILITY_MISMATCH
+ 201, // 5040 -> DCT_ERROR_REMOTE_HIGH_SPEED_MEDIUM_UNAVAILABLE
+ 211, // 5041 -> DCT_ERROR_REMOTE_WIFI_DISABLED
+ 212, // 5042 -> DCT_ERROR_REMOTE_WIFI_DISCONNECTED
+ 210, // 5043 -> DCT_ERROR_REMOTE_WIFI_CREDENTIAL_TRANSFER
+ 213, // 5044 -> DCT_ERROR_REMOTE_WIFI_INTERNET_CONNECTION
+ 208, // 5045 -> DCT_ERROR_REMOTE_UPGRADE_HIGH_SPEED_MEDIUM_FAILED
+ 209, // 5046 -> DCT_ERROR_REMOTE_USER_CANCELLED
+ 206, // 5047 -> DCT_ERROR_REMOTE_SERVICE_CANCELLED
+ 207, // 5048 -> DCT_ERROR_REMOTE_UNVERIFIED_INTEGRITY
+ 224, // 5049 -> DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_LOW_SPEED
+ 220, // 5050 -> DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_CONNECTION
+ 231, // 5051 -> DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_USB_NOT_PLUGGED
+ 230, // 5052 -> DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_USB_NOT_HOST
+ 225, // 5053 -> DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_MDNS_DISCOVERY_NOT_STARTED
+ 228, // 5054 -> DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_NO_MEDIUM
+ 229, // 5055 -> DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_USB_NETWORK_NOT_STARTED
+ 226, // 5056 -> DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_MEDIUM_NEGOTIATION
+ 222, // 5057 -> DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_HOST_NOT_STARTED
+ 221, // 5058 -> DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_HOST_NETWORK_NOT_AVAILABLE
+ 227, // 5059 -> DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_NO_INCOMING_HTTP_CONNECTION
+ 232, // 5060 -> DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_USB_NO_CONNECTED_DEVICE
+ 223, // 5061 -> DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_INTERRUPTED
};
const ::std::string& OperationResultCode_Name(OperationResultCode value) {
static const bool kDummy = ::google::protobuf::internal::InitializeEnumStrings(
- OperationResultCode_entries, OperationResultCode_entries_by_number, 401,
+ OperationResultCode_entries, OperationResultCode_entries_by_number, 438,
OperationResultCode_strings);
(void)kDummy;
int idx = ::google::protobuf::internal::LookUpEnumName(OperationResultCode_entries,
OperationResultCode_entries_by_number,
- 401, value);
+ 438, value);
return idx == -1 ? ::google::protobuf::internal::GetEmptyString() : OperationResultCode_strings[idx].get();
}
bool OperationResultCode_Parse(::absl::string_view name, OperationResultCode* PROTOBUF_NONNULL value) {
int int_value;
bool success = ::google::protobuf::internal::LookUpEnumValue(
- OperationResultCode_entries, 401, name, &int_value);
+ OperationResultCode_entries, 438, name, &int_value);
if (success) {
*value = static_cast(int_value);
}
diff --git a/compiled_proto/proto/connections_enums.pb.h b/compiled_proto/proto/connections_enums.pb.h
index 0d0dcf74..097d4e90 100644
--- a/compiled_proto/proto/connections_enums.pb.h
+++ b/compiled_proto/proto/connections_enums.pb.h
@@ -324,18 +324,19 @@ bool Medium_Parse(
enum WifiDirectAuthType : int {
WIFI_DIRECT_TYPE_UNKNOWN = 0,
WIFI_DIRECT_WITH_PASSWORD = 1,
- WIFI_DIRECT_WITH_PIN = 2,
+ WIFI_DIRECT_WITH_PIN [[deprecated]] = 2,
+ WIFI_DIRECT_WITH_DEVICE_NAME = 3,
};
extern const uint32_t WifiDirectAuthType_internal_data_[];
inline constexpr WifiDirectAuthType WifiDirectAuthType_MIN =
static_cast(0);
inline constexpr WifiDirectAuthType WifiDirectAuthType_MAX =
- static_cast(2);
+ static_cast(3);
inline bool WifiDirectAuthType_IsValid(int value) {
- return 0 <= value && value <= 2;
+ return 0 <= value && value <= 3;
}
-inline constexpr int WifiDirectAuthType_ARRAYSIZE = 2 + 1;
+inline constexpr int WifiDirectAuthType_ARRAYSIZE = 3 + 1;
const ::std::string& WifiDirectAuthType_Name(WifiDirectAuthType value);
template
const ::std::string& WifiDirectAuthType_Name(T value) {
@@ -1272,17 +1273,54 @@ enum OperationResultCode : int {
DCT_ERROR_SERVICE_CANCELLED = 5022,
DCT_ERROR_UNVERIFIED_INTEGRITY = 5023,
DCT_ERROR_HTTP_SERVER_CLOSED = 5024,
+ DCT_ERROR_CHECKIN_FAILURE = 5025,
+ DCT_ERROR_REMOTE_ATTESTATION_TIMEOUT = 5026,
+ DCT_ERROR_REMOTE_ATTESTATION_NULL_PACKET = 5027,
+ DCT_ERROR_REMOTE_ATTESTATION_STATUS_NOT_AVAILABLE = 5028,
+ DCT_ERROR_REMOTE_ATTESTATION_HASH_TOO_SHORT = 5029,
+ DCT_ERROR_REMOTE_ATTESTATION_APPLE_INTEGRITY_UNAVAILABLE = 5030,
+ DCT_ERROR_LOCAL_ATTESTATION_PLAY_INTEGRITY_UNAVAILABLE = 5031,
+ DCT_ERROR_LOCAL_ATTESTATION_TIMEOUT = 5032,
+ DCT_ERROR_PARALLEL_ATTESTATION_TIMEOUT = 5033,
+ DCT_ERROR_REMOTE_MDNS_DISCOVERY_TIMEOUT = 5034,
+ DCT_ERROR_REMOTE_MDNS_REGISTER_SERVICE = 5035,
+ DCT_ERROR_REMOTE_REQUEST_FAILED = 5036,
+ DCT_ERROR_REMOTE_RESPONSE_FAILED = 5037,
+ DCT_ERROR_REMOTE_CONTROL_MESSAGE_EXCHANGE = 5038,
+ DCT_ERROR_REMOTE_CAPABILITY_MISMATCH = 5039,
+ DCT_ERROR_REMOTE_HIGH_SPEED_MEDIUM_UNAVAILABLE = 5040,
+ DCT_ERROR_REMOTE_WIFI_DISABLED = 5041,
+ DCT_ERROR_REMOTE_WIFI_DISCONNECTED = 5042,
+ DCT_ERROR_REMOTE_WIFI_CREDENTIAL_TRANSFER = 5043,
+ DCT_ERROR_REMOTE_WIFI_INTERNET_CONNECTION = 5044,
+ DCT_ERROR_REMOTE_UPGRADE_HIGH_SPEED_MEDIUM_FAILED = 5045,
+ DCT_ERROR_REMOTE_USER_CANCELLED = 5046,
+ DCT_ERROR_REMOTE_SERVICE_CANCELLED = 5047,
+ DCT_ERROR_REMOTE_UNVERIFIED_INTEGRITY = 5048,
+ DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_LOW_SPEED = 5049,
+ DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_CONNECTION = 5050,
+ DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_USB_NOT_PLUGGED = 5051,
+ DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_USB_NOT_HOST = 5052,
+ DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_MDNS_DISCOVERY_NOT_STARTED = 5053,
+ DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_NO_MEDIUM = 5054,
+ DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_USB_NETWORK_NOT_STARTED = 5055,
+ DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_MEDIUM_NEGOTIATION = 5056,
+ DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_HOST_NOT_STARTED = 5057,
+ DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_HOST_NETWORK_NOT_AVAILABLE = 5058,
+ DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_NO_INCOMING_HTTP_CONNECTION = 5059,
+ DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_USB_NO_CONNECTED_DEVICE = 5060,
+ DCT_ERROR_UPGRADE_HIGH_SPEED_MEDIUM_FAILED_INTERRUPTED = 5061,
};
extern const uint32_t OperationResultCode_internal_data_[];
inline constexpr OperationResultCode OperationResultCode_MIN =
static_cast(0);
inline constexpr OperationResultCode OperationResultCode_MAX =
- static_cast(5024);
+ static_cast(5061);
inline bool OperationResultCode_IsValid(int value) {
return ::google::protobuf::internal::ValidateEnum(value, OperationResultCode_internal_data_);
}
-inline constexpr int OperationResultCode_ARRAYSIZE = 5024 + 1;
+inline constexpr int OperationResultCode_ARRAYSIZE = 5061 + 1;
const ::std::string& OperationResultCode_Name(OperationResultCode value);
template
const ::std::string& OperationResultCode_Name(T value) {
diff --git a/connections/BUILD b/connections/BUILD
index 1bf50743..f7cddcb5 100644
--- a/connections/BUILD
+++ b/connections/BUILD
@@ -44,9 +44,11 @@ cc_library(
],
deps = [
":core_types",
+ "//connections/implementation:client_proxy",
"//connections/implementation:internal",
+ "//connections/implementation:service_id_constants",
+ "//connections/implementation/analytics",
"//connections/v3:v3_types",
- "//internal/analytics:event_logger",
"//internal/interop:device",
"//internal/platform:base",
"//internal/platform:logging",
@@ -95,15 +97,15 @@ cc_library(
"//connections/implementation/proto:offline_wire_formats_cc_proto",
"//internal/interop:authentication_status",
"//internal/platform:base",
+ "//internal/platform:comm",
"//internal/platform:logging",
"//internal/platform:mac_address",
- "//internal/platform:types",
"//internal/platform:util",
"//proto:connections_enums_cc_proto",
"@com_google_absl//absl/functional:any_invocable",
"@com_google_absl//absl/random",
+ "@com_google_absl//absl/strings",
"@com_google_absl//absl/time",
- "@com_google_absl//absl/types:variant",
],
)
@@ -124,6 +126,7 @@ cc_test(
"//connections/implementation:internal_test",
"//connections/v3:v3_types",
"//internal/platform:base",
+ "//internal/platform:comm",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
diff --git a/connections/c/BUILD b/connections/c/BUILD
index a9ce6b37..c745e9c9 100644
--- a/connections/c/BUILD
+++ b/connections/c/BUILD
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("@rules_apple//apple:apple.bzl", "apple_static_xcframework")
+load("@rules_apple//apple:apple_xcframework.bzl", "apple_static_xcframework")
load("@rules_apple//apple:macos.bzl", "macos_dylib")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("//third_party/cpptoolchains/portable_llvm/build_defs:windows.bzl", "windows")
@@ -51,16 +51,18 @@ cc_library(
":nc_types",
"//connections:core",
"//connections:core_types",
+ "//connections/implementation/analytics:analytics_recorder_impl",
"//connections/implementation/flags:connections_flags",
- "//internal/analytics:event_logger",
"//internal/flags:flag_reader",
"//internal/flags:nearby_flags",
"//internal/platform:base",
+ "//internal/platform:comm",
"//internal/platform:logging",
"//internal/platform:mac_address",
"//internal/platform:types",
- "//internal/proto/analytics:connections_log_cc_proto",
- "//sharing/proto/analytics:sharing_log_cc_proto",
+ "//location/nearby/analytics/cpp/logging:event_logger",
+ "//location/nearby/analytics/cpp/proto:connections_log_cc_proto",
+ "//location/nearby/analytics/cpp/proto:sharing_log_cc_proto",
"@com_google_absl//absl/base:no_destructor",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/strings",
@@ -73,6 +75,7 @@ cc_library(
],
"//conditions:default": [],
}),
+ alwayslink = True,
)
# iOS only.
diff --git a/connections/c/nc.cc b/connections/c/nc.cc
index e251f77c..2c975cb9 100644
--- a/connections/c/nc.cc
+++ b/connections/c/nc.cc
@@ -20,10 +20,16 @@
#include
#include
#include
+#include
#include
#include
#include
+#if !defined(NC_OSS_BUILD)
+#include "location/nearby/analytics/cpp/logging/event_logger.h"
+#include "location/nearby/analytics/cpp/proto/connections_log.pb.h"
+#include "location/nearby/analytics/cpp/proto/nearby_sharing_log.pb.h"
+#endif // !defined(NC_OSS_BUILD)
#include "absl/base/no_destructor.h"
#include "absl/container/flat_hash_map.h"
#include "absl/strings/str_cat.h"
@@ -34,6 +40,9 @@
#include "connections/connection_options.h"
#include "connections/core.h"
#include "connections/discovery_options.h"
+#if !defined(NC_OSS_BUILD)
+#include "connections/implementation/analytics/analytics_recorder_impl.h"
+#endif // !defined(NC_OSS_BUILD)
#include "connections/listeners.h"
#include "connections/medium_selector.h"
#include "connections/out_of_band_connection_metadata.h"
@@ -41,7 +50,6 @@
#include "connections/payload.h"
#include "connections/status.h"
#include "connections/strategy.h"
-#include "internal/analytics/event_logger.h"
#include "internal/flags/flag.h"
#include "internal/flags/flag_reader.h"
#include "internal/flags/nearby_flags.h"
@@ -49,8 +57,6 @@
#include "internal/platform/file.h"
#include "internal/platform/logging.h"
#include "internal/platform/mac_address.h"
-#include "internal/proto/analytics/connections_log.pb.h"
-#include "sharing/proto/analytics/nearby_sharing_log.pb.h"
#if TARGET_OS_IOS
#include "internal/platform/implementation/apple/nearby_logger.h"
#endif // TARGET_OS_IOS
@@ -118,6 +124,7 @@ class FlagReaderWrapper : public nearby::flags::FlagReader {
NC_PHENOTYPE_FLAG_READER phenotype_flag_reader_;
};
+#if !defined(NC_OSS_BUILD)
// This is a bridging class between the C API and the C++ EventLogger interface.
class NcEventLogger : public ::nearby::analytics::EventLogger {
public:
@@ -145,6 +152,10 @@ class NcEventLogger : public ::nearby::analytics::EventLogger {
private:
const NC_EVENT_LOGGER* event_logger_;
};
+#else // !defined(NC_OSS_BUILD)
+class NcEventLogger;
+#endif // !defined(NC_OSS_BUILD)
+
} // namespace
typedef struct NcContext {
@@ -244,6 +255,7 @@ NcContext* GetContext(NC_INSTANCE instance) {
return cpp_connection_request_info;
}
+#if !defined(NC_OSS_BUILD)
NC_INSTANCE NcCreateService() {
return NcCreateServiceWithEventLogger(nullptr);
}
@@ -259,12 +271,24 @@ NcCreateServiceWithEventLogger(const NC_EVENT_LOGGER* event_logger) {
nc_context.router = new ::nearby::connections::ServiceControllerRouter();
nc_context.event_logger =
event_logger == nullptr ? nullptr : new NcEventLogger(event_logger);
- nc_context.core = new ::nearby::connections::Core(nc_context.event_logger,
- nc_context.router);
+ nc_context.core = new ::nearby::connections::Core(
+ std::make_unique<::nearby::analytics::AnalyticsRecorderImpl>(
+ nc_context.event_logger),
+ nc_context.router);
kNcContextMap->insert({nc_context.core, nc_context});
return nc_context.core;
}
+#else // !defined(NC_OSS_BUILD)
+NC_INSTANCE NcCreateService() {
+ NcContext nc_context;
+ nc_context.router = new ::nearby::connections::ServiceControllerRouter();
+ nc_context.core = new ::nearby::connections::Core(nc_context.router);
+
+ kNcContextMap->insert({nc_context.core, nc_context});
+ return nc_context.core;
+}
+#endif // !defined(NC_OSS_BUILD)
void NcCloseService(NC_INSTANCE instance) {
NcContext* nc_context = GetContext(instance);
diff --git a/connections/c/nc.h b/connections/c/nc.h
index b3dd2505..cc00735f 100644
--- a/connections/c/nc.h
+++ b/connections/c/nc.h
@@ -27,11 +27,13 @@ extern "C" {
// Creates a new Nearby Connections service.
NC_API NC_INSTANCE NcCreateService();
+#if !defined(NC_OSS_BUILD)
// Creates a new Nearby Connections service with an event logger.
// The passed-in |event_logger| must remain valid until NcCloseService() is
// called.
NC_API NC_INSTANCE
NcCreateServiceWithEventLogger(const NC_EVENT_LOGGER* event_logger);
+#endif // !defined(NC_OSS_BUILD)
// Closes a Nearby Connections service.
NC_API void NcCloseService(NC_INSTANCE instance);
diff --git a/connections/core.h b/connections/core.h
index 69edb815..b72ebc6d 100644
--- a/connections/core.h
+++ b/connections/core.h
@@ -25,6 +25,7 @@
#include "connections/advertising_options.h"
#include "connections/connection_options.h"
#include "connections/discovery_options.h"
+#include "connections/implementation/analytics/analytics_recorder.h"
#include "connections/implementation/client_proxy.h"
#include "connections/implementation/service_controller_router.h"
#include "connections/listeners.h"
@@ -37,7 +38,6 @@
#include "connections/v3/discovery_options.h"
#include "connections/v3/listeners.h"
#include "connections/v3/listening_result.h"
-#include "internal/analytics/event_logger.h"
#include "internal/interop/device.h"
#include "internal/interop/device_provider.h"
@@ -49,9 +49,9 @@ class Core {
public:
explicit Core(ServiceControllerRouter* router);
// Client needs to call this constructor if analytics logger is needed.
- Core(::nearby::analytics::EventLogger* event_logger,
+ Core(std::unique_ptr analytics_recorder,
ServiceControllerRouter* router)
- : client_(event_logger), router_(router) {}
+ : client_(std::move(analytics_recorder)), router_(router) {}
~Core();
Core(Core&&);
Core& operator=(Core&&);
diff --git a/connections/implementation/BUILD b/connections/implementation/BUILD
index ec42c3d2..334a3149 100644
--- a/connections/implementation/BUILD
+++ b/connections/implementation/BUILD
@@ -49,30 +49,143 @@ cc_library(
],
)
+cc_library(
+ name = "service_id_constants",
+ hdrs = ["service_id_constants.h"],
+ visibility = ["//connections:__subpackages__"],
+ deps = [
+ "@com_google_absl//absl/strings",
+ "@com_google_absl//absl/strings:string_view",
+ ],
+)
+
+cc_library(
+ name = "bwu_handler",
+ srcs = ["base_bwu_handler.cc"],
+ hdrs = [
+ "base_bwu_handler.h",
+ "bwu_handler.h",
+ ],
+ visibility = ["//connections:__subpackages__"],
+ deps = [
+ ":client_proxy",
+ ":endpoint_channel",
+ ":service_id_constants",
+ "//internal/platform:base",
+ "//internal/platform:logging",
+ "@com_google_absl//absl/container:flat_hash_map",
+ "@com_google_absl//absl/container:flat_hash_set",
+ "@com_google_absl//absl/functional:any_invocable",
+ ],
+)
+
+cc_library(
+ name = "offline_frames",
+ srcs = [
+ "offline_frames.cc",
+ "offline_frames_validator.cc",
+ ],
+ hdrs = [
+ "internal_payload.h",
+ "offline_frames.h",
+ "offline_frames_validator.h",
+ ],
+ visibility = ["//connections:__subpackages__"],
+ deps = [
+ "//connections:core_types",
+ "//connections/implementation/flags:connections_flags",
+ "//connections/implementation/proto:offline_wire_formats_cc_proto",
+ "//internal/flags:nearby_flags",
+ "//internal/platform:base",
+ "//internal/platform:logging",
+ "//internal/platform:mac_address",
+ "@com_google_absl//absl/strings:string_view",
+ "@com_google_absl//absl/time",
+ ],
+)
+
+cc_library(
+ name = "client_proxy",
+ srcs = ["client_proxy.cc"],
+ hdrs = ["client_proxy.h"],
+ visibility = ["//connections:__subpackages__"],
+ deps = [
+ "//connections:core_types",
+ "//connections/implementation/analytics",
+ "//connections/implementation/flags:connections_flags",
+ "//connections/implementation/mediums/advertisements:dct_advertisement",
+ "//connections/implementation/proto:offline_wire_formats_cc_proto",
+ "//connections/v3:v3_types",
+ "//internal/base:file_path",
+ "//internal/base:files",
+ "//internal/flags:nearby_flags",
+ "//internal/interop:device",
+ "//internal/platform:base",
+ "//internal/platform:cancellation_flag",
+ "//internal/platform:error_code_recorder",
+ "//internal/platform:logging",
+ "//internal/platform:mac_address",
+ "//internal/platform:types",
+ "//internal/platform/implementation:comm",
+ "//internal/platform/implementation:platform",
+ "//internal/platform/implementation:types",
+ "//proto:connections_enums_cc_proto",
+ "@com_google_absl//absl/container:flat_hash_map",
+ "@com_google_absl//absl/container:flat_hash_set",
+ "@com_google_absl//absl/functional:any_invocable",
+ "@com_google_absl//absl/random",
+ "@com_google_absl//absl/strings",
+ "@com_google_absl//absl/strings:string_view",
+ "@com_google_absl//absl/time",
+ "@com_google_absl//absl/types:span",
+ ],
+)
+
+cc_library(
+ name = "endpoint_channel",
+ srcs = [
+ "base_endpoint_channel.cc",
+ "endpoint_channel_manager.cc",
+ ],
+ hdrs = [
+ "base_endpoint_channel.h",
+ "endpoint_channel.h",
+ "endpoint_channel_manager.h",
+ ],
+ visibility = ["//connections:__subpackages__"],
+ deps = [
+ ":client_proxy",
+ ":offline_frames",
+ "//connections:core_types",
+ "//connections/implementation/analytics",
+ "//connections/implementation/flags:connections_flags",
+ "//internal/flags:nearby_flags",
+ "//internal/platform:base",
+ "//internal/platform:logging",
+ "//internal/platform:types",
+ "//internal/platform/implementation:types",
+ "//proto:connections_enums_cc_proto",
+ "@com_google_absl//absl/base:core_headers",
+ "@com_google_absl//absl/container:flat_hash_map",
+ "@com_google_absl//absl/strings",
+ "@com_google_absl//absl/strings:string_view",
+ "@com_google_absl//absl/time",
+ "@com_google_ukey2//:ukey2",
+ ],
+)
+
cc_library(
name = "internal",
srcs = [
- "awdl_bwu_handler.cc",
- "awdl_endpoint_channel.cc",
- "base_bwu_handler.cc",
- "base_endpoint_channel.cc",
"base_pcp_handler.cc",
- "ble_endpoint_channel.cc",
- "ble_l2cap_endpoint_channel.cc",
- "bluetooth_bwu_handler.cc",
"bluetooth_device_name.cc",
- "bluetooth_endpoint_channel.cc",
"bwu_manager.cc",
- "client_proxy.cc",
"connections_authentication_transport.cc",
"encryption_runner.cc",
- "endpoint_channel_manager.cc",
"endpoint_manager.cc",
"injected_bluetooth_device_store.cc",
"internal_payload.cc",
"internal_payload_factory.cc",
- "offline_frames.cc",
- "offline_frames_validator.cc",
"offline_service_controller.cc",
"p2p_cluster_pcp_handler.cc",
"p2p_point_to_point_pcp_handler.cc",
@@ -80,41 +193,17 @@ cc_library(
"payload_manager.cc",
"pcp_manager.cc",
"service_controller_router.cc",
- "webrtc_bwu_handler.cc",
- "webrtc_bwu_handler_stub.cc",
- "webrtc_endpoint_channel.cc",
- "wifi_direct_bwu_handler.cc",
- "wifi_direct_endpoint_channel.cc",
- "wifi_hotspot_bwu_handler.cc",
- "wifi_hotspot_endpoint_channel.cc",
- "wifi_lan_bwu_handler.cc",
- "wifi_lan_endpoint_channel.cc",
"wifi_lan_service_info.cc",
],
hdrs = [
- "awdl_bwu_handler.h",
- "awdl_endpoint_channel.h",
- "base_bwu_handler.h",
- "base_endpoint_channel.h",
"base_pcp_handler.h",
- "ble_endpoint_channel.h",
- "ble_l2cap_endpoint_channel.h",
- "bluetooth_bwu_handler.h",
"bluetooth_device_name.h",
- "bluetooth_endpoint_channel.h",
- "bwu_handler.h",
"bwu_manager.h",
- "client_proxy.h",
"connections_authentication_transport.h",
"encryption_runner.h",
- "endpoint_channel.h",
- "endpoint_channel_manager.h",
"endpoint_manager.h",
"injected_bluetooth_device_store.h",
- "internal_payload.h",
"internal_payload_factory.h",
- "offline_frames.h",
- "offline_frames_validator.h",
"offline_service_controller.h",
"p2p_cluster_pcp_handler.h",
"p2p_point_to_point_pcp_handler.h",
@@ -124,49 +213,37 @@ cc_library(
"pcp_manager.h",
"service_controller.h",
"service_controller_router.h",
- "service_id_constants.h",
- "webrtc_bwu_handler.h",
- "webrtc_bwu_handler_stub.h",
- "webrtc_endpoint_channel.h",
- "wifi_direct_bwu_handler.h",
- "wifi_direct_endpoint_channel.h",
- "wifi_hotspot_bwu_handler.h",
- "wifi_hotspot_endpoint_channel.h",
- "wifi_lan_bwu_handler.h",
- "wifi_lan_endpoint_channel.h",
"wifi_lan_service_info.h",
],
- copts = [
- "-DCORE_ADAPTER_DLL",
- "-DNO_WEBRTC",
- ],
+ copts = ["-DCORE_ADAPTER_DLL"],
visibility = [
"//chrome/chromeos/assistant/data_migration/lib:__pkg__",
"//connections:__pkg__",
"//connections:partners",
"//connections/implementation/fuzzers:__pkg__",
- "//connections/implementation/mediums/multiplex:__pkg__",
"//sharing:__subpackages__",
],
deps = [
":ble_advertisement",
+ ":bwu_handler",
+ ":client_proxy",
+ ":endpoint_channel",
+ ":offline_frames",
+ ":service_id_constants",
":types",
"//connections:core_types",
"//connections/implementation/analytics",
"//connections/implementation/flags:connections_flags",
"//connections/implementation/mediums",
"//connections/implementation/mediums:utils",
- "//connections/implementation/mediums:webrtc_utils",
+ "//connections/implementation/mediums:webrtc",
+ "//connections/implementation/mediums:webrtc_peer_id",
"//connections/implementation/mediums/advertisements:dct_advertisement",
"//connections/implementation/mediums/advertisements:util",
"//connections/implementation/mediums/ble:ble_advertisement_header",
"//connections/implementation/mediums/ble:ble_socket",
"//connections/implementation/proto:offline_wire_formats_cc_proto",
"//connections/v3:v3_types",
- "//internal/analytics:event_logger",
- "//internal/base:file_path",
- "//internal/base:files",
- "//internal/base:masker",
"//internal/flags:nearby_flags",
"//internal/interop:authentication_status",
"//internal/interop:authentication_transport_interface",
@@ -175,7 +252,6 @@ cc_library(
"//internal/platform:cancellation_flag",
"//internal/platform:comm",
"//internal/platform:connection_info",
- "//internal/platform:error_code_recorder",
"//internal/platform:logging",
"//internal/platform:mac_address",
"//internal/platform:types",
@@ -184,7 +260,6 @@ cc_library(
"//internal/platform/implementation:platform",
"//internal/platform/implementation:types",
"//internal/platform/implementation:wifi_utils",
- "//internal/proto/analytics:connections_log_cc_proto",
"//proto:connections_enums_cc_proto",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/container:btree",
@@ -192,7 +267,6 @@ cc_library(
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/functional:any_invocable",
"@com_google_absl//absl/functional:bind_front",
- "@com_google_absl//absl/random",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
@@ -214,6 +288,7 @@ cc_library(
"fake_bwu_handler.h",
"fake_endpoint_channel.h",
"mock_device.h",
+ "mock_endpoint_channel.h",
"mock_service_controller.h",
"mock_service_controller_router.h",
"offline_simulation_user.h",
@@ -223,7 +298,11 @@ cc_library(
"//connections:__subpackages__",
],
deps = [
+ ":bwu_handler",
+ ":client_proxy",
+ ":endpoint_channel",
":internal",
+ ":offline_frames",
"//connections:core_types",
"//connections/implementation/analytics",
"//connections/implementation/flags:connections_flags",
@@ -247,30 +326,29 @@ cc_test(
name = "bwu_test",
srcs = [
"base_bwu_handler_test.cc",
- "bluetooth_bwu_test.cc",
"bwu_manager_test.cc",
- "wifi_direct_bwu_test.cc",
- "wifi_hotspot_bwu_test.cc",
],
deps = [
+ ":bwu_handler",
+ ":client_proxy",
+ ":endpoint_channel",
":internal",
":internal_test",
+ ":offline_frames",
+ ":service_id_constants",
"//connections:core_types",
+ "//connections/implementation/analytics",
"//connections/implementation/flags:connections_flags",
"//connections/implementation/mediums",
"//internal/flags:nearby_flags",
"//internal/platform:base",
- "//internal/platform:logging",
- "//internal/platform:test_util",
"//internal/platform:types",
- "//internal/platform/flags:platform_flags",
+ "//internal/platform/implementation:platform", # build_cleaner: keep
"//internal/platform/implementation/g3", # build_cleaner: keep
- "//internal/proto/analytics:connections_log_cc_proto",
"//proto:connections_enums_cc_proto",
"@com_github_protobuf_matchers//protobuf-matchers",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/strings",
- "@com_google_absl//absl/time",
"@com_google_googletest//:gtest_main",
],
)
@@ -279,6 +357,7 @@ cc_test(
name = "pcp_manager_test",
srcs = ["pcp_manager_test.cc"],
deps = [
+ ":endpoint_channel",
":internal",
":internal_test",
"//connections:core_types",
@@ -304,17 +383,20 @@ cc_test(
],
shard_count = 8,
deps = [
+ ":client_proxy",
+ ":endpoint_channel",
":internal",
":internal_test",
+ ":offline_frames",
":types",
"//connections:core_types",
"//connections/implementation/analytics",
+ "//connections/implementation/analytics:mock_analytics_recorder",
"//connections/implementation/flags:connections_flags",
"//connections/implementation/mediums",
- "//connections/implementation/mediums:webrtc_utils",
+ "//connections/implementation/mediums:webrtc_peer_id",
"//connections/implementation/proto:offline_wire_formats_cc_proto",
"//connections/v3:v3_types",
- "//internal/analytics:mock_event_logger",
"//internal/flags:nearby_flags",
"//internal/interop:authentication_status",
"//internal/interop:authentication_transport_interface",
@@ -325,7 +407,6 @@ cc_test(
"//internal/platform:test_util",
"//internal/platform:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
- "//internal/proto/analytics:connections_log_cc_proto",
"//proto:connections_enums_cc_proto",
"@com_github_protobuf_matchers//protobuf-matchers",
"@com_google_absl//absl/base:core_headers",
@@ -362,7 +443,7 @@ cc_test(
name = "offline_frames_test",
srcs = ["offline_frames_validator_test.cc"],
deps = [
- ":internal",
+ ":offline_frames",
"//connections:core_types",
"//connections/implementation/flags:connections_flags",
"//connections/implementation/proto:offline_wire_formats_cc_proto",
@@ -382,12 +463,11 @@ cc_test(
"client_proxy_test.cc",
],
deps = [
- ":internal",
- "//base:casts",
+ ":client_proxy",
"//connections:core_types",
+ "//connections/implementation/analytics:mock_analytics_recorder",
"//connections/implementation/flags:connections_flags",
"//connections/v3:v3_types",
- "//internal/analytics:mock_event_logger",
"//internal/flags:nearby_flags",
"//internal/interop:device",
"//internal/platform:base",
@@ -411,6 +491,8 @@ cc_test(
"encryption_runner_test.cc",
],
deps = [
+ ":client_proxy",
+ ":endpoint_channel",
":internal",
"//connections/implementation/analytics",
"//internal/platform:base",
@@ -432,9 +514,12 @@ cc_test(
"endpoint_manager_test.cc",
],
deps = [
+ ":client_proxy",
+ ":endpoint_channel",
":internal",
+ ":internal_test",
+ ":offline_frames",
"//connections:core_types",
- "//connections/implementation/analytics",
"//connections/implementation/flags:connections_flags",
"//internal/flags:nearby_flags",
"//internal/platform:base",
@@ -459,14 +544,17 @@ cc_test(
"endpoint_channel_manager_test.cc",
],
deps = [
+ ":client_proxy",
+ ":endpoint_channel",
":internal",
+ ":offline_frames",
+ "//connections/implementation/analytics",
"//connections/implementation/flags:connections_flags",
"//internal/flags:nearby_flags",
"//internal/platform:base",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
- "//internal/proto/analytics:connections_log_cc_proto",
"//proto:connections_enums_cc_proto",
"@com_github_protobuf_matchers//protobuf-matchers",
"@com_google_absl//absl/strings",
@@ -484,13 +572,11 @@ cc_test(
],
deps = [
":internal",
- "//connections/implementation/analytics",
+ ":internal_test",
"//internal/platform:base",
"//internal/platform/implementation/g3", # build_cleaner: keep
- "//proto:connections_enums_cc_proto",
"@com_github_protobuf_matchers//protobuf-matchers",
"@com_google_absl//absl/strings:string_view",
- "@com_google_absl//absl/time",
"@com_google_googletest//:gtest_main",
],
)
@@ -503,8 +589,8 @@ cc_test(
deps = [
":internal",
":internal_test",
+ ":offline_frames",
"//connections:core_types",
- "//connections/implementation/analytics",
"//internal/platform:base",
"//internal/platform:logging",
"//internal/platform:test_util",
@@ -525,6 +611,7 @@ cc_test(
"service_controller_router_test.cc",
],
deps = [
+ ":client_proxy",
":internal",
":internal_test",
"//connections:core_types",
@@ -575,9 +662,11 @@ cc_test(
],
deps = [
":internal",
+ ":offline_frames",
"//connections:core_types",
"//connections/implementation/proto:offline_wire_formats_cc_proto",
"//internal/platform:base",
+ "//internal/platform:comm",
"//internal/platform:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
"@com_github_protobuf_matchers//protobuf-matchers",
@@ -586,26 +675,3 @@ cc_test(
"@com_google_googletest//:gtest_main",
],
)
-
-cc_test(
- name = "wifi_lan_bwu_handler_test",
- srcs = [
- "wifi_lan_bwu_handler_test.cc",
- ],
- deps = [
- ":internal",
- "//connections:core_types",
- "//connections/implementation/mediums",
- "//internal/analytics:mock_event_logger",
- "//internal/platform:base",
- "//internal/platform:mock_platform",
- "//internal/platform:test_util",
- "//internal/platform/implementation:comm",
- "//internal/platform/implementation:platform",
- "//internal/platform/implementation:platform_impl",
- "//internal/proto/analytics:connections_log_cc_proto",
- "@com_github_protobuf_matchers//protobuf-matchers",
- "@com_google_absl//absl/strings:string_view",
- "@com_google_googletest//:gtest_main",
- ],
-)
diff --git a/connections/implementation/analytics/BUILD b/connections/implementation/analytics/BUILD
index 903272ff..d893305c 100644
--- a/connections/implementation/analytics/BUILD
+++ b/connections/implementation/analytics/BUILD
@@ -20,59 +20,92 @@ cc_library(
name = "analytics",
srcs = [
"analytics_recorder.cc",
- "throughput_recorder.cc",
],
hdrs = [
"advertising_metadata_params.h",
"analytics_recorder.h",
"connection_attempt_metadata_params.h",
"discovery_metadata_params.h",
- "packet_meta_data.h",
- "throughput_recorder.h",
+ "operation_result_with_medium.h",
],
copts = ["-DCORE_ADAPTER_DLL"],
visibility = ["//connections:__subpackages__"],
deps = [
"//connections:core_types",
- "//internal/analytics:event_logger",
+ "//internal/platform:error_code_recorder",
+ "//proto:connections_enums_cc_proto",
+ "@com_google_absl//absl/time",
+ ],
+)
+
+cc_library(
+ name = "analytics_recorder_impl",
+ srcs = [
+ "analytics_recorder_impl.cc",
+ ],
+ hdrs = [
+ "analytics_recorder_impl.h",
+ ],
+ copts = ["-DCORE_ADAPTER_DLL"],
+ visibility = [
+ "//connections/c:__pkg__",
+ "//sharing:__pkg__",
+ ],
+ deps = [
+ ":analytics",
+ "//connections:core_types",
"//internal/platform:error_code_recorder",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform/implementation:types",
- "//internal/proto/analytics:connections_log_cc_proto",
+ "//location/nearby/analytics/cpp/logging:event_logger",
+ "//location/nearby/analytics/cpp/proto:connections_log_cc_proto",
"//proto:connections_enums_cc_proto",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/container:btree",
- "@com_google_absl//absl/container:flat_hash_map",
- "@com_google_absl//absl/meta:type_traits",
- "@com_google_absl//absl/strings",
- "@com_google_absl//absl/strings:str_format",
+ "@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/time",
"@com_google_protobuf//:protobuf_lite",
],
)
+cc_library(
+ name = "mock_analytics_recorder",
+ testonly = True,
+ hdrs = [
+ "mock_analytics_recorder.h",
+ ],
+ compatible_with = ["//buildenv/target:non_prod"],
+ visibility = ["//connections:__subpackages__"],
+ deps = [
+ ":analytics",
+ "//connections:core_types",
+ "//internal/platform:error_code_recorder",
+ "//proto:connections_enums_cc_proto",
+ "@com_google_absl//absl/time",
+ "@com_google_googletest//:gtest_for_library_testonly",
+ ],
+)
+
cc_test(
name = "analytics_test",
size = "small",
srcs = [
- "analytics_recorder_test.cc",
- "throughput_recorder_test.cc",
+ "analytics_recorder_impl_test.cc",
],
shard_count = 16,
deps = [
":analytics",
+ ":analytics_recorder_impl",
"//connections:core_types",
- "//internal/analytics:mock_event_logger",
"//internal/platform:base",
"//internal/platform:error_code_recorder",
- "//internal/platform:logging",
"//internal/platform:test_util",
"//internal/platform:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
- "//internal/proto/analytics:connections_log_cc_proto",
- "//internal/test",
+ "//location/nearby/analytics/cpp/logging:mock_event_logger",
+ "//location/nearby/analytics/cpp/proto:connections_log_cc_proto",
"//net/proto2/contrib/parse_proto:parse_text_proto",
"//proto:connections_enums_cc_proto",
"@com_github_protobuf_matchers//protobuf-matchers",
diff --git a/connections/implementation/analytics/advertising_metadata_params.h b/connections/implementation/analytics/advertising_metadata_params.h
index 2b3b3372..2b40864b 100644
--- a/connections/implementation/analytics/advertising_metadata_params.h
+++ b/connections/implementation/analytics/advertising_metadata_params.h
@@ -17,7 +17,7 @@
#include
-#include "internal/proto/analytics/connections_log.pb.h"
+#include "connections/implementation/analytics/operation_result_with_medium.h"
namespace nearby {
@@ -26,8 +26,7 @@ struct AdvertisingMetadataParams {
bool is_extended_advertisement_supported = false;
int connected_ap_frequency = 0;
bool is_nfc_available = false;
- std::vector
+ std::vector
operation_result_with_mediums = {};
};
diff --git a/connections/implementation/analytics/analytics_recorder.cc b/connections/implementation/analytics/analytics_recorder.cc
index f91edcef..67649104 100644
--- a/connections/implementation/analytics/analytics_recorder.cc
+++ b/connections/implementation/analytics/analytics_recorder.cc
@@ -14,921 +14,35 @@
#include "connections/implementation/analytics/analytics_recorder.h"
-#include
-#include
-#include
#include
#include
-#include
#include
-#include "absl/algorithm/container.h"
-#include "absl/container/btree_map.h"
-#include "absl/strings/string_view.h"
-#include "absl/time/time.h"
#include "connections/implementation/analytics/advertising_metadata_params.h"
#include "connections/implementation/analytics/connection_attempt_metadata_params.h"
#include "connections/implementation/analytics/discovery_metadata_params.h"
-#include "connections/payload_type.h"
-#include "connections/strategy.h"
-#include "internal/analytics/event_logger.h"
-#include "internal/platform/error_code_params.h"
-#include "internal/platform/implementation/system_clock.h"
-#include "internal/platform/logging.h"
-#include "internal/platform/mutex_lock.h"
-#include "internal/proto/analytics/connections_log.pb.h"
+#include "connections/implementation/analytics/operation_result_with_medium.h"
#include "proto/connections_enums.pb.h"
-#include "google/protobuf/repeated_ptr_field.h"
-namespace nearby {
-namespace analytics {
+namespace nearby::analytics {
-namespace {
-// const char kVersion_1_0_0[] = "v1.0.0";
-const char kVersion[] = "v1.5.0";
-constexpr absl::string_view kOnStartClientSession = "OnStartClientSession";
-const absl::Duration kConnectionTokenMaxLife = absl::Hours(24);
-
-using ::location::nearby::analytics::proto::ConnectionsLog;
-using ::location::nearby::proto::connections::ACCEPTED;
-using ::location::nearby::proto::connections::ADVERTISER;
-using ::location::nearby::proto::connections::BandwidthUpgradeErrorStage;
-using ::location::nearby::proto::connections::BandwidthUpgradeResult;
-using ::location::nearby::proto::connections::BYTES;
-using ::location::nearby::proto::connections::CLIENT_SESSION;
-using ::location::nearby::proto::connections::CONNECTION_CLOSED;
-using ::location::nearby::proto::connections::ConnectionAttemptDirection;
-using ::location::nearby::proto::connections::ConnectionAttemptResult;
-using ::location::nearby::proto::connections::ConnectionAttemptType;
using ::location::nearby::proto::connections::ConnectionBand;
-using ::location::nearby::proto::connections::ConnectionRequestResponse;
-using ::location::nearby::proto::connections::ConnectionsStrategy;
using ::location::nearby::proto::connections::ConnectionTechnology;
-using ::location::nearby::proto::connections::DisconnectionReason;
-using ::location::nearby::proto::connections::DISCOVERER;
-using ::location::nearby::proto::connections::ERROR_CODE;
-using ::location::nearby::proto::connections::EventType;
-using ::location::nearby::proto::connections::FILE;
-using ::location::nearby::proto::connections::IGNORED;
-using ::location::nearby::proto::connections::INCOMING;
-using ::location::nearby::proto::connections::INITIAL;
using ::location::nearby::proto::connections::Medium;
-using ::location::nearby::proto::connections::MOVED_TO_NEW_MEDIUM;
-using ::location::nearby::proto::connections::NOT_SENT;
-using ::location::nearby::proto::connections::OperationResultCategory;
using ::location::nearby::proto::connections::OperationResultCode;
-using ::location::nearby::proto::connections::OUTGOING;
-using ::location::nearby::proto::connections::P2P_CLUSTER;
-using ::location::nearby::proto::connections::P2P_POINT_TO_POINT;
-using ::location::nearby::proto::connections::P2P_STAR;
-using ::location::nearby::proto::connections::PayloadStatus;
-using ::location::nearby::proto::connections::PayloadType;
-using ::location::nearby::proto::connections::REJECTED;
-using ::location::nearby::proto::connections::RESULT_SUCCESS;
-using ::location::nearby::proto::connections::SessionRole;
-using ::location::nearby::proto::connections::START_CLIENT_SESSION;
-using ::location::nearby::proto::connections::START_STRATEGY_SESSION;
-using ::location::nearby::proto::connections::STOP_CLIENT_SESSION;
-using ::location::nearby::proto::connections::STOP_STRATEGY_SESSION;
-using ::location::nearby::proto::connections::StopAdvertisingReason;
-using ::location::nearby::proto::connections::StopDiscoveringReason;
-using ::location::nearby::proto::connections::STREAM;
-using ::location::nearby::proto::connections::UNFINISHED;
-using ::location::nearby::proto::connections::UNFINISHED_ERROR;
-using ::location::nearby::proto::connections::UNKNOWN_MEDIUM;
-using ::location::nearby::proto::connections::UNKNOWN_PAYLOAD_TYPE;
-using ::location::nearby::proto::connections::UNKNOWN_STRATEGY;
-using ::location::nearby::proto::connections::UPGRADE_RESULT_SUCCESS;
-using ::location::nearby::proto::connections::UPGRADE_SUCCESS;
-using ::location::nearby::proto::connections::UPGRADE_UNFINISHED;
-using ::location::nearby::proto::connections::UPGRADED;
-using ::nearby::analytics::EventLogger;
-using SafeDisconnectionResult = ::location::nearby::analytics::proto::
- ConnectionsLog::EstablishedConnection::SafeDisconnectionResult;
-
-OperationResultCategory ConvertToOperationResultCategory(
- OperationResultCode result_code) {
- if (result_code == OperationResultCode::DETAIL_SUCCESS) {
- return OperationResultCategory::CATEGORY_SUCCESS;
- }
- // TODO(b/409865630): check later if we need to add back the dct error.
- // Section of CATEGORY_DCT_ERROR, from 5000 to 5499 if (result_code
- // >= OperationResultCode::DCT_ERROR_BLE_DISABLED) {
- // return OperationResultCategory::CATEGORY_DCT_ERROR;
- //}
-
- // Section of CATEGORY_NEARBY_ERROR, starting from 4500 to 4999
- if (result_code >=
- OperationResultCode::NEARBY_BLE_ADVERTISEMENT_MAPPING_TO_MAC_ERROR) {
- return OperationResultCategory::CATEGORY_NEARBY_ERROR;
- }
- // Section of CATEGORY_CONNECTIVITY_ERROR, starting from 3500 to 4499
- if (result_code >=
- OperationResultCode::CONNECTIVITY_WIFI_AWARE_ATTACH_FAILURE) {
- return OperationResultCategory::CATEGORY_CONNECTIVITY_ERROR;
- }
- // Section of CATEGORY_IO_ERROR, from 3000 to 3499
- if (result_code >= OperationResultCode::IO_FILE_OPENING_ERROR) {
- return OperationResultCategory::CATEGORY_IO_ERROR;
- }
- // Section of CATEGORY_MISCELLANEOUS, from 2500 to 2999
- if (result_code >=
- OperationResultCode::MISCELLEANEOUS_BLUETOOTH_MAC_ADDRESS_NULL) {
- return OperationResultCategory::CATEGORY_MISCELLANEOUS;
- }
- // Section of CATEGORY_CLIENT_ERROR, from 2000 to 2499
- if (result_code >=
- OperationResultCode::
- CLIENT_WIFI_DIRECT_ALREADY_HOSTING_DIRECT_GROUP_FOR_THIS_CLIENT) {
- return OperationResultCategory::CATEGORY_CLIENT_ERROR;
- }
- // Section of CATEGORY_MEDIUM_UNAVAILABLE, from 1500 to 1999
- if (result_code >= OperationResultCode::
- MEDIUM_UNAVAILABLE_WIFI_AWARE_RESOURCE_NOT_AVAILABLE) {
- return OperationResultCategory::CATEGORY_MEDIUM_UNAVAILABLE;
- }
- // Section of CATEGORY_DEVICE_STATE_ERROR, from 1000 to 1499
- if (result_code >=
- OperationResultCode::DEVICE_STATE_ERROR_UNFINISHED_UPGRADE_ATTEMPTS) {
- return OperationResultCategory::CATEGORY_DEVICE_STATE_ERROR;
- }
- // Section of CATEGORY_CLIENT_CANCELLATION, from 500 to 999
- if (result_code >=
- OperationResultCode::CLIENT_CANCELLATION_REMOTE_IN_CANCELED_STATE) {
- return OperationResultCategory::CATEGORY_CLIENT_CANCELLATION;
- }
- // Clarify other non success cases as unknown
- return OperationResultCategory::CATEGORY_UNKNOWN;
-}
-} // namespace
-
-AnalyticsRecorder::AnalyticsRecorder(EventLogger* event_logger)
- : event_logger_(event_logger) {
- VLOG(1) << "Start AnalyticsRecorder ctor event_logger_=" << event_logger_;
- LogStartSession();
-}
-
-AnalyticsRecorder::~AnalyticsRecorder() = default;
-
-bool AnalyticsRecorder::IsSessionLogged() {
- MutexLock lock(&mutex_);
- return session_was_logged_;
-}
-
-int AnalyticsRecorder::GetLatestUpdateIndexLocked(
- const std::vector& list) {
- int latest_update_index = 0;
- for (const auto& operation_result_with_medium : list) {
- if (operation_result_with_medium.update_index() > latest_update_index) {
- latest_update_index = operation_result_with_medium.update_index();
- }
- }
- return latest_update_index;
-}
-
-void AnalyticsRecorder::OnStartAdvertising(
- connections::Strategy strategy, const std::vector& mediums,
- AdvertisingMetadataParams* advertising_metadata_params) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnStartAdvertising")) {
- return;
- }
- if (!strategy.IsValid()) {
- LOG(INFO) << "AnalyticsRecorder OnStartAdvertising with unknown "
- "strategy, bail out.";
- return;
- }
- // Initialize/update a StrategySession.
- UpdateStrategySessionLocked(strategy, ADVERTISER);
-
- // Initialize and set a AdvertisingPhase.
- started_advertising_phase_time_ = SystemClock::ElapsedRealtime();
- current_advertising_phase_ =
- std::make_unique();
- absl::c_copy(mediums, RepeatedFieldBackInserter(
- current_advertising_phase_->mutable_medium()));
- // Set a AdvertisingMetadata.
- AdvertisingMetadataParams default_params = {};
- if (advertising_metadata_params == nullptr) {
- advertising_metadata_params = &default_params;
- }
- if (!advertising_metadata_params->operation_result_with_mediums.empty()) {
- absl::c_copy(advertising_metadata_params->operation_result_with_mediums,
- RepeatedFieldBackInserter(
- current_advertising_phase_->mutable_adv_dis_result()));
- }
- auto* advertising_metadata =
- current_advertising_phase_->mutable_advertising_metadata();
- advertising_metadata->set_supports_extended_ble_advertisements(
- advertising_metadata_params->is_extended_advertisement_supported);
- advertising_metadata->set_connected_ap_frequency(
- advertising_metadata_params->connected_ap_frequency);
- advertising_metadata->set_supports_nfc_technology(
- advertising_metadata_params->is_nfc_available);
-}
-
-void AnalyticsRecorder::OnStopAdvertising() {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnStopAdvertising")) {
- return;
- }
- RecordAdvertisingPhaseDurationAndReasonLocked(/* on_stop= */ true);
-}
-
-int AnalyticsRecorder::GetNextAdvertisingUpdateIndex() {
- MutexLock lock(&mutex_);
-
- if (current_advertising_phase_ == nullptr) {
- return 0;
- }
- return GetLatestUpdateIndexLocked(
- std::vector(
- current_advertising_phase_->adv_dis_result().begin(),
- current_advertising_phase_->adv_dis_result().end())) +
- 1;
-}
-
-void AnalyticsRecorder::OnStartDiscovery(
- connections::Strategy strategy, const std::vector& mediums,
- DiscoveryMetadataParams* discovery_metadata_params) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnStartDiscovery")) {
- return;
- }
- if (!strategy.IsValid()) {
- LOG(INFO) << "AnalyticsRecorder OnStartDiscovery unknown "
- "strategy enter, bail out.";
- return;
- }
-
- // Initialize/update a StrategySession.
- UpdateStrategySessionLocked(strategy, DISCOVERER);
-
- // Initialize and set a DiscoveryPhase.
- started_discovery_phase_time_ = SystemClock::ElapsedRealtime();
- current_discovery_phase_ = std::make_unique();
- absl::c_copy(mediums, RepeatedFieldBackInserter(
- current_discovery_phase_->mutable_medium()));
- // Set a DiscoveryMetadata.
- DiscoveryMetadataParams default_params = {};
- if (discovery_metadata_params == nullptr) {
- discovery_metadata_params = &default_params;
- }
- if (!discovery_metadata_params->operation_result_with_mediums.empty()) {
- absl::c_copy(discovery_metadata_params->operation_result_with_mediums,
- RepeatedFieldBackInserter(
- current_discovery_phase_->mutable_adv_dis_result()));
- }
- auto* discovery_metadata =
- current_discovery_phase_->mutable_discovery_metadata();
- discovery_metadata->set_supports_extended_ble_advertisements(
- discovery_metadata_params->is_extended_advertisement_supported);
- discovery_metadata->set_connected_ap_frequency(
- discovery_metadata_params->connected_ap_frequency);
- discovery_metadata->set_supports_nfc_technology(
- discovery_metadata_params->is_nfc_available);
-}
-
-void AnalyticsRecorder::OnStopDiscovery() {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnStopDiscovery")) {
- return;
- }
- RecordDiscoveryPhaseDurationAndReasonLocked(/*on_stop=*/true);
-}
-
-int AnalyticsRecorder::GetNextDiscoveryUpdateIndex() {
- MutexLock lock(&mutex_);
- if (current_discovery_phase_ == nullptr) {
- return 0;
- }
- return GetLatestUpdateIndexLocked(
- std::vector(
- current_discovery_phase_->adv_dis_result().begin(),
- current_discovery_phase_->adv_dis_result().end())) +
- 1;
-}
-
-void AnalyticsRecorder::OnStartedIncomingConnectionListening(
- connections::Strategy strategy) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnStartedIncomingConnectionListening")) {
- return;
- }
- UpdateStrategySessionLocked(strategy, ADVERTISER);
- if (started_advertising_phase_time_ == absl::InfinitePast()) {
- started_advertising_phase_time_ = SystemClock::ElapsedRealtime();
- }
-}
-
-void AnalyticsRecorder::OnStoppedIncomingConnectionListening() {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnStoppedIncomingConnectionListening")) {
- return;
- }
- RecordAdvertisingPhaseDurationAndReasonLocked(/* on_stop= */ false);
-}
-
-void AnalyticsRecorder::OnEndpointFound(Medium medium) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnEndpointFound")) {
- return;
- }
- if (current_discovery_phase_ == nullptr) {
- LOG(INFO) << "Unable to record discovered endpoint due to null "
- "current_discovery_phase_";
- return;
- }
- ConnectionsLog::DiscoveredEndpoint* discovered_endpoint =
- current_discovery_phase_->add_discovered_endpoint();
- discovered_endpoint->set_medium(medium);
- discovered_endpoint->set_latency_millis(absl::ToInt64Milliseconds(
- SystemClock::ElapsedRealtime() - started_discovery_phase_time_));
-}
-
-void AnalyticsRecorder::OnRequestConnection(
- const connections::Strategy& strategy, const std::string& endpoint_id) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("onRequestConnection")) {
- return;
- }
-
- UpdateStrategySessionLocked(strategy, DISCOVERER);
- if (started_discovery_phase_time_ == absl::InfinitePast()) {
- started_discovery_phase_time_ = SystemClock::ElapsedRealtime();
- }
-}
-
-void AnalyticsRecorder::OnConnectionRequestReceived(
- const std::string& remote_endpoint_id) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnConnectionRequestReceived")) {
- return;
- }
- absl::Time current_time = SystemClock::ElapsedRealtime();
- auto connection_request =
- std::make_unique();
- connection_request->set_duration_millis(absl::ToUnixMillis(current_time));
- connection_request->set_request_delay_millis(absl::ToInt64Milliseconds(
- current_time - started_advertising_phase_time_));
- incoming_connection_requests_.insert(
- {remote_endpoint_id, std::move(connection_request)});
-}
-
-void AnalyticsRecorder::OnConnectionRequestSent(
- const std::string& remote_endpoint_id) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnConnectionRequestSent")) {
- return;
- }
- absl::Time current_time = SystemClock::ElapsedRealtime();
- auto connection_request =
- std::make_unique();
- connection_request->set_duration_millis(absl::ToUnixMillis(current_time));
- connection_request->set_request_delay_millis(
- absl::ToInt64Milliseconds(current_time - started_discovery_phase_time_));
- outgoing_connection_requests_.insert(
- {remote_endpoint_id, std::move(connection_request)});
-}
-
-void AnalyticsRecorder::OnRemoteEndpointAccepted(
- const std::string& remote_endpoint_id) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnRemoteEndpointAccepted")) {
- return;
- }
- RemoteEndpointRespondedLocked(remote_endpoint_id, ACCEPTED);
-}
-
-void AnalyticsRecorder::OnLocalEndpointAccepted(
- const std::string& remote_endpoint_id) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnLocalEndpointAccepted")) {
- return;
- }
- LocalEndpointRespondedLocked(remote_endpoint_id, ACCEPTED);
-}
-
-void AnalyticsRecorder::OnRemoteEndpointRejected(
- const std::string& remote_endpoint_id) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnRemoteEndpointRejected")) {
- return;
- }
- RemoteEndpointRespondedLocked(remote_endpoint_id, REJECTED);
-}
-
-void AnalyticsRecorder::OnLocalEndpointRejected(
- const std::string& remote_endpoint_id) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnLocalEndpointRejected")) {
- return;
- }
- LocalEndpointRespondedLocked(remote_endpoint_id, REJECTED);
-}
-
-void AnalyticsRecorder::OnIncomingConnectionAttempt(
- ConnectionAttemptType type, Medium medium, ConnectionAttemptResult result,
- absl::Duration duration, const std::string& connection_token,
- ConnectionAttemptMetadataParams* connection_attempt_metadata_params) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnIncomingConnectionAttempt")) {
- return;
- }
- if (current_strategy_session_ == nullptr) {
- LOG(INFO) << "Unable to record incoming connection attempt due to "
- "null current_strategy_session_";
- return;
- }
-
- ConnectionAttemptMetadataParams default_params = {};
- if (connection_attempt_metadata_params == nullptr) {
- connection_attempt_metadata_params = &default_params;
- }
- OnIncomingConnectionAttemptLocked(type, medium, result, duration,
- connection_token,
- connection_attempt_metadata_params);
-}
-
-void AnalyticsRecorder::OnIncomingConnectionAttemptLocked(
- location::nearby::proto::connections::ConnectionAttemptType type,
- location::nearby::proto::connections::Medium medium,
- location::nearby::proto::connections::ConnectionAttemptResult result,
- absl::Duration duration, const std::string& connection_token,
- ConnectionAttemptMetadataParams* connection_attempt_metadata_params) {
- auto* connection_attempt =
- current_strategy_session_->add_connection_attempt();
- connection_attempt->set_duration_millis(absl::ToInt64Milliseconds(duration));
- connection_attempt->set_type(type);
- connection_attempt->set_direction(INCOMING);
- connection_attempt->set_medium(medium);
- connection_attempt->set_attempt_result(result);
- connection_attempt->set_connection_token(connection_token);
-
- auto* connection_attempt_metadata =
- connection_attempt->mutable_connection_attempt_metadata();
- connection_attempt_metadata->set_technology(
- connection_attempt_metadata_params->technology);
- connection_attempt_metadata->set_band(
- connection_attempt_metadata_params->band);
- connection_attempt_metadata->set_frequency(
- connection_attempt_metadata_params->frequency);
- connection_attempt_metadata->set_network_operator(
- connection_attempt_metadata_params->network_operator);
- connection_attempt_metadata->set_country_code(
- connection_attempt_metadata_params->country_code);
- connection_attempt_metadata->set_frequency(
- connection_attempt_metadata_params->frequency);
- connection_attempt_metadata->set_is_tdls_used(
- connection_attempt_metadata_params->is_tdls_used);
- connection_attempt_metadata->set_wifi_hotspot_status(
- connection_attempt_metadata_params->wifi_hotspot_enabled);
- connection_attempt_metadata->set_try_counts(
- connection_attempt_metadata_params->try_count);
- connection_attempt_metadata->set_max_tx_speed(
- connection_attempt_metadata_params->max_wifi_tx_speed);
- connection_attempt_metadata->set_max_rx_speed(
- connection_attempt_metadata_params->max_wifi_rx_speed);
- connection_attempt_metadata->set_wifi_channel_width(
- connection_attempt_metadata_params->channel_width);
-
- auto operation_result_proto =
- std::make_unique();
- operation_result_proto->set_result_code(
- connection_attempt_metadata_params->operation_result_code);
- operation_result_proto->set_result_category(ConvertToOperationResultCategory(
- connection_attempt_metadata_params->operation_result_code));
- connection_attempt->set_allocated_operation_result(
- operation_result_proto.release());
-}
-
-void AnalyticsRecorder::OnOutgoingConnectionAttempt(
- const std::string& remote_endpoint_id, ConnectionAttemptType type,
- Medium medium, ConnectionAttemptResult result, absl::Duration duration,
- const std::string& connection_token,
- ConnectionAttemptMetadataParams* connection_attempt_metadata_params) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnOutgoingConnectionAttempt")) {
- return;
- }
- if (current_strategy_session_ == nullptr) {
- LOG(INFO) << "Unable to record outgoing connection attempt due to "
- "null current_strategy_session_";
- return;
- }
-
- ConnectionAttemptMetadataParams default_params = {};
- if (connection_attempt_metadata_params == nullptr) {
- connection_attempt_metadata_params = &default_params;
- }
-
- // For the case of transfer a big file and the upgrades always failure, then
- // there will have repeating upgrade attempt and cause many same attempt value
- // be log. So add a method to skip.
- if (ConnectionAttemptResultCodeExistedLocked(
- medium, OUTGOING, connection_token, type,
- connection_attempt_metadata_params->operation_result_code)) {
- return;
- }
-
- OnOutgoingConnectionAttemptLocked(remote_endpoint_id, type, medium, result,
- duration, connection_token,
- connection_attempt_metadata_params);
-}
-
-void AnalyticsRecorder::OnOutgoingConnectionAttemptLocked(
- const std::string& remote_endpoint_id, ConnectionAttemptType type,
- Medium medium, ConnectionAttemptResult result, absl::Duration duration,
- const std::string& connection_token,
- ConnectionAttemptMetadataParams* connection_attempt_metadata_params) {
- auto* connection_attempt =
- current_strategy_session_->add_connection_attempt();
- connection_attempt->set_duration_millis(absl::ToInt64Milliseconds(duration));
- connection_attempt->set_type(type);
- connection_attempt->set_direction(OUTGOING);
- connection_attempt->set_medium(medium);
- connection_attempt->set_attempt_result(result);
- connection_attempt->set_connection_token(connection_token);
-
- auto* connection_attempt_metadata =
- connection_attempt->mutable_connection_attempt_metadata();
- connection_attempt_metadata->set_technology(
- connection_attempt_metadata_params->technology);
- connection_attempt_metadata->set_band(
- connection_attempt_metadata_params->band);
- connection_attempt_metadata->set_frequency(
- connection_attempt_metadata_params->frequency);
- connection_attempt_metadata->set_network_operator(
- connection_attempt_metadata_params->network_operator);
- connection_attempt_metadata->set_country_code(
- connection_attempt_metadata_params->country_code);
- connection_attempt_metadata->set_frequency(
- connection_attempt_metadata_params->frequency);
- connection_attempt_metadata->set_is_tdls_used(
- connection_attempt_metadata_params->is_tdls_used);
- connection_attempt_metadata->set_wifi_hotspot_status(
- connection_attempt_metadata_params->wifi_hotspot_enabled);
- connection_attempt_metadata->set_try_counts(
- connection_attempt_metadata_params->try_count);
- connection_attempt_metadata->set_max_tx_speed(
- connection_attempt_metadata_params->max_wifi_tx_speed);
- connection_attempt_metadata->set_max_rx_speed(
- connection_attempt_metadata_params->max_wifi_rx_speed);
- connection_attempt_metadata->set_wifi_channel_width(
- connection_attempt_metadata_params->channel_width);
-
- auto operation_result_proto =
- std::make_unique();
- operation_result_proto->set_result_code(
- connection_attempt_metadata_params->operation_result_code);
- operation_result_proto->set_result_category(ConvertToOperationResultCategory(
- connection_attempt_metadata_params->operation_result_code));
- connection_attempt->set_allocated_operation_result(
- operation_result_proto.release());
-
- if (type == INITIAL && result != RESULT_SUCCESS) {
- auto it = outgoing_connection_requests_.find(remote_endpoint_id);
- if (it != outgoing_connection_requests_.end()) {
- // An outgoing, initial ConnectionAttempt has a corresponding
- // ConnectionRequest that, since the ConnectionAttempt has failed, will
- // never be delivered to the advertiser.
- auto pair = outgoing_connection_requests_.extract(it);
- std::unique_ptr& connection_request =
- pair.mapped();
- connection_request->set_local_response(NOT_SENT);
- connection_request->set_remote_response(NOT_SENT);
- UpdateDiscovererConnectionRequestLocked(connection_request.get());
- }
- }
-}
-
-void AnalyticsRecorder::OnConnectionEstablished(
- const std::string& endpoint_id, Medium medium,
- const std::string& connection_token) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnConnectionEstablished")) {
- return;
- }
- auto it = active_connections_.find(endpoint_id);
- if (it != active_connections_.end()) {
- const std::unique_ptr& logical_connection = it->second;
- logical_connection->PhysicalConnectionEstablished(medium, connection_token);
- } else {
- active_connections_.insert(
- {endpoint_id,
- std::make_unique(medium, connection_token)});
- }
-}
-
-void AnalyticsRecorder::OnConnectionClosed(const std::string& endpoint_id,
- Medium medium,
- DisconnectionReason reason,
- SafeDisconnectionResult result) {
- MutexLock lock(&mutex_);
- LOG(INFO) << __func__
- << ": OnConnectionClosed is called with endpoint_id:" << endpoint_id
- << ", medium:" << Medium_Name(medium)
- << ", reason:" << DisconnectionReason_Name(reason)
- << ", result:" << result;
-
- if (!CanRecordAnalyticsLocked("OnConnectionClosed")) {
- return;
- }
-
- if (current_strategy_session_ == nullptr) {
- VLOG(1) << "AnalyticsRecorder CanRecordAnalytics Unexpected call "
- << __func__ << " since current_strategy_session_ is required.";
- return;
- }
-
- auto it = active_connections_.find(endpoint_id);
- if (it == active_connections_.end()) {
- return;
- }
- const std::unique_ptr& logical_connection = it->second;
- logical_connection->PhysicalConnectionClosed(medium, reason, result);
- if (reason != UPGRADED) {
- // Unless this is an upgraded connection, remove this from our active
- // connections. Any future communication with an endpoint will need to be
- // re-established with a new ConnectionRequest.
- auto pair = active_connections_.extract(it);
- std::unique_ptr& logical_connection = pair.mapped();
-
- absl::c_copy(
- logical_connection->GetEstablisedConnections(),
- RepeatedFieldBackInserter(
- current_strategy_session_->mutable_established_connection()));
- }
-}
-
-void AnalyticsRecorder::OnIncomingPayloadStarted(
- const std::string& endpoint_id, std::int64_t payload_id,
- connections::PayloadType type, std::int64_t total_size_bytes) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnIncomingPayloadStarted")) {
- return;
- }
- auto it = active_connections_.find(endpoint_id);
- if (it == active_connections_.end()) {
- return;
- }
- const std::unique_ptr& logical_connection = it->second;
- logical_connection->IncomingPayloadStarted(
- payload_id, PayloadTypeToProtoPayloadType(type), total_size_bytes);
-}
-
-void AnalyticsRecorder::OnPayloadChunkReceived(const std::string& endpoint_id,
- std::int64_t payload_id,
- std::int64_t chunk_size_bytes) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnPayloadChunkReceived")) {
- return;
- }
- auto it = active_connections_.find(endpoint_id);
- if (it == active_connections_.end()) {
- return;
- }
- const std::unique_ptr& logical_connection = it->second;
- logical_connection->ChunkReceived(payload_id, chunk_size_bytes);
-}
-
-void AnalyticsRecorder::OnIncomingPayloadDone(
- const std::string& endpoint_id, std::int64_t payload_id,
- PayloadStatus status, OperationResultCode operation_result_code) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnIncomingPayloadDone")) {
- return;
- }
- auto it = active_connections_.find(endpoint_id);
- if (it == active_connections_.end()) {
- return;
- }
- const std::unique_ptr& logical_connection = it->second;
- logical_connection->IncomingPayloadDone(payload_id, status,
- operation_result_code);
-}
-
-void AnalyticsRecorder::OnOutgoingPayloadStarted(
- const std::vector& endpoint_ids, std::int64_t payload_id,
- connections::PayloadType type, std::int64_t total_size_bytes) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnOutgoingPayloadStarted")) {
- return;
- }
- for (const auto& endpoint_id : endpoint_ids) {
- auto it = active_connections_.find(endpoint_id);
- if (it == active_connections_.end()) {
- continue;
- }
- const std::unique_ptr& logical_connection = it->second;
- logical_connection->OutgoingPayloadStarted(
- payload_id, PayloadTypeToProtoPayloadType(type), total_size_bytes);
- }
-}
-
-void AnalyticsRecorder::OnPayloadChunkSent(const std::string& endpoint_id,
- std::int64_t payload_id,
- std::int64_t chunk_size_bytes) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnPayloadChunkSent")) {
- return;
- }
- auto it = active_connections_.find(endpoint_id);
- if (it == active_connections_.end()) {
- return;
- }
- const std::unique_ptr& logical_connection = it->second;
- logical_connection->ChunkSent(payload_id, chunk_size_bytes);
-}
-
-void AnalyticsRecorder::OnOutgoingPayloadDone(
- const std::string& endpoint_id, std::int64_t payload_id,
- PayloadStatus status, OperationResultCode operation_result_code) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnOutgoingPayloadDone")) {
- return;
- }
- auto it = active_connections_.find(endpoint_id);
- if (it == active_connections_.end()) {
- return;
- }
-
- const std::unique_ptr& logical_connection = it->second;
- logical_connection->OutgoingPayloadDone(payload_id, status,
- operation_result_code);
-}
-
-void AnalyticsRecorder::OnBandwidthUpgradeStarted(
- const std::string& endpoint_id, Medium from_medium, Medium to_medium,
- ConnectionAttemptDirection direction, const std::string& connection_token) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnBandwidthUpgradeStarted")) {
- return;
- }
- auto bandwidth_upgrade_attempt =
- std::make_unique();
- bandwidth_upgrade_attempt->set_duration_millis(
- absl::ToUnixMillis(SystemClock::ElapsedRealtime()));
- bandwidth_upgrade_attempt->set_from_medium(from_medium);
- bandwidth_upgrade_attempt->set_to_medium(to_medium);
- bandwidth_upgrade_attempt->set_direction(direction);
- bandwidth_upgrade_attempt->set_connection_token(connection_token);
- bandwidth_upgrade_attempts_.insert(
- {endpoint_id, std::move(bandwidth_upgrade_attempt)});
-}
-
-void AnalyticsRecorder::UpdateBwUpgradeNetworkInfo(
- const std::string& endpoint_id, int num_interfaces,
- int num_ipv6_only_interfaces) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("UpdateBwUpgradeNetworkInfo")) {
- return;
- }
- auto it = bandwidth_upgrade_attempts_.find(endpoint_id);
- if (it == bandwidth_upgrade_attempts_.end()) {
- return;
- }
- ConnectionsLog::BandwidthUpgradeAttempt* bandwidth_upgrade_attempt =
- it->second.get();
- bandwidth_upgrade_attempt->set_num_interfaces(num_interfaces);
- bandwidth_upgrade_attempt->set_num_ipv6_only_interfaces(
- num_ipv6_only_interfaces);
-}
-
-void AnalyticsRecorder::OnBandwidthUpgradeError(
- const std::string& endpoint_id, BandwidthUpgradeResult result,
- BandwidthUpgradeErrorStage error_stage,
- OperationResultCode operation_result_code) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnBandwidthUpgradeError")) {
- return;
- }
- // If the same records existed, drop this one.
- if (EraseIfBandwidthUpgradeRecordExistedLocked(
- endpoint_id, result, error_stage, operation_result_code)) {
- return;
- }
- FinishUpgradeAttemptLocked(endpoint_id, result, error_stage,
- operation_result_code);
-}
-
-void AnalyticsRecorder::OnBandwidthUpgradeSuccess(
- const std::string& endpoint_id) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnBandwidthUpgradeSuccess")) {
- return;
- }
- FinishUpgradeAttemptLocked(endpoint_id, UPGRADE_RESULT_SUCCESS,
- UPGRADE_SUCCESS,
- OperationResultCode::DETAIL_SUCCESS);
-}
-
-void AnalyticsRecorder::OnErrorCode(const ErrorCodeParams& params) {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("OnErrorCode")) {
- return;
- }
- auto error_code = std::make_unique();
- error_code->set_medium(params.medium);
- error_code->set_event(params.event);
- error_code->set_connection_token(params.connection_token);
- error_code->set_description(params.description);
-
- if (params.is_common_error) {
- error_code->set_common_error(params.common_error);
- } else {
- switch (params.event) {
- case location::nearby::errorcode::proto::START_ADVERTISING:
- error_code->set_start_advertising_error(params.start_advertising_error);
- break;
- case location::nearby::errorcode::proto::STOP_ADVERTISING:
- error_code->set_stop_advertising_error(params.stop_advertising_error);
- break;
- case location::nearby::errorcode::proto::
- START_LISTENING_INCOMING_CONNECTION:
- error_code->set_start_listening_incoming_connection_error(
- params.start_listening_incoming_connection_error);
- break;
- case location::nearby::errorcode::proto::
- STOP_LISTENING_INCOMING_CONNECTION:
- error_code->set_stop_listening_incoming_connection_error(
- params.stop_listening_incoming_connection_error);
- break;
- case location::nearby::errorcode::proto::START_DISCOVERING:
- error_code->set_start_discovering_error(params.start_discovering_error);
- break;
- case location::nearby::errorcode::proto::STOP_DISCOVERING:
- error_code->set_stop_discovering_error(params.stop_discovering_error);
- break;
- case location::nearby::errorcode::proto::CONNECT:
- error_code->set_connect_error(params.connect_error);
- break;
- case location::nearby::errorcode::proto::DISCONNECT:
- error_code->set_disconnect_error(params.disconnect_error);
- break;
- case location::nearby::errorcode::proto::UNKNOWN_EVENT:
- default:
- error_code->set_common_error(params.common_error);
- break;
- }
- }
-
- ConnectionsLog connections_log;
- connections_log.set_event_type(ERROR_CODE);
- connections_log.set_version(kVersion);
- connections_log.set_allocated_error_code(error_code.release());
-
- VLOG(1) << "AnalyticsRecorder LogErrorCode connections_log="
- << connections_log.DebugString(); // NOLINT
-
- event_logger_->Log(connections_log);
-}
-
-void AnalyticsRecorder::LogStartSession() {
- MutexLock lock(&mutex_);
- if (start_client_session_was_logged_) {
- LOG(WARNING) << "AnalyticsRecorder CanRecordAnalytics Unexpected call "
- << kOnStartClientSession
- << " after start client session has already been logged.";
- return;
- }
-
- session_was_logged_ = false;
- if (CanRecordAnalyticsLocked(kOnStartClientSession)) {
- client_session_ = std::make_unique();
- started_client_session_time_ = SystemClock::ElapsedRealtime();
- start_client_session_was_logged_ = true;
- LogEvent(START_CLIENT_SESSION);
- }
-}
-
-void AnalyticsRecorder::LogSession() {
- MutexLock lock(&mutex_);
- if (!CanRecordAnalyticsLocked("LogSession")) {
- return;
- }
- FinishStrategySessionLocked();
- client_session_->set_duration_millis(absl::ToInt64Milliseconds(
- SystemClock::ElapsedRealtime() - started_client_session_time_));
- LogClientSessionLocked();
- LogEvent(STOP_CLIENT_SESSION);
- start_client_session_was_logged_ = false;
- session_was_logged_ = true;
-}
std::unique_ptr
AnalyticsRecorder::BuildAdvertisingMetadataParams(
bool is_extended_advertisement_supported, int connected_ap_frequency,
bool is_nfc_available,
- const std::vector&
+ const std::vector&
operation_result_with_mediums) {
auto params = std::make_unique();
params->is_extended_advertisement_supported =
is_extended_advertisement_supported;
params->connected_ap_frequency = connected_ap_frequency;
params->is_nfc_available = is_nfc_available;
- params->operation_result_with_mediums =
- std::move(operation_result_with_mediums);
+ params->operation_result_with_mediums = operation_result_with_mediums;
return params;
}
@@ -936,15 +50,14 @@ std::unique_ptr
AnalyticsRecorder::BuildDiscoveryMetadataParams(
bool is_extended_advertisement_supported, int connected_ap_frequency,
bool is_nfc_available,
- const std::vector&
+ const std::vector&
operation_result_with_mediums) {
auto params = std::make_unique();
params->is_extended_advertisement_supported =
is_extended_advertisement_supported;
params->connected_ap_frequency = connected_ap_frequency;
params->is_nfc_available = is_nfc_available;
- params->operation_result_with_mediums =
- std::move(operation_result_with_mediums);
+ params->operation_result_with_mediums = operation_result_with_mediums;
return params;
}
@@ -1000,694 +113,4 @@ OperationResultCode AnalyticsRecorder::GetChannelIoErrorResultCodeFromMedium(
}
}
-bool AnalyticsRecorder::CanRecordAnalyticsLocked(
- absl::string_view method_name) {
- VLOG(1) << "AnalyticsRecorder LogEvent " << method_name << " is calling.";
- if (event_logger_ == nullptr) {
- return false;
- }
-
- if (session_was_logged_) {
- VLOG(1) << "AnalyticsRecorder CanRecordAnalytics Unexpected call "
- << method_name << " after session has already been logged.";
- return false;
- }
-
- return true;
-}
-
-// TODO: b/391339677 - Investigate why we need to reset the resources. And
-// verify in b/238375695 to see if we still meet the issue after removing the
-// Reset function.
-void AnalyticsRecorder::LogClientSessionLocked() {
- ConnectionsLog connections_log;
- connections_log.set_event_type(CLIENT_SESSION);
- connections_log.set_allocated_client_session(client_session_.release());
- connections_log.set_version(kVersion);
-
- VLOG(1) << "AnalyticsRecorder LogClientSession connections_log="
- << connections_log.DebugString(); // NOLINT
-
- event_logger_->Log(connections_log);
- client_session_ = nullptr;
-}
-
-void AnalyticsRecorder::LogEvent(EventType event_type) {
- ConnectionsLog connections_log;
- connections_log.set_event_type(event_type);
- connections_log.set_version(kVersion);
-
- VLOG(1) << "AnalyticsRecorder LogEvent connections_log="
- << connections_log.DebugString(); // NOLINT
-
- event_logger_->Log(connections_log);
-}
-
-void AnalyticsRecorder::UpdateStrategySessionLocked(
- connections::Strategy strategy, SessionRole role) {
- // If we're not switching strategies, just update the current StrategySession
- // with the new role.
- if (strategy == current_strategy_ && current_strategy_session_ != nullptr) {
- if (absl::c_linear_search(current_strategy_session_->role(), role)) {
- // We've already acted as this role before, so make sure we've finished
- // recording the previous round.
- switch (role) {
- case ADVERTISER:
- FinishAdvertisingPhaseLocked();
- break;
- case DISCOVERER:
- FinishDiscoveryPhaseLocked();
- break;
- default:
- break;
- }
- } else {
- current_strategy_session_->add_role(role);
- }
- } else {
- // Otherwise, we're starting a new Strategy.
- current_strategy_ = strategy;
- FinishStrategySessionLocked();
- LogEvent(START_STRATEGY_SESSION);
- current_strategy_session_ =
- std::make_unique();
- started_strategy_session_time_ = SystemClock::ElapsedRealtime();
- current_strategy_session_->set_strategy(
- StrategyToConnectionStrategy(strategy));
- current_strategy_session_->add_role(role);
- }
-}
-
-void AnalyticsRecorder::RecordAdvertisingPhaseDurationAndReasonLocked(
- bool on_stop) const {
- if (current_advertising_phase_ == nullptr) {
- LOG(INFO) << "Unable to record advertising phase duration due to "
- "null current_advertising_phase_";
- return;
- }
- if (!current_advertising_phase_->has_duration_millis()) {
- current_advertising_phase_->set_duration_millis(absl::ToInt64Milliseconds(
- SystemClock::ElapsedRealtime() - started_advertising_phase_time_));
- }
- if (!current_advertising_phase_->has_stop_reason()) {
- current_advertising_phase_->set_stop_reason(
- on_stop ? StopAdvertisingReason::CLIENT_STOP_ADVERTISING
- : StopAdvertisingReason::FINISH_SESSION_STOP_ADVERTISING);
- }
-}
-
-void AnalyticsRecorder::FinishAdvertisingPhaseLocked() {
- if (current_advertising_phase_ != nullptr) {
- for (const auto& item : incoming_connection_requests_) {
- // ConnectionRequests still pending have been ignored by the local or
- // remote (or both) endpoints.
- const std::unique_ptr&
- connection_request = item.second;
- MarkConnectionRequestIgnoredLocked(connection_request.get());
- UpdateAdvertiserConnectionRequestLocked(connection_request.get());
- }
- RecordAdvertisingPhaseDurationAndReasonLocked(/* on_stop= */ false);
- if (current_strategy_session_ != nullptr) {
- *current_strategy_session_->add_advertising_phase() =
- *std::move(current_advertising_phase_);
- } else {
- LOG(INFO) << "Unable to record advertising phase due to null "
- "current_strategy_session_";
- }
- }
- incoming_connection_requests_.clear();
-}
-
-void AnalyticsRecorder::RecordDiscoveryPhaseDurationAndReasonLocked(
- bool on_stop) const {
- if (current_discovery_phase_ == nullptr) {
- LOG(INFO) << "Unable to record discovery phase duration due to "
- "null current_discovery_phase_";
- return;
- }
- if (!current_discovery_phase_->has_duration_millis()) {
- current_discovery_phase_->set_duration_millis(absl::ToInt64Milliseconds(
- SystemClock::ElapsedRealtime() - started_discovery_phase_time_));
- }
- // If the stop reason haven't been set yet, then set it.
- if (!current_discovery_phase_->has_stop_reason()) {
- current_discovery_phase_->set_stop_reason(
- on_stop ? StopDiscoveringReason::CLIENT_STOP_DISCOVERING
- : StopDiscoveringReason::FINISH_SESSION_STOP_DISCOVERING);
- }
-}
-
-void AnalyticsRecorder::FinishDiscoveryPhaseLocked() {
- if (current_discovery_phase_ != nullptr) {
- for (const auto& item : outgoing_connection_requests_) {
- // ConnectionRequests still pending have been ignored by the local or
- // remote (or both) endpoints.
- const std::unique_ptr&
- connection_request = item.second;
- MarkConnectionRequestIgnoredLocked(connection_request.get());
- UpdateDiscovererConnectionRequestLocked(connection_request.get());
- }
- RecordDiscoveryPhaseDurationAndReasonLocked(/* on_stop=*/false);
- if (current_strategy_session_ != nullptr) {
- *current_strategy_session_->add_discovery_phase() =
- *std::move(current_discovery_phase_);
- } else {
- LOG(INFO) << "Unable to record discovery phase due to null "
- "current_strategy_session_";
- }
- }
- outgoing_connection_requests_.clear();
-}
-
-bool AnalyticsRecorder::UpdateAdvertiserConnectionRequestLocked(
- ConnectionsLog::ConnectionRequest* request) {
- if (current_advertising_phase_ == nullptr) {
- LOG(INFO) << "Unable to record advertiser connection request due to null "
- "current_advertising_phase_";
- return false;
- }
- if (BothEndpointsRespondedLocked(request)) {
- request->set_duration_millis(
- absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
- request->duration_millis());
- *current_advertising_phase_->add_received_connection_request() = *request;
- return true;
- }
- return false;
-}
-
-bool AnalyticsRecorder::UpdateDiscovererConnectionRequestLocked(
- ConnectionsLog::ConnectionRequest* request) {
- if (current_discovery_phase_ == nullptr) {
- LOG(INFO) << "Unable to record discoverer connection request due "
- "to null current_discovery_phase_.";
- return false;
- }
- if (BothEndpointsRespondedLocked(request) ||
- request->local_response() == NOT_SENT) {
- request->set_duration_millis(
- absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
- request->duration_millis());
- *current_discovery_phase_->add_sent_connection_request() = *request;
- return true;
- }
- return false;
-}
-
-bool AnalyticsRecorder::BothEndpointsRespondedLocked(
- ConnectionsLog::ConnectionRequest* request) {
- return request->has_local_response() && request->has_remote_response();
-}
-
-void AnalyticsRecorder::LocalEndpointRespondedLocked(
- const std::string& remote_endpoint_id, ConnectionRequestResponse response) {
- auto out = outgoing_connection_requests_.find(remote_endpoint_id);
- if (out != outgoing_connection_requests_.end()) {
- ConnectionsLog::ConnectionRequest* connection_request = out->second.get();
- connection_request->set_local_response(response);
- if (UpdateDiscovererConnectionRequestLocked(connection_request)) {
- outgoing_connection_requests_.erase(out);
- }
- }
- auto in = incoming_connection_requests_.find(remote_endpoint_id);
- if (in != incoming_connection_requests_.end()) {
- ConnectionsLog::ConnectionRequest* connection_request = in->second.get();
- connection_request->set_local_response(response);
- if (UpdateAdvertiserConnectionRequestLocked(connection_request)) {
- incoming_connection_requests_.erase(in);
- }
- }
-}
-
-void AnalyticsRecorder::RemoteEndpointRespondedLocked(
- const std::string& remote_endpoint_id, ConnectionRequestResponse response) {
- auto out = outgoing_connection_requests_.find(remote_endpoint_id);
- if (out != outgoing_connection_requests_.end()) {
- ConnectionsLog::ConnectionRequest* connection_request = out->second.get();
- connection_request->set_remote_response(response);
- if (UpdateDiscovererConnectionRequestLocked(connection_request)) {
- outgoing_connection_requests_.erase(out);
- }
- }
- auto in = incoming_connection_requests_.find(remote_endpoint_id);
- if (in != incoming_connection_requests_.end()) {
- ConnectionsLog::ConnectionRequest* connection_request = in->second.get();
- connection_request->set_remote_response(response);
- if (UpdateAdvertiserConnectionRequestLocked(connection_request)) {
- incoming_connection_requests_.erase(in);
- }
- }
-}
-
-void AnalyticsRecorder::MarkConnectionRequestIgnoredLocked(
- ConnectionsLog::ConnectionRequest* request) {
- if (!request->has_local_response()) {
- request->set_local_response(IGNORED);
- }
- if (!request->has_remote_response()) {
- request->set_remote_response(IGNORED);
- }
-}
-
-bool AnalyticsRecorder::ConnectionAttemptResultCodeExistedLocked(
- Medium medium, ConnectionAttemptDirection direction,
- const std::string& connection_token, ConnectionAttemptType type,
- OperationResultCode operation_result_code) {
- if (current_strategy_session_ == nullptr ||
- current_strategy_session_->connection_attempt_size() == 0) {
- return false;
- }
- for (auto& connection_attempt :
- current_strategy_session_->connection_attempt()) {
- if (connection_attempt.medium() == medium &&
- connection_attempt.direction() == direction &&
- connection_attempt.connection_token() == connection_token &&
- connection_attempt.type() == type &&
- connection_attempt.operation_result().result_code() ==
- operation_result_code) {
- return true;
- }
- }
-
- return false;
-}
-
-// If bandwidth upgrade always failed on the same fromMedium, toMedium, result,
-// stage and result code, we'll drop the duplicate logs for preventing the waste
-// of log storage space
-bool AnalyticsRecorder::EraseIfBandwidthUpgradeRecordExistedLocked(
- const std::string& endpoint_id, BandwidthUpgradeResult result,
- BandwidthUpgradeErrorStage error_stage,
- OperationResultCode operation_result_code) {
- if (current_strategy_session_ == nullptr) {
- return false;
- }
- auto it = bandwidth_upgrade_attempts_.find(endpoint_id);
- if (it != bandwidth_upgrade_attempts_.end()) {
- ConnectionsLog::BandwidthUpgradeAttempt* attempt = it->second.get();
- for (auto& existing_attempt :
- current_strategy_session_->upgrade_attempt()) {
- if (attempt->from_medium() == existing_attempt.from_medium() &&
- attempt->to_medium() == existing_attempt.to_medium() &&
- result == existing_attempt.upgrade_result() &&
- error_stage == existing_attempt.error_stage() &&
- operation_result_code ==
- existing_attempt.operation_result().result_code()) {
- bandwidth_upgrade_attempts_.erase(it);
- return true;
- }
- }
- }
- return false;
-}
-
-void AnalyticsRecorder::FinishUpgradeAttemptLocked(
- const std::string& endpoint_id, BandwidthUpgradeResult result,
- BandwidthUpgradeErrorStage error_stage,
- OperationResultCode operation_result_code, bool erase_item) {
- if (current_strategy_session_ == nullptr) {
- LOG(INFO) << "Unable to record upgrade attempt due to null "
- "current_strategy_session_";
- return;
- }
- // Add the BandwidthUpgradeAttempt in the current StrategySession.
- auto it = bandwidth_upgrade_attempts_.find(endpoint_id);
- if (it != bandwidth_upgrade_attempts_.end()) {
- ConnectionsLog::BandwidthUpgradeAttempt* attempt = it->second.get();
- attempt->set_duration_millis(
- absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
- attempt->duration_millis());
- attempt->set_error_stage(error_stage);
- attempt->set_upgrade_result(result);
-
- auto operation_result_proto =
- std::make_unique();
- operation_result_proto->set_result_code(operation_result_code);
- operation_result_proto->set_result_category(
- ConvertToOperationResultCategory(operation_result_code));
- attempt->set_allocated_operation_result(operation_result_proto.release());
- *current_strategy_session_->add_upgrade_attempt() = *attempt;
- if (erase_item) {
- bandwidth_upgrade_attempts_.erase(it);
- }
- }
-}
-
-void AnalyticsRecorder::FinishStrategySessionLocked() {
- if (current_strategy_session_ != nullptr) {
- FinishAdvertisingPhaseLocked();
- FinishDiscoveryPhaseLocked();
-
- // Finish any unfinished LogicalConnections.
- for (const auto& item : active_connections_) {
- const std::unique_ptr& logical_connection =
- item.second;
- logical_connection->CloseAllPhysicalConnections();
- absl::c_copy(
- logical_connection->GetEstablisedConnections(),
- RepeatedFieldBackInserter(
- current_strategy_session_->mutable_established_connection()));
- }
- active_connections_.clear();
-
- // Finish any pending upgrade attempts.
- for (const auto& item : bandwidth_upgrade_attempts_) {
- FinishUpgradeAttemptLocked(
- item.first, UNFINISHED_ERROR, UPGRADE_UNFINISHED,
- OperationResultCode::DEVICE_STATE_ERROR_UNFINISHED_UPGRADE_ATTEMPTS,
- /*erase_item=*/false);
- }
- bandwidth_upgrade_attempts_.clear();
-
- // Add the StrategySession in ClientSession
- if (current_strategy_session_ != nullptr) {
- current_strategy_session_->set_duration_millis(absl::ToInt64Milliseconds(
- SystemClock::ElapsedRealtime() - started_strategy_session_time_));
- *client_session_->add_strategy_session() =
- *std::move(current_strategy_session_);
- }
-
- current_strategy_session_ = nullptr;
- current_strategy_ = connections::Strategy::kNone;
- LogEvent(STOP_STRATEGY_SESSION);
- }
-}
-
-ConnectionsStrategy AnalyticsRecorder::StrategyToConnectionStrategy(
- connections::Strategy strategy) {
- if (strategy == connections::Strategy::kP2pCluster) {
- return P2P_CLUSTER;
- }
- if (strategy == connections::Strategy::kP2pStar) {
- return P2P_STAR;
- }
- if (strategy == connections::Strategy::kP2pPointToPoint) {
- return P2P_POINT_TO_POINT;
- }
- return UNKNOWN_STRATEGY;
-}
-
-PayloadType AnalyticsRecorder::PayloadTypeToProtoPayloadType(
- connections::PayloadType type) {
- switch (type) {
- case connections::PayloadType::kBytes:
- return BYTES;
- case connections::PayloadType::kFile:
- return FILE;
- case connections::PayloadType::kStream:
- return STREAM;
- default:
- return UNKNOWN_PAYLOAD_TYPE;
- }
-}
-
-void AnalyticsRecorder::PendingPayload::AddChunk(
- std::int64_t chunk_size_bytes) {
- num_bytes_transferred_ += chunk_size_bytes;
- num_chunks_++;
-}
-
-ConnectionsLog::Payload AnalyticsRecorder::PendingPayload::GetProtoPayload(
- PayloadStatus status) {
- ConnectionsLog::Payload payload;
- payload.set_duration_millis(
- absl::ToInt64Milliseconds(SystemClock::ElapsedRealtime() - start_time_));
- payload.set_type(type_);
- payload.set_total_size_bytes(total_size_bytes_);
- payload.set_num_bytes_transferred(num_bytes_transferred_);
- payload.set_num_chunks(num_chunks_);
- payload.set_status(status);
-
- auto operation_result_proto =
- std::make_unique();
- operation_result_proto->set_result_code(operation_result_code_);
- operation_result_proto->set_result_category(
- ConvertToOperationResultCategory(operation_result_code_));
- payload.set_allocated_operation_result(operation_result_proto.release());
-
- return payload;
-}
-
-void AnalyticsRecorder::LogicalConnection::PhysicalConnectionEstablished(
- Medium medium, const std::string& connection_token) {
- if (current_medium_ != UNKNOWN_MEDIUM) {
- LOG(WARNING) << "Unexpected call to PhysicalConnectionEstablished while "
- "AnalyticsRecorder still has an active current medium.";
- }
-
- auto established_connection =
- std::make_unique();
- established_connection->set_medium(medium);
- established_connection->set_duration_millis(
- absl::ToUnixMillis(SystemClock::ElapsedRealtime()));
- established_connection->set_connection_token(connection_token);
-
- auto operation_result_proto =
- std::make_unique();
- operation_result_proto->set_result_code(OperationResultCode::DETAIL_SUCCESS);
- operation_result_proto->set_result_category(
- OperationResultCategory::CATEGORY_SUCCESS);
- established_connection->set_allocated_operation_result(
- operation_result_proto.release());
- physical_connections_.insert({medium, std::move(established_connection)});
- current_medium_ = medium;
-}
-
-void AnalyticsRecorder::LogicalConnection::PhysicalConnectionClosed(
- Medium medium, DisconnectionReason reason, SafeDisconnectionResult result) {
- if (current_medium_ == UNKNOWN_MEDIUM) {
- LOG(WARNING) << "Unexpected call to PhysicalConnectionClosed() for medium "
- << Medium_Name(medium)
- << " while AnalyticsRecorder has no active current medium";
- } else if (current_medium_ != medium) {
- LOG(WARNING) << "Unexpected call to PhysicalConnectionClosed() for medium "
- << Medium_Name(medium)
- << "while AnalyticsRecorder has active medium "
- << Medium_Name(current_medium_);
- }
-
- auto it = physical_connections_.find(medium);
- if (it == physical_connections_.end()) {
- LOG(WARNING)
- << "Unexpected call to physicalConnectionClosed() for medium "
- << Medium_Name(medium)
- << " with no corresponding EstablishedConnection that was previously"
- " opened.";
- return;
- }
- ConnectionsLog::EstablishedConnection* established_connection =
- it->second.get();
- if (established_connection->has_disconnection_reason()) {
- LOG(WARNING) << "Unexpected call to physicalConnectionClosed() for medium "
- << Medium_Name(medium)
- << " which already has disconnection reason "
- << DisconnectionReason_Name(
- established_connection->disconnection_reason());
- return;
- }
- FinishPhysicalConnection(established_connection, reason, result);
-
- if (medium == current_medium_) {
- // If the EstablishedConnection we just closed was the one that we have
- // marked as current, unset currentMedium.
- current_medium_ = UNKNOWN_MEDIUM;
- }
-}
-
-void AnalyticsRecorder::LogicalConnection::CloseAllPhysicalConnections() {
- for (const auto& physical_connection : physical_connections_) {
- ConnectionsLog::EstablishedConnection* established_connection =
- physical_connection.second.get();
- if (!established_connection->has_disconnection_reason()) {
- FinishPhysicalConnection(
- established_connection, UNFINISHED,
- ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
- }
- }
- current_medium_ = UNKNOWN_MEDIUM;
-}
-
-std::vector
-AnalyticsRecorder::LogicalConnection::GetEstablisedConnections() {
- std::vector established_connections;
- if (current_medium_ != UNKNOWN_MEDIUM) {
- LOG(WARNING)
- << "AnalyticsRecorder expected no more active physical connections "
- "before logging this endpoint connection.";
- return established_connections;
- }
- std::transform(physical_connections_.begin(), physical_connections_.end(),
- std::back_inserter(established_connections),
- [](auto& kv) { return *kv.second; });
- physical_connections_.clear();
-
- for (auto& established_connection : established_connections) {
- if (absl::Milliseconds(established_connection.duration_millis()) >=
- kConnectionTokenMaxLife) {
- LOG(INFO) << "connection token exceed TTL, drop token.";
- established_connection.set_connection_token("");
- }
- }
-
- return established_connections;
-}
-
-void AnalyticsRecorder::LogicalConnection::IncomingPayloadStarted(
- std::int64_t payload_id, PayloadType type, std::int64_t total_size_bytes) {
- incoming_payloads_.insert(
- {payload_id, std::make_unique(type, total_size_bytes)});
-}
-
-void AnalyticsRecorder::LogicalConnection::ChunkReceived(
- std::int64_t payload_id, std::int64_t size_bytes) {
- auto it = incoming_payloads_.find(payload_id);
- if (it == incoming_payloads_.end()) {
- return;
- }
- PendingPayload* pending_payload = it->second.get();
- pending_payload->AddChunk(size_bytes);
-}
-
-void AnalyticsRecorder::LogicalConnection::IncomingPayloadDone(
- std::int64_t payload_id, PayloadStatus status,
- OperationResultCode operation_result_code) {
- if (current_medium_ == UNKNOWN_MEDIUM) {
- LOG(WARNING) << "Unexpected call to incomingPayloadDone() while "
- "AnalyticsRecorder has no active current medium.";
- return;
- }
- auto it = physical_connections_.find(current_medium_);
- if (it != physical_connections_.end()) {
- const std::unique_ptr&
- established_connection = it->second;
- auto it = incoming_payloads_.find(payload_id);
- if (it != incoming_payloads_.end()) {
- it->second->SetOperationResultCode(operation_result_code);
- *established_connection->add_received_payload() =
- it->second->GetProtoPayload(status);
- incoming_payloads_.erase(it);
- }
- }
-}
-
-void AnalyticsRecorder::LogicalConnection::OutgoingPayloadStarted(
- std::int64_t payload_id, PayloadType type, std::int64_t total_size_bytes) {
- outgoing_payloads_.insert(
- {payload_id, std::make_unique(type, total_size_bytes)});
-}
-
-void AnalyticsRecorder::LogicalConnection::ChunkSent(std::int64_t payload_id,
- std::int64_t size_bytes) {
- auto it = outgoing_payloads_.find(payload_id);
- if (it == outgoing_payloads_.end()) {
- return;
- }
- PendingPayload* payload = it->second.get();
- payload->AddChunk(size_bytes);
-}
-
-void AnalyticsRecorder::LogicalConnection::OutgoingPayloadDone(
- std::int64_t payload_id, PayloadStatus status,
- OperationResultCode operation_result_code) {
- if (current_medium_ == UNKNOWN_MEDIUM) {
- LOG(WARNING) << "Unexpected call to outgoingPayloadDone() while "
- "AnalyticsRecorder has no active current medium.";
- return;
- }
- auto it = physical_connections_.find(current_medium_);
- if (it != physical_connections_.end()) {
- const std::unique_ptr&
- established_connection = it->second;
- auto it = outgoing_payloads_.find(payload_id);
- if (it != outgoing_payloads_.end()) {
- it->second->SetOperationResultCode(operation_result_code);
- *established_connection->add_sent_payload() =
- it->second->GetProtoPayload(status);
- outgoing_payloads_.erase(it);
- }
- }
-}
-
-void AnalyticsRecorder::LogicalConnection::FinishPhysicalConnection(
- ConnectionsLog::EstablishedConnection* established_connection,
- DisconnectionReason reason, SafeDisconnectionResult result) {
- established_connection->set_disconnection_reason(reason);
- established_connection->set_safe_disconnection_result(result);
- established_connection->set_duration_millis(
- absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
- established_connection->duration_millis());
-
- // Add any not-yet-finished payloads to this EstablishedConnection.
- std::vector in_payloads =
- ResolvePendingPayloads(incoming_payloads_, reason);
- absl::c_move(in_payloads,
- RepeatedFieldBackInserter(
- established_connection->mutable_received_payload()));
- std::vector out_payloads =
- ResolvePendingPayloads(outgoing_payloads_, reason);
- absl::c_move(out_payloads,
- RepeatedFieldBackInserter(
- established_connection->mutable_sent_payload()));
-}
-
-std::vector
-AnalyticsRecorder::LogicalConnection::ResolvePendingPayloads(
- absl::btree_map>&
- pending_payloads,
- DisconnectionReason reason) {
- std::vector completed_payloads;
- absl::btree_map>
- upgraded_payloads;
- PayloadStatus status =
- reason == UPGRADED ? MOVED_TO_NEW_MEDIUM : CONNECTION_CLOSED;
-
- OperationResultCode operation_result_code =
- GetPendingPayloadResultCodeFromReason(reason);
- for (const auto& item : pending_payloads) {
- const std::unique_ptr& pending_payload = item.second;
- pending_payload->SetOperationResultCode(operation_result_code);
- ConnectionsLog::Payload proto_payload =
- pending_payload->GetProtoPayload(status);
- completed_payloads.push_back(proto_payload);
- if (reason == UPGRADED) {
- upgraded_payloads.insert(
- {item.first,
- std::make_unique(pending_payload->type(),
- pending_payload->total_size_bytes(),
- operation_result_code)});
- }
- }
- pending_payloads.clear();
-
- if (reason == UPGRADED) {
- // Re-populate the map with a new PendingPayload for each pending payload,
- // since we expect them to be completed on the next EstablishedConnection.
- pending_payloads = std::move(upgraded_payloads);
- }
- // Return the list of completed payloads to be added to the current
- // EstablishedConnection.
- return completed_payloads;
-}
-
-OperationResultCode
-AnalyticsRecorder::LogicalConnection::GetPendingPayloadResultCodeFromReason(
- DisconnectionReason reason) {
- switch (reason) {
- case UPGRADED:
- return OperationResultCode::MISCELLEANEOUS_MOVE_TO_NEW_MEDIUM;
- case DisconnectionReason::LOCAL_DISCONNECTION:
- return OperationResultCode::CLIENT_CANCELLATION_LOCAL_DISCONNECT;
- case DisconnectionReason::REMOTE_DISCONNECTION:
- return OperationResultCode::CLIENT_CANCELLATION_REMOTE_DISCONNECT;
- default:
- return OperationResultCode::NEARBY_GENERIC_CONNECTION_CLOSED;
- }
-}
-
-OperationResultCategory AnalyticsRecorder::GetOperationResultCategory(
- location::nearby::proto::connections::OperationResultCode result_code) {
- return ConvertToOperationResultCategory(result_code);
-}
-
-} // namespace analytics
-} // namespace nearby
+} // namespace nearby::analytics
diff --git a/connections/implementation/analytics/analytics_recorder.h b/connections/implementation/analytics/analytics_recorder.h
index b24232b3..601d12bc 100644
--- a/connections/implementation/analytics/analytics_recorder.h
+++ b/connections/implementation/analytics/analytics_recorder.h
@@ -18,118 +18,98 @@
#include
#include
#include
-#include
#include
-#include "absl/base/thread_annotations.h"
-#include "absl/container/btree_map.h"
-#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "connections/implementation/analytics/advertising_metadata_params.h"
#include "connections/implementation/analytics/connection_attempt_metadata_params.h"
#include "connections/implementation/analytics/discovery_metadata_params.h"
+#include "connections/implementation/analytics/operation_result_with_medium.h"
#include "connections/payload_type.h"
#include "connections/strategy.h"
-#include "internal/analytics/event_logger.h"
#include "internal/platform/error_code_params.h"
-#include "internal/platform/implementation/system_clock.h"
-#include "internal/platform/mutex.h"
-#include "internal/proto/analytics/connections_log.pb.h"
#include "proto/connections_enums.pb.h"
-namespace nearby {
-namespace analytics {
+namespace nearby::analytics {
+
+enum class SafeDisconnectionResult {
+ kUnknown = 0,
+ kSafeDisconnection = 1,
+ kUnsafeDisconnection = 2,
+};
class AnalyticsRecorder {
public:
- explicit AnalyticsRecorder(::nearby::analytics::EventLogger* event_logger);
- virtual ~AnalyticsRecorder();
+ AnalyticsRecorder() = default;
+ virtual ~AnalyticsRecorder() = default;
// Advertising phase
- void OnStartAdvertising(
+ virtual void OnStartAdvertising(
connections::Strategy strategy,
const std::vector& mediums,
- AdvertisingMetadataParams* advertising_metadata_params)
- ABSL_LOCKS_EXCLUDED(mutex_);
- void OnStopAdvertising() ABSL_LOCKS_EXCLUDED(mutex_);
+ AdvertisingMetadataParams* advertising_metadata_params) = 0;
+ virtual void OnStopAdvertising() = 0;
- // In case the client calls the {@link BasePcp#updateAdvertisingOptions()}
- // multiple times, adds one index value to group the mediums results within
- // the same UpdateAdvertisingOptions call, this API is to return the largest
- // index value in current_advertising_phase.
- int GetNextAdvertisingUpdateIndex() ABSL_LOCKS_EXCLUDED(mutex_);
+ virtual int GetNextAdvertisingUpdateIndex() = 0;
// Connection listening
- void OnStartedIncomingConnectionListening(connections::Strategy strategy)
- ABSL_LOCKS_EXCLUDED(mutex_);
- void OnStoppedIncomingConnectionListening() ABSL_LOCKS_EXCLUDED(mutex_);
+ virtual void OnStartedIncomingConnectionListening(
+ connections::Strategy strategy) = 0;
+ virtual void OnStoppedIncomingConnectionListening() = 0;
// Discovery phase
- void OnStartDiscovery(
+ virtual void OnStartDiscovery(
connections::Strategy strategy,
const std::vector& mediums,
- DiscoveryMetadataParams* discovery_metadata_params)
- ABSL_LOCKS_EXCLUDED(mutex_);
- void OnStopDiscovery() ABSL_LOCKS_EXCLUDED(mutex_);
+ DiscoveryMetadataParams* discovery_metadata_params) = 0;
+ virtual void OnStopDiscovery() = 0;
- // In case the client calls the {@link BasePcp#updateDiscoveryOptions()}
- // multiple times, adds one index value to group the medium results within the
- // same UpdateDiscoveryOptions call, this
- // API is to return the latest index value in current_discovery_phase.
- int GetNextDiscoveryUpdateIndex() ABSL_LOCKS_EXCLUDED(mutex_);
- void OnEndpointFound(location::nearby::proto::connections::Medium medium)
- ABSL_LOCKS_EXCLUDED(mutex_);
+ virtual int GetNextDiscoveryUpdateIndex() = 0;
+ virtual void OnEndpointFound(
+ location::nearby::proto::connections::Medium medium) = 0;
// Connection request
- void OnRequestConnection(const connections::Strategy& strategy,
- const std::string& endpoint_id)
- ABSL_LOCKS_EXCLUDED(mutex_);
+ virtual void OnRequestConnection(const connections::Strategy& strategy,
+ const std::string& endpoint_id) = 0;
- void OnConnectionRequestReceived(const std::string& remote_endpoint_id)
- ABSL_LOCKS_EXCLUDED(mutex_);
- void OnConnectionRequestSent(const std::string& remote_endpoint_id)
- ABSL_LOCKS_EXCLUDED(mutex_);
- void OnRemoteEndpointAccepted(const std::string& remote_endpoint_id)
- ABSL_LOCKS_EXCLUDED(mutex_);
- void OnLocalEndpointAccepted(const std::string& remote_endpoint_id)
- ABSL_LOCKS_EXCLUDED(mutex_);
- void OnRemoteEndpointRejected(const std::string& remote_endpoint_id)
- ABSL_LOCKS_EXCLUDED(mutex_);
- void OnLocalEndpointRejected(const std::string& remote_endpoint_id)
- ABSL_LOCKS_EXCLUDED(mutex_);
+ virtual void OnConnectionRequestReceived(
+ const std::string& remote_endpoint_id) = 0;
+ virtual void OnConnectionRequestSent(
+ const std::string& remote_endpoint_id) = 0;
+ virtual void OnRemoteEndpointAccepted(
+ const std::string& remote_endpoint_id) = 0;
+ virtual void OnLocalEndpointAccepted(
+ const std::string& remote_endpoint_id) = 0;
+ virtual void OnRemoteEndpointRejected(
+ const std::string& remote_endpoint_id) = 0;
+ virtual void OnLocalEndpointRejected(
+ const std::string& remote_endpoint_id) = 0;
// Connection attempt
- // Records an attempt with meta data at establishing an incoming physical
- // connection.
- void OnIncomingConnectionAttempt(
+ virtual void OnIncomingConnectionAttempt(
location::nearby::proto::connections::ConnectionAttemptType type,
location::nearby::proto::connections::Medium medium,
location::nearby::proto::connections::ConnectionAttemptResult result,
absl::Duration duration, const std::string& connection_token,
- ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
- ABSL_LOCKS_EXCLUDED(mutex_);
- // Records an attempt with meta data at establishing an outgoing physical
- // connection.
- void OnOutgoingConnectionAttempt(
+ ConnectionAttemptMetadataParams* connection_attempt_metadata_params) = 0;
+ virtual void OnOutgoingConnectionAttempt(
const std::string& remote_endpoint_id,
location::nearby::proto::connections::ConnectionAttemptType type,
location::nearby::proto::connections::Medium medium,
location::nearby::proto::connections::ConnectionAttemptResult result,
absl::Duration duration, const std::string& connection_token,
- ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
- ABSL_LOCKS_EXCLUDED(mutex_);
+ ConnectionAttemptMetadataParams* connection_attempt_metadata_params) = 0;
+
static std::unique_ptr
BuildAdvertisingMetadataParams(
bool is_extended_advertisement_supported = false,
int connected_ap_frequency = 0, bool is_nfc_available = false,
- const std::vector&
+ const std::vector&
operation_result_with_mediums = {});
static std::unique_ptr BuildDiscoveryMetadataParams(
bool is_extended_advertisement_supported = false,
int connected_ap_frequency = 0, bool is_nfc_available = false,
- const std::vector&
+ const std::vector&
operation_result_with_mediums = {});
static std::unique_ptr
@@ -147,363 +127,78 @@ class AnalyticsRecorder {
GetChannelIoErrorResultCodeFromMedium(
location::nearby::proto::connections::Medium medium);
- // Connection establishedSafeDisconnectionResult
- void OnConnectionEstablished(
+ // Connection established
+ virtual void OnConnectionEstablished(
const std::string& endpoint_id,
location::nearby::proto::connections::Medium medium,
- const std::string& connection_token) ABSL_LOCKS_EXCLUDED(mutex_);
- void OnConnectionClosed(
+ const std::string& connection_token) = 0;
+ virtual void OnConnectionClosed(
const std::string& endpoint_id,
location::nearby::proto::connections::Medium medium,
location::nearby::proto::connections::DisconnectionReason reason,
- location::nearby::analytics::proto::ConnectionsLog::
- EstablishedConnection::SafeDisconnectionResult result)
- ABSL_LOCKS_EXCLUDED(mutex_);
+ SafeDisconnectionResult result) = 0;
// Payload
- void OnIncomingPayloadStarted(const std::string& endpoint_id,
- std::int64_t payload_id,
- connections::PayloadType type,
- std::int64_t total_size_bytes)
- ABSL_LOCKS_EXCLUDED(mutex_);
- void OnPayloadChunkReceived(const std::string& endpoint_id,
- std::int64_t payload_id,
- std::int64_t chunk_size_bytes)
- ABSL_LOCKS_EXCLUDED(mutex_);
- void OnIncomingPayloadDone(
+ virtual void OnIncomingPayloadStarted(const std::string& endpoint_id,
+ std::int64_t payload_id,
+ connections::PayloadType type,
+ std::int64_t total_size_bytes) = 0;
+ virtual void OnPayloadChunkReceived(const std::string& endpoint_id,
+ std::int64_t payload_id,
+ std::int64_t chunk_size_bytes) = 0;
+ virtual void OnIncomingPayloadDone(
const std::string& endpoint_id, std::int64_t payload_id,
location::nearby::proto::connections::PayloadStatus status,
location::nearby::proto::connections::OperationResultCode
- operation_result_code) ABSL_LOCKS_EXCLUDED(mutex_);
- void OnOutgoingPayloadStarted(const std::vector& endpoint_ids,
- std::int64_t payload_id,
- connections::PayloadType type,
- std::int64_t total_size_bytes)
- ABSL_LOCKS_EXCLUDED(mutex_);
- void OnPayloadChunkSent(const std::string& endpoint_id,
- std::int64_t payload_id,
- std::int64_t chunk_size_bytes)
- ABSL_LOCKS_EXCLUDED(mutex_);
- void OnOutgoingPayloadDone(
+ operation_result_code) = 0;
+ virtual void OnOutgoingPayloadStarted(
+ const std::vector& endpoint_ids, std::int64_t payload_id,
+ connections::PayloadType type, std::int64_t total_size_bytes) = 0;
+ virtual void OnPayloadChunkSent(const std::string& endpoint_id,
+ std::int64_t payload_id,
+ std::int64_t chunk_size_bytes) = 0;
+ virtual void OnOutgoingPayloadDone(
const std::string& endpoint_id, std::int64_t payload_id,
location::nearby::proto::connections::PayloadStatus status,
location::nearby::proto::connections::OperationResultCode
- operation_result_code) ABSL_LOCKS_EXCLUDED(mutex_);
+ operation_result_code) = 0;
// BandwidthUpgrade
- void OnBandwidthUpgradeStarted(
+ virtual void OnBandwidthUpgradeStarted(
const std::string& endpoint_id,
location::nearby::proto::connections::Medium from_medium,
location::nearby::proto::connections::Medium to_medium,
location::nearby::proto::connections::ConnectionAttemptDirection
direction,
- const std::string& connection_token) ABSL_LOCKS_EXCLUDED(mutex_);
- void UpdateBwUpgradeNetworkInfo(const std::string& endpoint_id,
- int num_interfaces,
- int num_ipv6_only_interfaces)
- ABSL_LOCKS_EXCLUDED(mutex_);
- void OnBandwidthUpgradeError(
+ const std::string& connection_token) = 0;
+ virtual void UpdateBwUpgradeNetworkInfo(const std::string& endpoint_id,
+ int num_interfaces,
+ int num_ipv6_only_interfaces) = 0;
+ virtual void OnBandwidthUpgradeError(
const std::string& endpoint_id,
location::nearby::proto::connections::BandwidthUpgradeResult result,
location::nearby::proto::connections::BandwidthUpgradeErrorStage
error_stage,
location::nearby::proto::connections::OperationResultCode
- operation_result_code) ABSL_LOCKS_EXCLUDED(mutex_);
- void OnBandwidthUpgradeSuccess(const std::string& endpoint_id)
- ABSL_LOCKS_EXCLUDED(mutex_);
+ operation_result_code) = 0;
+ virtual void OnBandwidthUpgradeSuccess(const std::string& endpoint_id) = 0;
// Error Code
- void OnErrorCode(const ErrorCodeParams& params);
+ virtual void OnErrorCode(const ErrorCodeParams& params) = 0;
- // Log the start client session event with start client session logging
- // resources setup (e.g. client_session_, started_client_session_time_)
- void LogStartSession() ABSL_LOCKS_EXCLUDED(mutex_);
+ virtual void LogStartSession() = 0;
+ virtual void LogSession() = 0;
- // Invokes event_logger_.Log() at the end of life of client. Log action is
- // called in a separate thread to allow synchronous potentially lengthy
- // execution.
- void LogSession() ABSL_LOCKS_EXCLUDED(mutex_);
+ virtual bool IsSessionLogged() = 0;
- bool IsSessionLogged();
-
- location::nearby::proto::connections::OperationResultCategory
+ virtual location::nearby::proto::connections::OperationResultCategory
GetOperationResultCategory(
- location::nearby::proto::connections::OperationResultCode result_code);
-
- // Waits until all logs are sent to the backend.
- // For testing only.
- void Sync();
-
- private:
- // Tracks the chunks and duration of a Payload on a particular medium.
- class PendingPayload {
- public:
- PendingPayload(location::nearby::proto::connections::PayloadType type,
- std::int64_t total_size_bytes)
- : PendingPayload(type, total_size_bytes,
- location::nearby::proto::connections::
- OperationResultCode::DETAIL_UNKNOWN) {}
- PendingPayload(location::nearby::proto::connections::PayloadType type,
- std::int64_t total_size_bytes,
- location::nearby::proto::connections::OperationResultCode
- operation_result_code)
- : start_time_(SystemClock::ElapsedRealtime()),
- type_(type),
- total_size_bytes_(total_size_bytes),
- num_bytes_transferred_(0),
- num_chunks_(0),
- operation_result_code_(operation_result_code) {}
- ~PendingPayload() = default;
-
- void AddChunk(std::int64_t chunk_size_bytes);
-
- location::nearby::analytics::proto::ConnectionsLog::Payload GetProtoPayload(
- location::nearby::proto::connections::PayloadStatus status);
-
- location::nearby::proto::connections::PayloadType type() const {
- return type_;
- }
-
- std::int64_t total_size_bytes() const { return total_size_bytes_; }
-
- void SetOperationResultCode(
- location::nearby::proto::connections::OperationResultCode
- operation_result_code) {
- operation_result_code_ = operation_result_code;
- }
-
- private:
- absl::Time start_time_;
- location::nearby::proto::connections::PayloadType type_;
- std::int64_t total_size_bytes_;
- std::int64_t num_bytes_transferred_;
- int num_chunks_;
- location::nearby::proto::connections::OperationResultCode
- operation_result_code_ = location::nearby::proto::connections::
- OperationResultCode::DETAIL_UNKNOWN;
- };
-
- class LogicalConnection {
- public:
- LogicalConnection(
- location::nearby::proto::connections::Medium initial_medium,
- const std::string& connection_token) {
- PhysicalConnectionEstablished(initial_medium, connection_token);
- }
- LogicalConnection(const LogicalConnection&) = delete;
- LogicalConnection(LogicalConnection&& other)
- : current_medium_(std::move(other.current_medium_)),
- physical_connections_(std::move(other.physical_connections_)),
- incoming_payloads_(std::move(other.incoming_payloads_)),
- outgoing_payloads_(std::move(other.outgoing_payloads_)) {}
- LogicalConnection& operator=(const LogicalConnection&) = delete;
- LogicalConnection&& operator=(LogicalConnection&&) = delete;
- ~LogicalConnection() = default;
-
- void PhysicalConnectionEstablished(
- location::nearby::proto::connections::Medium medium,
- const std::string& connection_token);
- void PhysicalConnectionClosed(
- location::nearby::proto::connections::Medium medium,
- location::nearby::proto::connections::DisconnectionReason reason,
- location::nearby::analytics::proto::ConnectionsLog::
- EstablishedConnection::SafeDisconnectionResult result);
- void CloseAllPhysicalConnections();
-
- void IncomingPayloadStarted(
- std::int64_t payload_id,
- location::nearby::proto::connections::PayloadType type,
- std::int64_t total_size_bytes);
- void ChunkReceived(std::int64_t payload_id, std::int64_t size_bytes);
- void IncomingPayloadDone(
- std::int64_t payload_id,
- location::nearby::proto::connections::PayloadStatus status,
- location::nearby::proto::connections::OperationResultCode
- operation_result_code);
- void OutgoingPayloadStarted(
- std::int64_t payload_id,
- location::nearby::proto::connections::PayloadType type,
- std::int64_t total_size_bytes);
- void ChunkSent(std::int64_t payload_id, std::int64_t size_bytes);
- void OutgoingPayloadDone(
- std::int64_t payload_id,
- location::nearby::proto::connections::PayloadStatus status,
- location::nearby::proto::connections::OperationResultCode
- operation_result_code);
-
- std::vector
- GetEstablisedConnections();
-
- private:
- void FinishPhysicalConnection(
- location::nearby::analytics::proto::ConnectionsLog::
- EstablishedConnection* established_connection,
- location::nearby::proto::connections::DisconnectionReason reason,
- location::nearby::analytics::proto::ConnectionsLog::
- EstablishedConnection::SafeDisconnectionResult result);
- std::vector
- ResolvePendingPayloads(
- absl::btree_map>&
- pending_payloads,
- location::nearby::proto::connections::DisconnectionReason reason);
- location::nearby::proto::connections::OperationResultCode
- GetPendingPayloadResultCodeFromReason(
- location::nearby::proto::connections::DisconnectionReason reason);
-
- location::nearby::proto::connections::Medium current_medium_ =
- location::nearby::proto::connections::UNKNOWN_MEDIUM;
- absl::btree_map>
- physical_connections_;
- absl::btree_map>
- incoming_payloads_;
- absl::btree_map>
- outgoing_payloads_;
- };
-
- bool CanRecordAnalyticsLocked(absl::string_view method_name)
- ABSL_SHARED_LOCKS_REQUIRED(mutex_);
-
- // Callbacks the ConnectionsLog proto byte array data to the EventLogger with
- // ClientSession sub-proto.
- void LogClientSessionLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- // Callbacks the ConnectionsLog proto byte array data to the EventLogger.
- void LogEvent(location::nearby::proto::connections::EventType event_type);
-
- void UpdateStrategySessionLocked(
- connections::Strategy strategy,
- location::nearby::proto::connections::SessionRole role)
- ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- void RecordAdvertisingPhaseDurationAndReasonLocked(bool on_stop) const
- ABSL_SHARED_LOCKS_REQUIRED(mutex_);
- void FinishAdvertisingPhaseLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- void RecordDiscoveryPhaseDurationAndReasonLocked(bool on_stop) const
- ABSL_SHARED_LOCKS_REQUIRED(mutex_);
- void FinishDiscoveryPhaseLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- bool UpdateAdvertiserConnectionRequestLocked(
- location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
- request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
- bool UpdateDiscovererConnectionRequestLocked(
- location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
- request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
- bool BothEndpointsRespondedLocked(
- location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
- request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
- void LocalEndpointRespondedLocked(
- const std::string& remote_endpoint_id,
- location::nearby::proto::connections::ConnectionRequestResponse response)
- ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- void RemoteEndpointRespondedLocked(
- const std::string& remote_endpoint_id,
- location::nearby::proto::connections::ConnectionRequestResponse response)
- ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- void MarkConnectionRequestIgnoredLocked(
- location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
- request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
- void OnIncomingConnectionAttemptLocked(
- location::nearby::proto::connections::ConnectionAttemptType type,
- location::nearby::proto::connections::Medium medium,
- location::nearby::proto::connections::ConnectionAttemptResult result,
- absl::Duration duration, const std::string& connection_token,
- ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
- ABSL_SHARED_LOCKS_REQUIRED(mutex_);
- void OnOutgoingConnectionAttemptLocked(
- const std::string& remote_endpoint_id,
- location::nearby::proto::connections::ConnectionAttemptType type,
- location::nearby::proto::connections::Medium medium,
- location::nearby::proto::connections::ConnectionAttemptResult result,
- absl::Duration duration, const std::string& connection_token,
- ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
- ABSL_SHARED_LOCKS_REQUIRED(mutex_);
- bool ConnectionAttemptResultCodeExistedLocked(
- location::nearby::proto::connections::Medium medium,
- location::nearby::proto::connections::ConnectionAttemptDirection
- direction,
- const std::string& connection_token,
- location::nearby::proto::connections::ConnectionAttemptType type,
location::nearby::proto::connections::OperationResultCode
- operation_result_code) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
- bool EraseIfBandwidthUpgradeRecordExistedLocked(
- const std::string& endpoint_id,
- location::nearby::proto::connections::BandwidthUpgradeResult result,
- location::nearby::proto::connections::BandwidthUpgradeErrorStage
- error_stage,
- location::nearby::proto::connections::OperationResultCode
- operation_result_code) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
- void FinishUpgradeAttemptLocked(
- const std::string& endpoint_id,
- location::nearby::proto::connections::BandwidthUpgradeResult result,
- location::nearby::proto::connections::BandwidthUpgradeErrorStage
- error_stage,
- location::nearby::proto::connections::OperationResultCode
- operation_result_code,
- bool erase_item = true) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
- void FinishStrategySessionLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
+ result_code) = 0;
- int GetLatestUpdateIndexLocked(
- const std::vector& list)
- ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
-
- location::nearby::proto::connections::ConnectionsStrategy
- StrategyToConnectionStrategy(connections::Strategy strategy);
- location::nearby::proto::connections::PayloadType
- PayloadTypeToProtoPayloadType(connections::PayloadType type);
-
- // Not owned by AnalyticsRecorder. Pointer must refer to a valid object
- // that outlives the one constructed.
- ::nearby::analytics::EventLogger* event_logger_;
-
- // Protects all sub-protos reading and writing in ConnectionLog.
- Mutex mutex_;
-
- // ClientSession
- std::unique_ptr<
- location::nearby::analytics::proto::ConnectionsLog::ClientSession>
- client_session_;
- absl::Time started_client_session_time_;
- bool session_was_logged_ ABSL_GUARDED_BY(mutex_) = false;
- bool start_client_session_was_logged_ ABSL_GUARDED_BY(mutex_) = false;
-
- // Current StrategySession
- connections::Strategy current_strategy_ ABSL_GUARDED_BY(mutex_) =
- connections::Strategy::kNone;
- std::unique_ptr<
- location::nearby::analytics::proto::ConnectionsLog::StrategySession>
- current_strategy_session_ ABSL_GUARDED_BY(mutex_);
- absl::Time started_strategy_session_time_ ABSL_GUARDED_BY(mutex_);
-
- // Current AdvertisingPhase
- std::unique_ptr<
- location::nearby::analytics::proto::ConnectionsLog::AdvertisingPhase>
- current_advertising_phase_;
- absl::Time started_advertising_phase_time_ = absl::InfinitePast();
-
- // Current DiscoveryPhase
- std::unique_ptr<
- location::nearby::analytics::proto::ConnectionsLog::DiscoveryPhase>
- current_discovery_phase_;
- absl::Time started_discovery_phase_time_ = absl::InfinitePast();
-
- absl::btree_map>
- incoming_connection_requests_ ABSL_GUARDED_BY(mutex_);
- absl::btree_map>
- outgoing_connection_requests_ ABSL_GUARDED_BY(mutex_);
- absl::btree_map>
- active_connections_ ABSL_GUARDED_BY(mutex_);
- absl::btree_map>
- bandwidth_upgrade_attempts_ ABSL_GUARDED_BY(mutex_);
+ virtual void Sync() = 0;
};
-} // namespace analytics
-} // namespace nearby
+} // namespace nearby::analytics
#endif // ANALYTICS_ANALYTICS_RECORDER_H_
diff --git a/connections/implementation/analytics/analytics_recorder_impl.cc b/connections/implementation/analytics/analytics_recorder_impl.cc
new file mode 100644
index 00000000..75d155a9
--- /dev/null
+++ b/connections/implementation/analytics/analytics_recorder_impl.cc
@@ -0,0 +1,16 @@
+// Copyright 2026 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 "connections/implementation/analytics/analytics_recorder_impl.h"
+
diff --git a/connections/implementation/analytics/analytics_recorder_impl.h b/connections/implementation/analytics/analytics_recorder_impl.h
new file mode 100644
index 00000000..b26ffb01
--- /dev/null
+++ b/connections/implementation/analytics/analytics_recorder_impl.h
@@ -0,0 +1,150 @@
+// Copyright 2026 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.
+
+#ifndef CONNECTIONS_IMPLEMENTATION_ANALYTICS_ANALYTICS_RECORDER_IMPL_H_
+#define CONNECTIONS_IMPLEMENTATION_ANALYTICS_ANALYTICS_RECORDER_IMPL_H_
+
+#include
+#include
+#include
+
+#include "absl/time/time.h"
+#include "connections/implementation/analytics/analytics_recorder.h"
+#include "location/nearby/analytics/cpp/logging/event_logger.h"
+#include "proto/connections_enums.pb.h"
+
+namespace nearby::analytics {
+
+class AnalyticsRecorderImpl : public AnalyticsRecorder {
+ public:
+ explicit AnalyticsRecorderImpl(EventLogger* event_logger = nullptr)
+ : event_logger_(event_logger) {}
+ ~AnalyticsRecorderImpl() override = default;
+
+ void OnStartAdvertising(
+ connections::Strategy strategy,
+ const std::vector& mediums,
+ AdvertisingMetadataParams* advertising_metadata_params) override {}
+ void OnStopAdvertising() override {}
+ int GetNextAdvertisingUpdateIndex() override { return 0; }
+ void OnStartedIncomingConnectionListening(
+ connections::Strategy strategy) override {}
+ void OnStoppedIncomingConnectionListening() override {}
+ void OnStartDiscovery(
+ connections::Strategy strategy,
+ const std::vector& mediums,
+ DiscoveryMetadataParams* discovery_metadata_params) override {}
+ void OnStopDiscovery() override {}
+ int GetNextDiscoveryUpdateIndex() override { return 0; }
+ void OnEndpointFound(
+ location::nearby::proto::connections::Medium medium) override {}
+ void OnRequestConnection(const connections::Strategy& strategy,
+ const std::string& endpoint_id) override {}
+ void OnConnectionRequestReceived(
+ const std::string& remote_endpoint_id) override {}
+ void OnConnectionRequestSent(const std::string& remote_endpoint_id) override {}
+ void OnRemoteEndpointAccepted(
+ const std::string& remote_endpoint_id) override {}
+ void OnLocalEndpointAccepted(
+ const std::string& remote_endpoint_id) override {}
+ void OnRemoteEndpointRejected(
+ const std::string& remote_endpoint_id) override {}
+ void OnLocalEndpointRejected(
+ const std::string& remote_endpoint_id) override {}
+ void OnIncomingConnectionAttempt(
+ location::nearby::proto::connections::ConnectionAttemptType type,
+ location::nearby::proto::connections::Medium medium,
+ location::nearby::proto::connections::ConnectionAttemptResult result,
+ absl::Duration duration, const std::string& connection_token,
+ ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
+ override {}
+ void OnOutgoingConnectionAttempt(
+ const std::string& remote_endpoint_id,
+ location::nearby::proto::connections::ConnectionAttemptType type,
+ location::nearby::proto::connections::Medium medium,
+ location::nearby::proto::connections::ConnectionAttemptResult result,
+ absl::Duration duration, const std::string& connection_token,
+ ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
+ override {}
+ void OnConnectionEstablished(
+ const std::string& endpoint_id,
+ location::nearby::proto::connections::Medium medium,
+ const std::string& connection_token) override {}
+ void OnConnectionClosed(
+ const std::string& endpoint_id,
+ location::nearby::proto::connections::Medium medium,
+ location::nearby::proto::connections::DisconnectionReason reason,
+ SafeDisconnectionResult result) override {}
+ void OnIncomingPayloadStarted(const std::string& endpoint_id,
+ std::int64_t payload_id,
+ connections::PayloadType type,
+ std::int64_t total_size_bytes) override {}
+ void OnPayloadChunkReceived(const std::string& endpoint_id,
+ std::int64_t payload_id,
+ std::int64_t chunk_size_bytes) override {}
+ void OnIncomingPayloadDone(
+ const std::string& endpoint_id, std::int64_t payload_id,
+ location::nearby::proto::connections::PayloadStatus status,
+ location::nearby::proto::connections::OperationResultCode
+ operation_result_code) override {}
+ void OnOutgoingPayloadStarted(const std::vector& endpoint_ids,
+ std::int64_t payload_id,
+ connections::PayloadType type,
+ std::int64_t total_size_bytes) override {}
+ void OnPayloadChunkSent(const std::string& endpoint_id,
+ std::int64_t payload_id,
+ std::int64_t chunk_size_bytes) override {}
+ void OnOutgoingPayloadDone(
+ const std::string& endpoint_id, std::int64_t payload_id,
+ location::nearby::proto::connections::PayloadStatus status,
+ location::nearby::proto::connections::OperationResultCode
+ operation_result_code) override {}
+ void OnBandwidthUpgradeStarted(
+ const std::string& endpoint_id,
+ location::nearby::proto::connections::Medium from_medium,
+ location::nearby::proto::connections::Medium to_medium,
+ location::nearby::proto::connections::ConnectionAttemptDirection
+ direction,
+ const std::string& connection_token) override {}
+ void UpdateBwUpgradeNetworkInfo(const std::string& endpoint_id,
+ int num_interfaces,
+ int num_ipv6_only_interfaces) override {}
+ void OnBandwidthUpgradeError(
+ const std::string& endpoint_id,
+ location::nearby::proto::connections::BandwidthUpgradeResult result,
+ location::nearby::proto::connections::BandwidthUpgradeErrorStage
+ error_stage,
+ location::nearby::proto::connections::OperationResultCode
+ operation_result_code) override {}
+ void OnBandwidthUpgradeSuccess(const std::string& endpoint_id) override {}
+ void OnErrorCode(const ErrorCodeParams& params) override {}
+ void LogStartSession() override {}
+ void LogSession() override {}
+ bool IsSessionLogged() override { return false; }
+ location::nearby::proto::connections::OperationResultCategory
+ GetOperationResultCategory(
+ location::nearby::proto::connections::OperationResultCode result_code)
+ override {
+ return location::nearby::proto::connections::CATEGORY_UNKNOWN;
+ }
+ void Sync() override {}
+
+ private:
+ EventLogger* event_logger_;
+};
+
+} // namespace nearby::analytics
+
+#endif // CONNECTIONS_IMPLEMENTATION_ANALYTICS_ANALYTICS_RECORDER_IMPL_H_
+
diff --git a/connections/implementation/analytics/analytics_recorder_test.cc b/connections/implementation/analytics/analytics_recorder_test.cc
deleted file mode 100644
index c431e862..00000000
--- a/connections/implementation/analytics/analytics_recorder_test.cc
+++ /dev/null
@@ -1,2593 +0,0 @@
-// Copyright 2022-2023 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 "connections/implementation/analytics/analytics_recorder.h"
-
-#include
-
-#include
-#include
-#include
-#include
-
-#include "net/proto2/contrib/parse_proto/parse_text_proto.h"
-#include "gmock/gmock.h"
-#include "protobuf-matchers/protocol-buffer-matchers.h"
-#include "gtest/gtest.h"
-#include "absl/time/time.h"
-#include "connections/implementation/analytics/connection_attempt_metadata_params.h"
-#include "connections/payload_type.h"
-#include "connections/strategy.h"
-#include "internal/analytics/mock_event_logger.h"
-#include "internal/platform/count_down_latch.h"
-#include "internal/platform/error_code_params.h"
-#include "internal/platform/error_code_recorder.h"
-#include "internal/platform/exception.h"
-#include "internal/platform/medium_environment.h"
-#include "internal/proto/analytics/connections_log.proto.h"
-#include "internal/test/fake_clock.h"
-#include "proto/connections_enums.proto.h"
-
-namespace nearby {
-namespace analytics {
-namespace {
-
-using ::location::nearby::analytics::proto::ConnectionsLog;
-using ::location::nearby::errorcode::proto::DISCONNECT;
-using ::location::nearby::errorcode::proto::DISCONNECT_NETWORK_FAILED;
-using ::location::nearby::errorcode::proto::INVALID_PARAMETER;
-using ::location::nearby::errorcode::proto::NULL_BLUETOOTH_DEVICE_NAME;
-using ::location::nearby::errorcode::proto::START_DISCOVERING;
-using ::location::nearby::errorcode::proto::START_EXTENDED_DISCOVERING_FAILED;
-using ::location::nearby::errorcode::proto::
- TACHYON_SEND_MESSAGE_STATUS_EXCEPTION;
-using ::location::nearby::proto::connections::BLE;
-using ::location::nearby::proto::connections::BLUETOOTH;
-using ::location::nearby::proto::connections::CLIENT_SESSION;
-using ::location::nearby::proto::connections::ERROR_CODE;
-using ::location::nearby::proto::connections::EventType;
-using ::location::nearby::proto::connections::INCOMING;
-using ::location::nearby::proto::connections::INITIAL;
-using ::location::nearby::proto::connections::LOCAL_DISCONNECTION;
-using ::location::nearby::proto::connections::Medium;
-using ::location::nearby::proto::connections::OperationResultCategory;
-using ::location::nearby::proto::connections::OperationResultCode;
-using ::location::nearby::proto::connections::RESULT_ERROR;
-using ::location::nearby::proto::connections::RESULT_SUCCESS;
-using ::location::nearby::proto::connections::START_CLIENT_SESSION;
-using ::location::nearby::proto::connections::START_STRATEGY_SESSION;
-using ::location::nearby::proto::connections::STOP_CLIENT_SESSION;
-using ::location::nearby::proto::connections::STOP_STRATEGY_SESSION;
-using ::location::nearby::proto::connections::SUCCESS;
-using ::location::nearby::proto::connections::UPGRADED;
-using ::location::nearby::proto::connections::WEB_RTC;
-using ::location::nearby::proto::connections::WIFI_LAN;
-using ::location::nearby::proto::connections::WIFI_LAN_MEDIUM_ERROR;
-using ::location::nearby::proto::connections::WIFI_LAN_SOCKET_CREATION;
-using ::nearby::analytics::MockEventLogger;
-using ::proto2::contrib::parse_proto::ParseTextProtoOrDie;
-using ::testing::Contains;
-using ::protobuf_matchers::EqualsProto;
-using ::testing::Not;
-
-constexpr absl::Duration kDefaultTimeout = absl::Milliseconds(1000);
-
-class FakeEventLogger : public MockEventLogger {
- public:
- explicit FakeEventLogger(CountDownLatch& client_session_done_latch)
- : client_session_done_latch_(client_session_done_latch) {}
-
- FakeEventLogger(CountDownLatch& client_session_done_latch,
- CountDownLatch* start_client_session_done_latch_ptr)
- : client_session_done_latch_(client_session_done_latch),
- start_client_session_done_latch_ptr_(
- start_client_session_done_latch_ptr) {}
-
- void Log(const ConnectionsLog& message) override {
- EventType event_type = message.event_type();
- logged_event_types_.push_back(event_type);
- if (event_type == CLIENT_SESSION) {
- logged_client_session_count_++;
- logged_client_session_ = message.client_session();
- }
- if (event_type == ERROR_CODE) {
- error_code_ = message.error_code();
- }
- if (event_type == STOP_CLIENT_SESSION) {
- client_session_done_latch_.CountDown();
- }
- if (start_client_session_done_latch_ptr_ != nullptr &&
- event_type == START_CLIENT_SESSION) {
- start_client_session_done_latch_ptr_->CountDown();
- }
- }
-
- int GetLoggedClientSessionCount() const {
- return logged_client_session_count_;
- }
-
- const ConnectionsLog::ClientSession& GetLoggedClientSession() {
- return logged_client_session_;
- }
-
- const ConnectionsLog::ErrorCode& GetErrorCode() { return error_code_; }
-
- std::vector GetLoggedEventTypes() { return logged_event_types_; }
-
- void SetClientSessionDoneLatch(
- const CountDownLatch& client_session_done_latch) {
- client_session_done_latch_ = client_session_done_latch;
- }
-
- void SetStartClientSessionDoneLatchPtr(
- CountDownLatch* start_client_session_done_latch_ptr) {
- start_client_session_done_latch_ptr_ = start_client_session_done_latch_ptr;
- }
-
- private:
- int logged_client_session_count_ = 0;
- CountDownLatch& client_session_done_latch_;
- CountDownLatch* start_client_session_done_latch_ptr_ = nullptr;
- ConnectionsLog::ClientSession logged_client_session_;
- ConnectionsLog::ErrorCode error_code_;
- std::vector logged_event_types_;
-};
-
-class AnalyticsRecorderTest : public ::testing::Test {
- protected:
- void SetUp() override {
- MediumEnvironment::Instance().Start({.use_simulated_clock = true});
- }
-
- void TearDown() override { MediumEnvironment::Instance().Stop(); }
-
- FakeClock& GetFakeClock() const {
- return *MediumEnvironment::Instance().GetSimulatedClock().value();
- }
-};
-
-// Test if session_was_logged_ is reset by checking if LogSession can take
-// effect again or not.
-TEST_F(AnalyticsRecorderTest, SessionOnlyLoggedOnceWorks) {
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- analytics_recorder.LogSession();
- analytics_recorder.LogSession();
- analytics_recorder.LogSession();
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- // Only called once.
- EXPECT_EQ(event_logger.GetLoggedClientSessionCount(), 1);
-}
-
-TEST_F(AnalyticsRecorderTest, SetFieldsCorrectlyForNestedAdvertisingCalls) {
- connections::Strategy strategy = connections::Strategy::kP2pStar;
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- ConnectionsLog::OperationResultWithMedium operation_result;
- operation_result.set_medium(BLUETOOTH);
- operation_result.set_result_code(OperationResultCode::DETAIL_SUCCESS);
- operation_result.set_result_category(
- OperationResultCategory::CATEGORY_SUCCESS);
- auto advertising_metadata_params =
- analytics_recorder.BuildAdvertisingMetadataParams();
- advertising_metadata_params->operation_result_with_mediums = {
- operation_result};
- GetFakeClock().FastForward(absl::Milliseconds(50));
- analytics_recorder.OnStartAdvertising(strategy, /*mediums=*/{BLE, BLUETOOTH},
- advertising_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStopAdvertising();
- operation_result.set_medium(BLE);
- advertising_metadata_params->operation_result_with_mediums = {
- operation_result};
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnStartAdvertising(strategy, /*mediums=*/{BLUETOOTH},
- advertising_metadata_params.get());
-
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 650
- strategy_session {
- duration_millis: 600
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 100
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- adv_dis_result {
- medium: BLUETOOTH
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- stop_reason: CLIENT_STOP_ADVERTISING
- }
- advertising_phase {
- duration_millis: 300
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- adv_dis_result {
- medium: BLE
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- stop_reason: FINISH_SESSION_STOP_ADVERTISING
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- (EqualsProto(strategy_session_proto)));
-}
-
-TEST_F(AnalyticsRecorderTest, SetFieldsCorrectlyForNestedDiscoveryCalls) {
- connections::Strategy strategy = connections::Strategy::kP2pStar;
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- ConnectionsLog::OperationResultWithMedium operation_result;
- operation_result.set_medium(BLUETOOTH);
- operation_result.set_result_code(OperationResultCode::DETAIL_SUCCESS);
- operation_result.set_result_category(
- OperationResultCategory::CATEGORY_SUCCESS);
- ConnectionsLog::OperationResultWithMedium operation_result2;
- operation_result2.set_medium(BLE);
- operation_result2.set_result_code(OperationResultCode::DETAIL_SUCCESS);
- operation_result2.set_result_category(
- OperationResultCategory::CATEGORY_SUCCESS);
-
- auto discovery_metadata_params =
- analytics_recorder.BuildDiscoveryMetadataParams(
- /*is_extended_advertisement_supported*/ true,
- /*connected_ap_frequency*/ 1, /*is_nfc_available=*/false,
- {operation_result, operation_result2});
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartDiscovery(strategy, /*mediums=*/{BLE, BLUETOOTH},
- discovery_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnStopDiscovery();
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.OnEndpointFound(BLUETOOTH);
- GetFakeClock().FastForward(absl::Milliseconds(400));
- analytics_recorder.OnEndpointFound(BLE);
- GetFakeClock().FastForward(absl::Milliseconds(500));
-
- auto discovery_metadata_params2 =
- analytics_recorder.BuildDiscoveryMetadataParams(
- /*is_extended_advertisement_supported*/ true,
- /*connected_ap_frequency*/ 1, /*is_nfc_available=*/false,
- {operation_result});
- analytics_recorder.OnStartDiscovery(strategy, /*mediums=*/{BLUETOOTH},
- discovery_metadata_params2.get());
- GetFakeClock().FastForward(absl::Milliseconds(600));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 2100
- strategy_session {
- duration_millis: 2000
- strategy: P2P_STAR
- role: DISCOVERER
- discovery_phase {
- duration_millis: 200
- medium: BLE
- medium: BLUETOOTH
- discovered_endpoint {
- medium: BLUETOOTH
- latency_millis: 500
- }
- discovered_endpoint {
- medium: BLE
- latency_millis: 900
- }
- discovery_metadata {
- supports_extended_ble_advertisements: true
- connected_ap_frequency: 1
- supports_nfc_technology: false
- }
- adv_dis_result {
- medium: BLUETOOTH
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- adv_dis_result {
- medium: BLE
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- stop_reason: CLIENT_STOP_DISCOVERING
- }
- discovery_phase {
- duration_millis: 600
- medium: BLUETOOTH
- discovery_metadata {
- supports_extended_ble_advertisements: true
- connected_ap_frequency: 1
- supports_nfc_technology: false
- }
- adv_dis_result {
- medium: BLUETOOTH
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- stop_reason: FINISH_SESSION_STOP_DISCOVERING
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto));
-}
-
-TEST_F(AnalyticsRecorderTest,
- OneStrategySessionForMultipleRoundsOfDiscoveryAdvertising) {
- connections::Strategy strategy = connections::Strategy::kP2pStar;
- std::vector mediums = {BLE, BLUETOOTH};
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- auto advertising_metadata_params =
- analytics_recorder.BuildAdvertisingMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartAdvertising(strategy, mediums,
- advertising_metadata_params.get());
- auto discovery_metadata_params =
- analytics_recorder.BuildDiscoveryMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnStartDiscovery(strategy, mediums,
- discovery_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.OnStopAdvertising();
- GetFakeClock().FastForward(absl::Milliseconds(400));
- analytics_recorder.OnStopDiscovery();
- GetFakeClock().FastForward(absl::Milliseconds(500));
- analytics_recorder.OnStartAdvertising(strategy, mediums,
- advertising_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(600));
- analytics_recorder.OnStopAdvertising();
- GetFakeClock().FastForward(absl::Milliseconds(700));
- analytics_recorder.OnStartDiscovery(strategy, mediums,
- discovery_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(800));
- analytics_recorder.OnStopDiscovery();
- GetFakeClock().FastForward(absl::Milliseconds(900));
- analytics_recorder.OnStartDiscovery(strategy, mediums, {});
- GetFakeClock().FastForward(absl::Milliseconds(1000));
- analytics_recorder.OnStartAdvertising(strategy, mediums,
- advertising_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(1100));
- analytics_recorder.OnStopDiscovery();
- GetFakeClock().FastForward(absl::Milliseconds(1200));
- analytics_recorder.OnStopAdvertising();
- GetFakeClock().FastForward(absl::Milliseconds(1300));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- std::vector event_types = event_logger.GetLoggedEventTypes();
- EXPECT_THAT(event_types, Contains(START_STRATEGY_SESSION).Times(1));
- EXPECT_THAT(event_types, Contains(STOP_STRATEGY_SESSION).Times(1));
-
- ConnectionsLog::ClientSession strategy_session_proto =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 9100
- strategy_session {
- duration_millis: 9000
- strategy: P2P_STAR
- role: ADVERTISER
- role: DISCOVERER
- discovery_phase {
- duration_millis: 700
- medium: BLE
- medium: BLUETOOTH
- discovery_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: CLIENT_STOP_DISCOVERING
- }
- discovery_phase {
- duration_millis: 800
- medium: BLE
- medium: BLUETOOTH
- discovery_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: CLIENT_STOP_DISCOVERING
- }
- discovery_phase {
- duration_millis: 2100
- medium: BLE
- medium: BLUETOOTH
- discovery_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: CLIENT_STOP_DISCOVERING
- }
- advertising_phase {
- duration_millis: 500
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: CLIENT_STOP_ADVERTISING
- }
- advertising_phase {
- duration_millis: 600
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: CLIENT_STOP_ADVERTISING
- }
- advertising_phase {
- duration_millis: 2300
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: CLIENT_STOP_ADVERTISING
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto));
-}
-
-TEST_F(AnalyticsRecorderTest, AdvertiserConnectionRequestsWorks) {
- std::string endpoint_id_0 = "endpoint_id_0";
- std::string endpoint_id_1 = "endpoint_id_1";
- std::string endpoint_id_2 = "endpoint_id_2";
- std::string endpoint_id_3 = "endpoint_id_3";
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- ConnectionsLog::OperationResultWithMedium operation_result;
- operation_result.set_medium(BLE);
- operation_result.set_result_code(OperationResultCode::DETAIL_SUCCESS);
- operation_result.set_result_category(
- OperationResultCategory::CATEGORY_SUCCESS);
- auto advertising_metadata_params =
- analytics_recorder.BuildAdvertisingMetadataParams();
- advertising_metadata_params->operation_result_with_mediums = {
- operation_result};
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar,
- /*mediums=*/{BLE, BLUETOOTH},
- advertising_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnConnectionRequestReceived(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.OnLocalEndpointAccepted(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(400));
- analytics_recorder.OnRemoteEndpointAccepted(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(500));
- analytics_recorder.OnConnectionRequestReceived(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(600));
- analytics_recorder.OnLocalEndpointAccepted(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(700));
- analytics_recorder.OnRemoteEndpointRejected(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(800));
- analytics_recorder.OnConnectionRequestReceived(endpoint_id_2);
- GetFakeClock().FastForward(absl::Milliseconds(900));
- analytics_recorder.OnLocalEndpointRejected(endpoint_id_2);
- GetFakeClock().FastForward(absl::Milliseconds(1000));
- analytics_recorder.OnRemoteEndpointAccepted(endpoint_id_2);
- GetFakeClock().FastForward(absl::Milliseconds(1100));
- analytics_recorder.OnConnectionRequestReceived(endpoint_id_3);
- GetFakeClock().FastForward(absl::Milliseconds(1200));
- analytics_recorder.OnLocalEndpointRejected(endpoint_id_3);
- GetFakeClock().FastForward(absl::Milliseconds(1300));
- analytics_recorder.OnRemoteEndpointRejected(endpoint_id_3);
- GetFakeClock().FastForward(absl::Milliseconds(1400));
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 10500
- strategy_session {
- duration_millis: 10400
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 10400
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- adv_dis_result {
- medium: BLE
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- stop_reason: FINISH_SESSION_STOP_ADVERTISING
- received_connection_request {
- duration_millis: 700
- request_delay_millis: 200
- local_response: ACCEPTED
- remote_response: ACCEPTED
- }
- received_connection_request {
- duration_millis: 1300
- request_delay_millis: 1400
- local_response: ACCEPTED
- remote_response: REJECTED
- }
- received_connection_request {
- duration_millis: 1900
- request_delay_millis: 3500
- local_response: REJECTED
- remote_response: ACCEPTED
- }
- received_connection_request {
- duration_millis: 2500
- request_delay_millis: 6500
- local_response: REJECTED
- remote_response: REJECTED
- }
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto));
-}
-
-TEST_F(AnalyticsRecorderTest, DiscoveryConnectionRequestsWorks) {
- std::string endpoint_id_0 = "endpoint_id_0";
- std::string endpoint_id_1 = "endpoint_id_1";
- std::string endpoint_id_2 = "endpoint_id_2";
- std::string endpoint_id_3 = "endpoint_id_3";
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- ConnectionsLog::OperationResultWithMedium operation_result;
- operation_result.set_medium(BLUETOOTH);
- operation_result.set_result_code(OperationResultCode::DETAIL_SUCCESS);
- operation_result.set_result_category(
- OperationResultCategory::CATEGORY_SUCCESS);
- auto discovery_metadata_params =
- analytics_recorder.BuildDiscoveryMetadataParams();
- discovery_metadata_params->operation_result_with_mediums = {operation_result};
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartDiscovery(connections::Strategy::kP2pStar,
- /*mediums=*/{BLE, BLUETOOTH},
- discovery_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnConnectionRequestSent(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.OnLocalEndpointAccepted(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(400));
- analytics_recorder.OnRemoteEndpointAccepted(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(500));
- analytics_recorder.OnConnectionRequestSent(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(600));
- analytics_recorder.OnLocalEndpointAccepted(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(700));
- analytics_recorder.OnRemoteEndpointRejected(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(800));
- analytics_recorder.OnConnectionRequestSent(endpoint_id_2);
- GetFakeClock().FastForward(absl::Milliseconds(900));
- analytics_recorder.OnLocalEndpointRejected(endpoint_id_2);
- GetFakeClock().FastForward(absl::Milliseconds(1000));
- analytics_recorder.OnRemoteEndpointAccepted(endpoint_id_2);
- GetFakeClock().FastForward(absl::Milliseconds(1100));
-
- analytics_recorder.OnConnectionRequestSent(endpoint_id_3);
- GetFakeClock().FastForward(absl::Milliseconds(1200));
- analytics_recorder.OnLocalEndpointRejected(endpoint_id_3);
- GetFakeClock().FastForward(absl::Milliseconds(1300));
- analytics_recorder.OnRemoteEndpointRejected(endpoint_id_3);
- GetFakeClock().FastForward(absl::Milliseconds(1400));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 10500
- strategy_session {
- duration_millis: 10400
- strategy: P2P_STAR
- role: DISCOVERER
- discovery_phase {
- duration_millis: 10400
- medium: BLE
- medium: BLUETOOTH
- discovery_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- adv_dis_result {
- medium: BLUETOOTH
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- stop_reason: FINISH_SESSION_STOP_DISCOVERING
- sent_connection_request {
- duration_millis: 700
- request_delay_millis: 200
- local_response: ACCEPTED
- remote_response: ACCEPTED
- }
- sent_connection_request {
- duration_millis: 1300
- request_delay_millis: 1400
- local_response: ACCEPTED
- remote_response: REJECTED
- }
- sent_connection_request {
- duration_millis: 1900
- request_delay_millis: 3500
- local_response: REJECTED
- remote_response: ACCEPTED
- }
- sent_connection_request {
- duration_millis: 2500
- request_delay_millis: 6500
- local_response: REJECTED
- remote_response: REJECTED
- }
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto));
-}
-
-TEST_F(AnalyticsRecorderTest,
- AdvertiserUnfinishedConnectionRequestsIncludedAsIgnored) {
- std::string endpoint_id_0 = "endpoint_id_0";
- std::string endpoint_id_1 = "endpoint_id_1";
- std::string endpoint_id_2 = "endpoint_id_2";
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- ConnectionsLog::OperationResultWithMedium operation_result;
- operation_result.set_medium(BLUETOOTH);
- operation_result.set_result_code(OperationResultCode::DETAIL_SUCCESS);
- operation_result.set_result_category(
- OperationResultCategory::CATEGORY_SUCCESS);
- auto advertising_metadata_params =
- analytics_recorder.BuildAdvertisingMetadataParams();
- advertising_metadata_params->operation_result_with_mediums = {
- operation_result};
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar,
- /*mediums=*/{BLE, BLUETOOTH},
- advertising_metadata_params.get());
- // Ignored by local.
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnConnectionRequestReceived(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.OnRemoteEndpointAccepted(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(400));
-
- // Ignored by remote.
- analytics_recorder.OnConnectionRequestReceived(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(500));
- analytics_recorder.OnLocalEndpointAccepted(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(600));
-
- // Ignored by both.
- analytics_recorder.OnConnectionRequestReceived(endpoint_id_2);
- GetFakeClock().FastForward(absl::Milliseconds(700));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 2800
- strategy_session {
- duration_millis: 2700
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 2700
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- adv_dis_result {
- medium: BLUETOOTH
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- stop_reason: FINISH_SESSION_STOP_ADVERTISING
- received_connection_request {
- duration_millis: 2500
- request_delay_millis: 200
- local_response: IGNORED
- remote_response: ACCEPTED
- }
- received_connection_request {
- duration_millis: 1800
- request_delay_millis: 900
- local_response: ACCEPTED
- remote_response: IGNORED
- }
- received_connection_request {
- duration_millis: 700
- request_delay_millis: 2000
- local_response: IGNORED
- remote_response: IGNORED
- }
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto));
-}
-
-TEST_F(AnalyticsRecorderTest,
- DiscovererUnfinishedConnectionRequestsIncludedAsIgnored) {
- std::string endpoint_id_0 = "endpoint_id_0";
- std::string endpoint_id_1 = "endpoint_id_1";
- std::string endpoint_id_2 = "endpoint_id_2";
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- ConnectionsLog::OperationResultWithMedium operation_result;
- operation_result.set_medium(BLUETOOTH);
- operation_result.set_result_code(OperationResultCode::DETAIL_SUCCESS);
- operation_result.set_result_category(
- OperationResultCategory::CATEGORY_SUCCESS);
- auto discovery_metadata_params =
- analytics_recorder.BuildDiscoveryMetadataParams();
- discovery_metadata_params->operation_result_with_mediums = {operation_result};
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartDiscovery(connections::Strategy::kP2pStar,
- /*mediums=*/{BLE, BLUETOOTH},
- discovery_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(200));
-
- // Ignored by local.
- analytics_recorder.OnConnectionRequestSent(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.OnRemoteEndpointAccepted(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(400));
-
- // Ignored by remote.
- analytics_recorder.OnConnectionRequestSent(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(500));
- analytics_recorder.OnLocalEndpointAccepted(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(600));
-
- // Ignored by both.
- analytics_recorder.OnConnectionRequestSent(endpoint_id_2);
- GetFakeClock().FastForward(absl::Milliseconds(700));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 2800
- strategy_session {
- duration_millis: 2700
- strategy: P2P_STAR
- role: DISCOVERER
- discovery_phase {
- duration_millis: 2700
- medium: BLE
- medium: BLUETOOTH
- discovery_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- adv_dis_result {
- medium: BLUETOOTH
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- stop_reason: FINISH_SESSION_STOP_DISCOVERING
- sent_connection_request {
- duration_millis: 2500
- request_delay_millis: 200
- local_response: IGNORED
- remote_response: ACCEPTED
- }
- sent_connection_request {
- duration_millis: 1800
- request_delay_millis: 900
- local_response: ACCEPTED
- remote_response: IGNORED
- }
- sent_connection_request {
- duration_millis: 700
- request_delay_millis: 2000
- local_response: IGNORED
- remote_response: IGNORED
- }
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto));
-}
-
-TEST_F(AnalyticsRecorderTest, SuccessfulIncomingConnectionAttempt) {
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- ConnectionsLog::OperationResultWithMedium operation_result;
- operation_result.set_medium(BLUETOOTH);
- operation_result.set_result_code(OperationResultCode::DETAIL_SUCCESS);
- operation_result.set_result_category(
- OperationResultCategory::CATEGORY_SUCCESS);
- auto advertising_metadata_params =
- analytics_recorder.BuildAdvertisingMetadataParams();
- advertising_metadata_params->operation_result_with_mediums = {
- operation_result};
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar,
- /*mediums=*/{BLE, BLUETOOTH},
- advertising_metadata_params.get());
-
- auto connections_attempt_metadata_params =
- std::make_unique();
- connections_attempt_metadata_params->operation_result_code =
- OperationResultCode::DETAIL_SUCCESS;
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnIncomingConnectionAttempt(
- INITIAL, BLUETOOTH, RESULT_SUCCESS, absl::Duration{},
- /*connection_token=*/"", connections_attempt_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.OnStopAdvertising();
- GetFakeClock().FastForward(absl::Milliseconds(400));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 1000
- strategy_session {
- duration_millis: 900
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 500
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: CLIENT_STOP_ADVERTISING
- adv_dis_result {
- medium: BLUETOOTH
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- }
- connection_attempt {
- duration_millis: 0
- type: INITIAL
- direction: INCOMING
- medium: BLUETOOTH
- attempt_result: RESULT_SUCCESS
- connection_token: ""
- connection_attempt_metadata {
- technology: CONNECTION_TECHNOLOGY_UNKNOWN_TECHNOLOGY
- band: CONNECTION_BAND_UNKNOWN_BAND
- frequency: -1
- network_operator: ""
- country_code: ""
- is_tdls_used: false
- try_counts: 0
- wifi_hotspot_status: false
- max_tx_speed: 0
- max_rx_speed: 0
- wifi_channel_width: -1
- }
- operation_result {
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto));
-}
-
-TEST_F(AnalyticsRecorderTest,
- FailedConnectionAttemptUpdatesConnectionRequestNotSent) {
- std::string endpoint_id = "endpoint_id";
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- auto connections_attempt_metadata_params =
- analytics_recorder.BuildConnectionAttemptMetadataParams(
- ::location::nearby::proto::connections::
- CONNECTION_TECHNOLOGY_HOTSPOT_LOCALONLY,
- ::location::nearby::proto::connections::
- CONNECTION_BAND_WIFI_BAND_6GHZ,
- /*frequency*/ 2400, /*try_count*/ 0, /*network_operator*/ {},
- /*country_code*/ {}, /*is_tdls_used*/ false,
- /*wifi_hotspot_enabled*/ false, /*max_wifi_tx_speed*/ 0,
- /*max_wifi_rx_speed*/ 0, /*channel_width*/ 0,
- OperationResultCode::CONNECTIVITY_BT_CLIENT_SOCKET_CREATION_FAILURE);
- auto discovery_metadata_params =
- analytics_recorder.BuildDiscoveryMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartDiscovery(connections::Strategy::kP2pStar,
- /*mediums=*/{BLE, BLUETOOTH},
- discovery_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnConnectionRequestSent(endpoint_id);
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.OnOutgoingConnectionAttempt(
- endpoint_id, INITIAL, BLUETOOTH, RESULT_ERROR, absl::Duration{},
- /*connection_token=*/"", connections_attempt_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(400));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 1000
- strategy_session {
- duration_millis: 900
- strategy: P2P_STAR
- role: DISCOVERER
- discovery_phase {
- duration_millis: 900
- medium: BLE
- medium: BLUETOOTH
- discovery_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: FINISH_SESSION_STOP_DISCOVERING
- sent_connection_request {
- duration_millis: 300
- request_delay_millis: 200
- local_response: NOT_SENT
- remote_response: NOT_SENT
- }
- }
- connection_attempt {
- duration_millis: 0
- type: INITIAL
- direction: OUTGOING
- medium: BLUETOOTH
- attempt_result: RESULT_ERROR
- connection_token: ""
- connection_attempt_metadata {
- technology: CONNECTION_TECHNOLOGY_HOTSPOT_LOCALONLY
- band: CONNECTION_BAND_WIFI_BAND_6GHZ
- frequency: 2400
- network_operator: ""
- country_code: ""
- is_tdls_used: false
- try_counts: 0
- wifi_hotspot_status: false
- max_tx_speed: 0
- max_rx_speed: 0
- wifi_channel_width: 0
- }
- operation_result {
- result_category: CATEGORY_CONNECTIVITY_ERROR
- result_code: CONNECTIVITY_BT_CLIENT_SOCKET_CREATION_FAILURE
- }
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto));
-}
-
-TEST_F(AnalyticsRecorderTest,
- UnfinishedEstablishedConnectionsAddedAsUnfinished) {
- std::string endpoint_id = "endpoint_id";
- std::string connection_token = "connection_token";
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- auto advertising_metadata_params =
- analytics_recorder.BuildAdvertisingMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar,
- /*mediums=*/{BLE, BLUETOOTH},
- advertising_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnConnectionEstablished(endpoint_id, BLUETOOTH,
- connection_token);
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.OnConnectionClosed(
- endpoint_id, BLUETOOTH, UPGRADED,
- ConnectionsLog::EstablishedConnection::UNKNOWN_SAFE_DISCONNECTION_RESULT);
- GetFakeClock().FastForward(absl::Milliseconds(400));
- analytics_recorder.OnConnectionEstablished(endpoint_id, WIFI_LAN,
- connection_token);
- GetFakeClock().FastForward(absl::Milliseconds(500));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 1500
- strategy_session {
- duration_millis: 1400
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 1400
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: FINISH_SESSION_STOP_ADVERTISING
- }
- established_connection {
- duration_millis: 300
- medium: BLUETOOTH
- disconnection_reason: UPGRADED
- connection_token: "connection_token"
- safe_disconnection_result: UNKNOWN_SAFE_DISCONNECTION_RESULT
- operation_result {
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- }
- established_connection {
- duration_millis: 500
- medium: WIFI_LAN
- disconnection_reason: UNFINISHED
- connection_token: "connection_token"
- safe_disconnection_result: SAFE_DISCONNECTION
- operation_result {
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto));
-}
-
-TEST_F(AnalyticsRecorderTest, OutgoingPayloadUpgraded) {
- std::string endpoint_id = "endpoint_id";
- std::int64_t payload_id = 123456789;
- std::string connection_token = "connection_token";
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- auto advertising_metadata_params =
- analytics_recorder.BuildAdvertisingMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar,
- /*mediums=*/{BLE, BLUETOOTH},
- advertising_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnConnectionEstablished(endpoint_id, BLUETOOTH,
- connection_token);
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.OnOutgoingPayloadStarted(
- {endpoint_id}, payload_id, connections::PayloadType::kFile, 50);
- GetFakeClock().FastForward(absl::Milliseconds(400));
- analytics_recorder.OnPayloadChunkSent(endpoint_id, payload_id, 10);
- GetFakeClock().FastForward(absl::Milliseconds(500));
- analytics_recorder.OnPayloadChunkSent(endpoint_id, payload_id, 10);
- GetFakeClock().FastForward(absl::Milliseconds(600));
- analytics_recorder.OnConnectionClosed(
- endpoint_id, BLUETOOTH, UPGRADED,
- ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
- GetFakeClock().FastForward(absl::Milliseconds(700));
- analytics_recorder.OnConnectionEstablished(endpoint_id, WIFI_LAN,
- connection_token);
- GetFakeClock().FastForward(absl::Milliseconds(800));
- analytics_recorder.OnPayloadChunkSent(endpoint_id, payload_id, 10);
- GetFakeClock().FastForward(absl::Milliseconds(900));
- analytics_recorder.OnPayloadChunkSent(endpoint_id, payload_id, 10);
- GetFakeClock().FastForward(absl::Milliseconds(1000));
- analytics_recorder.OnPayloadChunkSent(endpoint_id, payload_id, 10);
- GetFakeClock().FastForward(absl::Milliseconds(1100));
- analytics_recorder.OnOutgoingPayloadDone(endpoint_id, payload_id, SUCCESS,
- OperationResultCode::DETAIL_SUCCESS);
- GetFakeClock().FastForward(absl::Milliseconds(1200));
- analytics_recorder.OnConnectionClosed(
- endpoint_id, WIFI_LAN, LOCAL_DISCONNECTION,
- ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
- GetFakeClock().FastForward(absl::Milliseconds(1300));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 9100
- strategy_session {
- duration_millis: 9000
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 9000
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: FINISH_SESSION_STOP_ADVERTISING
- }
- established_connection {
- duration_millis: 1800
- medium: BLUETOOTH
- sent_payload {
- duration_millis: 1500
- type: FILE
- total_size_bytes: 50
- num_bytes_transferred: 20
- num_chunks: 2
- status: MOVED_TO_NEW_MEDIUM
- operation_result {
- result_category: CATEGORY_MISCELLANEOUS
- result_code: MISCELLEANEOUS_MOVE_TO_NEW_MEDIUM
- }
- }
- disconnection_reason: UPGRADED
- connection_token: "connection_token"
- safe_disconnection_result: SAFE_DISCONNECTION
- operation_result {
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- }
- established_connection {
- duration_millis: 5000
- medium: WIFI_LAN
- sent_payload {
- duration_millis: 4500
- type: FILE
- total_size_bytes: 50
- num_bytes_transferred: 30
- num_chunks: 3
- status: SUCCESS
- operation_result {
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- }
- disconnection_reason: LOCAL_DISCONNECTION
- connection_token: "connection_token"
- safe_disconnection_result: SAFE_DISCONNECTION
- operation_result {
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto));
-}
-
-TEST_F(AnalyticsRecorderTest, UpgradeAttemptWorks) {
- std::string endpoint_id = "endpoint_id";
- std::string endpoint_id_1 = "endpoint_id_1";
- std::string endpoint_id_2 = "endpoint_id_2";
- std::string connection_token = "connection_token";
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- auto advertising_metadata_params =
- analytics_recorder.BuildAdvertisingMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar,
- /*mediums=*/{BLE, BLUETOOTH},
- advertising_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(200));
-
- analytics_recorder.OnBandwidthUpgradeStarted(endpoint_id, BLE, WIFI_LAN,
- INCOMING, connection_token);
- GetFakeClock().FastForward(absl::Milliseconds(300));
-
- analytics_recorder.OnBandwidthUpgradeStarted(
- endpoint_id_1, BLUETOOTH, WIFI_LAN, INCOMING, connection_token);
- // Error to upgrade.
- GetFakeClock().FastForward(absl::Milliseconds(400));
- analytics_recorder.OnBandwidthUpgradeError(
- endpoint_id, WIFI_LAN_MEDIUM_ERROR, WIFI_LAN_SOCKET_CREATION,
- OperationResultCode::CONNECTIVITY_WIFI_LAN_INVALID_CREDENTIAL);
- // Success to upgrade.
- GetFakeClock().FastForward(absl::Milliseconds(500));
- analytics_recorder.OnBandwidthUpgradeSuccess(endpoint_id_1);
- // Upgrade is unfinished.
- GetFakeClock().FastForward(absl::Milliseconds(600));
- analytics_recorder.OnBandwidthUpgradeStarted(
- endpoint_id_2, BLUETOOTH, WIFI_LAN, INCOMING, connection_token);
- GetFakeClock().FastForward(absl::Milliseconds(700));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 2800
- strategy_session {
- duration_millis: 2700
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 2700
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: FINISH_SESSION_STOP_ADVERTISING
- }
- upgrade_attempt {
- duration_millis: 700
- direction: INCOMING
- from_medium: BLE
- to_medium: WIFI_LAN
- upgrade_result: WIFI_LAN_MEDIUM_ERROR
- error_stage: WIFI_LAN_SOCKET_CREATION
- connection_token: "connection_token"
- operation_result {
- result_category: CATEGORY_CONNECTIVITY_ERROR
- result_code: CONNECTIVITY_WIFI_LAN_INVALID_CREDENTIAL
- }
- }
- upgrade_attempt {
- duration_millis: 900
- direction: INCOMING
- from_medium: BLUETOOTH
- to_medium: WIFI_LAN
- upgrade_result: UPGRADE_RESULT_SUCCESS
- error_stage: UPGRADE_SUCCESS
- connection_token: "connection_token"
- operation_result {
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- }
- upgrade_attempt {
- duration_millis: 700
- direction: INCOMING
- from_medium: BLUETOOTH
- to_medium: WIFI_LAN
- upgrade_result: UNFINISHED_ERROR
- error_stage: UPGRADE_UNFINISHED
- connection_token: "connection_token"
- operation_result {
- result_category: CATEGORY_DEVICE_STATE_ERROR
- result_code: DEVICE_STATE_ERROR_UNFINISHED_UPGRADE_ATTEMPTS
- }
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto));
-}
-
-TEST_F(AnalyticsRecorderTest, StartListeningForIncomingConnectionsWorks) {
- std::string endpoint_id = "endpoint_id";
- std::string endpoint_id_1 = "endpoint_id_1";
- std::string endpoint_id_2 = "endpoint_id_2";
- std::string connection_token = "connection_token";
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartedIncomingConnectionListening(
- connections::Strategy::kP2pStar);
- GetFakeClock().FastForward(absl::Milliseconds(200));
-
- analytics_recorder.OnBandwidthUpgradeStarted(endpoint_id, BLE, WIFI_LAN,
- INCOMING, connection_token);
-
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.OnBandwidthUpgradeStarted(
- endpoint_id_1, BLUETOOTH, WIFI_LAN, INCOMING, connection_token);
- GetFakeClock().FastForward(absl::Milliseconds(400));
- // Error to upgrade.
- analytics_recorder.OnBandwidthUpgradeError(
- endpoint_id, WIFI_LAN_MEDIUM_ERROR, WIFI_LAN_SOCKET_CREATION,
- OperationResultCode::CONNECTIVITY_WIFI_LAN_INVALID_CREDENTIAL);
- GetFakeClock().FastForward(absl::Milliseconds(500));
- // Success to upgrade.
- analytics_recorder.OnBandwidthUpgradeSuccess(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(600));
-
- analytics_recorder.LogSession();
- // ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 2100
- strategy_session {
- duration_millis: 2000
- strategy: P2P_STAR
- role: ADVERTISER
- upgrade_attempt {
- direction: INCOMING
- duration_millis: 700
- from_medium: BLE
- to_medium: WIFI_LAN
- upgrade_result: WIFI_LAN_MEDIUM_ERROR
- error_stage: WIFI_LAN_SOCKET_CREATION
- connection_token: "connection_token"
- operation_result {
- result_category: CATEGORY_CONNECTIVITY_ERROR
- result_code: CONNECTIVITY_WIFI_LAN_INVALID_CREDENTIAL
- }
- }
- upgrade_attempt {
- direction: INCOMING
- duration_millis: 900
- from_medium: BLUETOOTH
- to_medium: WIFI_LAN
- upgrade_result: UPGRADE_RESULT_SUCCESS
- error_stage: UPGRADE_SUCCESS
- connection_token: "connection_token"
- operation_result {
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto));
-}
-
-TEST_F(AnalyticsRecorderTest, SetErrorCodeFieldsCorrectly) {
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- auto discovery_metadata_params =
- analytics_recorder.BuildDiscoveryMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartDiscovery(connections::Strategy::kP2pStar,
- /*mediums=*/{WEB_RTC},
- discovery_metadata_params.get());
-
- ErrorCodeParams error_code_params = ErrorCodeRecorder::BuildErrorCodeParams(
- WEB_RTC, DISCONNECT, DISCONNECT_NETWORK_FAILED,
- TACHYON_SEND_MESSAGE_STATUS_EXCEPTION, "", "connection_token");
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnErrorCode(error_code_params);
- GetFakeClock().FastForward(absl::Milliseconds(300));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ErrorCode error_code_proto = ParseTextProtoOrDie(R"pb(
- medium: WEB_RTC
- event: DISCONNECT
- description: TACHYON_SEND_MESSAGE_STATUS_EXCEPTION
- disconnect_error: DISCONNECT_NETWORK_FAILED
- connection_token: "connection_token"
- )pb");
-
- EXPECT_THAT(event_logger.GetErrorCode(), EqualsProto(error_code_proto));
-}
-
-TEST_F(AnalyticsRecorderTest,
- SetErrorCodeFieldsCorrectlyForUnknownDescription) {
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- auto discovery_metadata_params =
- analytics_recorder.BuildDiscoveryMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartDiscovery(connections::Strategy::kP2pStar,
- /*mediums=*/{BLUETOOTH},
- discovery_metadata_params.get());
-
- ErrorCodeParams error_code_params;
- // Skip setting error_code_params.description
- error_code_params.medium = BLUETOOTH;
- error_code_params.event = START_DISCOVERING;
- error_code_params.start_discovering_error = START_EXTENDED_DISCOVERING_FAILED;
- error_code_params.connection_token = "connection_token";
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnErrorCode(error_code_params);
- GetFakeClock().FastForward(absl::Milliseconds(300));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ErrorCode error_code_proto = ParseTextProtoOrDie(R"pb(
- medium: BLUETOOTH
- event: START_DISCOVERING
- description: UNKNOWN
- start_discovering_error: START_EXTENDED_DISCOVERING_FAILED
- connection_token: "connection_token"
- )pb");
-
- EXPECT_THAT(event_logger.GetErrorCode(), EqualsProto(error_code_proto));
-}
-
-TEST_F(AnalyticsRecorderTest, SetErrorCodeFieldsCorrectlyForCommonError) {
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- auto discovery_metadata_params =
- analytics_recorder.BuildDiscoveryMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartDiscovery(connections::Strategy::kP2pStar,
- /*mediums=*/{BLUETOOTH},
- discovery_metadata_params.get());
-
- ErrorCodeParams error_code_params = ErrorCodeRecorder::BuildErrorCodeParams(
- BLUETOOTH, START_DISCOVERING, INVALID_PARAMETER,
- NULL_BLUETOOTH_DEVICE_NAME, "", "connection_token");
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnErrorCode(error_code_params);
- GetFakeClock().FastForward(absl::Milliseconds(300));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ErrorCode error_code_proto = ParseTextProtoOrDie(R"pb(
- medium: BLUETOOTH
- event: START_DISCOVERING
- description: NULL_BLUETOOTH_DEVICE_NAME
- common_error: INVALID_PARAMETER
- connection_token: "connection_token"
- )pb");
-
- EXPECT_THAT(event_logger.GetErrorCode(), EqualsProto(error_code_proto));
-}
-
-TEST_F(AnalyticsRecorderTest, CheckIfSessionWasLogged) {
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- GetFakeClock().FastForward(absl::Milliseconds(100));
- // LogSession to count down client_session_done_latch.
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- EXPECT_TRUE(analytics_recorder.IsSessionLogged());
-}
-
-TEST_F(AnalyticsRecorderTest, ConstructAnalyticsRecorder) {
- CountDownLatch client_session_done_latch(0);
- CountDownLatch start_client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch,
- &start_client_session_done_latch);
-
- // Call the constructor to count down the session_done_latch.
- AnalyticsRecorder analytics_recorder(&event_logger);
- ASSERT_TRUE(start_client_session_done_latch.Await(kDefaultTimeout).result());
-
- std::vector event_types = event_logger.GetLoggedEventTypes();
- EXPECT_EQ(event_types.size(), 1);
- EXPECT_THAT(event_types, Contains(START_CLIENT_SESSION).Times(1));
-}
-
-TEST_F(
- AnalyticsRecorderTest,
- StartClientSessionOnlyLoggedOnceWorksAfterAnalyticsRecorderIsConstructed) {
- CountDownLatch client_session_done_latch(0);
- CountDownLatch start_client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch,
- &start_client_session_done_latch);
-
- // Call the constructor to count down the start_client_session_done_latch.
- AnalyticsRecorder analytics_recorder(&event_logger);
- ASSERT_TRUE(start_client_session_done_latch.Await(kDefaultTimeout).result());
-
- // Log start client session once.
- EXPECT_THAT(event_logger.GetLoggedEventTypes(),
- Contains(START_CLIENT_SESSION).Times(1));
-
- // Reset the start_client_session_done_latch. However, LogStartSession cannot
- // count down the start_client_session_done_latch.
- CountDownLatch new_start_client_session_done_latch(1);
- event_logger.SetStartClientSessionDoneLatchPtr(
- &new_start_client_session_done_latch);
- analytics_recorder.LogStartSession();
- ASSERT_FALSE(
- new_start_client_session_done_latch.Await(kDefaultTimeout).result());
-
- // No more start client session was logged.
- EXPECT_THAT(event_logger.GetLoggedEventTypes(),
- Contains(START_CLIENT_SESSION).Times(1));
-}
-
-TEST_F(AnalyticsRecorderTest,
- CanLogStartClientSessionOnceAgainAfterSessionWasLogged) {
- CountDownLatch client_session_done_latch(0);
- CountDownLatch start_client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch,
- &start_client_session_done_latch);
-
- // Call the constructor to count down the start_client_session_done_latch.
- AnalyticsRecorder analytics_recorder(&event_logger);
- ASSERT_TRUE(start_client_session_done_latch.Await(kDefaultTimeout).result());
-
- // Log start client session once.
- EXPECT_THAT(event_logger.GetLoggedEventTypes(),
- Contains(START_CLIENT_SESSION).Times(1));
-
- // Reset the client_session_done_latch. Call LogSession to count down the
- // client_session_done_latch.
- CountDownLatch new_client_session_done_latch(1);
- event_logger.SetClientSessionDoneLatch(new_client_session_done_latch);
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- // Reset the start_client_session_done_latch. Call LogStartSession to count
- // down the start_client_session_done_latch.
- CountDownLatch new_start_client_session_done_latch(1);
- event_logger.SetStartClientSessionDoneLatchPtr(
- &new_start_client_session_done_latch);
- analytics_recorder.LogStartSession();
- analytics_recorder.LogStartSession();
- analytics_recorder.LogStartSession();
- analytics_recorder.LogStartSession();
- ASSERT_TRUE(
- new_start_client_session_done_latch.Await(kDefaultTimeout).result());
-
- // Can log start client session once again.
- EXPECT_THAT(event_logger.GetLoggedEventTypes(),
- Contains(START_CLIENT_SESSION).Times(2));
-}
-
-TEST_F(AnalyticsRecorderTest,
- ClearcIncomingConnectionRequestsAfterSessionWasLogged) {
- std::string endpoint_id_0 = "endpoint_id_0";
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- auto advertising_metadata_params =
- analytics_recorder.BuildAdvertisingMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar,
- /*mediums=*/{BLE, BLUETOOTH},
- advertising_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnConnectionRequestReceived(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.OnLocalEndpointAccepted(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(400));
- analytics_recorder.OnRemoteEndpointAccepted(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(500));
-
- // LogSession
- analytics_recorder.LogSession(); // call ResetClientSessionLoggingResouces
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto1 =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 1500
- strategy_session {
- duration_millis: 1400
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 1400
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: FINISH_SESSION_STOP_ADVERTISING
- received_connection_request {
- duration_millis: 700
- request_delay_millis: 200
- local_response: ACCEPTED
- remote_response: ACCEPTED
- }
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto1));
-
- // LogStartSession
- CountDownLatch new_start_client_session_done_latch(1);
- event_logger.SetStartClientSessionDoneLatchPtr(
- &new_start_client_session_done_latch);
- GetFakeClock().FastForward(absl::Milliseconds(600));
- analytics_recorder.LogStartSession();
- ASSERT_TRUE(
- new_start_client_session_done_latch.Await(kDefaultTimeout).result());
-
- // LogSession again
- CountDownLatch new_client_session_done_latch(1);
- event_logger.SetClientSessionDoneLatch(new_client_session_done_latch);
- std::string endpoint_id_1 = "endpoint_id_1";
- GetFakeClock().FastForward(absl::Milliseconds(700));
- analytics_recorder.OnConnectionRequestReceived(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(800));
- analytics_recorder.OnLocalEndpointAccepted(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(900));
- analytics_recorder.OnRemoteEndpointAccepted(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(1000));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(new_client_session_done_latch.Await(kDefaultTimeout).result());
-
- // - if the current_strategy_session_ and current_advertising_phase_ are not
- // reset, the duplicate advertising_phase (with the additional
- // received_connection_request) will append to the strategy_session)
- ConnectionsLog::ClientSession strategy_session_proto2 = ParseTextProtoOrDie(
- R"pb(
- duration_millis: 0
- strategy_session {
- duration_millis: 0
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 0
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- received_connection_request {
- duration_millis: 0
- request_delay_millis: 0
- local_response: ACCEPTED
- remote_response: ACCEPTED
- }
- }
- advertising_phase {
- duration_millis: 0
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- received_connection_request {
- duration_millis: 0
- request_delay_millis: 0
- local_response: ACCEPTED
- remote_response: ACCEPTED
- }
- received_connection_request {
- duration_millis: 0
- request_delay_millis: 0
- local_response: ACCEPTED
- remote_response: ACCEPTED
- }
- }
- })pb");
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- Not(EqualsProto(strategy_session_proto2)));
-}
-
-TEST_F(AnalyticsRecorderTest,
- ClearcOutgoingConnectionRequestsAfterSessionWasLogged) {
- std::string endpoint_id_0 = "endpoint_id_0";
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- auto discovery_metadata_params =
- analytics_recorder.BuildDiscoveryMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartDiscovery(connections::Strategy::kP2pStar,
- /*mediums=*/{BLE, BLUETOOTH},
- discovery_metadata_params.get());
-
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnConnectionRequestSent(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.OnLocalEndpointAccepted(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(400));
- analytics_recorder.OnRemoteEndpointAccepted(endpoint_id_0);
- GetFakeClock().FastForward(absl::Milliseconds(500));
-
- // LogSession
- analytics_recorder.LogSession(); // call ResetClientSessionLoggingResouces
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto1 =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 1500
- strategy_session {
- duration_millis: 1400
- strategy: P2P_STAR
- role: DISCOVERER
- discovery_phase {
- duration_millis: 1400
- medium: BLE
- medium: BLUETOOTH
- discovery_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: FINISH_SESSION_STOP_DISCOVERING
- sent_connection_request {
- duration_millis: 700
- request_delay_millis: 200
- local_response: ACCEPTED
- remote_response: ACCEPTED
- }
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto1));
-
- // LogStartSession
- CountDownLatch new_start_client_session_done_latch(1);
- event_logger.SetStartClientSessionDoneLatchPtr(
- &new_start_client_session_done_latch);
- analytics_recorder.LogStartSession();
- ASSERT_TRUE(
- new_start_client_session_done_latch.Await(kDefaultTimeout).result());
-
- // LogSession again
- CountDownLatch new_client_session_done_latch(1);
- event_logger.SetClientSessionDoneLatch(new_client_session_done_latch);
- std::string endpoint_id_1 = "endpoint_id_1";
- GetFakeClock().FastForward(absl::Milliseconds(600));
- analytics_recorder.OnConnectionRequestSent(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(700));
- analytics_recorder.OnLocalEndpointAccepted(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(800));
- analytics_recorder.OnRemoteEndpointAccepted(endpoint_id_1);
- GetFakeClock().FastForward(absl::Milliseconds(900));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- // - if the current_strategy_session_ and current_discovery_phase_ are
- // not reset, the duplicate discovery_phase (with the additional
- // sent_connection_request) will append to the strategy_session)
- ConnectionsLog::ClientSession strategy_session_proto2 =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 0
- strategy_session {
- duration_millis: 0
- strategy: P2P_STAR
- role: DISCOVERER
- discovery_phase {
- duration_millis: 0
- medium: BLE
- medium: BLUETOOTH
- discovery_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- sent_connection_request {
- duration_millis: 0
- request_delay_millis: 0
- local_response: ACCEPTED
- remote_response: ACCEPTED
- }
- }
- discovery_phase {
- duration_millis: 0
- medium: BLE
- medium: BLUETOOTH
- discovery_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- sent_connection_request {
- duration_millis: 0
- request_delay_millis: 0
- local_response: ACCEPTED
- remote_response: ACCEPTED
- }
- sent_connection_request {
- duration_millis: 0
- request_delay_millis: 0
- local_response: ACCEPTED
- remote_response: ACCEPTED
- }
- }
- })pb");
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- Not(EqualsProto(strategy_session_proto2)));
-}
-
-TEST_F(AnalyticsRecorderTest, ClearcActiveConnectionsAfterSessionWasLogged) {
- connections::Strategy strategy = connections::Strategy::kP2pStar;
- std::vector mediums = {BLE, BLUETOOTH};
- std::string endpoint_id = "endpoint_id";
- std::string connection_token = "connection_token";
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- auto advertising_metadata_params =
- analytics_recorder.BuildAdvertisingMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartAdvertising(strategy, mediums,
- advertising_metadata_params.get());
-
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnConnectionEstablished(endpoint_id, BLUETOOTH,
- connection_token);
- GetFakeClock().FastForward(absl::Milliseconds(300));
-
- // LogSession
- analytics_recorder.LogSession(); // call ResetClientSessionLoggingResouces
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
- ConnectionsLog::ClientSession strategy_session_proto1 =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 600
- strategy_session {
- duration_millis: 500
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 500
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: FINISH_SESSION_STOP_ADVERTISING
- }
- established_connection {
- duration_millis: 300
- medium: BLUETOOTH
- disconnection_reason: UNFINISHED
- connection_token: "connection_token"
- safe_disconnection_result: SAFE_DISCONNECTION
- operation_result {
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto1));
-
- // LogStartSession
- CountDownLatch new_start_client_session_done_latch(1);
- event_logger.SetStartClientSessionDoneLatchPtr(
- &new_start_client_session_done_latch);
- GetFakeClock().FastForward(absl::Milliseconds(400));
- analytics_recorder.LogStartSession();
- ASSERT_TRUE(
- new_start_client_session_done_latch.Await(kDefaultTimeout).result());
-
- // LogSession again
- CountDownLatch new_client_session_done_latch(1);
- event_logger.SetClientSessionDoneLatch(new_client_session_done_latch);
- GetFakeClock().FastForward(absl::Milliseconds(500));
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- // - if the current_strategy_session_ and advertising_phase_ are not
- // reset, the duplicate advertising_phase_ (with the additional
- // will append to the strategy_session), and the active connection (i.e.
- // established_connection) will stay there.
- ConnectionsLog::ClientSession strategy_session_proto2 =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 0
- strategy_session {
- duration_millis: 0
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 0
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- }
- advertising_phase {
- duration_millis: 0
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- }
- established_connection {
- duration_millis: 0
- medium: BLUETOOTH
- disconnection_reason: UNFINISHED
- connection_token: "connection_token"
- safe_disconnection_result: SAFE_DISCONNECTION
- operation_result {
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- Not(EqualsProto(strategy_session_proto2)));
-}
-
-TEST_F(AnalyticsRecorderTest,
- ClearBandwidthUpgradeAttemptsAfterSessionWasLogged) {
- std::string endpoint_id = "endpoint_id";
- std::string endpoint_id_1 = "endpoint_id_1";
- std::string endpoint_id_2 = "endpoint_id_2";
- std::string connection_token = "connection_token";
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- auto advertising_metadata_params =
- analytics_recorder.BuildAdvertisingMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar,
- /*mediums=*/{BLE, BLUETOOTH},
- advertising_metadata_params.get());
-
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnBandwidthUpgradeStarted(endpoint_id, BLE, WIFI_LAN,
- INCOMING, connection_token);
-
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.OnBandwidthUpgradeStarted(
- endpoint_id_1, BLUETOOTH, WIFI_LAN, INCOMING, connection_token);
- // - Error to upgrade.
- GetFakeClock().FastForward(absl::Milliseconds(400));
- analytics_recorder.OnBandwidthUpgradeError(
- endpoint_id, WIFI_LAN_MEDIUM_ERROR, WIFI_LAN_SOCKET_CREATION,
- OperationResultCode::CONNECTIVITY_WIFI_LAN_INVALID_CREDENTIAL);
- // - Success to upgrade.
- GetFakeClock().FastForward(absl::Milliseconds(500));
- analytics_recorder.OnBandwidthUpgradeSuccess(endpoint_id_1);
-
- // - Upgrade is unfinished.
- GetFakeClock().FastForward(absl::Milliseconds(600));
- analytics_recorder.OnBandwidthUpgradeStarted(
- endpoint_id_2, BLUETOOTH, WIFI_LAN, INCOMING, connection_token);
-
- GetFakeClock().FastForward(absl::Milliseconds(700));
- // LogSession
- analytics_recorder.LogSession(); // call ResetClientSessionLoggingResouces
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- // - if the current_strategy_session_ and advertising_phase_ are not
- // reset, the duplicate advertising_phase_, and the upgrade_attempts (i.e.
- // bandwidth_upgrade_attempts_) will stay there.
- ConnectionsLog::ClientSession strategy_session_proto1 =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 2800
- strategy_session {
- duration_millis: 2700
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 2700
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: FINISH_SESSION_STOP_ADVERTISING
- }
- upgrade_attempt {
- direction: INCOMING
- duration_millis: 700
- from_medium: BLE
- to_medium: WIFI_LAN
- upgrade_result: WIFI_LAN_MEDIUM_ERROR
- error_stage: WIFI_LAN_SOCKET_CREATION
- connection_token: "connection_token"
- operation_result {
- result_category: CATEGORY_CONNECTIVITY_ERROR
- result_code: CONNECTIVITY_WIFI_LAN_INVALID_CREDENTIAL
- }
- }
- upgrade_attempt {
- direction: INCOMING
- duration_millis: 900
- from_medium: BLUETOOTH
- to_medium: WIFI_LAN
- upgrade_result: UPGRADE_RESULT_SUCCESS
- error_stage: UPGRADE_SUCCESS
- connection_token: "connection_token"
- operation_result {
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- }
- upgrade_attempt {
- direction: INCOMING
- duration_millis: 700
- from_medium: BLUETOOTH
- to_medium: WIFI_LAN
- upgrade_result: UNFINISHED_ERROR
- error_stage: UPGRADE_UNFINISHED
- connection_token: "connection_token"
- operation_result {
- result_category: CATEGORY_DEVICE_STATE_ERROR
- result_code: DEVICE_STATE_ERROR_UNFINISHED_UPGRADE_ATTEMPTS
- }
- }
- })pb");
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto1));
-
- // LogStartSession
- CountDownLatch new_start_client_session_done_latch(1);
- event_logger.SetStartClientSessionDoneLatchPtr(
- &new_start_client_session_done_latch);
- GetFakeClock().FastForward(absl::Milliseconds(800));
- analytics_recorder.LogStartSession();
- ASSERT_TRUE(
- new_start_client_session_done_latch.Await(kDefaultTimeout).result());
-
- // LogSession again
- CountDownLatch new_client_session_done_latch(1);
- event_logger.SetClientSessionDoneLatch(new_client_session_done_latch);
- GetFakeClock().FastForward(absl::Milliseconds(900));
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto2 =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 0
- strategy_session {
- duration_millis: 0
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 0
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- }
- advertising_phase {
- duration_millis: 0
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- }
- upgrade_attempt {
- direction: INCOMING
- from_medium: BLE
- to_medium: WIFI_LAN
- upgrade_result: WIFI_LAN_MEDIUM_ERROR
- error_stage: WIFI_LAN_SOCKET_CREATION
- connection_token: "connection_token"
- operation_result {
- result_category: CATEGORY_CONNECTIVITY_ERROR
- result_code: CONNECTIVITY_WIFI_LAN_INVALID_CREDENTIAL
- }
- }
- upgrade_attempt {
- direction: INCOMING
- from_medium: BLUETOOTH
- to_medium: WIFI_LAN
- upgrade_result: UPGRADE_RESULT_SUCCESS
- error_stage: UPGRADE_SUCCESS
- connection_token: "connection_token"
- operation_result {
- result_category: CATEGORY_SUCCESS
- result_code: DETAIL_SUCCESS
- }
- }
- upgrade_attempt {
- direction: INCOMING
- from_medium: BLUETOOTH
- to_medium: WIFI_LAN
- upgrade_result: UNFINISHED_ERROR
- error_stage: UPGRADE_UNFINISHED
- connection_token: "connection_token"
- operation_result {
- result_category: CATEGORY_DEVICE_STATE_ERROR
- result_code: DEVICE_STATE_ERROR_UNFINISHED_UPGRADE_ATTEMPTS
- }
- }
- })pb");
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- Not(EqualsProto(strategy_session_proto2)));
-}
-
-// Test if current_strategy_ is reset by checking if the same strategy would
-// be logged for different client sessions or not. If yes, it should be logged.
-// Otherwise, not.
-TEST_F(AnalyticsRecorderTest,
- CanLogSeparateStartStrategySessionForSameStrategyAfterSessionWasLogged) {
- connections::Strategy strategy = connections::Strategy::kP2pStar;
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- auto advertising_metadata_params =
- analytics_recorder.BuildAdvertisingMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar,
- /*mediums=*/{BLUETOOTH},
- advertising_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnStopAdvertising();
-
- GetFakeClock().FastForward(absl::Milliseconds(300));
- // LogSession
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- // The same strategy session shouldn't be logged again with the same client
- // session.
- EXPECT_THAT(event_logger.GetLoggedEventTypes(),
- Contains(START_STRATEGY_SESSION).Times(1));
-
- // LogStartSession
- CountDownLatch new_start_client_session_done_latch(1);
- event_logger.SetStartClientSessionDoneLatchPtr(
- &new_start_client_session_done_latch);
- GetFakeClock().FastForward(absl::Milliseconds(400));
- analytics_recorder.LogStartSession();
- ASSERT_TRUE(
- new_start_client_session_done_latch.Await(kDefaultTimeout).result());
-
- // LogSession again
- CountDownLatch new_client_session_done_latch(1);
- event_logger.SetClientSessionDoneLatch(new_client_session_done_latch);
-
- GetFakeClock().FastForward(absl::Milliseconds(500));
- analytics_recorder.OnStartAdvertising(strategy, /*mediums=*/{BLUETOOTH},
- advertising_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(600));
- analytics_recorder.OnStopAdvertising();
- GetFakeClock().FastForward(absl::Milliseconds(700));
-
- analytics_recorder.LogSession();
- ASSERT_TRUE(new_client_session_done_latch.Await(kDefaultTimeout).result());
-
- EXPECT_THAT(event_logger.GetLoggedEventTypes(),
- Contains(START_STRATEGY_SESSION).Times(2));
-}
-
-// Test if current_strategy_session_ is reset. If not, the same strategy session
-// proto will be logged.
-TEST_F(AnalyticsRecorderTest,
- NotLogSameStrategySessionProtoAfterSessionWasLogged) {
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- // Via OnStartAdvertising, current_strategy_session_is set in
- // UpdateStrategySessionLocked.
- auto advertising_metadata_params =
- analytics_recorder.BuildAdvertisingMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar,
- /*mediums=*/{BLE, BLUETOOTH},
- advertising_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnStopAdvertising();
- GetFakeClock().FastForward(absl::Milliseconds(300));
- // LogSession
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 600
- strategy_session {
- duration_millis: 500
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 200
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: CLIENT_STOP_ADVERTISING
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto));
-
- // LogStartSession
- CountDownLatch new_start_client_session_done_latch(1);
- event_logger.SetStartClientSessionDoneLatchPtr(
- &new_start_client_session_done_latch);
- GetFakeClock().FastForward(absl::Milliseconds(400));
- analytics_recorder.LogStartSession();
- ASSERT_TRUE(
- new_start_client_session_done_latch.Await(kDefaultTimeout).result());
-
- // LogSession again
- // - if current_strategy_session_ is reset, the same
- // strategy_session_proto will be logged.
- CountDownLatch new_client_session_done_latch(1);
- event_logger.SetClientSessionDoneLatch(new_client_session_done_latch);
- GetFakeClock().FastForward(absl::Milliseconds(500));
- analytics_recorder.LogSession();
- ASSERT_TRUE(new_client_session_done_latch.Await(kDefaultTimeout).result());
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- Not(EqualsProto(strategy_session_proto)));
-}
-
-// Test if current_advertising_phase_ is reset.
-TEST_F(AnalyticsRecorderTest,
- NotLogDuplicateAdvertisingPhaseAfterSessionWasLogged) {
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- auto advertising_metadata_params =
- analytics_recorder.BuildAdvertisingMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartAdvertising(
- connections::Strategy::kP2pStar,
- /*mediums=*/{BLUETOOTH},
- advertising_metadata_params.get()); // set current_advertising_phase_
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnStopAdvertising();
- GetFakeClock().FastForward(absl::Milliseconds(300));
-
- // LogSession
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto1 =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 600
- strategy_session {
- duration_millis: 500
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 200
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: CLIENT_STOP_ADVERTISING
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto1));
-
- // LogStartSession
- CountDownLatch new_start_client_session_done_latch(1);
- event_logger.SetStartClientSessionDoneLatchPtr(
- &new_start_client_session_done_latch);
- GetFakeClock().FastForward(absl::Milliseconds(400));
- analytics_recorder.LogStartSession();
- ASSERT_TRUE(
- new_start_client_session_done_latch.Await(kDefaultTimeout).result());
-
- // LogSession again
- // - if the current_strategy_session_ and current_advertising_phase_ are
- // not reset, the same strategy_session with two same advertising_phase will
- // be logged.
- CountDownLatch new_client_session_done_latch(1);
- event_logger.SetClientSessionDoneLatch(new_client_session_done_latch);
- GetFakeClock().FastForward(absl::Milliseconds(500));
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto2 =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 0
- strategy_session {
- duration_millis: 0
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 0
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- }
- advertising_phase {
- duration_millis: 0
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- }
- })pb");
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- Not(EqualsProto(strategy_session_proto2)));
-}
-
-// Test if current_discovery_phase_ is reset.
-TEST_F(AnalyticsRecorderTest,
- NotLogDuplicateDiscoveryPhaseAfterSessionWasLogged) {
- connections::Strategy strategy = connections::Strategy::kP2pStar;
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- auto discovery_metadata_params =
- analytics_recorder.BuildDiscoveryMetadataParams(
- /*is_extended_advertisement_supported*/ true,
- /*connected_ap_frequency*/ 1, /*is_nfc_available=*/false);
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartDiscovery(
- strategy, {BLUETOOTH},
- discovery_metadata_params.get()); // set current_discovery_phase_
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnStopDiscovery();
- GetFakeClock().FastForward(absl::Milliseconds(300));
- analytics_recorder.OnEndpointFound(BLUETOOTH);
- GetFakeClock().FastForward(absl::Milliseconds(400));
- // LogSession
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto1 =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 1000
- strategy_session {
- duration_millis: 900
- strategy: P2P_STAR
- role: DISCOVERER
- discovery_phase {
- duration_millis: 200
- medium: BLUETOOTH
- discovered_endpoint {
- medium: BLUETOOTH
- latency_millis: 500
- }
- discovery_metadata {
- supports_extended_ble_advertisements: true
- connected_ap_frequency: 1
- supports_nfc_technology: false
- }
- stop_reason: CLIENT_STOP_DISCOVERING
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto1));
-
- // LogStartSession
- CountDownLatch new_start_client_session_done_latch(1);
- event_logger.SetStartClientSessionDoneLatchPtr(
- &new_start_client_session_done_latch);
- GetFakeClock().FastForward(absl::Milliseconds(500));
- analytics_recorder.LogStartSession();
- ASSERT_TRUE(
- new_start_client_session_done_latch.Await(kDefaultTimeout).result());
-
- // LogSession again
- // - if the current_strategy_session_ and current_discovery_phase_ are not
- // reset, the same strategy_session with two same discovery_phase will be
- // logged.
- CountDownLatch new_client_session_done_latch(1);
- event_logger.SetClientSessionDoneLatch(new_client_session_done_latch);
- GetFakeClock().FastForward(absl::Milliseconds(600));
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto2 =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 0
- strategy_session {
- duration_millis: 0
- strategy: P2P_STAR
- role: DISCOVERER
- discovery_phase {
- duration_millis: 0
- medium: BLUETOOTH
- discovered_endpoint { medium: BLUETOOTH }
- discovery_metadata {
- supports_extended_ble_advertisements: true
- connected_ap_frequency: 1
- supports_nfc_technology: false
- }
- stop_reason: CLIENT_STOP_DISCOVERING
- }
- discovery_phase {
- duration_millis: 0
- medium: BLUETOOTH
- discovery_metadata {
- supports_extended_ble_advertisements: true
- connected_ap_frequency: 1
- supports_nfc_technology: false
- }
- }
- })pb");
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- Not(EqualsProto(strategy_session_proto2)));
-}
-
-TEST_F(AnalyticsRecorderTest,
- NotAddNewConnectionWithoutCallingOnStartAdvertising) {
- std::string endpoint_id = "endpoint_id";
-
- CountDownLatch client_session_done_latch(1);
- FakeEventLogger event_logger(client_session_done_latch);
- AnalyticsRecorder analytics_recorder(&event_logger);
-
- // via OnStartAdvertising, current_strategy_session_ is set in
- // UpdateStrategySessionLocked.
- auto advertising_metadata_params =
- analytics_recorder.BuildAdvertisingMetadataParams();
- GetFakeClock().FastForward(absl::Milliseconds(100));
- analytics_recorder.OnStartAdvertising(connections::Strategy::kP2pStar,
- /*mediums=*/{BLE, BLUETOOTH},
- advertising_metadata_params.get());
- GetFakeClock().FastForward(absl::Milliseconds(200));
- analytics_recorder.OnStopAdvertising();
- GetFakeClock().FastForward(absl::Milliseconds(300));
-
- // LogSession
- analytics_recorder.LogSession();
- ASSERT_TRUE(client_session_done_latch.Await(kDefaultTimeout).result());
-
- ConnectionsLog::ClientSession strategy_session_proto =
- ParseTextProtoOrDie(R"pb(
- duration_millis: 600
- strategy_session {
- duration_millis: 500
- strategy: P2P_STAR
- role: ADVERTISER
- advertising_phase {
- duration_millis: 200
- medium: BLE
- medium: BLUETOOTH
- advertising_metadata {
- supports_extended_ble_advertisements: false
- connected_ap_frequency: 0
- supports_nfc_technology: false
- }
- stop_reason: CLIENT_STOP_ADVERTISING
- }
- })pb");
-
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto));
-
- // Without calling OnStartAdvertising won't create new
- // current_strategy_session_.
- GetFakeClock().FastForward(absl::Milliseconds(400));
- analytics_recorder.OnConnectionEstablished(endpoint_id, BLUETOOTH,
- /*connection_token=*/"");
- GetFakeClock().FastForward(absl::Milliseconds(500));
- analytics_recorder.OnConnectionClosed(
- endpoint_id, BLUETOOTH, UPGRADED,
- ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
- GetFakeClock().FastForward(absl::Milliseconds(600));
- analytics_recorder.LogSession();
-
- // The proto won't change.
- EXPECT_THAT(event_logger.GetLoggedClientSession(),
- EqualsProto(strategy_session_proto));
-}
-
-} // namespace
-} // namespace analytics
-} // namespace nearby
diff --git a/connections/implementation/analytics/discovery_metadata_params.h b/connections/implementation/analytics/discovery_metadata_params.h
index 6442b03c..b90b2703 100644
--- a/connections/implementation/analytics/discovery_metadata_params.h
+++ b/connections/implementation/analytics/discovery_metadata_params.h
@@ -17,7 +17,7 @@
#include
-#include "internal/proto/analytics/connections_log.pb.h"
+#include "connections/implementation/analytics/operation_result_with_medium.h"
namespace nearby {
@@ -26,8 +26,7 @@ struct DiscoveryMetadataParams {
bool is_extended_advertisement_supported = false;
int connected_ap_frequency = 0;
bool is_nfc_available = false;
- std::vector
+ std::vector
operation_result_with_mediums = {};
};
diff --git a/connections/implementation/analytics/mock_analytics_recorder.h b/connections/implementation/analytics/mock_analytics_recorder.h
new file mode 100644
index 00000000..d407d98b
--- /dev/null
+++ b/connections/implementation/analytics/mock_analytics_recorder.h
@@ -0,0 +1,196 @@
+// Copyright 2026 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.
+
+#ifndef ANALYTICS_MOCK_ANALYTICS_RECORDER_H_
+#define ANALYTICS_MOCK_ANALYTICS_RECORDER_H_
+
+#include
+#include
+#include
+
+#include "gmock/gmock.h"
+#include "absl/time/time.h"
+#include "connections/implementation/analytics/advertising_metadata_params.h"
+#include "connections/implementation/analytics/analytics_recorder.h"
+#include "connections/implementation/analytics/connection_attempt_metadata_params.h"
+#include "connections/implementation/analytics/discovery_metadata_params.h"
+#include "connections/payload_type.h"
+#include "connections/strategy.h"
+#include "internal/platform/error_code_params.h"
+#include "proto/connections_enums.pb.h"
+
+namespace nearby::analytics {
+
+class MockAnalyticsRecorder : public AnalyticsRecorder {
+ public:
+ MockAnalyticsRecorder() = default;
+ ~MockAnalyticsRecorder() override = default;
+
+ // Advertising phase
+ MOCK_METHOD(void, OnStartAdvertising,
+ (connections::Strategy strategy,
+ const std::vector&
+ mediums,
+ AdvertisingMetadataParams* advertising_metadata_params),
+ (override));
+ MOCK_METHOD(void, OnStopAdvertising, (), (override));
+
+ MOCK_METHOD(int, GetNextAdvertisingUpdateIndex, (), (override));
+
+ // Connection listening
+ MOCK_METHOD(void, OnStartedIncomingConnectionListening,
+ (connections::Strategy strategy), (override));
+ MOCK_METHOD(void, OnStoppedIncomingConnectionListening, (), (override));
+
+ // Discovery phase
+ MOCK_METHOD(void, OnStartDiscovery,
+ (connections::Strategy strategy,
+ const std::vector&
+ mediums,
+ DiscoveryMetadataParams* discovery_metadata_params),
+ (override));
+ MOCK_METHOD(void, OnStopDiscovery, (), (override));
+
+ MOCK_METHOD(int, GetNextDiscoveryUpdateIndex, (), (override));
+ MOCK_METHOD(void, OnEndpointFound,
+ (location::nearby::proto::connections::Medium medium),
+ (override));
+
+ // Connection request
+ MOCK_METHOD(void, OnRequestConnection,
+ (const connections::Strategy& strategy,
+ const std::string& endpoint_id),
+ (override));
+
+ MOCK_METHOD(void, OnConnectionRequestReceived,
+ (const std::string& remote_endpoint_id), (override));
+ MOCK_METHOD(void, OnConnectionRequestSent,
+ (const std::string& remote_endpoint_id), (override));
+ MOCK_METHOD(void, OnRemoteEndpointAccepted,
+ (const std::string& remote_endpoint_id), (override));
+ MOCK_METHOD(void, OnLocalEndpointAccepted,
+ (const std::string& remote_endpoint_id), (override));
+ MOCK_METHOD(void, OnRemoteEndpointRejected,
+ (const std::string& remote_endpoint_id), (override));
+ MOCK_METHOD(void, OnLocalEndpointRejected,
+ (const std::string& remote_endpoint_id), (override));
+
+ // Connection attempt
+ MOCK_METHOD(
+ void, OnIncomingConnectionAttempt,
+ (location::nearby::proto::connections::ConnectionAttemptType type,
+ location::nearby::proto::connections::Medium medium,
+ location::nearby::proto::connections::ConnectionAttemptResult result,
+ absl::Duration duration, const std::string& connection_token,
+ ConnectionAttemptMetadataParams* connection_attempt_metadata_params),
+ (override));
+ MOCK_METHOD(
+ void, OnOutgoingConnectionAttempt,
+ (const std::string& remote_endpoint_id,
+ location::nearby::proto::connections::ConnectionAttemptType type,
+ location::nearby::proto::connections::Medium medium,
+ location::nearby::proto::connections::ConnectionAttemptResult result,
+ absl::Duration duration, const std::string& connection_token,
+ ConnectionAttemptMetadataParams* connection_attempt_metadata_params),
+ (override));
+
+ // Connection established
+ MOCK_METHOD(void, OnConnectionEstablished,
+ (const std::string& endpoint_id,
+ location::nearby::proto::connections::Medium medium,
+ const std::string& connection_token),
+ (override));
+ MOCK_METHOD(void, OnConnectionClosed,
+ (const std::string& endpoint_id,
+ location::nearby::proto::connections::Medium medium,
+ location::nearby::proto::connections::DisconnectionReason reason,
+ SafeDisconnectionResult result),
+ (override));
+
+ // Payload
+ MOCK_METHOD(void, OnIncomingPayloadStarted,
+ (const std::string& endpoint_id, std::int64_t payload_id,
+ connections::PayloadType type, std::int64_t total_size_bytes),
+ (override));
+ MOCK_METHOD(void, OnPayloadChunkReceived,
+ (const std::string& endpoint_id, std::int64_t payload_id,
+ std::int64_t chunk_size_bytes),
+ (override));
+ MOCK_METHOD(void, OnIncomingPayloadDone,
+ (const std::string& endpoint_id, std::int64_t payload_id,
+ location::nearby::proto::connections::PayloadStatus status,
+ location::nearby::proto::connections::OperationResultCode
+ operation_result_code),
+ (override));
+ MOCK_METHOD(void, OnOutgoingPayloadStarted,
+ (const std::vector& endpoint_ids,
+ std::int64_t payload_id, connections::PayloadType type,
+ std::int64_t total_size_bytes),
+ (override));
+ MOCK_METHOD(void, OnPayloadChunkSent,
+ (const std::string& endpoint_id, std::int64_t payload_id,
+ std::int64_t chunk_size_bytes),
+ (override));
+ MOCK_METHOD(void, OnOutgoingPayloadDone,
+ (const std::string& endpoint_id, std::int64_t payload_id,
+ location::nearby::proto::connections::PayloadStatus status,
+ location::nearby::proto::connections::OperationResultCode
+ operation_result_code),
+ (override));
+
+ // BandwidthUpgrade
+ MOCK_METHOD(void, OnBandwidthUpgradeStarted,
+ (const std::string& endpoint_id,
+ location::nearby::proto::connections::Medium from_medium,
+ location::nearby::proto::connections::Medium to_medium,
+ location::nearby::proto::connections::ConnectionAttemptDirection
+ direction,
+ const std::string& connection_token),
+ (override));
+ MOCK_METHOD(void, UpdateBwUpgradeNetworkInfo,
+ (const std::string& endpoint_id, int num_interfaces,
+ int num_ipv6_only_interfaces),
+ (override));
+ MOCK_METHOD(void, OnBandwidthUpgradeError,
+ (const std::string& endpoint_id,
+ location::nearby::proto::connections::BandwidthUpgradeResult
+ result,
+ location::nearby::proto::connections::BandwidthUpgradeErrorStage
+ error_stage,
+ location::nearby::proto::connections::OperationResultCode
+ operation_result_code),
+ (override));
+ MOCK_METHOD(void, OnBandwidthUpgradeSuccess, (const std::string& endpoint_id),
+ (override));
+
+ // Error Code
+ MOCK_METHOD(void, OnErrorCode, (const ErrorCodeParams& params), (override));
+
+ MOCK_METHOD(void, LogStartSession, (), (override));
+ MOCK_METHOD(void, LogSession, (), (override));
+
+ MOCK_METHOD(bool, IsSessionLogged, (), (override));
+
+ MOCK_METHOD(
+ location::nearby::proto::connections::OperationResultCategory,
+ GetOperationResultCategory,
+ (location::nearby::proto::connections::OperationResultCode result_code),
+ (override));
+
+ MOCK_METHOD(void, Sync, (), (override));
+};
+
+} // namespace nearby::analytics
+
+#endif // ANALYTICS_MOCK_ANALYTICS_RECORDER_H_
diff --git a/connections/implementation/analytics/operation_result_with_medium.h b/connections/implementation/analytics/operation_result_with_medium.h
new file mode 100644
index 00000000..483acc14
--- /dev/null
+++ b/connections/implementation/analytics/operation_result_with_medium.h
@@ -0,0 +1,55 @@
+// Copyright 2026 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.
+
+#ifndef ANALYTICS_OPERATION_RESULT_WITH_MEDIUM_H_
+#define ANALYTICS_OPERATION_RESULT_WITH_MEDIUM_H_
+
+#include
+
+#include "proto/connections_enums.pb.h"
+
+namespace nearby::analytics {
+
+struct OperationResultWithMedium {
+ location::nearby::proto::connections::Medium medium =
+ location::nearby::proto::connections::UNKNOWN_MEDIUM;
+ std::optional update_index;
+ location::nearby::proto::connections::OperationResultCategory
+ result_category = location::nearby::proto::connections::CATEGORY_UNKNOWN;
+ location::nearby::proto::connections::OperationResultCode result_code =
+ location::nearby::proto::connections::DETAIL_UNKNOWN;
+ std::optional
+ connection_mode;
+
+ void set_medium(location::nearby::proto::connections::Medium m) {
+ medium = m;
+ }
+ void set_update_index(int i) { update_index = i; }
+ void set_result_category(
+ location::nearby::proto::connections::OperationResultCategory c) {
+ result_category = c;
+ }
+ void set_result_code(
+ location::nearby::proto::connections::OperationResultCode c) {
+ result_code = c;
+ }
+ void set_connection_mode(
+ location::nearby::proto::connections::ConnectionMode m) {
+ connection_mode = m;
+ }
+};
+
+} // namespace nearby::analytics
+
+#endif // ANALYTICS_OPERATION_RESULT_WITH_MEDIUM_H_
diff --git a/connections/implementation/analytics/packet_meta_data.h b/connections/implementation/analytics/packet_meta_data.h
deleted file mode 100644
index 09d2a85a..00000000
--- a/connections/implementation/analytics/packet_meta_data.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2022-2023 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.
-
-#ifndef NEARBY_CONNECTIONS_IMPLEMENTATION_ANALYTICS_PACKET_META_DATA_H_
-#define NEARBY_CONNECTIONS_IMPLEMENTATION_ANALYTICS_PACKET_META_DATA_H_
-
-#include
-
-#include "absl/time/time.h"
-#include "internal/platform/implementation/system_clock.h"
-#include "internal/platform/system_clock.h"
-
-namespace nearby {
-namespace analytics {
-
-struct PacketMetaData {
- int packet_size;
- absl::Time file_io_start_time;
- absl::Time file_io_end_time;
- absl::Time encryption_start_time;
- absl::Time encryption_end_time;
- absl::Time socket_io_start_time;
- absl::Time socket_io_end_time;
-
- void Reset() {
- file_io_start_time = SystemClock::ElapsedRealtime();
- socket_io_start_time = SystemClock::ElapsedRealtime();
- socket_io_start_time = SystemClock::ElapsedRealtime();
- packet_size = 0;
- }
-
- void SetPacketSize(int packet_size) {
- this->packet_size = packet_size;
- }
-
- int GetPacketSize() {
- return packet_size;
- }
-
- void StartFileIo() {
- file_io_start_time = SystemClock::ElapsedRealtime();
- }
-
- void StopFileIo() {
- file_io_end_time = SystemClock::ElapsedRealtime();
- }
-
- void StartEncryption() {
- encryption_start_time = SystemClock::ElapsedRealtime();
- }
-
- void StopEncryption() {
- encryption_end_time = SystemClock::ElapsedRealtime();
- }
-
- void StartSocketIo() {
- socket_io_start_time = SystemClock::ElapsedRealtime();
- }
-
- void StopSocketIo() {
- socket_io_end_time = SystemClock::ElapsedRealtime();
- }
-
- int64_t GetEncryptionTimeInMillis() {
- if (encryption_end_time > encryption_start_time) {
- return absl::ToInt64Milliseconds(encryption_end_time -
- encryption_start_time);
- }
- return 0L;
- }
-
- int64_t GetFileIoTimeInMillis() {
- if (file_io_end_time > file_io_start_time) {
- return absl::ToInt64Milliseconds(file_io_end_time - file_io_start_time);
- }
- return 0L;
- }
-
- int64_t GetSocketIoTimeInMillis() {
- if (socket_io_end_time > socket_io_start_time) {
- return absl::ToInt64Milliseconds(socket_io_end_time -
- socket_io_start_time);
- }
- return 0L;
- }
-};
-
-} // namespace analytics
-} // namespace nearby
-
-#endif // NEARBY_CONNECTIONS_IMPLEMENTATION_ANALYTICS_PACKET_META_DATA_H_
diff --git a/connections/implementation/analytics/throughput_recorder.cc b/connections/implementation/analytics/throughput_recorder.cc
deleted file mode 100644
index 7833d4ad..00000000
--- a/connections/implementation/analytics/throughput_recorder.cc
+++ /dev/null
@@ -1,333 +0,0 @@
-// Copyright 2022-2023 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 "connections/implementation/analytics/throughput_recorder.h"
-
-#include
-
-#include
-#include
-#include
-#include
-#include
-
-#include "absl/container/flat_hash_map.h"
-#include "absl/meta/type_traits.h"
-#include "absl/strings/str_format.h"
-#include "absl/time/time.h"
-#include "internal/platform/implementation/system_clock.h"
-#include "internal/platform/logging.h"
-#include "internal/platform/mutex_lock.h"
-
-namespace nearby {
-namespace analytics {
-
-namespace {
-constexpr int kDefaultThroughoutKbps = 0;
-constexpr int kKbInBytes = 1024;
-constexpr int kSecInMs = 1000;
-} // namespace
-
-ThroughputRecorder::ThroughputRecorder(int64_t payload_id)
- : payload_id_(payload_id) {}
-
-ThroughputRecorderContainer& ThroughputRecorderContainer::GetInstance() {
- alignas(ThroughputRecorderContainer) static char
- storage[sizeof(ThroughputRecorderContainer)];
- static ThroughputRecorderContainer* env =
- new (&storage) ThroughputRecorderContainer();
- return *env;
-}
-
-void ThroughputRecorder::Start(PayloadType payload_type,
- PayloadDirection payload_direction) {
- std::string direction =
- (payload_direction == PayloadDirection::INCOMING_PAYLOAD) ? "; Receive"
- : "; Send";
-
- VLOG(1) << "Start TP profiling for payload_id:" << payload_id_ << direction;
-
- if (payload_type == PayloadType::kUnknown) {
- VLOG(1) << "Ignore ThroughputRecorder::start for Unknown Payload type";
- return;
- }
-
- MutexLock lock(&mutex_);
- start_timestamp_ = SystemClock::ElapsedRealtime();
- payload_type_ = payload_type;
- payload_direction_ = payload_direction;
- // Add packetLostAlarm later
-}
-
-bool ThroughputRecorder::Stop() {
- MutexLock lock(&mutex_);
- VLOG(1) << "Stop TP profiling for payload_id:" << payload_id_;
- if (payload_type_ == PayloadType::kUnknown) {
- VLOG(1) << "Ignore ThroughputRecorder::stop as it never start";
- return false;
- }
- {
- // Add packetLostAlarm stop process later
- absl::Time stop_timestamp = SystemClock::ElapsedRealtime();
- int64_t total_byte_size = 0;
- int medium_size = throughputs_.size();
-
- // The worse case is the socket/connect blocking the write request, never
- // got return when writing a frame out, it would get a very good data rate
- // for this case. e.g. use 60 seconds to send a file and failed, the counter
- // only get the duration as 30 seconds because the last write request
- // blocked.
- if (!success_) {
- if (!throughputs_.empty()) {
- for (auto& tp : throughputs_) {
- tp.second.SetLastTimestamp(stop_timestamp);
- }
- }
- }
-
- // calculate throughput by medium
- for (auto& tp : throughputs_) {
- tp.second.dump();
- total_byte_size += tp.second.GetTotalByteSize();
- }
-
- throughputs_.clear();
-
- int64_t total_millis =
- absl::ToInt64Milliseconds(stop_timestamp - start_timestamp_);
- throughput_kbps_ = CalculateThroughputKBps(total_byte_size, total_millis);
- int throughput_mbps = CalculateThroughputMBps(throughput_kbps_);
-
- // calculate overall throughput if there are multiple mediums
- if (medium_size > 1) {
- if (throughput_kbps_ != kDefaultThroughoutKbps) {
- std::string dump_content = absl::StrFormat(
- "%s %s data(%d bytes) %s, overall used %d milliseconds, "
- "throughput "
- "is %d MB/s (%d KB/s), File IO takes %d ms, %s takes %d "
- "ms, "
- "Socket IO takes %d ms",
- (payload_direction_ == PayloadDirection::INCOMING_PAYLOAD)
- ? "Received"
- : "Sent",
- ToString(payload_type_), total_byte_size,
- success_ ? "SUCCEEDED" : "FAILED", total_millis, throughput_mbps,
- throughput_kbps_, file_io_time_,
- (payload_direction_ == PayloadDirection::INCOMING_PAYLOAD)
- ? "Decryption"
- : "Encryption",
- encryption_time_, socket_io_time_);
- LOG(INFO) << dump_content;
- }
- }
- }
- return true;
-}
-
-void ThroughputRecorder::MarkAsSuccess() {
- MutexLock lock(&mutex_);
- success_ = true;
-}
-
-int ThroughputRecorder::CalculateThroughputKBps(int64_t total_byte_size,
- int64_t total_millis) {
- if (total_millis > 0) {
- return (int)(total_byte_size * kSecInMs / kKbInBytes / total_millis);
- }
- return kDefaultThroughoutKbps;
-}
-
-int ThroughputRecorder::CalculateThroughputMBps(int throughputKBps) {
- return throughputKBps / kKbInBytes;
-}
-
-void ThroughputRecorder::Throughput::Add(int frame_size, int64_t file_io_time,
- int64_t encryption_time,
- int64_t socket_io_time) {
- total_byte_size_ += frame_size;
- // reset the last timestamp
- last_timestamp_ = SystemClock::ElapsedRealtime();
- file_io_time_ += file_io_time;
- encryption_time_ += encryption_time;
- socket_io_time_ += socket_io_time;
-}
-
-bool ThroughputRecorder::Throughput::dump() {
- int64_t total_millis =
- absl::ToInt64Milliseconds(last_timestamp_ - start_timestamp_);
- int throughput_kbps = CalculateThroughputKBps(total_byte_size_, total_millis);
- if (throughput_kbps == kDefaultThroughoutKbps) {
- return false;
- }
- int throughpu_mbps = CalculateThroughputMBps(throughput_kbps);
- int64_t other =
- total_millis - file_io_time_ - encryption_time_ - socket_io_time_;
- std::string dump_content = absl::StrFormat(
- "%s %s data(%ld bytes) via %s used %ld milliseconds, throughput is %d "
- "MB/s (%d KB/s), File IO takes %ld ms, %s takes %ld ms, "
- "Socket IO takes %ld ms, "
- "Other takes %ld ms",
- (payload_direction_ == PayloadDirection::INCOMING_PAYLOAD) ? "Received"
- : "Sent",
- ToString(payload_type_), total_byte_size_,
- location::nearby::proto::connections::Medium_Name(medium_), total_millis,
- throughpu_mbps, throughput_kbps, file_io_time_,
- (payload_direction_ == PayloadDirection::INCOMING_PAYLOAD) ? "Decryption"
- : "Encryption",
- encryption_time_, socket_io_time_, other);
- LOG(INFO) << dump_content;
- return true;
-}
-
-ThroughputRecorder::Throughput& ThroughputRecorder::GetThroughput(
- Medium medium, int64_t duration_millis) {
- auto it = throughputs_.find(medium);
- if (it == throughputs_.end()) {
- auto throughput = new Throughput(
- medium,
- SystemClock::ElapsedRealtime() - absl::Milliseconds(duration_millis),
- payload_type_, payload_direction_);
- throughputs_.emplace(medium, std::move(*throughput));
- delete throughput;
- return throughputs_.find(medium)->second;
- }
- return it->second;
-}
-
-int ThroughputRecorder::GetThroughputsSize() {
- MutexLock lock(&mutex_);
- return throughputs_.size();
-}
-
-int ThroughputRecorder::GetThroughputKbps() { return throughput_kbps_; }
-
-int64_t ThroughputRecorder::GetDurationMillis() { return duration_millis_; }
-
-void ThroughputRecorder::OnFrameSent(Medium medium,
- PacketMetaData& packetMetaData) {
- MutexLock lock(&mutex_);
- if (payload_type_ == PayloadType::kUnknown) {
- VLOG(1) << "PayloadType is invalid, return";
- return;
- }
-
- duration_millis_ = packetMetaData.GetEncryptionTimeInMillis() +
- packetMetaData.GetFileIoTimeInMillis() +
- packetMetaData.GetSocketIoTimeInMillis();
- GetThroughput(medium, duration_millis_)
- .Add(packetMetaData.packet_size, packetMetaData.GetFileIoTimeInMillis(),
- packetMetaData.GetEncryptionTimeInMillis(),
- packetMetaData.GetSocketIoTimeInMillis());
- CalculateDurationTimes(packetMetaData);
-}
-
-void ThroughputRecorder::OnFrameReceived(Medium medium,
- PacketMetaData& packetMetaData) {
- MutexLock lock(&mutex_);
- if (payload_type_ == PayloadType::kUnknown) {
- VLOG(1) << "PayloadType is invalid, return";
- return;
- }
-
- // Add packetLostAlarm process later
- duration_millis_ = packetMetaData.GetEncryptionTimeInMillis() +
- packetMetaData.GetFileIoTimeInMillis() +
- packetMetaData.GetSocketIoTimeInMillis();
- GetThroughput(medium, duration_millis_)
- .Add(packetMetaData.packet_size, packetMetaData.GetFileIoTimeInMillis(),
- packetMetaData.GetEncryptionTimeInMillis(),
- packetMetaData.GetSocketIoTimeInMillis());
- CalculateDurationTimes(packetMetaData);
-}
-
-void ThroughputRecorder::CalculateDurationTimes(PacketMetaData packetMetaData) {
- encryption_time_ += packetMetaData.GetEncryptionTimeInMillis();
- socket_io_time_ += packetMetaData.GetSocketIoTimeInMillis();
- file_io_time_ += packetMetaData.GetFileIoTimeInMillis();
-}
-
-std::string ThroughputRecorder::ToString(PayloadType type) {
- switch (type) {
- case PayloadType::kBytes:
- return std::string("Bytes");
- case PayloadType::kStream:
- return std::string("Stream");
- case PayloadType::kFile:
- return std::string("File");
- case PayloadType::kUnknown:
- return std::string("Unknown");
- }
-}
-
-// Inplementation for ThroughputRecorderContainer
-
-void ThroughputRecorderContainer::Shutdown() {
- MutexLock lock(&mutex_);
- VLOG(1) << __func__ << ". Num of Instance:" << throughput_recorders_.size();
- for (auto& throughput_recorder : throughput_recorders_) {
- VLOG(1) << "Stop instance: " << throughput_recorder.second;
- throughput_recorder.second->Stop();
- delete throughput_recorder.second;
- }
- throughput_recorders_.clear();
-}
-
-ThroughputRecorder* ThroughputRecorderContainer::GetTPRecorder(
- const int64_t payload_id, PayloadDirection payload_direction) {
- MutexLock lock(&mutex_);
- auto it = throughput_recorders_.find(
- std::pair(payload_id, payload_direction));
- if (it == throughput_recorders_.end()) {
- auto instance = new ThroughputRecorder(payload_id);
- std::string direction =
- (payload_direction == PayloadDirection::INCOMING_PAYLOAD) ? "; Receive"
- : "; Send";
- VLOG(1) << "Add ThroughputRecorder instance : " << instance
- << " for payload_id:" << payload_id << direction;
- throughput_recorders_.emplace(
- std::pair(payload_id, payload_direction),
- instance);
- return instance;
- }
-
- return it->second;
-}
-
-void ThroughputRecorderContainer::StopTPRecorder(
- const int64_t payload_id, PayloadDirection payload_direction) {
- MutexLock lock(&mutex_);
- std::string direction =
- (payload_direction == PayloadDirection::INCOMING_PAYLOAD) ? "; Receive"
- : "; Send";
- auto it = throughput_recorders_.find(
- std::pair(payload_id, payload_direction));
- if (it != throughput_recorders_.end()) {
- VLOG(1) << "Found and stop/delete ThroughputRecorder instance : "
- << &(it->second) << " for payload_id:" << payload_id << direction;
- it->second->Stop();
- delete it->second;
- throughput_recorders_.erase(
- std::pair(payload_id, payload_direction));
- return;
- }
- VLOG(1) << "No ThroughputRecorder found for :" << payload_id;
-}
-
-int ThroughputRecorderContainer::GetSize() {
- MutexLock lock(&mutex_);
- return throughput_recorders_.size();
-}
-
-} // namespace analytics
-} // namespace nearby
diff --git a/connections/implementation/analytics/throughput_recorder.h b/connections/implementation/analytics/throughput_recorder.h
deleted file mode 100644
index e6dcdc05..00000000
--- a/connections/implementation/analytics/throughput_recorder.h
+++ /dev/null
@@ -1,144 +0,0 @@
-// Copyright 2022-2023 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.
-
-#ifndef NEARBY_CONNECTIONS_IMPLEMENTATION_ANALYTICS_THROUGHPUT_RECORDER_H_
-#define NEARBY_CONNECTIONS_IMPLEMENTATION_ANALYTICS_THROUGHPUT_RECORDER_H_
-
-#include
-#include
-#include
-
-#include "absl/base/thread_annotations.h"
-#include "absl/container/flat_hash_map.h"
-#include "absl/time/time.h"
-#include "connections/implementation/analytics/packet_meta_data.h"
-#include "connections/payload_type.h"
-#include "internal/platform/mutex.h"
-#include "proto/connections_enums.pb.h"
-
-namespace nearby {
-namespace analytics {
-
-// The following aliases are only for users' convenience.
-using ::location::nearby::proto::connections::Medium;
-using ::nearby::connections::PayloadType;
-// Enum to represent if a payload is incoming or outgoing.
-using ::nearby::connections::PayloadDirection;
-
-class ThroughputRecorder {
- public:
- explicit ThroughputRecorder(int64_t payload_id);
- ~ThroughputRecorder() = default;
-
- void Start(PayloadType payload_type, PayloadDirection payload_direction);
- bool Stop() ABSL_LOCKS_EXCLUDED(mutex_);
- static int CalculateThroughputKBps(int64_t total_byte_size,
- int64_t total_millis);
- static int CalculateThroughputMBps(int throughputKBps);
-
- class Throughput {
- public:
- Throughput() = default;
- ~Throughput() = default;
- Throughput(Medium medium, absl::Time start_timestamp,
- PayloadType payload_type, PayloadDirection payload_direction)
- : medium_(medium),
- start_timestamp_(start_timestamp),
- payload_type_(payload_type),
- payload_direction_(payload_direction) {}
-
- void Add(int frame_size, int64_t file_io_time, int64_t encryption_time,
- int64_t socket_io_time);
-
- void SetLastTimestamp(absl::Time time_stamp) {
- last_timestamp_ = time_stamp;
- }
-
- int64_t GetTotalByteSize() { return total_byte_size_; }
-
- bool dump();
-
- private:
- Medium medium_;
- absl::Time start_timestamp_;
- PayloadType payload_type_;
- int64_t total_byte_size_ = 0;
- absl::Time last_timestamp_;
- PayloadDirection payload_direction_ = PayloadDirection::INCOMING_PAYLOAD;
- int64_t file_io_time_ = 0;
- int64_t encryption_time_ = 0;
- int64_t socket_io_time_ = 0;
- };
-
- Throughput& GetThroughput(Medium medium, int64_t duration_millis);
- int GetThroughputsSize();
- int GetThroughputKbps();
- int64_t GetDurationMillis();
- void OnFrameSent(Medium medium, PacketMetaData& packetMetaData);
- void OnFrameReceived(Medium medium, PacketMetaData& packetMetaData);
- void MarkAsSuccess();
-
- private:
- void CalculateDurationTimes(PacketMetaData packetMetaData);
- static std::string ToString(PayloadType type);
-
- Mutex mutex_;
- int64_t payload_id_ = 0;
- absl::Time start_timestamp_;
- PayloadType payload_type_ = PayloadType::kUnknown;
- PayloadDirection payload_direction_ = PayloadDirection::INCOMING_PAYLOAD;
- absl::flat_hash_map throughputs_;
- bool success_ = false;
-
- int64_t file_io_time_ = 0;
- int64_t encryption_time_ = 0;
- int64_t socket_io_time_ = 0;
- int64_t duration_millis_ = 0;
- int throughput_kbps_ = 0;
-};
-
-class ThroughputRecorderContainer {
- public:
- ThroughputRecorderContainer(const ThroughputRecorderContainer&) = delete;
- ThroughputRecorderContainer& operator=(const ThroughputRecorderContainer&) =
- delete;
-
- static ThroughputRecorderContainer& GetInstance();
- void Shutdown() ABSL_LOCKS_EXCLUDED(mutex_);
-
- ThroughputRecorder* GetTPRecorder(int64_t payload_id,
- PayloadDirection payload_direction)
- ABSL_LOCKS_EXCLUDED(mutex_);
- void StopTPRecorder(int64_t payload_id, PayloadDirection payload_direction)
- ABSL_LOCKS_EXCLUDED(mutex_);
- int GetSize() ABSL_LOCKS_EXCLUDED(mutex_);
-
- private:
- // This is a singleton object, for which destructor will never be called.
- // Constructor will be invoked once from Instance() static method.
- // Object is create in-place (with a placement new) to guarantee that
- // destructor is not scheduled for execution at exit.
- ThroughputRecorderContainer() = default;
- ~ThroughputRecorderContainer() = default;
-
- Mutex mutex_;
- // std::pair for
- absl::flat_hash_map, ThroughputRecorder*>
- throughput_recorders_ ABSL_GUARDED_BY(mutex_);
-};
-
-} // namespace analytics
-} // namespace nearby
-
-#endif // NEARBY_CONNECTIONS_IMPLEMENTATION_ANALYTICS_THROUGHPUT_RECORDER_H_
diff --git a/connections/implementation/analytics/throughput_recorder_test.cc b/connections/implementation/analytics/throughput_recorder_test.cc
deleted file mode 100644
index 8b31add3..00000000
--- a/connections/implementation/analytics/throughput_recorder_test.cc
+++ /dev/null
@@ -1,233 +0,0 @@
-// Copyright 2022-2023 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 "connections/implementation/analytics/throughput_recorder.h"
-
-#include
-
-#include
-#include
-
-#include "gtest/gtest.h"
-#include "absl/time/clock.h"
-#include "absl/time/time.h"
-#include "internal/platform/logging.h"
-#include "proto/connections_enums.pb.h"
-
-namespace nearby {
-namespace analytics {
-namespace {
-// TODO(b/246693797): Add unit tests coverage for throughput recorder code
-
-constexpr int64_t kPayloadIdA = 123456789;
-constexpr int64_t kPayloadIdB = 987654321;
-constexpr int kFrameSize = 10 * 64 * 1024;
-constexpr int64_t kTotalByteSize1GB = 1024 * 1024 * 1024;
-constexpr int64_t kTotalMillis10Sec = 10 * 1000;
-constexpr int kTPResultKBPerSec = 1024 * 1024 / 10;
-constexpr int kTPKBPerSec = 100 * 1024;
-constexpr int kTPResultMBPerSec = 100;
-
-// class ThroughputRecorderTest : public testing::Test {
-class ThroughputRecorderTest : public testing::TestWithParam {
- protected:
- ThroughputRecorderTest() = default;
- ~ThroughputRecorderTest() override {
- ThroughputRecorderContainer::GetInstance().Shutdown();
- }
-
- ThroughputRecorderContainer& tp_recorder_container_ =
- ThroughputRecorderContainer::GetInstance();
-};
-
-INSTANTIATE_TEST_SUITE_P(ParametrisedTestThroughputRecorderTest,
- ThroughputRecorderTest, testing::Values(true, false));
-
-TEST(ThroughputRecorder, CalculateThroughputKBps) {
- EXPECT_EQ(ThroughputRecorder::CalculateThroughputKBps(kTotalByteSize1GB,
- kTotalMillis10Sec),
- kTPResultKBPerSec);
- EXPECT_EQ(ThroughputRecorder::CalculateThroughputKBps(kTotalByteSize1GB, 0),
- 0);
-}
-
-TEST(ThroughputRecorder, CalculateThroughputMBps) {
- EXPECT_EQ(ThroughputRecorder::CalculateThroughputMBps(kTPKBPerSec),
- kTPResultMBPerSec);
-}
-
-TEST(ThroughputRecorderContainer, InstanceCreate_ContainerSize) {
- ThroughputRecorderContainer& TPRecorderContainer =
- ThroughputRecorderContainer::GetInstance();
- TPRecorderContainer.GetTPRecorder(kPayloadIdA,
- PayloadDirection::OUTGOING_PAYLOAD);
- TPRecorderContainer.GetTPRecorder(kPayloadIdB,
- PayloadDirection::INCOMING_PAYLOAD);
- EXPECT_EQ(ThroughputRecorderContainer::GetInstance().GetSize(), 2);
- ThroughputRecorderContainer::GetInstance().Shutdown();
- EXPECT_EQ(ThroughputRecorderContainer::GetInstance().GetSize(), 0);
-}
-
-TEST_F(ThroughputRecorderTest, OnFrameSentSaveTransferredSize) {
- auto TPRecorder = tp_recorder_container_.GetTPRecorder(
- kPayloadIdA, PayloadDirection::OUTGOING_PAYLOAD);
- TPRecorder->Start(PayloadType::kFile, PayloadDirection::OUTGOING_PAYLOAD);
-
- PacketMetaData packet_meta_data;
- packet_meta_data.SetPacketSize(kFrameSize);
- TPRecorder->OnFrameSent(location::nearby::proto::connections::BLE,
- packet_meta_data);
- TPRecorder->OnFrameSent(location::nearby::proto::connections::BLE,
- packet_meta_data);
- TPRecorder->OnFrameSent(location::nearby::proto::connections::BLE,
- packet_meta_data);
-
- auto throughput =
- TPRecorder->GetThroughput(location::nearby::proto::connections::BLE, 0);
- EXPECT_EQ(throughput.GetTotalByteSize(), kFrameSize * 3);
-}
-
-TEST_F(ThroughputRecorderTest, OnIgnoreUnkownPaylaodType) {
- auto TPRecorder = tp_recorder_container_.GetTPRecorder(
- kPayloadIdA, PayloadDirection::OUTGOING_PAYLOAD);
- TPRecorder->Start(PayloadType::kUnknown, PayloadDirection::OUTGOING_PAYLOAD);
-
- PacketMetaData packet_meta_data;
- TPRecorder->OnFrameSent(location::nearby::proto::connections::BLE,
- packet_meta_data);
- EXPECT_EQ(TPRecorder->GetThroughputsSize(), 0);
-
- TPRecorder->Start(PayloadType::kUnknown, PayloadDirection::INCOMING_PAYLOAD);
- TPRecorder->OnFrameReceived(location::nearby::proto::connections::BLE,
- packet_meta_data);
- EXPECT_EQ(TPRecorder->GetThroughputsSize(), 0);
-}
-
-TEST_P(ThroughputRecorderTest, OnFrameSentStopAndDump) {
- auto TPRecorder = tp_recorder_container_.GetTPRecorder(
- kPayloadIdA, PayloadDirection::OUTGOING_PAYLOAD);
- TPRecorder->Start(PayloadType::kFile, PayloadDirection::OUTGOING_PAYLOAD);
-
- PacketMetaData packet_meta_data;
- packet_meta_data.SetPacketSize(kFrameSize);
- packet_meta_data.StartFileIo();
- absl::SleepFor(absl::Milliseconds(5));
- packet_meta_data.StopFileIo();
- packet_meta_data.StartEncryption();
- absl::SleepFor(absl::Milliseconds(6));
- packet_meta_data.StopEncryption();
- packet_meta_data.StartSocketIo();
- absl::SleepFor(absl::Milliseconds(7));
- packet_meta_data.StopSocketIo();
- TPRecorder->OnFrameSent(location::nearby::proto::connections::BLE,
- packet_meta_data);
- EXPECT_EQ(TPRecorder->GetDurationMillis(),
- packet_meta_data.GetEncryptionTimeInMillis() +
- packet_meta_data.GetFileIoTimeInMillis() +
- packet_meta_data.GetSocketIoTimeInMillis());
-
- packet_meta_data.SetPacketSize(kFrameSize);
- packet_meta_data.StartFileIo();
- absl::SleepFor(absl::Milliseconds(15));
- packet_meta_data.StopFileIo();
- packet_meta_data.StartEncryption();
- absl::SleepFor(absl::Milliseconds(16));
- packet_meta_data.StopEncryption();
- packet_meta_data.StartSocketIo();
- absl::SleepFor(absl::Milliseconds(17));
- packet_meta_data.StopSocketIo();
- TPRecorder->OnFrameSent(location::nearby::proto::connections::BLE,
- packet_meta_data);
-
- if (GetParam() == true) {
- LOG(INFO) << "MarkAsSuccess";
- TPRecorder->MarkAsSuccess();
- }
- EXPECT_TRUE(TPRecorder->Stop());
- EXPECT_NE(TPRecorder->GetThroughputKbps(), 0);
-}
-
-TEST_F(ThroughputRecorderTest, OnFrameSentStopAndDumpForMultiMeadium) {
- auto TPRecorder = tp_recorder_container_.GetTPRecorder(
- kPayloadIdA, PayloadDirection::OUTGOING_PAYLOAD);
- TPRecorder->Start(PayloadType::kFile, PayloadDirection::OUTGOING_PAYLOAD);
-
- PacketMetaData packet_meta_data1;
- packet_meta_data1.SetPacketSize(kFrameSize);
- packet_meta_data1.StartFileIo();
- absl::SleepFor(absl::Milliseconds(5));
- packet_meta_data1.StopFileIo();
- packet_meta_data1.StartEncryption();
- absl::SleepFor(absl::Milliseconds(6));
- packet_meta_data1.StopEncryption();
- packet_meta_data1.StartSocketIo();
- absl::SleepFor(absl::Milliseconds(7));
- packet_meta_data1.StopSocketIo();
- TPRecorder->OnFrameSent(location::nearby::proto::connections::BLE,
- packet_meta_data1);
-
- PacketMetaData packet_meta_data2;
- packet_meta_data2.SetPacketSize(kFrameSize);
- packet_meta_data2.StartFileIo();
- absl::SleepFor(absl::Milliseconds(15));
- packet_meta_data2.StopFileIo();
- packet_meta_data2.StartEncryption();
- absl::SleepFor(absl::Milliseconds(16));
- packet_meta_data2.StopEncryption();
- packet_meta_data2.StartSocketIo();
- absl::SleepFor(absl::Milliseconds(17));
- packet_meta_data2.StopSocketIo();
- TPRecorder->OnFrameSent(location::nearby::proto::connections::WIFI_LAN,
- packet_meta_data2);
-
- TPRecorder->MarkAsSuccess();
- EXPECT_TRUE(TPRecorder->Stop());
- EXPECT_NE(TPRecorder->GetThroughputKbps(), 0);
-}
-
-TEST_F(ThroughputRecorderTest, OnFrameReceivedCheckDurationMillis) {
- auto TPRecorder = tp_recorder_container_.GetTPRecorder(
- kPayloadIdA, PayloadDirection::INCOMING_PAYLOAD);
- TPRecorder->Start(PayloadType::kFile, PayloadDirection::INCOMING_PAYLOAD);
-
- PacketMetaData packet_meta_data;
- packet_meta_data.SetPacketSize(kFrameSize);
- packet_meta_data.StartFileIo();
- absl::SleepFor(absl::Milliseconds(5));
- packet_meta_data.StopFileIo();
- packet_meta_data.StartEncryption();
- absl::SleepFor(absl::Milliseconds(6));
- packet_meta_data.StopEncryption();
- packet_meta_data.StartSocketIo();
- absl::SleepFor(absl::Milliseconds(7));
- packet_meta_data.StopSocketIo();
- TPRecorder->OnFrameReceived(location::nearby::proto::connections::BLE,
- packet_meta_data);
- EXPECT_EQ(TPRecorder->GetDurationMillis(),
- packet_meta_data.GetEncryptionTimeInMillis() +
- packet_meta_data.GetFileIoTimeInMillis() +
- packet_meta_data.GetSocketIoTimeInMillis());
-}
-
-TEST_F(ThroughputRecorderTest, OnTPRecorderNotStarted) {
- auto TPRecorder = tp_recorder_container_.GetTPRecorder(
- kPayloadIdA, PayloadDirection::OUTGOING_PAYLOAD);
- auto throughput =
- TPRecorder->GetThroughput(location::nearby::proto::connections::BLE, 0);
- EXPECT_FALSE(throughput.dump());
-}
-
-} // namespace
-} // namespace analytics
-} // namespace nearby
diff --git a/connections/implementation/awdl_bwu_handler_test.cc b/connections/implementation/awdl_bwu_handler_test.cc
new file mode 100644
index 00000000..627a7af6
--- /dev/null
+++ b/connections/implementation/awdl_bwu_handler_test.cc
@@ -0,0 +1,576 @@
+// Copyright 2026 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 "connections/implementation/awdl_bwu_handler.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#include "gmock/gmock.h"
+#include "protobuf-matchers/protocol-buffer-matchers.h"
+#include "gtest/gtest.h"
+#include "absl/strings/string_view.h"
+#include "absl/time/clock.h"
+#include "absl/time/time.h"
+#include "connections/implementation/awdl_endpoint_channel.h"
+#include "connections/implementation/bwu_handler.h"
+#include "connections/implementation/client_proxy.h"
+#include "connections/implementation/mediums/awdl.h"
+#include "connections/implementation/mediums/mediums.h"
+#include "connections/strategy.h"
+#include "internal/analytics/mock_event_logger.h"
+#include "internal/analytics/sharing_log_matchers.h"
+#include "internal/platform/awdl.h"
+#include "internal/platform/byte_array.h"
+#include "internal/platform/cancellation_flag.h"
+#include "internal/platform/count_down_latch.h"
+#include "internal/platform/exception.h"
+#include "internal/platform/implementation/awdl.h"
+#include "internal/platform/implementation/platform.h"
+#include "internal/platform/implementation/psk_info.h"
+#include "internal/platform/input_stream.h"
+#include "internal/platform/medium_environment.h"
+#include "internal/platform/mock_input_stream.h"
+#include "internal/platform/mock_output_stream.h"
+#include "internal/platform/nsd_service_info.h"
+#include "internal/platform/output_stream.h"
+#include "internal/proto/analytics/connections_log.pb.h"
+
+namespace nearby {
+
+class MockAwdlSocket : public api::AwdlSocket {
+ public:
+ MOCK_METHOD(InputStream&, GetInputStream, (), (override));
+ MOCK_METHOD(OutputStream&, GetOutputStream, (), (override));
+ MOCK_METHOD(Exception, Close, (), (override));
+};
+
+class MockAwdlServerSocket : public api::AwdlServerSocket {
+ public:
+ MOCK_METHOD(std::string, GetIPAddress, (), (const, override));
+ MOCK_METHOD(int, GetPort, (), (const, override));
+ MOCK_METHOD(std::unique_ptr, Accept, (), (override));
+ MOCK_METHOD(Exception, Close, (), (override));
+};
+
+class MockAwdlMedium : public api::AwdlMedium {
+ public:
+ MOCK_METHOD(bool, IsNetworkConnected, (), (const, override));
+ MOCK_METHOD(bool, StartAdvertising, (const NsdServiceInfo& nsd_service_info),
+ (override));
+ MOCK_METHOD(bool, StopAdvertising, (const NsdServiceInfo& nsd_service_info),
+ (override));
+ MOCK_METHOD(bool, StartDiscovery,
+ (const std::string& service_type,
+ DiscoveredServiceCallback callback),
+ (override));
+ MOCK_METHOD(bool, StopDiscovery, (const std::string& service_type),
+ (override));
+ MOCK_METHOD(std::unique_ptr, ConnectToService,
+ (const NsdServiceInfo& remote_service_info,
+ CancellationFlag* cancellation_flag),
+ (override));
+ MOCK_METHOD(std::unique_ptr, ConnectToService,
+ (const NsdServiceInfo& remote_service_info,
+ const api::PskInfo& psk_info,
+ CancellationFlag* cancellation_flag),
+ (override));
+ MOCK_METHOD(std::unique_ptr, ListenForService,
+ (int port), (override));
+ MOCK_METHOD(std::unique_ptr, ListenForService,
+ (const api::PskInfo& psk_info, int port), (override));
+ MOCK_METHOD((std::optional>),
+ GetDynamicPortRange, (), (override));
+};
+
+MockAwdlMedium* awdl_medium_mock = nullptr;
+
+namespace connections {
+namespace {
+
+using ::location::nearby::analytics::proto::ConnectionsLog;
+using ::location::nearby::connections::BandwidthUpgradeNegotiationFrame;
+using ::location::nearby::connections::OfflineFrame;
+using ::location::nearby::connections::V1Frame;
+using ::location::nearby::proto::connections::EventType;
+using ::location::nearby::proto::connections::OperationResultCode;
+using ::nearby::analytics::HasEventType;
+using ::testing::_;
+using ::testing::ByMove;
+using ::protobuf_matchers::EqualsProto;
+using ::testing::Matcher;
+using ::testing::MockFunction;
+using ::testing::Return;
+using ::testing::ReturnRef;
+using ::testing::StrictMock;
+
+constexpr absl::string_view kServiceId{"service_id"};
+constexpr absl::string_view kEndpointId{"endpoint_id"};
+constexpr absl::string_view kServiceName{"awdl_srv"};
+constexpr absl::string_view kServiceType{"_awdl._tcp"};
+constexpr absl::string_view kPassword{"password123"};
+constexpr absl::string_view kChannelName{"channel_name"};
+
+class AwdlBwuHandlerTest : public ::testing::Test {
+ protected:
+ AwdlBwuHandlerTest()
+ : handler_(mediums_, incoming_connection_callback_.AsStdFunction()) {}
+
+ void SetUp() override {
+ // By default, network is connected.
+ ON_CALL(*awdl_medium_mock, IsNetworkConnected())
+ .WillByDefault(Return(true));
+ }
+
+ Mediums mediums_;
+ MockFunction)>
+ incoming_connection_callback_;
+ AwdlBwuHandler handler_;
+ nearby::analytics::MockEventLogger mock_event_logger_;
+ MockInputStream mock_input_stream_;
+ MockOutputStream mock_output_stream_;
+};
+
+TEST_F(AwdlBwuHandlerTest,
+ CreateUpgradedEndpointChannel_InvalidCredentials_Fails) {
+ ClientProxy client(&mock_event_logger_);
+ BandwidthUpgradeNegotiationFrame::UpgradePathInfo path_info;
+ path_info.mutable_awdl_credentials(); // Empty credentials
+
+ auto result =
+ static_cast(&handler_)->CreateUpgradedEndpointChannel(
+ &client, "service_id", "endpoint_id", path_info);
+
+ ASSERT_TRUE(result.has_error());
+ EXPECT_EQ(result.error().operation_result_code().value(),
+ OperationResultCode::CONNECTIVITY_AWDL_INVALID_CREDENTIAL);
+}
+
+TEST_F(AwdlBwuHandlerTest, CreateUpgradedEndpointChannel_Success) {
+ ClientProxy client(&mock_event_logger_);
+ client.AddCancellationFlag(std::string(kEndpointId));
+ MockInputStream input_stream;
+ MockOutputStream output_stream;
+ auto awdl_socket = std::make_unique();
+ EXPECT_CALL(*awdl_socket, GetInputStream())
+ .WillRepeatedly(ReturnRef(input_stream));
+ EXPECT_CALL(*awdl_socket, GetOutputStream())
+ .WillRepeatedly(ReturnRef(output_stream));
+
+ EXPECT_CALL(*awdl_medium_mock, StartDiscovery(_, _))
+ .WillOnce([](const std::string& service_type,
+ api::AwdlMedium::DiscoveredServiceCallback callback) {
+ NsdServiceInfo service_info;
+ service_info.SetServiceName(std::string(kServiceName));
+ service_info.SetServiceType(service_type);
+ if (callback.service_discovered_cb) {
+ NsdServiceInfo service_info_copy = service_info;
+ callback.service_discovered_cb(service_info_copy);
+ }
+ return true;
+ });
+ EXPECT_CALL(*awdl_medium_mock, StopDiscovery(_)).WillRepeatedly(Return(true));
+ EXPECT_CALL(*awdl_medium_mock, ConnectToService(_, _, _))
+ .WillOnce(Return(ByMove(std::move(awdl_socket))));
+
+ BandwidthUpgradeNegotiationFrame::UpgradePathInfo path_info;
+ auto* credentials = path_info.mutable_awdl_credentials();
+ credentials->set_service_name(kServiceName);
+ credentials->set_service_type(kServiceType);
+ credentials->set_password(kPassword);
+
+ auto result =
+ static_cast(&handler_)->CreateUpgradedEndpointChannel(
+ &client, std::string(kServiceId), std::string(kEndpointId),
+ path_info);
+
+ EXPECT_TRUE(result.has_value());
+}
+
+TEST_F(AwdlBwuHandlerTest,
+ InitializeUpgradedMediumForEndpoint_StartAcceptingConnectionsFails) {
+ MediumEnvironment::Instance().Start({.use_simulated_clock = true});
+ ClientProxy client(&mock_event_logger_);
+ client.AddCancellationFlag(std::string(kEndpointId));
+
+ EXPECT_CALL(*awdl_medium_mock, ListenForService(_, 0))
+ .WillOnce(Return(ByMove(nullptr)));
+
+ ByteArray result = handler_.InitializeUpgradedMediumForEndpoint(
+ &client, std::string(kServiceId), std::string(kEndpointId));
+
+ EXPECT_TRUE(result.Empty());
+ MediumEnvironment::Instance().Stop();
+}
+
+TEST_F(AwdlBwuHandlerTest, InitializeUpgradedMediumForEndpoint_Success) {
+ MediumEnvironment::Instance().Start({.use_simulated_clock = true});
+ // The reason for putting ClientProxy inside a C++ { } block so it destructs
+ // before the simulated clock is restored. Otherwise, the simulated clock
+ // would stopped before ClientProxy went out of scope, causing its destructor
+ // to log the session duration using the real system clock. If 1 or more
+ // real-world milliseconds elapsed between the test start and test end, this
+ // duration evaluated to something > 0.
+ {
+ ClientProxy client(&mock_event_logger_);
+ client.GetAnalyticsRecorder().OnStartAdvertising(
+ Strategy::kP2pPointToPoint,
+ {location::nearby::proto::connections::Medium::BLUETOOTH},
+ /*advertising_metadata_params=*/nullptr);
+ client.GetAnalyticsRecorder().OnBandwidthUpgradeStarted(
+ std::string(kEndpointId),
+ location::nearby::proto::connections::Medium::BLUETOOTH,
+ location::nearby::proto::connections::Medium::AWDL,
+ location::nearby::proto::connections::ConnectionAttemptDirection::
+ OUTGOING,
+ /*connection_token=*/"");
+ client.AddCancellationFlag(std::string(kEndpointId));
+
+ auto awdl_server_socket = std::make_unique();
+ auto* awdl_server_socket_ptr = awdl_server_socket.get();
+ EXPECT_CALL(*awdl_server_socket_ptr, GetPort())
+ .WillRepeatedly(Return(8080));
+ EXPECT_CALL(*awdl_server_socket_ptr, Accept())
+ .WillOnce(Return(ByMove(nullptr)));
+ EXPECT_CALL(*awdl_server_socket_ptr, Close())
+ .WillRepeatedly(Return(Exception{Exception::kSuccess}));
+
+ EXPECT_CALL(*awdl_medium_mock, ListenForService(_, 0))
+ .WillOnce(Return(ByMove(std::move(awdl_server_socket))));
+
+ std::string captured_service_name;
+ std::string captured_service_type;
+ EXPECT_CALL(*awdl_medium_mock, StartAdvertising(_))
+ .WillOnce([&](const NsdServiceInfo& nsd_service_info) {
+ captured_service_name = nsd_service_info.GetServiceName();
+ captured_service_type = nsd_service_info.GetServiceType();
+ return true;
+ });
+
+ ByteArray result = handler_.InitializeUpgradedMediumForEndpoint(
+ &client, std::string(kServiceId), std::string(kEndpointId));
+
+ EXPECT_FALSE(result.Empty());
+ OfflineFrame expected_frame;
+ expected_frame.set_version(OfflineFrame::V1);
+ expected_frame.mutable_v1()->set_type(
+ V1Frame::BANDWIDTH_UPGRADE_NEGOTIATION);
+ auto* bwu_frame =
+ expected_frame.mutable_v1()->mutable_bandwidth_upgrade_negotiation();
+ bwu_frame->set_event_type(
+ BandwidthUpgradeNegotiationFrame::UPGRADE_PATH_AVAILABLE);
+ auto* upgrade_path_info = bwu_frame->mutable_upgrade_path_info();
+ upgrade_path_info->set_medium(
+ BandwidthUpgradeNegotiationFrame::UpgradePathInfo::AWDL);
+ upgrade_path_info->set_supports_client_introduction_ack(true);
+ upgrade_path_info->set_supports_disabling_encryption(true);
+ auto* awdl_credentials = upgrade_path_info->mutable_awdl_credentials();
+ awdl_credentials->set_service_name(captured_service_name);
+ awdl_credentials->set_service_type(captured_service_type);
+
+ // The password is automatically generated and set in the handle start, we
+ // can obtain it from the credential Since we mock StartAcceptingConnections
+ // instead of using real awdl, GetPskInfo won't work perfectly. However
+ // InitializeUpgradedMediumForEndpoint internally calls
+ // parser::ForBwuAwdlPathAvailable which puts the generated password. We
+ // will extract it from result directly to build expected frame.
+ OfflineFrame result_frame;
+ EXPECT_TRUE(result_frame.ParseFromString(std::string(result)));
+ awdl_credentials->set_password(result_frame.v1()
+ .bandwidth_upgrade_negotiation()
+ .upgrade_path_info()
+ .awdl_credentials()
+ .password());
+
+ EXPECT_THAT(result_frame, EqualsProto(expected_frame));
+
+ constexpr absl::string_view kClientSessionLog = R"pb(
+ event_type: CLIENT_SESSION
+ client_session { duration_millis: 0 }
+ version: "v1.5.0"
+ )pb";
+ constexpr absl::string_view kExpectedUpgradeLog = R"pb(
+ event_type: CLIENT_SESSION
+ client_session {
+ duration_millis: 0
+ strategy_session {
+ duration_millis: 0
+ strategy: P2P_POINT_TO_POINT
+ role: ADVERTISER
+ advertising_phase {
+ duration_millis: 0
+ medium: BLUETOOTH
+ advertising_metadata {
+ supports_extended_ble_advertisements: false
+ connected_ap_frequency: 0
+ supports_nfc_technology: false
+ }
+ stop_reason: FINISH_SESSION_STOP_ADVERTISING
+ }
+ upgrade_attempt {
+ direction: OUTGOING
+ duration_millis: 0
+ from_medium: BLUETOOTH
+ to_medium: AWDL
+ upgrade_result: UNFINISHED_ERROR
+ error_stage: UPGRADE_UNFINISHED
+ connection_token: ""
+ operation_result {
+ result_category: CATEGORY_DEVICE_STATE_ERROR
+ result_code: DEVICE_STATE_ERROR_UNFINISHED_UPGRADE_ATTEMPTS
+ }
+ }
+ }
+ }
+ version: "v1.5.0"
+ )pb";
+ EXPECT_CALL(mock_event_logger_,
+ Log(Matcher(
+ HasEventType(EventType::STOP_STRATEGY_SESSION))))
+ .Times(1);
+ EXPECT_CALL(mock_event_logger_,
+ Log(Matcher(
+ HasEventType(EventType::STOP_CLIENT_SESSION))))
+ .Times(3);
+ EXPECT_CALL(mock_event_logger_,
+ Log(Matcher(
+ HasEventType(EventType::START_CLIENT_SESSION))))
+ .Times(3);
+ EXPECT_CALL(
+ mock_event_logger_,
+ Log(Matcher(EqualsProto(kClientSessionLog))))
+ .Times(2);
+ EXPECT_CALL(
+ mock_event_logger_,
+ Log(Matcher(EqualsProto(kExpectedUpgradeLog))));
+ // Flush pending logs.
+ client.GetAnalyticsRecorder().LogSession();
+ handler_.RevertInitiatorState();
+ }
+ MediumEnvironment::Instance().Stop();
+}
+
+TEST_F(AwdlBwuHandlerTest, OnIncomingAwdlConnection_Success) {
+ MediumEnvironment::Instance().Start({.use_simulated_clock = true});
+ ClientProxy client(&mock_event_logger_);
+ client.AddCancellationFlag(std::string(kEndpointId));
+
+ auto awdl_server_socket = std::make_unique();
+ auto* awdl_server_socket_ptr = awdl_server_socket.get();
+ EXPECT_CALL(*awdl_server_socket_ptr, Close())
+ .WillRepeatedly(Return(Exception{Exception::kSuccess}));
+ EXPECT_CALL(*awdl_server_socket_ptr, Accept())
+ .WillOnce([this]() {
+ auto awdl_socket = std::make_unique();
+ EXPECT_CALL(*awdl_socket, GetInputStream())
+ .WillRepeatedly(ReturnRef(mock_input_stream_));
+ EXPECT_CALL(*awdl_socket, GetOutputStream())
+ .WillRepeatedly(ReturnRef(mock_output_stream_));
+ return awdl_socket;
+ })
+ .WillRepeatedly([]() {
+ absl::SleepFor(absl::Seconds(5));
+ return nullptr;
+ });
+
+ EXPECT_CALL(*awdl_medium_mock, ListenForService(_, 0))
+ .WillOnce(Return(ByMove(std::move(awdl_server_socket))));
+ EXPECT_CALL(*awdl_medium_mock, StartAdvertising(_)).WillOnce(Return(true));
+
+ CountDownLatch latch(1);
+ EXPECT_CALL(incoming_connection_callback_, Call(&client, _))
+ .WillOnce([&latch](ClientProxy* client,
+ std::unique_ptr
+ connection) { latch.CountDown(); });
+
+ ByteArray result = handler_.InitializeUpgradedMediumForEndpoint(
+ &client, std::string(kServiceId), std::string(kEndpointId));
+ EXPECT_FALSE(result.Empty());
+
+ auto await_result = latch.Await(absl::Seconds(5));
+ EXPECT_TRUE(await_result.ok());
+
+ handler_.RevertInitiatorState();
+ MediumEnvironment::Instance().Stop();
+}
+
+TEST_F(AwdlBwuHandlerTest, AwdlIncomingSocket_ToStringAndClose) {
+ MediumEnvironment::Instance().Start({.use_simulated_clock = true});
+ ClientProxy client(&mock_event_logger_);
+ client.AddCancellationFlag(std::string(kEndpointId));
+
+ auto awdl_server_socket = std::make_unique();
+ auto* awdl_server_socket_ptr = awdl_server_socket.get();
+ EXPECT_CALL(*awdl_server_socket_ptr, Close())
+ .WillRepeatedly(Return(Exception{Exception::kSuccess}));
+ EXPECT_CALL(*awdl_server_socket_ptr, Accept())
+ .WillOnce([this]() {
+ auto awdl_socket = std::make_unique();
+ EXPECT_CALL(*awdl_socket, GetInputStream())
+ .WillRepeatedly(ReturnRef(mock_input_stream_));
+ EXPECT_CALL(*awdl_socket, GetOutputStream())
+ .WillRepeatedly(ReturnRef(mock_output_stream_));
+ EXPECT_CALL(*awdl_socket, Close())
+ .WillOnce(Return(Exception{Exception::kSuccess}));
+ return awdl_socket;
+ })
+ .WillRepeatedly([]() {
+ absl::SleepFor(absl::Seconds(5));
+ return nullptr;
+ });
+
+ EXPECT_CALL(*awdl_medium_mock, ListenForService(_, 0))
+ .WillOnce(Return(ByMove(std::move(awdl_server_socket))));
+ EXPECT_CALL(*awdl_medium_mock, StartAdvertising(_)).WillOnce(Return(true));
+
+ CountDownLatch latch(1);
+ EXPECT_CALL(incoming_connection_callback_, Call(&client, _))
+ .WillOnce([&latch](ClientProxy* client,
+ std::unique_ptr
+ connection) {
+ EXPECT_FALSE(connection->socket->ToString().empty());
+ connection->socket->Close();
+ latch.CountDown();
+ });
+
+ ByteArray result = handler_.InitializeUpgradedMediumForEndpoint(
+ &client, std::string(kServiceId), std::string(kEndpointId));
+ EXPECT_FALSE(result.Empty());
+
+ auto await_result = latch.Await(absl::Seconds(5));
+ EXPECT_TRUE(await_result.ok());
+
+ handler_.RevertInitiatorState();
+ MediumEnvironment::Instance().Stop();
+}
+
+TEST_F(AwdlBwuHandlerTest, HandleRevertInitiatorStateForService_Success) {
+ MediumEnvironment::Instance().Start({.use_simulated_clock = true});
+ ClientProxy client(&mock_event_logger_);
+ client.AddCancellationFlag(std::string(kEndpointId));
+
+ auto awdl_server_socket = std::make_unique();
+ auto* awdl_server_socket_ptr = awdl_server_socket.get();
+ EXPECT_CALL(*awdl_server_socket_ptr, Close())
+ .WillRepeatedly(Return(Exception{Exception::kSuccess}));
+ EXPECT_CALL(*awdl_server_socket_ptr, Accept()).WillRepeatedly([]() {
+ absl::SleepFor(absl::Seconds(10));
+ return nullptr;
+ });
+
+ EXPECT_CALL(*awdl_medium_mock, ListenForService(_, 0))
+ .WillOnce(Return(ByMove(std::move(awdl_server_socket))));
+ EXPECT_CALL(*awdl_medium_mock, StartAdvertising(_)).WillOnce(Return(true));
+ EXPECT_CALL(*awdl_medium_mock, StopAdvertising(_)).WillOnce(Return(true));
+
+ handler_.InitializeUpgradedMediumForEndpoint(&client, std::string(kServiceId),
+ std::string(kEndpointId));
+
+ handler_.RevertInitiatorState();
+ MediumEnvironment::Instance().Stop();
+}
+
+TEST_F(AwdlBwuHandlerTest, GetUpgradeMedium_ReturnsAwdl) {
+ auto* bwu_handler = static_cast(&handler_);
+ EXPECT_EQ(bwu_handler->GetUpgradeMedium(),
+ location::nearby::proto::connections::Medium::AWDL);
+}
+
+TEST_F(AwdlBwuHandlerTest, OnEndpointDisconnect_DoesNotCrash) {
+ ClientProxy client(&mock_event_logger_);
+ auto* bwu_handler = static_cast(&handler_);
+ // This method is a no-op, just verifying it doesn't crash.
+ bwu_handler->OnEndpointDisconnect(&client, std::string(kEndpointId));
+}
+
+class AwdlEndpointChannelTest : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ ON_CALL(*awdl_medium_mock, IsNetworkConnected())
+ .WillByDefault(Return(true));
+ mock_socket_ = std::make_unique>();
+ EXPECT_CALL(*mock_socket_, GetInputStream())
+ .WillRepeatedly(ReturnRef(mock_input_stream_));
+ EXPECT_CALL(*mock_socket_, GetOutputStream())
+ .WillRepeatedly(ReturnRef(mock_output_stream_));
+ }
+
+ std::unique_ptr> mock_socket_;
+ StrictMock mock_input_stream_;
+ StrictMock mock_output_stream_;
+ Awdl awdl_medium_;
+};
+
+TEST_F(AwdlEndpointChannelTest, CloseImpl_StopsDiscoveryIfOutgoing) {
+ EXPECT_CALL(*mock_socket_, Close())
+ .WillOnce(Return(Exception{Exception::kSuccess}));
+ EXPECT_CALL(mock_input_stream_, Close())
+ .WillOnce(Return(Exception{Exception::kSuccess}));
+ EXPECT_CALL(mock_output_stream_, Close())
+ .WillOnce(Return(Exception{Exception::kSuccess}));
+ EXPECT_CALL(*awdl_medium_mock, StartDiscovery(_, _)).WillOnce(Return(true));
+ EXPECT_CALL(*awdl_medium_mock, StopDiscovery(_)).WillOnce(Return(true));
+ awdl_medium_.StartDiscovery(std::string(kServiceId), {});
+
+ AwdlEndpointChannel channel(
+ std::string(kServiceId), std::string(kChannelName),
+ AwdlSocket(std::move(mock_socket_)), &awdl_medium_,
+ /*is_outgoing=*/true);
+
+ channel.Close(location::nearby::proto::connections::DisconnectionReason::
+ UNKNOWN_DISCONNECTION_REASON);
+}
+
+TEST_F(AwdlEndpointChannelTest, CloseImpl_DoesNotStopDiscoveryIfIncoming) {
+ EXPECT_CALL(*mock_socket_, Close())
+ .WillOnce(Return(Exception{Exception::kSuccess}));
+ EXPECT_CALL(mock_input_stream_, Close())
+ .WillOnce(Return(Exception{Exception::kSuccess}));
+ EXPECT_CALL(mock_output_stream_, Close())
+ .WillOnce(Return(Exception{Exception::kSuccess}));
+
+ AwdlEndpointChannel channel(
+ std::string(kServiceId), std::string(kChannelName),
+ AwdlSocket(std::move(mock_socket_)), &awdl_medium_,
+ /*is_outgoing=*/false);
+
+ channel.Close(location::nearby::proto::connections::DisconnectionReason::
+ UNKNOWN_DISCONNECTION_REASON);
+}
+
+TEST_F(AwdlEndpointChannelTest, EnableMultiplexSocket_CallsSocket) {
+ AwdlEndpointChannel channel(
+ std::string(kServiceId), std::string(kChannelName),
+ AwdlSocket(std::move(mock_socket_)), &awdl_medium_,
+ /*is_outgoing=*/true);
+
+ EXPECT_TRUE(channel.EnableMultiplexSocket());
+}
+
+} // namespace
+} // namespace connections
+namespace api {
+
+std::unique_ptr ImplementationPlatform::CreateAwdlMedium() {
+ auto medium = std::make_unique();
+ awdl_medium_mock = medium.get();
+ return medium;
+}
+
+} // namespace api
+} // namespace nearby
diff --git a/connections/implementation/base_bwu_handler.cc b/connections/implementation/base_bwu_handler.cc
index 15f14aa2..29dbb8f0 100644
--- a/connections/implementation/base_bwu_handler.cc
+++ b/connections/implementation/base_bwu_handler.cc
@@ -20,7 +20,6 @@
#include "connections/implementation/client_proxy.h"
#include "connections/implementation/service_id_constants.h"
-#include "internal/platform/byte_array.h"
#include "internal/platform/logging.h"
namespace nearby {
@@ -30,16 +29,16 @@ BaseBwuHandler::BaseBwuHandler(
IncomingConnectionCallback incoming_connection_callback)
: incoming_connection_callback_(std::move(incoming_connection_callback)) {}
-ByteArray BaseBwuHandler::InitializeUpgradedMediumForEndpoint(
+std::string BaseBwuHandler::InitializeUpgradedMediumForEndpoint(
ClientProxy* client, const std::string& service_id,
const std::string& endpoint_id) {
std::string upgrade_service_id = WrapInitiatorUpgradeServiceId(service_id);
// Perform any medium-specific handling in the child class.
- ByteArray upgrade_path_available_frame =
+ std::string upgrade_path_available_frame =
HandleInitializeUpgradedMediumForEndpoint(client, upgrade_service_id,
endpoint_id);
- if (!upgrade_path_available_frame.Empty()) {
+ if (!upgrade_path_available_frame.empty()) {
upgrade_service_id_to_active_endpoint_ids_[upgrade_service_id].insert(
endpoint_id);
}
diff --git a/connections/implementation/base_bwu_handler.h b/connections/implementation/base_bwu_handler.h
index 3f8e40ad..d95aacd8 100644
--- a/connections/implementation/base_bwu_handler.h
+++ b/connections/implementation/base_bwu_handler.h
@@ -22,7 +22,6 @@
#include "absl/container/flat_hash_set.h"
#include "connections/implementation/bwu_handler.h"
#include "connections/implementation/client_proxy.h"
-#include "internal/platform/byte_array.h"
namespace nearby {
namespace connections {
@@ -35,7 +34,7 @@ class BaseBwuHandler : public BwuHandler {
IncomingConnectionCallback incoming_connection_callback);
// BwuHandler implementation:
- ByteArray InitializeUpgradedMediumForEndpoint(
+ std::string InitializeUpgradedMediumForEndpoint(
ClientProxy* client, const std::string& service_id,
const std::string& endpoint_id) final;
void RevertInitiatorState() final;
@@ -51,7 +50,7 @@ class BaseBwuHandler : public BwuHandler {
// respectively, to handle medium-specific logic.
// HandleRevertInitiatorStateForService is only invoked after the last
// endpoint for the service is reverted.
- virtual ByteArray HandleInitializeUpgradedMediumForEndpoint(
+ virtual std::string HandleInitializeUpgradedMediumForEndpoint(
ClientProxy* client, const std::string& upgrade_service_id,
const std::string& endpoint_id) = 0;
virtual void HandleRevertInitiatorStateForService(
diff --git a/connections/implementation/base_bwu_handler_test.cc b/connections/implementation/base_bwu_handler_test.cc
index da3f87ab..a8c8c0be 100644
--- a/connections/implementation/base_bwu_handler_test.cc
+++ b/connections/implementation/base_bwu_handler_test.cc
@@ -24,7 +24,6 @@
#include "connections/implementation/client_proxy.h"
#include "connections/implementation/endpoint_channel.h"
#include "connections/implementation/service_id_constants.h"
-#include "internal/platform/byte_array.h"
#include "internal/platform/expected.h"
namespace nearby {
@@ -55,8 +54,8 @@ class BwuHandlerImpl : public BaseBwuHandler {
const std::vector& handle_revert_calls() const {
return handle_revert_calls_;
}
- void set_handle_initialize_output(ByteArray bytes) {
- handle_initialize_output_ = bytes;
+ void set_handle_initialize_output(absl::string_view bytes) {
+ handle_initialize_output_ = std::string(bytes);
}
private:
@@ -73,7 +72,7 @@ class BwuHandlerImpl : public BaseBwuHandler {
const std::string& endpoint_id) final {}
// BaseBwuHandler implementation:
- ByteArray HandleInitializeUpgradedMediumForEndpoint(
+ std::string HandleInitializeUpgradedMediumForEndpoint(
ClientProxy* client, const std::string& upgrade_service_id,
const std::string& endpoint_id) final {
handle_initialize_calls_.push_back({.client = client,
@@ -86,7 +85,7 @@ class BwuHandlerImpl : public BaseBwuHandler {
handle_revert_calls_.push_back({.service_id = upgrade_service_id});
}
- ByteArray handle_initialize_output_;
+ std::string handle_initialize_output_;
std::vector handle_initialize_calls_;
std::vector handle_revert_calls_;
};
@@ -95,7 +94,7 @@ TEST(BaseBwuHandlerTest, InitializeAndRevert) {
ClientProxy client;
BwuHandlerImpl handler;
- ByteArray expected_output{"not empty"};
+ absl::string_view expected_output{"not empty"};
handler.set_handle_initialize_output(expected_output);
// Initialize two upgrade endpoints for service A and one for service B.
@@ -150,7 +149,7 @@ TEST(BaseBwuHandlerTest, InitializeAndRevertAll) {
ClientProxy client;
BwuHandlerImpl handler;
- ByteArray expected_output{"not empty"};
+ absl::string_view expected_output{"not empty"};
handler.set_handle_initialize_output(expected_output);
handler.InitializeUpgradedMediumForEndpoint(&client, /*service_id=*/"A",
@@ -169,7 +168,7 @@ TEST(BaseBwuHandlerTest, Initialize_Failure_EmptyUpgradePathAvailableFrame) {
ClientProxy client;
BwuHandlerImpl handler;
- ByteArray expected_output{};
+ absl::string_view expected_output{};
handler.set_handle_initialize_output(expected_output);
handler.InitializeUpgradedMediumForEndpoint(&client, /*service_id=*/"A",
@@ -191,7 +190,7 @@ TEST(BaseBwuHandlerTest, Initialize_StillWorkWithUpgradeServiceIdSuffix) {
ClientProxy client;
BwuHandlerImpl handler;
- ByteArray expected_output{"not empty"};
+ absl::string_view expected_output{"not empty"};
handler.set_handle_initialize_output(expected_output);
// The method should be robust and not add _another_ upgrade suffix
@@ -208,7 +207,7 @@ TEST(BaseBwuHandlerTest, Revert_Failure_CantFindService) {
ClientProxy client;
BwuHandlerImpl handler;
- ByteArray expected_output{"not empty"};
+ absl::string_view expected_output{"not empty"};
handler.set_handle_initialize_output(expected_output);
handler.InitializeUpgradedMediumForEndpoint(&client, /*service_id=*/"A",
/*endpoint_id=*/"1");
@@ -222,7 +221,7 @@ TEST(BaseBwuHandlerTest, Revert_Failure_CantFindEndpoint) {
ClientProxy client;
BwuHandlerImpl handler;
- ByteArray expected_output{"not empty"};
+ absl::string_view expected_output{"not empty"};
handler.set_handle_initialize_output(expected_output);
handler.InitializeUpgradedMediumForEndpoint(&client, /*service_id=*/"A",
/*endpoint_id=*/"1");
diff --git a/connections/implementation/base_endpoint_channel.cc b/connections/implementation/base_endpoint_channel.cc
index 0687d7be..05e4a303 100644
--- a/connections/implementation/base_endpoint_channel.cc
+++ b/connections/implementation/base_endpoint_channel.cc
@@ -40,15 +40,13 @@
#include "internal/platform/mutex_lock.h"
#include "internal/platform/output_stream.h"
-namespace nearby {
-namespace connections {
+namespace nearby::connections {
namespace {
-using ::location::nearby::analytics::proto::ConnectionsLog;
using ::location::nearby::proto::connections::Medium::BLE;
using ::location::nearby::proto::connections::Medium::BLE_L2CAP;
-using DisconnectionReason =
- ::location::nearby::proto::connections::DisconnectionReason;
+using ::nearby::analytics::SafeDisconnectionResult;
+using ::location::nearby::proto::connections::DisconnectionReason;
Exception WriteInt(OutputStream* writer, std::int32_t value) {
return Base64Utils::WriteInt(writer, value);
@@ -92,21 +90,18 @@ BaseEndpointChannel::BaseEndpointChannel(
try_count_(try_count) {}
ExceptionOr BaseEndpointChannel::Read() {
- PacketMetaData packet_meta_data;
- return Read(packet_meta_data);
-}
-
-ExceptionOr BaseEndpointChannel::Read(
- PacketMetaData& packet_meta_data) {
ByteArray result;
{
MutexLock lock(&reader_mutex_);
- packet_meta_data.StartSocketIo();
ExceptionOr read_int;
+ // currently there's not way to have both kRefactorBleL2cap flag working AND
+ // have mediums other than ble_l2cap working. upstream may change this in the future
+ //
+ // So we have to explicitly add a condition to skip this pathway when medium is l2cap
if (NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_connections_feature::
- kRefactorBleL2cap)) {
+ kRefactorBleL2cap) && GetMedium() == BLE_L2CAP) {
ExceptionOr read_control_block_bytes = DispatchPacket();
if (!read_control_block_bytes.ok()) {
LOG(WARNING) << __func__ << ": Failed to dispatch packet: "
@@ -133,8 +128,6 @@ ExceptionOr BaseEndpointChannel::Read(
if (!read_bytes.ok()) {
return read_bytes;
}
- packet_meta_data.StopSocketIo();
- packet_meta_data.SetPacketSize(read_int.result() + sizeof(std::int32_t));
result = std::move(read_bytes.result());
}
@@ -144,7 +137,6 @@ ExceptionOr BaseEndpointChannel::Read(
if (IsEncryptionEnabledLocked()) {
// If encryption is enabled, decode the message.
std::string input(std::move(result));
- packet_meta_data.StartEncryption();
std::unique_ptr decrypted_data =
crypto_context_->DecodeMessageFromPeer(input);
if (decrypted_data) {
@@ -157,7 +149,7 @@ ExceptionOr BaseEndpointChannel::Read(
// and let it through if it is, otherwise message is erased.
// TODO(apolyudov): verify this happens at most once per session.
result = {};
- auto parsed = parser::FromBytes(ByteArray(input));
+ auto parsed = parser::FromBytes(input);
if (parsed.ok()) {
if (parser::GetFrameType(parsed.result()) ==
location::nearby::connections::V1Frame::KEEP_ALIVE) {
@@ -175,7 +167,6 @@ ExceptionOr BaseEndpointChannel::Read(
<< ": Unable to parse data as unencrypted message.";
}
}
- packet_meta_data.StopEncryption();
if (result.Empty()) {
LOG(WARNING) << __func__ << ": Unable to parse read result.";
return ExceptionOr(message_exception);
@@ -190,13 +181,7 @@ ExceptionOr BaseEndpointChannel::Read(
return ExceptionOr(result);
}
-Exception BaseEndpointChannel::Write(const ByteArray& data) {
- PacketMetaData packet_meta_data;
- return Write(data.AsStringView(), packet_meta_data);
-}
-
-Exception BaseEndpointChannel::Write(absl::string_view data,
- PacketMetaData& packet_meta_data) {
+Exception BaseEndpointChannel::Write(absl::string_view data) {
{
MutexLock pause_lock(&is_paused_mutex_);
if (is_paused_) {
@@ -217,9 +202,7 @@ Exception BaseEndpointChannel::Write(absl::string_view data,
MutexLock crypto_lock(&crypto_mutex_);
if (IsEncryptionEnabledLocked()) {
// If encryption is enabled, encode the message.
- packet_meta_data.StartEncryption();
encrypted = crypto_context_->EncodeMessageToPeer(data);
- packet_meta_data.StopEncryption();
if (!encrypted) {
LOG(WARNING) << __func__ << ": Failed to encrypt data.";
return {Exception::kIo};
@@ -235,7 +218,6 @@ Exception BaseEndpointChannel::Write(absl::string_view data,
return {Exception::kIo};
}
- packet_meta_data.StartSocketIo();
Exception write_exception;
if (NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_connections_feature::
@@ -262,8 +244,6 @@ Exception BaseEndpointChannel::Write(absl::string_view data,
<< ": Failed to flush writer: " << flush_exception.value;
return flush_exception;
}
- packet_meta_data.StopSocketIo();
- packet_meta_data.SetPacketSize(data_size + sizeof(std::uint32_t));
}
{
@@ -326,7 +306,7 @@ void BaseEndpointChannel::SetAnalyticsRecorder(
void BaseEndpointChannel::Close(
location::nearby::proto::connections::DisconnectionReason reason) {
- Close(reason, ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
+ Close(reason, SafeDisconnectionResult::kSafeDisconnection);
}
void BaseEndpointChannel::Close(
@@ -490,5 +470,4 @@ std::unique_ptr BaseEndpointChannel::EncodeMessageForTests(
return crypto_context_->EncodeMessageToPeer(data);
}
-} // namespace connections
-} // namespace nearby
+} // namespace nearby::connections
diff --git a/connections/implementation/base_endpoint_channel.h b/connections/implementation/base_endpoint_channel.h
index 9946b9fa..421a8a9f 100644
--- a/connections/implementation/base_endpoint_channel.h
+++ b/connections/implementation/base_endpoint_channel.h
@@ -23,7 +23,6 @@
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "connections/implementation/analytics/analytics_recorder.h"
-#include "connections/implementation/analytics/packet_meta_data.h"
#include "connections/implementation/endpoint_channel.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/condition_variable.h"
@@ -32,10 +31,7 @@
#include "internal/platform/mutex.h"
#include "internal/platform/output_stream.h"
-namespace nearby {
-namespace connections {
-
-using analytics::PacketMetaData;
+namespace nearby::connections {
class BaseEndpointChannel : public EndpointChannel {
public:
@@ -51,20 +47,16 @@ class BaseEndpointChannel : public EndpointChannel {
~BaseEndpointChannel() override = default;
// EndpointChannel:
- ExceptionOr Read() override;
- ExceptionOr Read(PacketMetaData& packet_meta_data)
+ ExceptionOr Read()
ABSL_LOCKS_EXCLUDED(reader_mutex_, crypto_mutex_,
last_read_mutex_) override;
- Exception Write(const ByteArray& data) override;
- Exception Write(absl::string_view data, PacketMetaData& packet_meta_data)
+ Exception Write(absl::string_view data)
ABSL_LOCKS_EXCLUDED(writer_mutex_, crypto_mutex_) override;
void Close() ABSL_LOCKS_EXCLUDED(is_paused_mutex_) override;
void Close(location::nearby::proto::connections::DisconnectionReason reason)
override;
- void Close(
- location::nearby::proto::connections::DisconnectionReason reason,
- location::nearby::analytics::proto::ConnectionsLog::
- EstablishedConnection::SafeDisconnectionResult result) override;
+ void Close(location::nearby::proto::connections::DisconnectionReason reason,
+ nearby::analytics::SafeDisconnectionResult result) override;
bool IsClosed() const ABSL_LOCKS_EXCLUDED(is_paused_mutex_) override;
std::string GetType() const override;
std::string GetServiceId() const override;
@@ -176,7 +168,6 @@ class BaseEndpointChannel : public EndpointChannel {
std::string endpoint_id_ = "";
};
-} // namespace connections
-} // namespace nearby
+} // namespace nearby::connections
#endif // CORE_INTERNAL_BASE_ENDPOINT_CHANNEL_H_
diff --git a/connections/implementation/base_endpoint_channel_test.cc b/connections/implementation/base_endpoint_channel_test.cc
index a1bad6e0..1e3cbbde 100644
--- a/connections/implementation/base_endpoint_channel_test.cc
+++ b/connections/implementation/base_endpoint_channel_test.cc
@@ -108,20 +108,26 @@ std::function MakeDataMonitor(const std::string& label,
std::pair,
std::shared_ptr>
-DoDhKeyExchange(BaseEndpointChannel* channel_a,
- BaseEndpointChannel* channel_b) {
+DoDhKeyExchange(std::shared_ptr channel_a,
+ std::shared_ptr channel_b) {
std::shared_ptr context_a;
std::shared_ptr context_b;
EncryptionRunner crypto_a;
EncryptionRunner crypto_b;
ClientProxy proxy_a;
ClientProxy proxy_b;
- CountDownLatch latch(2);
+ std::shared_ptr shared_channel_a = channel_a;
+ std::shared_ptr shared_channel_b = channel_b;
+
+ // Create a shared_ptr for the latch to prevent Use-After-Free if the
+ // negotiation times out and this function returns early.
+ auto latch = std::make_shared(2);
+
crypto_a.StartClient(
- &proxy_a, "endpoint_id", channel_a,
+ &proxy_a, "endpoint_id", shared_channel_a,
{
.on_success_cb =
- [&latch, &context_a](
+ [latch, &context_a](
const std::string& endpoint_id,
std::unique_ptr ukey2,
const std::string& auth_token,
@@ -131,20 +137,19 @@ DoDhKeyExchange(BaseEndpointChannel* channel_a,
auto context = ukey2->ToConnectionContext();
EXPECT_NE(context, nullptr);
context_a = std::move(context);
- latch.CountDown();
+ latch->CountDown();
},
.on_failure_cb =
- [&latch](const std::string& endpoint_id,
- EndpointChannel* channel) {
+ [latch](const std::string& endpoint_id) {
LOG(INFO) << "client-A side key negotiation failed";
- latch.CountDown();
+ latch->CountDown();
},
});
crypto_b.StartServer(
- &proxy_b, "endpoint_id", channel_b,
+ &proxy_b, "endpoint_id", shared_channel_b,
{
.on_success_cb =
- [&latch, &context_b](
+ [latch, &context_b](
const std::string& endpoint_id,
std::unique_ptr ukey2,
const std::string& auth_token,
@@ -154,16 +159,15 @@ DoDhKeyExchange(BaseEndpointChannel* channel_a,
auto context = ukey2->ToConnectionContext();
EXPECT_NE(context, nullptr);
context_b = std::move(context);
- latch.CountDown();
+ latch->CountDown();
},
.on_failure_cb =
- [&latch](const std::string& endpoint_id,
- EndpointChannel* channel) {
+ [latch](const std::string& endpoint_id) {
LOG(INFO) << "client-B side key negotiation failed";
- latch.CountDown();
+ latch->CountDown();
},
});
- EXPECT_TRUE(latch.Await(absl::Milliseconds(5000)).result());
+ EXPECT_TRUE(latch->Await(absl::Milliseconds(5000)).result());
return std::make_pair(std::move(context_a), std::move(context_b));
}
@@ -174,7 +178,7 @@ class BaseEndpointChannelTest : public ::testing::Test {
NearbyFlags::GetInstance().ResetOverridedValues();
}
- const ByteArray kTestData{"test_data"};
+ const absl::string_view kTestData = "test_data";
};
TEST_F(BaseEndpointChannelTest, ReadSucceedsWhenFlagDisabled) {
@@ -189,7 +193,7 @@ TEST_F(BaseEndpointChannelTest, ReadSucceedsWhenFlagDisabled) {
channel_a.Write(kTestData);
ByteArray rx_message = std::move(channel_b.Read().result());
- EXPECT_EQ(rx_message, kTestData);
+ EXPECT_EQ(rx_message.AsStringView(), kTestData);
}
TEST_F(BaseEndpointChannelTest, ReadCallsDispatchPacketWhenFlagEnabled) {
@@ -203,13 +207,14 @@ TEST_F(BaseEndpointChannelTest, ReadCallsDispatchPacketWhenFlagEnabled) {
TestEndpointChannel channel_b(pipe_a.first.get(), pipe_b.second.get());
EXPECT_CALL(channel_b, DispatchPacket)
- .WillOnce(::testing::Return(ExceptionOr(kTestData)));
+ .WillOnce(::testing::Return(
+ ExceptionOr(ByteArray(std::string(kTestData)))));
channel_a.Write(kTestData);
auto read_byte = channel_b.Read();
EXPECT_TRUE(read_byte.ok());
- EXPECT_EQ(read_byte.result(), kTestData);
+ EXPECT_EQ(read_byte.result().AsStringView(), kTestData);
}
TEST_F(BaseEndpointChannelTest,
@@ -243,10 +248,10 @@ TEST_F(BaseEndpointChannelTest, ReadWrite) {
auto pipe_b = CreatePipe(); // channel_b writes to pipe_b, reads from pipe_a.
TestEndpointChannel channel_a(pipe_b.first.get(), pipe_a.second.get());
TestEndpointChannel channel_b(pipe_a.first.get(), pipe_b.second.get());
- ByteArray tx_message{"data message"};
+ absl::string_view tx_message = "data message";
channel_a.Write(tx_message);
ByteArray rx_message = std::move(channel_b.Read().result());
- EXPECT_EQ(rx_message, tx_message);
+ EXPECT_EQ(rx_message.AsStringView(), tx_message);
}
TEST_F(BaseEndpointChannelTest, ChannelUnencryptedByDefault) {
@@ -264,20 +269,22 @@ TEST_F(BaseEndpointChannelTest, TryDecrypt) {
absl::string_view kMessage = "message";
auto pipe_a = CreatePipe(); // channel_a writes to pipe_a, reads from pipe_b.
auto pipe_b = CreatePipe(); // channel_b writes to pipe_b, reads from pipe_a.
- TestEndpointChannel channel_a(pipe_b.first.get(), pipe_a.second.get());
- TestEndpointChannel channel_b(pipe_a.first.get(), pipe_b.second.get());
- auto [context_a, context_b] = DoDhKeyExchange(&channel_a, &channel_b);
+ auto channel_a = std::make_shared(pipe_b.first.get(),
+ pipe_a.second.get());
+ auto channel_b = std::make_shared(pipe_a.first.get(),
+ pipe_b.second.get());
+ auto [context_a, context_b] = DoDhKeyExchange(channel_a, channel_b);
ASSERT_NE(context_a, nullptr);
ASSERT_NE(context_b, nullptr);
- channel_a.EnableEncryption(context_a);
- channel_b.EnableEncryption(context_b);
+ channel_a->EnableEncryption(context_a);
+ channel_b->EnableEncryption(context_b);
std::unique_ptr encrypted_message =
- channel_a.EncodeMessageForTests(kMessage);
+ channel_a->EncodeMessageForTests(kMessage);
ExceptionOr decrypted_message =
- channel_b.TryDecrypt(ByteArray(*encrypted_message));
+ channel_b->TryDecrypt(ByteArray(*encrypted_message));
- EXPECT_TRUE(channel_b.IsEncrypted());
+ EXPECT_TRUE(channel_b->IsEncrypted());
EXPECT_TRUE(decrypted_message.ok());
EXPECT_EQ(decrypted_message.result().AsStringView(), kMessage);
}
@@ -285,16 +292,18 @@ TEST_F(BaseEndpointChannelTest, TryDecrypt) {
TEST_F(BaseEndpointChannelTest, TryDecryptFailsWhenDecryptionFails) {
auto pipe_a = CreatePipe(); // channel_a writes to pipe_a, reads from pipe_b.
auto pipe_b = CreatePipe(); // channel_b writes to pipe_b, reads from pipe_a.
- TestEndpointChannel channel_a(pipe_b.first.get(), pipe_a.second.get());
- TestEndpointChannel channel_b(pipe_a.first.get(), pipe_b.second.get());
- auto [context_a, context_b] = DoDhKeyExchange(&channel_a, &channel_b);
+ auto channel_a = std::make_shared(pipe_b.first.get(),
+ pipe_a.second.get());
+ auto channel_b = std::make_shared(pipe_a.first.get(),
+ pipe_b.second.get());
+ auto [context_a, context_b] = DoDhKeyExchange(channel_a, channel_b);
ASSERT_NE(context_a, nullptr);
- channel_a.EnableEncryption(context_a);
+ channel_a->EnableEncryption(context_a);
ExceptionOr result =
- channel_a.TryDecrypt(ByteArray("invalid message"));
+ channel_a->TryDecrypt(ByteArray("invalid message"));
- EXPECT_TRUE(channel_a.IsEncrypted());
+ EXPECT_TRUE(channel_a->IsEncrypted());
EXPECT_FALSE(result.ok());
EXPECT_EQ(result.exception(), Exception::kExecution);
}
@@ -332,12 +341,12 @@ TEST_F(BaseEndpointChannelTest, NotEncryptedReadWriteCanBeIntercepted) {
EXPECT_EQ(channel_b.GetType(), "BLE");
// Start data transfer
- ByteArray tx_message{"data message"};
+ absl::string_view tx_message = "data message";
channel_a.Write(tx_message);
ByteArray rx_message = std::move(channel_b.Read().result());
// Verify expectations.
- EXPECT_EQ(rx_message, tx_message);
+ EXPECT_EQ(rx_message.AsStringView(), tx_message);
{
absl::MutexLock lock(mutex);
std::string message{tx_message};
@@ -365,13 +374,15 @@ TEST_F(BaseEndpointChannelTest, EncryptedReadWriteCanNotBeIntercepted) {
// to server "b".
auto server_b = CreatePipe(); // Data pump "b" reads from client "b", writes
// to server "a".
- TestEndpointChannel channel_a(server_a.first.get(), client_a.second.get());
- TestEndpointChannel channel_b(server_b.first.get(), client_b.second.get());
+ auto channel_a = std::make_shared(server_a.first.get(),
+ client_a.second.get());
+ auto channel_b = std::make_shared(server_b.first.get(),
+ client_b.second.get());
- ON_CALL(channel_a, GetMedium).WillByDefault([]() {
+ ON_CALL(*channel_a, GetMedium).WillByDefault([]() {
return Medium::BLUETOOTH;
});
- ON_CALL(channel_b, GetMedium).WillByDefault([]() {
+ ON_CALL(*channel_b, GetMedium).WillByDefault([]() {
return Medium::BLUETOOTH;
});
@@ -384,24 +395,24 @@ TEST_F(BaseEndpointChannelTest, EncryptedReadWriteCanNotBeIntercepted) {
MakeDataMonitor("monitor_b", &capture_b, &mutex)));
// Run DH key exchange; setup encryption contexts for channels.
- auto [context_a, context_b] = DoDhKeyExchange(&channel_a, &channel_b);
+ auto [context_a, context_b] = DoDhKeyExchange(channel_a, channel_b);
ASSERT_NE(context_a, nullptr);
ASSERT_NE(context_b, nullptr);
- channel_a.EnableEncryption(context_a);
- channel_b.EnableEncryption(context_b);
+ channel_a->EnableEncryption(context_a);
+ channel_b->EnableEncryption(context_b);
- EXPECT_EQ(channel_a.GetType(), "ENCRYPTED_BLUETOOTH");
- EXPECT_EQ(channel_b.GetType(), "ENCRYPTED_BLUETOOTH");
- EXPECT_TRUE(channel_a.IsEncrypted());
- EXPECT_TRUE(channel_b.IsEncrypted());
+ EXPECT_EQ(channel_a->GetType(), "ENCRYPTED_BLUETOOTH");
+ EXPECT_EQ(channel_b->GetType(), "ENCRYPTED_BLUETOOTH");
+ EXPECT_TRUE(channel_a->IsEncrypted());
+ EXPECT_TRUE(channel_b->IsEncrypted());
// Start data transfer
- ByteArray tx_message{"data message"};
- channel_a.Write(tx_message);
- ByteArray rx_message = std::move(channel_b.Read().result());
+ absl::string_view tx_message = "data message";
+ channel_a->Write(tx_message);
+ ByteArray rx_message = std::move(channel_b->Read().result());
// Verify expectations.
- EXPECT_EQ(rx_message, tx_message);
+ EXPECT_EQ(rx_message.AsStringView(), tx_message);
{
absl::MutexLock lock(mutex);
std::string message{tx_message};
@@ -410,8 +421,8 @@ TEST_F(BaseEndpointChannelTest, EncryptedReadWriteCanNotBeIntercepted) {
}
// Shutdown test environment.
- channel_a.Close(DisconnectionReason::LOCAL_DISCONNECTION);
- channel_b.Close(DisconnectionReason::REMOTE_DISCONNECTION);
+ channel_a->Close(DisconnectionReason::LOCAL_DISCONNECTION);
+ channel_b->Close(DisconnectionReason::REMOTE_DISCONNECTION);
}
TEST_F(BaseEndpointChannelTest, CanBesuspendedAndResumed) {
@@ -432,8 +443,8 @@ TEST_F(BaseEndpointChannelTest, CanBesuspendedAndResumed) {
EXPECT_EQ(channel_b.GetType(), "WIFI_LAN");
// Start data transfer
- ByteArray tx_message{"data message"};
- ByteArray more_message{"more data"};
+ absl::string_view tx_message = "data message";
+ absl::string_view more_message = "more data";
channel_a.Write(tx_message);
ByteArray rx_message = std::move(channel_b.Read().result());
@@ -459,7 +470,7 @@ TEST_F(BaseEndpointChannelTest, CanBesuspendedAndResumed) {
// Resume; verify that data transfer comepleted.
channel_a.Resume();
EXPECT_TRUE(latch.Await(absl::Milliseconds(1000)).result());
- EXPECT_EQ(read_more, more_message);
+ EXPECT_EQ(read_more.AsStringView(), more_message);
// Shutdown test environment.
channel_a.Close(DisconnectionReason::LOCAL_DISCONNECTION);
@@ -485,43 +496,45 @@ TEST_F(BaseEndpointChannelTest, ReadUnencryptedFrameOnEncryptedChannel) {
// Setup test communication environment.
auto pipe_a = CreatePipe(); // channel_a writes to pipe_a, reads from pipe_b.
auto pipe_b = CreatePipe(); // channel_b writes to pipe_b, reads from pipe_a.
- TestEndpointChannel channel_a(pipe_b.first.get(), pipe_a.second.get());
- TestEndpointChannel channel_b(pipe_a.first.get(), pipe_b.second.get());
+ auto channel_a = std::make_shared(pipe_b.first.get(),
+ pipe_a.second.get());
+ auto channel_b = std::make_shared(pipe_a.first.get(),
+ pipe_b.second.get());
- ON_CALL(channel_a, GetMedium).WillByDefault([]() {
+ ON_CALL(*channel_a, GetMedium).WillByDefault([]() {
return Medium::BLUETOOTH;
});
- ON_CALL(channel_b, GetMedium).WillByDefault([]() {
+ ON_CALL(*channel_b, GetMedium).WillByDefault([]() {
return Medium::BLUETOOTH;
});
// Run DH key exchange; setup encryption contexts for channels. But only
// encrypt |channel_b|.
- auto [context_a, context_b] = DoDhKeyExchange(&channel_a, &channel_b);
+ auto [context_a, context_b] = DoDhKeyExchange(channel_a, channel_b);
ASSERT_NE(context_a, nullptr);
ASSERT_NE(context_b, nullptr);
- channel_b.EnableEncryption(context_b);
+ channel_b->EnableEncryption(context_b);
- EXPECT_EQ(channel_a.GetType(), "BLUETOOTH");
- EXPECT_EQ(channel_b.GetType(), "ENCRYPTED_BLUETOOTH");
+ EXPECT_EQ(channel_a->GetType(), "BLUETOOTH");
+ EXPECT_EQ(channel_b->GetType(), "ENCRYPTED_BLUETOOTH");
// An unencrypted KeepAlive should succeed.
- ByteArray keep_alive_message = parser::ForKeepAlive();
- channel_a.Write(keep_alive_message);
- ExceptionOr