platform/upstream/bluez.git
2 years agoemulator: Inclusive language changes
Archie Pusaka [Wed, 15 Sep 2021 08:31:58 +0000 (16:31 +0800)]
emulator: Inclusive language changes

BT core spec 5.3 promotes the usage of inclusive languages.
This CL replaces some terms with the more appropriate counterparts,
such as "central", "peripheral", and "accept list".

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Inclusive language changes
Archie Pusaka [Wed, 15 Sep 2021 08:31:57 +0000 (16:31 +0800)]
monitor: Inclusive language changes

BT core spec 5.3 promotes the usage of inclusive languages.
This CL replaces some terms with the more appropriate counterparts,
such as "central", "peripheral", "link key", and "accept list"

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtio: Inclusive language changes
Archie Pusaka [Wed, 15 Sep 2021 08:31:56 +0000 (16:31 +0800)]
btio: Inclusive language changes

BT core spec 5.3 promotes the usage of inclusive languages.
This CL uses "central" as it is deemed to be more appropriate.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agolib: Inclusive language changes
Archie Pusaka [Wed, 15 Sep 2021 08:31:55 +0000 (16:31 +0800)]
lib: Inclusive language changes

BT core spec 5.3 promotes the usage of inclusive languages.
This CL replaces some terms with the more appropriate counterparts,
such as "central", "peripheral", and "accept list".

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomedia: Add media_player prefix for callback
Luiz Augusto von Dentz [Fri, 17 Sep 2021 20:50:45 +0000 (13:50 -0700)]
media: Add media_player prefix for callback

This adds media_player prefix to callback so it is inline with pause
which now uses such callback due to possible clash with libc
definition.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomedia: Fix build with glibc >= 2.34
Fabrice Fontaine [Sun, 12 Sep 2021 20:48:39 +0000 (22:48 +0200)]
media: Fix build with glibc >= 2.34

pause() is defined in glibc since the very early times; it appears in
upstream commit 28f540f45bba (initial import) in 1995 [0].

Bluez has been defining a function named pause() for ages too, since
commit caab74c97542 (media: Implement new callbacks for pass-through
operations) in 2013 [1]

With the recent bump to glibc 2.34.xxx, the build now fails because the
two pause() clash:

profiles/audio/media.c:1284:13: error: conflicting types for 'pause'
 1284 | static bool pause(void *user_data)
      |             ^~~~~
In file included from /tmp/instance-0/output-1/per-package/bluez5_utils/host/s390x-buildroot-linux-gnu/sysroot/usr/include/bits/sigstksz.h:24,
                 from /tmp/instance-0/output-1/per-package/bluez5_utils/host/s390x-buildroot-linux-gnu/sysroot/usr/include/signal.h:328,
                 from /tmp/instance-0/output-1/per-package/bluez5_utils/host/bin/../s390x-buildroot-linux-gnu/sysroot/usr/include/glib-2.0/glib/gbacktrace.h:36,
                 from /tmp/instance-0/output-1/per-package/bluez5_utils/host/bin/../s390x-buildroot-linux-gnu/sysroot/usr/include/glib-2.0/glib.h:34,
                 from profiles/audio/media.c:21:
/tmp/instance-0/output-1/per-package/bluez5_utils/host/s390x-buildroot-linux-gnu/sysroot/usr/include/unistd.h:489:12: note: previous declaration of 'pause' was here
  489 | extern int pause (void);
      |            ^~~~~

The culprit is indeed glibc 2.34, as can be seen in this result matrix:

         \   bluez5_utils
    glibc \  5.60  |  5.61
    -------\-------+--------
    2.33   |  OK   |   OK
    -------+-------+--------
    2.34   |  KO   |   KO

The underlying reason that pause() is now causing issues with glibc 2.34
is not obvious: glibc is a big beast, and finding such issues is not
easy. However, we can see that the pause() provided by NPTL has been
dropped in favour of the generic one, so maybe this is causing symbol
visibility or weakness to change or something...

We fix that by renaming the local pause() in bluez5_utils with a
namespace-prefix, like some other functions there already have.

Fixes:
  - http://autobuild.buildroot.org/results/c4fbface34be8815838fd7201621d7a8fddd32c5
  - http://autobuild.buildroot.org/results/62b88740f19fbe4a1ad7959dc141d539eb88c1f8

[0] https://sourceware.org/git/?p=glibc.git;a=commit;h=28f540f45bbacd939bfd07f213bcad2bf730b1bf
[1] https://github.com/bluez/bluez/commit/caab74c97542a56b591f0b16b44ab6ba4b40f0f5

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools: userchan-tester: Add test case for the closing channel
Tedd Ho-Jeong An [Fri, 20 Aug 2021 05:07:05 +0000 (22:07 -0700)]
tools: userchan-tester: Add test case for the closing channel

This patch adds a test casse for checking the controller power state
after closing the user channel.

When the user channel is closed, the controller should be powered down
state.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agolib: Fix variable-length array declarations in hci structures
Peter A. Bigot [Tue, 31 Aug 2021 16:35:45 +0000 (09:35 -0700)]
lib: Fix variable-length array declarations in hci structures

