Commit 57be2379 authored by Michael Hansen's avatar Michael Hansen Committed by Chromium LUCI CQ

[Nearby] Suppress BT discoverable system notification.

This suppresses the "Your computer is discoverable..." system
notification when turning on high visibility mode using the toggle in
the Nearby settings subpage.

This will need to be cleaned up with a better abstraction when
addressing tech debt in crbug.com/1155669.

Fixed: 1158521
Change-Id: If5a5de8846f090a79f69d0b799e7d5a0d35ee104
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2622579Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Commit-Queue: Michael Hansen <hansenmichael@google.com>
Cr-Commit-Position: refs/heads/master@{#842565}
parent 7d6a2dcd
...@@ -137,6 +137,10 @@ void NearbyShareDelegateImpl::OnEnabledChanged(bool enabled) { ...@@ -137,6 +137,10 @@ void NearbyShareDelegateImpl::OnEnabledChanged(bool enabled) {
} }
} }
void NearbyShareDelegateImpl::OnHighVisibilityChangeRequested() {
is_enable_high_visibility_request_active_ = true;
}
void NearbyShareDelegateImpl::OnHighVisibilityChanged(bool high_visibility_on) { void NearbyShareDelegateImpl::OnHighVisibilityChanged(bool high_visibility_on) {
is_enable_high_visibility_request_active_ = false; is_enable_high_visibility_request_active_ = false;
......
...@@ -76,6 +76,7 @@ class NearbyShareDelegateImpl ...@@ -76,6 +76,7 @@ class NearbyShareDelegateImpl
const std::vector<std::string>& visible_contact_ids) override {} const std::vector<std::string>& visible_contact_ids) override {}
// NearbyShareService::Observer // NearbyShareService::Observer
void OnHighVisibilityChangeRequested() override;
void OnHighVisibilityChanged(bool high_visibility_on) override; void OnHighVisibilityChanged(bool high_visibility_on) override;
void OnShutdown() override; void OnShutdown() override;
......
...@@ -151,6 +151,17 @@ TEST_F(NearbyShareDelegateImplTest, TestIsEnableHighVisibilityRequestActive) { ...@@ -151,6 +151,17 @@ TEST_F(NearbyShareDelegateImplTest, TestIsEnableHighVisibilityRequestActive) {
EXPECT_FALSE(delegate_.IsEnableHighVisibilityRequestActive()); EXPECT_FALSE(delegate_.IsEnableHighVisibilityRequestActive());
} }
TEST_F(NearbyShareDelegateImplTest, TestIsEnableOnHighVisibilityRequest) {
settings()->SetEnabled(true);
EXPECT_CALL(controller_, HighVisibilityEnabledChanged(true));
delegate_.OnHighVisibilityChangeRequested();
EXPECT_TRUE(delegate_.IsEnableHighVisibilityRequestActive());
SetHighVisibilityOn(true);
EXPECT_FALSE(delegate_.IsEnableHighVisibilityRequestActive());
}
TEST_F(NearbyShareDelegateImplTest, ShowOnboardingAndTurnOnHighVisibility) { TEST_F(NearbyShareDelegateImplTest, ShowOnboardingAndTurnOnHighVisibility) {
settings()->SetEnabled(false); settings()->SetEnabled(false);
......
...@@ -70,6 +70,7 @@ class NearbySharingService : public KeyedService { ...@@ -70,6 +70,7 @@ class NearbySharingService : public KeyedService {
class Observer : public base::CheckedObserver { class Observer : public base::CheckedObserver {
public: public:
virtual void OnHighVisibilityChangeRequested() {}
virtual void OnHighVisibilityChanged(bool in_high_visibility) = 0; virtual void OnHighVisibilityChanged(bool in_high_visibility) = 0;
// Called during the |KeyedService| shutdown, but before everything has been // Called during the |KeyedService| shutdown, but before everything has been
......
...@@ -1643,11 +1643,22 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() { ...@@ -1643,11 +1643,22 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() {
// updated API referenced in the bug which allows setting a per-advertisement // updated API referenced in the bug which allows setting a per-advertisement
// interval. // interval.
// TODO(crbug/1155669): This will suppress the system notification that
// alerts the user that their device is discoverable, but it exposes Nearby
// Share logic to external components. We should clean this up with a better
// abstraction.
bool used_device_name = device_name.has_value();
if (used_device_name) {
for (auto& observer : observers_) {
observer.OnHighVisibilityChangeRequested();
}
}
nearby_connections_manager_->StartAdvertising( nearby_connections_manager_->StartAdvertising(
*endpoint_info, *endpoint_info,
/*listener=*/this, power_level, data_usage, /*listener=*/this, power_level, data_usage,
base::BindOnce(&NearbySharingServiceImpl::OnStartAdvertisingResult, base::BindOnce(&NearbySharingServiceImpl::OnStartAdvertisingResult,
weak_ptr_factory_.GetWeakPtr(), device_name.has_value())); weak_ptr_factory_.GetWeakPtr(), used_device_name));
advertising_power_level_ = power_level; advertising_power_level_ = power_level;
NS_LOG(VERBOSE) << __func__ NS_LOG(VERBOSE) << __func__
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment