mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Deprecate enable_payload_received_ack flag.
PiperOrigin-RevId: 865529732
This commit is contained in:
committed by
Copybara-Service
parent
5888be0903
commit
26f03a641c
@@ -227,7 +227,6 @@ 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",
|
||||
|
||||
@@ -137,6 +137,7 @@ 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::
|
||||
@@ -145,6 +146,10 @@ 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,
|
||||
@@ -182,9 +187,7 @@ class EndpointManagerTest : public ::testing::Test {
|
||||
EXPECT_TRUE(done.Await(absl::Milliseconds(1000)).result());
|
||||
}
|
||||
}
|
||||
SetSafeToDisconnect set_safe_to_disconnect_{/*safe_to_disconnect=*/true,
|
||||
/*auto_reconnect=*/false,
|
||||
/*safe_to_disconnect_version=*/5};
|
||||
SetSafeToDisconnect set_safe_to_disconnect_{true, false, true, 5};
|
||||
std::unique_ptr<ClientProxy> client_ = std::make_unique<ClientProxy>();
|
||||
ConnectionOptions connection_options_{
|
||||
.keep_alive_interval_millis = 5000,
|
||||
|
||||
@@ -77,6 +77,9 @@ constexpr auto kEnableNearbyConnectionsPreferences =
|
||||
// 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 safe-to-disconnect feature.
|
||||
constexpr auto kEnableSafeToDisconnect =
|
||||
flags::Flag<bool>(kConfigPackage, "45425789", false);
|
||||
|
||||
@@ -539,6 +539,18 @@ void PayloadManager::OnIncomingFrame(OfflineFrame& offline_frame,
|
||||
// Block any payload before the connection been accepted by both sides
|
||||
// to prevent unauthorized transfer.
|
||||
if (!to_client->IsConnectedToEndpoint(from_endpoint_id)) {
|
||||
if (frame.packet_type() == PayloadTransferFrame::DATA) {
|
||||
PendingPayloadHandle pending_payload =
|
||||
pending_payloads_.GetPayload(frame.payload_header().id());
|
||||
bool is_last = IsLastChunk(frame.payload_chunk());
|
||||
// If payload need to be ack'd receiving, then send back the ACK frame.
|
||||
if (pending_payload && is_last &&
|
||||
IsPayloadReceivedAckEnabled(to_client, from_endpoint_id,
|
||||
*pending_payload)) {
|
||||
SendPayloadReceivedAck(to_client, *pending_payload, from_endpoint_id,
|
||||
is_last);
|
||||
}
|
||||
}
|
||||
VLOG(1) << "PayloadManager skipped process payloads before PCP connected, "
|
||||
<< frame.payload_header().id();
|
||||
return;
|
||||
@@ -909,7 +921,8 @@ void PayloadManager::SendPayloadReceivedAck(ClientProxy* client,
|
||||
PendingPayload& pending_payload,
|
||||
const std::string& endpoint_id,
|
||||
bool is_last_chunk) {
|
||||
if (!is_last_chunk) {
|
||||
if (!is_last_chunk ||
|
||||
!IsPayloadReceivedAckEnabled(client, endpoint_id, pending_payload)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -931,7 +944,8 @@ bool PayloadManager::WaitForReceivedAck(
|
||||
PendingPayload& pending_payload,
|
||||
const PayloadTransferFrame::PayloadHeader& payload_header,
|
||||
std::int64_t payload_chunk_offset, bool is_last_chunk) {
|
||||
if (!is_last_chunk) {
|
||||
if (!is_last_chunk ||
|
||||
!IsPayloadReceivedAckEnabled(client, endpoint_id, pending_payload)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1019,6 +1033,18 @@ bool PayloadManager::WaitForReceivedAck(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PayloadManager::IsPayloadReceivedAckEnabled(
|
||||
ClientProxy* client, const std::string& endpoint_id,
|
||||
PendingPayload& pending_payload) {
|
||||
return NearbyFlags::GetInstance().GetBoolFlag(
|
||||
config_package_nearby::nearby_connections_feature::
|
||||
kEnablePayloadReceivedAck) &&
|
||||
client->IsPayloadReceivedAckEnabled(endpoint_id) &&
|
||||
(pending_payload.GetInternalPayload()->GetType() !=
|
||||
nearby::connections::PayloadTransferFrame::PayloadTransferFrame::
|
||||
PayloadHeader::BYTES);
|
||||
}
|
||||
|
||||
void PayloadManager::HandleFinishedOutgoingPayload(
|
||||
ClientProxy* client, const EndpointIds& finished_endpoint_ids,
|
||||
const PayloadTransferFrame::PayloadHeader& payload_header,
|
||||
|
||||
@@ -367,6 +367,9 @@ class PayloadManager : public EndpointManager::FrameProcessor {
|
||||
const location::nearby::connections::PayloadTransferFrame::PayloadHeader&
|
||||
payload_header,
|
||||
std::int64_t payload_chunk_offset, bool is_last_chunk);
|
||||
bool IsPayloadReceivedAckEnabled(ClientProxy* client,
|
||||
const std::string& endpoint_id,
|
||||
PendingPayload& pending_payload);
|
||||
|
||||
// Handles a finished outgoing payload for the given endpointIds. All
|
||||
// statuses except for SUCCESS are handled here.
|
||||
|
||||
@@ -14,25 +14,11 @@
|
||||
|
||||
#include "connections/implementation/simulation_user.h"
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/functional/bind_front.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "connections/listeners.h"
|
||||
#include "connections/out_of_band_connection_metadata.h"
|
||||
#include "connections/payload.h"
|
||||
#include "connections/status.h"
|
||||
#include "connections/v3/connection_listening_options.h"
|
||||
#include "internal/interop/device.h"
|
||||
#include "internal/platform/byte_array.h"
|
||||
#include "internal/platform/count_down_latch.h"
|
||||
#include "internal/platform/future.h"
|
||||
#include "internal/platform/logging.h"
|
||||
#include "internal/platform/mutex_lock.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace connections {
|
||||
|
||||
@@ -19,36 +19,21 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "connections/advertising_options.h"
|
||||
#include "connections/connection_options.h"
|
||||
#include "connections/discovery_options.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "connections/implementation/bwu_manager.h"
|
||||
#include "connections/implementation/client_proxy.h"
|
||||
#include "connections/implementation/endpoint_channel_manager.h"
|
||||
#include "connections/implementation/endpoint_manager.h"
|
||||
#include "connections/implementation/flags/nearby_connections_feature_flags.h"
|
||||
#include "connections/implementation/injected_bluetooth_device_store.h"
|
||||
#include "connections/implementation/mediums/mediums.h"
|
||||
#include "connections/implementation/payload_manager.h"
|
||||
#include "connections/implementation/pcp_manager.h"
|
||||
#include "connections/listeners.h"
|
||||
#include "connections/medium_selector.h"
|
||||
#include "connections/out_of_band_connection_metadata.h"
|
||||
#include "connections/payload.h"
|
||||
#include "connections/status.h"
|
||||
#include "connections/strategy.h"
|
||||
#include "connections/v3/connection_listening_options.h"
|
||||
#include "connections/v3/connections_device.h"
|
||||
#include "internal/flags/nearby_flags.h"
|
||||
#include "internal/interop/device.h"
|
||||
#include "internal/platform/byte_array.h"
|
||||
#include "internal/platform/condition_variable.h"
|
||||
#include "internal/platform/count_down_latch.h"
|
||||
#include "internal/platform/feature_flags.h"
|
||||
#include "internal/platform/future.h"
|
||||
#include "internal/platform/mutex.h"
|
||||
|
||||
// Test-only class to help run end-to-end simulations for nearby connections
|
||||
// protocol.
|
||||
@@ -62,6 +47,7 @@ namespace connections {
|
||||
class SetSafeToDisconnect {
|
||||
public:
|
||||
explicit 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::
|
||||
@@ -70,6 +56,10 @@ 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,
|
||||
@@ -88,13 +78,10 @@ class SimulationUser {
|
||||
void Clear() { endpoint_id.clear(); }
|
||||
};
|
||||
|
||||
explicit SimulationUser(
|
||||
const std::string& device_name,
|
||||
BooleanMediumSelector allowed = BooleanMediumSelector(),
|
||||
SetSafeToDisconnect set_safe_to_disconnect =
|
||||
SetSafeToDisconnect(/*safe_to_disconnect=*/true,
|
||||
/*auto_reconnect=*/false,
|
||||
/*safe_to_disconnect_version=*/5))
|
||||
SimulationUser(const std::string& device_name,
|
||||
BooleanMediumSelector allowed = BooleanMediumSelector(),
|
||||
SetSafeToDisconnect set_safe_to_disconnect =
|
||||
SetSafeToDisconnect(true, false, true, 5))
|
||||
: info_{ByteArray{device_name}},
|
||||
advertising_options_{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user