Use of zero as the size for arrays as the last element of a structure
is a GNU C extension, which as of GCC 10 produces diagnostics when
values in the extended array are referenced.  Switch to the C99
standard idiom for flexible array members, already in use in a few
other headers.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadmin: Fix double free
Luiz Augusto von Dentz [Thu, 16 Sep 2021 22:36:00 +0000 (15:36 -0700)]
admin: Fix double free

Fixes the following double free which happen due to exit calling
btd_unregister_adapter_driver:

Invalid read of size 8
   at 0x1CDA97: queue_foreach (queue.c:198)
   by 0x1318B8: admin_policy_remove (admin.c:591)
   by 0x18982A: plugin_cleanup (plugin.c:217)
   by 0x12E3FD: main (main.c:1214)
 Address 0x547ffb8 is 8 bytes inside a block of size 32 free'd
   at 0x483A9F5: free (vg_replace_malloc.c:538)
   by 0x1318CB: admin_policy_remove (admin.c:592)
   by 0x18F416: unload_driver (adapter.c:7215)
   by 0x496F50F: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.6600.8)
   by 0x131988: admin_exit (admin.c:623)
   by 0x18982A: plugin_cleanup (plugin.c:217)
   by 0x12E3FD: main (main.c:1214)
 Block was alloc'd at
   at 0x4839809: malloc (vg_replace_malloc.c:307)
   by 0x1CDE1E: btd_malloc (util.c:33)
   by 0x1CD83D: queue_new (queue.c:47)
   by 0x13150D: admin_init (admin.c:614)
   by 0x18966B: plugin_init (plugin.c:187)
   by 0x12E358: main (main.c:1198)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadmin: Fix leaking uuids loads from storage
Luiz Augusto von Dentz [Thu, 16 Sep 2021 22:18:14 +0000 (15:18 -0700)]
admin: Fix leaking uuids loads from storage

This fixes the following trace:

8 bytes in 1 blocks are definitely lost in loss record 27 of 274
   at 0x4839809: malloc (vg_replace_malloc.c:307)
   by 0x495BBB8: g_malloc (in /usr/lib64/libglib-2.0.so.0.6600.8)
   by 0x494C024: g_key_file_get_string_list (in /usr/lib64/libglib-2.0.so.0.6600.8)
   by 0x131ECD: key_file_load_service_allowlist (admin.c:294)
   by 0x131ECD: load_policy_settings (admin.c:346)
   by 0x131ECD: admin_policy_adapter_probe (admin.c:497)
   by 0x18F554: probe_driver (adapter.c:4858)
   by 0x19DF5A: load_drivers (adapter.c:4873)
   by 0x19DF5A: adapter_register (adapter.c:8975)
   by 0x19DF5A: read_info_complete (adapter.c:9791)
   by 0x1CE831: request_complete (mgmt.c:264)
   by 0x1CF7D4: can_read_data (mgmt.c:356)
   by 0x1DE634: watch_callback (io-glib.c:157)
   by 0x4953A9E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6600.8)
   by 0x49A5A97: ??? (in /usr/lib64/libglib-2.0.so.0.6600.8)
   by 0x4953162: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6600.8)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agopolicy: Use btd_service_is_initiator
Luiz Augusto von Dentz [Thu, 16 Sep 2021 18:25:12 +0000 (11:25 -0700)]
policy: Use btd_service_is_initiator

Instead of using BTD_SERVICE_STATE_CONNECTING use
btd_service_is_initiator to determine if the service initiated the
connection and then proceed to connect other service immediately.

Fixes: https://github.com/bluez/bluez/issues/205
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoservice: Add btd_service_is_initiator
Luiz Augusto von Dentz [Thu, 16 Sep 2021 18:16:08 +0000 (11:16 -0700)]
service: Add btd_service_is_initiator

Since BTD_SERVICE_STATE_CONNECTING is being used for both initiator and
responder case it is no longer possible to use the state distint when
the service connection was initiated locally or not, so to fix this a
new flag is introduce to track when btd_service_connect has been
called.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agosco-tester: Add tests for sending data
Luiz Augusto von Dentz [Wed, 15 Sep 2021 22:35:01 +0000 (15:35 -0700)]
sco-tester: Add tests for sending data

This adds tests for sending data over the socket.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugins/admin: create admin_policy_settings if not exists
Yun-Hao Chung [Mon, 6 Sep 2021 06:03:17 +0000 (14:03 +0800)]
plugins/admin: create admin_policy_settings if not exists

If admin_policy_settings is not found when loading, we should create one
instead of printing error.

Reviewed-by: Shyh-In Hwang <josephsih@chromium.org>
Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugins/admin: add adapter_remove handler
Yun-Hao Chung [Mon, 6 Sep 2021 06:03:16 +0000 (14:03 +0800)]
plugins/admin: add adapter_remove handler

Currently admin doesn't handle adapter removed callbacks, which causes
interfaces AdminPolicySet1 and AdminPolicyStatus1 not being
unregistered, which in turns causes these interfaces can not be
re-registered once adapter is back.

This adds handler for adapter_remove.

Reviewed-by: Shyh-In Hwang <josephsih@chromium.org>
Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mgmt-tester: Update exp feature testcase
Tedd Ho-Jeong An [Tue, 14 Sep 2021 22:39:07 +0000 (15:39 -0700)]
tools/mgmt-tester: Update exp feature testcase

This patch updates the experimental feature test case with the recently
added "codec offload" feature.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/util: Update UUID database with LE Audio services
Luiz Augusto von Dentz [Mon, 13 Sep 2021 18:04:05 +0000 (11:04 -0700)]
shared/util: Update UUID database with LE Audio services

This updates UUID database with the values from assigned numbers for LE
Audio services.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/util: Add conversion function for 24 bits
Luiz Augusto von Dentz [Tue, 4 Aug 2020 23:42:31 +0000 (16:42 -0700)]
shared/util: Add conversion function for 24 bits

This adds get/put 24 bits variants.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadv_monitor: Clear any running DeviceLost timers on power down
Manish Mandlik [Fri, 10 Sep 2021 02:05:36 +0000 (19:05 -0700)]
adv_monitor: Clear any running DeviceLost timers on power down

This patch clears any running Adv Monitor DeviceLost timers on bt power
down. It'll also invoke DeviceLost event if the device is already found
and is being tracked for the DeviceLost event.

Verified this by adding a monitor using bluetoothctl and confirming that
the DeviceLost event is getting triggered for already found device in
case of bt power down.

Reviewed-by: mcchou@google.com
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Enable codec offload when Experimental is set
Luiz Augusto von Dentz [Tue, 7 Sep 2021 22:27:10 +0000 (15:27 -0700)]
adapter: Enable codec offload when Experimental is set

This enables codec offload experimental feature if its UUIDs has been
enabled by main.conf:Experimental or -E has been passed in the command
line.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomain.conf: Allow passing a list of UUIDs to Experimental
Luiz Augusto von Dentz [Tue, 7 Sep 2021 21:05:38 +0000 (14:05 -0700)]
main.conf: Allow passing a list of UUIDs to Experimental

This allows the user to enable a subset of the experimental features to
be enabled instead of all of them and also change -E to work in the same
way so a list of UUIDs can also be given at the command line.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoclient: Add support for printing ExperimentalFeatures property
Luiz Augusto von Dentz [Tue, 17 Aug 2021 00:56:34 +0000 (17:56 -0700)]
client: Add support for printing ExperimentalFeatures property

Thid adds support to show command to print ExperimentalFeatures property:

[bluetooth]# show
Controller ...
Experimental: BlueZ Experimental LL p.. (15c0a148-c273-11ea-b3de-0242ac130004)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Implement ExperimentalFeatures property
Luiz Augusto von Dentz [Tue, 17 Aug 2021 00:54:03 +0000 (17:54 -0700)]
adapter: Implement ExperimentalFeatures property

This implements ExperimentalFeatures property which indicates the list
of UUIDs that represents the experimental features currently enabled.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter-api: Add ExperimentalFeatures property
Luiz Augusto von Dentz [Mon, 16 Aug 2021 23:20:10 +0000 (16:20 -0700)]
adapter-api: Add ExperimentalFeatures property

This adds ExperimentalFeatures property which indicates what
experimental features are currently enabled.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/sco-tester: add a test case for offload SCO connect
Kiran K [Tue, 7 Sep 2021 11:25:56 +0000 (16:55 +0530)]
tools/sco-tester: add a test case for offload SCO connect

Add a test case for offload SCO connect with codec type set to mSBC

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/sco-tester: Add a test case for setting offload codec
Kiran K [Tue, 7 Sep 2021 11:25:55 +0000 (16:55 +0530)]
tools/sco-tester: Add a test case for setting offload codec

Add a test case to set codec for HFP offload use case

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/sco-tester: add test cases to get offload codecs
Kiran K [Tue, 7 Sep 2021 11:25:54 +0000 (16:55 +0530)]
tools/sco-tester: add test cases to get offload codecs

Add a test case to query offload codecs supported over sco

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoavdtp: use separate local SEID pool for each adapter
Pauli Virtanen [Sun, 5 Sep 2021 15:43:56 +0000 (18:43 +0300)]
avdtp: use separate local SEID pool for each adapter

Local SEIDs are currently allocated from a pool that is common for all
adapters. However, AVDTP spec v1.3, sec 4.10 states "To prevent
conflicts, the scope of the SEID shall be both device-local and
connection-local. The application is responsible for assigning a SEID,
which is not in use on the connection to the same peer device." In
practice, registering the same media application for multiple adapters
can result to running out of SEIDs, even though the spec does not
require SEIDs to be unique across adapters.

To fix this, have a2dp_server own the SEID pool and pass it to avdtp
functions. Currently, a2dp_server is the only one that registers local
SEPs, and its correspondence to adapters is unique, so it can own the
pool.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/util: use 64-bit bitmap in util_get/clear_uid
Pauli Virtanen [Sun, 5 Sep 2021 15:43:55 +0000 (18:43 +0300)]
shared/util: use 64-bit bitmap in util_get/clear_uid

