0

Bluetooth: Floss: Wire ARC's OnServiceChanged

The OnServiceChanged isn't called when we're done updating a service,
but rather when we need to do a rediscovery because the peer updates
something.

Bug: b:284429795
Test: Pass ARC-T CTSV Bluetooth LE Insecure Client Test
Change-Id: Ide4c77a86fcb40d24ccbe41889c2839bc62e2a6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4617795
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Archie Pusaka <apusaka@chromium.org>
Reviewed-by: Gordon Seto <gordonseto@google.com>
Cr-Commit-Position: refs/heads/main@{#1159283}
This commit is contained in:
Archie
2023-06-17 08:11:04 +00:00
committed by Chromium LUCI CQ
parent 3ccfd8024e
commit 84d29de4c1
7 changed files with 48 additions and 1 deletions

@ -702,6 +702,26 @@ void ArcBluetoothBridge::GattDiscoveryCompleteForService(
// Placeholder for GATT client functionality
}
void ArcBluetoothBridge::GattNeedsDiscovery(BluetoothDevice* device) {
if (!arc_bridge_service_->bluetooth()->IsConnected()) {
return;
}
// This is a bit of a misnomer from ARC side: OnServiceChanged needs to be
// called when we get the signal that something is changed on the peer side,
// so ARC can start to re-discover everything again.
// However, the GattServiceChanged below indicates we have updated a service,
// so it doesn't actually mean ARC needs to re-discover everything.
auto* btle_instance = ARC_GET_INSTANCE_FOR_METHOD(
arc_bridge_service_->bluetooth(), OnServiceChanged);
if (!btle_instance) {
return;
}
btle_instance->OnServiceChanged(
mojom::BluetoothAddress::From(device->GetAddress()));
}
// TODO(b/284429795) This is wrong. See GattNeedsDiscovery above.
void ArcBluetoothBridge::GattServiceChanged(
BluetoothAdapter* adapter,
BluetoothRemoteGattService* service) {

@ -148,6 +148,8 @@ class ArcBluetoothBridge
device::BluetoothAdapter* adapter,
device::BluetoothRemoteGattService* service) override;
void GattNeedsDiscovery(device::BluetoothDevice* device) override;
void GattServiceChanged(device::BluetoothAdapter* adapter,
device::BluetoothRemoteGattService* service) override;

@ -361,6 +361,12 @@ void BluetoothAdapter::NotifyDeviceIsBlockedByPolicyChanged(
for (auto& observer : observers_)
observer.DeviceBlockedByPolicyChanged(this, device, new_blocked_status);
}
void BluetoothAdapter::NotifyGattNeedsDiscovery(BluetoothDevice* device) {
for (auto& observer : observers_) {
observer.GattNeedsDiscovery(device);
}
}
#endif
void BluetoothAdapter::NotifyGattServiceAdded(

@ -270,6 +270,12 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapter
BluetoothAdapter* adapter,
BluetoothRemoteGattService* service) {}
#if BUILDFLAG(IS_CHROMEOS)
// Called when the GATT service on the peer side indicates that something is
// changed on their side, so we need to start re-discovery everything.
virtual void GattNeedsDiscovery(BluetoothDevice* device) {}
#endif
// See "Deprecated GATT Added/Removed Events NOTE" above.
//
// Called when properties of the remote GATT service |service| have changed.
@ -689,6 +695,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapter
bool new_bonded_status);
void NotifyDeviceIsBlockedByPolicyChanged(BluetoothDevice* device,
bool new_blocked_status);
void NotifyGattNeedsDiscovery(BluetoothDevice* device);
#endif
void NotifyGattServiceAdded(BluetoothRemoteGattService* service);

@ -1000,4 +1000,14 @@ void BluetoothDeviceFloss::GattConfigureMtu(std::string address,
DidConnectGatt(absl::nullopt);
}
#if BUILDFLAG(IS_CHROMEOS)
void BluetoothDeviceFloss::GattServiceChanged(std::string address) {
if (address != GetAddress()) {
return;
}
adapter()->NotifyGattNeedsDiscovery(this);
}
#endif
} // namespace floss

@ -172,6 +172,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceFloss
int32_t mtu,
GattStatus status) override;
#if BUILDFLAG(IS_CHROMEOS)
void GattServiceChanged(std::string address) override;
void GattExecuteWrite(std::string address, GattStatus status) override;
#endif

@ -247,7 +247,8 @@ class DEVICE_BLUETOOTH_EXPORT FlossGattClientObserver
int32_t timeout,
GattStatus status) {}
// Notification when there is an addition/removal/change of a GATT service.
// Notification from the peer that some records are updated, so a re-discovery
// is in order.
virtual void GattServiceChanged(std::string address) {}
};