mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
remove FullName & IconUrl from preference & local device data manager.
PiperOrigin-RevId: 692612482
This commit is contained in:
committed by
Copybara-Service
parent
cf8d435f81
commit
6443dfedf7
@@ -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);
|
||||
|
||||
|
||||
@@ -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<std::string>());
|
||||
|
||||
preference_manager.SetString(kNearbySharingFullNameName, std::string());
|
||||
|
||||
preference_manager.SetString(kNearbySharingIconUrlName, std::string());
|
||||
|
||||
preference_manager.Remove(kNearbySharingPublicCertificateExpirationDictName);
|
||||
preference_manager.Remove(kNearbySharingPrivateCertificateListName);
|
||||
preference_manager.Remove(
|
||||
|
||||
@@ -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[];
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "sharing/local_device_data/fake_nearby_share_local_device_data_manager.h"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@@ -93,16 +92,6 @@ std::string FakeNearbyShareLocalDeviceDataManager::GetDeviceName() const {
|
||||
return device_name_;
|
||||
}
|
||||
|
||||
std::optional<std::string> FakeNearbyShareLocalDeviceDataManager::GetFullName()
|
||||
const {
|
||||
return full_name_;
|
||||
}
|
||||
|
||||
std::optional<std::string> 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<std::string>& 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<std::string>& 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
|
||||
|
||||
@@ -97,8 +97,6 @@ class FakeNearbyShareLocalDeviceDataManager
|
||||
// NearbyShareLocalDeviceDataManager:
|
||||
std::string GetId() override;
|
||||
std::string GetDeviceName() const override;
|
||||
std::optional<std::string> GetFullName() const override;
|
||||
std::optional<std::string> 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<std::string>& full_name);
|
||||
void SetIconUrl(const std::optional<std::string>& icon_url);
|
||||
|
||||
std::vector<UploadContactsCall>& upload_contacts_calls() {
|
||||
return upload_contacts_calls_;
|
||||
@@ -144,8 +140,6 @@ class FakeNearbyShareLocalDeviceDataManager
|
||||
|
||||
std::string id_;
|
||||
std::string device_name_;
|
||||
std::optional<std::string> full_name_;
|
||||
std::optional<std::string> icon_url_;
|
||||
std::vector<UploadContactsCall> upload_contacts_calls_;
|
||||
std::vector<UploadCertificatesCall> upload_certificates_calls_;
|
||||
DeviceNameValidationResult next_validation_result_ =
|
||||
|
||||
@@ -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<std::string> 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<std::string> 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(
|
||||
|
||||
@@ -158,19 +158,6 @@ std::string NearbyShareLocalDeviceDataManagerImpl::GetDeviceName() const {
|
||||
return device_name.empty() ? GetDefaultDeviceName() : device_name;
|
||||
}
|
||||
|
||||
std::optional<std::string> NearbyShareLocalDeviceDataManagerImpl::GetFullName()
|
||||
const {
|
||||
return preference_manager_.GetString(prefs::kNearbySharingFullNameName,
|
||||
std::string());
|
||||
}
|
||||
|
||||
std::optional<std::string> NearbyShareLocalDeviceDataManagerImpl::GetIconUrl()
|
||||
const {
|
||||
return preference_manager_.GetString(prefs::kNearbySharingIconUrlName,
|
||||
std::string());
|
||||
}
|
||||
|
||||
|
||||
DeviceNameValidationResult
|
||||
NearbyShareLocalDeviceDataManagerImpl::ValidateDeviceName(
|
||||
absl::string_view name) {
|
||||
|
||||
@@ -76,8 +76,6 @@ class NearbyShareLocalDeviceDataManagerImpl
|
||||
// NearbyShareLocalDeviceDataManager:
|
||||
std::string GetId() override;
|
||||
std::string GetDeviceName() const override;
|
||||
std::optional<std::string> GetFullName() const override;
|
||||
std::optional<std::string> GetIconUrl() const override;
|
||||
DeviceNameValidationResult ValidateDeviceName(
|
||||
absl::string_view name) override;
|
||||
DeviceNameValidationResult SetDeviceName(absl::string_view name) override;
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user