Commit f68faa20 authored by Qiyu Hu's avatar Qiyu Hu Committed by Commit Bot

arc: bluetooth: Exclude GATT service UUIDs from advertisement data

According to "Supplement to the Bluetooth Core Specification" (CSS 7.0,
https://www.bluetooth.com/specifications/bluetooth-core-specification),
Part A, 1.1, "GAP and GATT service UUIDs should not be included in a
Service UUIDs AD type, for either a complete or incomplete list."

present in scan result

Bug: 78593133
Test: Do nRF scan and confirm that only non GATT service UUIDs are
Change-Id: Ia1d069a4356b1de90c19667fa28db167a5e3a7bb
Reviewed-on: https://chromium-review.googlesource.com/1108882
Commit-Queue: Qiyu Hu <qiyuh@google.com>
Reviewed-by: default avatarLuis Hector Chavez <lhchavez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569323}
parent 10d938c3
...@@ -2678,7 +2678,11 @@ ArcBluetoothBridge::GetAdvertisingData(const BluetoothDevice* device) const { ...@@ -2678,7 +2678,11 @@ ArcBluetoothBridge::GetAdvertisingData(const BluetoothDevice* device) const {
advertising_data.push_back(std::move(local_name)); advertising_data.push_back(std::move(local_name));
// Service UUIDs // Service UUIDs
const BluetoothDevice::UUIDSet& uuid_set = device->GetUUIDs(); BluetoothDevice::UUIDSet uuid_set = device->GetUUIDs();
for (const BluetoothRemoteGattService* gatt_service :
device->GetGattServices()) {
uuid_set.erase(gatt_service->GetUUID());
}
if (uuid_set.size() > 0) { if (uuid_set.size() > 0) {
mojom::BluetoothAdvertisingDataPtr service_uuids = mojom::BluetoothAdvertisingDataPtr service_uuids =
mojom::BluetoothAdvertisingData::New(); mojom::BluetoothAdvertisingData::New();
......
...@@ -24,11 +24,13 @@ ...@@ -24,11 +24,13 @@
#include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h" #include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h"
#include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h" #include "device/bluetooth/dbus/fake_bluetooth_gatt_service_client.h"
#include "device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.h" #include "device/bluetooth/dbus/fake_bluetooth_le_advertising_manager_client.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace { namespace {
constexpr int16_t kTestRssi = -50; constexpr int16_t kTestRssi = -50;
constexpr int16_t kTestRssi2 = -70; constexpr int16_t kTestRssi2 = -70;
constexpr char kTestServiceUUID[] = "00001357-0000-1000-8000-00805f9b34fb";
} // namespace } // namespace
namespace arc { namespace arc {
...@@ -52,6 +54,10 @@ class ArcBluetoothBridgeTest : public testing::Test { ...@@ -52,6 +54,10 @@ class ArcBluetoothBridgeTest : public testing::Test {
fake_bluetooth_device_client->CreateDevice( fake_bluetooth_device_client->CreateDevice(
dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath),
dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
fake_bluetooth_device_client->UpdateServiceAndManufacturerData(
dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath),
{kTestServiceUUID}, /* service_data = */ {},
/* manufacture_data = */ {});
fake_bluetooth_gatt_service_client->ExposeHeartRateService( fake_bluetooth_gatt_service_client->ExposeHeartRateService(
dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath)); dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
fake_bluetooth_gatt_characteristic_client->ExposeHeartRateCharacteristics( fake_bluetooth_gatt_characteristic_client->ExposeHeartRateCharacteristics(
...@@ -205,7 +211,7 @@ class ArcBluetoothBridgeTest : public testing::Test { ...@@ -205,7 +211,7 @@ class ArcBluetoothBridgeTest : public testing::Test {
TEST_F(ArcBluetoothBridgeTest, DeviceFound) { TEST_F(ArcBluetoothBridgeTest, DeviceFound) {
EXPECT_EQ(0u, fake_bluetooth_instance_->device_found_data().size()); EXPECT_EQ(0u, fake_bluetooth_instance_->device_found_data().size());
AddTestDevice(); AddTestDevice();
EXPECT_EQ(2u, fake_bluetooth_instance_->device_found_data().size()); EXPECT_EQ(5u, fake_bluetooth_instance_->device_found_data().size());
const std::vector<mojom::BluetoothPropertyPtr>& prop = const std::vector<mojom::BluetoothPropertyPtr>& prop =
fake_bluetooth_instance_->device_found_data().back(); fake_bluetooth_instance_->device_found_data().back();
...@@ -217,9 +223,12 @@ TEST_F(ArcBluetoothBridgeTest, DeviceFound) { ...@@ -217,9 +223,12 @@ TEST_F(ArcBluetoothBridgeTest, DeviceFound) {
EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress), EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress),
prop[1]->get_bdaddr()->To<std::string>()); prop[1]->get_bdaddr()->To<std::string>());
EXPECT_TRUE(prop[2]->is_uuids()); EXPECT_TRUE(prop[2]->is_uuids());
EXPECT_EQ(1u, prop[2]->get_uuids().size()); EXPECT_THAT(
EXPECT_EQ(bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID, prop[2]->get_uuids(),
prop[2]->get_uuids()[0].value()); testing::UnorderedElementsAre(
device::BluetoothUUID(
bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID),
device::BluetoothUUID(kTestServiceUUID)));
EXPECT_TRUE(prop[3]->is_device_class()); EXPECT_TRUE(prop[3]->is_device_class());
EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyClass, EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyClass,
prop[3]->get_device_class()); prop[3]->get_device_class());
...@@ -232,7 +241,7 @@ TEST_F(ArcBluetoothBridgeTest, DeviceFound) { ...@@ -232,7 +241,7 @@ TEST_F(ArcBluetoothBridgeTest, DeviceFound) {
EXPECT_EQ(kTestRssi, prop[6]->get_remote_rssi()); EXPECT_EQ(kTestRssi, prop[6]->get_remote_rssi());
ChangeTestDeviceRssi(kTestRssi2); ChangeTestDeviceRssi(kTestRssi2);
EXPECT_EQ(3u, fake_bluetooth_instance_->device_found_data().size()); EXPECT_EQ(6u, fake_bluetooth_instance_->device_found_data().size());
const std::vector<mojom::BluetoothPropertyPtr>& prop2 = const std::vector<mojom::BluetoothPropertyPtr>& prop2 =
fake_bluetooth_instance_->device_found_data().back(); fake_bluetooth_instance_->device_found_data().back();
EXPECT_EQ(7u, prop2.size()); EXPECT_EQ(7u, prop2.size());
...@@ -263,7 +272,7 @@ TEST_F(ArcBluetoothBridgeTest, LEDeviceFound) { ...@@ -263,7 +272,7 @@ TEST_F(ArcBluetoothBridgeTest, LEDeviceFound) {
EXPECT_TRUE(adv_data[1]->is_service_uuids()); EXPECT_TRUE(adv_data[1]->is_service_uuids());
EXPECT_EQ(1u, adv_data[1]->get_service_uuids().size()); EXPECT_EQ(1u, adv_data[1]->get_service_uuids().size());
EXPECT_EQ(bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID, EXPECT_EQ(kTestServiceUUID,
adv_data[1]->get_service_uuids()[0].canonical_value()); adv_data[1]->get_service_uuids()[0].canonical_value());
EXPECT_EQ(kTestRssi, le_device_found_data->rssi()); EXPECT_EQ(kTestRssi, le_device_found_data->rssi());
......
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