From f727d00ad1cd2e4c8b0138424d7fda0d9eedc19a Mon Sep 17 00:00:00 2001 From: Anay Wadhera Date: Fri, 19 May 2023 12:13:01 -0700 Subject: [PATCH] Create v3 ConnectionResponseInfo PiperOrigin-RevId: 533518921 --- connections/v3/BUILD | 2 +- ...ection_resolution.h => connection_result.h} | 18 +++++++++++++++--- connections/v3/listeners.h | 7 ++++--- 3 files changed, 20 insertions(+), 7 deletions(-) rename connections/v3/{connection_resolution.h => connection_result.h} (58%) diff --git a/connections/v3/BUILD b/connections/v3/BUILD index 26afa091..554d9d10 100644 --- a/connections/v3/BUILD +++ b/connections/v3/BUILD @@ -3,7 +3,7 @@ cc_library( hdrs = [ "bandwidth_info.h", "connection_listening_options.h", - "connection_resolution.h", + "connection_result.h", "connections_device.h", "connections_device_provider.h", "listeners.h", diff --git a/connections/v3/connection_resolution.h b/connections/v3/connection_result.h similarity index 58% rename from connections/v3/connection_resolution.h rename to connections/v3/connection_result.h index 18b361c5..dc45efb8 100644 --- a/connections/v3/connection_resolution.h +++ b/connections/v3/connection_result.h @@ -12,8 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef THIRD_PARTY_NEARBY_CONNECTIONS_V3_CONNECTION_RESOLUTION_H_ -#define THIRD_PARTY_NEARBY_CONNECTIONS_V3_CONNECTION_RESOLUTION_H_ +#ifndef THIRD_PARTY_NEARBY_CONNECTIONS_V3_CONNECTION_RESULT_H_ +#define THIRD_PARTY_NEARBY_CONNECTIONS_V3_CONNECTION_RESULT_H_ + +#include #include "connections/status.h" @@ -25,8 +27,18 @@ struct ConnectionResult { nearby::connections::Status status; }; +// These fields should never be empty. +struct InitialConnectionInfo { + // 4-digit authentication code shown to user derived by UKEY2. + std::string authentication_digits; + // Raw 32-byte authentication token derived by UKEY2. + std::string raw_authentication_token; + // Specifies if the connection is incoming or outgoing. + bool is_incoming_connection = false; +}; + } // namespace v3 } // namespace connections } // namespace nearby -#endif // THIRD_PARTY_NEARBY_CONNECTIONS_V3_CONNECTION_RESOLUTION_H_ +#endif // THIRD_PARTY_NEARBY_CONNECTIONS_V3_CONNECTION_RESULT_H_ diff --git a/connections/v3/listeners.h b/connections/v3/listeners.h index 10d44509..01f985e3 100644 --- a/connections/v3/listeners.h +++ b/connections/v3/listeners.h @@ -18,7 +18,7 @@ #include "absl/functional/any_invocable.h" #include "connections/listeners.h" #include "connections/v3/bandwidth_info.h" -#include "connections/v3/connection_resolution.h" +#include "connections/v3/connection_result.h" #include "internal/interop/device.h" namespace nearby { @@ -44,8 +44,9 @@ struct ConnectionListener { // remote_device - The identifier for the remote endpoint. // info - Other relevant information about the connection. absl::AnyInvocable - initiated_cb = [](const NearbyDevice&, const ConnectionResponseInfo&) {}; + const v3::InitialConnectionInfo& info)> + initiated_cb = + [](const NearbyDevice&, const v3::InitialConnectionInfo&) {}; // Called when both sides have accepted or either side has rejected the // connection. If the {@link ConnectionResolution}'s status is {@link