The util_get/clear_uid functions use int type for bitmap, and are used
e.g. for SEID allocation. However, valid SEIDs are in range 1 to 0x3E
(AVDTP spec v1.3, 8.20.1), and 8*sizeof(int) is often smaller than 0x3E.

The function is also used in src/advertising.c, but an explicit maximum
value is always provided, so growing the bitmap size is safe there.

Use 64-bit bitmap instead, to be able to cover the valid range.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/shell: don't allow completion fallback
Alain Michaud [Fri, 3 Sep 2021 14:01:18 +0000 (14:01 +0000)]
shared/shell: don't allow completion fallback

When using bluetoothctl, if the user enters a quotation mark before
pressing tab, the completion handler falls back to the shell's handler
which ends up printing the current folder's file content.  This behavior
is never desired in bt_shell's menu.

This was verified by typing " then tab-tab before and after the change as
been made to confirm the desired behavior and verified that all other
argument completions (such as address completion) continues to function.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix calculation of RFCOMM length
Luiz Augusto von Dentz [Fri, 3 Sep 2021 00:01:24 +0000 (17:01 -0700)]
monitor: Fix calculation of RFCOMM length

Byte order is assumed to be big endian instead of little endian.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugin/admin: fix set empty allowlist no persistence issue
Yun-Hao Chung [Tue, 31 Aug 2021 05:39:00 +0000 (13:39 +0800)]
plugin/admin: fix set empty allowlist no persistence issue

This patch fixes a bug when setting empty service allowlist, the
allowlist sets successfully but it fails to be stored in the file.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtmgmt: add non-interactive quit on read-sysconfig
Yun-Hao Chung [Tue, 31 Aug 2021 05:44:36 +0000 (13:44 +0800)]
btmgmt: add non-interactive quit on read-sysconfig

This fixes the erros that read-sysconfig doesn't exit in non-interactive
mode.

Reviewed-by: Archie Pusaka <apusaka@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mgmt-tester: add a exp feature to Read Exp Feature - Success
Joseph Hwang [Fri, 20 Aug 2021 05:18:02 +0000 (13:18 +0800)]
tools/mgmt-tester: add a exp feature to Read Exp Feature - Success

This patch adds a new quality report feature to the
"Read Exp Feature - Success" test.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotest-runner: Enable bluetoothd debug when running with -d
Luiz Augusto von Dentz [Thu, 26 Aug 2021 16:30:31 +0000 (09:30 -0700)]
test-runner: Enable bluetoothd debug when running with -d

This enable bluetoothd debug when running with -d.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodevice: set le_state.svc_resolved = false in gatt_cache_cleanup()
David Lechner [Wed, 25 Aug 2021 16:51:25 +0000 (11:51 -0500)]
device: set le_state.svc_resolved = false in gatt_cache_cleanup()

When the GATT cache is cleared, there is no longer a list of GATT
services, so we need to set le_state.svc_resolved = false so that
the next time the device connects, it will enumerate the services
again.

This partially fixes an issue where the UUIDs D-Bus property was empty
after scanning, connecting, disconnecting and scanning again when
[GATT] Cache = yes is set in main.conf.

Issue: https://github.com/bluez/bluez/issues/192
Suggested-by: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodevice: clear eir_uuids list on disconnect
David Lechner [Wed, 25 Aug 2021 16:51:24 +0000 (11:51 -0500)]
device: clear eir_uuids list on disconnect

The eir_uuids list contains GATT service UUIDs from advertising data.
The device may advertise different UUIDs each time it is scanned and
connected, so the list needs to be cleared when the device disconnects.

This partially fixes an issue where the UUIDs D-Bus property is empty
after scanning, connecting, disconnecting and scanning again when
[GATT] Cache = yes is set in main.conf.

Issue: https://github.com/bluez/bluez/issues/192
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: Do not always attempt to connect EATT immediately
Luiz Augusto von Dentz [Wed, 25 Aug 2021 21:03:50 +0000 (14:03 -0700)]
gatt: Do not always attempt to connect EATT immediately

Wait the bt_gatt_client becomes ready (has performed service discovery)
before attempting to connect EATT when acting as peripheral/acceptor
since the central/initiator might actually attempt to connect EATT
channels in the same way which can potentially cause a collisions.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/att: Fix attempting to send Exchange MTU on EATT bearer
Luiz Augusto von Dentz [Wed, 25 Aug 2021 16:07:18 +0000 (09:07 -0700)]
shared/att: Fix attempting to send Exchange MTU on EATT bearer

EATT bearer shall use the L2CAP signalling for negotiating the MTU
size.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/att: Fix accepting Exchange MTU on EATT bearer
Luiz Augusto von Dentz [Wed, 25 Aug 2021 15:58:07 +0000 (08:58 -0700)]
shared/att: Fix accepting Exchange MTU on EATT bearer

