mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Remove unused code related to allowed contacts and all contacts.
PiperOrigin-RevId: 647443590
This commit is contained in:
committed by
Copybara-Service
parent
1f5654089f
commit
2e868f9a00
@@ -23,7 +23,6 @@ namespace nearby {
|
||||
namespace sharing {
|
||||
namespace prefs {
|
||||
|
||||
ABSL_CONST_INIT extern const char kNearbySharingAllowedContactsName[];
|
||||
ABSL_CONST_INIT extern const char kNearbySharingBackgroundVisibilityName[];
|
||||
ABSL_CONST_INIT extern const char
|
||||
kNearbySharingBackgroundTemporarilyVisibleName[];
|
||||
@@ -64,7 +63,6 @@ ABSL_CONST_INIT extern const char
|
||||
kNearbySharingSchedulerUploadLocalDeviceCertificatesName[];
|
||||
ABSL_CONST_INIT extern const char kNearbySharingUsersName[];
|
||||
ABSL_CONST_INIT extern const char kNearbySharingIsAnalyticsEnabledName[];
|
||||
ABSL_CONST_INIT extern const char kNearbySharingIsAllContactsEnabledName[];
|
||||
ABSL_CONST_INIT extern const char kNearbySharingAutoAppStartEnabledName[];
|
||||
|
||||
ABSL_CONST_INIT const proto::DeviceVisibility kDefaultVisibility =
|
||||
|
||||
@@ -201,14 +201,6 @@ void NearbyShareSettings::RestoreFallbackVisibility() {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> NearbyShareSettings::GetAllowedContacts() const {
|
||||
MutexLock lock(&mutex_);
|
||||
std::vector<std::string> allowed_contacts =
|
||||
preference_manager_.GetStringArray(
|
||||
prefs::kNearbySharingAllowedContactsName, {});
|
||||
return allowed_contacts;
|
||||
}
|
||||
|
||||
bool NearbyShareSettings::IsOnboardingComplete() const {
|
||||
MutexLock lock(&mutex_);
|
||||
return preference_manager_.GetBoolean(
|
||||
@@ -431,18 +423,6 @@ void NearbyShareSettings::SetIsTemporarilyVisible(
|
||||
is_temporarily_visible);
|
||||
}
|
||||
|
||||
void NearbyShareSettings::GetAllowedContacts(
|
||||
std::function<void(absl::Span<const std::string>)> callback) {
|
||||
std::move(callback)(GetAllowedContacts());
|
||||
}
|
||||
|
||||
void NearbyShareSettings::SetAllowedContacts(
|
||||
absl::Span<const std::string> allowed_contacts) {
|
||||
MutexLock lock(&mutex_);
|
||||
preference_manager_.SetStringArray(prefs::kNearbySharingAllowedContactsName,
|
||||
allowed_contacts);
|
||||
}
|
||||
|
||||
void NearbyShareSettings::GetCustomSavePathAsync(
|
||||
const std::function<void(absl::string_view)>& callback) const {
|
||||
callback(GetCustomSavePath());
|
||||
@@ -470,8 +450,6 @@ void NearbyShareSettings::OnPreferenceChanged(absl::string_view key) {
|
||||
} else if (key == prefs::kNearbySharingDataUsageName) {
|
||||
NotifyAllObservers(key,
|
||||
Observer::Data(static_cast<int64_t>(GetDataUsage())));
|
||||
} else if (key == prefs::kNearbySharingAllowedContactsName) {
|
||||
NotifyAllObservers(key, Observer::Data(GetAllowedContacts()));
|
||||
} else if (key == prefs::kNearbySharingOnboardingCompleteName) {
|
||||
NotifyAllObservers(key, Observer::Data(IsOnboardingComplete()));
|
||||
} else if (key == prefs::kNearbySharingCustomSavePath) {
|
||||
@@ -550,30 +528,6 @@ std::string NearbyShareSettings::Dump() const {
|
||||
return sstream.str();
|
||||
}
|
||||
|
||||
bool NearbyShareSettings::GetIsAllContactsEnabled() {
|
||||
MutexLock lock(&mutex_);
|
||||
return preference_manager_.GetBoolean(
|
||||
prefs::kNearbySharingIsAllContactsEnabledName, true);
|
||||
}
|
||||
|
||||
void NearbyShareSettings::SetIsAllContactsEnabled(
|
||||
bool is_all_contacts_enabled) const {
|
||||
MutexLock lock(&mutex_);
|
||||
preference_manager_.SetBoolean(
|
||||
prefs::kNearbySharingIsAllContactsEnabledName, is_all_contacts_enabled);
|
||||
|
||||
if (is_all_contacts_enabled) {
|
||||
if (GetVisibility() ==
|
||||
DeviceVisibility::DEVICE_VISIBILITY_SELECTED_CONTACTS) {
|
||||
SetVisibility(DeviceVisibility::DEVICE_VISIBILITY_ALL_CONTACTS);
|
||||
}
|
||||
} else {
|
||||
if (GetVisibility() == DeviceVisibility::DEVICE_VISIBILITY_ALL_CONTACTS) {
|
||||
SetVisibility(DeviceVisibility::DEVICE_VISIBILITY_SELECTED_CONTACTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool NearbyShareSettings::is_fast_initiation_hardware_supported() {
|
||||
MutexLock lock(&mutex_);
|
||||
return is_fast_initiation_hardware_supported_;
|
||||
|
||||
@@ -182,7 +182,6 @@ class NearbyShareSettings
|
||||
proto::DeviceVisibility GetFallbackVisibility() const;
|
||||
bool GetIsTemporarilyVisible() const;
|
||||
void SetIsTemporarilyVisible(bool is_temporarily_visible) const;
|
||||
std::vector<std::string> GetAllowedContacts() const;
|
||||
bool IsOnboardingComplete() const;
|
||||
std::string GetCustomSavePath() const;
|
||||
|
||||
@@ -217,12 +216,6 @@ class NearbyShareSettings
|
||||
void SetIsReceiving(bool is_receiving) const;
|
||||
bool GetIsAnalyticsEnabled();
|
||||
void SetIsAnalyticsEnabled(bool is_analytics_enabled) const;
|
||||
bool GetIsAllContactsEnabled();
|
||||
void SetIsAllContactsEnabled(bool is_all_contacts_enabled) const;
|
||||
|
||||
void GetAllowedContacts(
|
||||
std::function<void(absl::Span<const std::string>)> callback);
|
||||
void SetAllowedContacts(absl::Span<const std::string> allowed_contacts);
|
||||
|
||||
void GetCustomSavePathAsync(
|
||||
const std::function<void(absl::string_view)>& callback) const;
|
||||
|
||||
@@ -68,11 +68,6 @@ class FakeNearbyShareSettingsObserver : public NearbyShareSettings::Observer {
|
||||
visibility_ = static_cast<DeviceVisibility>(data.value.as_int64);
|
||||
} else if (key == prefs::kNearbySharingOnboardingCompleteName) {
|
||||
is_onboarding_complete_ = data.value.as_bool;
|
||||
} else if (key == prefs::kNearbySharingAllowedContactsName) {
|
||||
allowed_contacts_.clear();
|
||||
for (auto& allowed_contact : data.value.as_string_array) {
|
||||
allowed_contacts_.push_back(allowed_contact);
|
||||
}
|
||||
} else if (key == prefs::kNearbySharingDeviceNameName) {
|
||||
device_name_ = data.value.as_string;
|
||||
}
|
||||
@@ -474,49 +469,6 @@ TEST_F(NearbyShareSettingsTest, GetFallbackVisibility) {
|
||||
Flush();
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareSettingsTest, GetAndSetAllowedContacts) {
|
||||
const std::string id1("1");
|
||||
|
||||
std::vector<std::string> allowed_contacts;
|
||||
|
||||
settings()->GetAllowedContacts(
|
||||
[&allowed_contacts](absl::Span<const std::string> result) {
|
||||
allowed_contacts.clear();
|
||||
for (auto& contact : result) {
|
||||
allowed_contacts.push_back(contact);
|
||||
}
|
||||
});
|
||||
EXPECT_EQ(allowed_contacts.size(), 0u);
|
||||
|
||||
settings()->SetAllowedContacts({id1});
|
||||
Flush();
|
||||
EXPECT_EQ(observer_.allowed_contacts().size(), 1u);
|
||||
EXPECT_TRUE(Contains(observer_.allowed_contacts(), id1));
|
||||
|
||||
settings()->GetAllowedContacts(
|
||||
[&allowed_contacts](absl::Span<const std::string> result) {
|
||||
allowed_contacts.clear();
|
||||
for (auto& contact : result) {
|
||||
allowed_contacts.push_back(contact);
|
||||
}
|
||||
});
|
||||
EXPECT_EQ(allowed_contacts.size(), 1u);
|
||||
EXPECT_TRUE(Contains(observer_.allowed_contacts(), id1));
|
||||
|
||||
settings()->SetAllowedContacts({});
|
||||
Flush();
|
||||
EXPECT_EQ(observer_.allowed_contacts().size(), 0u);
|
||||
|
||||
settings()->GetAllowedContacts(
|
||||
[&allowed_contacts](absl::Span<const std::string> result) {
|
||||
allowed_contacts.clear();
|
||||
for (auto& contact : result) {
|
||||
allowed_contacts.push_back(contact);
|
||||
}
|
||||
});
|
||||
EXPECT_EQ(allowed_contacts.size(), 0u);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace sharing
|
||||
} // namespace nearby
|
||||
|
||||
Reference in New Issue
Block a user