Cleanup unnecessary files and classes.

PiperOrigin-RevId: 823206305
This commit is contained in:
Francis Tsui
2025-10-23 15:15:43 -07:00
committed by Copybara-Service
parent 59a038a0c3
commit 9ccfded727
15 changed files with 92 additions and 329 deletions
+1 -2
View File
@@ -366,6 +366,7 @@ cc_library(
"//sharing/common",
"//sharing/common:enum",
"//sharing/contacts",
"//sharing/contacts:contacts_interface",
"//sharing/fast_initiation:nearby_fast_initiation",
"//sharing/flags/generated:generated_flags",
"//sharing/internal/api:platform",
@@ -612,14 +613,12 @@ cc_test(
"//sharing/certificates:test_support",
"//sharing/common",
"//sharing/common:enum",
"//sharing/contacts",
"//sharing/contacts:test_support",
"//sharing/fast_initiation:nearby_fast_initiation",
"//sharing/fast_initiation:test_support",
"//sharing/flags/generated:generated_flags",
"//sharing/internal/api:mock_sharing_platform",
"//sharing/internal/api:platform",
"//sharing/internal/public:types",
"//sharing/internal/test:nearby_test",
"//sharing/local_device_data",
"//sharing/local_device_data:test_support",
+1 -2
View File
@@ -124,13 +124,12 @@ cc_test(
":test_support",
"//internal/platform:mac_address",
"//internal/platform/implementation:account_manager",
"//internal/platform/implementation:platform_impl", # fixdeps: keep
"//internal/platform/implementation:platform_impl",
"//internal/test",
"//proto/identity/v1:resources_cc_proto",
"//proto/identity/v1:rpcs_cc_proto",
"//sharing/common",
"//sharing/common:enum",
"//sharing/contacts:test_support",
"//sharing/internal/api:mock_sharing_platform",
"//sharing/internal/api:platform",
"//sharing/internal/public:pref_names",
@@ -48,7 +48,6 @@
#include "sharing/certificates/nearby_share_encrypted_metadata_key.h"
#include "sharing/certificates/nearby_share_private_certificate.h"
#include "sharing/certificates/test_util.h"
#include "sharing/contacts/fake_nearby_share_contact_manager.h"
#include "sharing/internal/api/fake_nearby_share_client.h"
#include "sharing/internal/api/mock_sharing_platform.h"
#include "sharing/internal/public/pref_names.h"
@@ -114,7 +113,6 @@ class NearbyShareCertificateManagerImplTest
local_device_data_manager_ =
std::make_unique<FakeNearbyShareLocalDeviceDataManager>(
kDefaultDeviceName);
contact_manager_ = std::make_unique<FakeNearbyShareContactManager>();
AccountManager::Account account{
.display_name = GetNearbyShareTestMetadata().full_name(),
@@ -501,7 +499,6 @@ class NearbyShareCertificateManagerImplTest
FakeNearbyShareCertificateStorage::Factory cert_store_factory_;
std::unique_ptr<FakeNearbyShareLocalDeviceDataManager>
local_device_data_manager_;
std::unique_ptr<FakeNearbyShareContactManager> contact_manager_;
std::unique_ptr<NearbyShareCertificateManager> cert_manager_;
};
+15 -35
View File
@@ -17,60 +17,49 @@ load("@rules_cc//cc:cc_test.bzl", "cc_test")
licenses(["notice"])
cc_library(
name = "contacts_interface",
hdrs = [
"nearby_share_contact_manager.h",
],
visibility = ["//visibility:public"],
deps = [
"//sharing/proto:share_cc_proto",
"@com_google_absl//absl/functional:any_invocable",
"@com_google_absl//absl/status:statusor",
],
)
cc_library(
name = "contacts",
srcs = [
"nearby_share_contact_manager.cc",
"nearby_share_contact_manager_impl.cc",
],
hdrs = [
"nearby_share_contact_manager.h",
"nearby_share_contact_manager_impl.h",
],
visibility = ["//visibility:public"],
deps = [
"//internal/base",
"//internal/crypto_cros",
"//internal/flags:nearby_flags",
":contacts_interface",
"//internal/platform:types",
"//internal/platform/implementation:account_manager",
"//sharing/common",
"//sharing/flags/generated:generated_flags",
"//sharing/internal/api:platform",
"//sharing/internal/base",
"//sharing/internal/public:logging",
"//sharing/internal/public:types",
"//sharing/local_device_data",
"//sharing/proto:share_cc_proto",
"//sharing/scheduling",
"@com_google_absl//absl/functional:any_invocable",
"@com_google_absl//absl/functional:bind_front",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/time",
],
)
cc_library(
name = "test_support",
testonly = True,
srcs = [
"fake_nearby_share_contact_manager.cc",
],
hdrs = [
"fake_nearby_share_contact_manager.h",
],
visibility = ["//visibility:public"],
deps = [
":contacts",
"//internal/platform/implementation:account_manager",
"//internal/platform/implementation:types",
"//sharing/internal/api:platform",
"//sharing/internal/public:types",
"//sharing/local_device_data",
],
deps = [":contacts_interface"],
)
cc_test(
@@ -83,20 +72,11 @@ cc_test(
"//internal/platform/implementation:account_manager",
"//internal/platform/implementation:platform_impl",
"//internal/test",
"//sharing/common",
"//sharing/internal/api:mock_sharing_platform",
"//sharing/internal/api:platform",
"//sharing/internal/test:nearby_test",
"//sharing/local_device_data:test_support",
"//sharing/proto:share_cc_proto",
"//sharing/scheduling",
"//sharing/scheduling:test_support",
"@com_github_protobuf_matchers//protobuf-matchers",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/time",
"@com_google_googletest//:gtest_main",
],
@@ -1,52 +0,0 @@
// Copyright 2021-2023 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 "sharing/contacts/fake_nearby_share_contact_manager.h"
#include <memory>
#include <vector>
#include "internal/platform/implementation/account_manager.h"
#include "sharing/contacts/nearby_share_contact_manager.h"
#include "sharing/internal/api/sharing_rpc_client.h"
#include "sharing/internal/public/context.h"
namespace nearby {
namespace sharing {
FakeNearbyShareContactManager::Factory::Factory() = default;
FakeNearbyShareContactManager::Factory::~Factory() = default;
std::unique_ptr<NearbyShareContactManager>
FakeNearbyShareContactManager::Factory::CreateInstance(
Context* context, AccountManager& account_manager,
nearby::sharing::api::SharingRpcClientFactory* nearby_client_factory) {
latest_nearby_client_factory_ = nearby_client_factory;
latest_account_manager_ = &account_manager;
auto instance = std::make_unique<FakeNearbyShareContactManager>();
instances_.push_back(instance.get());
return instance;
}
FakeNearbyShareContactManager::FakeNearbyShareContactManager() = default;
FakeNearbyShareContactManager::~FakeNearbyShareContactManager() = default;
void FakeNearbyShareContactManager::GetContacts(ContactsCallback callback) {}
} // namespace sharing
} // namespace nearby
@@ -15,68 +15,19 @@
#ifndef THIRD_PARTY_NEARBY_SHARING_CONTACTS_FAKE_NEARBY_SHARE_CONTACT_MANAGER_H_
#define THIRD_PARTY_NEARBY_SHARING_CONTACTS_FAKE_NEARBY_SHARE_CONTACT_MANAGER_H_
#include <stddef.h>
#include <memory>
#include <vector>
#include "internal/platform/implementation/account_manager.h"
#include "sharing/contacts/nearby_share_contact_manager.h"
#include "sharing/contacts/nearby_share_contact_manager_impl.h"
#include "sharing/internal/api/sharing_rpc_client.h"
#include "sharing/internal/public/context.h"
namespace nearby {
namespace sharing {
// A fake implementation of NearbyShareContactManager, along with a fake
// factory, to be used in tests. Stores parameters input into
// NearbyShareContactManager method calls. Use the notification methods from the
// base class--NotifyContactsDownloaded() and NotifyContactsUploaded()--to alert
// observers of changes; these methods are made public in this fake class.
// A fake implementation of NearbyShareContactManager.
class FakeNearbyShareContactManager : public NearbyShareContactManager {
public:
// Factory that creates FakeNearbyShareContactManager instances. Use in
// NearbyShareContactManagerImpl::Factor::SetFactoryForTesting() in unit
// tests.
class Factory : public NearbyShareContactManagerImpl::Factory {
public:
Factory();
~Factory() override;
// Returns all FakeNearbyShareContactManager instances created by
// CreateInstance().
std::vector<FakeNearbyShareContactManager*>& instances() {
return instances_;
}
nearby::sharing::api::SharingRpcClientFactory* latest_http_client_factory()
const {
return latest_nearby_client_factory_;
}
AccountManager* latest_account_manager() const {
return latest_account_manager_;
}
private:
// NearbyShareContactManagerImpl::Factory:
std::unique_ptr<NearbyShareContactManager> CreateInstance(
Context* context, AccountManager& account_manager,
nearby::sharing::api::SharingRpcClientFactory* nearby_client_factory)
override;
std::vector<FakeNearbyShareContactManager*> instances_;
nearby::sharing::api::SharingRpcClientFactory*
latest_nearby_client_factory_ = nullptr;
AccountManager* latest_account_manager_ = nullptr;
};
FakeNearbyShareContactManager();
~FakeNearbyShareContactManager() override;
FakeNearbyShareContactManager() = default;
~FakeNearbyShareContactManager() override = default;
private:
void GetContacts(ContactsCallback callback) override;
void GetContacts(ContactsCallback callback) override {};
};
} // namespace sharing
@@ -1,29 +0,0 @@
// Copyright 2021-2023 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 "sharing/contacts/nearby_share_contact_manager.h"
#include <stdint.h>
#include "sharing/proto/rpc_resources.pb.h"
namespace nearby {
namespace sharing {
NearbyShareContactManager::NearbyShareContactManager() = default;
NearbyShareContactManager::~NearbyShareContactManager() = default;
} // namespace sharing
} // namespace nearby
@@ -26,27 +26,15 @@
namespace nearby {
namespace sharing {
// The Nearby Share contacts manager interfaces with the Nearby server in the
// following ways:
// 1) The user's contacts are downloaded from People API, using the Nearby
// server as a proxy.
// 2) All the user's contacts are uploaded to Nearby server, along with an
// indication of what contacts are allowed for selected-contacts visibility
// mode. The Nearby server will distribute all-contacts visibility
// certificates accordingly. For privacy reasons, the Nearby server needs to
// explicitly receive the list of contacts from the device instead of pulling
// them directly from People API.
//
// All contact data and update notifications are conveyed via observer methods;
// the manager does not return data directly from function calls.
// The Nearby Share contacts manager retrieves the user's contact list from the
// server.
class NearbyShareContactManager {
public:
using ContactsCallback = absl::AnyInvocable<
void(absl::StatusOr<std::vector<nearby::sharing::proto::ContactRecord>>,
uint32_t num_unreachable_contacts_filtered_out) &&>;
NearbyShareContactManager();
virtual ~NearbyShareContactManager();
virtual ~NearbyShareContactManager() = default;
// Retrieves the user's contact list from the server.
virtual void GetContacts(ContactsCallback callback) = 0;
@@ -23,7 +23,6 @@
#include <utility>
#include <vector>
#include "absl/memory/memory.h"
#include "absl/status/statusor.h"
#include "absl/synchronization/notification.h"
#include "internal/platform/implementation/account_manager.h"
@@ -42,53 +41,32 @@ using ::nearby::sharing::proto::ContactRecord;
using ::nearby::sharing::proto::ListContactPeopleRequest;
using ::nearby::sharing::proto::ListContactPeopleResponse;
void FilterOutUnreachableContacts(std::vector<ContactRecord>& contacts) {
contacts.erase(
std::remove_if(contacts.begin(), contacts.end(),
[](const nearby::sharing::proto::ContactRecord& contact) {
return !contact.is_reachable();
}),
contacts.end());
}
// Class for maintaining a single instance of contacts download request. It
// is responsible for downloading all available pages and making the results
// or error available.
class ContactDownloadContext {
public:
ContactDownloadContext(
nearby::sharing::api::SharingRpcClient* nearby_share_client,
NearbyShareContactManager::ContactsCallback download_callback)
: nearby_share_client_(nearby_share_client),
download_callback_(std::move(download_callback)) {}
} // namespace
// Fetches the next page of contacts.
// If |next_page_token_| is empty, it fetches the first page.
// On successful download, if page token in the response is empty, the
// |download_callback_| is invoked with all downloaded contacts.
void FetchNextPage();
// static
NearbyShareContactManagerImpl::Factory*
NearbyShareContactManagerImpl::Factory::test_factory_ = nullptr;
private:
nearby::sharing::api::SharingRpcClient* const nearby_share_client_;
std::optional<std::string> next_page_token_;
int page_number_ = 1;
std::vector<ContactRecord> contacts_;
NearbyShareContactManager::ContactsCallback download_callback_;
};
// static
std::unique_ptr<NearbyShareContactManager>
NearbyShareContactManagerImpl::Factory::Create(
Context* context, AccountManager& account_manager,
nearby::sharing::api::SharingRpcClientFactory* nearby_client_factory) {
if (test_factory_) {
return test_factory_->CreateInstance(context, account_manager,
nearby_client_factory);
}
return absl::WrapUnique(new NearbyShareContactManagerImpl(
context, account_manager, nearby_client_factory));
}
// static
void NearbyShareContactManagerImpl::Factory::SetFactoryForTesting(
Factory* test_factory) {
test_factory_ = test_factory;
}
NearbyShareContactManagerImpl::Factory::~Factory() = default;
NearbyShareContactManagerImpl::NearbyShareContactManagerImpl(
Context* context, AccountManager& account_manager,
nearby::sharing::api::SharingRpcClientFactory* nearby_client_factory)
: account_manager_(account_manager),
nearby_share_client_(nearby_client_factory->CreateInstance()),
executor_(context->CreateSequencedTaskRunner()) {}
NearbyShareContactManagerImpl::~NearbyShareContactManagerImpl() = default;
void NearbyShareContactManagerImpl::ContactDownloadContext::FetchNextPage() {
void ContactDownloadContext::FetchNextPage() {
LOG(INFO) << "Downloading contacts page=" << page_number_++;
ListContactPeopleRequest request;
if (next_page_token_.has_value()) {
@@ -112,7 +90,12 @@ void NearbyShareContactManagerImpl::ContactDownloadContext::FetchNextPage() {
// We should filter here because we only care about contacts that we
// can share with.
uint32_t contacts_size = contacts_.size();
FilterOutUnreachableContacts(contacts_);
// Filter out unreachable contacts.
contacts_.erase(std::remove_if(contacts_.begin(), contacts_.end(),
[](const ContactRecord& contact) {
return !contact.is_reachable();
}),
contacts_.end());
uint32_t num_unreachable_contacts_filtered_out =
contacts_size - contacts_.size();
std::move(download_callback_)(std::move(contacts_),
@@ -125,6 +108,15 @@ void NearbyShareContactManagerImpl::ContactDownloadContext::FetchNextPage() {
});
}
} // namespace
NearbyShareContactManagerImpl::NearbyShareContactManagerImpl(
Context* context, AccountManager& account_manager,
nearby::sharing::api::SharingRpcClientFactory* nearby_client_factory)
: account_manager_(account_manager),
nearby_share_client_(nearby_client_factory->CreateInstance()),
executor_(context->CreateSequencedTaskRunner()) {}
void NearbyShareContactManagerImpl::GetContacts(ContactsCallback callback) {
executor_->PostTask([this, callback = std::move(callback)]() mutable {
LOG(INFO) << "Start downloading contacts";
@@ -15,94 +15,26 @@
#ifndef THIRD_PARTY_NEARBY_SHARING_CONTACTS_NEARBY_SHARE_CONTACT_MANAGER_IMPL_H_
#define THIRD_PARTY_NEARBY_SHARING_CONTACTS_NEARBY_SHARE_CONTACT_MANAGER_IMPL_H_
#include <stdint.h>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "internal/platform/implementation/account_manager.h"
#include "internal/platform/task_runner.h"
#include "sharing/contacts/nearby_share_contact_manager.h"
#include "sharing/internal/api/sharing_rpc_client.h"
#include "sharing/internal/public/context.h"
#include "sharing/proto/rpc_resources.pb.h"
namespace nearby {
namespace sharing {
// Implementation of NearbyShareContactManager that persists the set of allowed
// contact IDs--for selected-contacts visibility mode--in prefs. Other
// contact data is downloaded from People API, via the NearbyShare server, as
// needed.
//
// The Nearby Share server must be explicitly informed of all contacts this
// device is aware of--needed for all-contacts visibility mode--as well as what
// contacts are allowed for selected-contacts visibility mode. These uploaded
// contact lists are used by the server to distribute the device's public
// certificates accordingly. This implementation persists a hash of the last
// uploaded contact data, and after every contacts download, a subsequent upload
// request is made if we detect that the contact list or allowlist has changed
// since the last successful upload. We also schedule periodic contact uploads
// just in case the server removed the record.
//
// In addition to supporting on-demand contact downloads, this implementation
// periodically checks in with the Nearby Share server to see if the user's
// contact list has changed since the last upload.
class NearbyShareContactManagerImpl : public NearbyShareContactManager {
public:
class Factory {
public:
static std::unique_ptr<NearbyShareContactManager> Create(
Context* context, AccountManager& account_manager,
nearby::sharing::api::SharingRpcClientFactory* nearby_client_factory);
static void SetFactoryForTesting(Factory* test_factory);
protected:
virtual ~Factory();
virtual std::unique_ptr<NearbyShareContactManager> CreateInstance(
Context* context, AccountManager& account_manager,
nearby::sharing::api::SharingRpcClientFactory*
nearby_client_factory) = 0;
private:
static Factory* test_factory_;
};
~NearbyShareContactManagerImpl() override;
private:
// Class for maintaining a single instance of contacts download request. It
// is responsible for downloading all available pages and making the results
// or error available.
class ContactDownloadContext {
public:
ContactDownloadContext(
nearby::sharing::api::SharingRpcClient* nearby_share_client,
ContactsCallback download_callback)
: nearby_share_client_(nearby_share_client),
download_callback_(std::move(download_callback)) {}
// Fetches the next page of contacts.
// If |next_page_token_| is empty, it fetches the first page.
// On successful download, if page token in the response is empty, the
// |download_callback_| is invoked with all downloaded contacts.
void FetchNextPage();
private:
nearby::sharing::api::SharingRpcClient* const nearby_share_client_;
std::optional<std::string> next_page_token_;
int page_number_ = 1;
std::vector<nearby::sharing::proto::ContactRecord> contacts_;
ContactsCallback download_callback_;
};
NearbyShareContactManagerImpl(
Context* context, AccountManager& account_manager,
nearby::sharing::api::SharingRpcClientFactory* nearby_client_factory);
~NearbyShareContactManagerImpl() override = default;
private:
// NearbyShareContactsManager:
void GetContacts(ContactsCallback callback) override;
@@ -26,14 +26,11 @@
#include "absl/time/time.h"
#include "internal/platform/implementation/account_manager.h"
#include "internal/test/fake_account_manager.h"
#include "sharing/contacts/nearby_share_contact_manager.h"
#include "sharing/internal/api/fake_nearby_share_client.h"
#include "sharing/internal/test/fake_context.h"
#include "sharing/local_device_data/fake_nearby_share_local_device_data_manager.h"
#include "sharing/proto/contact_rpc.pb.h"
#include "sharing/proto/rpc_resources.pb.h"
#include "sharing/scheduling/fake_nearby_share_scheduler_factory.h"
#include "sharing/scheduling/nearby_share_scheduler_factory.h"
namespace nearby::sharing {
namespace {
@@ -61,19 +58,17 @@ class NearbyShareContactManagerImplTest
~NearbyShareContactManagerImplTest() override = default;
void SetUp() override {
NearbyShareSchedulerFactory::SetFactoryForTesting(&scheduler_factory_);
AccountManager::Account account;
account.id = kTestAccountId;
account.email = kTestProfileUserName;
fake_account_manager_.SetAccount(account);
manager_ = NearbyShareContactManagerImpl::Factory::Create(
manager_ = std::make_unique<NearbyShareContactManagerImpl>(
&fake_context_, fake_account_manager_, &nearby_client_factory_);
}
void TearDown() override {
manager_.reset();
NearbyShareSchedulerFactory::SetFactoryForTesting(nullptr);
}
void Sync() {
@@ -101,8 +96,7 @@ class NearbyShareContactManagerImplTest
FakeNearbyShareClientFactory nearby_client_factory_;
FakeNearbyShareLocalDeviceDataManager local_device_data_manager_;
std::unique_ptr<FakeAccountManager> account_manager_;
FakeNearbyShareSchedulerFactory scheduler_factory_;
std::unique_ptr<NearbyShareContactManager> manager_;
std::unique_ptr<NearbyShareContactManagerImpl> manager_;
};
} // namespace
+12 -2
View File
@@ -14,13 +14,13 @@
#include "sharing/nearby_sharing_service_factory.h"
#include <cstdint>
#include <memory>
#include <utility>
#include "internal/analytics/event_logger.h"
#include "internal/platform/task_runner.h"
#include "sharing/analytics/analytics_recorder.h"
#include "sharing/contacts/nearby_share_contact_manager_impl.h"
#include "sharing/internal/api/sharing_platform.h"
#include "sharing/internal/public/context_impl.h"
#include "sharing/nearby_connections_manager_factory.h"
@@ -54,9 +54,19 @@ NearbySharingService* NearbySharingServiceFactory::CreateSharingService(
service_thread.get(), context_.get(),
sharing_platform.GetDeviceInfo(), event_logger);
auto nearby_share_client_factory =
sharing_platform.CreateSharingRpcClientFactory(context_->GetClock(),
analytics_recorder);
auto nearby_share_contact_manager =
std::make_unique<NearbyShareContactManagerImpl>(
context_.get(), sharing_platform.GetAccountManager(),
nearby_share_client_factory.get());
nearby_sharing_service_ = std::make_unique<NearbySharingServiceImpl>(
std::move(service_thread), context_.get(), sharing_platform,
std::move(nearby_connections_manager), analytics_recorder);
std::move(nearby_share_client_factory),
std::move(nearby_connections_manager),
std::move(nearby_share_contact_manager), analytics_recorder);
return nearby_sharing_service_.get();
}
+6 -6
View File
@@ -63,7 +63,6 @@
#include "sharing/common/nearby_share_prefs.h"
#include "sharing/constants.h"
#include "sharing/contacts/nearby_share_contact_manager.h"
#include "sharing/contacts/nearby_share_contact_manager_impl.h"
#include "sharing/fast_initiation/nearby_fast_initiation.h"
#include "sharing/fast_initiation/nearby_fast_initiation_impl.h"
#include "sharing/file_attachment.h"
@@ -72,6 +71,7 @@
#include "sharing/incoming_share_session.h"
#include "sharing/internal/api/bluetooth_adapter.h"
#include "sharing/internal/api/sharing_platform.h"
#include "sharing/internal/api/sharing_rpc_client.h"
#include "sharing/internal/base/encode.h"
#include "sharing/internal/public/connectivity_manager.h"
#include "sharing/internal/public/context.h"
@@ -112,6 +112,7 @@ using ::location::nearby::proto::sharing::OSType;
using ::location::nearby::proto::sharing::ResponseToIntroduction;
using ::location::nearby::proto::sharing::SessionStatus;
using ::nearby::sharing::api::SharingPlatform;
using ::nearby::sharing::api::SharingRpcClientFactory;
using ::nearby::sharing::proto::DataUsage;
using ::nearby::sharing::proto::DeviceVisibility;
using ::nearby::sharing::service::proto::ConnectionResponseFrame;
@@ -212,7 +213,9 @@ std::string GenerateDeviceId() {
NearbySharingServiceImpl::NearbySharingServiceImpl(
std::unique_ptr<TaskRunner> service_thread, Context* context,
SharingPlatform& sharing_platform,
std::unique_ptr<SharingRpcClientFactory> nearby_share_client_factory,
std::unique_ptr<NearbyConnectionsManager> nearby_connections_manager,
std::unique_ptr<NearbyShareContactManager> contact_manager,
analytics::AnalyticsRecorder* analytics_recorder)
: service_thread_(std::move(service_thread)),
context_(context),
@@ -221,14 +224,11 @@ NearbySharingServiceImpl::NearbySharingServiceImpl(
account_manager_(sharing_platform.GetAccountManager()),
analytics_recorder_(*analytics_recorder),
nearby_connections_manager_(std::move(nearby_connections_manager)),
nearby_share_client_factory_(
sharing_platform.CreateSharingRpcClientFactory(context_->GetClock(),
&analytics_recorder_)),
nearby_share_client_factory_(std::move(nearby_share_client_factory)),
local_device_data_manager_(
NearbyShareLocalDeviceDataManagerImpl::Factory::Create(
preference_manager_, account_manager_, device_info_)),
contact_manager_(NearbyShareContactManagerImpl::Factory::Create(
context_, account_manager_, nearby_share_client_factory_.get())),
contact_manager_(std::move(contact_manager)),
nearby_fast_initiation_(
NearbyFastInitiationImpl::Factory::Create(context_)),
settings_(std::make_unique<NearbyShareSettings>(
+3
View File
@@ -102,7 +102,10 @@ class NearbySharingServiceImpl
NearbySharingServiceImpl(
std::unique_ptr<nearby::TaskRunner> service_thread, Context* context,
nearby::sharing::api::SharingPlatform& sharing_platform,
std::unique_ptr<nearby::sharing::api::SharingRpcClientFactory>
nearby_share_client_factory,
std::unique_ptr<NearbyConnectionsManager> nearby_connections_manager,
std::unique_ptr<NearbyShareContactManager> contact_manager,
analytics::AnalyticsRecorder* analytics_recorder);
~NearbySharingServiceImpl() override;
+4 -5
View File
@@ -64,7 +64,6 @@
#include "sharing/common/nearby_share_prefs.h"
#include "sharing/constants.h"
#include "sharing/contacts/fake_nearby_share_contact_manager.h"
#include "sharing/contacts/nearby_share_contact_manager_impl.h"
#include "sharing/fake_nearby_connections_manager.h"
#include "sharing/fast_initiation/fake_nearby_fast_initiation.h"
#include "sharing/fast_initiation/nearby_fast_initiation_impl.h"
@@ -408,8 +407,6 @@ class NearbySharingServiceImplTest : public testing::Test {
.WillOnce(Return(std::move(mock_app_info)));
NearbyShareLocalDeviceDataManagerImpl::Factory::SetFactoryForTesting(
&local_device_data_manager_factory_);
NearbyShareContactManagerImpl::Factory::SetFactoryForTesting(
&contact_manager_factory_);
NearbyShareCertificateManagerImpl::Factory::SetFactoryForTesting(
&certificate_manager_factory_);
nearby_fast_initiation_factory_ =
@@ -424,6 +421,7 @@ class NearbySharingServiceImplTest : public testing::Test {
auto fake_task_runner =
std::make_unique<FakeTaskRunner>(fake_context_.fake_clock(), 1);
sharing_service_task_runner_ = fake_task_runner.get();
contact_manager_ = new FakeNearbyShareContactManager();
fake_nearby_connections_manager_ = new FakeNearbyConnectionsManager();
connection_ = std::make_unique<NearbyConnectionImpl>(fake_device_info_);
fake_nearby_connections_manager_->set_send_payload_callback(
@@ -463,7 +461,6 @@ class NearbySharingServiceImplTest : public testing::Test {
true);
NearbyShareLocalDeviceDataManagerImpl::Factory::SetFactoryForTesting(
nullptr);
NearbyShareContactManagerImpl::Factory::SetFactoryForTesting(nullptr);
NearbyShareCertificateManagerImpl::Factory::SetFactoryForTesting(nullptr);
NearbyFlags::GetInstance().ResetOverridedValues();
nearby_fast_initiation_factory_.reset();
@@ -480,7 +477,9 @@ class NearbySharingServiceImplTest : public testing::Test {
std::unique_ptr<FakeTaskRunner> task_runner) {
return std::make_unique<NearbySharingServiceImpl>(
std::move(task_runner), &fake_context_, mock_sharing_platform_,
/*nearby_share_client_factory=*/nullptr,
absl::WrapUnique(fake_nearby_connections_manager_),
absl::WrapUnique(contact_manager_),
analytics_recorder_.get());
}
@@ -1257,7 +1256,7 @@ class NearbySharingServiceImplTest : public testing::Test {
FakeNearbyConnectionsManager* fake_nearby_connections_manager_ = nullptr;
FakeNearbyShareLocalDeviceDataManager::Factory
local_device_data_manager_factory_;
FakeNearbyShareContactManager::Factory contact_manager_factory_;
FakeNearbyShareContactManager* contact_manager_ = nullptr;
FakeNearbyShareCertificateManager::Factory certificate_manager_factory_;
std::unique_ptr<FakeNearbyFastInitiation::Factory>
nearby_fast_initiation_factory_;