If remote send Exchange MTU it shall fail as the MTU negotiation shall
happen over L2CAP signalling not ATT for those channels.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodevice: Remove GATT Attribute when device is removed
Luiz Augusto von Dentz [Tue, 24 Aug 2021 22:48:38 +0000 (15:48 -0700)]
device: Remove GATT Attribute when device is removed

This makes the GATT Attribute cache to be removed when device is removed
just like SDP ServiceRecords.

Fixes: https://github.com/bluez/bluez/issues/191
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoRelease 5.61
Marcel Holtmann [Sun, 22 Aug 2021 04:27:18 +0000 (06:27 +0200)]
Release 5.61

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mgmt-tester: Add Read OOB Ext Data test cases
Brian Gix [Wed, 18 Aug 2021 18:28:13 +0000 (11:28 -0700)]
tools/mgmt-tester: Add Read OOB Ext Data test cases

Read Local OOB Ext Data - Invalid index
Read Local OOB Ext Data - Legacy pairing
Read Local OOB Ext Data - Success SSP
Read Local OOB Ext Data - Success SC

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Fix removing advertising set if it was terminated
Luiz Augusto von Dentz [Wed, 18 Aug 2021 22:39:32 +0000 (15:39 -0700)]
btdev: Fix removing advertising set if it was terminated

Consider the advertising set disabled but don't remove it as the host
may still reuse it.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Fix order of BT_HCI_EVT_LE_ADV_SET_TERM
Luiz Augusto von Dentz [Wed, 18 Aug 2021 20:45:05 +0000 (13:45 -0700)]
btdev: Fix order of BT_HCI_EVT_LE_ADV_SET_TERM

BT_HCI_EVT_LE_ADV_SET_TERM shall come after
BT_HCI_EVT_LE_ENHANCED_CONN_COMPLETE otherwise the host doesn't know
the connection handle.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Fix sending terminate advertising event to the wrong device
Luiz Augusto von Dentz [Wed, 18 Aug 2021 18:42:53 +0000 (11:42 -0700)]
btdev: Fix sending terminate advertising event to the wrong device

The device where the event should be sent is the same that had created
not the connection one.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/util: Decode BlueZ offload codec UUID
Kiran K [Wed, 18 Aug 2021 05:59:48 +0000 (11:29 +0530)]
shared/util: Decode BlueZ offload codec UUID

This adds BlueZ offload codec UUID to uuid128_table so it is
decoded by the likes of btmon.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomgmt: Set offload codec mgmt feature
Kiran K [Wed, 18 Aug 2021 05:59:47 +0000 (11:29 +0530)]
mgmt: Set offload codec mgmt feature

Add mgmt support to toggle offload codec feature

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator: Add support enhanced SCO connection
Kiran K [Tue, 17 Aug 2021 08:49:41 +0000 (14:19 +0530)]
emulator: Add support enhanced SCO connection

Add support for enhanced_setup_synchronous_connection command
in btdev

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Track PSM for L2CAP analyze function
Marcel Holtmann [Tue, 17 Aug 2021 11:11:16 +0000 (13:11 +0200)]
monitor: Track PSM for L2CAP analyze function

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomain: Add missing Experimental entry to General options
Luiz Augusto von Dentz [Tue, 17 Aug 2021 00:47:38 +0000 (17:47 -0700)]
main: Add missing Experimental entry to General options

When Experimental was introduced it was not added to General option
which causes a warning to be printed when it is set.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Fix warning when exit
Luiz Augusto von Dentz [Tue, 17 Aug 2021 00:51:39 +0000 (17:51 -0700)]
adapter: Fix warning when exit

g_hash_table_destroy prints a warning when it is NULL so this checks if
adapter->allowed_uuid_set has actually been set.

Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Simplify setting of experimental debug feature
Luiz Augusto von Dentz [Mon, 16 Aug 2021 23:01:32 +0000 (16:01 -0700)]
adapter: Simplify setting of experimental debug feature

The action already indicates the value of btd_opts.experimental.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix logging of CIG Test SDU Interval param
Mariusz Skamra [Mon, 16 Aug 2021 14:29:56 +0000 (16:29 +0200)]
monitor: Fix logging of CIG Test SDU Interval param

This fixes log of SDU interval in StoM direction.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix Maximum PDU type in CIS Test Param
Mariusz Skamra [Mon, 16 Aug 2021 14:29:55 +0000 (16:29 +0200)]
monitor: Fix Maximum PDU type in CIS Test Param

The Maximum PDU in CIS Test parameters is 2 byte value.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Track L2CAP packets for analyze function
Marcel Holtmann [Mon, 16 Aug 2021 16:35:25 +0000 (18:35 +0200)]
monitor: Track L2CAP packets for analyze function

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Store MSFT extension event prefix
Marcel Holtmann [Mon, 16 Aug 2021 15:35:18 +0000 (17:35 +0200)]
monitor: Store MSFT extension event prefix

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobthost: Fix not initializing address types properly
Luiz Augusto von Dentz [Fri, 13 Aug 2021 20:54:10 +0000 (13:54 -0700)]
bthost: Fix not initializing address types properly

