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 {
advertising_data.push_back(std::move(local_name));
// 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) {
mojom::BluetoothAdvertisingDataPtr service_uuids =
mojom::BluetoothAdvertisingData::New();
......
......@@ -24,11 +24,13 @@
#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_le_advertising_manager_client.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
constexpr int16_t kTestRssi = -50;
constexpr int16_t kTestRssi2 = -70;
constexpr char kTestServiceUUID[] = "00001357-0000-1000-8000-00805f9b34fb";
} // namespace
namespace arc {
......@@ -52,6 +54,10 @@ class ArcBluetoothBridgeTest : public testing::Test {
fake_bluetooth_device_client->CreateDevice(
dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath),
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(
dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
fake_bluetooth_gatt_characteristic_client->ExposeHeartRateCharacteristics(
......@@ -205,7 +211,7 @@ class ArcBluetoothBridgeTest : public testing::Test {
TEST_F(ArcBluetoothBridgeTest, DeviceFound) {
EXPECT_EQ(0u, fake_bluetooth_instance_->device_found_data().size());
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 =
fake_bluetooth_instance_->device_found_data().back();
......@@ -217,9 +223,12 @@ TEST_F(ArcBluetoothBridgeTest, DeviceFound) {
EXPECT_EQ(std::string(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress),
prop[1]->get_bdaddr()->To<std::string>());
EXPECT_TRUE(prop[2]->is_uuids());
EXPECT_EQ(1u, prop[2]->get_uuids().size());
EXPECT_EQ(bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID,
prop[2]->get_uuids()[0].value());
EXPECT_THAT(
prop[2]->get_uuids(),
testing::UnorderedElementsAre(
device::BluetoothUUID(
bluez::FakeBluetoothGattServiceClient::kHeartRateServiceUUID),
device::BluetoothUUID(kTestServiceUUID)));
EXPECT_TRUE(prop[3]->is_device_class());
EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyClass,
prop[3]->get_device_class());
......@@ -232,7 +241,7 @@ TEST_F(ArcBluetoothBridgeTest, DeviceFound) {
EXPECT_EQ(kTestRssi, prop[6]->get_remote_rssi());
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 =
fake_bluetooth_instance_->device_found_data().back();
EXPECT_EQ(7u, prop2.size());
......@@ -263,7 +272,7 @@ TEST_F(ArcBluetoothBridgeTest, LEDeviceFound) {
EXPECT_TRUE(adv_data[1]->is_service_uuids());
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());
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