Skip to content

Commit

Permalink
Remove SetIsTemporarilyVisible from public API.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 647819183
  • Loading branch information
anayw2001 authored and copybara-github committed Jun 28, 2024
1 parent 0cc4138 commit f17c075
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
2 changes: 0 additions & 2 deletions sharing/common/nearby_share_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ ABSL_CONST_INIT const char kNearbySharingAllowedContactsName[] =
"nearby_sharing.allowed_contacts";
ABSL_CONST_INIT const char kNearbySharingBackgroundVisibilityName[] =
"nearby_sharing.background_visibility";
ABSL_CONST_INIT const char kNearbySharingBackgroundTemporarilyVisibleName[] =
"nearby_sharing.background_temporarily_visible";
ABSL_CONST_INIT const char kNearbySharingBackgroundFallbackVisibilityName[] =
"nearby_sharing.background_fallback_visibility";
ABSL_CONST_INIT const char
Expand Down
2 changes: 0 additions & 2 deletions sharing/common/nearby_share_prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ namespace sharing {
namespace prefs {

ABSL_CONST_INIT extern const char kNearbySharingBackgroundVisibilityName[];
ABSL_CONST_INIT extern const char
kNearbySharingBackgroundTemporarilyVisibleName[];
ABSL_CONST_INIT extern const char
kNearbySharingBackgroundFallbackVisibilityName[];
ABSL_CONST_INIT extern const char
Expand Down
11 changes: 1 addition & 10 deletions sharing/nearby_sharing_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,7 @@ void NearbyShareSettings::SetFallbackVisibility(

bool NearbyShareSettings::GetIsTemporarilyVisible() const {
MutexLock lock(&mutex_);
return preference_manager_.GetBoolean(
prefs::kNearbySharingBackgroundTemporarilyVisibleName, false);
}

void NearbyShareSettings::SetIsTemporarilyVisible(
bool is_temporarily_visible) const {
MutexLock lock(&mutex_);
preference_manager_.SetBoolean(
prefs::kNearbySharingBackgroundTemporarilyVisibleName,
is_temporarily_visible);
return visibility_expiration_timer_->IsRunning();
}

void NearbyShareSettings::GetCustomSavePathAsync(
Expand Down
1 change: 0 additions & 1 deletion sharing/nearby_sharing_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ class NearbyShareSettings
proto::DeviceVisibility GetLastVisibility() const;

bool GetIsTemporarilyVisible() const;
void SetIsTemporarilyVisible(bool is_temporarily_visible) const;
bool IsOnboardingComplete() const;
std::string GetCustomSavePath() const;

Expand Down
13 changes: 13 additions & 0 deletions sharing/nearby_sharing_settings_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,19 @@ TEST_F(NearbyShareSettingsTest,
DeviceVisibility::DEVICE_VISIBILITY_SELF_SHARE);
}

TEST_F(NearbyShareSettingsTest, TemporaryVisibilityIsCorrect) {
// Set our initial visibility to self share.
settings()->SetVisibility(DeviceVisibility::DEVICE_VISIBILITY_SELF_SHARE);
// Verify that the visibility is not temporary.
EXPECT_FALSE(settings()->GetIsTemporarilyVisible());
// Transition to temporary everyone mode.
settings()->SetVisibility(
DeviceVisibility::DEVICE_VISIBILITY_EVERYONE,
absl::Seconds(prefs::kDefaultMaxVisibilityExpirationSeconds));
// Verify that the visibility is temporary.
EXPECT_TRUE(settings()->GetIsTemporarilyVisible());
}

TEST(NearbyShareVisibilityTest, RestoresFallbackVisibility_ExpiredTimer) {
// Create Nearby Share settings dependencies.
FakeContext context;
Expand Down

0 comments on commit f17c075

Please sign in to comment.