The address type given to the init_conn is the peer address type
(btdev) not the bthost address type, the old code assume it could use
since only BDADDR_BREDR or BDADDR_LE_PUBLIC was tested but with the
upcoming support for LL Privacy the peer address type would become
BDADDR_LE_RANDOM which cannot be used as address type of bthost as that
doesn't support random addresses and would likely cause SMP to fail when
pairing.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobthost: Add bthost_debug and use it on smp.c
Luiz Augusto von Dentz [Thu, 12 Aug 2021 20:19:14 +0000 (13:19 -0700)]
bthost: Add bthost_debug and use it on smp.c

This adds bthost_debug which wraps util_debug and make use of it in
smp.c.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugins/admin: add uuid duplicate check
Yun-Hao Chung [Wed, 11 Aug 2021 07:17:57 +0000 (15:17 +0800)]
plugins/admin: add uuid duplicate check

SetServiceAllowlist should ignore those duplicated UUIDs.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoclient: add AffectedByPolicy property
Yun-Hao Chung [Wed, 11 Aug 2021 07:08:57 +0000 (15:08 +0800)]
client: add AffectedByPolicy property

This prints property AffectedByPolicy in device info if
org.bluez.AdminPolicyStatus1 exists.

This also rename find_battery_by_path to find_proxies_by_path to reuse
the function.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoclient: add admin submenu and allow command
Yun-Hao Chung [Wed, 11 Aug 2021 07:08:56 +0000 (15:08 +0800)]
client: add admin submenu and allow command

This creates a menu - admin and add a commands to bluetoothctl
- allow [clear/uuid1 uuid2 ...]

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/shell: fix missing stdbool in shell.h
Yun-Hao Chung [Wed, 11 Aug 2021 07:08:55 +0000 (15:08 +0800)]
shared/shell: fix missing stdbool in shell.h

bt_shell_menu_exists_t returns bool, but stdbool.h is not included.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoclient/advertising: Fix not disabling local-name in Includes
Luiz Augusto von Dentz [Tue, 10 Aug 2021 21:59:12 +0000 (14:59 -0700)]
client/advertising: Fix not disabling local-name in Includes

When setting a advertising.name other than on/off it shall also disable
local-name flag from Includes as that would cause an error when parsed
by the daemon.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadvertising: Fix failing to advertise with Includes=local-name
Luiz Augusto von Dentz [Tue, 10 Aug 2021 21:50:16 +0000 (14:50 -0700)]
advertising: Fix failing to advertise with Includes=local-name

When local-name is set MGMT_ADV_FLAG_LOCAL_NAME would be set which would
be sent with MGMT_OP_ADD_EXT_ADV_PARAMS but latter one it would be
overwrite in generate_scan_rsp.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Make --analyze print address OUI
Luiz Augusto von Dentz [Mon, 9 Aug 2021 22:47:18 +0000 (15:47 -0700)]
monitor: Make --analyze print address OUI

This makes analyze.c use packet_print_addr which does take care of
decoding OUI portion of the address.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Make --analyze output latencies in msec
Luiz Augusto von Dentz [Fri, 6 Aug 2021 21:30:16 +0000 (14:30 -0700)]
monitor: Make --analyze output latencies in msec

Milisecconds is probably the best unit to have since it is unlikely that
the controller can respond in under 1 msec as well as most time
sensitive connection e.g. A2DP, HFP, etc, also don't expect the
latencies to be over 1 sec.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix not accouting for multiple outstanding packets
Luiz Augusto von Dentz [Fri, 6 Aug 2021 21:22:58 +0000 (14:22 -0700)]
monitor: Fix not accouting for multiple outstanding packets

Analyze code was not accounting for the fact that multiple outstanding
packets could be pending which will cause the last_tx to be overwritten
but its latency would be calculated against the very first packet
complete.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix minimun packet latency
Luiz Augusto von Dentz [Fri, 6 Aug 2021 21:05:16 +0000 (14:05 -0700)]
monitor: Fix minimun packet latency

It seems timer_sub can produce negative values leading to median packet
latency to be negative e.g conn->last_tx_compl is ahead of
conn->last_tx, in which case it should be discarded.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix median packet size
Luiz Augusto von Dentz [Fri, 6 Aug 2021 20:33:01 +0000 (13:33 -0700)]
monitor: Fix median packet size

Calculating the median packet based on the current median + size / 2
does not account for last packet could smaller e.g. opp transfer could
end with just 1 byte which would cut the median in a half, so this
switch to more traditional means of calculating by doing total bytes
sent / num of packets so each an every packet has the same weight.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoaudio/transport: Only store volume when also emitting DBus prop change
Marijn Suijten [Sun, 8 Aug 2021 14:35:55 +0000 (16:35 +0200)]
audio/transport: Only store volume when also emitting DBus prop change

By setting a2dp->volume early in set_volume() the resulting call to
media_transport_update_volume() when an AVRCP reply is received will
likely see the same volume received (unless the peer rounded it to
another value) and bail on equality, before emitting a DBus property
change.  This results in DBus clients not being made aware of the change
unless the peer is an audio source (that receives a notification about
changed volume, instead of a command to _set_ a new volume), where
set_volume() immediately raises the DBus signal.

