Commit a19a0b5a authored by Ryan Hansberry's avatar Ryan Hansberry Committed by Chromium LUCI CQ

[Nearby] Suppress 'device paired' Bluetooth notification during Nearby connections.

If an incoming or outgoing Bluetooth connection has been initiated by a
Nearby Connections client, such as Nearby Share, do not display the
"Device has paired and connected..." notification.

Making generic Bluetooth UI logic (BluetoothNotificationController)
aware of the inner workings of Nearby is not ideal, but is the
quickest solution we have available before launch. We will clean
up this behavior leak in crbug.com/1155669.

Bug: 1155668
Change-Id: Ib06656dbca9ae538b36ebf0b54ec192d88d9f466
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2572804
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833977}
parent 6cb8fa07
...@@ -1777,6 +1777,7 @@ component("ash") { ...@@ -1777,6 +1777,7 @@ component("ash") {
"//chromeos/components/phonehub", "//chromeos/components/phonehub",
"//chromeos/components/quick_answers", "//chromeos/components/quick_answers",
"//chromeos/components/quick_answers/public/cpp:prefs", "//chromeos/components/quick_answers/public/cpp:prefs",
"//chromeos/services/nearby/public/cpp",
"//chromeos/ui/base", "//chromeos/ui/base",
"//chromeos/ui/frame", "//chromeos/ui/frame",
"//services/viz/public/mojom", "//services/viz/public/mojom",
...@@ -2412,6 +2413,7 @@ test("ash_unittests") { ...@@ -2412,6 +2413,7 @@ test("ash_unittests") {
"//chromeos/services/assistant/public/mojom", "//chromeos/services/assistant/public/mojom",
"//chromeos/services/multidevice_setup/public/cpp:test_support", "//chromeos/services/multidevice_setup/public/cpp:test_support",
"//chromeos/services/multidevice_setup/public/mojom", "//chromeos/services/multidevice_setup/public/mojom",
"//chromeos/services/nearby/public/cpp",
"//chromeos/services/network_config/public/mojom", "//chromeos/services/network_config/public/mojom",
"//chromeos/system", "//chromeos/system",
"//chromeos/ui/frame:test_support", "//chromeos/ui/frame:test_support",
......
...@@ -80,6 +80,7 @@ include_rules = [ ...@@ -80,6 +80,7 @@ include_rules = [
"+chromeos/services/assistant/public" , "+chromeos/services/assistant/public" ,
"+chromeos/services/assistant/test_support", "+chromeos/services/assistant/test_support",
"+chromeos/services/multidevice_setup/public", "+chromeos/services/multidevice_setup/public",
"+chromeos/services/nearby/public",
"+chromeos/services/network_config/public", "+chromeos/services/network_config/public",
"+chromeos/services/power/public", "+chromeos/services/power/public",
# TODO(https://crbug.com/644361): Eliminate this. # TODO(https://crbug.com/644361): Eliminate this.
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chromeos/services/nearby/public/cpp/nearby_client_uuids.h"
#include "device/bluetooth/bluetooth_adapter_factory.h" #include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/bluetooth_device.h" #include "device/bluetooth/bluetooth_device.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -361,6 +362,16 @@ void BluetoothNotificationController::NotifyPairedDevice( ...@@ -361,6 +362,16 @@ void BluetoothNotificationController::NotifyPairedDevice(
false /* by_user */); false /* by_user */);
} }
// If the newly paired device is connected via a Nearby Connections client
// (e.g., Nearby Share), do not display this notification.
// TODO(crbug.com/1155669): Generalize this logic to prevent leaking Nearby
// implementation details.
for (const auto& uuid : device->GetUUIDs()) {
if (chromeos::nearby::IsNearbyClientUuid(uuid)) {
return;
}
}
std::unique_ptr<Notification> notification = CreateSystemNotification( std::unique_ptr<Notification> notification = CreateSystemNotification(
message_center::NOTIFICATION_TYPE_SIMPLE, GetPairedNotificationId(device), message_center::NOTIFICATION_TYPE_SIMPLE, GetPairedNotificationId(device),
base::string16() /* title */, base::string16() /* title */,
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chromeos/services/nearby/public/cpp/nearby_client_uuids.h"
#include "device/bluetooth/bluetooth_adapter_factory.h" #include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/test/mock_bluetooth_adapter.h" #include "device/bluetooth/test/mock_bluetooth_adapter.h"
#include "device/bluetooth/test/mock_bluetooth_device.h" #include "device/bluetooth/test/mock_bluetooth_device.h"
...@@ -255,4 +256,18 @@ TEST_F(BluetoothNotificationControllerTest, ...@@ -255,4 +256,18 @@ TEST_F(BluetoothNotificationControllerTest,
EXPECT_EQ(0, system_tray_client_->show_bluetooth_settings_count()); EXPECT_EQ(0, system_tray_client_->show_bluetooth_settings_count());
} }
TEST_F(BluetoothNotificationControllerTest,
PairedDeviceNotification_DeviceConnectionInitiatedByNearbyClient) {
VerifyPairedNotificationIsNotVisible(bluetooth_device_1_.get());
base::flat_set<device::BluetoothUUID> uuid_set;
uuid_set.insert(chromeos::nearby::GetNearbyClientUuids()[0]);
ON_CALL(*bluetooth_device_1_, GetUUIDs()).WillByDefault(Return(uuid_set));
ShowPairedNotification(notification_controller_.get(),
bluetooth_device_1_.get());
VerifyPairedNotificationIsNotVisible(bluetooth_device_1_.get());
}
} // namespace ash } // namespace ash
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