2020-08-21 07:06:01

by Sonny Sasaka

[permalink] [raw]
Subject: [PATCH BlueZ] gap: Enable the external flag

From: Joseph Hwang <[email protected]>

This patch enables the external flag for gap so that the gap service can
be exported over D-Bus.

Tested on Chrome OS that this fixes https://crbug.com/722987 so that GAP
API can be propagated to Android apps.

Test Method 1:
- Connect to a peripheral.
- Use dbus methods to query the org.bluez.GattService1
interface in managed objects.
- Confirm that the gap 0x1800 profile was exported like:
GattService1 path: /org/bluez/hci0/dev_xx/service0001
service_props: dbus.String(u'UUID'):
dbus.String(u'00001800-0000-1000-8000-00805f9b34fb'

Test Method 2:
- Install BleManager APK attached in C#0 of https://crbug.com/722987
to ARC++ in a chromebook.
- Launch the application.
- Connect to a Dash robot. Confirm that there are 3 services
instead of 2.

Reviewed-by: Sonny Sasaka <[email protected]>

---
profiles/gap/gas.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/profiles/gap/gas.c b/profiles/gap/gas.c
index dffa31314..abe5341c0 100644
--- a/profiles/gap/gas.c
+++ b/profiles/gap/gas.c
@@ -310,6 +310,7 @@ static int gap_disconnect(struct btd_service *service)
static struct btd_profile gap_profile = {
.name = "gap-profile",
.remote_uuid = GAP_UUID,
+ .external = true,
.device_probe = gap_probe,
.device_remove = gap_remove,
.accept = gap_accept,
--
2.26.2


2020-08-21 17:33:51

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH BlueZ] gap: Enable the external flag

Hi Sonny,

On Fri, Aug 21, 2020 at 12:08 AM Sonny Sasaka <[email protected]> wrote:
>
> From: Joseph Hwang <[email protected]>
>
> This patch enables the external flag for gap so that the gap service can
> be exported over D-Bus.
>
> Tested on Chrome OS that this fixes https://crbug.com/722987 so that GAP
> API can be propagated to Android apps.
>
> Test Method 1:
> - Connect to a peripheral.
> - Use dbus methods to query the org.bluez.GattService1
> interface in managed objects.
> - Confirm that the gap 0x1800 profile was exported like:
> GattService1 path: /org/bluez/hci0/dev_xx/service0001
> service_props: dbus.String(u'UUID'):
> dbus.String(u'00001800-0000-1000-8000-00805f9b34fb'
>
> Test Method 2:
> - Install BleManager APK attached in C#0 of https://crbug.com/722987
> to ARC++ in a chromebook.
> - Launch the application.
> - Connect to a Dash robot. Confirm that there are 3 services
> instead of 2.
>
> Reviewed-by: Sonny Sasaka <[email protected]>
>
> ---
> profiles/gap/gas.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/profiles/gap/gas.c b/profiles/gap/gas.c
> index dffa31314..abe5341c0 100644
> --- a/profiles/gap/gas.c
> +++ b/profiles/gap/gas.c
> @@ -310,6 +310,7 @@ static int gap_disconnect(struct btd_service *service)
> static struct btd_profile gap_profile = {
> .name = "gap-profile",
> .remote_uuid = GAP_UUID,
> + .external = true,
> .device_probe = gap_probe,
> .device_remove = gap_remove,
> .accept = gap_accept,
> --
> 2.26.2

I guess you will end up exporting every single service at the end, so
perhaps we should just have an entry to main.conf
(ExportClaimedServices) where the system can define if services
claimed by plugins are allowed to be accessed over D-Bus, and we
should probably add a comment that when doing so it may cause
conflicts between the daemon and applications (especially GAP/GATT
service can be very sensitive).


--
Luiz Augusto von Dentz