From 6443dfedf785d2d5600e0126c20f44df116f948b Mon Sep 17 00:00:00 2001 From: Suet-Fei Li Date: Sat, 2 Nov 2024 22:48:53 -0700 Subject: [PATCH] remove FullName & IconUrl from preference & local device data manager. PiperOrigin-RevId: 692612482 --- ...rby_share_certificate_manager_impl_test.cc | 4 --- sharing/common/nearby_share_prefs.cc | 8 ----- sharing/common/nearby_share_prefs.h | 2 -- ..._nearby_share_local_device_data_manager.cc | 32 ------------------- ...e_nearby_share_local_device_data_manager.h | 6 ---- .../nearby_share_local_device_data_manager.h | 17 +--------- ...by_share_local_device_data_manager_impl.cc | 13 -------- ...rby_share_local_device_data_manager_impl.h | 2 -- ...are_local_device_data_manager_impl_test.cc | 2 -- 9 files changed, 1 insertion(+), 85 deletions(-) diff --git a/sharing/certificates/nearby_share_certificate_manager_impl_test.cc b/sharing/certificates/nearby_share_certificate_manager_impl_test.cc index 840b5340..c016d6b4 100644 --- a/sharing/certificates/nearby_share_certificate_manager_impl_test.cc +++ b/sharing/certificates/nearby_share_certificate_manager_impl_test.cc @@ -130,10 +130,6 @@ class NearbyShareCertificateManagerImplTest // Set default device data. local_device_data_manager_->SetDeviceName( GetNearbyShareTestMetadata().device_name()); - local_device_data_manager_->SetFullName( - GetNearbyShareTestMetadata().full_name()); - local_device_data_manager_->SetIconUrl( - GetNearbyShareTestMetadata().icon_url()); SetBluetoothMacAddress(kTestUnparsedBluetoothMacAddress); SetMockBluetoothAddress(kTestUnparsedBluetoothMacAddress); diff --git a/sharing/common/nearby_share_prefs.cc b/sharing/common/nearby_share_prefs.cc index bdd40124..ece25e2f 100644 --- a/sharing/common/nearby_share_prefs.cc +++ b/sharing/common/nearby_share_prefs.cc @@ -56,10 +56,6 @@ ABSL_CONST_INIT const char kNearbySharingDeviceNameName[] = "nearby_sharing.device_name"; ABSL_CONST_INIT const char kNearbySharingFastInitiationNotificationStateName[] = "nearby_sharing.fast_initiation_notification_state"; -ABSL_CONST_INIT const char kNearbySharingFullNameName[] = - "nearby_sharing.full_name"; -ABSL_CONST_INIT const char kNearbySharingIconUrlName[] = - "nearby_sharing.icon_url"; ABSL_CONST_INIT const char kNearbySharingPublicCertificateExpirationDictName[] = "nearbyshare.public_certificate_expiration_dict"; ABSL_CONST_INIT const char kNearbySharingPrivateCertificateListName[] = @@ -123,10 +119,6 @@ void RegisterNearbySharingPrefs(PreferenceManager& preference_manager, preference_manager.SetStringArray(kNearbySharingAllowedContactsName, std::vector()); - preference_manager.SetString(kNearbySharingFullNameName, std::string()); - - preference_manager.SetString(kNearbySharingIconUrlName, std::string()); - preference_manager.Remove(kNearbySharingPublicCertificateExpirationDictName); preference_manager.Remove(kNearbySharingPrivateCertificateListName); preference_manager.Remove( diff --git a/sharing/common/nearby_share_prefs.h b/sharing/common/nearby_share_prefs.h index 2f146aff..97f62c3a 100644 --- a/sharing/common/nearby_share_prefs.h +++ b/sharing/common/nearby_share_prefs.h @@ -36,8 +36,6 @@ ABSL_CONST_INIT extern const char kNearbySharingDeviceIdName[]; ABSL_CONST_INIT extern const char kNearbySharingDeviceNameName[]; ABSL_CONST_INIT extern const char kNearbySharingFastInitiationNotificationStateName[]; -ABSL_CONST_INIT extern const char kNearbySharingFullNameName[]; -ABSL_CONST_INIT extern const char kNearbySharingIconUrlName[]; ABSL_CONST_INIT extern const char kNearbySharingPrivateCertificateListName[]; ABSL_CONST_INIT extern const char kNearbySharingPublicCertificateExpirationDictName[]; diff --git a/sharing/local_device_data/fake_nearby_share_local_device_data_manager.cc b/sharing/local_device_data/fake_nearby_share_local_device_data_manager.cc index 906f4417..4f7467c7 100644 --- a/sharing/local_device_data/fake_nearby_share_local_device_data_manager.cc +++ b/sharing/local_device_data/fake_nearby_share_local_device_data_manager.cc @@ -15,7 +15,6 @@ #include "sharing/local_device_data/fake_nearby_share_local_device_data_manager.h" #include -#include #include #include #include @@ -93,16 +92,6 @@ std::string FakeNearbyShareLocalDeviceDataManager::GetDeviceName() const { return device_name_; } -std::optional FakeNearbyShareLocalDeviceDataManager::GetFullName() - const { - return full_name_; -} - -std::optional FakeNearbyShareLocalDeviceDataManager::GetIconUrl() - const { - return icon_url_; -} - DeviceNameValidationResult FakeNearbyShareLocalDeviceDataManager::ValidateDeviceName( absl::string_view name) { @@ -142,27 +131,6 @@ void FakeNearbyShareLocalDeviceDataManager::UploadCertificates( callback(upload_certificate_result_); } } -void FakeNearbyShareLocalDeviceDataManager::SetFullName( - const absl::optional& full_name) { - if (full_name_ == full_name) return; - - full_name_ = full_name; - NotifyLocalDeviceDataChanged( - /*did_device_name_change=*/false, - /*did_full_name_change=*/true, - /*did_icon_change=*/false); -} - -void FakeNearbyShareLocalDeviceDataManager::SetIconUrl( - const absl::optional& icon_url) { - if (icon_url_ == icon_url) return; - - icon_url_ = icon_url; - NotifyLocalDeviceDataChanged( - /*did_device_name_change=*/false, - /*did_full_name_change=*/false, - /*did_icon_change=*/true); -} } // namespace sharing } // namespace nearby diff --git a/sharing/local_device_data/fake_nearby_share_local_device_data_manager.h b/sharing/local_device_data/fake_nearby_share_local_device_data_manager.h index 5d0597ef..a0fb4317 100644 --- a/sharing/local_device_data/fake_nearby_share_local_device_data_manager.h +++ b/sharing/local_device_data/fake_nearby_share_local_device_data_manager.h @@ -97,8 +97,6 @@ class FakeNearbyShareLocalDeviceDataManager // NearbyShareLocalDeviceDataManager: std::string GetId() override; std::string GetDeviceName() const override; - std::optional GetFullName() const override; - std::optional GetIconUrl() const override; DeviceNameValidationResult ValidateDeviceName( absl::string_view name) override; DeviceNameValidationResult SetDeviceName(absl::string_view name) override; @@ -113,8 +111,6 @@ class FakeNearbyShareLocalDeviceDataManager using NearbyShareLocalDeviceDataManager::NotifyLocalDeviceDataChanged; void SetId(absl::string_view id) { id_ = std::string(id); } - void SetFullName(const std::optional& full_name); - void SetIconUrl(const std::optional& icon_url); std::vector& upload_contacts_calls() { return upload_contacts_calls_; @@ -144,8 +140,6 @@ class FakeNearbyShareLocalDeviceDataManager std::string id_; std::string device_name_; - std::optional full_name_; - std::optional icon_url_; std::vector upload_contacts_calls_; std::vector upload_certificates_calls_; DeviceNameValidationResult next_validation_result_ = diff --git a/sharing/local_device_data/nearby_share_local_device_data_manager.h b/sharing/local_device_data/nearby_share_local_device_data_manager.h index dd929a36..1d6a3de7 100644 --- a/sharing/local_device_data/nearby_share_local_device_data_manager.h +++ b/sharing/local_device_data/nearby_share_local_device_data_manager.h @@ -34,11 +34,7 @@ namespace sharing { // a std::string, which will not contain a null terminator. extern const size_t kNearbyShareDeviceNameMaxLength; -// Manages local device data related to the UpdateDevice RPC such as the device -// ID, name, and icon URL; provides the user's full name and icon URL returned -// from the Nearby server; and handles uploading contacts and certificates to -// the Nearby server. The uploading of contacts and certificates might seem out -// of place, but this class is the entry point for all UpdateDevice RPC calls. +// Handles uploading contacts and certificates to the Nearby server. class NearbyShareLocalDeviceDataManager { public: class Observer { @@ -71,17 +67,6 @@ class NearbyShareLocalDeviceDataManager { // This can be modified by SetDeviceName(). virtual std::string GetDeviceName() const = 0; - // TODO(b/690916264): NearbyShareLocalDeviceDataManager FullName & IconUrl - // are no longer used, delete them. - // Returns the user's full name, for example, "Barack Obama". Returns - // absl::nullopt if the name has not yet been set from an UpdateDevice RPC - // response. - virtual std::optional GetFullName() const = 0; - - // Returns the URL of the user's image. Returns absl::nullopt if the URL has - // not yet been set from an UpdateDevice RPC response. - virtual std::optional GetIconUrl() const = 0; - // Validates the provided device name and returns an error if validation // fails. This is just a check and the device name is not persisted. virtual DeviceNameValidationResult ValidateDeviceName( diff --git a/sharing/local_device_data/nearby_share_local_device_data_manager_impl.cc b/sharing/local_device_data/nearby_share_local_device_data_manager_impl.cc index ccdea318..25af9f38 100644 --- a/sharing/local_device_data/nearby_share_local_device_data_manager_impl.cc +++ b/sharing/local_device_data/nearby_share_local_device_data_manager_impl.cc @@ -158,19 +158,6 @@ std::string NearbyShareLocalDeviceDataManagerImpl::GetDeviceName() const { return device_name.empty() ? GetDefaultDeviceName() : device_name; } -std::optional NearbyShareLocalDeviceDataManagerImpl::GetFullName() - const { - return preference_manager_.GetString(prefs::kNearbySharingFullNameName, - std::string()); -} - -std::optional NearbyShareLocalDeviceDataManagerImpl::GetIconUrl() - const { - return preference_manager_.GetString(prefs::kNearbySharingIconUrlName, - std::string()); -} - - DeviceNameValidationResult NearbyShareLocalDeviceDataManagerImpl::ValidateDeviceName( absl::string_view name) { diff --git a/sharing/local_device_data/nearby_share_local_device_data_manager_impl.h b/sharing/local_device_data/nearby_share_local_device_data_manager_impl.h index f9567f15..183ce270 100644 --- a/sharing/local_device_data/nearby_share_local_device_data_manager_impl.h +++ b/sharing/local_device_data/nearby_share_local_device_data_manager_impl.h @@ -76,8 +76,6 @@ class NearbyShareLocalDeviceDataManagerImpl // NearbyShareLocalDeviceDataManager: std::string GetId() override; std::string GetDeviceName() const override; - std::optional GetFullName() const override; - std::optional GetIconUrl() const override; DeviceNameValidationResult ValidateDeviceName( absl::string_view name) override; DeviceNameValidationResult SetDeviceName(absl::string_view name) override; diff --git a/sharing/local_device_data/nearby_share_local_device_data_manager_impl_test.cc b/sharing/local_device_data/nearby_share_local_device_data_manager_impl_test.cc index 5fae252c..ad906193 100644 --- a/sharing/local_device_data/nearby_share_local_device_data_manager_impl_test.cc +++ b/sharing/local_device_data/nearby_share_local_device_data_manager_impl_test.cc @@ -58,9 +58,7 @@ const char kFakeEmptyDeviceName[] = ""; const char kFakeFullName[] = "Barack Obama"; const char kFakeGivenName[] = "Barack奥巴马"; const char kFakeIconUrl[] = "https://www.google.com"; -const char kFakeIconUrl2[] = "https://www.google.com/2"; const char kFakeIconToken[] = "token"; -const char kFakeIconToken2[] = "token2"; const char kFakeInvalidDeviceName[] = "\xC0"; const char kFakeTooLongDeviceName[] = "this string is 33 bytes in UTF-8!"; const char kFakeTooLongGivenName[] = "this is a 33-byte string in utf-8";