Implement Safe to Disconnect feature

PiperOrigin-RevId: 560119556
This commit is contained in:
hai007
2023-08-25 09:51:44 -07:00
committed by Copybara-Service
parent 965cc0ecbc
commit 55aedfb235
27 changed files with 1052 additions and 178 deletions
+17
View File
@@ -267,6 +267,20 @@ class ClientProxy final {
connections_device_provider_ = std::move(provider);
}
const bool& IsSupportSafeToDisconnect() const {
return supports_safe_to_disconnect_;
}
const std::int32_t& GetLocalSafeToDisconnectVersion() const {
return local_safe_to_disconnect_version_;
}
std::optional<std::int32_t> GetRemoteSafeToDisconnectVersion(
absl::string_view endpoint_id) const;
void SetRemoteSafeToDisconnectVersion(
absl::string_view endpoint_id,
const std::int32_t& safe_to_disconnect_version);
bool IsSafeToDisconnectEnabled(absl::string_view endpoint_id);
bool IsPayloadReceivedAckEnabled(absl::string_view endpoint_id);
private:
struct Connection {
// Status: may be either:
@@ -296,6 +310,7 @@ class ClientProxy final {
AdvertisingOptions advertising_options;
std::string connection_token;
std::optional<location::nearby::connections::OsInfo> os_info;
std::int32_t safe_to_disconnect_version;
};
using ConnectionPair = std::pair<Connection, PayloadListener>;
@@ -427,6 +442,8 @@ class ClientProxy final {
NearbyDeviceProvider* external_device_provider_ = nullptr;
// For Nearby Connections' own device provider.
std::unique_ptr<v3::ConnectionsDeviceProvider> connections_device_provider_;
bool supports_safe_to_disconnect_;
std::int32_t local_safe_to_disconnect_version_;
};
} // namespace connections