This issue is observed when playing back audio to headphones through an
AbsoluteVolume-enabled audio server like PulseAudio, which does not
receive the "Volume" change (while the peer does change volume) when
setting this property externally using ie. dbus-send.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoaudio/avrcp: Use host/network order as appropriate for pdu->params_len
Marijn Suijten [Sun, 8 Aug 2021 14:35:26 +0000 (16:35 +0200)]
audio/avrcp: Use host/network order as appropriate for pdu->params_len

When comparing against or writing to pdu->params_len to enforce matching
length with total packet length, take into account that pdu->params_len
is in network order (big endian) while packet size (operand_count) is in
host order (usually little endian).

This silently breaks a number of AVRCP commands that perform a quick
length check based on params_len and bail if it doesn't match exactly.

Fixes: e2b0f0d8d ("avrcp: Fix not checking if params_len match number of received bytes")
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc: Add a doc for Intel hardware variants
Tedd Ho-Jeong An [Fri, 6 Aug 2021 05:49:41 +0000 (22:49 -0700)]
doc: Add a doc for Intel hardware variants

This patch adds a document for Intel hardware variants currently
supported by the kernel and its firmware list.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Add support for tlv based version format for Intel vendor
Tedd Ho-Jeong An [Fri, 6 Aug 2021 00:43:04 +0000 (17:43 -0700)]
monitor: Add support for tlv based version format for Intel vendor

Some Intel device supports two different formats of the
HCI_Intel_Read_Version command depends on the command parameter and this
patch parses the command and response parameters depends on the format.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Add proper handling for own_address_type 0x03
Luiz Augusto von Dentz [Wed, 4 Aug 2021 00:57:38 +0000 (17:57 -0700)]
btdev: Add proper handling for own_address_type 0x03

When own_address_type is set to 0x03 the host expects the controller to
generate RPAs using the stored IRK from the resolving list and in
addition to that set the generated RPA as Local RPA in LE Enhanced
Connection Complete.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Add further stats to analzye functionality
Marcel Holtmann [Fri, 6 Aug 2021 14:15:30 +0000 (16:15 +0200)]
monitor: Add further stats to analzye functionality

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc: add admin policy file storage description
Yun-Hao Chung [Tue, 3 Aug 2021 11:43:17 +0000 (19:43 +0800)]
doc: add admin policy file storage description

This adds storage description of admin policy file in
doc/settings-storage.txt

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc: add description of admin policy
Yun-Hao Chung [Tue, 3 Aug 2021 11:43:16 +0000 (19:43 +0800)]
doc: add description of admin policy

This adds admin-policy-api.txt.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugins/admin: persist policy settings
Yun-Hao Chung [Tue, 3 Aug 2021 11:43:15 +0000 (19:43 +0800)]
plugins/admin: persist policy settings

This adds code to store the ServiceAllowlist to file
/var/lib/bluetooth/{MAC_ADDR}/admin_policy
The stored settings will be loaded upon admin_policy initialized.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugins/admin: add AffectedByPolicy property
Yun-Hao Chung [Tue, 3 Aug 2021 11:43:14 +0000 (19:43 +0800)]
plugins/admin: add AffectedByPolicy property

This adds property to indicate if a device has any service that is being
blocked by admin policy.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugins/admin: add device callbacks
Yun-Hao Chung [Tue, 3 Aug 2021 11:43:13 +0000 (19:43 +0800)]
plugins/admin: add device callbacks

This adds callbacks for device resolved and device removed. It is
necessary for implementation of "AffectedByPolicy" property since it
needs to register an interface for each device object and unregister it
once the device gets removed.

Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugins/admin: add ServiceAllowList property
Yun-Hao Chung [Tue, 3 Aug 2021 11:43:12 +0000 (19:43 +0800)]
plugins/admin: add ServiceAllowList property

This adds code to register interface org.bluez.AdminPolicyStatus.
The interface will provide read-only properties to indicate the current
settings of admin policies. We separate this from AdminPolicySet so that
normal clients can check current policy settings while only a few
clients can change policies.

This patch also adds readonly property ServiceAllowlist to
AdminPolicyStatus1, which indicates the current setting of service
allowlist.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugins/admin: add ServiceAllowList method
Yun-Hao Chung [Tue, 3 Aug 2021 11:43:11 +0000 (19:43 +0800)]
plugins/admin: add ServiceAllowList method

This adds code to register interface org.bluez.AdminPolicySet1.
The interface will provide methods to limit users to operate certain
functions of bluez, such as allow/disallow user to taggle adapter power,
or only allow users to connect services in the specified list, etc.

This patch also implements ServiceAllowlist in
org.bluez.AdminPolicySet1.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugins/admin: add admin_policy adapter driver
Yun-Hao Chung [Tue, 3 Aug 2021 11:43:10 +0000 (19:43 +0800)]
plugins/admin: add admin_policy adapter driver

