diff --git a/sharing/common/nearby_share_prefs.h b/sharing/common/nearby_share_prefs.h index 6a96a864..c8244816 100644 --- a/sharing/common/nearby_share_prefs.h +++ b/sharing/common/nearby_share_prefs.h @@ -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 = diff --git a/sharing/nearby_sharing_settings.cc b/sharing/nearby_sharing_settings.cc index c38e0e73..2f621eae 100644 --- a/sharing/nearby_sharing_settings.cc +++ b/sharing/nearby_sharing_settings.cc @@ -201,14 +201,6 @@ void NearbyShareSettings::RestoreFallbackVisibility() { } } -std::vector NearbyShareSettings::GetAllowedContacts() const { - MutexLock lock(&mutex_); - std::vector 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)> callback) { - std::move(callback)(GetAllowedContacts()); -} - -void NearbyShareSettings::SetAllowedContacts( - absl::Span allowed_contacts) { - MutexLock lock(&mutex_); - preference_manager_.SetStringArray(prefs::kNearbySharingAllowedContactsName, - allowed_contacts); -} - void NearbyShareSettings::GetCustomSavePathAsync( const std::function& 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(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_; diff --git a/sharing/nearby_sharing_settings.h b/sharing/nearby_sharing_settings.h index 8d8868b9..e1909866 100644 --- a/sharing/nearby_sharing_settings.h +++ b/sharing/nearby_sharing_settings.h @@ -182,7 +182,6 @@ class NearbyShareSettings proto::DeviceVisibility GetFallbackVisibility() const; bool GetIsTemporarilyVisible() const; void SetIsTemporarilyVisible(bool is_temporarily_visible) const; - std::vector 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)> callback); - void SetAllowedContacts(absl::Span allowed_contacts); void GetCustomSavePathAsync( const std::function& callback) const; diff --git a/sharing/nearby_sharing_settings_test.cc b/sharing/nearby_sharing_settings_test.cc index 080e961d..c0b39c48 100644 --- a/sharing/nearby_sharing_settings_test.cc +++ b/sharing/nearby_sharing_settings_test.cc @@ -68,11 +68,6 @@ class FakeNearbyShareSettingsObserver : public NearbyShareSettings::Observer { visibility_ = static_cast(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 allowed_contacts; - - settings()->GetAllowedContacts( - [&allowed_contacts](absl::Span 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 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 result) { - allowed_contacts.clear(); - for (auto& contact : result) { - allowed_contacts.push_back(contact); - } - }); - EXPECT_EQ(allowed_contacts.size(), 0u); -} - } // namespace } // namespace sharing } // namespace nearby