Merge remote-tracking branch 'nearby/main' into apply-upstream

# Conflicts:
#	MODULE.bazel
#	connections/implementation/mediums/ble_v2.cc
#	internal/platform/implementation/BUILD
This commit is contained in:
kidfromjupiter
2026-02-04 19:12:40 +00:00
1278 changed files with 930060 additions and 211365 deletions
+44
View File
@@ -0,0 +1,44 @@
# Copyright 2025 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.
name: 'Setup protobuf for swift build'
description: 'Composite action to setup protobuf for swift build'
runs:
using: "composite"
steps:
- name: sync protobuf repo
uses: actions/checkout@v6
with:
repository: protocolbuffers/protobuf
ref: v33.2
path: google-protobuf
- name: install protoc
run: |
brew install protobuf
protoc --version
shell: bash
- name: generate nearby proto bindings
run: |
mkdir protoc_out
protoc --cpp_out=protoc_out connections/implementation/proto/offline_wire_formats.proto internal/proto/analytics/connections_log.proto internal/proto/credential.proto internal/proto/local_credential.proto internal/proto/metadata.proto proto/errorcode/error_code_enums.proto proto/mediums/ble_frames.proto proto/mediums/multiplex_frames.proto proto/mediums/nfc_frames.proto proto/mediums/web_rtc_signaling_frames.proto proto/connections_enums.proto proto/sharing_enums.proto sharing/proto/analytics/nearby_sharing_log.proto
ls -lR protoc_out
shell: bash
- name: generate ukey2 proto bindings
run: |
cd third_party/ukey2/ukey2
mkdir protoc_out
protoc --cpp_out=protoc_out --proto_path=. --proto_path=src/main/proto src/main/proto/device_to_device_messages.proto
protoc --cpp_out=protoc_out src/main/proto/securegcm.proto src/main/proto/securemessage.proto src/main/proto/ukey.proto
ls -lR protoc_out
shell: bash
+8 -10
View File
@@ -24,7 +24,8 @@ jobs:
name: Build Swift
runs-on: macOS-latest
steps:
- uses: actions/checkout@v3
- name: sync repo
uses: actions/checkout@v6
with:
submodules: true
- name: Build
@@ -34,7 +35,7 @@ jobs:
name: Test Swift
runs-on: macOS-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
with:
submodules: true
- name: Test
@@ -44,21 +45,18 @@ jobs:
name: Build Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Build Connections
run: CC=clang-16 CXX=clang-16++ bazel build --proto_compiler=@com_github_protobuf_prebuilt//:protoc --copt='-DGITHUB_BUILD' //connections:core
- name: Build Presence
run: CC=clang-16 CXX=clang-16++ bazel build --proto_compiler=@com_github_protobuf_prebuilt//:protoc --copt='-DGITHUB_BUILD' //presence
- name: Build Sharing
run: CC=clang-16 CXX=clang-16++ bazel build --proto_compiler=@com_github_protobuf_prebuilt//:protoc --verbose_failures --copt='-DGITHUB_BUILD' //sharing/proto/... //sharing/analytics
run: CC=clang-18 CXX=clang-18++ BAZEL_CXXOPTS="-std=c++20" bazel build --@com_google_protobuf//bazel/toolchains:prefer_prebuilt_protoc=true --copt='-DGITHUB_BUILD' //connections:core
# - name: Build Presence
# run: CC=clang-18 CXX=clang-18++ BAZEL_CXXOPTS="-std=c++20" bazel build --@com_google_protobuf//bazel/toolchains:prefer_prebuilt_protoc=true --copt='-DGITHUB_BUILD' //presence
build-rust-linux:
name: Build Rust on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Build FPP
run: cargo build --manifest-path presence/fpp/fpp/Cargo.toml
-30
View File
@@ -1,42 +1,12 @@
[submodule "third_party/protobuf"]
path = third_party/protobuf
url = https://github.com/protocolbuffers/protobuf
branch = 3.19.x
[submodule "third_party/gtest"]
path = third_party/gtest
url = https://github.com/google/googletest
branch = main
[submodule "third_party/absl"]
path = third_party/absl
url = https://github.com/abseil/abseil-cpp
branch = master
[submodule "third_party/depot_tools"]
path = third_party/depot_tools
url = https://chromium.googlesource.com/chromium/tools/depot_tools.git
branch = main
[submodule "third_party/ukey2/ukey2"]
path = third_party/ukey2/ukey2
url = https://github.com/google/ukey2
branch = master
[submodule "third_party/smhasher/smhasher"]
path = third_party/smhasher/smhasher
url = https://github.com/aappleby/smhasher
branch = master
[submodule "third_party/securemessage/securemessage"]
path = third_party/securemessage/securemessage
url = https://github.com/google/securemessage.git
branch = master
[submodule "third_party/google-toolbox-for-mac/google-toolbox-for-mac"]
path = third_party/google-toolbox-for-mac/google-toolbox-for-mac
url = https://github.com/google/google-toolbox-for-mac.git
branch = main
[submodule "third_party/mbedtls"]
path = third_party/mbedtls
url = https://github.com/ARMmbed/mbedtls
[submodule "third_party/json/json"]
path = third_party/json/json
url = https://github.com/nlohmann/json
branch = master
[submodule "third_party/micro-ecc"]
path = third_party/micro-ecc
url = https://github.com/kmackay/micro-ecc
+13 -22
View File
@@ -1,34 +1,23 @@
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_apple", version = "3.19.0")
bazel_dep(name = "rules_cc", version = "0.2.0")
bazel_dep(name = "rules_rust", version = "0.54.1")
bazel_dep(name = "bazel_skylib", version = "1.8.1")
bazel_dep(name = "abseil-cpp", version = "20250814.0", repo_name = "com_google_absl")
bazel_dep(name = "rules_foreign_cc", version = "0.15.0")
bazel_dep(name = "rules_apple", version = "4.3.3")
bazel_dep(name = "rules_cc", version = "0.2.16")
bazel_dep(name = "rules_rust", version = "0.68.1")
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "abseil-cpp", version = "20260107.0", repo_name = "com_google_absl")
# version of prebuilt protoc in com_github_protobuf_prebuilt must match this.
bazel_dep(name = "protobuf", version = "32.0", repo_name = "com_google_protobuf")
bazel_dep(name = "googletest", version = "1.17.0", repo_name = "com_google_googletest")
bazel_dep(name = "boringssl", version = "0.0.0-20240126-22d349c")
bazel_dep(name = "protobuf", version = "33.4", repo_name = "com_google_protobuf")
bazel_dep(name = "googletest", version = "1.17.0.bcr.2", repo_name = "com_google_googletest")
bazel_dep(name = "boringssl", version = "0.20251124.0")
git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "beto-core",
commit = "415bd032561d078720642d52e28fd3bc9d5155d4",
commit = "479289ef072b0880c0347d36937265e44f00f4ee",
remote = "https://beto-core.googlesource.com/beto-core",
)
# Hedron's Compile Commands Extractor for Bazel
# https://github.com/hedronvision/bazel-compile-commands-extractor
# Hedron's Compile Commands Extractor for Bazel
# https://github.com/hedronvision/bazel-compile-commands-extractor
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
module_name = "hedron_compile_commands",
remote = "https://github.com/mikael-s-persson/bazel-compile-commands-extractor",
commit = "02d15621b528efd877f5d5657c4b738523a0eb17"
)
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
edition = "2021",
@@ -62,6 +51,7 @@ http_archive(
http_archive(
name = "aappleby_smhasher",
build_file_content = """
load("@rules_cc//cc:cc_library.bzl", "cc_library")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "libmurmur3",
@@ -77,12 +67,13 @@ cc_library(
http_archive(
name = "nlohmann_json",
build_file_content = """
load("@rules_cc//cc:cc_library.bzl", "cc_library")
cc_library(
name = "json",
hdrs = glob([
"include/nlohmann/**/*.hpp",
]),
strip_include_prefix = "include",
includes = ["include"],
visibility = ["//visibility:public"],
alwayslink = True,
)""",
+3 -3
View File
@@ -3,10 +3,10 @@
{
"identity" : "abseil-cpp-swiftpm",
"kind" : "remoteSourceControl",
"location" : "https://github.com/bourdakos1/abseil-cpp-SwiftPM.git",
"location" : "https://github.com/firebase/abseil-cpp-SwiftPM.git",
"state" : {
"branch" : "cxx17-test",
"revision" : "f2c56293ba0c7dc4fed62c38dfea5c5c2d632166"
"branch" : "main",
"revision" : "1c50c2cd0bffe5a03cde6fe17129334dcf05071b"
}
},
{
+126 -51
View File
@@ -51,20 +51,6 @@ let package = Package(
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "google-toolbox-for-mac",
path: "third_party/google-toolbox-for-mac",
exclude: [
"google-toolbox-for-mac/AppKit",
"google-toolbox-for-mac/UnitTesting",
],
sources: ["google-toolbox-for-mac/Foundation/GTMLogger.m"],
publicHeadersPath: "include",
cSettings: [
.headerSearchPath("google-toolbox-for-mac/"),
.unsafeFlags(["-fno-objc-arc"]),
]
),
.target(
name: "smhasher",
path: "third_party/smhasher",
@@ -94,7 +80,7 @@ let package = Package(
cSettings: [
.headerSearchPath("ukey2/"),
.headerSearchPath("compiled_proto/"),
.headerSearchPath("compiled_proto/src/main/"),
.headerSearchPath("compiled_proto/src/main/proto"),
]
),
.target(
@@ -103,10 +89,30 @@ let package = Package(
sources: ["EmptySwiftPackageManagerFile.cpp"],
publicHeadersPath: "json/include"
),
.target(
name: "protobuf-utf8",
dependencies: [
.product(name: "abseil", package: "abseil-cpp-SwiftPM"),
],
path: "third_party/protobuf/third_party/utf8_range",
sources: [
"utf8_validity.h",
"utf8_range.h",
"utf8_range.c",
],
publicHeadersPath: ".",
cSettings: [
.headerSearchPath("./"),
],
),
.target(
name: "protobuf",
dependencies: [
"protobuf-utf8",
],
path: "third_party/protobuf/src",
exclude: [
"google/protobuf/bridge",
"google/protobuf/compiler",
"google/protobuf/testdata",
"google/protobuf/testing",
@@ -120,16 +126,12 @@ let package = Package(
"google/protobuf/arenastring_unittest.cc",
"google/protobuf/descriptor.proto",
"google/protobuf/reflection_ops_unittest.cc",
"google/protobuf/stubs/stringprintf_unittest.cc",
"google/protobuf/empty.proto",
"google/protobuf/map_lite_unittest.proto",
"google/protobuf/test_util_lite.cc",
"google/protobuf/any_test.cc",
"google/protobuf/stubs/structurally_valid_unittest.cc",
"google/protobuf/unittest_proto3_arena_lite.proto",
"google/protobuf/stubs/strutil_unittest.cc",
"google/protobuf/unittest_preserve_unknown_enum.proto",
"google/protobuf/arena_test_util.cc",
"google/protobuf/any_test.proto",
"google/protobuf/timestamp.proto",
"google/protobuf/io/tokenizer_unittest.cc",
@@ -142,26 +144,18 @@ let package = Package(
"google/protobuf/map_unittest.proto",
"google/protobuf/unittest_no_field_presence.proto",
"google/protobuf/unittest_proto3_arena.proto",
"google/protobuf/stubs/stringpiece_unittest.cc",
"google/protobuf/stubs/time_test.cc",
"google/protobuf/unittest_optimize_for.proto",
"google/protobuf/map_test_util.inc",
"google/protobuf/stubs/statusor_test.cc",
"google/protobuf/wire_format_unittest.inc",
"google/protobuf/repeated_field_reflection_unittest.cc",
"google/protobuf/stubs/template_util_unittest.cc",
"google/protobuf/unittest_import_public.proto",
"google/protobuf/io/printer_unittest.cc",
"google/protobuf/test_messages_proto3.proto",
"google/protobuf/io/zero_copy_stream_unittest.cc",
"google/protobuf/text_format_unittest.cc",
"google/protobuf/stubs/int128_unittest.cc",
"google/protobuf/unittest_lazy_dependencies_enum.proto",
"google/protobuf/test_messages_proto2.proto",
"google/protobuf/unittest_arena.proto",
"google/protobuf/unittest_lite.proto",
"google/protobuf/type.proto",
"google/protobuf/test_util.inc",
"google/protobuf/extension_set_unittest.cc",
"google/protobuf/preserve_unknown_enum_test.cc",
"google/protobuf/unittest_lazy_dependencies.proto",
@@ -169,11 +163,9 @@ let package = Package(
"google/protobuf/unittest_embed_optimize_for.proto",
"google/protobuf/lite_unittest.cc",
"google/protobuf/unknown_field_set_unittest.cc",
"google/protobuf/stubs/bytestream_unittest.cc",
"google/protobuf/wire_format_unittest.cc",
"google/protobuf/unittest_proto3_lite.proto",
"google/protobuf/api.proto",
"google/protobuf/stubs/status_test.cc",
"google/protobuf/generated_message_reflection_unittest.cc",
"google/protobuf/unittest_custom_options.proto",
"google/protobuf/map_field_test.cc",
@@ -189,7 +181,6 @@ let package = Package(
"google/protobuf/io/coded_stream_unittest.cc",
"google/protobuf/unittest_drop_unknown_fields.proto",
"google/protobuf/source_context.proto",
"google/protobuf/generated_message_tctable_impl.inc",
"google/protobuf/map_proto2_unittest.proto",
"google/protobuf/proto3_lite_unittest.cc",
"google/protobuf/descriptor_unittest.cc",
@@ -199,11 +190,9 @@ let package = Package(
"google/protobuf/stubs/common_unittest.cc",
"google/protobuf/arena_unittest.cc",
"google/protobuf/unittest_enormous_descriptor.proto",
"google/protobuf/map_lite_test_util.cc",
"google/protobuf/unittest_proto3.proto",
"google/protobuf/struct.proto",
"google/protobuf/unittest_preserve_unknown_enum2.proto",
"google/protobuf/io/gzip_stream_unittest.sh",
"google/protobuf/unittest_empty.proto",
"google/protobuf/port_def.inc",
"google/protobuf/dynamic_message_unittest.cc",
@@ -215,17 +204,94 @@ let package = Package(
"google/protobuf/well_known_types_unittest.cc",
"google/protobuf/map_test.inc",
"google/protobuf/reflection_tester.cc",
"google/protobuf/varint_shuffle_test.cc",
"google/protobuf/unredacted_debug_format_for_test_test.cc",
"google/protobuf/wire_format_unittest.h",
"google/protobuf/wire_format_unittest.cc",
"google/protobuf/string_view_test.cc",
"google/protobuf/string_block_test.cc",
"google/protobuf/arena_align_test.cc",
"google/protobuf/arenaz_sampler_test.cc",
"google/protobuf/debug_counter_test.cc",
"google/protobuf/descriptor_visitor_test.cc",
"google/protobuf/edition_message_unittest.cc",
"google/protobuf/feature_resolver_test.cc",
"google/protobuf/generated_enum_util_test.cc",
"google/protobuf/generated_message_tctable_lite_test.cc",
"google/protobuf/has_bits_test.cc",
"google/protobuf/internal_feature_helper_test.cc",
"google/protobuf/internal_message_util_unittest.cc",
"google/protobuf/map_probe_benchmark.cc",
"google/protobuf/map_test_util.h",
"google/protobuf/message_unittest_legacy_apis.inc",
"google/protobuf/micro_string_test.cc",
"google/protobuf/no_field_presence_map_test.cc",
"google/protobuf/port_test.cc",
"google/protobuf/raw_ptr_test.cc",
"google/protobuf/redaction_metric_test.cc",
"google/protobuf/reflection_mode_test.cc",
"google/protobuf/reflection_tester.h",
"google/protobuf/reflection_visit_fields_test.cc",
"google/protobuf/repeated_field_reflection_unittest.inc",
"google/protobuf/repeated_ptr_field_unittest.cc",
"google/protobuf/retention_test.cc",
"google/protobuf/string_piece_field_support_unittest.cc",
"google/protobuf/test_textproto.h",
"google/protobuf/test_util.h",
"google/protobuf/test_util2.h",
"google/protobuf/test_util_lite.h",
"google/protobuf/os_macros_undef.inc",
"google/protobuf/os_macros_restore.inc",
"google/protobuf/lazily_build_dependencies_test.cc",
"google/protobuf/edition_unittest.proto",
"google/protobuf/internal_options.proto",
"google/protobuf/late_loaded_option.proto",
"google/protobuf/late_loaded_option_user.proto",
"google/protobuf/map_proto3_unittest.proto",
"google/protobuf/only_one_enum_test.proto",
"google/protobuf/sample_messages_edition.proto",
"google/protobuf/cpp_features.proto",
"google/protobuf/unittest_custom_features.proto",
"google/protobuf/unittest_custom_options_unlinked.proto",
"google/protobuf/unittest_delimited.proto",
"google/protobuf/unittest_delimited_import.proto",
"google/protobuf/unittest_extension_set.proto",
"google/protobuf/unittest_features.proto",
"google/protobuf/unittest_import_option.proto",
"google/protobuf/unittest_invalid_features.proto",
"google/protobuf/unittest_legacy_features.proto",
"google/protobuf/unittest_lite_edition_2024.proto",
"google/protobuf/unittest_proto3_bad_macros.proto",
"google/protobuf/unittest_proto3_extensions.proto",
"google/protobuf/unittest_redaction.proto",
"google/protobuf/unittest_retention.proto",
"google/protobuf/unittest_string_type.proto",
"google/protobuf/unittest_string_view.proto",
"google/protobuf/BUILD.bazel",
"google/protobuf/bridge/BUILD.bazel",
"google/protobuf/io/BUILD.bazel",
"google/protobuf/json/BUILD.bazel",
"google/protobuf/stubs/BUILD.bazel",
"google/protobuf/json/BUILD.bazel",
"google/protobuf/json/json_test.cc",
"google/protobuf/json/internal/lexer_test.cc",
"google/protobuf/json/internal/zero_copy_buffered_stream_test.cc",
"google/protobuf/io/printer_death_test.cc",
"google/protobuf/io/test_zero_copy_stream.h",
"google/protobuf/io/test_zero_copy_stream_test.cc",
"google/protobuf/io/zero_copy_sink_test.cc",
],
sources: [
"google/protobuf",
],
sources: ["google/protobuf"],
publicHeadersPath: ".",
cSettings: [
.headerSearchPath("./")
.headerSearchPath("./"),
]
),
.target(
name: "NearbyCommon",
dependencies: [
"google-toolbox-for-mac",
"json",
"smhasher",
"ukey2",
@@ -244,6 +310,7 @@ let package = Package(
"internal/platform/implementation/apple/Log/Tests",
"internal/platform/implementation/apple/Mediums/BLE/Tests",
"internal/platform/implementation/apple/Mediums/BLE/Sockets/Tests",
"internal/platform/implementation/apple/Mediums/CoreLocation/CLLocationManager/Fake/",
"internal/platform/implementation/apple/Mediums/Hotspot/Tests",
"internal/platform/implementation/apple/Mediums/WiFiCommon/Tests",
"internal/platform/implementation/apple/Tests",
@@ -253,7 +320,7 @@ let package = Package(
"connections/implementation/analytics/BUILD",
"connections/implementation/flags/BUILD",
"connections/implementation/mediums/advertisements/BUILD",
"connections/implementation/mediums/ble_v2/BUILD",
"connections/implementation/mediums/ble/BUILD",
"connections/implementation/mediums/multiplex/BUILD",
"connections/implementation/mediums/BUILD",
"connections/implementation/BUILD",
@@ -274,6 +341,7 @@ let package = Package(
"internal/platform/implementation/apple/Mediums/BUILD",
"internal/platform/implementation/apple/Mediums/BLE/BUILD",
"internal/platform/implementation/apple/Mediums/BLE/Sockets/BUILD",
"internal/platform/implementation/apple/Mediums/CoreLocation/CLLocationManager/Fake/BUILD",
"internal/platform/implementation/apple/Mediums/Hotspot/BUILD",
"internal/platform/implementation/apple/Mediums/WiFiCommon/BUILD",
"internal/platform/implementation/BUILD",
@@ -281,6 +349,7 @@ let package = Package(
"internal/analytics/BUILD",
"internal/flags/BUILD",
"internal/network/BUILD",
"internal/rpc/BUILD",
"internal/base/BUILD",
"internal/data/BUILD",
"internal/test/BUILD",
@@ -303,23 +372,25 @@ let package = Package(
"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/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/ble_v2_test.cc",
"connections/implementation/mediums/ble_v2/bloom_filter_test.cc",
"connections/implementation/mediums/ble_v2/ble_l2cap_packet_test.cc",
"connections/implementation/mediums/ble_v2/ble_packet_test.cc",
"connections/implementation/mediums/ble_v2/ble_advertisement_test.cc",
"connections/implementation/mediums/ble_v2/advertisement_read_result_test.cc",
"connections/implementation/mediums/ble_v2/ble_advertisement_header_test.cc",
"connections/implementation/mediums/ble_v2/ble_utils_test.cc",
"connections/implementation/mediums/ble_v2/discovered_peripheral_tracker_test.cc",
"connections/implementation/mediums/ble_v2/instant_on_lost_advertisement_test.cc",
"connections/implementation/mediums/ble_v2/instant_on_lost_manager_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",
"connections/implementation/mediums/ble/ble_packet_test.cc",
"connections/implementation/mediums/ble/ble_advertisement_test.cc",
"connections/implementation/mediums/ble/advertisement_read_result_test.cc",
"connections/implementation/mediums/ble/ble_advertisement_header_test.cc",
"connections/implementation/mediums/ble/ble_socket_test.cc",
"connections/implementation/mediums/ble/ble_utils_test.cc",
"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",
@@ -342,7 +413,6 @@ let package = Package(
"connections/implementation/pcp_manager_test.cc",
"connections/implementation/ble_advertisement_test.cc",
"connections/implementation/base_endpoint_channel_test.cc",
"connections/implementation/reconnect_manager_test.cc",
"connections/v3/connections_device_test.cc",
"connections/v3/connections_device_provider_test.cc",
"connections/implementation/connections_authentication_transport_test.cc",
@@ -352,6 +422,7 @@ let package = Package(
"internal/base/bluetooth_address_test.cc",
"internal/base/file_path_test.cc",
"internal/base/files_test.cc",
"internal/base/masker_test.cc",
"internal/crypto/ed25519_unittest.cc",
"internal/crypto_cros/aead_unittest.cc",
"internal/crypto_cros/ec_private_key_unittest.cc",
@@ -374,7 +445,7 @@ let package = Package(
"internal/platform/byte_array_test.cc",
"internal/platform/credential_storage_impl_test.cc",
"internal/platform/implementation/g3/awdl_test.cc",
"internal/platform/implementation/g3/ble_v2_test.cc",
"internal/platform/implementation/g3/ble_test.cc",
"internal/platform/input_stream_test.cc",
"internal/platform/mac_address_test.cc",
"internal/platform/single_thread_executor_test.cc",
@@ -401,7 +472,6 @@ let package = Package(
"internal/platform/multi_thread_executor_test.cc",
"internal/platform/ble_connection_info_test.cc",
"internal/platform/ble_test.cc",
"internal/platform/ble_v2_test.cc",
"internal/platform/prng_test.cc",
"internal/platform/implementation/apple/count_down_latch_test.cc",
"internal/platform/implementation/apple/condition_variable_test.cc",
@@ -422,6 +492,7 @@ let package = Package(
"internal/platform/borrowable_test.cc",
"internal/platform/implementation/windows/http_loader_test.cc",
"internal/platform/blocking_queue_stream_test.cc",
"internal/platform/service_address_test.cc",
"internal/network/utils_test.cc",
"internal/network/url_test.cc",
"internal/network/http_response_test.cc",
@@ -456,6 +527,10 @@ let package = Package(
"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?
"internal/platform/medium_environment.cc",
],
@@ -470,7 +545,7 @@ let package = Package(
.headerSearchPath("./"),
.headerSearchPath("compiled_proto/"),
.headerSearchPath("third_party/ukey2/ukey2/"),
.headerSearchPath("third_party/ukey2/compiled_proto/"),
.headerSearchPath("third_party/ukey2/compiled_proto/src/main/proto"),
.define("NO_WEBRTC"),
]
),
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,311 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: internal/proto/analytics/experiments_log.proto
#include "internal/proto/analytics/experiments_log.pb.h"
#include <algorithm>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
namespace nearby {
namespace experiments {
constexpr ExperimentsLog::ExperimentsLog(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
: experiment_token_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
, zwieback_cookie_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){}
struct ExperimentsLogDefaultTypeInternal {
constexpr ExperimentsLogDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~ExperimentsLogDefaultTypeInternal() {}
union {
ExperimentsLog _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ExperimentsLogDefaultTypeInternal _ExperimentsLog_default_instance_;
} // namespace experiments
} // namespace nearby
namespace nearby {
namespace experiments {
// ===================================================================
class ExperimentsLog::_Internal {
public:
using HasBits = decltype(std::declval<ExperimentsLog>()._has_bits_);
static void set_has_experiment_token(HasBits* has_bits) {
(*has_bits)[0] |= 1u;
}
static void set_has_zwieback_cookie(HasBits* has_bits) {
(*has_bits)[0] |= 2u;
}
};
ExperimentsLog::ExperimentsLog(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:nearby.experiments.ExperimentsLog)
}
ExperimentsLog::ExperimentsLog(const ExperimentsLog& from)
: ::PROTOBUF_NAMESPACE_ID::MessageLite(),
_has_bits_(from._has_bits_) {
_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
experiment_token_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
experiment_token_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_experiment_token()) {
experiment_token_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_experiment_token(),
GetArenaForAllocation());
}
zwieback_cookie_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
zwieback_cookie_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (from._internal_has_zwieback_cookie()) {
zwieback_cookie_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_zwieback_cookie(),
GetArenaForAllocation());
}
// @@protoc_insertion_point(copy_constructor:nearby.experiments.ExperimentsLog)
}
inline void ExperimentsLog::SharedCtor() {
experiment_token_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
experiment_token_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
zwieback_cookie_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
zwieback_cookie_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
}
ExperimentsLog::~ExperimentsLog() {
// @@protoc_insertion_point(destructor:nearby.experiments.ExperimentsLog)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<std::string>();
}
inline void ExperimentsLog::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
experiment_token_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
zwieback_cookie_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}
void ExperimentsLog::ArenaDtor(void* object) {
ExperimentsLog* _this = reinterpret_cast< ExperimentsLog* >(object);
(void)_this;
}
void ExperimentsLog::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void ExperimentsLog::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void ExperimentsLog::Clear() {
// @@protoc_insertion_point(message_clear_start:nearby.experiments.ExperimentsLog)
uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000003u) {
if (cached_has_bits & 0x00000001u) {
experiment_token_.ClearNonDefaultToEmpty();
}
if (cached_has_bits & 0x00000002u) {
zwieback_cookie_.ClearNonDefaultToEmpty();
}
}
_has_bits_.Clear();
_internal_metadata_.Clear<std::string>();
}
const char* ExperimentsLog::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
_Internal::HasBits has_bits{};
while (!ctx->Done(&ptr)) {
uint32_t tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
switch (tag >> 3) {
// optional bytes experiment_token = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
auto str = _internal_mutable_experiment_token();
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
} else
goto handle_unusual;
continue;
// optional string zwieback_cookie = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
auto str = _internal_mutable_zwieback_cookie();
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
CHK_(ptr);
} else
goto handle_unusual;
continue;
default:
goto handle_unusual;
} // switch
handle_unusual:
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto message_done;
}
ptr = UnknownFieldParse(
tag,
_internal_metadata_.mutable_unknown_fields<std::string>(),
ptr, ctx);
CHK_(ptr != nullptr);
} // while
message_done:
_has_bits_.Or(has_bits);
return ptr;
failure:
ptr = nullptr;
goto message_done;
#undef CHK_
}
uint8_t* ExperimentsLog::_InternalSerialize(
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:nearby.experiments.ExperimentsLog)
uint32_t cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
// optional bytes experiment_token = 1;
if (cached_has_bits & 0x00000001u) {
target = stream->WriteBytesMaybeAliased(
1, this->_internal_experiment_token(), target);
}
// optional string zwieback_cookie = 2;
if (cached_has_bits & 0x00000002u) {
target = stream->WriteStringMaybeAliased(
2, this->_internal_zwieback_cookie(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:nearby.experiments.ExperimentsLog)
return target;
}
size_t ExperimentsLog::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:nearby.experiments.ExperimentsLog)
size_t total_size = 0;
uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
cached_has_bits = _has_bits_[0];
if (cached_has_bits & 0x00000003u) {
// optional bytes experiment_token = 1;
if (cached_has_bits & 0x00000001u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
this->_internal_experiment_token());
}
// optional string zwieback_cookie = 2;
if (cached_has_bits & 0x00000002u) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_zwieback_cookie());
}
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void ExperimentsLog::CheckTypeAndMergeFrom(
const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast<const ExperimentsLog*>(
&from));
}
void ExperimentsLog::MergeFrom(const ExperimentsLog& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:nearby.experiments.ExperimentsLog)
GOOGLE_DCHECK_NE(&from, this);
uint32_t cached_has_bits = 0;
(void) cached_has_bits;
cached_has_bits = from._has_bits_[0];
if (cached_has_bits & 0x00000003u) {
if (cached_has_bits & 0x00000001u) {
_internal_set_experiment_token(from._internal_experiment_token());
}
if (cached_has_bits & 0x00000002u) {
_internal_set_zwieback_cookie(from._internal_zwieback_cookie());
}
}
_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}
void ExperimentsLog::CopyFrom(const ExperimentsLog& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:nearby.experiments.ExperimentsLog)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool ExperimentsLog::IsInitialized() const {
return true;
}
void ExperimentsLog::InternalSwap(ExperimentsLog* other) {
using std::swap;
auto* lhs_arena = GetArenaForAllocation();
auto* rhs_arena = other->GetArenaForAllocation();
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
swap(_has_bits_[0], other->_has_bits_[0]);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&experiment_token_, lhs_arena,
&other->experiment_token_, rhs_arena
);
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
&zwieback_cookie_, lhs_arena,
&other->zwieback_cookie_, rhs_arena
);
}
std::string ExperimentsLog::GetTypeName() const {
return "nearby.experiments.ExperimentsLog";
}
// @@protoc_insertion_point(namespace_scope)
} // namespace experiments
} // namespace nearby
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::nearby::experiments::ExperimentsLog* Arena::CreateMaybeMessage< ::nearby::experiments::ExperimentsLog >(Arena* arena) {
return Arena::CreateMessageInternal< ::nearby::experiments::ExperimentsLog >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
@@ -1,394 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: internal/proto/analytics/experiments_log.proto
#ifndef GOOGLE_PROTOBUF_INCLUDED_internal_2fproto_2fanalytics_2fexperiments_5flog_2eproto
#define GOOGLE_PROTOBUF_INCLUDED_internal_2fproto_2fanalytics_2fexperiments_5flog_2eproto
#include <limits>
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3019000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3019001 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/message_lite.h>
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
#include <google/protobuf/extension_set.h> // IWYU pragma: export
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
#define PROTOBUF_INTERNAL_EXPORT_internal_2fproto_2fanalytics_2fexperiments_5flog_2eproto
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
} // namespace internal
PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct TableStruct_internal_2fproto_2fanalytics_2fexperiments_5flog_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const uint32_t offsets[];
};
namespace nearby {
namespace experiments {
class ExperimentsLog;
struct ExperimentsLogDefaultTypeInternal;
extern ExperimentsLogDefaultTypeInternal _ExperimentsLog_default_instance_;
} // namespace experiments
} // namespace nearby
PROTOBUF_NAMESPACE_OPEN
template<> ::nearby::experiments::ExperimentsLog* Arena::CreateMaybeMessage<::nearby::experiments::ExperimentsLog>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
namespace nearby {
namespace experiments {
// ===================================================================
class ExperimentsLog final :
public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:nearby.experiments.ExperimentsLog) */ {
public:
inline ExperimentsLog() : ExperimentsLog(nullptr) {}
~ExperimentsLog() override;
explicit constexpr ExperimentsLog(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
ExperimentsLog(const ExperimentsLog& from);
ExperimentsLog(ExperimentsLog&& from) noexcept
: ExperimentsLog() {
*this = ::std::move(from);
}
inline ExperimentsLog& operator=(const ExperimentsLog& from) {
CopyFrom(from);
return *this;
}
inline ExperimentsLog& operator=(ExperimentsLog&& from) noexcept {
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
&& GetOwningArena() != nullptr
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
inline const std::string& unknown_fields() const {
return _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString);
}
inline std::string* mutable_unknown_fields() {
return _internal_metadata_.mutable_unknown_fields<std::string>();
}
static const ExperimentsLog& default_instance() {
return *internal_default_instance();
}
static inline const ExperimentsLog* internal_default_instance() {
return reinterpret_cast<const ExperimentsLog*>(
&_ExperimentsLog_default_instance_);
}
static constexpr int kIndexInFileMessages =
0;
friend void swap(ExperimentsLog& a, ExperimentsLog& b) {
a.Swap(&b);
}
inline void Swap(ExperimentsLog* other) {
if (other == this) return;
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() != nullptr &&
GetOwningArena() == other->GetOwningArena()) {
#else // PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() == other->GetOwningArena()) {
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
}
}
void UnsafeArenaSwap(ExperimentsLog* other) {
if (other == this) return;
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
ExperimentsLog* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final {
return CreateMaybeMessage<ExperimentsLog>(arena);
}
void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final;
void CopyFrom(const ExperimentsLog& from);
void MergeFrom(const ExperimentsLog& from);
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
uint8_t* _InternalSerialize(
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
void InternalSwap(ExperimentsLog* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "nearby.experiments.ExperimentsLog";
}
protected:
explicit ExperimentsLog(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
private:
static void ArenaDtor(void* object);
inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
std::string GetTypeName() const final;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kExperimentTokenFieldNumber = 1,
kZwiebackCookieFieldNumber = 2,
};
// optional bytes experiment_token = 1;
bool has_experiment_token() const;
private:
bool _internal_has_experiment_token() const;
public:
void clear_experiment_token();
const std::string& experiment_token() const;
template <typename ArgT0 = const std::string&, typename... ArgT>
void set_experiment_token(ArgT0&& arg0, ArgT... args);
std::string* mutable_experiment_token();
PROTOBUF_NODISCARD std::string* release_experiment_token();
void set_allocated_experiment_token(std::string* experiment_token);
private:
const std::string& _internal_experiment_token() const;
inline PROTOBUF_ALWAYS_INLINE void _internal_set_experiment_token(const std::string& value);
std::string* _internal_mutable_experiment_token();
public:
// optional string zwieback_cookie = 2;
bool has_zwieback_cookie() const;
private:
bool _internal_has_zwieback_cookie() const;
public:
void clear_zwieback_cookie();
const std::string& zwieback_cookie() const;
template <typename ArgT0 = const std::string&, typename... ArgT>
void set_zwieback_cookie(ArgT0&& arg0, ArgT... args);
std::string* mutable_zwieback_cookie();
PROTOBUF_NODISCARD std::string* release_zwieback_cookie();
void set_allocated_zwieback_cookie(std::string* zwieback_cookie);
private:
const std::string& _internal_zwieback_cookie() const;
inline PROTOBUF_ALWAYS_INLINE void _internal_set_zwieback_cookie(const std::string& value);
std::string* _internal_mutable_zwieback_cookie();
public:
// @@protoc_insertion_point(class_scope:nearby.experiments.ExperimentsLog)
private:
class _Internal;
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
::PROTOBUF_NAMESPACE_ID::internal::HasBits<1> _has_bits_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr experiment_token_;
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr zwieback_cookie_;
friend struct ::TableStruct_internal_2fproto_2fanalytics_2fexperiments_5flog_2eproto;
};
// ===================================================================
// ===================================================================
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
// ExperimentsLog
// optional bytes experiment_token = 1;
inline bool ExperimentsLog::_internal_has_experiment_token() const {
bool value = (_has_bits_[0] & 0x00000001u) != 0;
return value;
}
inline bool ExperimentsLog::has_experiment_token() const {
return _internal_has_experiment_token();
}
inline void ExperimentsLog::clear_experiment_token() {
experiment_token_.ClearToEmpty();
_has_bits_[0] &= ~0x00000001u;
}
inline const std::string& ExperimentsLog::experiment_token() const {
// @@protoc_insertion_point(field_get:nearby.experiments.ExperimentsLog.experiment_token)
return _internal_experiment_token();
}
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void ExperimentsLog::set_experiment_token(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000001u;
experiment_token_.SetBytes(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:nearby.experiments.ExperimentsLog.experiment_token)
}
inline std::string* ExperimentsLog::mutable_experiment_token() {
std::string* _s = _internal_mutable_experiment_token();
// @@protoc_insertion_point(field_mutable:nearby.experiments.ExperimentsLog.experiment_token)
return _s;
}
inline const std::string& ExperimentsLog::_internal_experiment_token() const {
return experiment_token_.Get();
}
inline void ExperimentsLog::_internal_set_experiment_token(const std::string& value) {
_has_bits_[0] |= 0x00000001u;
experiment_token_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
}
inline std::string* ExperimentsLog::_internal_mutable_experiment_token() {
_has_bits_[0] |= 0x00000001u;
return experiment_token_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
}
inline std::string* ExperimentsLog::release_experiment_token() {
// @@protoc_insertion_point(field_release:nearby.experiments.ExperimentsLog.experiment_token)
if (!_internal_has_experiment_token()) {
return nullptr;
}
_has_bits_[0] &= ~0x00000001u;
auto* p = experiment_token_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (experiment_token_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
experiment_token_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
}
inline void ExperimentsLog::set_allocated_experiment_token(std::string* experiment_token) {
if (experiment_token != nullptr) {
_has_bits_[0] |= 0x00000001u;
} else {
_has_bits_[0] &= ~0x00000001u;
}
experiment_token_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), experiment_token,
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (experiment_token_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
experiment_token_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:nearby.experiments.ExperimentsLog.experiment_token)
}
// optional string zwieback_cookie = 2;
inline bool ExperimentsLog::_internal_has_zwieback_cookie() const {
bool value = (_has_bits_[0] & 0x00000002u) != 0;
return value;
}
inline bool ExperimentsLog::has_zwieback_cookie() const {
return _internal_has_zwieback_cookie();
}
inline void ExperimentsLog::clear_zwieback_cookie() {
zwieback_cookie_.ClearToEmpty();
_has_bits_[0] &= ~0x00000002u;
}
inline const std::string& ExperimentsLog::zwieback_cookie() const {
// @@protoc_insertion_point(field_get:nearby.experiments.ExperimentsLog.zwieback_cookie)
return _internal_zwieback_cookie();
}
template <typename ArgT0, typename... ArgT>
inline PROTOBUF_ALWAYS_INLINE
void ExperimentsLog::set_zwieback_cookie(ArgT0&& arg0, ArgT... args) {
_has_bits_[0] |= 0x00000002u;
zwieback_cookie_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
// @@protoc_insertion_point(field_set:nearby.experiments.ExperimentsLog.zwieback_cookie)
}
inline std::string* ExperimentsLog::mutable_zwieback_cookie() {
std::string* _s = _internal_mutable_zwieback_cookie();
// @@protoc_insertion_point(field_mutable:nearby.experiments.ExperimentsLog.zwieback_cookie)
return _s;
}
inline const std::string& ExperimentsLog::_internal_zwieback_cookie() const {
return zwieback_cookie_.Get();
}
inline void ExperimentsLog::_internal_set_zwieback_cookie(const std::string& value) {
_has_bits_[0] |= 0x00000002u;
zwieback_cookie_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, value, GetArenaForAllocation());
}
inline std::string* ExperimentsLog::_internal_mutable_zwieback_cookie() {
_has_bits_[0] |= 0x00000002u;
return zwieback_cookie_.Mutable(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, GetArenaForAllocation());
}
inline std::string* ExperimentsLog::release_zwieback_cookie() {
// @@protoc_insertion_point(field_release:nearby.experiments.ExperimentsLog.zwieback_cookie)
if (!_internal_has_zwieback_cookie()) {
return nullptr;
}
_has_bits_[0] &= ~0x00000002u;
auto* p = zwieback_cookie_.ReleaseNonDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (zwieback_cookie_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
zwieback_cookie_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
return p;
}
inline void ExperimentsLog::set_allocated_zwieback_cookie(std::string* zwieback_cookie) {
if (zwieback_cookie != nullptr) {
_has_bits_[0] |= 0x00000002u;
} else {
_has_bits_[0] &= ~0x00000002u;
}
zwieback_cookie_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), zwieback_cookie,
GetArenaForAllocation());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (zwieback_cookie_.IsDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited())) {
zwieback_cookie_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:nearby.experiments.ExperimentsLog.zwieback_cookie)
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
// @@protoc_insertion_point(namespace_scope)
} // namespace experiments
} // namespace nearby
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_internal_2fproto_2fanalytics_2fexperiments_5flog_2eproto
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,85 +1,181 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// NO CHECKED-IN PROTOBUF GENCODE
// source: proto/errorcode/error_code_enums.proto
// Protobuf C++ Version: 6.33.3
#ifndef GOOGLE_PROTOBUF_INCLUDED_proto_2ferrorcode_2ferror_5fcode_5fenums_2eproto
#define GOOGLE_PROTOBUF_INCLUDED_proto_2ferrorcode_2ferror_5fcode_5fenums_2eproto
#ifndef proto_2ferrorcode_2ferror_5fcode_5fenums_2eproto_2epb_2eh
#define proto_2ferrorcode_2ferror_5fcode_5fenums_2eproto_2epb_2eh
#include <limits>
#include <string>
#include <type_traits>
#include <utility>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3019000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#include "google/protobuf/runtime_version.h"
#if PROTOBUF_VERSION != 6033003
#error "Protobuf C++ gencode is built with an incompatible version of"
#error "Protobuf C++ headers/runtime. See"
#error "https://protobuf.dev/support/cross-version-runtime-guarantee/#cpp"
#endif
#if 3019001 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/generated_enum_util.h>
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/arena.h"
#include "google/protobuf/arenastring.h"
#include "google/protobuf/generated_message_tctable_decl.h"
#include "google/protobuf/generated_message_util.h"
#include "google/protobuf/metadata_lite.h"
#include "google/protobuf/repeated_field.h" // IWYU pragma: export
#include "google/protobuf/extension_set.h" // IWYU pragma: export
#include "google/protobuf/generated_enum_util.h"
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
// Must be included last.
#include "google/protobuf/port_def.inc"
#define PROTOBUF_INTERNAL_EXPORT_proto_2ferrorcode_2ferror_5fcode_5fenums_2eproto
PROTOBUF_NAMESPACE_OPEN
namespace google {
namespace protobuf {
namespace internal {
class AnyMetadata;
template <typename T>
::absl::string_view GetAnyMessageName();
} // namespace internal
PROTOBUF_NAMESPACE_CLOSE
} // namespace protobuf
} // namespace google
// Internal implementation detail -- do not use these members.
struct TableStruct_proto_2ferrorcode_2ferror_5fcode_5fenums_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const uint32_t offsets[];
static const ::uint32_t offsets[];
};
PROTOBUF_NAMESPACE_OPEN
PROTOBUF_NAMESPACE_CLOSE
namespace location {
namespace nearby {
namespace errorcode {
namespace proto {
enum AcceptConnectionError : int;
extern const uint32_t AcceptConnectionError_internal_data_[];
enum CommonError : int;
extern const uint32_t CommonError_internal_data_[];
enum ConnectError : int;
extern const uint32_t ConnectError_internal_data_[];
enum Description : int;
extern const uint32_t Description_internal_data_[];
enum DisconnectError : int;
extern const uint32_t DisconnectError_internal_data_[];
enum ErrorType : int;
extern const uint32_t ErrorType_internal_data_[];
enum Event : int;
extern const uint32_t Event_internal_data_[];
enum ReceivePayloadError : int;
extern const uint32_t ReceivePayloadError_internal_data_[];
enum RejectConnectionError : int;
extern const uint32_t RejectConnectionError_internal_data_[];
enum SendPayloadError : int;
extern const uint32_t SendPayloadError_internal_data_[];
enum StartAdvertisingError : int;
extern const uint32_t StartAdvertisingError_internal_data_[];
enum StartDiscoveringError : int;
extern const uint32_t StartDiscoveringError_internal_data_[];
enum StartListeningIncomingConnectionError : int;
extern const uint32_t StartListeningIncomingConnectionError_internal_data_[];
enum StopAdvertisingError : int;
extern const uint32_t StopAdvertisingError_internal_data_[];
enum StopDiscoveringError : int;
extern const uint32_t StopDiscoveringError_internal_data_[];
enum StopListeningIncomingConnectionError : int;
extern const uint32_t StopListeningIncomingConnectionError_internal_data_[];
enum UpgradeError : int;
extern const uint32_t UpgradeError_internal_data_[];
} // namespace proto
} // namespace errorcode
} // namespace nearby
} // namespace location
namespace google {
namespace protobuf {
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::AcceptConnectionError_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::AcceptConnectionError>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::CommonError_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::CommonError>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::ConnectError_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::ConnectError>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::Description_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::Description>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::DisconnectError_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::DisconnectError>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::ErrorType_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::ErrorType>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::Event_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::Event>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::ReceivePayloadError_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::ReceivePayloadError>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::RejectConnectionError_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::RejectConnectionError>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::SendPayloadError_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::SendPayloadError>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::StartAdvertisingError_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::StartAdvertisingError>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::StartDiscoveringError_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::StartDiscoveringError>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::StartListeningIncomingConnectionError_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::StartListeningIncomingConnectionError>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::StopAdvertisingError_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::StopAdvertisingError>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::StopDiscoveringError_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::StopDiscoveringError>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::StopListeningIncomingConnectionError_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::StopListeningIncomingConnectionError>;
template <>
internal::EnumTraitsT<::location::nearby::errorcode::proto::UpgradeError_internal_data_>
internal::EnumTraitsImpl::value<::location::nearby::errorcode::proto::UpgradeError>;
} // namespace protobuf
} // namespace google
namespace location {
namespace nearby {
namespace errorcode {
namespace proto {
enum ErrorType : int {
UNKNOWN_TYPE = 0,
DEVELOPING = 1,
DEVICE = 2,
SYSTEM = 3,
NETWORK = 4,
OTHERS = 5
OTHERS = 5,
};
bool ErrorType_IsValid(int value);
constexpr ErrorType ErrorType_MIN = UNKNOWN_TYPE;
constexpr ErrorType ErrorType_MAX = OTHERS;
constexpr int ErrorType_ARRAYSIZE = ErrorType_MAX + 1;
const std::string& ErrorType_Name(ErrorType value);
template<typename T>
inline const std::string& ErrorType_Name(T enum_t_value) {
extern const uint32_t ErrorType_internal_data_[];
inline constexpr ErrorType ErrorType_MIN =
static_cast<ErrorType>(0);
inline constexpr ErrorType ErrorType_MAX =
static_cast<ErrorType>(5);
inline bool ErrorType_IsValid(int value) {
return 0 <= value && value <= 5;
}
inline constexpr int ErrorType_ARRAYSIZE = 5 + 1;
const ::std::string& ErrorType_Name(ErrorType value);
template <typename T>
const ::std::string& ErrorType_Name(T value) {
static_assert(::std::is_same<T, ErrorType>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function ErrorType_Name.");
return ErrorType_Name(static_cast<ErrorType>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to ErrorType_Name().");
return ErrorType_Name(static_cast<ErrorType>(value));
}
bool ErrorType_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, ErrorType* value);
::absl::string_view name, ErrorType* PROTOBUF_NONNULL value);
enum Event : int {
UNKNOWN_EVENT = 0,
START_ADVERTISING = 1,
@@ -95,23 +191,28 @@ enum Event : int {
SEND_PAYLOAD = 11,
CANCEL_PAYLOAD = 12,
RECEIVE_PAYLOAD = 13,
UPGRADE = 14
UPGRADE = 14,
};
bool Event_IsValid(int value);
constexpr Event Event_MIN = UNKNOWN_EVENT;
constexpr Event Event_MAX = UPGRADE;
constexpr int Event_ARRAYSIZE = Event_MAX + 1;
const std::string& Event_Name(Event value);
template<typename T>
inline const std::string& Event_Name(T enum_t_value) {
extern const uint32_t Event_internal_data_[];
inline constexpr Event Event_MIN =
static_cast<Event>(0);
inline constexpr Event Event_MAX =
static_cast<Event>(14);
inline bool Event_IsValid(int value) {
return 0 <= value && value <= 14;
}
inline constexpr int Event_ARRAYSIZE = 14 + 1;
const ::std::string& Event_Name(Event value);
template <typename T>
const ::std::string& Event_Name(T value) {
static_assert(::std::is_same<T, Event>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function Event_Name.");
return Event_Name(static_cast<Event>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to Event_Name().");
return Event_Name(static_cast<Event>(value));
}
bool Event_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Event* value);
::absl::string_view name, Event* PROTOBUF_NONNULL value);
enum CommonError : int {
UNKNOWN_ERROR = 0,
INVALID_PARAMETER = 1,
@@ -119,23 +220,28 @@ enum CommonError : int {
UNEXPECTED_MEDIUM_STATE = 3,
OUT_OF_RESOURCE = 4,
FLOW_CANCELED = 5,
UNEXPECTED_CALL = 6
UNEXPECTED_CALL = 6,
};
bool CommonError_IsValid(int value);
constexpr CommonError CommonError_MIN = UNKNOWN_ERROR;
constexpr CommonError CommonError_MAX = UNEXPECTED_CALL;
constexpr int CommonError_ARRAYSIZE = CommonError_MAX + 1;
const std::string& CommonError_Name(CommonError value);
template<typename T>
inline const std::string& CommonError_Name(T enum_t_value) {
extern const uint32_t CommonError_internal_data_[];
inline constexpr CommonError CommonError_MIN =
static_cast<CommonError>(0);
inline constexpr CommonError CommonError_MAX =
static_cast<CommonError>(6);
inline bool CommonError_IsValid(int value) {
return 0 <= value && value <= 6;
}
inline constexpr int CommonError_ARRAYSIZE = 6 + 1;
const ::std::string& CommonError_Name(CommonError value);
template <typename T>
const ::std::string& CommonError_Name(T value) {
static_assert(::std::is_same<T, CommonError>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function CommonError_Name.");
return CommonError_Name(static_cast<CommonError>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to CommonError_Name().");
return CommonError_Name(static_cast<CommonError>(value));
}
bool CommonError_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, CommonError* value);
::absl::string_view name, CommonError* PROTOBUF_NONNULL value);
enum StartAdvertisingError : int {
MULTIPLE_FAST_ADVERTISEMENT_NOT_ALLOWED = 31,
FAST_ADVERTISEMENT_ALREADY_ADVERTISED = 32,
@@ -151,45 +257,55 @@ enum StartAdvertisingError : int {
SHOULD_ACCEPT_CONNECTIONS_BEFORE_ADVERTISING_ON_WIFI_LAN = 44,
ACQUIRE_WIFI_AWARE_SESSION_FAILED = 45,
UNKNOWN_START_ADVERTISING_ERROR = 46,
AWARE_UPDATE_PUBLISHING_FAILED = 47
AWARE_UPDATE_PUBLISHING_FAILED = 47,
};
bool StartAdvertisingError_IsValid(int value);
constexpr StartAdvertisingError StartAdvertisingError_MIN = MULTIPLE_FAST_ADVERTISEMENT_NOT_ALLOWED;
constexpr StartAdvertisingError StartAdvertisingError_MAX = AWARE_UPDATE_PUBLISHING_FAILED;
constexpr int StartAdvertisingError_ARRAYSIZE = StartAdvertisingError_MAX + 1;
const std::string& StartAdvertisingError_Name(StartAdvertisingError value);
template<typename T>
inline const std::string& StartAdvertisingError_Name(T enum_t_value) {
extern const uint32_t StartAdvertisingError_internal_data_[];
inline constexpr StartAdvertisingError StartAdvertisingError_MIN =
static_cast<StartAdvertisingError>(31);
inline constexpr StartAdvertisingError StartAdvertisingError_MAX =
static_cast<StartAdvertisingError>(47);
inline bool StartAdvertisingError_IsValid(int value) {
return 0 <= value && value <= 47 && ((280785634459648u >> value) & 1) != 0;
}
inline constexpr int StartAdvertisingError_ARRAYSIZE = 47 + 1;
const ::std::string& StartAdvertisingError_Name(StartAdvertisingError value);
template <typename T>
const ::std::string& StartAdvertisingError_Name(T value) {
static_assert(::std::is_same<T, StartAdvertisingError>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function StartAdvertisingError_Name.");
return StartAdvertisingError_Name(static_cast<StartAdvertisingError>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to StartAdvertisingError_Name().");
return StartAdvertisingError_Name(static_cast<StartAdvertisingError>(value));
}
bool StartAdvertisingError_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, StartAdvertisingError* value);
::absl::string_view name, StartAdvertisingError* PROTOBUF_NONNULL value);
enum StopAdvertisingError : int {
STOP_ADVERTISING_FAILED = 31,
RESTORE_BLUETOOTH_NAME_FAILED = 32,
STOP_LEGACY_ADVERTISING_FAILED = 33,
STOP_EXTENDED_ADVERTISING_FAILED = 34,
UNKNOWN_STOP_ADVERTISING_ERROR = 35
UNKNOWN_STOP_ADVERTISING_ERROR = 35,
};
bool StopAdvertisingError_IsValid(int value);
constexpr StopAdvertisingError StopAdvertisingError_MIN = STOP_ADVERTISING_FAILED;
constexpr StopAdvertisingError StopAdvertisingError_MAX = UNKNOWN_STOP_ADVERTISING_ERROR;
constexpr int StopAdvertisingError_ARRAYSIZE = StopAdvertisingError_MAX + 1;
const std::string& StopAdvertisingError_Name(StopAdvertisingError value);
template<typename T>
inline const std::string& StopAdvertisingError_Name(T enum_t_value) {
extern const uint32_t StopAdvertisingError_internal_data_[];
inline constexpr StopAdvertisingError StopAdvertisingError_MIN =
static_cast<StopAdvertisingError>(31);
inline constexpr StopAdvertisingError StopAdvertisingError_MAX =
static_cast<StopAdvertisingError>(35);
inline bool StopAdvertisingError_IsValid(int value) {
return 31 <= value && value <= 35;
}
inline constexpr int StopAdvertisingError_ARRAYSIZE = 35 + 1;
const ::std::string& StopAdvertisingError_Name(StopAdvertisingError value);
template <typename T>
const ::std::string& StopAdvertisingError_Name(T value) {
static_assert(::std::is_same<T, StopAdvertisingError>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function StopAdvertisingError_Name.");
return StopAdvertisingError_Name(static_cast<StopAdvertisingError>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to StopAdvertisingError_Name().");
return StopAdvertisingError_Name(static_cast<StopAdvertisingError>(value));
}
bool StopAdvertisingError_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, StopAdvertisingError* value);
::absl::string_view name, StopAdvertisingError* PROTOBUF_NONNULL value);
enum StartDiscoveringError : int {
DUPLICATE_DISCOVERING_REQUESTED = 31,
START_LEGACY_DISCOVERING_FAILED = 32,
@@ -201,44 +317,54 @@ enum StartDiscoveringError : int {
L2CAP_FETCH_ADVERTISEMENT_FAILED = 38,
NOT_AVAILABLE_TO_FETCH_ADVERTISEMENT = 39,
ACQUIRE_WIFI_AWARE_SESSION_FOR_DISCOVERING_FAILED = 40,
UNKNOWN_START_DISCOVERING_ERROR = 41
UNKNOWN_START_DISCOVERING_ERROR = 41,
};
bool StartDiscoveringError_IsValid(int value);
constexpr StartDiscoveringError StartDiscoveringError_MIN = DUPLICATE_DISCOVERING_REQUESTED;
constexpr StartDiscoveringError StartDiscoveringError_MAX = UNKNOWN_START_DISCOVERING_ERROR;
constexpr int StartDiscoveringError_ARRAYSIZE = StartDiscoveringError_MAX + 1;
const std::string& StartDiscoveringError_Name(StartDiscoveringError value);
template<typename T>
inline const std::string& StartDiscoveringError_Name(T enum_t_value) {
extern const uint32_t StartDiscoveringError_internal_data_[];
inline constexpr StartDiscoveringError StartDiscoveringError_MIN =
static_cast<StartDiscoveringError>(31);
inline constexpr StartDiscoveringError StartDiscoveringError_MAX =
static_cast<StartDiscoveringError>(41);
inline bool StartDiscoveringError_IsValid(int value) {
return 31 <= value && value <= 41;
}
inline constexpr int StartDiscoveringError_ARRAYSIZE = 41 + 1;
const ::std::string& StartDiscoveringError_Name(StartDiscoveringError value);
template <typename T>
const ::std::string& StartDiscoveringError_Name(T value) {
static_assert(::std::is_same<T, StartDiscoveringError>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function StartDiscoveringError_Name.");
return StartDiscoveringError_Name(static_cast<StartDiscoveringError>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to StartDiscoveringError_Name().");
return StartDiscoveringError_Name(static_cast<StartDiscoveringError>(value));
}
bool StartDiscoveringError_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, StartDiscoveringError* value);
::absl::string_view name, StartDiscoveringError* PROTOBUF_NONNULL value);
enum StopDiscoveringError : int {
STOP_DISCOVERING_FAILED = 31,
STOP_LEGACY_DISCOVERING_FAILED = 32,
STOP_EXTENDED_DISCOVERING_FAILED = 33,
UNKNOWN_STOP_DISCOVERING_ERROR = 34
UNKNOWN_STOP_DISCOVERING_ERROR = 34,
};
bool StopDiscoveringError_IsValid(int value);
constexpr StopDiscoveringError StopDiscoveringError_MIN = STOP_DISCOVERING_FAILED;
constexpr StopDiscoveringError StopDiscoveringError_MAX = UNKNOWN_STOP_DISCOVERING_ERROR;
constexpr int StopDiscoveringError_ARRAYSIZE = StopDiscoveringError_MAX + 1;
const std::string& StopDiscoveringError_Name(StopDiscoveringError value);
template<typename T>
inline const std::string& StopDiscoveringError_Name(T enum_t_value) {
extern const uint32_t StopDiscoveringError_internal_data_[];
inline constexpr StopDiscoveringError StopDiscoveringError_MIN =
static_cast<StopDiscoveringError>(31);
inline constexpr StopDiscoveringError StopDiscoveringError_MAX =
static_cast<StopDiscoveringError>(34);
inline bool StopDiscoveringError_IsValid(int value) {
return 31 <= value && value <= 34;
}
inline constexpr int StopDiscoveringError_ARRAYSIZE = 34 + 1;
const ::std::string& StopDiscoveringError_Name(StopDiscoveringError value);
template <typename T>
const ::std::string& StopDiscoveringError_Name(T value) {
static_assert(::std::is_same<T, StopDiscoveringError>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function StopDiscoveringError_Name.");
return StopDiscoveringError_Name(static_cast<StopDiscoveringError>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to StopDiscoveringError_Name().");
return StopDiscoveringError_Name(static_cast<StopDiscoveringError>(value));
}
bool StopDiscoveringError_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, StopDiscoveringError* value);
::absl::string_view name, StopDiscoveringError* PROTOBUF_NONNULL value);
enum StartListeningIncomingConnectionError : int {
DUPLICATE_ACCEPTING_CONNECTION_REQUESTED = 31,
OPEN_GATT_SERVER_FAILED = 32,
@@ -249,42 +375,52 @@ enum StartListeningIncomingConnectionError : int {
CREATE_SERVER_SOCKET_FAILED = 37,
UNKNOWN_START_LISTENING_INCOMING_CONNECTION_ERROR = 38,
ACCEPT_SEND_AWARE_L2_MESSAGE_FAILED = 39,
ACCEPT_RECEIVE_AWARE_L2_MESSAGE_FAILED = 40
ACCEPT_RECEIVE_AWARE_L2_MESSAGE_FAILED = 40,
};
bool StartListeningIncomingConnectionError_IsValid(int value);
constexpr StartListeningIncomingConnectionError StartListeningIncomingConnectionError_MIN = DUPLICATE_ACCEPTING_CONNECTION_REQUESTED;
constexpr StartListeningIncomingConnectionError StartListeningIncomingConnectionError_MAX = ACCEPT_RECEIVE_AWARE_L2_MESSAGE_FAILED;
constexpr int StartListeningIncomingConnectionError_ARRAYSIZE = StartListeningIncomingConnectionError_MAX + 1;
const std::string& StartListeningIncomingConnectionError_Name(StartListeningIncomingConnectionError value);
template<typename T>
inline const std::string& StartListeningIncomingConnectionError_Name(T enum_t_value) {
extern const uint32_t StartListeningIncomingConnectionError_internal_data_[];
inline constexpr StartListeningIncomingConnectionError StartListeningIncomingConnectionError_MIN =
static_cast<StartListeningIncomingConnectionError>(31);
inline constexpr StartListeningIncomingConnectionError StartListeningIncomingConnectionError_MAX =
static_cast<StartListeningIncomingConnectionError>(40);
inline bool StartListeningIncomingConnectionError_IsValid(int value) {
return 31 <= value && value <= 40;
}
inline constexpr int StartListeningIncomingConnectionError_ARRAYSIZE = 40 + 1;
const ::std::string& StartListeningIncomingConnectionError_Name(StartListeningIncomingConnectionError value);
template <typename T>
const ::std::string& StartListeningIncomingConnectionError_Name(T value) {
static_assert(::std::is_same<T, StartListeningIncomingConnectionError>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function StartListeningIncomingConnectionError_Name.");
return StartListeningIncomingConnectionError_Name(static_cast<StartListeningIncomingConnectionError>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to StartListeningIncomingConnectionError_Name().");
return StartListeningIncomingConnectionError_Name(static_cast<StartListeningIncomingConnectionError>(value));
}
bool StartListeningIncomingConnectionError_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, StartListeningIncomingConnectionError* value);
::absl::string_view name, StartListeningIncomingConnectionError* PROTOBUF_NONNULL value);
enum StopListeningIncomingConnectionError : int {
STOP_ACCEPTING_CONNECTION_FAILED = 31,
UNKNOWN_STOP_LISTENING_INCOMING_CONNECTION_ERROR = 32
UNKNOWN_STOP_LISTENING_INCOMING_CONNECTION_ERROR = 32,
};
bool StopListeningIncomingConnectionError_IsValid(int value);
constexpr StopListeningIncomingConnectionError StopListeningIncomingConnectionError_MIN = STOP_ACCEPTING_CONNECTION_FAILED;
constexpr StopListeningIncomingConnectionError StopListeningIncomingConnectionError_MAX = UNKNOWN_STOP_LISTENING_INCOMING_CONNECTION_ERROR;
constexpr int StopListeningIncomingConnectionError_ARRAYSIZE = StopListeningIncomingConnectionError_MAX + 1;
const std::string& StopListeningIncomingConnectionError_Name(StopListeningIncomingConnectionError value);
template<typename T>
inline const std::string& StopListeningIncomingConnectionError_Name(T enum_t_value) {
extern const uint32_t StopListeningIncomingConnectionError_internal_data_[];
inline constexpr StopListeningIncomingConnectionError StopListeningIncomingConnectionError_MIN =
static_cast<StopListeningIncomingConnectionError>(31);
inline constexpr StopListeningIncomingConnectionError StopListeningIncomingConnectionError_MAX =
static_cast<StopListeningIncomingConnectionError>(32);
inline bool StopListeningIncomingConnectionError_IsValid(int value) {
return 31 <= value && value <= 32;
}
inline constexpr int StopListeningIncomingConnectionError_ARRAYSIZE = 32 + 1;
const ::std::string& StopListeningIncomingConnectionError_Name(StopListeningIncomingConnectionError value);
template <typename T>
const ::std::string& StopListeningIncomingConnectionError_Name(T value) {
static_assert(::std::is_same<T, StopListeningIncomingConnectionError>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function StopListeningIncomingConnectionError_Name.");
return StopListeningIncomingConnectionError_Name(static_cast<StopListeningIncomingConnectionError>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to StopListeningIncomingConnectionError_Name().");
return StopListeningIncomingConnectionError_Name(static_cast<StopListeningIncomingConnectionError>(value));
}
bool StopListeningIncomingConnectionError_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, StopListeningIncomingConnectionError* value);
::absl::string_view name, StopListeningIncomingConnectionError* PROTOBUF_NONNULL value);
enum ConnectError : int {
UNEXPECT_TARGET_LOST = 31,
ESTABLISH_GATT_CONNECTION_FAILED = 32,
@@ -301,137 +437,172 @@ enum ConnectError : int {
CONNECT_TO_NETWORK_FAILED = 43,
UNKNOWN_CONNECT_ERROR = 44,
CONNECT_SEND_AWARE_L2_MESSAGE_FAILED = 45,
CONNECT_READ_AWARE_L2_MESSAGE_FAILED = 46
CONNECT_READ_AWARE_L2_MESSAGE_FAILED = 46,
};
bool ConnectError_IsValid(int value);
constexpr ConnectError ConnectError_MIN = UNEXPECT_TARGET_LOST;
constexpr ConnectError ConnectError_MAX = CONNECT_READ_AWARE_L2_MESSAGE_FAILED;
constexpr int ConnectError_ARRAYSIZE = ConnectError_MAX + 1;
const std::string& ConnectError_Name(ConnectError value);
template<typename T>
inline const std::string& ConnectError_Name(T enum_t_value) {
extern const uint32_t ConnectError_internal_data_[];
inline constexpr ConnectError ConnectError_MIN =
static_cast<ConnectError>(31);
inline constexpr ConnectError ConnectError_MAX =
static_cast<ConnectError>(46);
inline bool ConnectError_IsValid(int value) {
return 31 <= value && value <= 46;
}
inline constexpr int ConnectError_ARRAYSIZE = 46 + 1;
const ::std::string& ConnectError_Name(ConnectError value);
template <typename T>
const ::std::string& ConnectError_Name(T value) {
static_assert(::std::is_same<T, ConnectError>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function ConnectError_Name.");
return ConnectError_Name(static_cast<ConnectError>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to ConnectError_Name().");
return ConnectError_Name(static_cast<ConnectError>(value));
}
bool ConnectError_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, ConnectError* value);
::absl::string_view name, ConnectError* PROTOBUF_NONNULL value);
enum DisconnectError : int {
DISCONNECT_NETWORK_FAILED = 31,
UNKNOWN_DISCONNECT_ERROR = 32
UNKNOWN_DISCONNECT_ERROR = 32,
};
bool DisconnectError_IsValid(int value);
constexpr DisconnectError DisconnectError_MIN = DISCONNECT_NETWORK_FAILED;
constexpr DisconnectError DisconnectError_MAX = UNKNOWN_DISCONNECT_ERROR;
constexpr int DisconnectError_ARRAYSIZE = DisconnectError_MAX + 1;
const std::string& DisconnectError_Name(DisconnectError value);
template<typename T>
inline const std::string& DisconnectError_Name(T enum_t_value) {
extern const uint32_t DisconnectError_internal_data_[];
inline constexpr DisconnectError DisconnectError_MIN =
static_cast<DisconnectError>(31);
inline constexpr DisconnectError DisconnectError_MAX =
static_cast<DisconnectError>(32);
inline bool DisconnectError_IsValid(int value) {
return 31 <= value && value <= 32;
}
inline constexpr int DisconnectError_ARRAYSIZE = 32 + 1;
const ::std::string& DisconnectError_Name(DisconnectError value);
template <typename T>
const ::std::string& DisconnectError_Name(T value) {
static_assert(::std::is_same<T, DisconnectError>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function DisconnectError_Name.");
return DisconnectError_Name(static_cast<DisconnectError>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to DisconnectError_Name().");
return DisconnectError_Name(static_cast<DisconnectError>(value));
}
bool DisconnectError_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DisconnectError* value);
::absl::string_view name, DisconnectError* PROTOBUF_NONNULL value);
enum SendPayloadError : int {
UNKNOWN_SEND_PAYLOAD_ERROR = 31,
SEND_PAYLOAD_FAILED = 32
SEND_PAYLOAD_FAILED = 32,
};
bool SendPayloadError_IsValid(int value);
constexpr SendPayloadError SendPayloadError_MIN = UNKNOWN_SEND_PAYLOAD_ERROR;
constexpr SendPayloadError SendPayloadError_MAX = SEND_PAYLOAD_FAILED;
constexpr int SendPayloadError_ARRAYSIZE = SendPayloadError_MAX + 1;
const std::string& SendPayloadError_Name(SendPayloadError value);
template<typename T>
inline const std::string& SendPayloadError_Name(T enum_t_value) {
extern const uint32_t SendPayloadError_internal_data_[];
inline constexpr SendPayloadError SendPayloadError_MIN =
static_cast<SendPayloadError>(31);
inline constexpr SendPayloadError SendPayloadError_MAX =
static_cast<SendPayloadError>(32);
inline bool SendPayloadError_IsValid(int value) {
return 31 <= value && value <= 32;
}
inline constexpr int SendPayloadError_ARRAYSIZE = 32 + 1;
const ::std::string& SendPayloadError_Name(SendPayloadError value);
template <typename T>
const ::std::string& SendPayloadError_Name(T value) {
static_assert(::std::is_same<T, SendPayloadError>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function SendPayloadError_Name.");
return SendPayloadError_Name(static_cast<SendPayloadError>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to SendPayloadError_Name().");
return SendPayloadError_Name(static_cast<SendPayloadError>(value));
}
bool SendPayloadError_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, SendPayloadError* value);
::absl::string_view name, SendPayloadError* PROTOBUF_NONNULL value);
enum ReceivePayloadError : int {
UNKNOWN_RECEIVE_PAYLOAD_ERROR = 31,
RECEIVE_PAYLOAD_FAILED = 32
RECEIVE_PAYLOAD_FAILED = 32,
};
bool ReceivePayloadError_IsValid(int value);
constexpr ReceivePayloadError ReceivePayloadError_MIN = UNKNOWN_RECEIVE_PAYLOAD_ERROR;
constexpr ReceivePayloadError ReceivePayloadError_MAX = RECEIVE_PAYLOAD_FAILED;
constexpr int ReceivePayloadError_ARRAYSIZE = ReceivePayloadError_MAX + 1;
const std::string& ReceivePayloadError_Name(ReceivePayloadError value);
template<typename T>
inline const std::string& ReceivePayloadError_Name(T enum_t_value) {
extern const uint32_t ReceivePayloadError_internal_data_[];
inline constexpr ReceivePayloadError ReceivePayloadError_MIN =
static_cast<ReceivePayloadError>(31);
inline constexpr ReceivePayloadError ReceivePayloadError_MAX =
static_cast<ReceivePayloadError>(32);
inline bool ReceivePayloadError_IsValid(int value) {
return 31 <= value && value <= 32;
}
inline constexpr int ReceivePayloadError_ARRAYSIZE = 32 + 1;
const ::std::string& ReceivePayloadError_Name(ReceivePayloadError value);
template <typename T>
const ::std::string& ReceivePayloadError_Name(T value) {
static_assert(::std::is_same<T, ReceivePayloadError>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function ReceivePayloadError_Name.");
return ReceivePayloadError_Name(static_cast<ReceivePayloadError>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to ReceivePayloadError_Name().");
return ReceivePayloadError_Name(static_cast<ReceivePayloadError>(value));
}
bool ReceivePayloadError_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, ReceivePayloadError* value);
::absl::string_view name, ReceivePayloadError* PROTOBUF_NONNULL value);
enum UpgradeError : int {
UNKNOWN_UPGRADE_ERROR = 31,
CREATE_P2P_GROUP_FAILED = 32
CREATE_P2P_GROUP_FAILED = 32,
};
bool UpgradeError_IsValid(int value);
constexpr UpgradeError UpgradeError_MIN = UNKNOWN_UPGRADE_ERROR;
constexpr UpgradeError UpgradeError_MAX = CREATE_P2P_GROUP_FAILED;
constexpr int UpgradeError_ARRAYSIZE = UpgradeError_MAX + 1;
const std::string& UpgradeError_Name(UpgradeError value);
template<typename T>
inline const std::string& UpgradeError_Name(T enum_t_value) {
extern const uint32_t UpgradeError_internal_data_[];
inline constexpr UpgradeError UpgradeError_MIN =
static_cast<UpgradeError>(31);
inline constexpr UpgradeError UpgradeError_MAX =
static_cast<UpgradeError>(32);
inline bool UpgradeError_IsValid(int value) {
return 31 <= value && value <= 32;
}
inline constexpr int UpgradeError_ARRAYSIZE = 32 + 1;
const ::std::string& UpgradeError_Name(UpgradeError value);
template <typename T>
const ::std::string& UpgradeError_Name(T value) {
static_assert(::std::is_same<T, UpgradeError>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function UpgradeError_Name.");
return UpgradeError_Name(static_cast<UpgradeError>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to UpgradeError_Name().");
return UpgradeError_Name(static_cast<UpgradeError>(value));
}
bool UpgradeError_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, UpgradeError* value);
::absl::string_view name, UpgradeError* PROTOBUF_NONNULL value);
enum AcceptConnectionError : int {
UNKNOWN_ACCEPT_CONNECTION_ERROR = 31,
RESPOND_ACCEPT_CONNECTION_FAILED = 32
RESPOND_ACCEPT_CONNECTION_FAILED = 32,
};
bool AcceptConnectionError_IsValid(int value);
constexpr AcceptConnectionError AcceptConnectionError_MIN = UNKNOWN_ACCEPT_CONNECTION_ERROR;
constexpr AcceptConnectionError AcceptConnectionError_MAX = RESPOND_ACCEPT_CONNECTION_FAILED;
constexpr int AcceptConnectionError_ARRAYSIZE = AcceptConnectionError_MAX + 1;
const std::string& AcceptConnectionError_Name(AcceptConnectionError value);
template<typename T>
inline const std::string& AcceptConnectionError_Name(T enum_t_value) {
extern const uint32_t AcceptConnectionError_internal_data_[];
inline constexpr AcceptConnectionError AcceptConnectionError_MIN =
static_cast<AcceptConnectionError>(31);
inline constexpr AcceptConnectionError AcceptConnectionError_MAX =
static_cast<AcceptConnectionError>(32);
inline bool AcceptConnectionError_IsValid(int value) {
return 31 <= value && value <= 32;
}
inline constexpr int AcceptConnectionError_ARRAYSIZE = 32 + 1;
const ::std::string& AcceptConnectionError_Name(AcceptConnectionError value);
template <typename T>
const ::std::string& AcceptConnectionError_Name(T value) {
static_assert(::std::is_same<T, AcceptConnectionError>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function AcceptConnectionError_Name.");
return AcceptConnectionError_Name(static_cast<AcceptConnectionError>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to AcceptConnectionError_Name().");
return AcceptConnectionError_Name(static_cast<AcceptConnectionError>(value));
}
bool AcceptConnectionError_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, AcceptConnectionError* value);
::absl::string_view name, AcceptConnectionError* PROTOBUF_NONNULL value);
enum RejectConnectionError : int {
UNKNOWN_REJECT_CONNECTION_ERROR = 31,
RESPOND_REJECT_CONNECTION_FAILED = 32
RESPOND_REJECT_CONNECTION_FAILED = 32,
};
bool RejectConnectionError_IsValid(int value);
constexpr RejectConnectionError RejectConnectionError_MIN = UNKNOWN_REJECT_CONNECTION_ERROR;
constexpr RejectConnectionError RejectConnectionError_MAX = RESPOND_REJECT_CONNECTION_FAILED;
constexpr int RejectConnectionError_ARRAYSIZE = RejectConnectionError_MAX + 1;
const std::string& RejectConnectionError_Name(RejectConnectionError value);
template<typename T>
inline const std::string& RejectConnectionError_Name(T enum_t_value) {
extern const uint32_t RejectConnectionError_internal_data_[];
inline constexpr RejectConnectionError RejectConnectionError_MIN =
static_cast<RejectConnectionError>(31);
inline constexpr RejectConnectionError RejectConnectionError_MAX =
static_cast<RejectConnectionError>(32);
inline bool RejectConnectionError_IsValid(int value) {
return 31 <= value && value <= 32;
}
inline constexpr int RejectConnectionError_ARRAYSIZE = 32 + 1;
const ::std::string& RejectConnectionError_Name(RejectConnectionError value);
template <typename T>
const ::std::string& RejectConnectionError_Name(T value) {
static_assert(::std::is_same<T, RejectConnectionError>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function RejectConnectionError_Name.");
return RejectConnectionError_Name(static_cast<RejectConnectionError>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to RejectConnectionError_Name().");
return RejectConnectionError_Name(static_cast<RejectConnectionError>(value));
}
bool RejectConnectionError_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, RejectConnectionError* value);
::absl::string_view name, RejectConnectionError* PROTOBUF_NONNULL value);
enum Description : int {
UNKNOWN = 0,
NULL_SERVICE_ID = 1,
@@ -618,69 +789,99 @@ enum Description : int {
MULTIPLEX_SOCKET_IOEXCEPTION = 184,
MULTIPLEX_SOCKET_UNKNOWN_RESPONSE_CODE = 185,
MULTIPLEX_SOCKET_EXECUTION_EXCEPTION = 186,
MULTIPLEX_SOCKET_INTERRUPTED_EXCEPTION = 187
MULTIPLEX_SOCKET_INTERRUPTED_EXCEPTION = 187,
};
bool Description_IsValid(int value);
constexpr Description Description_MIN = UNKNOWN;
constexpr Description Description_MAX = MULTIPLEX_SOCKET_INTERRUPTED_EXCEPTION;
constexpr int Description_ARRAYSIZE = Description_MAX + 1;
const std::string& Description_Name(Description value);
template<typename T>
inline const std::string& Description_Name(T enum_t_value) {
extern const uint32_t Description_internal_data_[];
inline constexpr Description Description_MIN =
static_cast<Description>(0);
inline constexpr Description Description_MAX =
static_cast<Description>(187);
inline bool Description_IsValid(int value) {
return ::google::protobuf::internal::ValidateEnum(value, Description_internal_data_);
}
inline constexpr int Description_ARRAYSIZE = 187 + 1;
const ::std::string& Description_Name(Description value);
template <typename T>
const ::std::string& Description_Name(T value) {
static_assert(::std::is_same<T, Description>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function Description_Name.");
return Description_Name(static_cast<Description>(enum_t_value));
::std::is_integral<T>::value,
"Incorrect type passed to Description_Name().");
return Description_Name(static_cast<Description>(value));
}
bool Description_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Description* value);
::absl::string_view name, Description* PROTOBUF_NONNULL value);
// ===================================================================
// ===================================================================
// ===================================================================
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
#ifdef __GNUC__
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#endif // __GNUC__
// @@protoc_insertion_point(namespace_scope)
} // namespace proto
} // namespace errorcode
} // namespace nearby
} // namespace location
PROTOBUF_NAMESPACE_OPEN
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::ErrorType> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::Event> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::CommonError> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::StartAdvertisingError> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::StopAdvertisingError> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::StartDiscoveringError> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::StopDiscoveringError> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::StartListeningIncomingConnectionError> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::StopListeningIncomingConnectionError> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::ConnectError> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::DisconnectError> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::SendPayloadError> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::ReceivePayloadError> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::UpgradeError> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::AcceptConnectionError> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::RejectConnectionError> : ::std::true_type {};
template <> struct is_proto_enum< ::location::nearby::errorcode::proto::Description> : ::std::true_type {};
namespace google {
namespace protobuf {
PROTOBUF_NAMESPACE_CLOSE
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::ErrorType> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::Event> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::CommonError> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::StartAdvertisingError> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::StopAdvertisingError> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::StartDiscoveringError> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::StopDiscoveringError> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::StartListeningIncomingConnectionError> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::StopListeningIncomingConnectionError> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::ConnectError> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::DisconnectError> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::SendPayloadError> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::ReceivePayloadError> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::UpgradeError> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::AcceptConnectionError> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::RejectConnectionError> : std::true_type {};
template <>
struct is_proto_enum<::location::nearby::errorcode::proto::Description> : std::true_type {};
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_proto_2ferrorcode_2ferror_5fcode_5fenums_2eproto
#include "google/protobuf/port_undef.inc"
#endif // proto_2ferrorcode_2ferror_5fcode_5fenums_2eproto_2epb_2eh
-748
View File
@@ -1,748 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: proto/fast_pair_enums.proto
#include "proto/fast_pair_enums.pb.h"
#include <algorithm>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
PROTOBUF_PRAGMA_INIT_SEG
namespace nearby {
namespace proto {
namespace fastpair {
constexpr FastPairEvent::FastPairEvent(
::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized){}
struct FastPairEventDefaultTypeInternal {
constexpr FastPairEventDefaultTypeInternal()
: _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
~FastPairEventDefaultTypeInternal() {}
union {
FastPairEvent _instance;
};
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT FastPairEventDefaultTypeInternal _FastPairEvent_default_instance_;
} // namespace fastpair
} // namespace proto
} // namespace nearby
namespace nearby {
namespace proto {
namespace fastpair {
bool FastPairEvent_BondState_IsValid(int value) {
switch (value) {
case 0:
case 10:
case 11:
case 12:
return true;
default:
return false;
}
}
static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> FastPairEvent_BondState_strings[4] = {};
static const char FastPairEvent_BondState_names[] =
"BONDED"
"BONDING"
"NONE"
"UNKNOWN_BOND_STATE";
static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry FastPairEvent_BondState_entries[] = {
{ {FastPairEvent_BondState_names + 0, 6}, 12 },
{ {FastPairEvent_BondState_names + 6, 7}, 11 },
{ {FastPairEvent_BondState_names + 13, 4}, 10 },
{ {FastPairEvent_BondState_names + 17, 18}, 0 },
};
static const int FastPairEvent_BondState_entries_by_number[] = {
3, // 0 -> UNKNOWN_BOND_STATE
2, // 10 -> NONE
1, // 11 -> BONDING
0, // 12 -> BONDED
};
const std::string& FastPairEvent_BondState_Name(
FastPairEvent_BondState value) {
static const bool dummy =
::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings(
FastPairEvent_BondState_entries,
FastPairEvent_BondState_entries_by_number,
4, FastPairEvent_BondState_strings);
(void) dummy;
int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName(
FastPairEvent_BondState_entries,
FastPairEvent_BondState_entries_by_number,
4, value);
return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() :
FastPairEvent_BondState_strings[idx].get();
}
bool FastPairEvent_BondState_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FastPairEvent_BondState* value) {
int int_value;
bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue(
FastPairEvent_BondState_entries, 4, name, &int_value);
if (success) {
*value = static_cast<FastPairEvent_BondState>(int_value);
}
return success;
}
#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr FastPairEvent_BondState FastPairEvent::UNKNOWN_BOND_STATE;
constexpr FastPairEvent_BondState FastPairEvent::NONE;
constexpr FastPairEvent_BondState FastPairEvent::BONDING;
constexpr FastPairEvent_BondState FastPairEvent::BONDED;
constexpr FastPairEvent_BondState FastPairEvent::BondState_MIN;
constexpr FastPairEvent_BondState FastPairEvent::BondState_MAX;
constexpr int FastPairEvent::BondState_ARRAYSIZE;
#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
bool FastPairEvent_ErrorCode_IsValid(int value) {
switch (value) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
return true;
default:
return false;
}
}
static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> FastPairEvent_ErrorCode_strings[17] = {};
static const char FastPairEvent_ErrorCode_names[] =
"DEVICE_NOT_BONDED_DURING_RETROACTIVE_PAIR"
"DEVICE_NOT_IN_PAIRED_HISTORY_EXCEPTION"
"EXECUTION_EXCEPTION"
"INTERRUPTED"
"MDH_REMOTE_EXCEPTION"
"OTHER_ERROR"
"PARSE_EXCEPTION"
"REFLECTIVE_OPERATION_EXCEPTION"
"SUCCESS_ADDRESS_ROTATE"
"SUCCESS_RETRY_GATT_ERROR"
"SUCCESS_RETRY_GATT_TIMEOUT"
"SUCCESS_RETRY_SECRET_HANDSHAKE_ERROR"
"SUCCESS_RETRY_SECRET_HANDSHAKE_TIMEOUT"
"SUCCESS_SECRET_HANDSHAKE_RECONNECT"
"SUCCESS_SIGNAL_LOST"
"TIMEOUT"
"UNKNOWN_ERROR_CODE";
static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry FastPairEvent_ErrorCode_entries[] = {
{ {FastPairEvent_ErrorCode_names + 0, 41}, 16 },
{ {FastPairEvent_ErrorCode_names + 41, 38}, 15 },
{ {FastPairEvent_ErrorCode_names + 79, 19}, 5 },
{ {FastPairEvent_ErrorCode_names + 98, 11}, 3 },
{ {FastPairEvent_ErrorCode_names + 109, 20}, 7 },
{ {FastPairEvent_ErrorCode_names + 129, 11}, 1 },
{ {FastPairEvent_ErrorCode_names + 140, 15}, 6 },
{ {FastPairEvent_ErrorCode_names + 155, 30}, 4 },
{ {FastPairEvent_ErrorCode_names + 185, 22}, 13 },
{ {FastPairEvent_ErrorCode_names + 207, 24}, 8 },
{ {FastPairEvent_ErrorCode_names + 231, 26}, 9 },
{ {FastPairEvent_ErrorCode_names + 257, 36}, 10 },
{ {FastPairEvent_ErrorCode_names + 293, 38}, 11 },
{ {FastPairEvent_ErrorCode_names + 331, 34}, 12 },
{ {FastPairEvent_ErrorCode_names + 365, 19}, 14 },
{ {FastPairEvent_ErrorCode_names + 384, 7}, 2 },
{ {FastPairEvent_ErrorCode_names + 391, 18}, 0 },
};
static const int FastPairEvent_ErrorCode_entries_by_number[] = {
16, // 0 -> UNKNOWN_ERROR_CODE
5, // 1 -> OTHER_ERROR
15, // 2 -> TIMEOUT
3, // 3 -> INTERRUPTED
7, // 4 -> REFLECTIVE_OPERATION_EXCEPTION
2, // 5 -> EXECUTION_EXCEPTION
6, // 6 -> PARSE_EXCEPTION
4, // 7 -> MDH_REMOTE_EXCEPTION
9, // 8 -> SUCCESS_RETRY_GATT_ERROR
10, // 9 -> SUCCESS_RETRY_GATT_TIMEOUT
11, // 10 -> SUCCESS_RETRY_SECRET_HANDSHAKE_ERROR
12, // 11 -> SUCCESS_RETRY_SECRET_HANDSHAKE_TIMEOUT
13, // 12 -> SUCCESS_SECRET_HANDSHAKE_RECONNECT
8, // 13 -> SUCCESS_ADDRESS_ROTATE
14, // 14 -> SUCCESS_SIGNAL_LOST
1, // 15 -> DEVICE_NOT_IN_PAIRED_HISTORY_EXCEPTION
0, // 16 -> DEVICE_NOT_BONDED_DURING_RETROACTIVE_PAIR
};
const std::string& FastPairEvent_ErrorCode_Name(
FastPairEvent_ErrorCode value) {
static const bool dummy =
::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings(
FastPairEvent_ErrorCode_entries,
FastPairEvent_ErrorCode_entries_by_number,
17, FastPairEvent_ErrorCode_strings);
(void) dummy;
int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName(
FastPairEvent_ErrorCode_entries,
FastPairEvent_ErrorCode_entries_by_number,
17, value);
return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() :
FastPairEvent_ErrorCode_strings[idx].get();
}
bool FastPairEvent_ErrorCode_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FastPairEvent_ErrorCode* value) {
int int_value;
bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue(
FastPairEvent_ErrorCode_entries, 17, name, &int_value);
if (success) {
*value = static_cast<FastPairEvent_ErrorCode>(int_value);
}
return success;
}
#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr FastPairEvent_ErrorCode FastPairEvent::UNKNOWN_ERROR_CODE;
constexpr FastPairEvent_ErrorCode FastPairEvent::OTHER_ERROR;
constexpr FastPairEvent_ErrorCode FastPairEvent::TIMEOUT;
constexpr FastPairEvent_ErrorCode FastPairEvent::INTERRUPTED;
constexpr FastPairEvent_ErrorCode FastPairEvent::REFLECTIVE_OPERATION_EXCEPTION;
constexpr FastPairEvent_ErrorCode FastPairEvent::EXECUTION_EXCEPTION;
constexpr FastPairEvent_ErrorCode FastPairEvent::PARSE_EXCEPTION;
constexpr FastPairEvent_ErrorCode FastPairEvent::MDH_REMOTE_EXCEPTION;
constexpr FastPairEvent_ErrorCode FastPairEvent::SUCCESS_RETRY_GATT_ERROR;
constexpr FastPairEvent_ErrorCode FastPairEvent::SUCCESS_RETRY_GATT_TIMEOUT;
constexpr FastPairEvent_ErrorCode FastPairEvent::SUCCESS_RETRY_SECRET_HANDSHAKE_ERROR;
constexpr FastPairEvent_ErrorCode FastPairEvent::SUCCESS_RETRY_SECRET_HANDSHAKE_TIMEOUT;
constexpr FastPairEvent_ErrorCode FastPairEvent::SUCCESS_SECRET_HANDSHAKE_RECONNECT;
constexpr FastPairEvent_ErrorCode FastPairEvent::SUCCESS_ADDRESS_ROTATE;
constexpr FastPairEvent_ErrorCode FastPairEvent::SUCCESS_SIGNAL_LOST;
constexpr FastPairEvent_ErrorCode FastPairEvent::DEVICE_NOT_IN_PAIRED_HISTORY_EXCEPTION;
constexpr FastPairEvent_ErrorCode FastPairEvent::DEVICE_NOT_BONDED_DURING_RETROACTIVE_PAIR;
constexpr FastPairEvent_ErrorCode FastPairEvent::ErrorCode_MIN;
constexpr FastPairEvent_ErrorCode FastPairEvent::ErrorCode_MAX;
constexpr int FastPairEvent::ErrorCode_ARRAYSIZE;
#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
bool FastPairEvent_BrEdrHandoverErrorCode_IsValid(int value) {
switch (value) {
case 0:
case 1:
case 2:
case 3:
return true;
default:
return false;
}
}
static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> FastPairEvent_BrEdrHandoverErrorCode_strings[4] = {};
static const char FastPairEvent_BrEdrHandoverErrorCode_names[] =
"BLUETOOTH_MAC_INVALID"
"CONTROL_POINT_RESULT_CODE_NOT_SUCCESS"
"TRANSPORT_BLOCK_INVALID"
"UNKNOWN_BR_EDR_HANDOVER_ERROR_CODE";
static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry FastPairEvent_BrEdrHandoverErrorCode_entries[] = {
{ {FastPairEvent_BrEdrHandoverErrorCode_names + 0, 21}, 2 },
{ {FastPairEvent_BrEdrHandoverErrorCode_names + 21, 37}, 1 },
{ {FastPairEvent_BrEdrHandoverErrorCode_names + 58, 23}, 3 },
{ {FastPairEvent_BrEdrHandoverErrorCode_names + 81, 34}, 0 },
};
static const int FastPairEvent_BrEdrHandoverErrorCode_entries_by_number[] = {
3, // 0 -> UNKNOWN_BR_EDR_HANDOVER_ERROR_CODE
1, // 1 -> CONTROL_POINT_RESULT_CODE_NOT_SUCCESS
0, // 2 -> BLUETOOTH_MAC_INVALID
2, // 3 -> TRANSPORT_BLOCK_INVALID
};
const std::string& FastPairEvent_BrEdrHandoverErrorCode_Name(
FastPairEvent_BrEdrHandoverErrorCode value) {
static const bool dummy =
::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings(
FastPairEvent_BrEdrHandoverErrorCode_entries,
FastPairEvent_BrEdrHandoverErrorCode_entries_by_number,
4, FastPairEvent_BrEdrHandoverErrorCode_strings);
(void) dummy;
int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName(
FastPairEvent_BrEdrHandoverErrorCode_entries,
FastPairEvent_BrEdrHandoverErrorCode_entries_by_number,
4, value);
return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() :
FastPairEvent_BrEdrHandoverErrorCode_strings[idx].get();
}
bool FastPairEvent_BrEdrHandoverErrorCode_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FastPairEvent_BrEdrHandoverErrorCode* value) {
int int_value;
bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue(
FastPairEvent_BrEdrHandoverErrorCode_entries, 4, name, &int_value);
if (success) {
*value = static_cast<FastPairEvent_BrEdrHandoverErrorCode>(int_value);
}
return success;
}
#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr FastPairEvent_BrEdrHandoverErrorCode FastPairEvent::UNKNOWN_BR_EDR_HANDOVER_ERROR_CODE;
constexpr FastPairEvent_BrEdrHandoverErrorCode FastPairEvent::CONTROL_POINT_RESULT_CODE_NOT_SUCCESS;
constexpr FastPairEvent_BrEdrHandoverErrorCode FastPairEvent::BLUETOOTH_MAC_INVALID;
constexpr FastPairEvent_BrEdrHandoverErrorCode FastPairEvent::TRANSPORT_BLOCK_INVALID;
constexpr FastPairEvent_BrEdrHandoverErrorCode FastPairEvent::BrEdrHandoverErrorCode_MIN;
constexpr FastPairEvent_BrEdrHandoverErrorCode FastPairEvent::BrEdrHandoverErrorCode_MAX;
constexpr int FastPairEvent::BrEdrHandoverErrorCode_ARRAYSIZE;
#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
bool FastPairEvent_CreateBondErrorCode_IsValid(int value) {
switch (value) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
return true;
default:
return false;
}
}
static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> FastPairEvent_CreateBondErrorCode_strings[6] = {};
static const char FastPairEvent_CreateBondErrorCode_names[] =
"BOND_BROKEN"
"FAILED_BUT_ALREADY_RECEIVE_PASS_KEY"
"INCORRECT_VARIANT"
"NO_PERMISSION"
"POSSIBLE_MITM"
"UNKNOWN_BOND_ERROR_CODE";
static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry FastPairEvent_CreateBondErrorCode_entries[] = {
{ {FastPairEvent_CreateBondErrorCode_names + 0, 11}, 1 },
{ {FastPairEvent_CreateBondErrorCode_names + 11, 35}, 5 },
{ {FastPairEvent_CreateBondErrorCode_names + 46, 17}, 4 },
{ {FastPairEvent_CreateBondErrorCode_names + 63, 13}, 3 },
{ {FastPairEvent_CreateBondErrorCode_names + 76, 13}, 2 },
{ {FastPairEvent_CreateBondErrorCode_names + 89, 23}, 0 },
};
static const int FastPairEvent_CreateBondErrorCode_entries_by_number[] = {
5, // 0 -> UNKNOWN_BOND_ERROR_CODE
0, // 1 -> BOND_BROKEN
4, // 2 -> POSSIBLE_MITM
3, // 3 -> NO_PERMISSION
2, // 4 -> INCORRECT_VARIANT
1, // 5 -> FAILED_BUT_ALREADY_RECEIVE_PASS_KEY
};
const std::string& FastPairEvent_CreateBondErrorCode_Name(
FastPairEvent_CreateBondErrorCode value) {
static const bool dummy =
::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings(
FastPairEvent_CreateBondErrorCode_entries,
FastPairEvent_CreateBondErrorCode_entries_by_number,
6, FastPairEvent_CreateBondErrorCode_strings);
(void) dummy;
int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName(
FastPairEvent_CreateBondErrorCode_entries,
FastPairEvent_CreateBondErrorCode_entries_by_number,
6, value);
return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() :
FastPairEvent_CreateBondErrorCode_strings[idx].get();
}
bool FastPairEvent_CreateBondErrorCode_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FastPairEvent_CreateBondErrorCode* value) {
int int_value;
bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue(
FastPairEvent_CreateBondErrorCode_entries, 6, name, &int_value);
if (success) {
*value = static_cast<FastPairEvent_CreateBondErrorCode>(int_value);
}
return success;
}
#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr FastPairEvent_CreateBondErrorCode FastPairEvent::UNKNOWN_BOND_ERROR_CODE;
constexpr FastPairEvent_CreateBondErrorCode FastPairEvent::BOND_BROKEN;
constexpr FastPairEvent_CreateBondErrorCode FastPairEvent::POSSIBLE_MITM;
constexpr FastPairEvent_CreateBondErrorCode FastPairEvent::NO_PERMISSION;
constexpr FastPairEvent_CreateBondErrorCode FastPairEvent::INCORRECT_VARIANT;
constexpr FastPairEvent_CreateBondErrorCode FastPairEvent::FAILED_BUT_ALREADY_RECEIVE_PASS_KEY;
constexpr FastPairEvent_CreateBondErrorCode FastPairEvent::CreateBondErrorCode_MIN;
constexpr FastPairEvent_CreateBondErrorCode FastPairEvent::CreateBondErrorCode_MAX;
constexpr int FastPairEvent::CreateBondErrorCode_ARRAYSIZE;
#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
bool FastPairEvent_ConnectErrorCode_IsValid(int value) {
switch (value) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return true;
default:
return false;
}
}
static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> FastPairEvent_ConnectErrorCode_strings[7] = {};
static const char FastPairEvent_ConnectErrorCode_names[] =
"DISCONNECTED"
"DISCOVERY_NOT_FINISHED"
"FAIL_TO_DISCOVERY"
"GET_PROFILE_PROXY_FAILED"
"LINK_KEY_CLEARED"
"UNKNOWN_CONNECT_ERROR_CODE"
"UNSUPPORTED_PROFILE";
static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry FastPairEvent_ConnectErrorCode_entries[] = {
{ {FastPairEvent_ConnectErrorCode_names + 0, 12}, 3 },
{ {FastPairEvent_ConnectErrorCode_names + 12, 22}, 6 },
{ {FastPairEvent_ConnectErrorCode_names + 34, 17}, 5 },
{ {FastPairEvent_ConnectErrorCode_names + 51, 24}, 2 },
{ {FastPairEvent_ConnectErrorCode_names + 75, 16}, 4 },
{ {FastPairEvent_ConnectErrorCode_names + 91, 26}, 0 },
{ {FastPairEvent_ConnectErrorCode_names + 117, 19}, 1 },
};
static const int FastPairEvent_ConnectErrorCode_entries_by_number[] = {
5, // 0 -> UNKNOWN_CONNECT_ERROR_CODE
6, // 1 -> UNSUPPORTED_PROFILE
3, // 2 -> GET_PROFILE_PROXY_FAILED
0, // 3 -> DISCONNECTED
4, // 4 -> LINK_KEY_CLEARED
2, // 5 -> FAIL_TO_DISCOVERY
1, // 6 -> DISCOVERY_NOT_FINISHED
};
const std::string& FastPairEvent_ConnectErrorCode_Name(
FastPairEvent_ConnectErrorCode value) {
static const bool dummy =
::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings(
FastPairEvent_ConnectErrorCode_entries,
FastPairEvent_ConnectErrorCode_entries_by_number,
7, FastPairEvent_ConnectErrorCode_strings);
(void) dummy;
int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName(
FastPairEvent_ConnectErrorCode_entries,
FastPairEvent_ConnectErrorCode_entries_by_number,
7, value);
return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() :
FastPairEvent_ConnectErrorCode_strings[idx].get();
}
bool FastPairEvent_ConnectErrorCode_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FastPairEvent_ConnectErrorCode* value) {
int int_value;
bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue(
FastPairEvent_ConnectErrorCode_entries, 7, name, &int_value);
if (success) {
*value = static_cast<FastPairEvent_ConnectErrorCode>(int_value);
}
return success;
}
#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr FastPairEvent_ConnectErrorCode FastPairEvent::UNKNOWN_CONNECT_ERROR_CODE;
constexpr FastPairEvent_ConnectErrorCode FastPairEvent::UNSUPPORTED_PROFILE;
constexpr FastPairEvent_ConnectErrorCode FastPairEvent::GET_PROFILE_PROXY_FAILED;
constexpr FastPairEvent_ConnectErrorCode FastPairEvent::DISCONNECTED;
constexpr FastPairEvent_ConnectErrorCode FastPairEvent::LINK_KEY_CLEARED;
constexpr FastPairEvent_ConnectErrorCode FastPairEvent::FAIL_TO_DISCOVERY;
constexpr FastPairEvent_ConnectErrorCode FastPairEvent::DISCOVERY_NOT_FINISHED;
constexpr FastPairEvent_ConnectErrorCode FastPairEvent::ConnectErrorCode_MIN;
constexpr FastPairEvent_ConnectErrorCode FastPairEvent::ConnectErrorCode_MAX;
constexpr int FastPairEvent::ConnectErrorCode_ARRAYSIZE;
#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
bool DeviceType_IsValid(int value) {
switch (value) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return true;
default:
return false;
}
}
static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> DeviceType_strings[7] = {};
static const char DeviceType_names[] =
"AUTO"
"PC"
"PHONE"
"TABLET"
"TV"
"UNKNOWN_DEVICE_TYPE"
"WEARABLE";
static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry DeviceType_entries[] = {
{ {DeviceType_names + 0, 4}, 3 },
{ {DeviceType_names + 4, 2}, 4 },
{ {DeviceType_names + 6, 5}, 1 },
{ {DeviceType_names + 11, 6}, 6 },
{ {DeviceType_names + 17, 2}, 5 },
{ {DeviceType_names + 19, 19}, 0 },
{ {DeviceType_names + 38, 8}, 2 },
};
static const int DeviceType_entries_by_number[] = {
5, // 0 -> UNKNOWN_DEVICE_TYPE
2, // 1 -> PHONE
6, // 2 -> WEARABLE
0, // 3 -> AUTO
1, // 4 -> PC
4, // 5 -> TV
3, // 6 -> TABLET
};
const std::string& DeviceType_Name(
DeviceType value) {
static const bool dummy =
::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings(
DeviceType_entries,
DeviceType_entries_by_number,
7, DeviceType_strings);
(void) dummy;
int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName(
DeviceType_entries,
DeviceType_entries_by_number,
7, value);
return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() :
DeviceType_strings[idx].get();
}
bool DeviceType_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DeviceType* value) {
int int_value;
bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue(
DeviceType_entries, 7, name, &int_value);
if (success) {
*value = static_cast<DeviceType>(int_value);
}
return success;
}
bool OsType_IsValid(int value) {
switch (value) {
case 0:
case 1:
case 2:
return true;
default:
return false;
}
}
static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> OsType_strings[3] = {};
static const char OsType_names[] =
"ANDROID"
"CHROME_OS"
"UNKNOWN_OS_TYPE";
static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry OsType_entries[] = {
{ {OsType_names + 0, 7}, 1 },
{ {OsType_names + 7, 9}, 2 },
{ {OsType_names + 16, 15}, 0 },
};
static const int OsType_entries_by_number[] = {
2, // 0 -> UNKNOWN_OS_TYPE
0, // 1 -> ANDROID
1, // 2 -> CHROME_OS
};
const std::string& OsType_Name(
OsType value) {
static const bool dummy =
::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings(
OsType_entries,
OsType_entries_by_number,
3, OsType_strings);
(void) dummy;
int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName(
OsType_entries,
OsType_entries_by_number,
3, value);
return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() :
OsType_strings[idx].get();
}
bool OsType_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, OsType* value) {
int int_value;
bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue(
OsType_entries, 3, name, &int_value);
if (success) {
*value = static_cast<OsType>(int_value);
}
return success;
}
// ===================================================================
class FastPairEvent::_Internal {
public:
};
FastPairEvent::FastPairEvent(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned)
: ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
SharedCtor();
if (!is_message_owned) {
RegisterArenaDtor(arena);
}
// @@protoc_insertion_point(arena_constructor:nearby.proto.fastpair.FastPairEvent)
}
FastPairEvent::FastPairEvent(const FastPairEvent& from)
: ::PROTOBUF_NAMESPACE_ID::MessageLite() {
_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:nearby.proto.fastpair.FastPairEvent)
}
inline void FastPairEvent::SharedCtor() {
}
FastPairEvent::~FastPairEvent() {
// @@protoc_insertion_point(destructor:nearby.proto.fastpair.FastPairEvent)
if (GetArenaForAllocation() != nullptr) return;
SharedDtor();
_internal_metadata_.Delete<std::string>();
}
inline void FastPairEvent::SharedDtor() {
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}
void FastPairEvent::ArenaDtor(void* object) {
FastPairEvent* _this = reinterpret_cast< FastPairEvent* >(object);
(void)_this;
}
void FastPairEvent::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void FastPairEvent::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
void FastPairEvent::Clear() {
// @@protoc_insertion_point(message_clear_start:nearby.proto.fastpair.FastPairEvent)
uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
_internal_metadata_.Clear<std::string>();
}
const char* FastPairEvent::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
while (!ctx->Done(&ptr)) {
uint32_t tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
if ((tag == 0) || ((tag & 7) == 4)) {
CHK_(ptr);
ctx->SetLastTag(tag);
goto message_done;
}
ptr = UnknownFieldParse(
tag,
_internal_metadata_.mutable_unknown_fields<std::string>(),
ptr, ctx);
CHK_(ptr != nullptr);
} // while
message_done:
return ptr;
failure:
ptr = nullptr;
goto message_done;
#undef CHK_
}
uint8_t* FastPairEvent::_InternalSerialize(
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:nearby.proto.fastpair.FastPairEvent)
uint32_t cached_has_bits = 0;
(void) cached_has_bits;
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
}
// @@protoc_insertion_point(serialize_to_array_end:nearby.proto.fastpair.FastPairEvent)
return target;
}
size_t FastPairEvent::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:nearby.proto.fastpair.FastPairEvent)
size_t total_size = 0;
uint32_t cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void FastPairEvent::CheckTypeAndMergeFrom(
const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast<const FastPairEvent*>(
&from));
}
void FastPairEvent::MergeFrom(const FastPairEvent& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:nearby.proto.fastpair.FastPairEvent)
GOOGLE_DCHECK_NE(&from, this);
uint32_t cached_has_bits = 0;
(void) cached_has_bits;
_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}
void FastPairEvent::CopyFrom(const FastPairEvent& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:nearby.proto.fastpair.FastPairEvent)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool FastPairEvent::IsInitialized() const {
return true;
}
void FastPairEvent::InternalSwap(FastPairEvent* other) {
using std::swap;
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
}
std::string FastPairEvent::GetTypeName() const {
return "nearby.proto.fastpair.FastPairEvent";
}
// @@protoc_insertion_point(namespace_scope)
} // namespace fastpair
} // namespace proto
} // namespace nearby
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::nearby::proto::fastpair::FastPairEvent* Arena::CreateMaybeMessage< ::nearby::proto::fastpair::FastPairEvent >(Arena* arena) {
return Arena::CreateMessageInternal< ::nearby::proto::fastpair::FastPairEvent >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
-583
View File
@@ -1,583 +0,0 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: proto/fast_pair_enums.proto
#ifndef GOOGLE_PROTOBUF_INCLUDED_proto_2ffast_5fpair_5fenums_2eproto
#define GOOGLE_PROTOBUF_INCLUDED_proto_2ffast_5fpair_5fenums_2eproto
#include <limits>
#include <string>
#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3019000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3019001 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
#include <google/protobuf/port_undef.inc>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata_lite.h>
#include <google/protobuf/message_lite.h>
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/generated_enum_util.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
#define PROTOBUF_INTERNAL_EXPORT_proto_2ffast_5fpair_5fenums_2eproto
PROTOBUF_NAMESPACE_OPEN
namespace internal {
class AnyMetadata;
} // namespace internal
PROTOBUF_NAMESPACE_CLOSE
// Internal implementation detail -- do not use these members.
struct TableStruct_proto_2ffast_5fpair_5fenums_2eproto {
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTableField entries[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::AuxiliaryParseTableField aux[]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[1]
PROTOBUF_SECTION_VARIABLE(protodesc_cold);
static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[];
static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[];
static const uint32_t offsets[];
};
namespace nearby {
namespace proto {
namespace fastpair {
class FastPairEvent;
struct FastPairEventDefaultTypeInternal;
extern FastPairEventDefaultTypeInternal _FastPairEvent_default_instance_;
} // namespace fastpair
} // namespace proto
} // namespace nearby
PROTOBUF_NAMESPACE_OPEN
template<> ::nearby::proto::fastpair::FastPairEvent* Arena::CreateMaybeMessage<::nearby::proto::fastpair::FastPairEvent>(Arena*);
PROTOBUF_NAMESPACE_CLOSE
namespace nearby {
namespace proto {
namespace fastpair {
enum FastPairEvent_BondState : int {
FastPairEvent_BondState_UNKNOWN_BOND_STATE = 0,
FastPairEvent_BondState_NONE = 10,
FastPairEvent_BondState_BONDING = 11,
FastPairEvent_BondState_BONDED = 12
};
bool FastPairEvent_BondState_IsValid(int value);
constexpr FastPairEvent_BondState FastPairEvent_BondState_BondState_MIN = FastPairEvent_BondState_UNKNOWN_BOND_STATE;
constexpr FastPairEvent_BondState FastPairEvent_BondState_BondState_MAX = FastPairEvent_BondState_BONDED;
constexpr int FastPairEvent_BondState_BondState_ARRAYSIZE = FastPairEvent_BondState_BondState_MAX + 1;
const std::string& FastPairEvent_BondState_Name(FastPairEvent_BondState value);
template<typename T>
inline const std::string& FastPairEvent_BondState_Name(T enum_t_value) {
static_assert(::std::is_same<T, FastPairEvent_BondState>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function FastPairEvent_BondState_Name.");
return FastPairEvent_BondState_Name(static_cast<FastPairEvent_BondState>(enum_t_value));
}
bool FastPairEvent_BondState_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FastPairEvent_BondState* value);
enum FastPairEvent_ErrorCode : int {
FastPairEvent_ErrorCode_UNKNOWN_ERROR_CODE = 0,
FastPairEvent_ErrorCode_OTHER_ERROR = 1,
FastPairEvent_ErrorCode_TIMEOUT = 2,
FastPairEvent_ErrorCode_INTERRUPTED = 3,
FastPairEvent_ErrorCode_REFLECTIVE_OPERATION_EXCEPTION = 4,
FastPairEvent_ErrorCode_EXECUTION_EXCEPTION = 5,
FastPairEvent_ErrorCode_PARSE_EXCEPTION = 6,
FastPairEvent_ErrorCode_MDH_REMOTE_EXCEPTION = 7,
FastPairEvent_ErrorCode_SUCCESS_RETRY_GATT_ERROR = 8,
FastPairEvent_ErrorCode_SUCCESS_RETRY_GATT_TIMEOUT = 9,
FastPairEvent_ErrorCode_SUCCESS_RETRY_SECRET_HANDSHAKE_ERROR = 10,
FastPairEvent_ErrorCode_SUCCESS_RETRY_SECRET_HANDSHAKE_TIMEOUT = 11,
FastPairEvent_ErrorCode_SUCCESS_SECRET_HANDSHAKE_RECONNECT = 12,
FastPairEvent_ErrorCode_SUCCESS_ADDRESS_ROTATE = 13,
FastPairEvent_ErrorCode_SUCCESS_SIGNAL_LOST = 14,
FastPairEvent_ErrorCode_DEVICE_NOT_IN_PAIRED_HISTORY_EXCEPTION = 15,
FastPairEvent_ErrorCode_DEVICE_NOT_BONDED_DURING_RETROACTIVE_PAIR = 16
};
bool FastPairEvent_ErrorCode_IsValid(int value);
constexpr FastPairEvent_ErrorCode FastPairEvent_ErrorCode_ErrorCode_MIN = FastPairEvent_ErrorCode_UNKNOWN_ERROR_CODE;
constexpr FastPairEvent_ErrorCode FastPairEvent_ErrorCode_ErrorCode_MAX = FastPairEvent_ErrorCode_DEVICE_NOT_BONDED_DURING_RETROACTIVE_PAIR;
constexpr int FastPairEvent_ErrorCode_ErrorCode_ARRAYSIZE = FastPairEvent_ErrorCode_ErrorCode_MAX + 1;
const std::string& FastPairEvent_ErrorCode_Name(FastPairEvent_ErrorCode value);
template<typename T>
inline const std::string& FastPairEvent_ErrorCode_Name(T enum_t_value) {
static_assert(::std::is_same<T, FastPairEvent_ErrorCode>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function FastPairEvent_ErrorCode_Name.");
return FastPairEvent_ErrorCode_Name(static_cast<FastPairEvent_ErrorCode>(enum_t_value));
}
bool FastPairEvent_ErrorCode_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FastPairEvent_ErrorCode* value);
enum FastPairEvent_BrEdrHandoverErrorCode : int {
FastPairEvent_BrEdrHandoverErrorCode_UNKNOWN_BR_EDR_HANDOVER_ERROR_CODE = 0,
FastPairEvent_BrEdrHandoverErrorCode_CONTROL_POINT_RESULT_CODE_NOT_SUCCESS = 1,
FastPairEvent_BrEdrHandoverErrorCode_BLUETOOTH_MAC_INVALID = 2,
FastPairEvent_BrEdrHandoverErrorCode_TRANSPORT_BLOCK_INVALID = 3
};
bool FastPairEvent_BrEdrHandoverErrorCode_IsValid(int value);
constexpr FastPairEvent_BrEdrHandoverErrorCode FastPairEvent_BrEdrHandoverErrorCode_BrEdrHandoverErrorCode_MIN = FastPairEvent_BrEdrHandoverErrorCode_UNKNOWN_BR_EDR_HANDOVER_ERROR_CODE;
constexpr FastPairEvent_BrEdrHandoverErrorCode FastPairEvent_BrEdrHandoverErrorCode_BrEdrHandoverErrorCode_MAX = FastPairEvent_BrEdrHandoverErrorCode_TRANSPORT_BLOCK_INVALID;
constexpr int FastPairEvent_BrEdrHandoverErrorCode_BrEdrHandoverErrorCode_ARRAYSIZE = FastPairEvent_BrEdrHandoverErrorCode_BrEdrHandoverErrorCode_MAX + 1;
const std::string& FastPairEvent_BrEdrHandoverErrorCode_Name(FastPairEvent_BrEdrHandoverErrorCode value);
template<typename T>
inline const std::string& FastPairEvent_BrEdrHandoverErrorCode_Name(T enum_t_value) {
static_assert(::std::is_same<T, FastPairEvent_BrEdrHandoverErrorCode>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function FastPairEvent_BrEdrHandoverErrorCode_Name.");
return FastPairEvent_BrEdrHandoverErrorCode_Name(static_cast<FastPairEvent_BrEdrHandoverErrorCode>(enum_t_value));
}
bool FastPairEvent_BrEdrHandoverErrorCode_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FastPairEvent_BrEdrHandoverErrorCode* value);
enum FastPairEvent_CreateBondErrorCode : int {
FastPairEvent_CreateBondErrorCode_UNKNOWN_BOND_ERROR_CODE = 0,
FastPairEvent_CreateBondErrorCode_BOND_BROKEN = 1,
FastPairEvent_CreateBondErrorCode_POSSIBLE_MITM = 2,
FastPairEvent_CreateBondErrorCode_NO_PERMISSION = 3,
FastPairEvent_CreateBondErrorCode_INCORRECT_VARIANT = 4,
FastPairEvent_CreateBondErrorCode_FAILED_BUT_ALREADY_RECEIVE_PASS_KEY = 5
};
bool FastPairEvent_CreateBondErrorCode_IsValid(int value);
constexpr FastPairEvent_CreateBondErrorCode FastPairEvent_CreateBondErrorCode_CreateBondErrorCode_MIN = FastPairEvent_CreateBondErrorCode_UNKNOWN_BOND_ERROR_CODE;
constexpr FastPairEvent_CreateBondErrorCode FastPairEvent_CreateBondErrorCode_CreateBondErrorCode_MAX = FastPairEvent_CreateBondErrorCode_FAILED_BUT_ALREADY_RECEIVE_PASS_KEY;
constexpr int FastPairEvent_CreateBondErrorCode_CreateBondErrorCode_ARRAYSIZE = FastPairEvent_CreateBondErrorCode_CreateBondErrorCode_MAX + 1;
const std::string& FastPairEvent_CreateBondErrorCode_Name(FastPairEvent_CreateBondErrorCode value);
template<typename T>
inline const std::string& FastPairEvent_CreateBondErrorCode_Name(T enum_t_value) {
static_assert(::std::is_same<T, FastPairEvent_CreateBondErrorCode>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function FastPairEvent_CreateBondErrorCode_Name.");
return FastPairEvent_CreateBondErrorCode_Name(static_cast<FastPairEvent_CreateBondErrorCode>(enum_t_value));
}
bool FastPairEvent_CreateBondErrorCode_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FastPairEvent_CreateBondErrorCode* value);
enum FastPairEvent_ConnectErrorCode : int {
FastPairEvent_ConnectErrorCode_UNKNOWN_CONNECT_ERROR_CODE = 0,
FastPairEvent_ConnectErrorCode_UNSUPPORTED_PROFILE = 1,
FastPairEvent_ConnectErrorCode_GET_PROFILE_PROXY_FAILED = 2,
FastPairEvent_ConnectErrorCode_DISCONNECTED = 3,
FastPairEvent_ConnectErrorCode_LINK_KEY_CLEARED = 4,
FastPairEvent_ConnectErrorCode_FAIL_TO_DISCOVERY = 5,
FastPairEvent_ConnectErrorCode_DISCOVERY_NOT_FINISHED = 6
};
bool FastPairEvent_ConnectErrorCode_IsValid(int value);
constexpr FastPairEvent_ConnectErrorCode FastPairEvent_ConnectErrorCode_ConnectErrorCode_MIN = FastPairEvent_ConnectErrorCode_UNKNOWN_CONNECT_ERROR_CODE;
constexpr FastPairEvent_ConnectErrorCode FastPairEvent_ConnectErrorCode_ConnectErrorCode_MAX = FastPairEvent_ConnectErrorCode_DISCOVERY_NOT_FINISHED;
constexpr int FastPairEvent_ConnectErrorCode_ConnectErrorCode_ARRAYSIZE = FastPairEvent_ConnectErrorCode_ConnectErrorCode_MAX + 1;
const std::string& FastPairEvent_ConnectErrorCode_Name(FastPairEvent_ConnectErrorCode value);
template<typename T>
inline const std::string& FastPairEvent_ConnectErrorCode_Name(T enum_t_value) {
static_assert(::std::is_same<T, FastPairEvent_ConnectErrorCode>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function FastPairEvent_ConnectErrorCode_Name.");
return FastPairEvent_ConnectErrorCode_Name(static_cast<FastPairEvent_ConnectErrorCode>(enum_t_value));
}
bool FastPairEvent_ConnectErrorCode_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, FastPairEvent_ConnectErrorCode* value);
enum DeviceType : int {
UNKNOWN_DEVICE_TYPE = 0,
PHONE = 1,
WEARABLE = 2,
AUTO = 3,
PC = 4,
TV = 5,
TABLET = 6
};
bool DeviceType_IsValid(int value);
constexpr DeviceType DeviceType_MIN = UNKNOWN_DEVICE_TYPE;
constexpr DeviceType DeviceType_MAX = TABLET;
constexpr int DeviceType_ARRAYSIZE = DeviceType_MAX + 1;
const std::string& DeviceType_Name(DeviceType value);
template<typename T>
inline const std::string& DeviceType_Name(T enum_t_value) {
static_assert(::std::is_same<T, DeviceType>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function DeviceType_Name.");
return DeviceType_Name(static_cast<DeviceType>(enum_t_value));
}
bool DeviceType_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, DeviceType* value);
enum OsType : int {
UNKNOWN_OS_TYPE = 0,
ANDROID = 1,
CHROME_OS = 2
};
bool OsType_IsValid(int value);
constexpr OsType OsType_MIN = UNKNOWN_OS_TYPE;
constexpr OsType OsType_MAX = CHROME_OS;
constexpr int OsType_ARRAYSIZE = OsType_MAX + 1;
const std::string& OsType_Name(OsType value);
template<typename T>
inline const std::string& OsType_Name(T enum_t_value) {
static_assert(::std::is_same<T, OsType>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function OsType_Name.");
return OsType_Name(static_cast<OsType>(enum_t_value));
}
bool OsType_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, OsType* value);
// ===================================================================
class FastPairEvent final :
public ::PROTOBUF_NAMESPACE_ID::MessageLite /* @@protoc_insertion_point(class_definition:nearby.proto.fastpair.FastPairEvent) */ {
public:
inline FastPairEvent() : FastPairEvent(nullptr) {}
~FastPairEvent() override;
explicit constexpr FastPairEvent(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized);
FastPairEvent(const FastPairEvent& from);
FastPairEvent(FastPairEvent&& from) noexcept
: FastPairEvent() {
*this = ::std::move(from);
}
inline FastPairEvent& operator=(const FastPairEvent& from) {
CopyFrom(from);
return *this;
}
inline FastPairEvent& operator=(FastPairEvent&& from) noexcept {
if (this == &from) return *this;
if (GetOwningArena() == from.GetOwningArena()
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
&& GetOwningArena() != nullptr
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
inline const std::string& unknown_fields() const {
return _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString);
}
inline std::string* mutable_unknown_fields() {
return _internal_metadata_.mutable_unknown_fields<std::string>();
}
static const FastPairEvent& default_instance() {
return *internal_default_instance();
}
static inline const FastPairEvent* internal_default_instance() {
return reinterpret_cast<const FastPairEvent*>(
&_FastPairEvent_default_instance_);
}
static constexpr int kIndexInFileMessages =
0;
friend void swap(FastPairEvent& a, FastPairEvent& b) {
a.Swap(&b);
}
inline void Swap(FastPairEvent* other) {
if (other == this) return;
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() != nullptr &&
GetOwningArena() == other->GetOwningArena()) {
#else // PROTOBUF_FORCE_COPY_IN_SWAP
if (GetOwningArena() == other->GetOwningArena()) {
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
InternalSwap(other);
} else {
::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other);
}
}
void UnsafeArenaSwap(FastPairEvent* other) {
if (other == this) return;
GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
FastPairEvent* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final {
return CreateMaybeMessage<FastPairEvent>(arena);
}
void CheckTypeAndMergeFrom(const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) final;
void CopyFrom(const FastPairEvent& from);
void MergeFrom(const FastPairEvent& from);
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final;
uint8_t* _InternalSerialize(
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
void InternalSwap(FastPairEvent* other);
private:
friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata;
static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() {
return "nearby.proto.fastpair.FastPairEvent";
}
protected:
explicit FastPairEvent(::PROTOBUF_NAMESPACE_ID::Arena* arena,
bool is_message_owned = false);
private:
static void ArenaDtor(void* object);
inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena);
public:
std::string GetTypeName() const final;
// nested types ----------------------------------------------------
typedef FastPairEvent_BondState BondState;
static constexpr BondState UNKNOWN_BOND_STATE =
FastPairEvent_BondState_UNKNOWN_BOND_STATE;
static constexpr BondState NONE =
FastPairEvent_BondState_NONE;
static constexpr BondState BONDING =
FastPairEvent_BondState_BONDING;
static constexpr BondState BONDED =
FastPairEvent_BondState_BONDED;
static inline bool BondState_IsValid(int value) {
return FastPairEvent_BondState_IsValid(value);
}
static constexpr BondState BondState_MIN =
FastPairEvent_BondState_BondState_MIN;
static constexpr BondState BondState_MAX =
FastPairEvent_BondState_BondState_MAX;
static constexpr int BondState_ARRAYSIZE =
FastPairEvent_BondState_BondState_ARRAYSIZE;
template<typename T>
static inline const std::string& BondState_Name(T enum_t_value) {
static_assert(::std::is_same<T, BondState>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function BondState_Name.");
return FastPairEvent_BondState_Name(enum_t_value);
}
static inline bool BondState_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,
BondState* value) {
return FastPairEvent_BondState_Parse(name, value);
}
typedef FastPairEvent_ErrorCode ErrorCode;
static constexpr ErrorCode UNKNOWN_ERROR_CODE =
FastPairEvent_ErrorCode_UNKNOWN_ERROR_CODE;
static constexpr ErrorCode OTHER_ERROR =
FastPairEvent_ErrorCode_OTHER_ERROR;
static constexpr ErrorCode TIMEOUT =
FastPairEvent_ErrorCode_TIMEOUT;
static constexpr ErrorCode INTERRUPTED =
FastPairEvent_ErrorCode_INTERRUPTED;
static constexpr ErrorCode REFLECTIVE_OPERATION_EXCEPTION =
FastPairEvent_ErrorCode_REFLECTIVE_OPERATION_EXCEPTION;
static constexpr ErrorCode EXECUTION_EXCEPTION =
FastPairEvent_ErrorCode_EXECUTION_EXCEPTION;
static constexpr ErrorCode PARSE_EXCEPTION =
FastPairEvent_ErrorCode_PARSE_EXCEPTION;
static constexpr ErrorCode MDH_REMOTE_EXCEPTION =
FastPairEvent_ErrorCode_MDH_REMOTE_EXCEPTION;
static constexpr ErrorCode SUCCESS_RETRY_GATT_ERROR =
FastPairEvent_ErrorCode_SUCCESS_RETRY_GATT_ERROR;
static constexpr ErrorCode SUCCESS_RETRY_GATT_TIMEOUT =
FastPairEvent_ErrorCode_SUCCESS_RETRY_GATT_TIMEOUT;
static constexpr ErrorCode SUCCESS_RETRY_SECRET_HANDSHAKE_ERROR =
FastPairEvent_ErrorCode_SUCCESS_RETRY_SECRET_HANDSHAKE_ERROR;
static constexpr ErrorCode SUCCESS_RETRY_SECRET_HANDSHAKE_TIMEOUT =
FastPairEvent_ErrorCode_SUCCESS_RETRY_SECRET_HANDSHAKE_TIMEOUT;
static constexpr ErrorCode SUCCESS_SECRET_HANDSHAKE_RECONNECT =
FastPairEvent_ErrorCode_SUCCESS_SECRET_HANDSHAKE_RECONNECT;
static constexpr ErrorCode SUCCESS_ADDRESS_ROTATE =
FastPairEvent_ErrorCode_SUCCESS_ADDRESS_ROTATE;
static constexpr ErrorCode SUCCESS_SIGNAL_LOST =
FastPairEvent_ErrorCode_SUCCESS_SIGNAL_LOST;
static constexpr ErrorCode DEVICE_NOT_IN_PAIRED_HISTORY_EXCEPTION =
FastPairEvent_ErrorCode_DEVICE_NOT_IN_PAIRED_HISTORY_EXCEPTION;
static constexpr ErrorCode DEVICE_NOT_BONDED_DURING_RETROACTIVE_PAIR =
FastPairEvent_ErrorCode_DEVICE_NOT_BONDED_DURING_RETROACTIVE_PAIR;
static inline bool ErrorCode_IsValid(int value) {
return FastPairEvent_ErrorCode_IsValid(value);
}
static constexpr ErrorCode ErrorCode_MIN =
FastPairEvent_ErrorCode_ErrorCode_MIN;
static constexpr ErrorCode ErrorCode_MAX =
FastPairEvent_ErrorCode_ErrorCode_MAX;
static constexpr int ErrorCode_ARRAYSIZE =
FastPairEvent_ErrorCode_ErrorCode_ARRAYSIZE;
template<typename T>
static inline const std::string& ErrorCode_Name(T enum_t_value) {
static_assert(::std::is_same<T, ErrorCode>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function ErrorCode_Name.");
return FastPairEvent_ErrorCode_Name(enum_t_value);
}
static inline bool ErrorCode_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,
ErrorCode* value) {
return FastPairEvent_ErrorCode_Parse(name, value);
}
typedef FastPairEvent_BrEdrHandoverErrorCode BrEdrHandoverErrorCode;
static constexpr BrEdrHandoverErrorCode UNKNOWN_BR_EDR_HANDOVER_ERROR_CODE =
FastPairEvent_BrEdrHandoverErrorCode_UNKNOWN_BR_EDR_HANDOVER_ERROR_CODE;
static constexpr BrEdrHandoverErrorCode CONTROL_POINT_RESULT_CODE_NOT_SUCCESS =
FastPairEvent_BrEdrHandoverErrorCode_CONTROL_POINT_RESULT_CODE_NOT_SUCCESS;
static constexpr BrEdrHandoverErrorCode BLUETOOTH_MAC_INVALID =
FastPairEvent_BrEdrHandoverErrorCode_BLUETOOTH_MAC_INVALID;
static constexpr BrEdrHandoverErrorCode TRANSPORT_BLOCK_INVALID =
FastPairEvent_BrEdrHandoverErrorCode_TRANSPORT_BLOCK_INVALID;
static inline bool BrEdrHandoverErrorCode_IsValid(int value) {
return FastPairEvent_BrEdrHandoverErrorCode_IsValid(value);
}
static constexpr BrEdrHandoverErrorCode BrEdrHandoverErrorCode_MIN =
FastPairEvent_BrEdrHandoverErrorCode_BrEdrHandoverErrorCode_MIN;
static constexpr BrEdrHandoverErrorCode BrEdrHandoverErrorCode_MAX =
FastPairEvent_BrEdrHandoverErrorCode_BrEdrHandoverErrorCode_MAX;
static constexpr int BrEdrHandoverErrorCode_ARRAYSIZE =
FastPairEvent_BrEdrHandoverErrorCode_BrEdrHandoverErrorCode_ARRAYSIZE;
template<typename T>
static inline const std::string& BrEdrHandoverErrorCode_Name(T enum_t_value) {
static_assert(::std::is_same<T, BrEdrHandoverErrorCode>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function BrEdrHandoverErrorCode_Name.");
return FastPairEvent_BrEdrHandoverErrorCode_Name(enum_t_value);
}
static inline bool BrEdrHandoverErrorCode_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,
BrEdrHandoverErrorCode* value) {
return FastPairEvent_BrEdrHandoverErrorCode_Parse(name, value);
}
typedef FastPairEvent_CreateBondErrorCode CreateBondErrorCode;
static constexpr CreateBondErrorCode UNKNOWN_BOND_ERROR_CODE =
FastPairEvent_CreateBondErrorCode_UNKNOWN_BOND_ERROR_CODE;
static constexpr CreateBondErrorCode BOND_BROKEN =
FastPairEvent_CreateBondErrorCode_BOND_BROKEN;
static constexpr CreateBondErrorCode POSSIBLE_MITM =
FastPairEvent_CreateBondErrorCode_POSSIBLE_MITM;
static constexpr CreateBondErrorCode NO_PERMISSION =
FastPairEvent_CreateBondErrorCode_NO_PERMISSION;
static constexpr CreateBondErrorCode INCORRECT_VARIANT =
FastPairEvent_CreateBondErrorCode_INCORRECT_VARIANT;
static constexpr CreateBondErrorCode FAILED_BUT_ALREADY_RECEIVE_PASS_KEY =
FastPairEvent_CreateBondErrorCode_FAILED_BUT_ALREADY_RECEIVE_PASS_KEY;
static inline bool CreateBondErrorCode_IsValid(int value) {
return FastPairEvent_CreateBondErrorCode_IsValid(value);
}
static constexpr CreateBondErrorCode CreateBondErrorCode_MIN =
FastPairEvent_CreateBondErrorCode_CreateBondErrorCode_MIN;
static constexpr CreateBondErrorCode CreateBondErrorCode_MAX =
FastPairEvent_CreateBondErrorCode_CreateBondErrorCode_MAX;
static constexpr int CreateBondErrorCode_ARRAYSIZE =
FastPairEvent_CreateBondErrorCode_CreateBondErrorCode_ARRAYSIZE;
template<typename T>
static inline const std::string& CreateBondErrorCode_Name(T enum_t_value) {
static_assert(::std::is_same<T, CreateBondErrorCode>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function CreateBondErrorCode_Name.");
return FastPairEvent_CreateBondErrorCode_Name(enum_t_value);
}
static inline bool CreateBondErrorCode_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,
CreateBondErrorCode* value) {
return FastPairEvent_CreateBondErrorCode_Parse(name, value);
}
typedef FastPairEvent_ConnectErrorCode ConnectErrorCode;
static constexpr ConnectErrorCode UNKNOWN_CONNECT_ERROR_CODE =
FastPairEvent_ConnectErrorCode_UNKNOWN_CONNECT_ERROR_CODE;
static constexpr ConnectErrorCode UNSUPPORTED_PROFILE =
FastPairEvent_ConnectErrorCode_UNSUPPORTED_PROFILE;
static constexpr ConnectErrorCode GET_PROFILE_PROXY_FAILED =
FastPairEvent_ConnectErrorCode_GET_PROFILE_PROXY_FAILED;
static constexpr ConnectErrorCode DISCONNECTED =
FastPairEvent_ConnectErrorCode_DISCONNECTED;
static constexpr ConnectErrorCode LINK_KEY_CLEARED =
FastPairEvent_ConnectErrorCode_LINK_KEY_CLEARED;
static constexpr ConnectErrorCode FAIL_TO_DISCOVERY =
FastPairEvent_ConnectErrorCode_FAIL_TO_DISCOVERY;
static constexpr ConnectErrorCode DISCOVERY_NOT_FINISHED =
FastPairEvent_ConnectErrorCode_DISCOVERY_NOT_FINISHED;
static inline bool ConnectErrorCode_IsValid(int value) {
return FastPairEvent_ConnectErrorCode_IsValid(value);
}
static constexpr ConnectErrorCode ConnectErrorCode_MIN =
FastPairEvent_ConnectErrorCode_ConnectErrorCode_MIN;
static constexpr ConnectErrorCode ConnectErrorCode_MAX =
FastPairEvent_ConnectErrorCode_ConnectErrorCode_MAX;
static constexpr int ConnectErrorCode_ARRAYSIZE =
FastPairEvent_ConnectErrorCode_ConnectErrorCode_ARRAYSIZE;
template<typename T>
static inline const std::string& ConnectErrorCode_Name(T enum_t_value) {
static_assert(::std::is_same<T, ConnectErrorCode>::value ||
::std::is_integral<T>::value,
"Incorrect type passed to function ConnectErrorCode_Name.");
return FastPairEvent_ConnectErrorCode_Name(enum_t_value);
}
static inline bool ConnectErrorCode_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name,
ConnectErrorCode* value) {
return FastPairEvent_ConnectErrorCode_Parse(name, value);
}
// accessors -------------------------------------------------------
// @@protoc_insertion_point(class_scope:nearby.proto.fastpair.FastPairEvent)
private:
class _Internal;
template <typename T> friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper;
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
friend struct ::TableStruct_proto_2ffast_5fpair_5fenums_2eproto;
};
// ===================================================================
// ===================================================================
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
// FastPairEvent
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
// @@protoc_insertion_point(namespace_scope)
} // namespace fastpair
} // namespace proto
} // namespace nearby
PROTOBUF_NAMESPACE_OPEN
template <> struct is_proto_enum< ::nearby::proto::fastpair::FastPairEvent_BondState> : ::std::true_type {};
template <> struct is_proto_enum< ::nearby::proto::fastpair::FastPairEvent_ErrorCode> : ::std::true_type {};
template <> struct is_proto_enum< ::nearby::proto::fastpair::FastPairEvent_BrEdrHandoverErrorCode> : ::std::true_type {};
template <> struct is_proto_enum< ::nearby::proto::fastpair::FastPairEvent_CreateBondErrorCode> : ::std::true_type {};
template <> struct is_proto_enum< ::nearby::proto::fastpair::FastPairEvent_ConnectErrorCode> : ::std::true_type {};
template <> struct is_proto_enum< ::nearby::proto::fastpair::DeviceType> : ::std::true_type {};
template <> struct is_proto_enum< ::nearby::proto::fastpair::OsType> : ::std::true_type {};
PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_proto_2ffast_5fpair_5fenums_2eproto
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+3
View File
@@ -49,6 +49,7 @@ cc_library(
"//internal/analytics:event_logger",
"//internal/interop:device",
"//internal/platform:base",
"//internal/platform:logging",
"//internal/platform:types",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/time",
@@ -94,6 +95,7 @@ cc_library(
"//connections/implementation/proto:offline_wire_formats_cc_proto",
"//internal/interop:authentication_status",
"//internal/platform:base",
"//internal/platform:logging",
"//internal/platform:mac_address",
"//internal/platform:types",
"//internal/platform:util",
@@ -122,6 +124,7 @@ cc_test(
"//connections/implementation:internal_test",
"//connections/v3:v3_types",
"//internal/platform:base",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
"@com_github_protobuf_matchers//protobuf-matchers",
+4 -1
View File
@@ -56,6 +56,7 @@ cc_library(
"//internal/flags:flag_reader",
"//internal/flags:nearby_flags",
"//internal/platform:base",
"//internal/platform:logging",
"//internal/platform:mac_address",
"//internal/platform:types",
"//internal/proto/analytics:connections_log_cc_proto",
@@ -65,8 +66,10 @@ cc_library(
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:span",
] + select({
"@platforms//os:platform_ios": [
"@platforms//os:apple": [
"//internal/platform/implementation/apple",
"//internal/platform/implementation/apple:nearby_logger",
"//internal/platform/implementation/apple/Mediums",
],
"//conditions:default": [],
}),
+1
View File
@@ -1,4 +1,5 @@
_NcCreateService
_NcCreateServiceWithEventLogger
_NcCloseService
_NcStartAdvertising
_NcStopAdvertising
+6 -56
View File
@@ -34,7 +34,6 @@
#include "connections/connection_options.h"
#include "connections/core.h"
#include "connections/discovery_options.h"
#include "connections/implementation/flags/nearby_connections_feature_flags.h"
#include "connections/listeners.h"
#include "connections/medium_selector.h"
#include "connections/out_of_band_connection_metadata.h"
@@ -156,15 +155,6 @@ typedef struct NcContext {
absl::NoDestructor<absl::flat_hash_map<NC_INSTANCE, NcContext>> kNcContextMap;
int64_t getFileSize(const char* filename) {
struct stat file_status;
if (stat(filename, &file_status) < 0) {
return -1;
}
return file_status.st_size;
}
int convertStringToInt(absl::string_view data) {
if (data.size() != 4) {
return 0;
@@ -266,45 +256,6 @@ NcCreateServiceWithEventLogger(const NC_EVENT_LOGGER* event_logger) {
::nearby::apple::EnableOsLog("com.google.nearby.connections");
#endif // TARGET_OS_IOS
#if defined(NC_IOS_SDK)
nearby::NearbyFlags::GetInstance().OverrideBoolFlagValue(
::nearby::connections::config_package_nearby::nearby_connections_feature::
kEnableBleV2,
true);
nearby::NearbyFlags::GetInstance().OverrideBoolFlagValue(
::nearby::connections::config_package_nearby::nearby_connections_feature::
kEnableDct,
false);
nearby::NearbyFlags::GetInstance().OverrideBoolFlagValue(
::nearby::connections::config_package_nearby::nearby_connections_feature::
kEnableDynamicRoleSwitch,
true);
nearby::NearbyFlags::GetInstance().OverrideBoolFlagValue(
::nearby::connections::config_package_nearby::nearby_connections_feature::
kEnableBleL2cap,
true);
nearby::NearbyFlags::GetInstance().OverrideBoolFlagValue(
::nearby::connections::config_package_nearby::nearby_connections_feature::
kEnableGattClientDisconnection,
true);
nearby::NearbyFlags::GetInstance().OverrideBoolFlagValue(
::nearby::connections::config_package_nearby::nearby_connections_feature::
kEnableAwdl,
true);
nearby::NearbyFlags::GetInstance().OverrideBoolFlagValue(
::nearby::connections::config_package_nearby::nearby_connections_feature::
kEnableStopBleScanningOnWifiUpgrade,
true);
nearby::NearbyFlags::GetInstance().OverrideBoolFlagValue(
::nearby::connections::config_package_nearby::nearby_connections_feature::
kUseStableEndpointId,
true);
nearby::NearbyFlags::GetInstance().OverrideBoolFlagValue(
::nearby::connections::config_package_nearby::nearby_connections_feature::
kEnableGattQueryInThread,
true);
#endif
nc_context.router = new ::nearby::connections::ServiceControllerRouter();
nc_context.event_logger =
event_logger == nullptr ? nullptr : new NcEventLogger(event_logger);
@@ -531,7 +482,7 @@ void NcInjectEndpoint(NC_INSTANCE instance, const NC_DATA* service_id,
}
::nearby::connections::OutOfBandConnectionMetadata
cpp_out_of_band_connection_metadata;
cpp_out_of_band_connection_metadata{};
cpp_out_of_band_connection_metadata.endpoint_id = metadata->endpoint_id;
cpp_out_of_band_connection_metadata.endpoint_info = {
metadata->endpoint_info.data,
@@ -541,6 +492,10 @@ void NcInjectEndpoint(NC_INSTANCE instance, const NC_DATA* service_id,
cpp_out_of_band_connection_metadata.remote_bluetooth_mac_address = {
metadata->remote_bluetooth_mac_address.data,
static_cast<size_t>(metadata->remote_bluetooth_mac_address.size)};
cpp_out_of_band_connection_metadata.ble_peripheral_native_id = {
metadata->ble_peripheral_native_id.data,
static_cast<size_t>(metadata->ble_peripheral_native_id.size)};
cpp_out_of_band_connection_metadata.psm = metadata->psm;
nc_context->core->InjectEndpoint(
std::string(service_id->data, service_id->size),
@@ -729,8 +684,7 @@ void NcSendPayload(NC_INSTANCE instance, size_t endpoint_ids_size,
payload->content.file.file_name);
}
nearby::InputFile input_file(full_file_name,
getFileSize(full_file_name.c_str()));
nearby::InputFile input_file(full_file_name);
cpp_payload =
::nearby::connections::Payload(payload->id, std::move(input_file));
} else if (payload->type == NC_PAYLOAD_TYPE_STREAM) {
@@ -815,10 +769,6 @@ int NcGetLocalEndpointId(NC_INSTANCE instance) {
void NcEnableBleV2(NC_INSTANCE instance, bool enable,
NcCallbackResult result_callback, CALLER_CONTEXT context) {
nearby::NearbyFlags::GetInstance().OverrideBoolFlagValue(
::nearby::connections::config_package_nearby::nearby_connections_feature::
kEnableBleV2,
enable);
result_callback(NC_STATUS_SUCCESS, context);
}
+1 -2
View File
@@ -181,8 +181,7 @@ NC_API void NcInitiateBandwidthUpgrade(NC_INSTANCE instance, int endpoint_id,
// Gets the local endpoint generated by Nearby Connections.
NC_API int NcGetLocalEndpointId(NC_INSTANCE instance);
// Enable/Disable BLE V2 advertising. The method should be deprecated after
// BLE V1 deprecated.
// Enable/Disable BLE V2 advertising. The method is deprecated. It's a no-op.
NC_API void NcEnableBleV2(NC_INSTANCE instance, bool enable,
NcCallbackResult result_callback,
CALLER_CONTEXT context);
+14
View File
@@ -305,6 +305,10 @@ typedef struct NC_OUT_OF_BAND_CONNECTION_METADATA {
// generated such that no two IDs are identical.
int endpoint_id;
//
// Properties for BLUETOOTH out-of-band connections.
//
// Endpoint info to use for the injected connection; will be included in the
// endpoint_found_cb callback. Should uniquely identify the InjectEndpoint()
// call so that the client which made the call can verify the endpoint
@@ -315,6 +319,16 @@ typedef struct NC_OUT_OF_BAND_CONNECTION_METADATA {
// Used for Bluetooth connections.
NC_DATA remote_bluetooth_mac_address;
//
// Properties for BLE out-of-band connections.
//
// The BLE peripheral native ID to use for the BLE connection.
NC_DATA ble_peripheral_native_id;
// The Protocol/Service Multiplexer(psm) value to use for the BLE connection.
int psm;
} NC_OUT_OF_BAND_CONNECTION_METADATA, *PNC_OUT_OF_BAND_CONNECTION_METADATA;
// Defines the minimal function interface for reading phenotype flags. Callbacks
+5 -5
View File
@@ -11,6 +11,7 @@
// 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 CORE_CONNECTION_OPTIONS_H_
#define CORE_CONNECTION_OPTIONS_H_
#include <string>
@@ -22,8 +23,7 @@
#include "internal/platform/mac_address.h"
#include "proto/connections_enums.pb.h"
namespace nearby {
namespace connections {
namespace nearby::connections {
struct ConnectionInfo {
std::string local_endpoint_id;
@@ -32,11 +32,12 @@ struct ConnectionInfo {
bool supports_5_ghz = false;
std::string bssid;
std::int32_t ap_frequency = -1;
std::string ip_address;
std::vector<location::nearby::proto::connections::Medium> supported_mediums;
std::int32_t keep_alive_interval_millis;
std::int32_t keep_alive_timeout_millis;
std::optional<location::nearby::connections::MediumRole> medium_role;
std::vector<location::nearby::proto::connections::WifiDirectAuthType>
supported_wifi_direct_auth_types;
};
// Connection Options: used for both Advertising and Discovery.
@@ -63,7 +64,6 @@ struct ConnectionOptions : public OptionsBase {
ConnectionInfo connection_info;
};
} // namespace connections
} // namespace nearby
} // namespace nearby::connections
#endif // CORE_CONNECTION_OPTIONS_H_
+1 -4
View File
@@ -64,13 +64,10 @@ objc_library(
deps = [
"//connections/c:nc",
"//connections/c:nc_types",
"//connections/implementation/flags:connections_flags",
"//internal/flags:nearby_flags",
"//internal/platform:base",
"//internal/platform:types",
"//internal/platform:logging",
"//internal/platform/implementation/apple", # buildcleaner: keep
"//third_party/dart_lang/v2:dart_api_dl",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:no_destructor",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/strings",
+56 -34
View File
@@ -1,6 +1,3 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,6 +11,10 @@ load("@rules_cc//cc:cc_test.bzl", "cc_test")
# 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.
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")
licenses(["notice"])
cc_library(
@@ -37,8 +38,8 @@ cc_library(
deps = [
":types",
"//internal/platform:base",
"//internal/platform:logging",
"//internal/platform:mac_address",
"//internal/platform:types",
"//internal/platform:util",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
@@ -58,7 +59,6 @@ cc_library(
"base_pcp_handler.cc",
"ble_endpoint_channel.cc",
"ble_l2cap_endpoint_channel.cc",
"ble_v2_endpoint_channel.cc",
"bluetooth_bwu_handler.cc",
"bluetooth_device_name.cc",
"bluetooth_endpoint_channel.cc",
@@ -79,7 +79,6 @@ cc_library(
"p2p_star_pcp_handler.cc",
"payload_manager.cc",
"pcp_manager.cc",
"reconnect_manager.cc",
"service_controller_router.cc",
"webrtc_bwu_handler.cc",
"webrtc_bwu_handler_stub.cc",
@@ -100,7 +99,6 @@ cc_library(
"base_pcp_handler.h",
"ble_endpoint_channel.h",
"ble_l2cap_endpoint_channel.h",
"ble_v2_endpoint_channel.h",
"bluetooth_bwu_handler.h",
"bluetooth_device_name.h",
"bluetooth_endpoint_channel.h",
@@ -124,7 +122,6 @@ cc_library(
"payload_manager.h",
"pcp_handler.h",
"pcp_manager.h",
"reconnect_manager.h",
"service_controller.h",
"service_controller_router.h",
"service_id_constants.h",
@@ -162,10 +159,14 @@ cc_library(
"//connections/implementation/mediums:webrtc_utils",
"//connections/implementation/mediums/advertisements:dct_advertisement",
"//connections/implementation/mediums/advertisements:util",
"//connections/implementation/mediums/ble_v2:ble_advertisement_header",
"//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,6 +176,7 @@ cc_library(
"//internal/platform:comm",
"//internal/platform:connection_info",
"//internal/platform:error_code_recorder",
"//internal/platform:logging",
"//internal/platform:mac_address",
"//internal/platform:types",
"//internal/platform:util",
@@ -190,9 +192,7 @@ 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/log:check",
"@com_google_absl//absl/random",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
@@ -227,12 +227,15 @@ cc_library(
"//connections:core_types",
"//connections/implementation/analytics",
"//connections/implementation/flags:connections_flags",
"//connections/implementation/mediums",
"//connections/v3:v3_types",
"//internal/flags:nearby_flags",
"//internal/interop:device",
"//internal/platform:base",
"//internal/platform:logging",
"//internal/platform:mac_address",
"//internal/platform:types",
"//internal/platform/implementation:types",
"@com_google_absl//absl/functional:any_invocable",
"@com_google_absl//absl/functional:bind_front",
"@com_google_absl//absl/strings",
@@ -258,12 +261,15 @@ cc_test(
"//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/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",
@@ -309,15 +315,18 @@ cc_test(
"//connections/implementation/mediums:webrtc_utils",
"//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",
"//internal/interop:device",
"//internal/platform:base",
"//internal/platform:logging",
"//internal/platform:mac_address",
"//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",
@@ -407,9 +416,11 @@ cc_test(
"//connections/implementation/analytics",
"//internal/platform:base",
"//internal/platform:types",
"//internal/platform/implementation:types",
"//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",
"@com_google_ukey2//:ukey2",
@@ -428,12 +439,14 @@ cc_test(
"//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/test",
"//proto:connections_enums_cc_proto",
"//testing/fuzzing:fuzztest",
"@com_github_protobuf_matchers//protobuf-matchers",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/time",
"@com_google_googletest//:gtest_main",
@@ -448,7 +461,10 @@ cc_test(
],
deps = [
":internal",
"//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",
@@ -474,6 +490,7 @@ cc_test(
"//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",
],
@@ -489,11 +506,11 @@ cc_test(
":internal_test",
"//connections:core_types",
"//connections/implementation/analytics",
"//connections/implementation/flags:connections_flags",
"//internal/flags:nearby_flags",
"//internal/platform:base",
"//internal/platform:logging",
"//internal/platform:test_util",
"//internal/platform:types",
"//internal/platform/implementation:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
"@com_github_protobuf_matchers//protobuf-matchers",
"@com_google_absl//absl/strings",
@@ -502,27 +519,6 @@ cc_test(
],
)
cc_test(
name = "reconnect_manager_test",
srcs = [
"reconnect_manager_test.cc",
],
deps = [
":internal",
":internal_test",
"//connections:core_types",
"//connections/implementation/mediums",
"//internal/platform:base",
"//internal/platform:test_util",
"//internal/platform:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
"@com_github_protobuf_matchers//protobuf-matchers",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/time",
"@com_google_googletest//:gtest_main",
],
)
cc_test(
name = "service_controller_test",
srcs = [
@@ -539,8 +535,10 @@ cc_test(
"//internal/interop:authentication_status",
"//internal/interop:device",
"//internal/platform:base",
"//internal/platform:logging",
"//internal/platform:test_util",
"//internal/platform:types",
"//internal/platform/implementation:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
"//proto:connections_enums_cc_proto",
"@com_github_protobuf_matchers//protobuf-matchers",
@@ -584,6 +582,30 @@ cc_test(
"//internal/platform:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
"@com_github_protobuf_matchers//protobuf-matchers",
"@com_google_absl//absl/strings:string_view",
"@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",
],
)
@@ -36,6 +36,7 @@ cc_library(
"//connections:core_types",
"//internal/analytics:event_logger",
"//internal/platform:error_code_recorder",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform/implementation:types",
"//internal/proto/analytics:connections_log_cc_proto",
@@ -66,9 +67,12 @@ cc_test(
"//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",
"//net/proto2/contrib/parse_proto:parse_text_proto",
"//proto:connections_enums_cc_proto",
"@com_github_protobuf_matchers//protobuf-matchers",
@@ -162,20 +162,12 @@ OperationResultCategory ConvertToOperationResultCategory(
}
} // namespace
AnalyticsRecorder::AnalyticsRecorder(EventLogger *event_logger)
AnalyticsRecorder::AnalyticsRecorder(EventLogger* event_logger)
: event_logger_(event_logger) {
VLOG(1) << "Start AnalyticsRecorder ctor event_logger_=" << event_logger_;
LogStartSession();
}
AnalyticsRecorder::AnalyticsRecorder(EventLogger *event_logger,
bool no_record_time_millis)
: event_logger_(event_logger),
no_record_time_millis_(no_record_time_millis) {
LOG(INFO) << "Start AnalyticsRecorder ctor event_logger_=" << event_logger_;
LogStartSession();
}
AnalyticsRecorder::~AnalyticsRecorder() = default;
bool AnalyticsRecorder::IsSessionLogged() {
@@ -184,9 +176,9 @@ bool AnalyticsRecorder::IsSessionLogged() {
}
int AnalyticsRecorder::GetLatestUpdateIndexLocked(
const std::vector<ConnectionsLog::OperationResultWithMedium> &list) {
const std::vector<ConnectionsLog::OperationResultWithMedium>& list) {
int latest_update_index = 0;
for (const auto &operation_result_with_medium : list) {
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();
}
@@ -195,8 +187,8 @@ int AnalyticsRecorder::GetLatestUpdateIndexLocked(
}
void AnalyticsRecorder::OnStartAdvertising(
connections::Strategy strategy, const std::vector<Medium> &mediums,
AdvertisingMetadataParams *advertising_metadata_params) {
connections::Strategy strategy, const std::vector<Medium>& mediums,
AdvertisingMetadataParams* advertising_metadata_params) {
MutexLock lock(&mutex_);
if (!CanRecordAnalyticsLocked("OnStartAdvertising")) {
return;
@@ -225,7 +217,7 @@ void AnalyticsRecorder::OnStartAdvertising(
RepeatedFieldBackInserter(
current_advertising_phase_->mutable_adv_dis_result()));
}
auto *advertising_metadata =
auto* advertising_metadata =
current_advertising_phase_->mutable_advertising_metadata();
advertising_metadata->set_supports_extended_ble_advertisements(
advertising_metadata_params->is_extended_advertisement_supported);
@@ -257,8 +249,8 @@ int AnalyticsRecorder::GetNextAdvertisingUpdateIndex() {
}
void AnalyticsRecorder::OnStartDiscovery(
connections::Strategy strategy, const std::vector<Medium> &mediums,
DiscoveryMetadataParams *discovery_metadata_params) {
connections::Strategy strategy, const std::vector<Medium>& mediums,
DiscoveryMetadataParams* discovery_metadata_params) {
MutexLock lock(&mutex_);
if (!CanRecordAnalyticsLocked("OnStartDiscovery")) {
return;
@@ -287,7 +279,7 @@ void AnalyticsRecorder::OnStartDiscovery(
RepeatedFieldBackInserter(
current_discovery_phase_->mutable_adv_dis_result()));
}
auto *discovery_metadata =
auto* discovery_metadata =
current_discovery_phase_->mutable_discovery_metadata();
discovery_metadata->set_supports_extended_ble_advertisements(
discovery_metadata_params->is_extended_advertisement_supported);
@@ -347,17 +339,15 @@ void AnalyticsRecorder::OnEndpointFound(Medium medium) {
"current_discovery_phase_";
return;
}
ConnectionsLog::DiscoveredEndpoint *discovered_endpoint =
ConnectionsLog::DiscoveredEndpoint* discovered_endpoint =
current_discovery_phase_->add_discovered_endpoint();
discovered_endpoint->set_medium(medium);
if (!no_record_time_millis_) {
discovered_endpoint->set_latency_millis(absl::ToInt64Milliseconds(
SystemClock::ElapsedRealtime() - started_discovery_phase_time_));
}
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) {
const connections::Strategy& strategy, const std::string& endpoint_id) {
MutexLock lock(&mutex_);
if (!CanRecordAnalyticsLocked("onRequestConnection")) {
return;
@@ -370,7 +360,7 @@ void AnalyticsRecorder::OnRequestConnection(
}
void AnalyticsRecorder::OnConnectionRequestReceived(
const std::string &remote_endpoint_id) {
const std::string& remote_endpoint_id) {
MutexLock lock(&mutex_);
if (!CanRecordAnalyticsLocked("OnConnectionRequestReceived")) {
return;
@@ -378,17 +368,15 @@ void AnalyticsRecorder::OnConnectionRequestReceived(
absl::Time current_time = SystemClock::ElapsedRealtime();
auto connection_request =
std::make_unique<ConnectionsLog::ConnectionRequest>();
if (!no_record_time_millis_) {
connection_request->set_duration_millis(absl::ToUnixMillis(current_time));
connection_request->set_request_delay_millis(absl::ToInt64Milliseconds(
current_time - started_advertising_phase_time_));
}
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) {
const std::string& remote_endpoint_id) {
MutexLock lock(&mutex_);
if (!CanRecordAnalyticsLocked("OnConnectionRequestSent")) {
return;
@@ -396,17 +384,15 @@ void AnalyticsRecorder::OnConnectionRequestSent(
absl::Time current_time = SystemClock::ElapsedRealtime();
auto connection_request =
std::make_unique<ConnectionsLog::ConnectionRequest>();
if (!no_record_time_millis_) {
connection_request->set_duration_millis(absl::ToUnixMillis(current_time));
connection_request->set_request_delay_millis(absl::ToInt64Milliseconds(
current_time - started_discovery_phase_time_));
}
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) {
const std::string& remote_endpoint_id) {
MutexLock lock(&mutex_);
if (!CanRecordAnalyticsLocked("OnRemoteEndpointAccepted")) {
return;
@@ -415,7 +401,7 @@ void AnalyticsRecorder::OnRemoteEndpointAccepted(
}
void AnalyticsRecorder::OnLocalEndpointAccepted(
const std::string &remote_endpoint_id) {
const std::string& remote_endpoint_id) {
MutexLock lock(&mutex_);
if (!CanRecordAnalyticsLocked("OnLocalEndpointAccepted")) {
return;
@@ -424,7 +410,7 @@ void AnalyticsRecorder::OnLocalEndpointAccepted(
}
void AnalyticsRecorder::OnRemoteEndpointRejected(
const std::string &remote_endpoint_id) {
const std::string& remote_endpoint_id) {
MutexLock lock(&mutex_);
if (!CanRecordAnalyticsLocked("OnRemoteEndpointRejected")) {
return;
@@ -433,7 +419,7 @@ void AnalyticsRecorder::OnRemoteEndpointRejected(
}
void AnalyticsRecorder::OnLocalEndpointRejected(
const std::string &remote_endpoint_id) {
const std::string& remote_endpoint_id) {
MutexLock lock(&mutex_);
if (!CanRecordAnalyticsLocked("OnLocalEndpointRejected")) {
return;
@@ -443,8 +429,8 @@ void AnalyticsRecorder::OnLocalEndpointRejected(
void AnalyticsRecorder::OnIncomingConnectionAttempt(
ConnectionAttemptType type, Medium medium, ConnectionAttemptResult result,
absl::Duration duration, const std::string &connection_token,
ConnectionAttemptMetadataParams *connection_attempt_metadata_params) {
absl::Duration duration, const std::string& connection_token,
ConnectionAttemptMetadataParams* connection_attempt_metadata_params) {
MutexLock lock(&mutex_);
if (!CanRecordAnalyticsLocked("OnIncomingConnectionAttempt")) {
return;
@@ -468,21 +454,18 @@ 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 =
absl::Duration duration, const std::string& connection_token,
ConnectionAttemptMetadataParams* connection_attempt_metadata_params) {
auto* connection_attempt =
current_strategy_session_->add_connection_attempt();
if (!no_record_time_millis_) {
connection_attempt->set_duration_millis(
absl::ToInt64Milliseconds(duration));
}
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 =
auto* connection_attempt_metadata =
connection_attempt->mutable_connection_attempt_metadata();
connection_attempt_metadata->set_technology(
connection_attempt_metadata_params->technology);
@@ -520,10 +503,10 @@ void AnalyticsRecorder::OnIncomingConnectionAttemptLocked(
}
void AnalyticsRecorder::OnOutgoingConnectionAttempt(
const std::string &remote_endpoint_id, ConnectionAttemptType type,
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) {
const std::string& connection_token,
ConnectionAttemptMetadataParams* connection_attempt_metadata_params) {
MutexLock lock(&mutex_);
if (!CanRecordAnalyticsLocked("OnOutgoingConnectionAttempt")) {
return;
@@ -554,23 +537,20 @@ void AnalyticsRecorder::OnOutgoingConnectionAttempt(
}
void AnalyticsRecorder::OnOutgoingConnectionAttemptLocked(
const std::string &remote_endpoint_id, ConnectionAttemptType type,
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 =
const std::string& connection_token,
ConnectionAttemptMetadataParams* connection_attempt_metadata_params) {
auto* connection_attempt =
current_strategy_session_->add_connection_attempt();
if (!no_record_time_millis_) {
connection_attempt->set_duration_millis(
absl::ToInt64Milliseconds(duration));
}
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 =
auto* connection_attempt_metadata =
connection_attempt->mutable_connection_attempt_metadata();
connection_attempt_metadata->set_technology(
connection_attempt_metadata_params->technology);
@@ -613,7 +593,7 @@ void AnalyticsRecorder::OnOutgoingConnectionAttemptLocked(
// ConnectionRequest that, since the ConnectionAttempt has failed, will
// never be delivered to the advertiser.
auto pair = outgoing_connection_requests_.extract(it);
std::unique_ptr<ConnectionsLog::ConnectionRequest> &connection_request =
std::unique_ptr<ConnectionsLog::ConnectionRequest>& connection_request =
pair.mapped();
connection_request->set_local_response(NOT_SENT);
connection_request->set_remote_response(NOT_SENT);
@@ -623,24 +603,24 @@ void AnalyticsRecorder::OnOutgoingConnectionAttemptLocked(
}
void AnalyticsRecorder::OnConnectionEstablished(
const std::string &endpoint_id, Medium medium,
const std::string &connection_token) {
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<LogicalConnection> &logical_connection = it->second;
const std::unique_ptr<LogicalConnection>& logical_connection = it->second;
logical_connection->PhysicalConnectionEstablished(medium, connection_token);
} else {
active_connections_.insert(
{endpoint_id, std::make_unique<LogicalConnection>(
medium, connection_token, no_record_time_millis_)});
{endpoint_id,
std::make_unique<LogicalConnection>(medium, connection_token)});
}
}
void AnalyticsRecorder::OnConnectionClosed(const std::string &endpoint_id,
void AnalyticsRecorder::OnConnectionClosed(const std::string& endpoint_id,
Medium medium,
DisconnectionReason reason,
SafeDisconnectionResult result) {
@@ -665,14 +645,14 @@ void AnalyticsRecorder::OnConnectionClosed(const std::string &endpoint_id,
if (it == active_connections_.end()) {
return;
}
const std::unique_ptr<LogicalConnection> &logical_connection = it->second;
const std::unique_ptr<LogicalConnection>& 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<LogicalConnection> &logical_connection = pair.mapped();
std::unique_ptr<LogicalConnection>& logical_connection = pair.mapped();
absl::c_copy(
logical_connection->GetEstablisedConnections(),
@@ -682,7 +662,7 @@ void AnalyticsRecorder::OnConnectionClosed(const std::string &endpoint_id,
}
void AnalyticsRecorder::OnIncomingPayloadStarted(
const std::string &endpoint_id, std::int64_t payload_id,
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")) {
@@ -692,12 +672,12 @@ void AnalyticsRecorder::OnIncomingPayloadStarted(
if (it == active_connections_.end()) {
return;
}
const std::unique_ptr<LogicalConnection> &logical_connection = it->second;
const std::unique_ptr<LogicalConnection>& logical_connection = it->second;
logical_connection->IncomingPayloadStarted(
payload_id, PayloadTypeToProtoPayloadType(type), total_size_bytes);
}
void AnalyticsRecorder::OnPayloadChunkReceived(const std::string &endpoint_id,
void AnalyticsRecorder::OnPayloadChunkReceived(const std::string& endpoint_id,
std::int64_t payload_id,
std::int64_t chunk_size_bytes) {
MutexLock lock(&mutex_);
@@ -708,12 +688,12 @@ void AnalyticsRecorder::OnPayloadChunkReceived(const std::string &endpoint_id,
if (it == active_connections_.end()) {
return;
}
const std::unique_ptr<LogicalConnection> &logical_connection = it->second;
const std::unique_ptr<LogicalConnection>& 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,
const std::string& endpoint_id, std::int64_t payload_id,
PayloadStatus status, OperationResultCode operation_result_code) {
MutexLock lock(&mutex_);
if (!CanRecordAnalyticsLocked("OnIncomingPayloadDone")) {
@@ -723,30 +703,30 @@ void AnalyticsRecorder::OnIncomingPayloadDone(
if (it == active_connections_.end()) {
return;
}
const std::unique_ptr<LogicalConnection> &logical_connection = it->second;
const std::unique_ptr<LogicalConnection>& logical_connection = it->second;
logical_connection->IncomingPayloadDone(payload_id, status,
operation_result_code);
}
void AnalyticsRecorder::OnOutgoingPayloadStarted(
const std::vector<std::string> &endpoint_ids, std::int64_t payload_id,
const std::vector<std::string>& 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) {
for (const auto& endpoint_id : endpoint_ids) {
auto it = active_connections_.find(endpoint_id);
if (it == active_connections_.end()) {
continue;
}
const std::unique_ptr<LogicalConnection> &logical_connection = it->second;
const std::unique_ptr<LogicalConnection>& logical_connection = it->second;
logical_connection->OutgoingPayloadStarted(
payload_id, PayloadTypeToProtoPayloadType(type), total_size_bytes);
}
}
void AnalyticsRecorder::OnPayloadChunkSent(const std::string &endpoint_id,
void AnalyticsRecorder::OnPayloadChunkSent(const std::string& endpoint_id,
std::int64_t payload_id,
std::int64_t chunk_size_bytes) {
MutexLock lock(&mutex_);
@@ -757,12 +737,12 @@ void AnalyticsRecorder::OnPayloadChunkSent(const std::string &endpoint_id,
if (it == active_connections_.end()) {
return;
}
const std::unique_ptr<LogicalConnection> &logical_connection = it->second;
const std::unique_ptr<LogicalConnection>& 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,
const std::string& endpoint_id, std::int64_t payload_id,
PayloadStatus status, OperationResultCode operation_result_code) {
MutexLock lock(&mutex_);
if (!CanRecordAnalyticsLocked("OnOutgoingPayloadDone")) {
@@ -773,24 +753,22 @@ void AnalyticsRecorder::OnOutgoingPayloadDone(
return;
}
const std::unique_ptr<LogicalConnection> &logical_connection = it->second;
const std::unique_ptr<LogicalConnection>& 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) {
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<ConnectionsLog::BandwidthUpgradeAttempt>();
if (!no_record_time_millis_) {
bandwidth_upgrade_attempt->set_duration_millis(
absl::ToUnixMillis(SystemClock::ElapsedRealtime()));
}
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);
@@ -799,8 +777,26 @@ void AnalyticsRecorder::OnBandwidthUpgradeStarted(
{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,
const std::string& endpoint_id, BandwidthUpgradeResult result,
BandwidthUpgradeErrorStage error_stage,
OperationResultCode operation_result_code) {
MutexLock lock(&mutex_);
@@ -817,7 +813,7 @@ void AnalyticsRecorder::OnBandwidthUpgradeError(
}
void AnalyticsRecorder::OnBandwidthUpgradeSuccess(
const std::string &endpoint_id) {
const std::string& endpoint_id) {
MutexLock lock(&mutex_);
if (!CanRecordAnalyticsLocked("OnBandwidthUpgradeSuccess")) {
return;
@@ -827,7 +823,7 @@ void AnalyticsRecorder::OnBandwidthUpgradeSuccess(
OperationResultCode::DETAIL_SUCCESS);
}
void AnalyticsRecorder::OnErrorCode(const ErrorCodeParams &params) {
void AnalyticsRecorder::OnErrorCode(const ErrorCodeParams& params) {
MutexLock lock(&mutex_);
if (!CanRecordAnalyticsLocked("OnErrorCode")) {
return;
@@ -912,10 +908,8 @@ void AnalyticsRecorder::LogSession() {
return;
}
FinishStrategySessionLocked();
if (!no_record_time_millis_) {
client_session_->set_duration_millis(absl::ToInt64Milliseconds(
SystemClock::ElapsedRealtime() - started_client_session_time_));
}
client_session_->set_duration_millis(absl::ToInt64Milliseconds(
SystemClock::ElapsedRealtime() - started_client_session_time_));
LogClientSessionLocked();
LogEvent(STOP_CLIENT_SESSION);
start_client_session_was_logged_ = false;
@@ -926,8 +920,8 @@ std::unique_ptr<AdvertisingMetadataParams>
AnalyticsRecorder::BuildAdvertisingMetadataParams(
bool is_extended_advertisement_supported, int connected_ap_frequency,
bool is_nfc_available,
const std::vector<ConnectionsLog::OperationResultWithMedium>
&operation_result_with_mediums) {
const std::vector<ConnectionsLog::OperationResultWithMedium>&
operation_result_with_mediums) {
auto params = std::make_unique<AdvertisingMetadataParams>();
params->is_extended_advertisement_supported =
is_extended_advertisement_supported;
@@ -942,8 +936,8 @@ std::unique_ptr<DiscoveryMetadataParams>
AnalyticsRecorder::BuildDiscoveryMetadataParams(
bool is_extended_advertisement_supported, int connected_ap_frequency,
bool is_nfc_available,
const std::vector<ConnectionsLog::OperationResultWithMedium>
&operation_result_with_mediums) {
const std::vector<ConnectionsLog::OperationResultWithMedium>&
operation_result_with_mediums) {
auto params = std::make_unique<DiscoveryMetadataParams>();
params->is_extended_advertisement_supported =
is_extended_advertisement_supported;
@@ -957,8 +951,8 @@ AnalyticsRecorder::BuildDiscoveryMetadataParams(
std::unique_ptr<ConnectionAttemptMetadataParams>
AnalyticsRecorder::BuildConnectionAttemptMetadataParams(
ConnectionTechnology technology, ConnectionBand band, int frequency,
int try_count, const std::string &network_operator,
const std::string &country_code, bool is_tdls_used,
int try_count, const std::string& network_operator,
const std::string& country_code, bool is_tdls_used,
bool wifi_hotspot_enabled, int max_wifi_tx_speed, int max_wifi_rx_speed,
int channel_width, OperationResultCode operation_result_code) {
auto params = std::make_unique<ConnectionAttemptMetadataParams>();
@@ -1091,8 +1085,7 @@ void AnalyticsRecorder::RecordAdvertisingPhaseDurationAndReasonLocked(
"null current_advertising_phase_";
return;
}
if (!current_advertising_phase_->has_duration_millis() &&
!no_record_time_millis_) {
if (!current_advertising_phase_->has_duration_millis()) {
current_advertising_phase_->set_duration_millis(absl::ToInt64Milliseconds(
SystemClock::ElapsedRealtime() - started_advertising_phase_time_));
}
@@ -1105,11 +1098,11 @@ void AnalyticsRecorder::RecordAdvertisingPhaseDurationAndReasonLocked(
void AnalyticsRecorder::FinishAdvertisingPhaseLocked() {
if (current_advertising_phase_ != nullptr) {
for (const auto &item : incoming_connection_requests_) {
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<ConnectionsLog::ConnectionRequest>
&connection_request = item.second;
const std::unique_ptr<ConnectionsLog::ConnectionRequest>&
connection_request = item.second;
MarkConnectionRequestIgnoredLocked(connection_request.get());
UpdateAdvertiserConnectionRequestLocked(connection_request.get());
}
@@ -1132,8 +1125,7 @@ void AnalyticsRecorder::RecordDiscoveryPhaseDurationAndReasonLocked(
"null current_discovery_phase_";
return;
}
if (!current_discovery_phase_->has_duration_millis() &&
!no_record_time_millis_) {
if (!current_discovery_phase_->has_duration_millis()) {
current_discovery_phase_->set_duration_millis(absl::ToInt64Milliseconds(
SystemClock::ElapsedRealtime() - started_discovery_phase_time_));
}
@@ -1147,11 +1139,11 @@ void AnalyticsRecorder::RecordDiscoveryPhaseDurationAndReasonLocked(
void AnalyticsRecorder::FinishDiscoveryPhaseLocked() {
if (current_discovery_phase_ != nullptr) {
for (const auto &item : outgoing_connection_requests_) {
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<ConnectionsLog::ConnectionRequest>
&connection_request = item.second;
const std::unique_ptr<ConnectionsLog::ConnectionRequest>&
connection_request = item.second;
MarkConnectionRequestIgnoredLocked(connection_request.get());
UpdateDiscovererConnectionRequestLocked(connection_request.get());
}
@@ -1168,18 +1160,16 @@ void AnalyticsRecorder::FinishDiscoveryPhaseLocked() {
}
bool AnalyticsRecorder::UpdateAdvertiserConnectionRequestLocked(
ConnectionsLog::ConnectionRequest *request) {
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)) {
if (!no_record_time_millis_) {
request->set_duration_millis(
absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
request->duration_millis());
}
request->set_duration_millis(
absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
request->duration_millis());
*current_advertising_phase_->add_received_connection_request() = *request;
return true;
}
@@ -1187,7 +1177,7 @@ bool AnalyticsRecorder::UpdateAdvertiserConnectionRequestLocked(
}
bool AnalyticsRecorder::UpdateDiscovererConnectionRequestLocked(
ConnectionsLog::ConnectionRequest *request) {
ConnectionsLog::ConnectionRequest* request) {
if (current_discovery_phase_ == nullptr) {
LOG(INFO) << "Unable to record discoverer connection request due "
"to null current_discovery_phase_.";
@@ -1195,11 +1185,9 @@ bool AnalyticsRecorder::UpdateDiscovererConnectionRequestLocked(
}
if (BothEndpointsRespondedLocked(request) ||
request->local_response() == NOT_SENT) {
if (!no_record_time_millis_) {
request->set_duration_millis(
absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
request->duration_millis());
}
request->set_duration_millis(
absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
request->duration_millis());
*current_discovery_phase_->add_sent_connection_request() = *request;
return true;
}
@@ -1207,15 +1195,15 @@ bool AnalyticsRecorder::UpdateDiscovererConnectionRequestLocked(
}
bool AnalyticsRecorder::BothEndpointsRespondedLocked(
ConnectionsLog::ConnectionRequest *request) {
ConnectionsLog::ConnectionRequest* request) {
return request->has_local_response() && request->has_remote_response();
}
void AnalyticsRecorder::LocalEndpointRespondedLocked(
const std::string &remote_endpoint_id, ConnectionRequestResponse response) {
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();
ConnectionsLog::ConnectionRequest* connection_request = out->second.get();
connection_request->set_local_response(response);
if (UpdateDiscovererConnectionRequestLocked(connection_request)) {
outgoing_connection_requests_.erase(out);
@@ -1223,7 +1211,7 @@ void AnalyticsRecorder::LocalEndpointRespondedLocked(
}
auto in = incoming_connection_requests_.find(remote_endpoint_id);
if (in != incoming_connection_requests_.end()) {
ConnectionsLog::ConnectionRequest *connection_request = in->second.get();
ConnectionsLog::ConnectionRequest* connection_request = in->second.get();
connection_request->set_local_response(response);
if (UpdateAdvertiserConnectionRequestLocked(connection_request)) {
incoming_connection_requests_.erase(in);
@@ -1232,10 +1220,10 @@ void AnalyticsRecorder::LocalEndpointRespondedLocked(
}
void AnalyticsRecorder::RemoteEndpointRespondedLocked(
const std::string &remote_endpoint_id, ConnectionRequestResponse response) {
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();
ConnectionsLog::ConnectionRequest* connection_request = out->second.get();
connection_request->set_remote_response(response);
if (UpdateDiscovererConnectionRequestLocked(connection_request)) {
outgoing_connection_requests_.erase(out);
@@ -1243,7 +1231,7 @@ void AnalyticsRecorder::RemoteEndpointRespondedLocked(
}
auto in = incoming_connection_requests_.find(remote_endpoint_id);
if (in != incoming_connection_requests_.end()) {
ConnectionsLog::ConnectionRequest *connection_request = in->second.get();
ConnectionsLog::ConnectionRequest* connection_request = in->second.get();
connection_request->set_remote_response(response);
if (UpdateAdvertiserConnectionRequestLocked(connection_request)) {
incoming_connection_requests_.erase(in);
@@ -1252,7 +1240,7 @@ void AnalyticsRecorder::RemoteEndpointRespondedLocked(
}
void AnalyticsRecorder::MarkConnectionRequestIgnoredLocked(
ConnectionsLog::ConnectionRequest *request) {
ConnectionsLog::ConnectionRequest* request) {
if (!request->has_local_response()) {
request->set_local_response(IGNORED);
}
@@ -1263,13 +1251,13 @@ void AnalyticsRecorder::MarkConnectionRequestIgnoredLocked(
bool AnalyticsRecorder::ConnectionAttemptResultCodeExistedLocked(
Medium medium, ConnectionAttemptDirection direction,
const std::string &connection_token, ConnectionAttemptType type,
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 :
for (auto& connection_attempt :
current_strategy_session_->connection_attempt()) {
if (connection_attempt.medium() == medium &&
connection_attempt.direction() == direction &&
@@ -1288,7 +1276,7 @@ bool AnalyticsRecorder::ConnectionAttemptResultCodeExistedLocked(
// 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,
const std::string& endpoint_id, BandwidthUpgradeResult result,
BandwidthUpgradeErrorStage error_stage,
OperationResultCode operation_result_code) {
if (current_strategy_session_ == nullptr) {
@@ -1296,8 +1284,8 @@ bool AnalyticsRecorder::EraseIfBandwidthUpgradeRecordExistedLocked(
}
auto it = bandwidth_upgrade_attempts_.find(endpoint_id);
if (it != bandwidth_upgrade_attempts_.end()) {
ConnectionsLog::BandwidthUpgradeAttempt *attempt = it->second.get();
for (auto &existing_attempt :
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() &&
@@ -1314,7 +1302,7 @@ bool AnalyticsRecorder::EraseIfBandwidthUpgradeRecordExistedLocked(
}
void AnalyticsRecorder::FinishUpgradeAttemptLocked(
const std::string &endpoint_id, BandwidthUpgradeResult result,
const std::string& endpoint_id, BandwidthUpgradeResult result,
BandwidthUpgradeErrorStage error_stage,
OperationResultCode operation_result_code, bool erase_item) {
if (current_strategy_session_ == nullptr) {
@@ -1325,12 +1313,10 @@ void AnalyticsRecorder::FinishUpgradeAttemptLocked(
// 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();
if (!no_record_time_millis_) {
attempt->set_duration_millis(
absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
attempt->duration_millis());
}
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);
@@ -1353,8 +1339,8 @@ void AnalyticsRecorder::FinishStrategySessionLocked() {
FinishDiscoveryPhaseLocked();
// Finish any unfinished LogicalConnections.
for (const auto &item : active_connections_) {
const std::unique_ptr<LogicalConnection> &logical_connection =
for (const auto& item : active_connections_) {
const std::unique_ptr<LogicalConnection>& logical_connection =
item.second;
logical_connection->CloseAllPhysicalConnections();
absl::c_copy(
@@ -1365,7 +1351,7 @@ void AnalyticsRecorder::FinishStrategySessionLocked() {
active_connections_.clear();
// Finish any pending upgrade attempts.
for (const auto &item : bandwidth_upgrade_attempts_) {
for (const auto& item : bandwidth_upgrade_attempts_) {
FinishUpgradeAttemptLocked(
item.first, UNFINISHED_ERROR, UPGRADE_UNFINISHED,
OperationResultCode::DEVICE_STATE_ERROR_UNFINISHED_UPGRADE_ATTEMPTS,
@@ -1375,11 +1361,8 @@ void AnalyticsRecorder::FinishStrategySessionLocked() {
// Add the StrategySession in ClientSession
if (current_strategy_session_ != nullptr) {
if (!no_record_time_millis_) {
current_strategy_session_->set_duration_millis(
absl::ToInt64Milliseconds(SystemClock::ElapsedRealtime() -
started_strategy_session_time_));
}
current_strategy_session_->set_duration_millis(absl::ToInt64Milliseconds(
SystemClock::ElapsedRealtime() - started_strategy_session_time_));
*client_session_->add_strategy_session() =
*std::move(current_strategy_session_);
}
@@ -1427,10 +1410,8 @@ void AnalyticsRecorder::PendingPayload::AddChunk(
ConnectionsLog::Payload AnalyticsRecorder::PendingPayload::GetProtoPayload(
PayloadStatus status) {
ConnectionsLog::Payload payload;
if (!no_record_time_millis_) {
payload.set_duration_millis(absl::ToInt64Milliseconds(
SystemClock::ElapsedRealtime() - start_time_));
}
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_);
@@ -1448,7 +1429,7 @@ ConnectionsLog::Payload AnalyticsRecorder::PendingPayload::GetProtoPayload(
}
void AnalyticsRecorder::LogicalConnection::PhysicalConnectionEstablished(
Medium medium, const std::string &connection_token) {
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.";
@@ -1457,10 +1438,8 @@ void AnalyticsRecorder::LogicalConnection::PhysicalConnectionEstablished(
auto established_connection =
std::make_unique<ConnectionsLog::EstablishedConnection>();
established_connection->set_medium(medium);
if (!no_record_time_millis_) {
established_connection->set_duration_millis(
absl::ToUnixMillis(SystemClock::ElapsedRealtime()));
}
established_connection->set_duration_millis(
absl::ToUnixMillis(SystemClock::ElapsedRealtime()));
established_connection->set_connection_token(connection_token);
auto operation_result_proto =
@@ -1496,7 +1475,7 @@ void AnalyticsRecorder::LogicalConnection::PhysicalConnectionClosed(
" opened.";
return;
}
ConnectionsLog::EstablishedConnection *established_connection =
ConnectionsLog::EstablishedConnection* established_connection =
it->second.get();
if (established_connection->has_disconnection_reason()) {
LOG(WARNING) << "Unexpected call to physicalConnectionClosed() for medium "
@@ -1516,8 +1495,8 @@ void AnalyticsRecorder::LogicalConnection::PhysicalConnectionClosed(
}
void AnalyticsRecorder::LogicalConnection::CloseAllPhysicalConnections() {
for (const auto &physical_connection : physical_connections_) {
ConnectionsLog::EstablishedConnection *established_connection =
for (const auto& physical_connection : physical_connections_) {
ConnectionsLog::EstablishedConnection* established_connection =
physical_connection.second.get();
if (!established_connection->has_disconnection_reason()) {
FinishPhysicalConnection(
@@ -1539,10 +1518,10 @@ AnalyticsRecorder::LogicalConnection::GetEstablisedConnections() {
}
std::transform(physical_connections_.begin(), physical_connections_.end(),
std::back_inserter(established_connections),
[](auto &kv) { return *kv.second; });
[](auto& kv) { return *kv.second; });
physical_connections_.clear();
for (auto &established_connection : established_connections) {
for (auto& established_connection : established_connections) {
if (absl::Milliseconds(established_connection.duration_millis()) >=
kConnectionTokenMaxLife) {
LOG(INFO) << "connection token exceed TTL, drop token.";
@@ -1556,8 +1535,7 @@ AnalyticsRecorder::LogicalConnection::GetEstablisedConnections() {
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<PendingPayload>(type, total_size_bytes,
no_record_time_millis_)});
{payload_id, std::make_unique<PendingPayload>(type, total_size_bytes)});
}
void AnalyticsRecorder::LogicalConnection::ChunkReceived(
@@ -1566,7 +1544,7 @@ void AnalyticsRecorder::LogicalConnection::ChunkReceived(
if (it == incoming_payloads_.end()) {
return;
}
PendingPayload *pending_payload = it->second.get();
PendingPayload* pending_payload = it->second.get();
pending_payload->AddChunk(size_bytes);
}
@@ -1580,8 +1558,8 @@ void AnalyticsRecorder::LogicalConnection::IncomingPayloadDone(
}
auto it = physical_connections_.find(current_medium_);
if (it != physical_connections_.end()) {
const std::unique_ptr<ConnectionsLog::EstablishedConnection>
&established_connection = it->second;
const std::unique_ptr<ConnectionsLog::EstablishedConnection>&
established_connection = it->second;
auto it = incoming_payloads_.find(payload_id);
if (it != incoming_payloads_.end()) {
it->second->SetOperationResultCode(operation_result_code);
@@ -1595,8 +1573,7 @@ void AnalyticsRecorder::LogicalConnection::IncomingPayloadDone(
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<PendingPayload>(type, total_size_bytes,
no_record_time_millis_)});
{payload_id, std::make_unique<PendingPayload>(type, total_size_bytes)});
}
void AnalyticsRecorder::LogicalConnection::ChunkSent(std::int64_t payload_id,
@@ -1605,7 +1582,7 @@ void AnalyticsRecorder::LogicalConnection::ChunkSent(std::int64_t payload_id,
if (it == outgoing_payloads_.end()) {
return;
}
PendingPayload *payload = it->second.get();
PendingPayload* payload = it->second.get();
payload->AddChunk(size_bytes);
}
@@ -1619,8 +1596,8 @@ void AnalyticsRecorder::LogicalConnection::OutgoingPayloadDone(
}
auto it = physical_connections_.find(current_medium_);
if (it != physical_connections_.end()) {
const std::unique_ptr<ConnectionsLog::EstablishedConnection>
&established_connection = it->second;
const std::unique_ptr<ConnectionsLog::EstablishedConnection>&
established_connection = it->second;
auto it = outgoing_payloads_.find(payload_id);
if (it != outgoing_payloads_.end()) {
it->second->SetOperationResultCode(operation_result_code);
@@ -1632,15 +1609,13 @@ void AnalyticsRecorder::LogicalConnection::OutgoingPayloadDone(
}
void AnalyticsRecorder::LogicalConnection::FinishPhysicalConnection(
ConnectionsLog::EstablishedConnection *established_connection,
ConnectionsLog::EstablishedConnection* established_connection,
DisconnectionReason reason, SafeDisconnectionResult result) {
established_connection->set_disconnection_reason(reason);
established_connection->set_safe_disconnection_result(result);
if (!no_record_time_millis_) {
established_connection->set_duration_millis(
absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
established_connection->duration_millis());
}
established_connection->set_duration_millis(
absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
established_connection->duration_millis());
// Add any not-yet-finished payloads to this EstablishedConnection.
std::vector<ConnectionsLog::Payload> in_payloads =
@@ -1657,8 +1632,8 @@ void AnalyticsRecorder::LogicalConnection::FinishPhysicalConnection(
std::vector<ConnectionsLog::Payload>
AnalyticsRecorder::LogicalConnection::ResolvePendingPayloads(
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>
&pending_payloads,
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>&
pending_payloads,
DisconnectionReason reason) {
std::vector<ConnectionsLog::Payload> completed_payloads;
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>
@@ -1668,8 +1643,8 @@ AnalyticsRecorder::LogicalConnection::ResolvePendingPayloads(
OperationResultCode operation_result_code =
GetPendingPayloadResultCodeFromReason(reason);
for (const auto &item : pending_payloads) {
const std::unique_ptr<PendingPayload> &pending_payload = item.second;
for (const auto& item : pending_payloads) {
const std::unique_ptr<PendingPayload>& pending_payload = item.second;
pending_payload->SetOperationResultCode(operation_result_code);
ConnectionsLog::Payload proto_payload =
pending_payload->GetProtoPayload(status);
@@ -1677,9 +1652,9 @@ AnalyticsRecorder::LogicalConnection::ResolvePendingPayloads(
if (reason == UPGRADED) {
upgraded_payloads.insert(
{item.first,
std::make_unique<PendingPayload>(
pending_payload->type(), pending_payload->total_size_bytes(),
no_record_time_millis_, operation_result_code)});
std::make_unique<PendingPayload>(pending_payload->type(),
pending_payload->total_size_bytes(),
operation_result_code)});
}
}
pending_payloads.clear();
@@ -42,17 +42,14 @@ namespace analytics {
class AnalyticsRecorder {
public:
explicit AnalyticsRecorder(::nearby::analytics::EventLogger *event_logger);
// For testing only.
AnalyticsRecorder(::nearby::analytics::EventLogger *event_logger,
bool no_record_time_millis);
explicit AnalyticsRecorder(::nearby::analytics::EventLogger* event_logger);
virtual ~AnalyticsRecorder();
// Advertising phase
void OnStartAdvertising(
connections::Strategy strategy,
const std::vector<location::nearby::proto::connections::Medium> &mediums,
AdvertisingMetadataParams *advertising_metadata_params)
const std::vector<location::nearby::proto::connections::Medium>& mediums,
AdvertisingMetadataParams* advertising_metadata_params)
ABSL_LOCKS_EXCLUDED(mutex_);
void OnStopAdvertising() ABSL_LOCKS_EXCLUDED(mutex_);
@@ -70,8 +67,8 @@ class AnalyticsRecorder {
// Discovery phase
void OnStartDiscovery(
connections::Strategy strategy,
const std::vector<location::nearby::proto::connections::Medium> &mediums,
DiscoveryMetadataParams *discovery_metadata_params)
const std::vector<location::nearby::proto::connections::Medium>& mediums,
DiscoveryMetadataParams* discovery_metadata_params)
ABSL_LOCKS_EXCLUDED(mutex_);
void OnStopDiscovery() ABSL_LOCKS_EXCLUDED(mutex_);
@@ -84,21 +81,21 @@ class AnalyticsRecorder {
ABSL_LOCKS_EXCLUDED(mutex_);
// Connection request
void OnRequestConnection(const connections::Strategy &strategy,
const std::string &endpoint_id)
void OnRequestConnection(const connections::Strategy& strategy,
const std::string& endpoint_id)
ABSL_LOCKS_EXCLUDED(mutex_);
void OnConnectionRequestReceived(const std::string &remote_endpoint_id)
void OnConnectionRequestReceived(const std::string& remote_endpoint_id)
ABSL_LOCKS_EXCLUDED(mutex_);
void OnConnectionRequestSent(const std::string &remote_endpoint_id)
void OnConnectionRequestSent(const std::string& remote_endpoint_id)
ABSL_LOCKS_EXCLUDED(mutex_);
void OnRemoteEndpointAccepted(const std::string &remote_endpoint_id)
void OnRemoteEndpointAccepted(const std::string& remote_endpoint_id)
ABSL_LOCKS_EXCLUDED(mutex_);
void OnLocalEndpointAccepted(const std::string &remote_endpoint_id)
void OnLocalEndpointAccepted(const std::string& remote_endpoint_id)
ABSL_LOCKS_EXCLUDED(mutex_);
void OnRemoteEndpointRejected(const std::string &remote_endpoint_id)
void OnRemoteEndpointRejected(const std::string& remote_endpoint_id)
ABSL_LOCKS_EXCLUDED(mutex_);
void OnLocalEndpointRejected(const std::string &remote_endpoint_id)
void OnLocalEndpointRejected(const std::string& remote_endpoint_id)
ABSL_LOCKS_EXCLUDED(mutex_);
// Connection attempt
@@ -108,39 +105,39 @@ class AnalyticsRecorder {
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::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(
const std::string &remote_endpoint_id,
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::Duration duration, const std::string& connection_token,
ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
ABSL_LOCKS_EXCLUDED(mutex_);
static std::unique_ptr<AdvertisingMetadataParams>
BuildAdvertisingMetadataParams(
bool is_extended_advertisement_supported = false,
int connected_ap_frequency = 0, bool is_nfc_available = false,
const std::vector<location::nearby::analytics::proto::ConnectionsLog::
OperationResultWithMedium>
&operation_result_with_mediums = {});
OperationResultWithMedium>&
operation_result_with_mediums = {});
static std::unique_ptr<DiscoveryMetadataParams> BuildDiscoveryMetadataParams(
bool is_extended_advertisement_supported = false,
int connected_ap_frequency = 0, bool is_nfc_available = false,
const std::vector<location::nearby::analytics::proto::ConnectionsLog::
OperationResultWithMedium>
&operation_result_with_mediums = {});
OperationResultWithMedium>&
operation_result_with_mediums = {});
static std::unique_ptr<ConnectionAttemptMetadataParams>
BuildConnectionAttemptMetadataParams(
location::nearby::proto::connections::ConnectionTechnology technology,
location::nearby::proto::connections::ConnectionBand band, int frequency,
int try_count, const std::string &network_operator = {},
const std::string &country_code = {}, bool is_tdls_used = false,
int try_count, const std::string& network_operator = {},
const std::string& country_code = {}, bool is_tdls_used = false,
bool wifi_hotspot_enabled = false, int max_wifi_tx_speed = 0,
int max_wifi_rx_speed = 0, int channel_width = -1,
location::nearby::proto::connections::OperationResultCode
@@ -152,11 +149,11 @@ class AnalyticsRecorder {
// Connection establishedSafeDisconnectionResult
void OnConnectionEstablished(
const std::string &endpoint_id,
const std::string& endpoint_id,
location::nearby::proto::connections::Medium medium,
const std::string &connection_token) ABSL_LOCKS_EXCLUDED(mutex_);
const std::string& connection_token) ABSL_LOCKS_EXCLUDED(mutex_);
void OnConnectionClosed(
const std::string &endpoint_id,
const std::string& endpoint_id,
location::nearby::proto::connections::Medium medium,
location::nearby::proto::connections::DisconnectionReason reason,
location::nearby::analytics::proto::ConnectionsLog::
@@ -164,55 +161,59 @@ class AnalyticsRecorder {
ABSL_LOCKS_EXCLUDED(mutex_);
// Payload
void OnIncomingPayloadStarted(const std::string &endpoint_id,
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,
void OnPayloadChunkReceived(const std::string& endpoint_id,
std::int64_t payload_id,
std::int64_t chunk_size_bytes)
ABSL_LOCKS_EXCLUDED(mutex_);
void OnIncomingPayloadDone(
const std::string &endpoint_id, std::int64_t payload_id,
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<std::string> &endpoint_ids,
void OnOutgoingPayloadStarted(const std::vector<std::string>& 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,
void OnPayloadChunkSent(const std::string& endpoint_id,
std::int64_t payload_id,
std::int64_t chunk_size_bytes)
ABSL_LOCKS_EXCLUDED(mutex_);
void OnOutgoingPayloadDone(
const std::string &endpoint_id, std::int64_t payload_id,
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_);
// BandwidthUpgrade
void OnBandwidthUpgradeStarted(
const std::string &endpoint_id,
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_);
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 &endpoint_id,
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)
void OnBandwidthUpgradeSuccess(const std::string& endpoint_id)
ABSL_LOCKS_EXCLUDED(mutex_);
// Error Code
void OnErrorCode(const ErrorCodeParams &params);
void OnErrorCode(const ErrorCodeParams& params);
// Log the start client session event with start client session logging
// resources setup (e.g. client_session_, started_client_session_time_)
@@ -238,12 +239,12 @@ class AnalyticsRecorder {
class PendingPayload {
public:
PendingPayload(location::nearby::proto::connections::PayloadType type,
std::int64_t total_size_bytes, bool no_record_time_millis)
: PendingPayload(type, total_size_bytes, no_record_time_millis,
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, bool no_record_time_millis,
std::int64_t total_size_bytes,
location::nearby::proto::connections::OperationResultCode
operation_result_code)
: start_time_(SystemClock::ElapsedRealtime()),
@@ -251,8 +252,7 @@ class AnalyticsRecorder {
total_size_bytes_(total_size_bytes),
num_bytes_transferred_(0),
num_chunks_(0),
operation_result_code_(operation_result_code),
no_record_time_millis_(no_record_time_millis) {}
operation_result_code_(operation_result_code) {}
~PendingPayload() = default;
void AddChunk(std::int64_t chunk_size_bytes);
@@ -281,31 +281,28 @@ class AnalyticsRecorder {
location::nearby::proto::connections::OperationResultCode
operation_result_code_ = location::nearby::proto::connections::
OperationResultCode::DETAIL_UNKNOWN;
// For testing only.
bool no_record_time_millis_ = false;
};
class LogicalConnection {
public:
LogicalConnection(
location::nearby::proto::connections::Medium initial_medium,
const std::string &connection_token, bool no_record_time_millis)
: no_record_time_millis_(no_record_time_millis) {
const std::string& connection_token) {
PhysicalConnectionEstablished(initial_medium, connection_token);
}
LogicalConnection(const LogicalConnection &) = delete;
LogicalConnection(LogicalConnection &&other)
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& operator=(const LogicalConnection&) = delete;
LogicalConnection&& operator=(LogicalConnection&&) = delete;
~LogicalConnection() = default;
void PhysicalConnectionEstablished(
location::nearby::proto::connections::Medium medium,
const std::string &connection_token);
const std::string& connection_token);
void PhysicalConnectionClosed(
location::nearby::proto::connections::Medium medium,
location::nearby::proto::connections::DisconnectionReason reason,
@@ -341,14 +338,14 @@ class AnalyticsRecorder {
private:
void FinishPhysicalConnection(
location::nearby::analytics::proto::ConnectionsLog::
EstablishedConnection *established_connection,
EstablishedConnection* established_connection,
location::nearby::proto::connections::DisconnectionReason reason,
location::nearby::analytics::proto::ConnectionsLog::
EstablishedConnection::SafeDisconnectionResult result);
std::vector<location::nearby::analytics::proto::ConnectionsLog::Payload>
ResolvePendingPayloads(
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>
&pending_payloads,
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>&
pending_payloads,
location::nearby::proto::connections::DisconnectionReason reason);
location::nearby::proto::connections::OperationResultCode
GetPendingPayloadResultCodeFromReason(
@@ -364,8 +361,6 @@ class AnalyticsRecorder {
incoming_payloads_;
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>
outgoing_payloads_;
// For testing only.
bool no_record_time_millis_ = false;
};
bool CanRecordAnalyticsLocked(absl::string_view method_name)
@@ -388,57 +383,57 @@ class AnalyticsRecorder {
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_);
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_);
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_);
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
void LocalEndpointRespondedLocked(
const std::string &remote_endpoint_id,
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,
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_);
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::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,
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::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,
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,
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,
const std::string& endpoint_id,
location::nearby::proto::connections::BandwidthUpgradeResult result,
location::nearby::proto::connections::BandwidthUpgradeErrorStage
error_stage,
@@ -449,7 +444,7 @@ class AnalyticsRecorder {
int GetLatestUpdateIndexLocked(
const std::vector<location::nearby::analytics::proto::ConnectionsLog::
OperationResultWithMedium> &list)
OperationResultWithMedium>& list)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
location::nearby::proto::connections::ConnectionsStrategy
@@ -459,14 +454,11 @@ class AnalyticsRecorder {
// Not owned by AnalyticsRecorder. Pointer must refer to a valid object
// that outlives the one constructed.
::nearby::analytics::EventLogger *event_logger_;
::nearby::analytics::EventLogger* event_logger_;
// Protects all sub-protos reading and writing in ConnectionLog.
Mutex mutex_;
// For testing only.
bool no_record_time_millis_ = false;
// ClientSession
std::unique_ptr<
location::nearby::analytics::proto::ConnectionsLog::ClientSession>
File diff suppressed because it is too large Load Diff
+12 -10
View File
@@ -32,6 +32,7 @@
#include "connections/implementation/mediums/utils.h"
#include "connections/implementation/offline_frames.h"
#include "connections/implementation/service_id_constants.h"
#include "internal/base/masker.h"
#include "internal/platform/awdl.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/count_down_latch.h"
@@ -44,6 +45,7 @@ namespace nearby {
namespace connections {
namespace {
using ::location::nearby::connections::BandwidthUpgradeNegotiationFrame;
using ::location::nearby::proto::connections::OperationResultCode;
constexpr absl::Duration kAwdlDiscoveryTimeout = absl::Seconds(5);
@@ -63,21 +65,21 @@ AwdlBwuHandler::AwdlBwuHandler(
ErrorOr<std::unique_ptr<EndpointChannel>>
AwdlBwuHandler::CreateUpgradedEndpointChannel(
ClientProxy* client, const std::string& service_id,
const std::string& endpoint_id, const UpgradePathInfo& upgrade_path_info) {
const std::string& endpoint_id,
const BandwidthUpgradeNegotiationFrame::UpgradePathInfo&
upgrade_path_info) {
std::string upgrade_service_id = WrapInitiatorUpgradeServiceId(service_id);
if (!upgrade_path_info.has_awdl_credentials()) {
return {
Error(OperationResultCode::CONNECTIVITY_AWDL_INVALID_CREDENTIAL)};
return {Error(OperationResultCode::CONNECTIVITY_AWDL_INVALID_CREDENTIAL)};
}
const UpgradePathInfo::AwdlCredentials& awdl_credentials =
upgrade_path_info.awdl_credentials();
const BandwidthUpgradeNegotiationFrame::UpgradePathInfo::AwdlCredentials&
awdl_credentials = upgrade_path_info.awdl_credentials();
if (!awdl_credentials.has_service_name() ||
!awdl_credentials.has_service_type() ||
!awdl_credentials.has_password()) {
LOG(ERROR) << "Failed to upgrade AWDL due to invalid credentials.";
return {
Error(OperationResultCode::CONNECTIVITY_AWDL_INVALID_CREDENTIAL)};
return {Error(OperationResultCode::CONNECTIVITY_AWDL_INVALID_CREDENTIAL)};
}
std::string service_name = awdl_credentials.service_name();
@@ -87,8 +89,8 @@ AwdlBwuHandler::CreateUpgradedEndpointChannel(
LOG(INFO) << "Attempting to connect to "
<< "AWDL (service_name:" << service_name
<< ", service_type:" << service_type
<< ", has password:" << (password.empty() ? "false" : "true")
<< ") for endpoint " << endpoint_id;
<< ", password:" << masker::Mask(password) << ") for endpoint "
<< endpoint_id;
NsdServiceInfo nsd_service_info{};
nsd_service_info.SetServiceName(service_name);
@@ -233,7 +235,7 @@ ByteArray AwdlBwuHandler::HandleInitializeUpgradedMediumForEndpoint(
LOG(INFO) << "Retrieved AWDL credentials. service_name: " << service_name
<< " and service_type: " << service_type
<< " and has password: " << (password.empty() ? "false" : "true");
<< " and password: " << masker::Mask(password);
// The AWDL upgraded medium is running under TLS, so we don't need to
// encryption for it again.
@@ -59,7 +59,8 @@ class AwdlBwuHandler : public BaseBwuHandler {
ErrorOr<std::unique_ptr<EndpointChannel>> CreateUpgradedEndpointChannel(
ClientProxy* client, const std::string& service_id,
const std::string& endpoint_id,
const UpgradePathInfo& upgrade_path_info) override;
const location::nearby::connections::BandwidthUpgradeNegotiationFrame::
UpgradePathInfo& upgrade_path_info) override;
location::nearby::proto::connections::Medium GetUpgradeMedium() const final {
return location::nearby::proto::connections::Medium::AWDL;
}
@@ -14,10 +14,13 @@
#include "connections/implementation/base_bwu_handler.h"
#include <memory>
#include <string>
#include <utility>
#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 {
@@ -19,9 +19,10 @@
#include <string>
#include "absl/container/flat_hash_map.h"
#include "absl/strings/string_view.h"
#include "absl/container/flat_hash_set.h"
#include "connections/implementation/bwu_handler.h"
#include "connections/implementation/endpoint_channel_manager.h"
#include "connections/implementation/client_proxy.h"
#include "internal/platform/byte_array.h"
namespace nearby {
namespace connections {
@@ -30,7 +30,7 @@
namespace nearby {
namespace connections {
namespace {
using ::location::nearby::connections::BandwidthUpgradeNegotiationFrame;
using ::location::nearby::proto::connections::OperationResultCode;
// Because BaseBwuHandler is still an abstract class, we need to implement the
@@ -61,11 +61,11 @@ class BwuHandlerImpl : public BaseBwuHandler {
private:
// BwuHandler implementation:
ErrorOr<std::unique_ptr<EndpointChannel>>
CreateUpgradedEndpointChannel(
ErrorOr<std::unique_ptr<EndpointChannel>> CreateUpgradedEndpointChannel(
ClientProxy* client, const std::string& service_id,
const std::string& endpoint_id,
const UpgradePathInfo& upgrade_path_info) final {
const BandwidthUpgradeNegotiationFrame::UpgradePathInfo&
upgrade_path_info) final {
return {Error(OperationResultCode::DETAIL_UNKNOWN)};
}
Medium GetUpgradeMedium() const final { return Medium::UNKNOWN_MEDIUM; }
@@ -30,6 +30,7 @@
#include "connections/implementation/flags/nearby_connections_feature_flags.h"
#include "connections/implementation/offline_frames.h"
#include "internal/flags/nearby_flags.h"
#include "internal/platform/base64_utils.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/exception.h"
#include "internal/platform/implementation/system_clock.h"
@@ -44,41 +45,13 @@ namespace 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;
std::int32_t BytesToInt(const ByteArray& bytes) {
const char* int_bytes = bytes.data();
std::int32_t result = 0;
result |= (static_cast<std::int32_t>(int_bytes[0]) & 0x0FF) << 24;
result |= (static_cast<std::int32_t>(int_bytes[1]) & 0x0FF) << 16;
result |= (static_cast<std::int32_t>(int_bytes[2]) & 0x0FF) << 8;
result |= (static_cast<std::int32_t>(int_bytes[3]) & 0x0FF);
return result;
}
ByteArray IntToBytes(std::int32_t value) {
char int_bytes[sizeof(std::int32_t)];
int_bytes[0] = static_cast<char>((value >> 24) & 0x0FF);
int_bytes[1] = static_cast<char>((value >> 16) & 0x0FF);
int_bytes[2] = static_cast<char>((value >> 8) & 0x0FF);
int_bytes[3] = static_cast<char>((value) & 0x0FF);
return ByteArray(int_bytes, sizeof(int_bytes));
}
ExceptionOr<std::int32_t> ReadInt(InputStream* reader) {
ExceptionOr<ByteArray> read_bytes = reader->ReadExactly(sizeof(std::int32_t));
if (!read_bytes.ok()) {
return ExceptionOr<std::int32_t>(read_bytes.exception());
}
return ExceptionOr<std::int32_t>(BytesToInt(std::move(read_bytes.result())));
}
Exception WriteInt(OutputStream* writer, std::int32_t value) {
return writer->Write(IntToBytes(value));
return Base64Utils::WriteInt(writer, value);
}
} // namespace
@@ -130,7 +103,22 @@ ExceptionOr<ByteArray> BaseEndpointChannel::Read(
MutexLock lock(&reader_mutex_);
packet_meta_data.StartSocketIo();
ExceptionOr<std::int32_t> read_int = ReadInt(reader_);
ExceptionOr<std::int32_t> read_int;
if (NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_connections_feature::
kRefactorBleL2cap)) {
ExceptionOr<ByteArray> read_control_block_bytes = DispatchPacket();
if (!read_control_block_bytes.ok()) {
LOG(WARNING) << __func__ << ": Failed to dispatch packet: "
<< read_control_block_bytes.exception();
return ExceptionOr<ByteArray>(read_control_block_bytes.exception());
}
read_int = (GetMedium() == BLE_L2CAP) ? ReadPayloadLength()
: Base64Utils::ReadInt(reader_);
} else {
read_int = Base64Utils::ReadInt(reader_);
}
if (!read_int.ok()) {
return ExceptionOr<ByteArray>(read_int.exception());
}
@@ -204,10 +192,10 @@ ExceptionOr<ByteArray> BaseEndpointChannel::Read(
Exception BaseEndpointChannel::Write(const ByteArray& data) {
PacketMetaData packet_meta_data;
return Write(data, packet_meta_data);
return Write(data.AsStringView(), packet_meta_data);
}
Exception BaseEndpointChannel::Write(const ByteArray& data,
Exception BaseEndpointChannel::Write(absl::string_view data,
PacketMetaData& packet_meta_data) {
{
MutexLock pause_lock(&is_paused_mutex_);
@@ -216,8 +204,9 @@ Exception BaseEndpointChannel::Write(const ByteArray& data,
}
}
ByteArray encrypted_data;
const ByteArray* data_to_write = &data;
absl::string_view data_to_write = data;
// Make sure encrypted message is value until end of function.
std::unique_ptr<std::string> encrypted;
{
// Holding both mutexes is necessary to prevent the keep alive and payload
// threads from writing encrypted messages out of order which causes a
@@ -229,19 +218,17 @@ Exception BaseEndpointChannel::Write(const ByteArray& data,
if (IsEncryptionEnabledLocked()) {
// If encryption is enabled, encode the message.
packet_meta_data.StartEncryption();
std::unique_ptr<std::string> encrypted =
crypto_context_->EncodeMessageToPeer(std::string(data));
encrypted = crypto_context_->EncodeMessageToPeer(data);
packet_meta_data.StopEncryption();
if (!encrypted) {
LOG(WARNING) << __func__ << ": Failed to encrypt data.";
return {Exception::kIo};
}
encrypted_data = ByteArray(std::move(*encrypted));
data_to_write = &encrypted_data;
data_to_write = *encrypted;
}
}
size_t data_size = data_to_write->size();
size_t data_size = data_to_write.size();
if (data_size < 0 || data_size > max_allowed_read_bytes_) {
LOG(WARNING) << __func__
<< ": Write an invalid number of bytes: " << data_size;
@@ -249,14 +236,21 @@ Exception BaseEndpointChannel::Write(const ByteArray& data,
}
packet_meta_data.StartSocketIo();
Exception write_exception =
WriteInt(writer_, static_cast<std::int32_t>(data_size));
Exception write_exception;
if (NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_connections_feature::
kRefactorBleL2cap) &&
(GetMedium() == BLE || GetMedium() == BLE_L2CAP)) {
write_exception = WritePayloadLength(data_size);
} else {
write_exception = WriteInt(writer_, static_cast<std::int32_t>(data_size));
}
if (write_exception.Raised()) {
LOG(WARNING) << __func__
<< ": Failed to write header: " << write_exception.value;
return write_exception;
}
write_exception = writer_->Write(*data_to_write);
write_exception = writer_->Write(data_to_write);
if (write_exception.Raised()) {
LOG(WARNING) << __func__
<< ": Failed to write data: " << write_exception.value;
@@ -493,7 +487,7 @@ std::unique_ptr<std::string> BaseEndpointChannel::EncodeMessageForTests(
absl::string_view data) {
MutexLock lock(&crypto_mutex_);
DCHECK(IsEncryptionEnabledLocked());
return crypto_context_->EncodeMessageToPeer(std::string(data));
return crypto_context_->EncodeMessageToPeer(data);
}
} // namespace connections
@@ -25,8 +25,8 @@
#include "connections/implementation/analytics/analytics_recorder.h"
#include "connections/implementation/analytics/packet_meta_data.h"
#include "connections/implementation/endpoint_channel.h"
#include "internal/platform/condition_variable.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/condition_variable.h"
#include "internal/platform/exception.h"
#include "internal/platform/input_stream.h"
#include "internal/platform/mutex.h"
@@ -56,7 +56,7 @@ class BaseEndpointChannel : public EndpointChannel {
ABSL_LOCKS_EXCLUDED(reader_mutex_, crypto_mutex_,
last_read_mutex_) override;
Exception Write(const ByteArray& data) override;
Exception Write(const ByteArray& data, PacketMetaData& packet_meta_data)
Exception Write(absl::string_view data, PacketMetaData& packet_meta_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)
@@ -90,6 +90,23 @@ class BaseEndpointChannel : public EndpointChannel {
void SetAnalyticsRecorder(analytics::AnalyticsRecorder* analytics_recorder,
const std::string& endpoint_id) override;
// Reads a complete packet from the underlying medium.
virtual ExceptionOr<ByteArray> DispatchPacket() {
return ExceptionOr<ByteArray>{};
}
// Reads the length of the next incoming data packet from the underlying
// medium.
virtual ExceptionOr<std::int32_t> ReadPayloadLength() {
return ExceptionOr<std::int32_t>{0};
}
// Writes the length of a data packet to the underlying medium before writing
// the packet itself.
virtual Exception WritePayloadLength(int payload_length) {
return {Exception::kFailed};
}
protected:
virtual void CloseImpl() = 0;
// For tests only.
@@ -31,7 +31,9 @@
#include "connections/implementation/client_proxy.h"
#include "connections/implementation/encryption_runner.h"
#include "connections/implementation/endpoint_channel.h"
#include "connections/implementation/flags/nearby_connections_feature_flags.h"
#include "connections/implementation/offline_frames.h"
#include "internal/flags/nearby_flags.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/count_down_latch.h"
#include "internal/platform/exception.h"
@@ -58,6 +60,7 @@ class TestEndpointChannel : public BaseEndpointChannel {
using BaseEndpointChannel::EncodeMessageForTests;
MOCK_METHOD(ExceptionOr<ByteArray>, DispatchPacket, (), (override));
MOCK_METHOD(Medium, GetMedium, (), (const, override));
MOCK_METHOD(void, CloseImpl, (), (override));
};
@@ -77,7 +80,8 @@ std::function<void()> MakeDataPump(
if (monitor) {
monitor(read_response.result());
}
auto write_response = output->Write(read_response.result());
auto write_response =
output->Write(read_response.result().AsStringView());
if (write_response.Raised()) {
LOG(INFO) << "Peer writer closed on '" << label << "'";
input->Close();
@@ -163,13 +167,77 @@ DoDhKeyExchange(BaseEndpointChannel* channel_a,
return std::make_pair(std::move(context_a), std::move(context_b));
}
TEST(BaseEndpointChannelTest, ConstructorDestructorWorks) {
class BaseEndpointChannelTest : public ::testing::Test {
protected:
void TearDown() override {
// Restore any overridden flags after each test to ensure test isolation.
NearbyFlags::GetInstance().ResetOverridedValues();
}
const ByteArray kTestData{"test_data"};
};
TEST_F(BaseEndpointChannelTest, ReadSucceedsWhenFlagDisabled) {
NearbyFlags::GetInstance().OverrideBoolFlagValue(
config_package_nearby::nearby_connections_feature::kRefactorBleL2cap,
false);
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());
channel_a.Write(kTestData);
ByteArray rx_message = std::move(channel_b.Read().result());
EXPECT_EQ(rx_message, kTestData);
}
TEST_F(BaseEndpointChannelTest, ReadCallsDispatchPacketWhenFlagEnabled) {
NearbyFlags::GetInstance().OverrideBoolFlagValue(
config_package_nearby::nearby_connections_feature::kRefactorBleL2cap,
true);
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());
EXPECT_CALL(channel_b, DispatchPacket)
.WillOnce(::testing::Return(ExceptionOr<ByteArray>(kTestData)));
channel_a.Write(kTestData);
auto read_byte = channel_b.Read();
EXPECT_TRUE(read_byte.ok());
EXPECT_EQ(read_byte.result(), kTestData);
}
TEST_F(BaseEndpointChannelTest,
ReadPropagatesFailureFromDispatchPacketWhenFlagEnabled) {
NearbyFlags::GetInstance().OverrideBoolFlagValue(
config_package_nearby::nearby_connections_feature::kRefactorBleL2cap,
true);
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());
EXPECT_CALL(channel_b, DispatchPacket)
.WillOnce(::testing::Return(ExceptionOr<ByteArray>(Exception::kIo)));
auto read_byte = channel_b.Read();
EXPECT_FALSE(read_byte.ok());
EXPECT_EQ(read_byte.GetException().value, Exception::kIo);
}
TEST_F(BaseEndpointChannelTest, ConstructorDestructorWorks) {
auto [input, output] = CreatePipe();
TestEndpointChannel test_channel(input.get(), output.get());
}
TEST(BaseEndpointChannelTest, ReadWrite) {
TEST_F(BaseEndpointChannelTest, ReadWrite) {
// Direct not-encrypted IO.
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.
@@ -181,7 +249,7 @@ TEST(BaseEndpointChannelTest, ReadWrite) {
EXPECT_EQ(rx_message, tx_message);
}
TEST(BaseEndpointChannelTest, ChannelUnencryptedByDefault) {
TEST_F(BaseEndpointChannelTest, ChannelUnencryptedByDefault) {
auto pipe = CreatePipe();
TestEndpointChannel channel(pipe.first.get(), pipe.second.get());
@@ -192,7 +260,7 @@ TEST(BaseEndpointChannelTest, ChannelUnencryptedByDefault) {
EXPECT_EQ(result.exception(), Exception::kFailed);
}
TEST(BaseEndpointChannelTest, TryDecrypt) {
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.
@@ -214,7 +282,7 @@ TEST(BaseEndpointChannelTest, TryDecrypt) {
EXPECT_EQ(decrypted_message.result().AsStringView(), kMessage);
}
TEST(BaseEndpointChannelTest, TryDecryptFailsWhenDecryptionFails) {
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());
@@ -231,7 +299,7 @@ TEST(BaseEndpointChannelTest, TryDecryptFailsWhenDecryptionFails) {
EXPECT_EQ(result.exception(), Exception::kExecution);
}
TEST(BaseEndpointChannelTest, NotEncryptedReadWriteCanBeIntercepted) {
TEST_F(BaseEndpointChannelTest, NotEncryptedReadWriteCanBeIntercepted) {
// Not encrypted IO; MITM scenario.
// Setup test communication environment.
@@ -282,7 +350,7 @@ TEST(BaseEndpointChannelTest, NotEncryptedReadWriteCanBeIntercepted) {
channel_b.Close(DisconnectionReason::REMOTE_DISCONNECTION);
}
TEST(BaseEndpointChannelTest, EncryptedReadWriteCanNotBeIntercepted) {
TEST_F(BaseEndpointChannelTest, EncryptedReadWriteCanNotBeIntercepted) {
// Encrypted IO; MITM scenario.
// Setup test communication environment.
@@ -346,7 +414,7 @@ TEST(BaseEndpointChannelTest, EncryptedReadWriteCanNotBeIntercepted) {
channel_b.Close(DisconnectionReason::REMOTE_DISCONNECTION);
}
TEST(BaseEndpointChannelTest, CanBesuspendedAndResumed) {
TEST_F(BaseEndpointChannelTest, CanBesuspendedAndResumed) {
// 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.
@@ -398,7 +466,7 @@ TEST(BaseEndpointChannelTest, CanBesuspendedAndResumed) {
channel_b.Close(DisconnectionReason::REMOTE_DISCONNECTION);
}
TEST(BaseEndpointChannelTest, ReadAfterInputStreamClosed) {
TEST_F(BaseEndpointChannelTest, ReadAfterInputStreamClosed) {
auto [input, output] = CreatePipe();
TestEndpointChannel test_channel(input.get(), output.get());
@@ -406,14 +474,14 @@ TEST(BaseEndpointChannelTest, ReadAfterInputStreamClosed) {
// Close the output stream before trying to read from the input.
output->Close();
// Trying to read should fail gracefully with an IO error.
// Trying to read should fail gracefully with an kNoData error.
ExceptionOr<ByteArray> read_data = test_channel.Read();
ASSERT_FALSE(read_data.ok());
ASSERT_TRUE(read_data.GetException().Raised(Exception::kIo));
EXPECT_EQ(read_data.exception(), Exception::kNoData);
}
TEST(BaseEndpointChannelTest, ReadUnencryptedFrameOnEncryptedChannel) {
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.
+134 -79
View File
@@ -29,6 +29,7 @@
#include "absl/container/flat_hash_set.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "absl/types/span.h"
@@ -51,6 +52,7 @@
#include "connections/implementation/offline_frames.h"
#include "connections/implementation/pcp.h"
#include "connections/implementation/proto/offline_wire_formats.pb.h"
#include "connections/implementation/webrtc_state.h"
#include "connections/listeners.h"
#include "connections/medium_selector.h"
#include "connections/out_of_band_connection_metadata.h"
@@ -73,6 +75,7 @@
#include "internal/platform/feature_flags.h"
#include "internal/platform/future.h"
#include "internal/platform/implementation/system_clock.h"
#include "internal/platform/implementation/upgrade_address_info.h"
#include "internal/platform/implementation/wifi.h"
#include "internal/platform/logging.h"
#include "internal/platform/mac_address.h"
@@ -83,8 +86,7 @@
#include "internal/platform/wifi_lan_connection_info.h"
#include "proto/connections_enums.pb.h"
namespace nearby {
namespace connections {
namespace nearby::connections {
namespace {
constexpr int kEndpointCancelAlarmTimeout = 10;
@@ -111,6 +113,7 @@ using ::location::nearby::connections::OsInfo;
using ::location::nearby::connections::PresenceDevice;
using ::location::nearby::connections::V1Frame;
using ::location::nearby::proto::connections::OperationResultCode;
using ::location::nearby::proto::connections::WifiDirectAuthType;
using ::securegcm::UKey2Handshake;
BasePcpHandler::BasePcpHandler(Mediums* mediums,
@@ -186,19 +189,30 @@ std::vector<ConnectionInfoVariant> BasePcpHandler::GetConnectionInfoFromResult(
std::vector<ConnectionInfoVariant> connection_infos;
for (const auto& medium : result.mediums) {
if (medium == location::nearby::proto::connections::BLUETOOTH) {
BluetoothConnectionInfo info(
mediums_->GetBluetoothClassic().GetAddress(), "", {});
BluetoothConnectionInfo info(mediums_->GetBluetoothClassic().GetAddress(),
"", {});
connection_infos.push_back(info);
} else if (medium == location::nearby::proto::connections::BLE) {
// TODO(b/284311319): Add relevant information.
BleConnectionInfo info("", "", "", {});
connection_infos.push_back(info);
} else if (medium == location::nearby::proto::connections::WIFI_LAN) {
std::pair<std::string, int> ip_port_pair =
mediums_->GetWifiLan().GetCredentials(std::string(service_id));
api::UpgradeAddressInfo upgrade_candidates =
mediums_->GetWifiLan().GetUpgradeAddressCandidates(
std::string(service_id));
// Only use IPv4 address. IPv4 addresses are always at the end of the
// list.
std::vector<char> ip_address;
int port = 0;
if (!upgrade_candidates.address_candidates.empty()) {
ip_address = upgrade_candidates.address_candidates.back().address;
if (ip_address.size() == 4) {
port = upgrade_candidates.address_candidates.back().port;
}
}
WifiLanConnectionInfo info(
ip_port_pair.first,
absl::StrCat(absl::Hex(ip_port_pair.second, absl::kZeroPad16)), "",
std::string(ip_address.begin(), ip_address.end()),
absl::StrCat(absl::Hex(port, absl::kZeroPad16)), "",
{});
connection_infos.push_back(info);
}
@@ -236,21 +250,8 @@ Status BasePcpHandler::StartAdvertising(
if (compatible_advertising_options.force_new_endpoint_id) {
client->ClearCachedLocalEndpointId();
}
if (NearbyFlags::GetInstance().GetBoolFlag(
connections::config_package_nearby::nearby_connections_feature::
kUseStableEndpointId)) {
if (ShouldEnterStableEndpointIdMode(compatible_advertising_options)) {
client->EnterStableEndpointIdMode();
}
} else {
// The endpoint id inside of the advertisement is different to high
// visibility and low visibility mode. In order to decide if client
// should grab the high visibility or low visibility id, it needs to
// tell client which one right now, before
// client#StartedAdvertising.
if (ShouldEnterHighVisibilityMode(compatible_advertising_options)) {
client->EnterHighVisibilityMode();
}
if (ShouldEnterStableEndpointIdMode(compatible_advertising_options)) {
client->EnterStableEndpointIdMode();
}
if (client->IsDctEnabled()) {
@@ -269,13 +270,7 @@ Status BasePcpHandler::StartAdvertising(
client, service_id, client->GetLocalEndpointId(),
info.endpoint_info, compatible_advertising_options);
if (!result.status.Ok()) {
if (NearbyFlags::GetInstance().GetBoolFlag(
connections::config_package_nearby::
nearby_connections_feature::kUseStableEndpointId)) {
client->ExitStableEndpointIdMode();
} else {
client->ExitHighVisibilityMode();
}
client->ExitStableEndpointIdMode();
response.Set(result.status);
return;
}
@@ -423,6 +418,52 @@ BooleanMediumSelector BasePcpHandler::ComputeIntersectionOfSupportedMediums(
continue;
}
}
if (my_medium ==
location::nearby::proto::connections::Medium::WIFI_DIRECT) {
auto remote_supported_wifi_direct_auth_types =
pending_connection_info.connection_options.connection_info
.supported_wifi_direct_auth_types;
LOG(INFO) << "Remote supported WifiDirect auth types: "
<< absl::StrJoin(
remote_supported_wifi_direct_auth_types, ", ",
[](std::string* out, int auth_type) {
absl::StrAppend(
out,
WifiDirectAuthType_Name(
static_cast<WifiDirectAuthType>(auth_type)));
});
auto local_supported_wifi_direct_auth_types =
mediums_->GetWifiDirect().GetSupportedWifiDirectAuthTypes();
LOG(INFO) << "Local supported WifiDirect auth types: "
<< absl::StrJoin(
local_supported_wifi_direct_auth_types, ", ",
[](std::string* out, int auth_type) {
absl::StrAppend(
out,
WifiDirectAuthType_Name(
static_cast<WifiDirectAuthType>(auth_type)));
});
bool found_common_auth_type = false;
for (const auto& auth_type : local_supported_wifi_direct_auth_types) {
if (auth_type == WifiDirectAuthType::WIFI_DIRECT_TYPE_UNKNOWN) {
continue;
}
if (std::find(remote_supported_wifi_direct_auth_types.begin(),
remote_supported_wifi_direct_auth_types.end(),
auth_type) !=
remote_supported_wifi_direct_auth_types.end()) {
LOG(INFO) << "Found common WifiDirect auth type: "
<< WifiDirectAuthType_Name(auth_type);
mediums_->GetWifiDirect().SetPreferredWifiDirectAuthType(auth_type);
found_common_auth_type = true;
break;
}
}
if (!found_common_auth_type) {
LOG(INFO) << "No common WifiDirect auth type found, skip WifiDirect.";
continue;
}
}
intersection.emplace(my_medium);
}
@@ -640,8 +681,8 @@ void BasePcpHandler::OnEncryptionSuccessRunnableV3(
ProcessPreConnectionInitiationFailure(
pending_connection_info.client, pending_connection_info.medium,
remote_device.GetEndpointId(), pending_connection_info.channel.get(),
pending_connection_info.is_incoming, pending_connection_info.start_time,
{Status::kEndpointIoError},
pending_connection_info.is_incoming, /*log_failure=*/true,
pending_connection_info.start_time, {Status::kEndpointIoError},
OperationResultCode::NEARBY_AUTHENTICATION_FAILURE,
pending_connection_info.result.lock().get());
return;
@@ -702,8 +743,8 @@ void BasePcpHandler::OnEncryptionSuccessRunnable(
ProcessPreConnectionInitiationFailure(
pending_connection_info.client, pending_connection_info.medium,
endpoint_id, pending_connection_info.channel.get(),
pending_connection_info.is_incoming, pending_connection_info.start_time,
{Status::kEndpointIoError},
pending_connection_info.is_incoming, /*log_failure=*/true,
pending_connection_info.start_time, {Status::kEndpointIoError},
OperationResultCode::NEARBY_AUTHENTICATION_FAILURE,
pending_connection_info.result.lock().get());
return;
@@ -787,8 +828,8 @@ void BasePcpHandler::OnEncryptionFailureRunnable(
ProcessPreConnectionInitiationFailure(
pending_connection_info.client, pending_connection_info.medium,
endpoint_id, pending_connection_info.channel.get(),
pending_connection_info.is_incoming, pending_connection_info.start_time,
{Status::kEndpointIoError},
pending_connection_info.is_incoming, /*log_failure=*/true,
pending_connection_info.start_time, {Status::kEndpointIoError},
OperationResultCode::NEARBY_ENCRYPTION_FAILURE,
pending_connection_info.result.lock().get());
}
@@ -807,7 +848,6 @@ ConnectionInfo BasePcpHandler::FillConnectionInfo(
api::WifiInformation& wifi_info = mediums_->GetWifi().GetInformation();
connection_info.bssid = wifi_info.bssid;
connection_info.ap_frequency = wifi_info.ap_frequency;
connection_info.ip_address = wifi_info.ip_address_4_bytes;
if (NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_connections_feature::
kEnableDynamicRoleSwitch) &&
@@ -821,12 +861,21 @@ ConnectionInfo BasePcpHandler::FillConnectionInfo(
LOG(INFO) << "Query for WIFI information: is_supports_5_ghz="
<< connection_info.supports_5_ghz
<< "; bssid=" << connection_info.bssid
<< "; ap_frequency=" << connection_info.ap_frequency
<< "Mhz; ip_address in bytes format="
<< absl::BytesToHexString(connection_info.ip_address);
<< "; ap_frequency=" << connection_info.ap_frequency << "Mhz";
}
connection_info.supported_mediums =
GetSupportedConnectionMediumsByPriority(connection_options);
if (NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_connections_feature::
kEnableWifiDirect)) {
connection_info.supported_wifi_direct_auth_types =
mediums_->GetWifiDirect().GetSupportedWifiDirectAuthTypes();
VLOG(1) << "Set SupportedWifiDirectAuthTypes for WIFI_DIRECT: "
<< absl::StrJoin(connection_info.supported_wifi_direct_auth_types,
",");
} else {
connection_info.supported_wifi_direct_auth_types = {};
}
if (!NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_connections_feature::
@@ -899,7 +948,8 @@ Status BasePcpHandler::RequestConnection(
<< endpoint_id;
ProcessPreConnectionInitiationFailure(
client, channel_medium, endpoint_id, channel.get(),
/* is_incoming = */ false, start_time, connect_impl_result.status,
/*is_incoming=*/false, /*log_failure=*/true, start_time,
connect_impl_result.status,
connect_impl_result.operation_result_code, result.get());
return;
}
@@ -923,7 +973,8 @@ Status BasePcpHandler::RequestConnection(
<< endpoint_id;
ProcessPreConnectionInitiationFailure(
client, channel_medium, endpoint_id, channel.get(),
/* is_incoming = */ false, start_time, {Status::kEndpointIoError},
/*is_incoming=*/false, /*log_failure=*/true, start_time,
{Status::kEndpointIoError},
client->GetAnalyticsRecorder()
.GetChannelIoErrorResultCodeFromMedium(channel_medium),
result.get());
@@ -1043,7 +1094,8 @@ Status BasePcpHandler::RequestConnectionV3(
<< endpoint_id;
ProcessPreConnectionInitiationFailure(
client, channel_medium, endpoint_id, channel.get(),
/* is_incoming = */ false, start_time, connect_impl_result.status,
/*is_incoming=*/false, /*log_failure=*/true, start_time,
connect_impl_result.status,
connect_impl_result.operation_result_code, result.get());
return;
}
@@ -1068,7 +1120,8 @@ Status BasePcpHandler::RequestConnectionV3(
<< endpoint_id;
ProcessPreConnectionInitiationFailure(
client, channel_medium, endpoint_id, channel.get(),
/* is_incoming = */ false, start_time, {Status::kEndpointIoError},
/*is_incoming=*/false, /*log_failure=*/true, start_time,
{Status::kEndpointIoError},
client->GetAnalyticsRecorder()
.GetChannelIoErrorResultCodeFromMedium(channel_medium),
result.get());
@@ -1159,12 +1212,7 @@ void BasePcpHandler::StripOutUnavailableMediums(
allowed.bluetooth = mediums_->GetBluetoothClassic().IsAvailable();
}
if (allowed.ble) {
if (NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_connections_feature::kEnableBleV2)) {
allowed.ble = mediums_->GetBleV2().IsAvailable();
} else {
allowed.ble = mediums_->GetBle().IsAvailable();
}
allowed.ble = mediums_->GetBle().IsAvailable();
}
if (allowed.web_rtc) {
allowed.web_rtc = mediums_->GetWebRtc().IsAvailable();
@@ -1211,12 +1259,7 @@ void BasePcpHandler::StripOutUnavailableMediums(
allowed.bluetooth = mediums_->GetBluetoothClassic().IsAvailable();
}
if (allowed.ble) {
if (NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_connections_feature::kEnableBleV2)) {
allowed.ble = mediums_->GetBleV2().IsAvailable();
} else {
allowed.ble = mediums_->GetBle().IsAvailable();
}
allowed.ble = mediums_->GetBle().IsAvailable();
}
if (allowed.web_rtc) {
allowed.web_rtc = mediums_->GetWebRtc().IsAvailable();
@@ -1378,15 +1421,13 @@ Exception BasePcpHandler::WriteConnectionRequestFrame(
PresenceDevice presence_device_frame;
switch (device_type) {
case NearbyDevice::kConnectionsDevice:
if (connections_device_frame.ParseFromString(
std::string(device_proto_bytes))) { // NOLINT
if (connections_device_frame.ParseFromString(device_proto_bytes)) {
return endpoint_channel->Write(parser::ForConnectionRequestConnections(
connections_device_frame, conection_info));
}
return {Exception::kInvalidProtocolBuffer};
case NearbyDevice::kPresenceDevice:
if (presence_device_frame.ParseFromString(
std::string(device_proto_bytes))) { // NOLINT
if (presence_device_frame.ParseFromString(device_proto_bytes)) {
return endpoint_channel->Write(parser::ForConnectionRequestPresence(
presence_device_frame, conection_info));
}
@@ -1400,9 +1441,9 @@ Exception BasePcpHandler::WriteConnectionRequestFrame(
void BasePcpHandler::ProcessPreConnectionInitiationFailure(
ClientProxy* client, Medium medium, const std::string& endpoint_id,
EndpointChannel* channel, bool is_incoming, absl::Time start_time,
Status status, OperationResultCode operation_result_code,
Future<Status>* result) {
EndpointChannel* channel, bool is_incoming, bool log_failure,
absl::Time start_time, Status status,
OperationResultCode operation_result_code, Future<Status>* result) {
if (channel != nullptr) {
channel->Close();
}
@@ -1412,8 +1453,10 @@ void BasePcpHandler::ProcessPreConnectionInitiationFailure(
result->Set(status);
}
LogConnectionAttemptFailure(client, medium, endpoint_id, is_incoming,
start_time, channel, operation_result_code);
if (log_failure) {
LogConnectionAttemptFailure(client, medium, endpoint_id, is_incoming,
start_time, channel, operation_result_code);
}
// result is hold inside a swapper, and saved in PendingConnectionInfo.
// PendingConnectionInfo destructor will clear the memory of SettableFuture
// shared_ptr for result.
@@ -1916,9 +1959,14 @@ Exception BasePcpHandler::OnIncomingConnection(
<< client->GetClientId() << "; device="
<< absl::BytesToHexString(remote_endpoint_info.data())
<< "with error: " << wrapped_frame.exception();
// Do not log connection failure if no data is received from the channel.
// This prevents logging Wifi connection failure when mDNS client connects
// to test the connection.
ProcessPreConnectionInitiationFailure(
client, medium, /*endpoint_id=*/"", channel.get(),
/*is_incoming=*/true, start_time, {Status::kError},
/*is_incoming=*/true,
/*log_failure=*/wrapped_frame.exception() != Exception::kNoData,
start_time, {Status::kError},
client->GetAnalyticsRecorder().GetChannelIoErrorResultCodeFromMedium(
medium),
nullptr);
@@ -2016,7 +2064,6 @@ Exception BasePcpHandler::OnIncomingConnection(
connection_info.supports_5_ghz = medium_metadata.supports_5_ghz();
connection_info.bssid = medium_metadata.bssid();
connection_info.ap_frequency = medium_metadata.ap_frequency();
connection_info.ip_address = medium_metadata.ip_address();
if (medium_metadata.has_medium_role()) {
connection_info.medium_role.emplace(medium_metadata.medium_role());
}
@@ -2026,9 +2073,7 @@ Exception BasePcpHandler::OnIncomingConnection(
<< "'s WIFI information: is_supports_5_ghz="
<< connection_info.supports_5_ghz << "; bssid=" << connection_info.bssid
<< "; ap_frequency=" << connection_info.ap_frequency
<< "Mhz; ip_address in bytes format="
<< absl::BytesToHexString(connection_info.ip_address)
<< "; support_wifi_direct_group_owner="
<< "Mhz; support_wifi_direct_group_owner="
<< medium_metadata.medium_role().support_wifi_direct_group_owner()
<< "; support_wifi_direct_group_client="
<< medium_metadata.medium_role().support_wifi_direct_group_client()
@@ -2050,9 +2095,21 @@ Exception BasePcpHandler::OnIncomingConnection(
<< connection_info.supports_5_ghz
<< "; bssid=" << connection_info.bssid
<< "; ap_frequency=" << connection_info.ap_frequency
<< "Mhz; ip_address in bytes format="
<< absl::BytesToHexString(connection_info.ip_address)
<< "; has no mediumRole";
<< "Mhz; has no mediumRole";
}
connection_info.supported_wifi_direct_auth_types =
parser::MediumMetadataWFDAuthTypesToWFDAuthTypes(medium_metadata);
if (!connection_info.supported_wifi_direct_auth_types.empty()) {
LOG(INFO) << connection_request.endpoint_id()
<< "'s supported WifiDirect auth types: "
<< absl::StrJoin(
connection_info.supported_wifi_direct_auth_types, ", ",
[](std::string* out, int auth_type) {
absl::StrAppend(
out,
WifiDirectAuthType_Name(
static_cast<WifiDirectAuthType>(auth_type)));
});
}
// We've successfully connected to the device, and are now about to jump on to
@@ -2178,8 +2235,8 @@ void BasePcpHandler::ProcessTieBreakLoss(
ProcessPreConnectionInitiationFailure(
client, pending_connection_info->medium, endpoint_id,
pending_connection_info->channel.get(),
pending_connection_info->is_incoming, pending_connection_info->start_time,
{Status::kEndpointIoError},
pending_connection_info->is_incoming, /*log_failure=*/true,
pending_connection_info->start_time, {Status::kEndpointIoError},
OperationResultCode::CLIENT_PROCESS_TIE_BREAK_LOSS,
pending_connection_info->result.lock().get());
ProcessPreConnectionResultFailure(client, endpoint_id,
@@ -2188,8 +2245,7 @@ void BasePcpHandler::ProcessTieBreakLoss(
}
bool BasePcpHandler::AppendRemoteBluetoothMacAddressEndpoint(
const std::string& endpoint_id,
MacAddress remote_bluetooth_mac_address,
const std::string& endpoint_id, MacAddress remote_bluetooth_mac_address,
const DiscoveryOptions& local_discovery_options) {
if (!local_discovery_options.allowed.bluetooth) {
return false;
@@ -2558,5 +2614,4 @@ void BasePcpHandler::PendingConnectionInfo::LocalEndpointRejectedConnection(
client->LocalEndpointRejectedConnection(endpoint_id);
}
} // namespace connections
} // namespace nearby
} // namespace nearby::connections
+4 -13
View File
@@ -55,7 +55,7 @@
#include "internal/interop/device.h"
#include "internal/interop/device_provider.h"
#include "internal/platform/atomic_boolean.h"
#include "internal/platform/ble_v2.h"
#include "internal/platform/ble.h"
#include "internal/platform/bluetooth_adapter.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/cancelable_alarm.h"
@@ -244,14 +244,6 @@ class BasePcpHandler : public PcpHandler,
BlePeripheral ble_peripheral;
};
struct BleV2Endpoint : public BasePcpHandler::DiscoveredEndpoint {
BleV2Endpoint(DiscoveredEndpoint endpoint, BleV2Peripheral peripheral)
: DiscoveredEndpoint(std::move(endpoint)),
ble_peripheral(std::move(peripheral)) {}
BleV2Peripheral ble_peripheral;
};
struct AwdlEndpoint : public DiscoveredEndpoint {
AwdlEndpoint(DiscoveredEndpoint endpoint,
const NsdServiceInfo& service_info)
@@ -569,8 +561,7 @@ class BasePcpHandler : public PcpHandler,
// address is created and appended into discovered_endpoints_ with key
// endpoint_id.
bool AppendRemoteBluetoothMacAddressEndpoint(
const std::string& endpoint_id,
MacAddress remote_bluetooth_mac_address,
const std::string& endpoint_id, MacAddress remote_bluetooth_mac_address,
const DiscoveryOptions& local_discovery_options)
ABSL_LOCKS_EXCLUDED(discovered_endpoint_mutex_);
@@ -585,8 +576,8 @@ class BasePcpHandler : public PcpHandler,
void ProcessPreConnectionInitiationFailure(
ClientProxy* client, Medium medium, const std::string& endpoint_id,
EndpointChannel* channel, bool is_incoming, absl::Time start_time,
Status status,
EndpointChannel* channel, bool is_incoming, bool log_failure,
absl::Time start_time, Status status,
location::nearby::proto::connections::OperationResultCode
operation_result_code,
Future<Status>* result);
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -14,11 +14,15 @@
#include "connections/implementation/ble_endpoint_channel.h"
#include <memory>
#include <string>
#include <utility>
#include "connections/implementation/base_endpoint_channel.h"
#include "connections/implementation/mediums/ble/ble_socket.h"
#include "internal/platform/ble.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/exception.h"
#include "internal/platform/input_stream.h"
#include "internal/platform/logging.h"
#include "internal/platform/output_stream.h"
@@ -42,6 +46,20 @@ InputStream* GetInputStreamOrNull(BleSocket& socket) {
return nullptr;
}
OutputStream* GetOutputStreamOrNull(mediums::BleSocket* socket) {
if (socket != nullptr && socket->IsValid()) {
return &socket->GetOutputStream();
}
return nullptr;
}
InputStream* GetInputStreamOrNull(mediums::BleSocket* socket) {
if (socket != nullptr && socket->IsValid()) {
return &socket->GetInputStream();
}
return nullptr;
}
} // namespace
BleEndpointChannel::BleEndpointChannel(const std::string& service_id,
@@ -52,6 +70,14 @@ BleEndpointChannel::BleEndpointChannel(const std::string& service_id,
GetOutputStreamOrNull(socket)),
ble_socket_(std::move(socket)) {}
BleEndpointChannel::BleEndpointChannel(
const std::string& service_id, const std::string& channel_name,
std::unique_ptr<mediums::BleSocket> socket)
: BaseEndpointChannel(service_id, channel_name,
GetInputStreamOrNull(socket.get()),
GetOutputStreamOrNull(socket.get())),
ble_socket_2_(std::move(socket)) {}
location::nearby::proto::connections::Medium BleEndpointChannel::GetMedium()
const {
return location::nearby::proto::connections::Medium::BLE;
@@ -62,11 +88,41 @@ int BleEndpointChannel::GetMaxTransmitPacketSize() const {
}
void BleEndpointChannel::CloseImpl() {
auto status = ble_socket_.Close();
if (!status.Ok()) {
LOG(INFO) << "Failed to close underlying socket for BleEndpointChannel "
<< GetName() << ": exception=" << status.value;
if (ble_socket_2_ != nullptr) {
if (!ble_socket_2_->IsValid()) {
LOG(WARNING) << "BleEndpointChannel " << GetName()
<< " is already closed.";
return;
}
Exception status = ble_socket_2_->Close();
if (!status.Ok()) {
LOG(WARNING)
<< "Failed to close underlying socket for BleEndpointChannel "
<< GetName() << ": exception=" << status.value;
}
} else {
if (!ble_socket_.IsValid()) {
LOG(WARNING) << "BleEndpointChannel " << GetName()
<< " is already closed.";
return;
}
Exception status = ble_socket_.Close();
if (!status.Ok()) {
LOG(WARNING)
<< "Failed to close underlying socket for BleEndpointChannel "
<< GetName() << ": exception=" << status.value;
}
}
LOG(INFO) << "BleEndpointChannel " << GetName() << " is already closed.";
}
ExceptionOr<ByteArray> BleEndpointChannel::DispatchPacket() {
return ble_socket_2_->DispatchPacket();
}
Exception BleEndpointChannel::WritePayloadLength(int payload_length) {
return ble_socket_2_->WritePayloadLength(payload_length);
}
} // namespace connections
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2022 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,13 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef CORE_INTERNAL_BLE_ENDPOINT_CHANNEL_H_
#define CORE_INTERNAL_BLE_ENDPOINT_CHANNEL_H_
#ifndef CONNECTIONS_IMPLEMENTATION_BLE_ENDPOINT_CHANNEL_H_
#define CONNECTIONS_IMPLEMENTATION_BLE_ENDPOINT_CHANNEL_H_
#include <memory>
#include <string>
#include "connections/implementation/base_endpoint_channel.h"
#include "connections/implementation/mediums/ble/ble_socket.h"
#include "internal/platform/ble.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/exception.h"
namespace nearby {
namespace connections {
@@ -29,19 +33,28 @@ class BleEndpointChannel final : public BaseEndpointChannel {
BleEndpointChannel(const std::string& service_id,
const std::string& channel_name, BleSocket socket);
// A refactor version of the above constructor.
BleEndpointChannel(const std::string& service_id,
const std::string& channel_name,
std::unique_ptr<mediums::BleSocket> socket);
location::nearby::proto::connections::Medium GetMedium() const override;
int GetMaxTransmitPacketSize() const override;
ExceptionOr<ByteArray> DispatchPacket() override;
Exception WritePayloadLength(int payload_length) override;
private:
static constexpr int kDefaultBleMaxTransmitPacketSize = 512; // 512 bytes
void CloseImpl() override;
BleSocket ble_socket_;
std::unique_ptr<mediums::BleSocket> ble_socket_2_ = nullptr;
};
} // namespace connections
} // namespace nearby
#endif // CORE_INTERNAL_BLE_ENDPOINT_CHANNEL_H_
#endif // CONNECTIONS_IMPLEMENTATION_BLE_ENDPOINT_CHANNEL_H_
@@ -14,15 +14,19 @@
#include "connections/implementation/ble_l2cap_endpoint_channel.h"
#include <cstdint>
#include <memory>
#include <string>
#include <utility>
#include "connections/implementation/base_endpoint_channel.h"
#include "internal/platform/ble_v2.h"
#include "connections/implementation/mediums/ble/ble_socket.h"
#include "internal/platform/ble.h"
#include "internal/platform/exception.h"
#include "internal/platform/input_stream.h"
#include "internal/platform/logging.h"
#include "internal/platform/output_stream.h"
#include "internal/platform/byte_array.h"
namespace nearby {
namespace connections {
@@ -45,6 +49,20 @@ InputStream* GetInputStreamOrNull(BleL2capSocket& socket) {
return nullptr;
}
OutputStream* GetOutputStreamOrNull(mediums::BleSocket* socket) {
if (socket != nullptr && socket->IsValid()) {
return &socket->GetOutputStream();
}
return nullptr;
}
InputStream* GetInputStreamOrNull(mediums::BleSocket* socket) {
if (socket != nullptr && socket->IsValid()) {
return &socket->GetInputStream();
}
return nullptr;
}
} // namespace
BleL2capEndpointChannel::BleL2capEndpointChannel(
@@ -55,6 +73,14 @@ BleL2capEndpointChannel::BleL2capEndpointChannel(
GetOutputStreamOrNull(socket)),
ble_l2cap_socket_(std::move(socket)) {}
BleL2capEndpointChannel::BleL2capEndpointChannel(
const std::string& service_id, const std::string& channel_name,
std::unique_ptr<mediums::BleSocket> socket)
: BaseEndpointChannel(service_id, channel_name,
GetInputStreamOrNull(socket.get()),
GetOutputStreamOrNull(socket.get())),
ble_l2cap_socket_2_(std::move(socket)) {}
location::nearby::proto::connections::Medium
BleL2capEndpointChannel::GetMedium() const {
return location::nearby::proto::connections::Medium::BLE_L2CAP;
@@ -65,12 +91,45 @@ int BleL2capEndpointChannel::GetMaxTransmitPacketSize() const {
}
void BleL2capEndpointChannel::CloseImpl() {
Exception status = ble_l2cap_socket_.Close();
if (!status.Ok()) {
LOG(WARNING)
<< "Failed to close underlying socket for BleL2capEndpointChannel "
<< GetName() << ": exception=" << status.value;
if (ble_l2cap_socket_2_ != nullptr) {
if (!ble_l2cap_socket_2_->IsValid()) {
LOG(WARNING) << "BleL2capEndpointChannel " << GetName()
<< " is already closed.";
return;
}
Exception status = ble_l2cap_socket_2_->Close();
if (!status.Ok()) {
LOG(WARNING)
<< "Failed to close underlying socket for BleL2capEndpointChannel "
<< GetName() << ": exception=" << status.value;
}
} else {
if (!ble_l2cap_socket_.IsValid()) {
LOG(WARNING) << "BleL2capEndpointChannel " << GetName()
<< " is already closed.";
return;
}
Exception status = ble_l2cap_socket_.Close();
if (!status.Ok()) {
LOG(WARNING)
<< "Failed to close underlying socket for BleL2capEndpointChannel "
<< GetName() << ": exception=" << status.value;
}
}
LOG(INFO) << "BleL2capEndpointChannel " << GetName() << " is already closed.";
}
ExceptionOr<ByteArray> BleL2capEndpointChannel::DispatchPacket() {
return ble_l2cap_socket_2_->DispatchPacket();
}
ExceptionOr<std::int32_t> BleL2capEndpointChannel::ReadPayloadLength() {
return ble_l2cap_socket_2_->ReadPayloadLength();
}
Exception BleL2capEndpointChannel::WritePayloadLength(int payload_length) {
return ble_l2cap_socket_2_->WritePayloadLength(payload_length);
}
} // namespace connections
@@ -15,10 +15,15 @@
#ifndef CORE_INTERNAL_BLE_L2CAP_ENDPOINT_CHANNEL_H_
#define CORE_INTERNAL_BLE_L2CAP_ENDPOINT_CHANNEL_H_
#include <cstdint>
#include <memory>
#include <string>
#include "connections/implementation/base_endpoint_channel.h"
#include "internal/platform/ble_v2.h"
#include "connections/implementation/mediums/ble/ble_socket.h"
#include "internal/platform/ble.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/exception.h"
namespace nearby {
namespace connections {
@@ -30,16 +35,26 @@ class BleL2capEndpointChannel final : public BaseEndpointChannel {
const std::string& channel_name,
BleL2capSocket socket);
// A refactor version of the above constructor.
BleL2capEndpointChannel(const std::string& service_id,
const std::string& channel_name,
std::unique_ptr<mediums::BleSocket> socket);
// Returns the medium of this endpoint channel.
location::nearby::proto::connections::Medium GetMedium() const override;
// Returns the maximum transmit packet size of this endpoint channel.
int GetMaxTransmitPacketSize() const override;
ExceptionOr<ByteArray> DispatchPacket() override;
ExceptionOr<std::int32_t> ReadPayloadLength() override;
Exception WritePayloadLength(int payload_length) override;
private:
void CloseImpl() override;
BleL2capSocket ble_l2cap_socket_;
std::unique_ptr<mediums::BleSocket> ble_l2cap_socket_2_ = nullptr;
};
} // namespace connections
@@ -1,74 +0,0 @@
// Copyright 2022 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/ble_v2_endpoint_channel.h"
#include <string>
#include <utility>
#include "connections/implementation/base_endpoint_channel.h"
#include "internal/platform/ble_v2.h"
#include "internal/platform/exception.h"
#include "internal/platform/input_stream.h"
#include "internal/platform/logging.h"
#include "internal/platform/output_stream.h"
namespace nearby {
namespace connections {
namespace {
OutputStream* GetOutputStreamOrNull(BleV2Socket& socket) {
if (socket.IsValid()) {
return &socket.GetOutputStream();
}
return nullptr;
}
InputStream* GetInputStreamOrNull(BleV2Socket& socket) {
if (socket.IsValid()) {
return &socket.GetInputStream();
}
return nullptr;
}
} // namespace
BleV2EndpointChannel::BleV2EndpointChannel(const std::string& service_id,
const std::string& channel_name,
BleV2Socket socket)
: BaseEndpointChannel(service_id, channel_name,
GetInputStreamOrNull(socket),
GetOutputStreamOrNull(socket)),
ble_socket_(std::move(socket)) {}
location::nearby::proto::connections::Medium BleV2EndpointChannel::GetMedium()
const {
return location::nearby::proto::connections::Medium::BLE;
}
int BleV2EndpointChannel::GetMaxTransmitPacketSize() const {
return kDefaultBleMaxTransmitPacketSize;
}
void BleV2EndpointChannel::CloseImpl() {
Exception status = ble_socket_.Close();
if (!status.Ok()) {
LOG(WARNING) << "Failed to close underlying socket for BleEndpointChannel "
<< GetName() << ": exception=" << status.value;
}
}
} // namespace connections
} // namespace nearby
@@ -1,47 +0,0 @@
// Copyright 2022 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_BLE_V2_ENDPOINT_CHANNEL_H_
#define CONNECTIONS_IMPLEMENTATION_BLE_V2_ENDPOINT_CHANNEL_H_
#include <string>
#include "connections/implementation/base_endpoint_channel.h"
#include "internal/platform/ble_v2.h"
namespace nearby {
namespace connections {
class BleV2EndpointChannel final : public BaseEndpointChannel {
public:
// Creates both outgoing and incoming Ble channels.
BleV2EndpointChannel(const std::string& service_id,
const std::string& channel_name, BleV2Socket socket);
location::nearby::proto::connections::Medium GetMedium() const override;
int GetMaxTransmitPacketSize() const override;
private:
static constexpr int kDefaultBleMaxTransmitPacketSize = 512; // 512 bytes
void CloseImpl() override;
BleV2Socket ble_socket_;
};
} // namespace connections
} // namespace nearby
#endif // CONNECTIONS_IMPLEMENTATION_BLE_V2_ENDPOINT_CHANNEL_H_
@@ -39,6 +39,7 @@ namespace nearby {
namespace connections {
namespace {
using ::location::nearby::connections::BandwidthUpgradeNegotiationFrame;
using ::location::nearby::proto::connections::OperationResultCode;
} // namespace
@@ -53,9 +54,11 @@ BluetoothBwuHandler::BluetoothBwuHandler(
ErrorOr<std::unique_ptr<EndpointChannel>>
BluetoothBwuHandler::CreateUpgradedEndpointChannel(
ClientProxy* client, const std::string& service_id,
const std::string& endpoint_id, const UpgradePathInfo& upgrade_path_info) {
const UpgradePathInfo::BluetoothCredentials& bluetooth_credentials =
upgrade_path_info.bluetooth_credentials();
const std::string& endpoint_id,
const BandwidthUpgradeNegotiationFrame::UpgradePathInfo&
upgrade_path_info) {
const BandwidthUpgradeNegotiationFrame::UpgradePathInfo::BluetoothCredentials&
bluetooth_credentials = upgrade_path_info.bluetooth_credentials();
if (!bluetooth_credentials.has_service_name() ||
!bluetooth_credentials.has_mac_address()) {
LOG(ERROR) << "BluetoothBwuHandler failed to parse UpgradePathInfo.";
@@ -17,7 +17,6 @@
#include <memory>
#include <string>
#include <utility>
#include "connections/implementation/base_bwu_handler.h"
#include "connections/implementation/client_proxy.h"
@@ -57,11 +56,11 @@ class BluetoothBwuHandler : public BaseBwuHandler {
};
// BwuHandler implementation:
ErrorOr<std::unique_ptr<EndpointChannel>>
CreateUpgradedEndpointChannel(ClientProxy* client,
const std::string& service_id,
const std::string& endpoint_id,
const UpgradePathInfo& upgrade_path_info) final;
ErrorOr<std::unique_ptr<EndpointChannel>> CreateUpgradedEndpointChannel(
ClientProxy* client, const std::string& service_id,
const std::string& endpoint_id,
const location::nearby::connections::BandwidthUpgradeNegotiationFrame::
UpgradePathInfo& upgrade_path_info) final;
Medium GetUpgradeMedium() const final { return Medium::BLUETOOTH; }
void OnEndpointDisconnect(ClientProxy* client,
const std::string& endpoint_id) final {}
+5 -10
View File
@@ -21,22 +21,16 @@
#include "absl/functional/any_invocable.h"
#include "connections/implementation/client_proxy.h"
#include "connections/implementation/endpoint_channel.h"
#include "connections/implementation/offline_frames.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/expected.h"
namespace nearby {
namespace connections {
using BwuNegotiationFrame =
location::nearby::connections::BandwidthUpgradeNegotiationFrame;
// Defines the set of methods that need to be implemented to handle the
// per-Medium-specific operations needed to upgrade an EndpointChannel.
class BwuHandler {
public:
using UpgradePathInfo = parser::UpgradePathInfo;
class IncomingSocket {
public:
virtual ~IncomingSocket() = default;
@@ -83,10 +77,11 @@ class BwuHandler {
// Initiator, and returns a new EndpointChannel for the upgraded medium.
// @BwuHandlerThread
virtual ErrorOr<std::unique_ptr<EndpointChannel>>
CreateUpgradedEndpointChannel(ClientProxy* client,
const std::string& service_id,
const std::string& endpoint_id,
const UpgradePathInfo& upgrade_path_info) = 0;
CreateUpgradedEndpointChannel(
ClientProxy* client, const std::string& service_id,
const std::string& endpoint_id,
const location::nearby::connections::BandwidthUpgradeNegotiationFrame::
UpgradePathInfo& upgrade_path_info) = 0;
// Returns the upgrade medium of the BwuHandler.
// @BwuHandlerThread
+38 -33
View File
@@ -105,7 +105,11 @@ BwuManager::BwuManager(
}
if (config_.allow_upgrade_to.All(false)) {
config_.allow_upgrade_to.web_rtc = true;
config_.allow_upgrade_to.wifi_direct = true;
if (NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_connections_feature::
kEnableWifiDirect)) {
config_.allow_upgrade_to.wifi_direct = true;
}
config_.allow_upgrade_to.wifi_lan = true;
config_.allow_upgrade_to.wifi_hotspot = true;
if (NearbyFlags::GetInstance().GetBoolFlag(
@@ -352,7 +356,7 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client,
proposed_medium)
<< " because it failed to initialize the "
"BWU_NEGOTIATION.UPGRADE_PATH_AVAILABLE OfflineFrame.";
UpgradePathInfo info;
BandwidthUpgradeNegotiationFrame::UpgradePathInfo info;
info.set_medium(parser::MediumToUpgradePathInfoMedium(proposed_medium));
ProcessUpgradeFailureEvent(
@@ -373,7 +377,7 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client,
proposed_medium)
<< " because it failed to write the "
"BWU_NEGOTIATION.UPGRADE_PATH_AVAILABLE OfflineFrame.";
UpgradePathInfo info;
BandwidthUpgradeNegotiationFrame::UpgradePathInfo info;
info.set_medium(parser::MediumToUpgradePathInfoMedium(proposed_medium));
ProcessUpgradeFailureEvent(
@@ -547,11 +551,12 @@ BwuHandler* BwuManager::GetHandlerForMedium(Medium medium) const {
return it->second.get();
}
void BwuManager::OnBwuNegotiationFrame(ClientProxy* client,
const BwuNegotiationFrame frame,
const std::string& endpoint_id) {
void BwuManager::OnBwuNegotiationFrame(
ClientProxy* client, const BandwidthUpgradeNegotiationFrame frame,
const std::string& endpoint_id) {
LOG(INFO) << "OnBwuNegotiationFrame: processing incoming "
<< BwuNegotiationFrame::EventType_Name(frame.event_type())
<< BandwidthUpgradeNegotiationFrame::EventType_Name(
frame.event_type())
<< " frame for endpoint " << endpoint_id;
if (!client->IsConnectedToEndpoint(endpoint_id)) {
@@ -564,28 +569,29 @@ void BwuManager::OnBwuNegotiationFrame(ClientProxy* client,
// advertise side already get, discover side should inform advertise side
// the upgrade failed, so the advertise side could have chance to initialize
// another upgrade flow again.
if (frame.event_type() == BwuNegotiationFrame::UPGRADE_PATH_AVAILABLE) {
if (frame.event_type() ==
BandwidthUpgradeNegotiationFrame::UPGRADE_PATH_AVAILABLE) {
RunUpgradeFailedProtocol(client, endpoint_id, frame.upgrade_path_info());
}
return;
}
switch (frame.event_type()) {
case BwuNegotiationFrame::UPGRADE_PATH_AVAILABLE:
case BandwidthUpgradeNegotiationFrame::UPGRADE_PATH_AVAILABLE:
ProcessBwuPathAvailableEvent(client, endpoint_id,
frame.upgrade_path_info());
break;
case BwuNegotiationFrame::UPGRADE_FAILURE:
case BandwidthUpgradeNegotiationFrame::UPGRADE_FAILURE:
ProcessUpgradeFailureEvent(
client, endpoint_id, frame.upgrade_path_info(),
BandwidthUpgradeResult::REMOTE_CONNECTION_ERROR,
/* record_analytic= */ true,
OperationResultCode::NEARBY_GENERIC_REMOTE_UPGRADE_FAILURE);
break;
case BwuNegotiationFrame::LAST_WRITE_TO_PRIOR_CHANNEL:
case BandwidthUpgradeNegotiationFrame::LAST_WRITE_TO_PRIOR_CHANNEL:
ProcessLastWriteToPriorChannelEvent(client, endpoint_id);
break;
case BwuNegotiationFrame::SAFE_TO_CLOSE_PRIOR_CHANNEL:
case BandwidthUpgradeNegotiationFrame::SAFE_TO_CLOSE_PRIOR_CHANNEL:
ProcessSafeToClosePriorChannelEvent(client, endpoint_id);
break;
default:
@@ -623,7 +629,7 @@ void BwuManager::OnIncomingConnection(
VLOG(1) << "BwuManager successfully created new EndpointChannel for "
"incoming socket";
ClientIntroduction introduction;
BandwidthUpgradeNegotiationFrame::ClientIntroduction introduction;
if (!ReadClientIntroductionFrame(channel, introduction)) {
// This was never a fully EstablishedConnection, no need to provide a
// closure reason.
@@ -776,7 +782,8 @@ void BwuManager::RunUpgradeProtocol(
// Outgoing BWU session.
void BwuManager::ProcessBwuPathAvailableEvent(
ClientProxy* client, const std::string& endpoint_id,
const UpgradePathInfo& upgrade_path_info) {
const BandwidthUpgradeNegotiationFrame::UpgradePathInfo&
upgrade_path_info) {
Medium upgrade_medium =
parser::UpgradePathInfoMediumToMedium(upgrade_path_info.medium());
LOG(INFO) << "ProcessBwuPathAvailableEvent for endpoint " << endpoint_id
@@ -925,7 +932,8 @@ void BwuManager::ProcessBwuPathAvailableEvent(
ErrorOr<std::unique_ptr<EndpointChannel>>
BwuManager::ProcessBwuPathAvailableEventInternal(
ClientProxy* client, const std::string& endpoint_id,
const UpgradePathInfo& upgrade_path_info) {
const BandwidthUpgradeNegotiationFrame::UpgradePathInfo&
upgrade_path_info) {
Medium medium =
parser::UpgradePathInfoMediumToMedium(upgrade_path_info.medium());
if (medium != GetBwuMediumForEndpoint(endpoint_id)) {
@@ -970,8 +978,6 @@ BwuManager::ProcessBwuPathAvailableEventInternal(
old_medium = old_channel->GetMedium();
}
bool enable_ble_v2 = NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_connections_feature::kEnableBleV2);
if (NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_connections_feature::
kEnableStopBleScanningOnWifiUpgrade)) {
@@ -979,13 +985,11 @@ BwuManager::ProcessBwuPathAvailableEventInternal(
location::nearby::connections::OsInfo::APPLE &&
old_medium == Medium::BLE && medium == Medium::WIFI_HOTSPOT) {
disable_ble_scanning = true;
if (enable_ble_v2) {
LOG(INFO) << "For Apple OS, if upgrade from BLE_V2 to WIFI_HOTSPOT, "
"we need to pause "
"BLE_V2 scanning because it can interfere with WIFI "
"Hotspot scanning and connection.";
ble_v2_medium_.PauseMediumScanning();
}
LOG(INFO) << "For Apple OS, if upgrade from BLE to WIFI_HOTSPOT, "
"we need to pause "
"BLE scanning because it can interfere with WIFI "
"Hotspot scanning and connection.";
ble_medium_.PauseMediumScanning();
}
}
@@ -997,10 +1001,8 @@ BwuManager::ProcessBwuPathAvailableEventInternal(
config_package_nearby::nearby_connections_feature::
kEnableStopBleScanningOnWifiUpgrade)) {
if (disable_ble_scanning) {
if (enable_ble_v2) {
LOG(INFO) << "Resume BLE_V2 scanning.";
ble_v2_medium_.ResumeMediumScanning();
}
LOG(INFO) << "Resume BLE scanning.";
ble_medium_.ResumeMediumScanning();
}
}
@@ -1070,7 +1072,8 @@ BwuManager::ProcessBwuPathAvailableEventInternal(
void BwuManager::RunUpgradeFailedProtocol(
ClientProxy* client, const std::string& endpoint_id,
const UpgradePathInfo& upgrade_path_info) {
const BandwidthUpgradeNegotiationFrame::UpgradePathInfo&
upgrade_path_info) {
LOG(INFO) << "RunUpgradeFailedProtocol for endpoint " << endpoint_id
<< " medium "
<< location::nearby::proto::connections::Medium_Name(
@@ -1117,8 +1120,9 @@ void BwuManager::RunUpgradeFailedProtocol(
<< " that the bandwidth upgrade failed.";
}
bool BwuManager::ReadClientIntroductionFrame(EndpointChannel* channel,
ClientIntroduction& introduction) {
bool BwuManager::ReadClientIntroductionFrame(
EndpointChannel* channel,
BandwidthUpgradeNegotiationFrame::ClientIntroduction& introduction) {
LOG(INFO) << "ReadClientIntroductionFrame with channel name: "
<< channel->GetName() << ", medium: "
<< location::nearby::proto::connections::Medium_Name(
@@ -1352,8 +1356,9 @@ void BwuManager::ProcessSafeToClosePriorChannelEvent(
void BwuManager::ProcessUpgradeFailureEvent(
ClientProxy* client, const std::string& endpoint_id,
const UpgradePathInfo& upgrade_info, BandwidthUpgradeResult result,
bool record_analytic, OperationResultCode operation_result_code) {
const BandwidthUpgradeNegotiationFrame::UpgradePathInfo& upgrade_info,
BandwidthUpgradeResult result, bool record_analytic,
OperationResultCode operation_result_code) {
LOG(INFO) << "ProcessUpgradeFailureEvent for endpoint " << endpoint_id
<< " from medium: "
<< location::nearby::proto::connections::Medium_Name(
+27 -20
View File
@@ -28,7 +28,7 @@
#include "connections/implementation/endpoint_channel.h"
#include "connections/implementation/endpoint_channel_manager.h"
#include "connections/implementation/endpoint_manager.h"
#include "connections/implementation/mediums/ble_v2.h"
#include "connections/implementation/mediums/ble.h"
#include "connections/implementation/mediums/mediums.h"
#include "connections/medium_selector.h"
#include "internal/platform/cancelable_alarm.h"
@@ -66,8 +66,6 @@ namespace connections {
// other, and upon doing so, close the prior EndpointChannel.
class BwuManager : public EndpointManager::FrameProcessor {
public:
using UpgradePathInfo = BwuHandler::UpgradePathInfo;
struct Config {
BooleanMediumSelector allow_upgrade_to;
absl::Duration bandwidth_upgrade_retry_delay;
@@ -139,13 +137,16 @@ class BwuManager : public EndpointManager::FrameProcessor {
const std::vector<Medium>& mediums) const;
// BaseBwuHandler
using ClientIntroduction = BwuNegotiationFrame::ClientIntroduction;
// Processes the BwuNegotiationFrames that come over the EndpointChannel on
// both initiator and responder side of the upgrade.
void OnBwuNegotiationFrame(ClientProxy* client,
const BwuNegotiationFrame frame,
const string& endpoint_id);
// Processes the
// location::nearby::connections::BandwidthUpgradeNegotiationFrames that come
// over the EndpointChannel on both initiator and responder side of the
// upgrade.
void OnBwuNegotiationFrame(
ClientProxy* client,
const location::nearby::connections::BandwidthUpgradeNegotiationFrame
frame,
const string& endpoint_id);
// Called to revert any state changed in the course of setting up the upgraded
// medium for an endpoint.
@@ -170,22 +171,27 @@ class BwuManager : public EndpointManager::FrameProcessor {
void RunUpgradeProtocol(ClientProxy* client, const std::string& endpoint_id,
std::unique_ptr<EndpointChannel> new_channel,
bool enable_encryption);
void RunUpgradeFailedProtocol(ClientProxy* client,
const std::string& endpoint_id,
const UpgradePathInfo& upgrade_path_info);
void ProcessBwuPathAvailableEvent(ClientProxy* client,
const std::string& endpoint_id,
const UpgradePathInfo& upgrade_path_info);
void RunUpgradeFailedProtocol(
ClientProxy* client, const std::string& endpoint_id,
const location::nearby::connections::BandwidthUpgradeNegotiationFrame::
UpgradePathInfo& upgrade_path_info);
void ProcessBwuPathAvailableEvent(
ClientProxy* client, const std::string& endpoint_id,
const location::nearby::connections::BandwidthUpgradeNegotiationFrame::
UpgradePathInfo& upgrade_path_info);
ErrorOr<std::unique_ptr<EndpointChannel>>
ProcessBwuPathAvailableEventInternal(
ClientProxy* client, const std::string& endpoint_id,
const UpgradePathInfo& upgrade_path_info);
const location::nearby::connections::BandwidthUpgradeNegotiationFrame::
UpgradePathInfo& upgrade_path_info);
void ProcessLastWriteToPriorChannelEvent(ClientProxy* client,
const std::string& endpoint_id);
void ProcessSafeToClosePriorChannelEvent(ClientProxy* client,
const std::string& endpoint_id);
bool ReadClientIntroductionFrame(EndpointChannel* endpoint_channel,
ClientIntroduction& introduction);
bool ReadClientIntroductionFrame(
EndpointChannel* endpoint_channel,
location::nearby::connections::BandwidthUpgradeNegotiationFrame::
ClientIntroduction& introduction);
bool ReadClientIntroductionAckFrame(EndpointChannel* endpoint_channel);
bool WriteClientIntroductionAckFrame(EndpointChannel* endpoint_channel);
void ProcessEndpointDisconnection(ClientProxy* client,
@@ -193,7 +199,8 @@ class BwuManager : public EndpointManager::FrameProcessor {
CountDownLatch* barrier);
void ProcessUpgradeFailureEvent(
ClientProxy* client, const std::string& endpoint_id,
const UpgradePathInfo& upgrade_info,
const location::nearby::connections::BandwidthUpgradeNegotiationFrame::
UpgradePathInfo& upgrade_info,
location::nearby::proto::connections::BandwidthUpgradeResult result,
bool record_analytic,
location::nearby::proto::connections::OperationResultCode
@@ -234,7 +241,7 @@ class BwuManager : public EndpointManager::FrameProcessor {
Mediums* mediums_;
absl::flat_hash_map<Medium, std::unique_ptr<BwuHandler>> handlers_;
BleV2& ble_v2_medium_{mediums_->GetBleV2()};
Ble& ble_medium_{mediums_->GetBle()};
EndpointManager* endpoint_manager_;
EndpointChannelManager* channel_manager_;
+48 -19
View File
@@ -19,8 +19,10 @@
#include <utility>
#include "gtest/gtest.h"
#include "absl/container/flat_hash_map.h"
#include "absl/strings/string_view.h"
#include "connections/connection_options.h"
#include "connections/implementation/bwu_handler.h"
#include "connections/implementation/client_proxy.h"
#include "connections/implementation/endpoint_channel.h"
#include "connections/implementation/endpoint_channel_manager.h"
@@ -32,10 +34,13 @@
#include "connections/implementation/offline_frames.h"
#include "connections/implementation/service_id_constants.h"
#include "connections/listeners.h"
#include "connections/medium_selector.h"
#include "internal/flags/nearby_flags.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/count_down_latch.h"
#include "internal/platform/exception.h"
#include "internal/platform/feature_flags.h"
#include "internal/platform/service_address.h"
#include "internal/proto/analytics/connections_log.pb.h"
#include "proto/connections_enums.pb.h"
@@ -44,8 +49,6 @@ namespace connections {
namespace {
using ::location::nearby::analytics::proto::ConnectionsLog;
using ::location::nearby::connections::BandwidthUpgradeNegotiationFrame;
using ::location::nearby::connections::
BandwidthUpgradeNegotiationFrame_UpgradePathInfo;
using ::location::nearby::connections::MediumRole;
using ::location::nearby::connections::OfflineFrame;
using ::location::nearby::connections::OsInfo;
@@ -60,9 +63,31 @@ constexpr absl::string_view kEndpointId3 = "Endpoint3";
constexpr absl::string_view kEndpointId4 = "Endpoint4";
constexpr absl::string_view kEndpointId5 = "Endpoint5";
BandwidthUpgradeNegotiationFrame::UpgradePathInfo::WifiHotspotCredentials
CreateWifiHotspotCredentials() {
BandwidthUpgradeNegotiationFrame::UpgradePathInfo::WifiHotspotCredentials
credentials;
credentials.set_ssid("Direct-357a2d8c");
credentials.set_password("b592f7d3");
credentials.set_port(1234);
credentials.set_frequency(2412);
credentials.set_gateway("123.234.23.1");
auto* candidate = credentials.mutable_address_candidates()->Add();
candidate->set_ip_address(std::string(
"\xfe\x80\\x00\x00\x00\x00\x00\x00\x4d\xb2\xb3\x5c\x22\x03\x98\xa1", 16));
candidate->set_port(1234);
candidate = credentials.mutable_address_candidates()->Add();
candidate->set_ip_address("\x7b\xea\x17\x01");
candidate->set_port(2412);
return credentials;
}
class BwuManagerTest : public ::testing::Test {
protected:
BwuManagerTest() {
NearbyFlags::GetInstance().OverrideBoolFlagValue(
config_package_nearby::nearby_connections_feature::kEnableWifiDirect,
true);
// Set up fake BWU handlers for WebRTC and WifiLAN.
absl::flat_hash_map<Medium, std::unique_ptr<BwuHandler>> handlers;
auto fake_web_rtc = std::make_unique<FakeBwuHandler>(Medium::WEB_RTC);
@@ -181,6 +206,9 @@ class BwuManagerTest : public ::testing::Test {
};
TEST(BwuManagerBaseTest, AllowToUpgradeMedium) {
NearbyFlags::GetInstance().OverrideBoolFlagValue(
config_package_nearby::nearby_connections_feature::kEnableWifiDirect,
true);
ClientProxy client;
EndpointChannelManager ecm;
EndpointManager em(&ecm);
@@ -833,8 +861,8 @@ TEST_F(BwuManagerTest, InitiateBwu_Revert_OnUpgradeFailure_FlagEnabled) {
/*initialize_call_index=*/2u, bwu_manager_.get());
// This upgrade fails.
BwuHandler::UpgradePathInfo info;
info.set_medium(BwuHandler::UpgradePathInfo::WEB_RTC);
BandwidthUpgradeNegotiationFrame::UpgradePathInfo info;
info.set_medium(BandwidthUpgradeNegotiationFrame::UpgradePathInfo::WEB_RTC);
ExceptionOr<OfflineFrame> upgrade_failure =
parser::FromBytes(parser::ForBwuFailure(info));
bwu_manager_->OnIncomingFrame(upgrade_failure.result(),
@@ -871,8 +899,8 @@ TEST_F(BwuManagerTest, InitiateBwu_Revert_OnUpgradeFailure_FlagDisabled) {
/*initialize_call_index=*/2u, bwu_manager_.get());
// This upgrade fails.
BwuHandler::UpgradePathInfo info;
info.set_medium(BwuHandler::UpgradePathInfo::WEB_RTC);
BandwidthUpgradeNegotiationFrame::UpgradePathInfo info;
info.set_medium(BandwidthUpgradeNegotiationFrame::UpgradePathInfo::WEB_RTC);
ExceptionOr<OfflineFrame> upgrade_failure =
parser::FromBytes(parser::ForBwuFailure(info));
bwu_manager_->OnIncomingFrame(upgrade_failure.result(),
@@ -894,15 +922,16 @@ TEST_F(BwuManagerTest, InitiateBwu_Revert_OnDisconnect_WifiDirect) {
CreateInitialEndpoint(&client_, kServiceIdA, kEndpointId1, Medium::BLUETOOTH);
ByteArray bytes = parser::ForBwuWifiDirectPathAvailable(
/*ssid=*/"Direct-12345678", /*password=*/"87654321", /*port=*/2143,
/*ssid=*/"", /*password=*/"", /*port=*/2143,
/*frequency=*/2412, /*supports_disabling_encryption=*/false,
/*gateway=*/"123.234.23.1");
/*gateway=*/"123.234.23.1", /*service_name=*/"NC-WifiDirectTest",
/*pin=*/"b592f7d3");
frame.ParseFromString(std::string(bytes));
::nearby::connections::V1Frame* v1_frame = frame.mutable_v1();
::nearby::connections::BandwidthUpgradeNegotiationFrame* sub_frame =
v1_frame->mutable_bandwidth_upgrade_negotiation();
::nearby::connections::BandwidthUpgradeNegotiationFrame_UpgradePathInfo*
BandwidthUpgradeNegotiationFrame::UpgradePathInfo*
upgrade_path_info = sub_frame->mutable_upgrade_path_info();
upgrade_path_info->set_supports_client_introduction_ack(false);
bwu_manager_->OnIncomingFrame(frame, std::string(kEndpointId1), &client_,
@@ -928,9 +957,9 @@ TEST_F(BwuManagerTest, InitiateBwu_Revert_OnDisconnect_Hotspot) {
ExceptionOr<OfflineFrame> hotspot_path_available_frame =
parser::FromBytes(parser::ForBwuWifiHotspotPathAvailable(
/*ssid=*/"Direct-357a2d8c", /*password=*/"b592f7d3",
/*port=*/1234, /*frequency=*/2412, /*gateway=*/"123.234.23.1",
false));
CreateWifiHotspotCredentials(),
/*supports_disabling_encryption=*/false));
ASSERT_TRUE(hotspot_path_available_frame.ok());
OfflineFrame frame = hotspot_path_available_frame.result();
frame.set_version(OfflineFrame::V1);
auto* v1_frame = frame.mutable_v1();
@@ -956,9 +985,9 @@ TEST_F(BwuManagerTest, InitiateBwu_Revert_OnDisconnect_Wlan) {
CreateInitialEndpoint(&client_, kServiceIdA, kEndpointId1, Medium::BLUETOOTH);
ExceptionOr<OfflineFrame> wlan_path_available_frame = parser::FromBytes(
parser::ForBwuWifiLanPathAvailable(/*ip_address=*/"ABCD",
/*port=*/1234));
ExceptionOr<OfflineFrame> wlan_path_available_frame =
parser::FromBytes(parser::ForBwuWifiLanPathAvailable(
{ServiceAddress{.address = {'A', 'B', 'C', 'D'}, .port = 1234}}));
OfflineFrame frame = wlan_path_available_frame.result();
frame.set_version(OfflineFrame::V1);
auto* v1_frame = frame.mutable_v1();
@@ -995,8 +1024,8 @@ TEST_F(BwuManagerTest, BlockBwuFrameBeforeAccept) {
ExceptionOr<OfflineFrame> hotspot_path_available_frame2 =
parser::FromBytes(parser::ForBwuWifiHotspotPathAvailable(
/*ssid=*/"Direct-357a2d8c", /*password=*/"b592f7d3",
/*port=*/1234, /*frequency=*/2412, /*gateway=*/"123.234.23.1", true));
CreateWifiHotspotCredentials(),
/*supports_disabling_encryption=*/true));
OfflineFrame frame2 = hotspot_path_available_frame2.result();
frame2.set_version(OfflineFrame::V1);
auto* v1_frame2 = frame2.mutable_v1();
@@ -1018,8 +1047,8 @@ TEST_F(BwuManagerTest, BlockBwuFrameBeforeAccept) {
TEST_F(BwuManagerTest, BlockBwuFrameFromAdvertiser) {
ExceptionOr<OfflineFrame> hotspot_path_available_frame =
parser::FromBytes(parser::ForBwuWifiHotspotPathAvailable(
/*ssid=*/"Direct-357a2d8c", /*password=*/"b592f7d3",
/*port=*/1234, /*frequency=*/2412, /*gateway=*/"123.234.23.1", true));
CreateWifiHotspotCredentials(),
/*supports_disabling_encryption=*/true));
OfflineFrame frame = hotspot_path_available_frame.result();
frame.set_version(OfflineFrame::V1);
auto* v1_frame = frame.mutable_v1();
+137 -91
View File
@@ -31,6 +31,7 @@
#include "absl/random/random.h"
#include "absl/strings/escaping.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "absl/types/span.h"
#include "connections/advertising_options.h"
#include "connections/connection_options.h"
@@ -52,15 +53,20 @@
#include "connections/v3/connections_device_provider.h"
#include "connections/v3/listeners.h"
#include "internal/analytics/event_logger.h"
#include "internal/base/file_path.h"
#include "internal/base/files.h"
#include "internal/flags/nearby_flags.h"
#include "internal/interop/device.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/cancelable_alarm.h"
#include "internal/platform/cancellation_flag.h"
#include "internal/platform/device_info_impl.h"
#include "internal/platform/error_code_params.h"
#include "internal/platform/error_code_recorder.h"
#include "internal/platform/feature_flags.h"
#include "internal/platform/implementation/app_lifecycle_monitor.h"
#include "internal/platform/implementation/platform.h"
#include "internal/platform/implementation/system_clock.h"
#include "internal/platform/logging.h"
#include "internal/platform/mac_address.h"
#include "internal/platform/mutex_lock.h"
@@ -68,8 +74,7 @@
#include "internal/platform/prng.h"
#include "proto/connections_enums.pb.h"
namespace nearby {
namespace connections {
namespace nearby::connections {
namespace {
using ::location::nearby::analytics::proto::ConnectionsLog;
@@ -81,16 +86,26 @@ constexpr char kEndpointIdChars[] = {
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'};
bool IsFeatureUseStableEndpointIdEnabled() {
return NearbyFlags::GetInstance().GetBoolFlag(
connections::config_package_nearby::nearby_connections_feature::
kUseStableEndpointId);
}
constexpr absl::string_view kPreferencesFilePath = "Google/Nearby/Connections";
constexpr absl::string_view kAdvertisingEndpointId =
"nc.advertising.endpoint_id";
constexpr absl::string_view kAdvertisingTimestamp = "nc.advertising.timestamp";
constexpr absl::Duration kAdvertisingKeepAliveDuration = absl::Seconds(30);
} // namespace
ClientProxy::ClientProxy(::nearby::analytics::EventLogger* event_logger)
: client_id_(Prng().NextInt64()) {
VLOG(1) << "ClientProxy ctor event_logger=" << event_logger;
if (NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_connections_feature::
kEnableNearbyConnectionsPreferences)) {
InitializePreferencesManager();
}
is_dct_enabled_ = NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_connections_feature::kEnableDct);
analytics_recorder_ =
@@ -115,6 +130,22 @@ ClientProxy::ClientProxy(::nearby::analytics::EventLogger* event_logger)
// Generate a 7 bits dedup value.
absl::BitGen bitgen;
dct_dedup_ = absl::Uniform(bitgen, 0, 1 << 7);
// Load advertising info from preferences.
LoadClientInfoFromPreferences();
if (preferences_manager_ != nullptr) {
app_lifecycle_monitor_ =
api::ImplementationPlatform::CreateAppLifecycleMonitor(
[this](api::AppLifecycleMonitor::AppLifecycleState state) {
if (state ==
api::AppLifecycleMonitor::AppLifecycleState::kInactive ||
state == api::AppLifecycleMonitor::AppLifecycleState::
kBackground) {
SaveClientInfoToPreferences();
}
});
}
}
ClientProxy::~ClientProxy() { Reset(); }
@@ -172,32 +203,20 @@ std::optional<MacAddress> ClientProxy::GetBluetoothMacAddress(
return std::nullopt;
}
void ClientProxy::SetBluetoothMacAddress(
const std::string& endpoint_id, MacAddress bluetooth_mac_address) {
void ClientProxy::SetBluetoothMacAddress(const std::string& endpoint_id,
MacAddress bluetooth_mac_address) {
bluetooth_mac_addresses_[endpoint_id] = bluetooth_mac_address;
}
std::string ClientProxy::GenerateLocalEndpointId() {
if (IsFeatureUseStableEndpointIdEnabled()) {
if (!cached_endpoint_id_.empty()) {
if (stable_endpoint_id_mode_) {
LOG(INFO) << "ClientProxy [Local Endpoint Re-using cached "
"endpoint id due to in stable endpoint id mode]: "
"client="
<< GetClientId()
<< "; cached_endpoint_id_=" << cached_endpoint_id_;
return cached_endpoint_id_;
}
}
} else {
if (high_vis_mode_) {
if (!cached_endpoint_id_.empty()) {
LOG(INFO) << "ClientProxy [Local Endpoint Re-using cached "
"endpoint id]: client="
<< GetClientId()
<< "; cached_endpoint_id_=" << cached_endpoint_id_;
return cached_endpoint_id_;
}
if (!cached_endpoint_id_.empty()) {
if (stable_endpoint_id_mode_) {
LOG(INFO) << "ClientProxy [Local Endpoint Re-using cached "
"endpoint id due to in stable endpoint id mode]: "
"client="
<< GetClientId()
<< "; cached_endpoint_id_=" << cached_endpoint_id_;
return cached_endpoint_id_;
}
}
std::string id;
@@ -216,11 +235,7 @@ void ClientProxy::Reset() {
StoppedAdvertising();
StoppedDiscovery();
RemoveAllEndpoints();
if (IsFeatureUseStableEndpointIdEnabled()) {
ExitStableEndpointIdMode();
} else {
ExitHighVisibilityMode();
}
ExitStableEndpointIdMode();
}
void ClientProxy::StartedAdvertising(
@@ -233,24 +248,14 @@ void ClientProxy::StartedAdvertising(
MutexLock lock(&mutex_);
LOG(INFO) << "ClientProxy [StartedAdvertising]: client=" << GetClientId();
if (IsFeatureUseStableEndpointIdEnabled()) {
if (stable_endpoint_id_mode_) {
cached_endpoint_id_ = local_endpoint_id_;
} else {
cached_endpoint_id_.clear();
}
CancelClearCachedEndpointIdAlarm();
if (stable_endpoint_id_mode_) {
cached_endpoint_id_ = local_endpoint_id_;
} else {
if (high_vis_mode_) {
cached_endpoint_id_ = local_endpoint_id_;
LOG(INFO)
<< "ClientProxy [High Visibility Mode Adv, Cache EndpointId]: client="
<< GetClientId() << "; cached_endpoint_id_=" << cached_endpoint_id_;
CancelClearCachedEndpointIdAlarm();
}
cached_endpoint_id_.clear();
}
CancelClearCachedEndpointIdAlarm();
advertising_info_ = {service_id, listener};
advertising_options_ = advertising_options;
@@ -277,11 +282,7 @@ void ClientProxy::StoppedAdvertising() {
// advertising_options_ is purposefully not cleared here.
OnSessionComplete();
if (IsFeatureUseStableEndpointIdEnabled()) {
ExitStableEndpointIdMode();
} else {
ExitHighVisibilityMode();
}
ExitStableEndpointIdMode();
}
bool ClientProxy::IsAdvertising() const {
@@ -604,10 +605,8 @@ void ClientProxy::OnDisconnected(const std::string& endpoint_id, bool notify) {
CancelEndpoint(endpoint_id);
if (IsFeatureUseStableEndpointIdEnabled()) {
if (!stable_endpoint_id_mode_ && !HasOngoingConnection()) {
ScheduleClearCachedEndpointIdAlarm();
}
if (!stable_endpoint_id_mode_ && !HasOngoingConnection()) {
ScheduleClearCachedEndpointIdAlarm();
}
}
@@ -674,16 +673,6 @@ std::int32_t ClientProxy::GetApFrequency(const std::string& endpoint_id) const {
return -1;
}
std::string ClientProxy::GetIPAddress(const std::string& endpoint_id) const {
MutexLock lock(&mutex_);
const ConnectionPair* item = LookupConnection(endpoint_id);
if (item != nullptr) {
return item->first.connection_options.connection_info.ip_address;
}
return {};
}
bool ClientProxy::IsConnectedToEndpoint(const std::string& endpoint_id) const {
return ConnectionStatusMatches(endpoint_id, Connection::kConnected);
}
@@ -1132,22 +1121,6 @@ v3::ConnectionListeningOptions ClientProxy::GetListeningOptions() const {
return listening_options_;
}
void ClientProxy::EnterHighVisibilityMode() {
MutexLock lock(&mutex_);
LOG(INFO) << "ClientProxy [EnterHighVisibilityMode]: client="
<< GetClientId();
high_vis_mode_ = true;
}
void ClientProxy::ExitHighVisibilityMode() {
MutexLock lock(&mutex_);
LOG(INFO) << "ClientProxy [ExitHighVisibilityMode]: client=" << GetClientId();
high_vis_mode_ = false;
ScheduleClearCachedEndpointIdAlarm();
}
void ClientProxy::EnterStableEndpointIdMode() {
MutexLock lock(&mutex_);
VLOG(1) << "ClientProxy [EnterStableEndpointIdMode]: client="
@@ -1174,7 +1147,7 @@ void ClientProxy::ScheduleClearCachedEndpointIdAlarm() {
return;
}
if (IsFeatureUseStableEndpointIdEnabled() && HasOngoingConnection()) {
if (HasOngoingConnection()) {
VLOG(1) << "ClientProxy [Handle clearing cached endpoint ID "
"during disconnection]: client="
<< GetClientId();
@@ -1188,9 +1161,7 @@ void ClientProxy::ScheduleClearCachedEndpointIdAlarm() {
<< GetClientId() << "; cached_endpoint_id_=" << cached_endpoint_id_;
cached_endpoint_id_alarm_ = std::make_unique<CancelableAlarm>(
"clear_high_power_endpoint_id_cache",
[this]() {
ClearCachedLocalEndpointId();
},
[this]() { ClearCachedLocalEndpointId(); },
kHighPowerAdvertisementEndpointIdCacheTimeout, &single_thread_executor_);
}
@@ -1348,6 +1319,83 @@ std::optional<std::string> ClientProxy::GetEndpointIdForDct() const {
return dct_endpoint_id_;
}
void ClientProxy::InitializePreferencesManager() {
LOG(INFO) << "ClientProxy [InitializePreferencesManager]: client="
<< GetClientId();
auto device_info_ = std::make_unique<nearby::DeviceInfoImpl>();
FilePath preferences_path =
device_info_->GetAppDataPath().append(FilePath(kPreferencesFilePath));
if (!Files::FileExists(preferences_path)) {
Files::CreateDirectories(preferences_path);
}
preferences_manager_ = api::ImplementationPlatform::CreatePreferencesManager(
preferences_path.ToString());
if (preferences_manager_ == nullptr) {
LOG(ERROR) << "ClientProxy [Failed to initialize preferences manager]: "
"client="
<< GetClientId();
}
}
void ClientProxy::SaveClientInfoToPreferences() {
MutexLock lock(&mutex_);
if (preferences_manager_ == nullptr) {
return;
}
if (advertising_info_.IsEmpty()) {
preferences_manager_->Remove(kAdvertisingEndpointId);
preferences_manager_->Remove(kAdvertisingTimestamp);
return;
}
preferences_manager_->SetString(kAdvertisingEndpointId, local_endpoint_id_);
preferences_manager_->SetTime(kAdvertisingTimestamp,
SystemClock::ElapsedRealtime());
LOG(INFO) << "ClientProxy [SaveClientInfoToPreferences]: client="
<< GetClientId() << "; local_endpoint_id_=" << local_endpoint_id_;
}
void ClientProxy::LoadClientInfoFromPreferences() {
MutexLock lock(&mutex_);
if (preferences_manager_ == nullptr) {
return;
}
absl::Time last_advertising_time = preferences_manager_->GetTime(
kAdvertisingTimestamp, absl::InfinitePast());
if (SystemClock::ElapsedRealtime() - last_advertising_time <
kAdvertisingKeepAliveDuration) {
std::string endpoint_id =
preferences_manager_->GetString(kAdvertisingEndpointId, "");
if (!endpoint_id.empty() && endpoint_id.length() == kEndpointIdLength) {
bool is_valid_endpoint_id = true;
for (const auto& c : endpoint_id) {
if (!((c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'))) {
is_valid_endpoint_id = false;
break;
}
}
if (is_valid_endpoint_id) {
local_endpoint_id_ = endpoint_id;
cached_endpoint_id_ = local_endpoint_id_;
LOG(INFO) << "ClientProxy [LoadClientInfoFromPreferences]: client="
<< GetClientId()
<< "; local_endpoint_id_=" << local_endpoint_id_;
}
}
}
preferences_manager_->Remove(kAdvertisingEndpointId);
preferences_manager_->Remove(kAdvertisingTimestamp);
}
std::string ClientProxy::ToString(PayloadProgressInfo::Status status) const {
switch (status) {
case PayloadProgressInfo::Status::kSuccess:
@@ -1367,7 +1415,6 @@ std::string ClientProxy::Dump() {
sstream << " Client ID: " << GetClientId() << std::endl;
sstream << " Local Endpoint ID: " << GetLocalEndpointId() << std::endl;
sstream << std::boolalpha;
sstream << " High Visibility Mode: " << high_vis_mode_ << std::endl;
sstream << " Is Advertising: " << IsAdvertising() << std::endl;
sstream << " Is Discovering: " << IsDiscovering() << std::endl;
sstream << std::noboolalpha;
@@ -1395,5 +1442,4 @@ std::string ClientProxy::Dump() {
return sstream.str();
}
} // namespace connections
} // namespace nearby
} // namespace nearby::connections
+19 -25
View File
@@ -22,9 +22,12 @@
#include <utility>
#include <vector>
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/functional/any_invocable.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "absl/types/span.h"
#include "connections/advertising_options.h"
#include "connections/connection_options.h"
#include "connections/discovery_options.h"
@@ -45,19 +48,15 @@
#include "internal/platform/cancelable_alarm.h"
#include "internal/platform/cancellation_flag.h"
#include "internal/platform/error_code_recorder.h"
#include "internal/platform/implementation/app_lifecycle_monitor.h"
#include "internal/platform/implementation/preferences_manager.h"
#include "internal/platform/mac_address.h"
#include "internal/platform/mutex.h"
// Prefer using absl:: versions of a set and a map; they tend to be more
// efficient: implementation is using open-addressing hash tables.
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/types/span.h"
#include "internal/platform/os_name.h"
#include "internal/platform/scheduled_executor.h"
#include "internal/proto/analytics/connections_log.pb.h"
namespace nearby {
namespace connections {
namespace nearby::connections {
// ClientProxy is tracking state of client's connection, and serves as
// a proxy for notifications sent to this client.
@@ -198,8 +197,6 @@ class ClientProxy final {
std::string GetBssid(const std::string& endpoint_id) const;
// Returns WIFI Frequency for this endpoint.
std::int32_t GetApFrequency(const std::string& endpoint_id) const;
// Returns IP Address in 4 bytes format for this endpoint.
std::string GetIPAddress(const std::string& endpoint_id) const;
// Returns true if it's safe to send payloads to this endpoint.
bool IsConnectedToEndpoint(const std::string& endpoint_id) const;
// Returns all endpoints that can safely be sent payloads.
@@ -269,15 +266,6 @@ class ClientProxy final {
DiscoveryOptions GetDiscoveryOptions() const;
v3::ConnectionListeningOptions GetListeningOptions() const;
// The endpoint id will be stable for 30 seconds after high visibility mode
// (high power and Bluetooth Classic) advertisement stops.
// If client re-enters high visibility mode within 30 seconds, he is going to
// have the same endpoint id.
void EnterHighVisibilityMode();
// Cleans up any modifications in high visibility mode. The endpoint id always
// rotates.
void ExitHighVisibilityMode();
// Enters stable endpoint ID mode.
void EnterStableEndpointIdMode();
// Cleans up any modifications in stable endpoint ID mode. The endpoint id
@@ -371,6 +359,9 @@ class ClientProxy final {
// Forces client to regenerate a new local endpoint id.
void ClearCachedLocalEndpointId();
// Saves the client information to preferences.
void SaveClientInfoToPreferences();
private:
struct Connection {
// Status: may be either:
@@ -458,6 +449,9 @@ class ClientProxy final {
std::optional<std::string> GetEndpointIdForDct() const;
void InitializePreferencesManager();
void LoadClientInfoFromPreferences();
// The device name used for DCT advertising.
std::string dct_device_name_;
// The dedup value used for DCT advertising.
@@ -469,11 +463,6 @@ class ClientProxy final {
std::int64_t client_id_;
std::string local_endpoint_id_;
std::string local_endpoint_info_;
// If currently is advertising in high visibility mode is true: high power and
// Bluetooth Classic enabled. When high_visibility_mode_ is true, the endpoint
// id is stable for 30s. When high_visibility_mode_ is false, the endpoint id
// always rotates.
bool high_vis_mode_ = false;
// If advertising is in stable endpoint ID mode, the endpoint ID is stable
// for 30s after advertising or disconnection. When stable_endpoint_id_mode_
@@ -534,6 +523,12 @@ class ClientProxy final {
std::unique_ptr<CancellationFlag> default_cancellation_flag_ =
std::make_unique<CancellationFlag>(true);
// An app lifecycle monitor for monitoring the app lifecycle state.
std::unique_ptr<api::AppLifecycleMonitor> app_lifecycle_monitor_;
// A preferences manager for storing client-specific preferences.
std::unique_ptr<nearby::api::PreferencesManager> preferences_manager_;
// An analytics logger with |EventLogger| provided by client, which is default
// nullptr as no-op.
std::unique_ptr<analytics::AnalyticsRecorder> analytics_recorder_;
@@ -554,7 +549,6 @@ class ClientProxy final {
bool is_dct_enabled_ = false;
};
} // namespace connections
} // namespace nearby
} // namespace nearby::connections
#endif // CORE_INTERNAL_CLIENT_PROXY_H_
+55 -64
View File
@@ -162,7 +162,8 @@ class ClientProxyTest : public ::testing::TestWithParam<FeatureFlags::Flags> {
void SetUp() override {
EnvironmentConfig config{/*webrtc_enabled=*/false,
/*use_simulated_clock=*/true};
/*use_simulated_clock=*/true,
/*use_temporary_directory_for_app_path=*/true};
env_.Start(config);
client1_ = std::make_unique<ClientProxy>(&event_logger1_);
client2_ = std::make_unique<ClientProxy>(&event_logger2_);
@@ -175,12 +176,6 @@ class ClientProxyTest : public ::testing::TestWithParam<FeatureFlags::Flags> {
NearbyFlags::GetInstance().ResetOverridedValues();
}
bool ShouldEnterHighVisibilityMode(
const AdvertisingOptions& advertising_options) {
return !advertising_options.low_power &&
advertising_options.allowed.bluetooth;
}
bool ShouldEnterStableEndpointIdMode(
const AdvertisingOptions& advertising_options) {
if (advertising_options.use_stable_endpoint_id) {
@@ -195,16 +190,8 @@ class ClientProxyTest : public ::testing::TestWithParam<FeatureFlags::Flags> {
Endpoint StartAdvertising(
ClientProxy* client, ConnectionListener listener,
AdvertisingOptions advertising_options = AdvertisingOptions{}) {
if (NearbyFlags::GetInstance().GetBoolFlag(
connections::config_package_nearby::nearby_connections_feature::
kUseStableEndpointId)) {
if (ShouldEnterStableEndpointIdMode(advertising_options)) {
client->EnterStableEndpointIdMode();
}
} else {
if (ShouldEnterHighVisibilityMode(advertising_options)) {
client->EnterHighVisibilityMode();
}
if (ShouldEnterStableEndpointIdMode(advertising_options)) {
client->EnterStableEndpointIdMode();
}
Endpoint endpoint{
.info = ByteArray{"advertising endpoint name"},
@@ -368,13 +355,6 @@ class ClientProxyTest : public ::testing::TestWithParam<FeatureFlags::Flags> {
client->OnPayloadProgress(endpoint.id, {});
}
void EnableUseStableEndpointIdFeature() {
NearbyFlags::GetInstance().OverrideBoolFlagValue(
connections::config_package_nearby::nearby_connections_feature::
kUseStableEndpointId,
true);
}
ClientProxy* client1() { return client1_.get(); }
ClientProxy* client2() { return client2_.get(); }
@@ -574,7 +554,6 @@ TEST_F(ClientProxyTest, DumpString) {
"Nearby Connections State\n"
" Client ID: %d\n"
" Local Endpoint ID: %s\n"
" High Visibility Mode: false\n"
" Is Advertising: false\n"
" Is Discovering: false\n"
" Advertising Service ID: \n"
@@ -825,7 +804,6 @@ TEST_F(ClientProxyTest,
TEST_F(ClientProxyTest,
RotateWhenLowVizAdvertisementAfterHighVizAndStableAdvertisement) {
EnableUseStableEndpointIdFeature();
BooleanMediumSelector booleanMediumSelector;
booleanMediumSelector.bluetooth = true;
@@ -866,7 +844,6 @@ TEST_F(ClientProxyTest,
TEST_F(
ClientProxyTest,
NoRotateWhenLowVizStableAdvertisementAfterHighVizAndStableAdvertisement) {
EnableUseStableEndpointIdFeature();
BooleanMediumSelector booleanMediumSelector;
booleanMediumSelector.bluetooth = true;
@@ -910,7 +887,6 @@ TEST_F(
TEST_F(
ClientProxyTest,
NoRotateWhenAdvertisementHasConnectionAfterStableAdvertisementForAWhile) {
EnableUseStableEndpointIdFeature();
BooleanMediumSelector booleanMediumSelector;
booleanMediumSelector.bluetooth = true;
@@ -957,7 +933,6 @@ TEST_F(
}
TEST_F(ClientProxyTest, RotateWhenLowVizAdvertisementAfterDisconnection) {
EnableUseStableEndpointIdFeature();
BooleanMediumSelector booleanMediumSelector;
booleanMediumSelector.bluetooth = true;
@@ -1000,7 +975,6 @@ TEST_F(ClientProxyTest, RotateWhenLowVizAdvertisementAfterDisconnection) {
TEST_F(ClientProxyTest,
NoRotateWhenLowVizAndStableAdvertisementAfterDisconnection) {
EnableUseStableEndpointIdFeature();
BooleanMediumSelector booleanMediumSelector;
booleanMediumSelector.bluetooth = true;
@@ -1045,7 +1019,6 @@ TEST_F(ClientProxyTest,
}
TEST_F(ClientProxyTest, RotateWhenAdvertisementAfterDisconnectionForAWhile) {
EnableUseStableEndpointIdFeature();
BooleanMediumSelector booleanMediumSelector;
booleanMediumSelector.bluetooth = true;
@@ -1146,36 +1119,6 @@ TEST_F(ClientProxyTest,
EXPECT_NE(advertising_endpoint_1.id, advertising_endpoint_2.id);
}
// Tests the low visibility mode with bluetooth disabled advertisment.
TEST_F(ClientProxyTest,
EndpointIdRotateWhenLowVizAdvertisementWithBluetoothDisabled) {
BooleanMediumSelector booleanMediumSelector;
booleanMediumSelector.bluetooth = false;
AdvertisingOptions advertising_options{
{
strategy_,
booleanMediumSelector,
},
false, // auto_upgrade_bandwidth
false, // enforce_topology_constraints
false, // low_power
true, // enable_bluetooth_listening
false, // enable_webrtc_listening
true, // use_stable_endpoint_id
};
Endpoint advertising_endpoint_1 = StartAdvertising(
client1(), advertising_connection_listener_, advertising_options);
StopAdvertising(client1());
Endpoint advertising_endpoint_2 = StartAdvertising(
client1(), advertising_connection_listener_, advertising_options);
EXPECT_NE(advertising_endpoint_1.id, advertising_endpoint_2.id);
}
// Tests the low visibility mode with low power advertisment.
TEST_F(ClientProxyTest, EndpointIdRotateWhenLowVizAdvertisementWithLowPower) {
BooleanMediumSelector booleanMediumSelector;
@@ -1457,9 +1400,9 @@ TEST_F(ClientProxyTest, GetLocalDeviceWorksWithDeviceProvider) {
MockDeviceProvider provider;
client1()->RegisterDeviceProvider(&provider);
ASSERT_NE(client1()->GetLocalDeviceProvider(), nullptr);
EXPECT_CALL(
*(down_cast<MockDeviceProvider*>(client1()->GetLocalDeviceProvider())),
GetLocalDevice);
EXPECT_CALL(*(absl::down_cast<MockDeviceProvider*>(
client1()->GetLocalDeviceProvider())),
GetLocalDevice);
client1()->GetLocalDevice();
}
@@ -1621,6 +1564,54 @@ TEST_F(ClientProxyTest, TestRemoteMultiplexSocketBitmask) {
false);
}
TEST_F(ClientProxyTest, SaveClientInfoFromPreferences) {
NearbyFlags::GetInstance().OverrideBoolFlagValue(
config_package_nearby::nearby_connections_feature::
kEnableNearbyConnectionsPreferences,
true);
client1_ = std::make_unique<ClientProxy>(&event_logger1_);
Endpoint advertising_endpoint =
StartAdvertising(client1(), advertising_connection_listener_);
std::string endpoint_id = advertising_endpoint.id;
client1_->SaveClientInfoToPreferences();
// Destroy the client and create a new one.
client1_.reset();
client1_ = std::make_unique<ClientProxy>(&event_logger1_);
// The new client should load the same endpoint ID.
EXPECT_EQ(client1()->GetLocalEndpointId(), endpoint_id);
NearbyFlags::GetInstance().OverrideBoolFlagValue(
config_package_nearby::nearby_connections_feature::
kEnableNearbyConnectionsPreferences,
false);
}
TEST_F(ClientProxyTest, NotLoadClientInfoFromPreferencesOnExpired) {
NearbyFlags::GetInstance().OverrideBoolFlagValue(
config_package_nearby::nearby_connections_feature::
kEnableNearbyConnectionsPreferences,
true);
client1_ = std::make_unique<ClientProxy>(&event_logger1_);
Endpoint advertising_endpoint =
StartAdvertising(client1(), advertising_connection_listener_);
std::string endpoint_id = advertising_endpoint.id;
client1_->SaveClientInfoToPreferences();
// Destroy the client and create a new one.
client1_.reset();
FastForward(absl::Hours(25));
client1_ = std::make_unique<ClientProxy>(&event_logger1_);
// The new client should load the same endpoint ID.
EXPECT_NE(client1()->GetLocalEndpointId(), endpoint_id);
NearbyFlags::GetInstance().OverrideBoolFlagValue(
config_package_nearby::nearby_connections_feature::
kEnableNearbyConnectionsPreferences,
false);
}
} // namespace
} // namespace connections
} // namespace nearby
@@ -22,6 +22,7 @@
#include "gmock/gmock.h"
#include "protobuf-matchers/protocol-buffer-matchers.h"
#include "gtest/gtest.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "connections/implementation/analytics/analytics_recorder.h"
#include "connections/implementation/endpoint_channel.h"
@@ -40,7 +41,7 @@ class MockEndpointChannel : public EndpointChannel {
MOCK_METHOD(ExceptionOr<ByteArray>, Read, (), (override));
MOCK_METHOD(ExceptionOr<ByteArray>, Read, (PacketMetaData&), (override));
MOCK_METHOD(Exception, Write, (const ByteArray& data), (override));
MOCK_METHOD(Exception, Write, (const ByteArray&, PacketMetaData&),
MOCK_METHOD(Exception, Write, (absl::string_view data, PacketMetaData&),
(override));
MOCK_METHOD(void, Close, (), (override));
MOCK_METHOD(
@@ -16,9 +16,11 @@
#include <cstddef>
#include <cstdint>
#include <memory>
#include <string>
#include "gtest/gtest.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "connections/implementation/analytics/analytics_recorder.h"
#include "connections/implementation/client_proxy.h"
@@ -26,6 +28,7 @@
#include "internal/platform/byte_array.h"
#include "internal/platform/count_down_latch.h"
#include "internal/platform/exception.h"
#include "internal/platform/implementation/system_clock.h"
#include "internal/platform/input_stream.h"
#include "internal/platform/output_stream.h"
#include "internal/platform/pipe.h"
@@ -53,9 +56,9 @@ class FakeEndpointChannel : public EndpointChannel {
}
Exception Write(const ByteArray& data) override {
write_timestamp_ = SystemClock::ElapsedRealtime();
return out_ ? out_->Write(data) : Exception{Exception::kIo};
return out_ ? out_->Write(data.AsStringView()) : Exception{Exception::kIo};
}
Exception Write(const ByteArray& data,
Exception Write(absl::string_view data,
PacketMetaData& packet_meta_data) override {
write_timestamp_ = SystemClock::ElapsedRealtime();
return out_ ? out_->Write(data) : Exception{Exception::kIo};
@@ -20,6 +20,7 @@
#include <string>
#include "securegcm/d2d_connection_context_v1.h"
#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"
@@ -45,7 +46,7 @@ class EndpointChannel {
virtual Exception Write(const ByteArray& data) = 0; // throws Exception::IO
virtual Exception Write(
const ByteArray& data,
absl::string_view data,
PacketMetaData& packet_meta_data) = 0; // throws Exception::IO
// Closes this EndpointChannel, without tracking the closure in analytics.
@@ -82,7 +82,8 @@ std::function<void()> MakeDataPump(
if (monitor) {
monitor(read_response.result());
}
auto write_response = output->Write(read_response.result());
auto write_response =
output->Write(read_response.result().AsStringView());
if (write_response.Raised()) {
LOG(INFO) << "Peer writer closed on '" << label << "'";
input->Close();
@@ -239,6 +239,10 @@ ExceptionOr<bool> EndpointManager::HandleData(
ExceptionOr<ByteArray> bytes = endpoint_channel->Read(packet_meta_data);
if (!bytes.ok()) {
LOG(INFO) << "Stop reading on read-time exception: " << bytes.exception();
// Treat kNoData as kIo.
if (bytes.exception() == Exception::kNoData) {
return ExceptionOr<bool>(Exception::kIo);
}
return ExceptionOr<bool>(bytes.exception());
}
ExceptionOr<OfflineFrame> wrapped_frame = parser::FromBytes(bytes.result());
@@ -956,7 +960,8 @@ std::vector<std::string> EndpointManager::SendTransferFrameBytes(
continue;
}
Exception write_exception = channel->Write(bytes, packet_meta_data);
Exception write_exception =
channel->Write(bytes.AsStringView(), packet_meta_data);
if (!write_exception.Ok()) {
failed_endpoint_ids.push_back(endpoint_id);
LOG(INFO) << "Failed to send packet; endpoint_id=" << endpoint_id;
@@ -14,7 +14,6 @@
#include "connections/implementation/endpoint_manager.h"
#include <atomic>
#include <cstdint>
#include <memory>
#include <string>
@@ -25,6 +24,7 @@
#include "protobuf-matchers/protocol-buffer-matchers.h"
#include "gtest/gtest.h"
#include "testing/fuzzing/fuzztest.h"
#include "absl/strings/string_view.h"
#include "absl/synchronization/mutex.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
@@ -46,8 +46,7 @@
#include "internal/test/fake_single_thread_executor.h"
#include "proto/connections_enums.pb.h"
namespace nearby {
namespace connections {
namespace nearby::connections {
namespace {
using ::fuzztest::Filter;
@@ -71,7 +70,7 @@ class MockEndpointChannel : public EndpointChannel {
(override));
MOCK_METHOD(Exception, Write, (const ByteArray& data), (override));
MOCK_METHOD(Exception, Write,
(const ByteArray& data, PacketMetaData& packet_meta_data),
(absl::string_view data, PacketMetaData& packet_meta_data),
(override));
MOCK_METHOD(void, Close, (), (override));
MOCK_METHOD(void, Close, (DisconnectionReason reason), (override));
@@ -138,7 +137,6 @@ class MockFrameProcessor : public EndpointManager::FrameProcessor {
class SetSafeToDisconnect {
public:
SetSafeToDisconnect(bool safe_to_disconnect, bool auto_reconnect,
bool payload_received_ack,
std::int32_t safe_to_disconnect_version) {
NearbyFlags::GetInstance().OverrideBoolFlagValue(
config_package_nearby::nearby_connections_feature::
@@ -147,10 +145,6 @@ class SetSafeToDisconnect {
NearbyFlags::GetInstance().OverrideBoolFlagValue(
config_package_nearby::nearby_connections_feature::kEnableAutoReconnect,
auto_reconnect);
NearbyFlags::GetInstance().OverrideBoolFlagValue(
config_package_nearby::nearby_connections_feature::
kEnablePayloadReceivedAck,
payload_received_ack);
NearbyFlags::GetInstance().OverrideInt64FlagValue(
config_package_nearby::nearby_connections_feature::
kSafeToDisconnectVersion,
@@ -188,7 +182,9 @@ class EndpointManagerTest : public ::testing::Test {
EXPECT_TRUE(done.Await(absl::Milliseconds(1000)).result());
}
}
SetSafeToDisconnect set_safe_to_disconnect_{true, false, true, 5};
SetSafeToDisconnect set_safe_to_disconnect_{/*safe_to_disconnect=*/true,
/*auto_reconnect=*/false,
/*safe_to_disconnect_version=*/5};
std::unique_ptr<ClientProxy> client_ = std::make_unique<ClientProxy>();
ConnectionOptions connection_options_{
.keep_alive_interval_millis = 5000,
@@ -277,7 +273,6 @@ TEST_F(EndpointManagerTest, RegisterFrameProcessorWorks) {
false /*supports_5_ghz*/,
"" /*bssid*/,
2412 /*ap_frequency*/,
"8xqT" /*ip_address in 4 bytes format*/,
std::vector<Medium>{Medium::BLE} /*supported_mediums*/,
0 /*keep_alive_interval_millis*/,
0 /*keep_alive_timeout_millis*/};
@@ -463,7 +458,6 @@ TEST_F(EndpointManagerTest, TryDecrypt) {
false /*supports_5_ghz*/,
"" /*bssid*/,
2412 /*ap_frequency*/,
"8xqT" /*ip_address in 4 bytes format*/,
std::vector<Medium>{Medium::BLE} /*supported_mediums*/,
0 /*keep_alive_interval_millis*/,
0 /*keep_alive_timeout_millis*/};
@@ -529,5 +523,4 @@ TEST_F(EndpointManagerTest, DisconnectEndpointDuringDestruction) {
}
} // namespace
} // namespace connections
} // namespace nearby
} // namespace nearby::connections
+28 -10
View File
@@ -32,7 +32,9 @@
#include "internal/platform/byte_array.h"
#include "internal/platform/exception.h"
#include "internal/platform/expected.h"
#include "internal/platform/logging.h"
#include "internal/platform/mac_address.h"
#include "internal/platform/service_address.h"
namespace nearby {
namespace connections {
@@ -115,7 +117,8 @@ class FakeBwuHandler : public BaseBwuHandler {
ErrorOr<std::unique_ptr<EndpointChannel>> CreateUpgradedEndpointChannel(
ClientProxy* client, const std::string& service_id,
const std::string& endpoint_id,
const UpgradePathInfo& upgrade_path_info) final {
const location::nearby::connections::BandwidthUpgradeNegotiationFrame::
UpgradePathInfo& upgrade_path_info) final {
create_calls_.push_back({.client = client,
.service_id = service_id,
.endpoint_id = endpoint_id});
@@ -145,23 +148,38 @@ class FakeBwuHandler : public BaseBwuHandler {
/*mac_address=*/mac_address);
}
case location::nearby::proto::connections::WIFI_LAN:
return parser::ForBwuWifiLanPathAvailable(/*ip_address=*/"ABCD",
/*port=*/1234);
return parser::ForBwuWifiLanPathAvailable(
{ServiceAddress{.address = {'A', 'B', 'C', 'D'}, .port = 1234}});
case location::nearby::proto::connections::WEB_RTC:
case location::nearby::proto::connections::WEB_RTC_NON_CELLULAR:
return parser::ForBwuWebrtcPathAvailable(
/*peer_id=*/"peer-id",
location::nearby::connections::LocationHint{});
case location::nearby::proto::connections::WIFI_HOTSPOT:
return parser::ForBwuWifiHotspotPathAvailable(
/*ssid=*/"Direct-357a2d8c", /*password=*/"b592f7d3",
/*port=*/1234, /*frequency=*/2412, /*gateway=*/"123.234.23.1",
false);
case location::nearby::proto::connections::WIFI_HOTSPOT: {
location::nearby::connections::BandwidthUpgradeNegotiationFrame::
UpgradePathInfo::WifiHotspotCredentials credentials;
credentials.set_ssid("Direct-357a2d8c");
credentials.set_password("b592f7d3");
credentials.set_port(1234);
credentials.set_frequency(2412);
credentials.set_gateway("123.234.23.1");
auto* candidate = credentials.mutable_address_candidates()->Add();
candidate->set_ip_address(std::string(
"\xfe\x80\x00\x00\x00\x00\x00\x00\x4d\xb2\xb3\x5c\x22\x03\x98\xa1",
16));
candidate->set_port(1234);
candidate = credentials.mutable_address_candidates()->Add();
candidate->set_ip_address("\x7b\xea\x17\x01");
candidate->set_port(2412);
return parser::ForBwuWifiHotspotPathAvailable(std::move(credentials),
false);
}
case location::nearby::proto::connections::WIFI_DIRECT:
return parser::ForBwuWifiDirectPathAvailable(
/*ssid=*/"Direct-12345678", /*password=*/"87654321", /*port=*/2143,
/*ssid=*/"", /*password=*/"", /*port=*/2143,
/*frequency=*/2412, /*supports_disabling_encryption=*/false,
/*gateway=*/"123.234.23.1");
/*gateway=*/"123.234.23.1", /*service_name=*/"NC-WifiDirectTest",
/*pin=*/"b592f7d3");
case location::nearby::proto::connections::UNKNOWN_MEDIUM:
case location::nearby::proto::connections::MDNS:
case location::nearby::proto::connections::BLE:
@@ -19,11 +19,13 @@
#include <memory>
#include <string>
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "connections/implementation/analytics/analytics_recorder.h"
#include "connections/implementation/endpoint_channel.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/exception.h"
#include "internal/platform/implementation/system_clock.h"
namespace nearby {
namespace connections {
@@ -52,7 +54,7 @@ class FakeEndpointChannel : public EndpointChannel {
write_timestamp_ = SystemClock::ElapsedRealtime();
return write_output_;
}
Exception Write(const ByteArray& data,
Exception Write(absl::string_view data,
PacketMetaData& packet_meta_data) override {
write_timestamp_ = SystemClock::ElapsedRealtime();
return write_output_;
+1 -2
View File
@@ -20,10 +20,9 @@ cc_library(
hdrs = [
"nearby_connections_feature_flags.h",
],
# Flags should not be visible to external users. Only for internal use.
visibility = [
"//connections:__subpackages__",
"//connections:partners",
"//googlemac/iPhone/Shared/Identity/SmartSetup:__subpackages__",
"//internal/platform:__subpackages__",
"//internal/platform/implementation:__subpackages__",
"//location/nearby/cpp:__subpackages__",
@@ -31,15 +31,12 @@ namespace nearby_connections_feature {
// The timeout in millis to report peripheral device lost.
constexpr auto kBlePeripheralLostTimeoutMillis =
flags::Flag<int64_t>(kConfigPackage, "45411439", 12000);
// When true, disable Bluetooth classic scanning.
constexpr auto kDisableBluetoothClassicScanning =
flags::Flag<bool>(kConfigPackage, "45639961", false);
// Disable instant on lost on BLE without extended feature.
constexpr auto kDisableInstantOnLostOnBleWithoutExtended =
flags::Flag<bool>(kConfigPackage, "45687098", true);
// When true, enable advertising for instant on lost feature.
constexpr auto kEnableAdvertisingForInstantOnLost =
flags::Flag<bool>(kConfigPackage, "45708614", false);
flags::Flag<bool>(kConfigPackage, "45708614", true);
// Enable/Disable auto_reconnect feature.
constexpr auto kEnableAutoReconnect =
flags::Flag<bool>(kConfigPackage, "45427690", false);
@@ -49,9 +46,9 @@ constexpr auto kEnableAwdl =
// Disable/Enable BLE L2CAP in Nearby Connections SDK.
constexpr auto kEnableBleL2cap =
flags::Flag<bool>(kConfigPackage, "45685706", false);
// Disable/Enable BLE v2 in Nearby Connections SDK.
constexpr auto kEnableBleV2 =
flags::Flag<bool>(kConfigPackage, "45401515", true);
// Enable/Disable BLE medium injection.
constexpr auto kEnableBleMediumInjection =
flags::Flag<bool>(kConfigPackage, "45743128", false);
// Enable/Disable DCT advertising/scanning specification.
constexpr auto kEnableDct =
flags::Flag<bool>(kConfigPackage, "45697202", false);
@@ -61,12 +58,7 @@ constexpr auto kEnableDynamicRoleSwitch =
// Enable/Disable GATT client disconnection.
constexpr auto kEnableGattClientDisconnection =
flags::Flag<bool>(kConfigPackage, "45698964", false);
// Disable/Enable GATT query in thread in BLE V2.
constexpr auto kEnableGattQueryInThread =
flags::Flag<bool>(kConfigPackage, "45415261", true);
// When true, enable instant on lost feature.
constexpr auto kEnableInstantOnLost =
flags::Flag<bool>(kConfigPackage, "45642180", false);
// When true, enable multiplexing in NC.
constexpr auto kEnableMultiplex =
flags::Flag<bool>(kConfigPackage, "45647946", false);
@@ -79,24 +71,24 @@ constexpr auto kEnableMultiplexBluetooth =
// When true, enable multiplexing in NC for Wifi.
constexpr auto kEnableMultiplexWifiLan =
flags::Flag<bool>(kConfigPackage, "45676647", false);
// Enable/Disable preferences for Nearby Connections.
constexpr auto kEnableNearbyConnectionsPreferences =
flags::Flag<bool>(kConfigPackage, "45732423", false);
// Enable/Disable payload manager to skip chunk update.
constexpr auto kEnablePayloadManagerToSkipChunkUpdate =
flags::Flag<bool>(kConfigPackage, "45415729", true);
// Enable/Disable payload-received-ack feature.
constexpr auto kEnablePayloadReceivedAck =
flags::Flag<bool>(kConfigPackage, "45425840", false);
// Enable/Disable GATT query for extended advertisement.
constexpr auto kEnableReadGattForExtendedAdvertisement =
flags::Flag<bool>(kConfigPackage, "45718229", false);
// Enable/Disable safe-to-disconnect feature.
constexpr auto kEnableSafeToDisconnect =
flags::Flag<bool>(kConfigPackage, "45425789", false);
// When true, enable scanning for instant on lost feature.
constexpr auto kEnableScanningForInstantOnLost =
flags::Flag<bool>(kConfigPackage, "45708613", false);
flags::Flag<bool>(kConfigPackage, "45708613", true);
// Stop BLE_V2 scanning when upgrading to WIFI Hotspot or WFD.
constexpr auto kEnableStopBleScanningOnWifiUpgrade =
flags::Flag<bool>(kConfigPackage, "45687902", false);
// Enable/Disable Wi-Fi Direct in Nearby connections SDK.
constexpr auto kEnableWifiDirect =
flags::Flag<bool>(kConfigPackage, "45741157", false);
// by default, enable Wi-Fi Hotspot client.
constexpr auto kEnableWifiHotspotClient =
flags::Flag<bool>(kConfigPackage, "45648734", true);
@@ -106,14 +98,14 @@ constexpr auto kMediumDefaultMaxTransmitPacketSize =
// Default max allowed read bytes for medium.
constexpr auto kMediumMaxAllowedReadBytes =
flags::Flag<int64_t>(kConfigPackage, "45669530", 1048576);
// Disable/Enable refactor of BLE/L2CAP in Nearby Connections SDK.
constexpr auto kRefactorBleL2cap =
flags::Flag<bool>(kConfigPackage, "45737079", false);
// Set the safe-to-disconnect version.
// 0. Disabled all. 1. safe-to-disconnect 2. reserved 3. auto-reconnect
// 4. auto-resume 5. non-distance-constraint-recovery 6. payload_ack
constexpr auto kSafeToDisconnectVersion =
flags::Flag<int64_t>(kConfigPackage, "45425841", 0);
// When true, use stable endpoint ID.
constexpr auto kUseStableEndpointId =
flags::Flag<bool>(kConfigPackage, "45639298", false);
} // namespace nearby_connections_feature
} // namespace config_package_nearby
@@ -46,7 +46,14 @@ class InjectedBluetoothDevice : public api::BluetoothDevice {
// api::BluetoothDevice:
std::string GetName() const override { return name_; }
std::string GetMacAddress() const override { return mac_address_; }
MacAddress GetMacAddress() const override {
if (mac_address_.empty()) {
return MacAddress();
}
MacAddress address;
MacAddress::FromString(mac_address_, address);
return address;
}
private:
const std::string name_;
@@ -99,7 +106,7 @@ BluetoothDevice InjectedBluetoothDeviceStore::CreateInjectedBluetoothDevice(
bool InjectedBluetoothDeviceStore::IsInjectedDevice(MacAddress mac_address) {
for (const auto& device : devices_) {
if (device->GetAddress() == mac_address) {
if (device->GetMacAddress() == mac_address) {
return true;
}
}
@@ -15,9 +15,11 @@
#ifndef CORE_INTERNAL_INTERNAL_PAYLOAD_H_
#define CORE_INTERNAL_INTERNAL_PAYLOAD_H_
#include <cstddef>
#include <cstdint>
#include <string>
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "connections/implementation/proto/offline_wire_formats.pb.h"
#include "connections/payload.h"
@@ -82,14 +84,11 @@ class InternalPayload {
// Adds the next chunk that comprises the Payload to which this object is
// bound.
//
// <p>Used when we are trying to reconstruct a Payload that lives on the
// other side of a hard boundary (like the other side of a Binder, or another
// device altogether), one byte blob at a time.
// Used when we are trying to reconstruct a Payload that lives on the
// other side of a hard boundary (like another device), one chunk at a time.
//
// @param chunk The next chunk; this being null signals that this is the last
// chunk, which will typically be used as a trigger to perform whatever state
// cleanup may be required by the concrete implementation.
virtual Exception AttachNextChunk(const ByteArray& chunk) = 0;
// `chunk` is the next chunk.
virtual Exception AttachNextChunk(absl::string_view chunk) = 0;
// Skips current stream pointer to the offset.
//
@@ -21,6 +21,7 @@
#include <utility>
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
#include "connections/implementation/internal_payload.h"
@@ -73,7 +74,7 @@ class BytesInternalPayload : public InternalPayload {
}
// Does nothing.
Exception AttachNextChunk(const ByteArray& chunk) override {
Exception AttachNextChunk(absl::string_view chunk) override {
return {Exception::kSuccess};
}
@@ -127,7 +128,7 @@ class OutgoingStreamInternalPayload : public InternalPayload {
return scoped_bytes_read;
}
Exception AttachNextChunk(const ByteArray& chunk) override {
Exception AttachNextChunk(absl::string_view chunk) override {
return {Exception::kIo};
}
@@ -171,8 +172,8 @@ class IncomingStreamInternalPayload : public InternalPayload {
ByteArray DetachNextChunk(int chunk_size) override { return {}; }
Exception AttachNextChunk(const ByteArray& chunk) override {
if (chunk.Empty()) {
Exception AttachNextChunk(absl::string_view chunk) override {
if (chunk.empty()) {
LOG(INFO) << "Received null last chunk for incoming payload " << this
<< ", closing OutputStream.";
Close();
@@ -229,7 +230,7 @@ class OutgoingFileInternalPayload : public InternalPayload {
return bytes;
}
Exception AttachNextChunk(const ByteArray& chunk) override {
Exception AttachNextChunk(absl::string_view chunk) override {
return {Exception::kIo};
}
@@ -285,8 +286,8 @@ class IncomingFileInternalPayload : public InternalPayload {
ByteArray DetachNextChunk(int chunk_size) override { return {}; }
Exception AttachNextChunk(const ByteArray& chunk) override {
if (chunk.Empty()) {
Exception AttachNextChunk(absl::string_view chunk) override {
if (chunk.empty()) {
// Received null last chunk for incoming payload.
Close();
return {Exception::kSuccess};
@@ -431,7 +432,7 @@ ErrorOr<std::unique_ptr<InternalPayload>> CreateIncomingInternalPayload(
return {Error(OperationResultCode::IO_FILE_OPENING_ERROR)};
}
return {std::make_unique<IncomingFileInternalPayload>(
Payload(payload_id, InputFile(payload_id, total_size)),
Payload(payload_id, InputFile(payload_id)),
std::move(output_file), last_modified_time, total_size)};
} else {
OutputFile output_file(file_path);
@@ -441,7 +442,7 @@ ErrorOr<std::unique_ptr<InternalPayload>> CreateIncomingInternalPayload(
}
return {std::make_unique<IncomingFileInternalPayload>(
Payload(payload_id, parent_folder, file_name,
InputFile(file_path, total_size)),
InputFile(file_path)),
std::move(output_file), last_modified_time, total_size)};
}
}
@@ -21,6 +21,7 @@
#include <utility>
#include "gtest/gtest.h"
#include "absl/strings/string_view.h"
#include "connections/implementation/internal_payload.h"
#include "connections/implementation/proto/offline_wire_formats.pb.h"
#include "connections/payload.h"
@@ -66,7 +67,7 @@ TEST(InternalPayloadFactoryTest, CanCreateInternalPayloadFromStreamPayload) {
TEST(InternalPayloadFactoryTest, CanCreateInternalPayloadFromFilePayload) {
Payload::Id payload_id = Payload::GenerateId();
InputFile inputFile(payload_id, 512);
InputFile inputFile(payload_id);
ErrorOr<std::unique_ptr<InternalPayload>> result =
CreateOutgoingInternalPayload(Payload{payload_id, std::move(inputFile)});
ASSERT_FALSE(result.has_error());
@@ -218,7 +219,8 @@ TEST(InternalPayloadFactoryTest,
ASSERT_TRUE(result.has_error());
}
void CreateFileWithContents(Payload::Id payload_id, const ByteArray& contents) {
void CreateFileWithContents(Payload::Id payload_id,
absl::string_view contents) {
OutputFile file(payload_id);
EXPECT_TRUE(file.Write(contents).Ok());
EXPECT_TRUE(file.Close().Ok());
@@ -226,12 +228,12 @@ void CreateFileWithContents(Payload::Id payload_id, const ByteArray& contents) {
TEST(InternalPayloadFactoryTest,
SkipToOffset_FilePayloadValidOffset_SkipsOffset) {
ByteArray contents("0123456789");
absl::string_view contents("0123456789");
constexpr size_t kOffset = 4;
size_t size_after_skip = contents.size() - kOffset;
Payload::Id payload_id = Payload::GenerateId();
CreateFileWithContents(payload_id, contents);
InputFile inputFile(payload_id, contents.size());
InputFile inputFile(payload_id);
ErrorOr<std::unique_ptr<InternalPayload>> internal_payload_result =
CreateOutgoingInternalPayload(Payload{payload_id, std::move(inputFile)});
ASSERT_FALSE(internal_payload_result.has_error());
@@ -251,7 +253,7 @@ TEST(InternalPayloadFactoryTest,
TEST(InternalPayloadFactoryTest,
SkipToOffset_StreamPayloadValidOffset_SkipsOffset) {
ByteArray contents("0123456789");
absl::string_view contents("0123456789");
constexpr size_t kOffset = 6;
auto [input, output] = CreatePipe();
ErrorOr<std::unique_ptr<InternalPayload>> internal_payload_result =
+18 -14
View File
@@ -1,6 +1,3 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,6 +11,10 @@ load("@rules_cc//cc:cc_test.bzl", "cc_test")
# 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.
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")
licenses(["notice"])
cc_library(
@@ -21,7 +22,6 @@ cc_library(
srcs = [
"awdl.cc",
"ble.cc",
"ble_v2.cc",
"bluetooth_classic.cc",
"bluetooth_radio.cc",
"mediums.cc",
@@ -34,7 +34,6 @@ cc_library(
hdrs = [
"awdl.h",
"ble.h",
"ble_v2.h",
"bluetooth_classic.h",
"bluetooth_radio.h",
"mediums.h",
@@ -55,9 +54,10 @@ cc_library(
"//connections:core_types",
"//connections/implementation:types",
"//connections/implementation/flags:connections_flags",
"//connections/implementation/mediums/ble_v2",
"//connections/implementation/mediums/ble_v2:ble_advertisement_header",
"//connections/implementation/mediums/ble_v2:bloom_filter",
"//connections/implementation/mediums/ble",
"//connections/implementation/mediums/ble:ble_advertisement_header",
"//connections/implementation/mediums/ble:ble_socket",
"//connections/implementation/mediums/ble:bloom_filter",
"//connections/implementation/mediums/multiplex",
"//connections/implementation/mediums/webrtc",
"//connections/implementation/proto:offline_wire_formats_cc_proto",
@@ -65,9 +65,11 @@ cc_library(
"//internal/platform:base",
"//internal/platform:cancellation_flag",
"//internal/platform:comm",
"//internal/platform:logging",
"//internal/platform:mac_address",
"//internal/platform:types",
"//internal/platform:uuid",
"//internal/platform/flags:platform_flags",
"//internal/platform/implementation:comm",
"//internal/platform/implementation:platform",
"//internal/platform/implementation:wifi_utils",
@@ -116,7 +118,7 @@ cc_library(
name = "lost_entity_tracker",
hdrs = ["lost_entity_tracker.h"],
visibility = [
"//connections/implementation/mediums/ble_v2:__pkg__",
"//connections/implementation/mediums/ble:__pkg__",
],
deps = [
"//internal/platform:types",
@@ -132,7 +134,7 @@ cc_library(
visibility = [
"//connections/implementation:__pkg__",
"//connections/implementation/mediums/advertisements:__pkg__",
"//connections/implementation/mediums/ble_v2:__subpackages__",
"//connections/implementation/mediums/ble:__subpackages__",
"//connections/implementation/mediums/multiplex:__pkg__",
"//internal/platform/implementation/windows:__pkg__",
],
@@ -148,7 +150,6 @@ cc_test(
srcs = [
"awdl_test.cc",
"ble_test.cc",
"ble_v2_test.cc",
"bluetooth_classic_test.cc",
"bluetooth_radio_test.cc",
"lost_entity_tracker_test.cc",
@@ -161,18 +162,20 @@ cc_test(
deps = [
":lost_entity_tracker",
":mediums",
":utils",
"//connections:core_types",
"//connections/implementation:types",
"//connections/implementation/flags:connections_flags",
"//connections/implementation/mediums/ble_v2",
"//connections/implementation/mediums/ble",
"//connections/implementation/mediums/ble:ble_socket",
"//internal/flags:nearby_flags",
"//internal/platform:base",
"//internal/platform:cancellation_flag",
"//internal/platform:comm",
"//internal/platform:logging",
"//internal/platform:mac_address",
"//internal/platform:test_util",
"//internal/platform:types",
"//internal/platform/implementation:platform",
"//internal/platform/implementation:comm",
"//internal/platform/implementation:types",
"//internal/platform/implementation/g3", # build_cleaner: keep
"@com_github_protobuf_matchers//protobuf-matchers",
@@ -205,6 +208,7 @@ cc_test(
"//internal/platform/implementation/g3", # build_cleaner: keep
"//internal/test",
"@com_github_protobuf_matchers//protobuf-matchers",
"@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest_main",
],
)
File diff suppressed because it is too large Load Diff
+294 -101
View File
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -15,184 +15,377 @@
#ifndef CORE_INTERNAL_MEDIUMS_BLE_H_
#define CORE_INTERNAL_MEDIUMS_BLE_H_
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "absl/base/thread_annotations.h"
#include "absl/container/btree_map.h"
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/functional/any_invocable.h"
#include "absl/strings/string_view.h"
#include "connections/implementation/mediums/ble/advertisement_read_result.h"
#include "connections/implementation/mediums/ble/ble_advertisement.h"
#include "connections/implementation/mediums/ble/ble_socket.h"
#include "connections/implementation/mediums/ble/discovered_peripheral_callback.h"
#include "connections/implementation/mediums/ble/discovered_peripheral_tracker.h"
#include "connections/implementation/mediums/ble/instant_on_lost_manager.h"
#include "connections/implementation/mediums/bluetooth_radio.h"
#include "connections/listeners.h"
#include "connections/implementation/pcp.h"
#include "connections/power_level.h"
#include "internal/platform/ble.h"
#include "internal/platform/bluetooth_adapter.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/cancelable_alarm.h"
#include "internal/platform/cancellation_flag.h"
#include "internal/platform/expected.h"
#include "internal/platform/implementation/ble.h"
#include "internal/platform/multi_thread_executor.h"
#include "internal/platform/mutex.h"
#include "internal/platform/mutex_lock.h"
#include "internal/platform/runnable.h"
#include "internal/platform/scheduled_executor.h"
#include "internal/platform/single_thread_executor.h"
namespace nearby {
namespace connections {
class Ble {
// Provides the operations that can be performed on the Bluetooth Low Energy
// (BLE) medium.
class Ble final {
public:
using DiscoveredPeripheralCallback = BleMedium::DiscoveredPeripheralCallback;
using AcceptedConnectionCallback = BleMedium::AcceptedConnectionCallback;
using DiscoveredPeripheralCallback = mediums::DiscoveredPeripheralCallback;
// Callback that is invoked when a new connection is accepted.
using AcceptedConnectionCallback =
absl::AnyInvocable<void(BleSocket socket, const std::string& service_id)>;
// Callback that is invoked when a new l2cap connection is accepted.
using AcceptedL2capConnectionCallback = absl::AnyInvocable<void(
BleL2capSocket socket, const std::string& service_id)>;
// The refactor version of AcceptedConnectionCallback and
// AcceptedL2capConnectionCallback above.
using AcceptedConnectionCallback2 =
absl::AnyInvocable<void(std::unique_ptr<mediums::BleSocket> socket,
const std::string& service_id)>;
// The type of the BLE advertising. In current implementation, we don't
// support multiple advertising types on a Medium instance.
enum class AdvertisingType : int {
kRegular = 0,
kFast = 1,
kDct = 2,
};
explicit Ble(BluetoothRadio& bluetooth_radio);
~Ble() = default;
~Ble();
// Returns true, if Ble communications are supported by a platform.
// Returns true, if BLE communications are supported by a platform.
bool IsAvailable() const ABSL_LOCKS_EXCLUDED(mutex_);
// Sets custom advertisement data, and then enables Ble advertising.
// Returns true, if data is successfully set, and false otherwise.
bool StartAdvertising(const std::string& service_id,
const ByteArray& advertisement_bytes,
const std::string& fast_advertisement_service_uuid)
// Starts BLE advertising, delivering additional information if the platform
// supports it.
//
// service_id - The service ID to track.
// power_level - The power level to use for the advertisement.
// advertising_type - The type of the BLE advertisement.
// advertisement_bytes - The connections BLE Advertisement used in
// advertising.
ErrorOr<bool> StartAdvertising(const std::string& service_id,
PowerLevel power_level,
AdvertisingType advertising_type,
const ByteArray& advertisement_bytes)
ABSL_LOCKS_EXCLUDED(mutex_);
// Disables Ble advertising.
// Disables BLE advertising.
bool StopAdvertising(const std::string& service_id)
ABSL_LOCKS_EXCLUDED(mutex_);
// (TODO:hais) remove this after ble_v2 refactor
// Sets custom advertisement data, and then enables Ble advertising.
bool IsAdvertising(const std::string& service_id) const
ABSL_LOCKS_EXCLUDED(mutex_);
bool IsAdvertisingForLegacyDevice(const std::string& service_id) const
ABSL_LOCKS_EXCLUDED(mutex_);
// Use dummy bytes to do ble advertising, only for legacy devices.
// Returns true, if data is successfully set, and false otherwise.
bool StartLegacyAdvertising(
ErrorOr<bool> StartLegacyAdvertising(
const std::string& service_id, const std::string& local_endpoint_id,
const std::string& fast_advertisement_service_uuid)
ABSL_LOCKS_EXCLUDED(mutex_);
// (TODO:hais) remove this after ble_v2 refactor
// Disables Ble advertising.
// (TODO:hais) update this after ble async api refactor.
// Stop Ble advertising with dummy bytes for legacy device.
bool StopLegacyAdvertising(const std::string& service_id)
ABSL_LOCKS_EXCLUDED(mutex_);
bool IsAdvertising(const std::string& service_id) ABSL_LOCKS_EXCLUDED(mutex_);
// Adds an alternative BLE service UUID16s for a given Nearby service
// id. If a device does not support BLE extended advertisements, an alternate
// service UUID16 may be used to trigger a GATT connection to retrieve GATT
// characteristics for the Nearby service
// These alternate uuids are active until the next call to `StopScanning`.
void AddAlternateUuidForService(uint16_t uuid, const std::string& service_id);
// Enables Ble scanning mode. Will report any discoverable peripherals in
// range through a callback. Returns true, if scanning mode was enabled,
// false otherwise.
bool StartScanning(const std::string& service_id,
const std::string& fast_advertisement_service_uuid,
DiscoveredPeripheralCallback callback)
// Enables BLE scanning for a service ID. Will report any discoverable
// advertisement data through a callback.
// Returns true, if the scanning is successfully enabled, false otherwise.
//
// service_id - The service ID to track.
// pcp - The PCP to use for the discovery.
// power_level - The power level to use for the discovery.
// include_dct_advertisement - Whether to include the dct advertisement in
// the discovery. it is false by default.
// discovered_peripheral_callback - The callback to invoke for discovery
// events.
ErrorOr<bool> StartScanning(const std::string& service_id, Pcp pcp,
PowerLevel power_level,
bool include_dct_advertisement,
DiscoveredPeripheralCallback callback)
ABSL_LOCKS_EXCLUDED(mutex_);
// Disables Ble discovery mode.
// Disables BLE scanning for a service ID.
// Returns true, if the scanning was previously enabled, false otherwise.
bool StopScanning(const std::string& service_id) ABSL_LOCKS_EXCLUDED(mutex_);
bool IsScanning(const std::string& service_id) ABSL_LOCKS_EXCLUDED(mutex_);
// Pauses BLE scanning at platform Medium level.
bool PauseMediumScanning();
// Resumes BLE scanning at platform Medium level.
bool ResumeMediumScanning();
// Returns true if the scanning for service ID is enabled.
bool IsScanning(const std::string& service_id) const
ABSL_LOCKS_EXCLUDED(mutex_);
// Starts a worker thread, creates a Ble socket, associates it with a
// service id.
bool StartAcceptingConnections(const std::string& service_id,
AcceptedConnectionCallback callback)
ErrorOr<bool> StartAcceptingConnections(const std::string& service_id,
AcceptedConnectionCallback callback)
ABSL_LOCKS_EXCLUDED(mutex_);
// Starts a worker thread, creates a Ble L2CAP socket, associates it with a
// service id.
// Returns the PSM of the L2CAP channel on success, or an error code on
// failure.
ErrorOr<int> StartAcceptingL2capConnections(
const std::string& service_id,
AcceptedL2capConnectionCallback l2cap_callback)
ABSL_LOCKS_EXCLUDED(mutex_);
// The refactor version of StartAcceptingConnections() above.
ErrorOr<bool> StartAcceptingConnections(const std::string& service_id,
AcceptedConnectionCallback2 callback)
ABSL_LOCKS_EXCLUDED(mutex_);
// The refactor version of StartAcceptingL2capConnections() above.
ErrorOr<int> StartAcceptingL2capConnections(
const std::string& service_id, AcceptedConnectionCallback2 callback)
ABSL_LOCKS_EXCLUDED(mutex_);
// Closes socket corresponding to a service id.
bool StopAcceptingConnections(const std::string& service_id)
ABSL_LOCKS_EXCLUDED(mutex_);
bool StopAcceptingL2capConnections(const std::string& service_id)
ABSL_LOCKS_EXCLUDED(mutex_);
bool IsAcceptingConnections(const std::string& service_id)
ABSL_LOCKS_EXCLUDED(mutex_);
bool IsAcceptingL2capConnections(const std::string& service_id)
ABSL_LOCKS_EXCLUDED(mutex_);
// Establishes connection to Ble peripheral.
// Returns socket instance. On success, BleSocket.IsValid() return true.
ErrorOr<BleSocket> Connect(const std::string& service_id,
const BlePeripheral& peripheral,
CancellationFlag* cancellation_flag)
ABSL_LOCKS_EXCLUDED(mutex_);
// Establishes connection to Ble peripheral.
// Returns socket instance. On success, BleSocket.IsValid() return true.
ErrorOr<BleL2capSocket> ConnectOverL2cap(const std::string& service_id,
const BlePeripheral& peripheral,
CancellationFlag* cancellation_flag)
ABSL_LOCKS_EXCLUDED(mutex_);
// The refactor version of Connect() above.
ErrorOr<std::unique_ptr<mediums::BleSocket>> Connect2(
const std::string& service_id, const BlePeripheral& peripheral,
CancellationFlag* cancellation_flag) ABSL_LOCKS_EXCLUDED(mutex_);
// The refactor version of ConnectOverL2cap() above.
ErrorOr<std::unique_ptr<mediums::BleSocket>> ConnectOverL2cap2(
const std::string& service_id, const BlePeripheral& peripheral,
CancellationFlag* cancellation_flag) ABSL_LOCKS_EXCLUDED(mutex_);
// Returns true if this object owns a valid platform implementation.
bool IsMediumValid() const ABSL_LOCKS_EXCLUDED(mutex_) {
MutexLock lock(&mutex_);
return medium_.IsValid();
}
// Returns true if this object has a valid BluetoothAdapter reference.
bool IsAdapterValid() const ABSL_LOCKS_EXCLUDED(mutex_) {
// Returns true if the BLE device support extended advertisement.
bool IsExtendedAdvertisementsAvailable() ABSL_LOCKS_EXCLUDED(mutex_) {
MutexLock lock(&mutex_);
return adapter_.IsValid();
}
return medium_.IsExtendedAdvertisementsAvailable();
};
// Establishes connection to Ble peripheral that was might be started on
// another peripheral with StartAcceptingConnections() using the same
// service_id. Blocks until connection is established, or server-side is
// terminated. Returns socket instance. On success, BleSocket.IsValid() return
// true.
ErrorOr<BleSocket> Connect(BlePeripheral& peripheral,
const std::string& service_id,
CancellationFlag* cancellation_flag)
ABSL_LOCKS_EXCLUDED(mutex_);
// Retrieves a BlePeripheral from a native BLE peripheral ID.
// On Apple platform, the native ID is NSUUID in string format like
// "E621E1F8-C36C-495A-93FC-0C247A3E6E5F", other platform will be MAC address
// as string format like "0C:24:7A:3E:6E:5F".
std::optional<BlePeripheral> RetrieveBlePeripheralFromNativeId(
const std::string& ble_peripheral_native_id) {
MutexLock lock(&mutex_);
return medium_.RetrieveBlePeripheralFromNativeId(ble_peripheral_native_id);
}
private:
struct AdvertisingInfo {
bool Empty() const { return service_ids.empty(); }
void Clear() { service_ids.clear(); }
void Add(const std::string& service_id) { service_ids.emplace(service_id); }
void Remove(const std::string& service_id) {
service_ids.erase(service_id);
}
bool Existed(const std::string& service_id) const {
return service_ids.contains(service_id);
}
absl::flat_hash_set<std::string> service_ids;
mediums::BleAdvertisement medium_advertisement;
ByteArray dct_advertisement;
PowerLevel power_level;
AdvertisingType advertising_type;
};
struct ScanningInfo {
bool Empty() const { return service_ids.empty(); }
void Clear() { service_ids.clear(); }
void Add(const std::string& service_id) { service_ids.emplace(service_id); }
void Remove(const std::string& service_id) {
service_ids.erase(service_id);
}
bool Existed(const std::string& service_id) const {
return service_ids.contains(service_id);
}
absl::flat_hash_set<std::string> service_ids;
};
struct AcceptingConnectionsInfo {
bool Empty() const { return service_ids.empty(); }
void Clear() { service_ids.clear(); }
void Add(const std::string& service_id) { service_ids.emplace(service_id); }
void Remove(const std::string& service_id) {
service_ids.erase(service_id);
}
bool Existed(const std::string& service_id) const {
return service_ids.contains(service_id);
}
absl::flat_hash_set<std::string> service_ids;
};
static constexpr int kMaxAdvertisementLength = 512;
static ByteArray GenerateHash(const std::string& source, size_t size);
static ByteArray GenerateDeviceToken();
// Same as IsAvailable(), but must be called with mutex_ held.
// Same as IsAvailable(), but must be called with `mutex_` held.
bool IsAvailableLocked() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
// Same as IsAdvertising(), but must be called with mutex_ held.
bool IsAdvertisingLocked(const std::string& service_id)
// Same as IsAdvertising(), but must be called with `mutex_` held.
bool IsAdvertisingLocked(const std::string& service_id) const
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
// Same as IsDiscovering(), but must be called with mutex_ held.
bool IsScanningLocked(const std::string& service_id)
// Same as IsAdvertisingForLegacyDevice(), but must be called with `mutex_`
// held.
bool IsAdvertisingForLegacyDeviceLocked(const std::string& service_id) const
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
// Same as IsAcceptingConnections(), but must be called with mutex_ held.
// Same as IsScanning(), but must be called with `mutex_` held.
bool IsScanningLocked(const std::string& service_id) const
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
// Same as IsListeningForIncomingConnections(), but must be called with
// `mutex_` held.
bool IsAcceptingConnectionsLocked(const std::string& service_id)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
// Same as IsListeningForIncomingConnections(), but must be called with
// `mutex_` held.
bool IsAcceptingL2capConnectionsLocked(const std::string& service_id)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
// Extract connection advertisement from medium advertisement.
ByteArray UnwrapAdvertisementBytes(
const ByteArray& medium_advertisement_data);
bool IsAdvertisementGattServerRunningLocked()
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
bool StartAdvertisementGattServerLocked(const std::string& service_id,
const ByteArray& gatt_advertisement)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
bool GenerateAdvertisementCharacteristic(int slot,
const ByteArray& gatt_advertisement,
GattServer& gatt_server)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
void ProcessFetchGattAdvertisementsRequest(
BlePeripheral peripheral, int num_slots, int psm,
const std::vector<std::string>& interesting_service_ids,
mediums::AdvertisementReadResult& advertisement_read_result)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
bool StopAdvertisementGattServerLocked()
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
ByteArray CreateAdvertisementHeader(int psm,
bool extended_advertisement_advertised)
ABSL_SHARED_LOCKS_REQUIRED(mutex_);
// For devices that don't have extended nor gatt adverting.
api::ble::BleAdvertisementData CreateAdvertisingDataForLegacyDevice();
bool StartAdvertisingLocked(const std::string& service_id)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
bool StartFastAdvertisingLocked(
const std::string& service_id, PowerLevel power_level,
const mediums::BleAdvertisement& medium_advertisement)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
bool StartRegularAdvertisingLocked(
const std::string& service_id, PowerLevel power_level,
const mediums::BleAdvertisement& medium_advertisement)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
bool StartGattAdvertisingLocked(const std::string& service_id,
PowerLevel power_level, int psm,
const ByteArray& medium_advertisement_bytes,
bool extended_advertisement_advertised)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
bool StartDctAdvertisingLocked(const std::string& service_id,
PowerLevel power_level,
const ByteArray& dct_advertisement)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
// Called by StartScanning when using the async methods.
bool StartAsyncScanningLocked(absl::string_view service_id,
PowerLevel power_level)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
// Called by StartScanning when using the async methods.
bool StopAsyncScanningLocked(absl::string_view service_id)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
api::ble::TxPowerLevel PowerLevelToTxPowerLevel(PowerLevel power_level);
void RunOnBleThread(Runnable runnable);
static constexpr int kMaxConcurrentAcceptLoops = 5;
SingleThreadExecutor serial_executor_;
ScheduledExecutor alarm_executor_;
mutable Mutex mutex_;
BluetoothRadio& radio_ ABSL_GUARDED_BY(mutex_);
BluetoothAdapter& adapter_ ABSL_GUARDED_BY(mutex_){
radio_.GetBluetoothAdapter()};
BluetoothAdapter& adapter_ ABSL_GUARDED_BY(mutex_);
BleMedium medium_ ABSL_GUARDED_BY(mutex_){adapter_};
AdvertisingInfo advertising_info_ ABSL_GUARDED_BY(mutex_);
ScanningInfo scanning_info_ ABSL_GUARDED_BY(mutex_);
DiscoveredPeripheralCallback discovered_peripheral_callback_;
AcceptingConnectionsInfo accepting_connections_info_ ABSL_GUARDED_BY(mutex_);
absl::btree_map<std::string, AdvertisingInfo> advertising_infos_
ABSL_GUARDED_BY(mutex_);
std::unique_ptr<GattServer> gatt_server_ ABSL_GUARDED_BY(mutex_);
absl::flat_hash_map<int, std::pair<std::string, ByteArray>>
gatt_advertisements_ ABSL_GUARDED_BY(mutex_);
absl::flat_hash_set<api::ble::GattCharacteristic> hosted_gatt_characteristics_
ABSL_GUARDED_BY(mutex_);
absl::flat_hash_set<std::string> scanned_service_ids_ ABSL_GUARDED_BY(mutex_);
// This map has the same purpose as the set above, but is used only by
// the async StartScanning method.
absl::flat_hash_map<std::string,
std::unique_ptr<api::ble::BleMedium::ScanningSession>>
service_ids_to_scanning_sessions_ ABSL_GUARDED_BY(mutex_);
// Save advertising sessions by service id, used by the async StartAdvertising
// method.
absl::flat_hash_map<std::string,
std::unique_ptr<api::ble::BleMedium::AdvertisingSession>>
service_ids_to_advertising_sessions_ ABSL_GUARDED_BY(mutex_);
std::unique_ptr<CancelableAlarm> lost_alarm_;
mediums::DiscoveredPeripheralTracker discovered_peripheral_tracker_
ABSL_GUARDED_BY(mutex_){medium_.IsExtendedAdvertisementsAvailable()};
// A thread pool dedicated to running all the accept loops from
// StartAcceptingConnections().
MultiThreadExecutor accept_loops_runner_{kMaxConcurrentAcceptLoops};
// A map of service_id -> ServerSocket. If map is non-empty, we
// are currently listening for incoming connections.
absl::flat_hash_map<std::string, BleServerSocket> server_sockets_
ABSL_GUARDED_BY(mutex_);
// Tracks currently connected incoming sockets. This lets the device know when
// it's okay to restart GATT server related operations.
absl::flat_hash_map<std::string, BleSocket> incoming_sockets_
ABSL_GUARDED_BY(mutex_);
mediums::InstantOnLostManager instant_on_lost_manager_;
// A map of service_id -> L2capServerSocket. If map is non-empty, we
// are currently listening for incoming connections.
absl::flat_hash_map<std::string, BleL2capServerSocket> l2cap_server_sockets_
ABSL_GUARDED_BY(mutex_);
// A map of service_id -> BleL2capSocket.
// Tracks currently connected incoming sockets. This lets the device know when
// it's okay to restart L2CAP server related operations.
absl::flat_hash_map<std::string, BleL2capSocket>
l2cap_incoming_service_id_to_sockets_ ABSL_GUARDED_BY(mutex_);
};
} // namespace connections
@@ -45,7 +45,7 @@ cc_library(
],
deps = [
"//internal/platform:base",
"//internal/platform:types",
"//internal/platform:logging",
"@aappleby_smhasher//:libmurmur3",
"@com_google_absl//absl/numeric:int128",
"@com_google_absl//absl/strings",
@@ -53,7 +53,53 @@ cc_library(
)
cc_library(
name = "ble_v2",
name = "ble_socket",
srcs = ["ble_socket.cc"],
hdrs = ["ble_socket.h"],
visibility = [
"//connections/implementation:__subpackages__",
"//internal/platform/implementation/windows:__pkg__",
],
deps = [
":ble",
"//connections/implementation/flags:connections_flags",
"//internal/flags:nearby_flags",
"//internal/platform:base",
"//internal/platform:comm",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform:util",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/synchronization",
],
)
cc_test(
name = "ble_socket_test",
srcs = ["ble_socket_test.cc"],
deps = [
":ble",
":ble_socket",
"//connections/implementation/flags:connections_flags",
"//internal/flags:nearby_flags",
"//internal/platform:base",
"//internal/platform:comm",
"//internal/platform:util",
"//internal/platform/implementation:comm",
"//internal/platform/implementation/g3", # buildcleaner: keep
"//proto:connections_enums_cc_proto",
"@com_github_protobuf_matchers//protobuf-matchers",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest_main",
],
)
cc_library(
name = "ble",
srcs = [
"advertisement_read_result.cc",
"ble_advertisement.cc",
@@ -92,6 +138,7 @@ cc_library(
"//internal/flags:nearby_flags",
"//internal/platform:base",
"//internal/platform:comm",
"//internal/platform:logging",
"//internal/platform:types",
"//internal/platform:util",
"//internal/platform:uuid",
@@ -111,7 +158,7 @@ cc_library(
)
cc_test(
name = "ble_v2_test",
name = "ble_test",
srcs = [
"advertisement_read_result_test.cc",
"ble_advertisement_header_test.cc",
@@ -125,16 +172,16 @@ cc_test(
"instant_on_lost_manager_test.cc",
],
deps = [
":ble",
":ble_advertisement_header",
":ble_v2",
":bloom_filter",
"//connections/implementation:types",
"//connections/implementation/flags:connections_flags",
"//connections/implementation/mediums:utils",
"//connections/implementation/mediums/advertisements:dct_advertisement",
"//internal/flags:nearby_flags",
"//internal/platform:base",
"//internal/platform:comm",
"//internal/platform:logging",
"//internal/platform:mac_address",
"//internal/platform:test_util",
"//internal/platform:types",
@@ -142,12 +189,13 @@ cc_test(
"//internal/platform/implementation:comm",
"//internal/platform/implementation/g3", # buildcleaner: keep
"//internal/test",
"//proto/mediums:ble_frames_cc_proto",
"@com_github_protobuf_matchers//protobuf-matchers",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/hash:hash_testing",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/time",
"@com_google_googletest//:gtest_main",
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "connections/implementation/mediums/ble_v2/advertisement_read_result.h"
#include "connections/implementation/mediums/ble/advertisement_read_result.h"
#include <algorithm>
#include <vector>

Some files were not shown because too many files have changed in this diff Show More