mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 07:36:10 -04:00
Remove NearbyShareSettings#isOnboardingComplete
PiperOrigin-RevId: 653002081
This commit is contained in:
committed by
Copybara-Service
parent
a0484fef80
commit
1a075e1e9c
@@ -54,16 +54,12 @@ 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 kNearbySharingOnboardingCompleteName[] =
|
||||
"nearby_sharing.onboarding_complete";
|
||||
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 kNearbySharingIconTokenName[] =
|
||||
"nearby_sharing.icon_token";
|
||||
ABSL_CONST_INIT const char kNearbySharingOnboardingDismissedTimeName[] =
|
||||
"nearby_sharing.onboarding_dismissed_time";
|
||||
ABSL_CONST_INIT const char kNearbySharingPublicCertificateExpirationDictName[] =
|
||||
"nearbyshare.public_certificate_expiration_dict";
|
||||
ABSL_CONST_INIT const char kNearbySharingPrivateCertificateListName[] =
|
||||
@@ -104,7 +100,6 @@ void RegisterNearbySharingPrefs(PreferenceManager& preference_manager,
|
||||
// values. To avoid setting them twice, we skip them here if
|
||||
// skip_persistent_ones is set to true.
|
||||
preference_manager.SetString(kNearbySharingCustomSavePath, std::string());
|
||||
preference_manager.SetBoolean(kNearbySharingOnboardingCompleteName, false);
|
||||
preference_manager.SetInteger(kNearbySharingBackgroundVisibilityName,
|
||||
static_cast<int>(kDefaultVisibility));
|
||||
preference_manager.SetInteger(
|
||||
@@ -138,9 +133,6 @@ void RegisterNearbySharingPrefs(PreferenceManager& preference_manager,
|
||||
|
||||
preference_manager.SetString(kNearbySharingIconTokenName, std::string());
|
||||
|
||||
preference_manager.SetTime(kNearbySharingOnboardingDismissedTimeName,
|
||||
absl::Now());
|
||||
|
||||
preference_manager.Remove(kNearbySharingPublicCertificateExpirationDictName);
|
||||
preference_manager.Remove(kNearbySharingPrivateCertificateListName);
|
||||
preference_manager.Remove(
|
||||
|
||||
@@ -35,11 +35,9 @@ 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 kNearbySharingOnboardingCompleteName[];
|
||||
ABSL_CONST_INIT extern const char kNearbySharingFullNameName[];
|
||||
ABSL_CONST_INIT extern const char kNearbySharingIconUrlName[];
|
||||
ABSL_CONST_INIT extern const char kNearbySharingIconTokenName[];
|
||||
ABSL_CONST_INIT extern const char kNearbySharingOnboardingDismissedTimeName[];
|
||||
ABSL_CONST_INIT extern const char kNearbySharingPrivateCertificateListName[];
|
||||
ABSL_CONST_INIT extern const char
|
||||
kNearbySharingPublicCertificateExpirationDictName[];
|
||||
|
||||
@@ -191,12 +191,6 @@ void NearbyShareSettings::RestoreFallbackVisibility() {
|
||||
}
|
||||
}
|
||||
|
||||
bool NearbyShareSettings::IsOnboardingComplete() const {
|
||||
MutexLock lock(&mutex_);
|
||||
return preference_manager_.GetBoolean(
|
||||
prefs::kNearbySharingOnboardingCompleteName, false);
|
||||
}
|
||||
|
||||
std::string NearbyShareSettings::GetCustomSavePath() const {
|
||||
MutexLock lock(&mutex_);
|
||||
return preference_manager_.GetString(
|
||||
@@ -241,19 +235,6 @@ void NearbyShareSettings::SetFastInitiationNotificationState(
|
||||
static_cast<int>(state));
|
||||
}
|
||||
|
||||
void NearbyShareSettings::IsOnboardingComplete(
|
||||
std::function<void(bool)> callback) {
|
||||
std::move(callback)(IsOnboardingComplete());
|
||||
}
|
||||
|
||||
void NearbyShareSettings::SetIsOnboardingComplete(
|
||||
bool completed, std::function<void()> callback) {
|
||||
MutexLock lock(&mutex_);
|
||||
preference_manager_.SetBoolean(prefs::kNearbySharingOnboardingCompleteName,
|
||||
completed);
|
||||
std::move(callback)();
|
||||
}
|
||||
|
||||
void NearbyShareSettings::GetDeviceName(
|
||||
std::function<void(absl::string_view)> callback) {
|
||||
std::move(callback)(GetDeviceName());
|
||||
@@ -433,8 +414,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::kNearbySharingOnboardingCompleteName) {
|
||||
NotifyAllObservers(key, Observer::Data(IsOnboardingComplete()));
|
||||
} else if (key == prefs::kNearbySharingCustomSavePath) {
|
||||
NotifyAllObservers(key, Observer::Data(GetCustomSavePath()));
|
||||
} else {
|
||||
|
||||
@@ -182,7 +182,6 @@ class NearbyShareSettings
|
||||
absl::Time GetLastVisibilityTimestamp() const;
|
||||
proto::DeviceVisibility GetLastVisibility() const;
|
||||
|
||||
bool IsOnboardingComplete() const;
|
||||
std::string GetCustomSavePath() const;
|
||||
|
||||
// Returns true if the feature is disabled by policy.
|
||||
@@ -196,8 +195,6 @@ class NearbyShareSettings
|
||||
void GetIsFastInitiationHardwareSupported(std::function<void(bool)> callback);
|
||||
void SetFastInitiationNotificationState(
|
||||
proto::FastInitiationNotificationState state);
|
||||
void IsOnboardingComplete(std::function<void(bool)> callback);
|
||||
void SetIsOnboardingComplete(bool completed, std::function<void()> callback);
|
||||
void GetDeviceName(std::function<void(absl::string_view)> callback);
|
||||
void ValidateDeviceName(
|
||||
absl::string_view device_name,
|
||||
|
||||
@@ -59,8 +59,6 @@ class FakeNearbyShareSettingsObserver : public NearbyShareSettings::Observer {
|
||||
custom_save_path_ = data.value.as_string;
|
||||
} else if (key == prefs::kNearbySharingBackgroundVisibilityName) {
|
||||
visibility_ = static_cast<DeviceVisibility>(data.value.as_int64);
|
||||
} else if (key == prefs::kNearbySharingOnboardingCompleteName) {
|
||||
is_onboarding_complete_ = data.value.as_bool;
|
||||
} else if (key == prefs::kNearbySharingDeviceNameName) {
|
||||
device_name_ = data.value.as_string;
|
||||
}
|
||||
@@ -81,11 +79,6 @@ class FakeNearbyShareSettingsObserver : public NearbyShareSettings::Observer {
|
||||
return is_fast_initiation_notification_hardware_supported_;
|
||||
}
|
||||
|
||||
bool is_onboarding_complete() const {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
return is_onboarding_complete_;
|
||||
}
|
||||
|
||||
const std::string& device_name() const {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
return device_name_;
|
||||
@@ -114,7 +107,6 @@ class FakeNearbyShareSettingsObserver : public NearbyShareSettings::Observer {
|
||||
FastInitiationNotificationState::ENABLED_FAST_INIT;
|
||||
bool is_fast_initiation_notification_hardware_supported_
|
||||
ABSL_GUARDED_BY(mutex_) = false;
|
||||
bool is_onboarding_complete_ ABSL_GUARDED_BY(mutex_) = false;
|
||||
std::string device_name_ ABSL_GUARDED_BY(mutex_) = "uncalled";
|
||||
std::string custom_save_path_ ABSL_GUARDED_BY(mutex_);
|
||||
DataUsage data_usage_ ABSL_GUARDED_BY(mutex_) = DataUsage::UNKNOWN_DATA_USAGE;
|
||||
@@ -141,11 +133,6 @@ class NearbyShareSettingsTest : public ::testing::Test {
|
||||
|
||||
NearbyShareSettings* settings() { return nearby_share_settings_.get(); }
|
||||
|
||||
void SetIsOnboardingComplete(bool is_complete) {
|
||||
preference_manager_.SetBoolean(
|
||||
prefs::kNearbySharingOnboardingCompleteName, is_complete);
|
||||
}
|
||||
|
||||
void SetVisibilityExpirationPreference(int expiration) {
|
||||
preference_manager_.SetInteger(
|
||||
prefs::kNearbySharingBackgroundVisibilityExpirationSeconds, expiration);
|
||||
@@ -219,19 +206,6 @@ TEST_F(NearbyShareSettingsTest, GetAndSetCustomSavePath) {
|
||||
GetCompatibleU8String(std::filesystem::temp_directory_path().u8string()));
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareSettingsTest, GetAndSetIsOnboardingComplete) {
|
||||
EXPECT_FALSE(observer_.is_onboarding_complete());
|
||||
SetIsOnboardingComplete(true);
|
||||
EXPECT_TRUE(settings()->IsOnboardingComplete());
|
||||
Flush();
|
||||
EXPECT_TRUE(observer_.is_onboarding_complete());
|
||||
|
||||
bool is_complete = false;
|
||||
settings()->IsOnboardingComplete(
|
||||
[&is_complete](bool result) { is_complete = result; });
|
||||
EXPECT_TRUE(is_complete);
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareSettingsTest, GetAndSetIsFastInitiationHardwareSupported) {
|
||||
EXPECT_FALSE(observer_.is_fast_initiation_notification_hardware_supported());
|
||||
settings()->SetIsFastInitiationHardwareSupported(true);
|
||||
|
||||
Reference in New Issue
Block a user