diff --git a/sharing/BUILD b/sharing/BUILD index 8c7986c7..b666406e 100644 --- a/sharing/BUILD +++ b/sharing/BUILD @@ -657,6 +657,7 @@ cc_test( ":transfer_metadata", ":transfer_metadata_matchers", ":types", + "//google/protobuf:timestamp_cc_proto", "//internal/base:file_path", "//internal/base:files", "//internal/flags:nearby_flags", diff --git a/sharing/nearby_sharing_service_impl.cc b/sharing/nearby_sharing_service_impl.cc index 9d63cea3..2e4c9211 100644 --- a/sharing/nearby_sharing_service_impl.cc +++ b/sharing/nearby_sharing_service_impl.cc @@ -2860,8 +2860,14 @@ void NearbySharingServiceImpl::OnPeerSyncBindingComplete( kJoinBindingTimeLifeTime); } } - // Download public certificates again to update the newly added sync binding. - certificate_manager_->DownloadPublicCertificates(); + // TODO: Remove this check after BE supports cert download without join time. + // Without join time, the new download can overwrite the bindings we added + // from the binding response. + if (binding_response.has_join_binding_time()) { + // Download public certificates again to update the newly added sync + // binding. + certificate_manager_->DownloadPublicCertificates(); + } } void NearbySharingServiceImpl::OnReceivedIntroduction( diff --git a/sharing/nearby_sharing_service_impl_test.cc b/sharing/nearby_sharing_service_impl_test.cc index a9ab39be..7c71d8b4 100644 --- a/sharing/nearby_sharing_service_impl_test.cc +++ b/sharing/nearby_sharing_service_impl_test.cc @@ -30,6 +30,7 @@ #include #include +#include "google/protobuf/timestamp.pb.h" #include "location/nearby/analytics/cpp/logging/mock_event_logger.h" #include "location/nearby/sharing/lib/account/fake_account_manager.h" #include "location/nearby/sharing/lib/account/mock_account_observer.h" @@ -5235,10 +5236,11 @@ TEST_F(NearbySharingServiceImplTest, InitiatePairingSuccess) { binding_response_frame.set_version(Frame::V1); binding_response_frame.mutable_v1()->set_type( service::proto::V1Frame::BINDINGS); - binding_response_frame.mutable_v1() + auto* binding_response = binding_response_frame.mutable_v1() ->mutable_bindings() - ->mutable_binding_response() - ->set_status(service::proto::BindingResponse::SUCCESS); + ->mutable_binding_response(); + binding_response->set_status(service::proto::BindingResponse::SUCCESS); + binding_response->mutable_join_binding_time()->set_seconds(1234567890); std::vector result_bytes(binding_response_frame.ByteSizeLong()); binding_response_frame.SerializeToArray(result_bytes.data(), result_bytes.size());