2021-04-01 10:33:54

by Yun-hao Chung

[permalink] [raw]
Subject: [Bluez PATCH 0/8] Hi Linux-bluetooth,

From: Yun-Hao Chung <[email protected]>


This series is to add a new method |SetServiceAllowList| in D-Bus API to
control what services can be connected by specifying UUID allow list.
Users can query a device property |IsBlockedByPolicy| to tell if some
of the services are currently restricted. Since we plan to add more
methods to limit different bluetooth functionalities, we also introduce
a new interface for this purpose. This series has been tested via sending
commands with dbus-send manually on chromebook octopus and eve.

Thanks,
Howard


Howard Chung (7):
doc: add description of SetServiceAllowList
lib: add hash functions for bt_uuid_t
core: add AdminPolicy Interface
input/hog: block connection by policy
audio: Remove Media1 interface when a2dp source disallowed
core: add properties IsBlockedByPolicy and ServiceAllowList
core: store ServiceAllowList into settings

Sonny Sasaka (1):
core: Initialize uuid_str_arr to NULL

Makefile.am | 3 +-
doc/admin_policy-api.txt | 34 +++++
doc/device-api.txt | 7 +
lib/uuid.c | 21 +++
lib/uuid.h | 3 +
profiles/audio/a2dp.c | 2 +
profiles/audio/avrcp.c | 3 +
profiles/input/hog.c | 22 +++
src/adapter.c | 148 +++++++++++++++++++-
src/adapter.h | 5 +
src/admin_policy.c | 292 +++++++++++++++++++++++++++++++++++++++
src/admin_policy.h | 23 +++
src/device.c | 79 ++++++++++-
src/device.h | 2 +
src/profile.c | 39 ++++++
src/profile.h | 5 +
src/service.c | 21 +++
src/service.h | 1 +
18 files changed, 705 insertions(+), 5 deletions(-)
create mode 100644 doc/admin_policy-api.txt
create mode 100644 src/admin_policy.c
create mode 100644 src/admin_policy.h

--
2.31.0.291.g576ba9dcdaf-goog


2021-04-01 10:35:54

by Yun-hao Chung

[permalink] [raw]
Subject: [Bluez PATCH 5/8] audio: Remove Media1 interface when a2dp source disallowed

When A2DP source profile is not allowed by policy, we remove the
a2dp_server and everything inside the object, which also release all
MediaEndpoints and MediaPlayer. When admin re-allowed A2DP source
profile, although we recreate the a2dp_server, clients are not able to
know they can register their endpoint and player now.

This patch handle this case by unregistering Media1 interface
when we remove a2dp_server, and register it back when a2dp_source is
allowed.

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

profiles/audio/a2dp.c | 2 ++
profiles/audio/avrcp.c | 3 +++
2 files changed, 5 insertions(+)

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index d31ed845cbe7..26d4f365207e 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -3275,6 +3275,7 @@ static int a2dp_source_server_probe(struct btd_profile *p,
{
struct a2dp_server *server;

+ media_register(adapter);
DBG("path %s", adapter_get_path(adapter));

server = find_server(servers, adapter);
@@ -3315,6 +3316,7 @@ static void a2dp_source_server_remove(struct btd_profile *p,
return;

a2dp_server_unregister(server);
+ media_unregister(adapter);
}

static int a2dp_sink_server_probe(struct btd_profile *p,
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 05dd791ded7c..c25495f19492 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -4735,6 +4735,8 @@ static void avrcp_controller_server_remove(struct btd_profile *p,

if (server->tg_record_id == 0)
avrcp_server_unregister(server);
+
+ media_unregister(adapter);
}

static int avrcp_controller_server_probe(struct btd_profile *p,
@@ -4745,6 +4747,7 @@ static int avrcp_controller_server_probe(struct btd_profile *p,

DBG("path %s", adapter_get_path(adapter));

+ media_register(adapter);
server = find_server(servers, adapter);
if (server != NULL)
goto done;
--
2.31.0.291.g576ba9dcdaf-goog

2021-04-01 17:49:47

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [Bluez PATCH 0/8] Hi Linux-bluetooth,

Hi Howard,

On Thu, Apr 1, 2021 at 3:25 AM Howard Chung <[email protected]> wrote:
>
> From: Yun-Hao Chung <[email protected]>
>
>
> This series is to add a new method |SetServiceAllowList| in D-Bus API to
> control what services can be connected by specifying UUID allow list.
> Users can query a device property |IsBlockedByPolicy| to tell if some
> of the services are currently restricted. Since we plan to add more
> methods to limit different bluetooth functionalities, we also introduce
> a new interface for this purpose. This series has been tested via sending
> commands with dbus-send manually on chromebook octopus and eve.
>
> Thanks,
> Howard
>
>
> Howard Chung (7):
> doc: add description of SetServiceAllowList
> lib: add hash functions for bt_uuid_t
> core: add AdminPolicy Interface
> input/hog: block connection by policy
> audio: Remove Media1 interface when a2dp source disallowed
> core: add properties IsBlockedByPolicy and ServiceAllowList
> core: store ServiceAllowList into settings
>
> Sonny Sasaka (1):
> core: Initialize uuid_str_arr to NULL
>
> Makefile.am | 3 +-
> doc/admin_policy-api.txt | 34 +++++
> doc/device-api.txt | 7 +
> lib/uuid.c | 21 +++
> lib/uuid.h | 3 +
> profiles/audio/a2dp.c | 2 +
> profiles/audio/avrcp.c | 3 +
> profiles/input/hog.c | 22 +++
> src/adapter.c | 148 +++++++++++++++++++-
> src/adapter.h | 5 +
> src/admin_policy.c | 292 +++++++++++++++++++++++++++++++++++++++
> src/admin_policy.h | 23 +++
> src/device.c | 79 ++++++++++-
> src/device.h | 2 +
> src/profile.c | 39 ++++++
> src/profile.h | 5 +
> src/service.c | 21 +++
> src/service.h | 1 +
> 18 files changed, 705 insertions(+), 5 deletions(-)
> create mode 100644 doc/admin_policy-api.txt
> create mode 100644 src/admin_policy.c
> create mode 100644 src/admin_policy.h
>
> --
> 2.31.0.291.g576ba9dcdaf-goog

I think I mentioned to one of you guys before so sorry I will be
repeating myself, we did in the past have control over
blocking/connection on a per service level using a plugin:

https://github.com/Vudentz/BlueZ/commits/service_api
https://github.com/Vudentz/BlueZ/blob/service_api/plugins/service.c

It probably need some rebasing to be applied on top but it already
gives upper layer control over things like auto-connect and blocked
properties, I've didn't add support for persisting the setting on
storage though since this use case was limited to car industry but if
we go into this direction I rather have this plugin instead.

--
Luiz Augusto von Dentz