This adds code to register admin_policy driver to adapter when
admin plugin is enabled.

The following test steps were performed:
1. restart bluetoothd
2. check if "Admin Policy is enabled" in system log

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugins: new plugin
Yun-Hao Chung [Tue, 3 Aug 2021 11:43:09 +0000 (19:43 +0800)]
plugins: new plugin

This adds an initial code for a new plugin admin.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agocore: block not allowed UUID connect in auth
Yun-Hao Chung [Tue, 3 Aug 2021 11:43:08 +0000 (19:43 +0800)]
core: block not allowed UUID connect in auth

This ensures any incoming profile connection will be blocked if its UUID
is not allowed by the following assumption:

1. Each system profile asks adapter authorization when seeing a incoming
   connection.
2. Each external profile checks if its UUID is allowed by adapter when
   seeing a incoming connection.

Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agocore: add adapter and device allowed_uuid functions
Yun-Hao Chung [Tue, 3 Aug 2021 11:43:07 +0000 (19:43 +0800)]
core: add adapter and device allowed_uuid functions

This implements functions in src/adapter.c and src/device.c for
plugins setting a list of allowed services.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agocore: add device callbacks to adapter driver
Yun-Hao Chung [Tue, 3 Aug 2021 11:43:06 +0000 (19:43 +0800)]
core: add device callbacks to adapter driver

This adds the following callbacks to btd_adapter_driver.

device_added:    called when a device is added to the adapter
device_removed:  called when a device is removed from the adapter
device_resolved: called when all services of the device have been
                 resolved.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agocore: add is_allowed property in btd_service
Yun-Hao Chung [Tue, 3 Aug 2021 11:43:05 +0000 (19:43 +0800)]
core: add is_allowed property in btd_service

This adds is_allowed property in btd_service. When is_allowed is set to
false, calling btd_service_connect and service_accept will fail and the
existing service connection gets disconnected.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoa2dp: Invalidate cache if SetConfiguration fails
Luiz Augusto von Dentz [Tue, 3 Aug 2021 01:13:19 +0000 (18:13 -0700)]
a2dp: Invalidate cache if SetConfiguration fails

If SetConfiguration fails with Unsupported Configuration it might
indicate that either the capabilities stored are incorrect or the seid
may have changed, so this attempt to invalidate the remote seps loaded
from cache when that happens so the next time there is an attempt to
discover this will force Get(All)Capabilities to be called and cause
the cache to be updated.

Fixes https://github.com/bluez/bluez/issues/178

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix truncated server socket path parameter
Mariusz Skamra [Wed, 4 Aug 2021 10:54:46 +0000 (12:54 +0200)]
monitor: Fix truncated server socket path parameter

This fixes the issue of --server <socket> parameter
last character was dropped. There is no need to use
strncpy, as the length is already checked, and it is
known that the destination buffer is big enough

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Track connections for analyze function
Marcel Holtmann [Tue, 3 Aug 2021 21:28:55 +0000 (23:28 +0200)]
monitor: Track connections for analyze function

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Remove unneeded fprintf for new devices
Marcel Holtmann [Tue, 3 Aug 2021 19:55:00 +0000 (21:55 +0200)]
monitor: Remove unneeded fprintf for new devices

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Count number of control messages
Marcel Holtmann [Tue, 3 Aug 2021 15:04:47 +0000 (17:04 +0200)]
monitor: Count number of control messages

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Add ISO packets to analyze option
Marcel Holtmann [Tue, 3 Aug 2021 14:58:41 +0000 (16:58 +0200)]
monitor: Add ISO packets to analyze option

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Remove unneeded fprintf for unknown opcodes
Marcel Holtmann [Tue, 3 Aug 2021 14:54:03 +0000 (16:54 +0200)]
monitor: Remove unneeded fprintf for unknown opcodes

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt-db: remove redundant check in foreach range
Yun-Hao Chung [Thu, 29 Jul 2021 03:36:00 +0000 (11:36 +0800)]
gatt-db: remove redundant check in foreach range

svc_start < foreach_data->end has already been checked in a few lines
before.

Reviewed-by: Archie Pusaka <apusaka@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomain.conf: Revert default for Privacy and Experimental
Luiz Augusto von Dentz [Thu, 29 Jul 2021 21:09:17 +0000 (14:09 -0700)]
main.conf: Revert default for Privacy and Experimental

Privacy shall be off by default until kernel is stable to support it,
also Experimental shall only be enabled for testing purpose.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Print EIR of Extended Advertisement Report
Sonny Sasaka [Thu, 15 Jul 2021 00:35:21 +0000 (17:35 -0700)]
monitor: Print EIR of Extended Advertisement Report

It's useful to be able to see Extended Adv's EIR flags just like the
legacy Adv.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: Add support for Central Address Resolution characteristic
Luiz Augusto von Dentz [Wed, 28 Jul 2021 20:44:44 +0000 (13:44 -0700)]
gatt: Add support for Central Address Resolution characteristic

This adds Central Address Resolution characteristic so peripherals can
use directed advertising using RPA as initiator address.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>