platform/upstream/bluez.git
5 months agoFix the security vulnerability issue 47/302047/1 accepted/tizen_6.5_unified tizen_6.5 accepted/tizen/6.5/unified/20231207.042856
Wootak Jung [Tue, 28 Nov 2023 05:51:49 +0000 (14:51 +0900)]
Fix the security vulnerability issue

A variant of this attack works when bluetoothctl shows that bluetooth is
discoverable, pariable, and discovering (only a subset may be necessary). On
Ubuntu 22.04 Desktop this becomes true when the GNOME panel for
bluetooth settings is opened.

BlueZ's setting ClassicBondedOnly=true prevents this attack.
This parameter is not enabled in CVE-2020-0556 patches and all distros
I checked have not opted into this setting. Most members of the distros list
are likely affected.

Change-Id: Ib4883d1766d314bcd415308a9e4805e196462f3a
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
7 months agoLE CoC: Add support for L2CAP_LE type socket 99/299399/1 accepted/tizen/6.5/unified/20231010.011950
Ayush Garg [Tue, 15 Feb 2022 07:35:15 +0000 (13:05 +0530)]
LE CoC: Add support for L2CAP_LE type socket

This patch adds following
- Implement method to create and remove L2CAP_LE socket
- Implement method to listen and connect to L2CAP_LE socket

Change-Id: I7f4f6ba5fe49b6d3fa05bfbc3a1b2bfdd269c6bb
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
9 months agoAdd support for custom advertising flags. 79/295579/2 accepted/tizen/6.5/unified/20230719.174801
Jakub Latusek [Wed, 1 Feb 2023 06:00:13 +0000 (15:00 +0900)]
Add support for custom advertising flags.

It is required to set proper advertising flags when establishing a
connection using
Bluetooth low energy to properly recognize device type.
Without this, the Linux device cannot recognize the Tizen device
properly and establish a connection.

Change-Id: I2dcbcd053a8de4c4954653ae8a5f55fbed775f66
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
Signed-off-by: Jakub Latusek <j.latusek@samsung.com>
21 months agoModify FastConnectable flag true in robot 58/279358/1
Wootak Jung [Mon, 8 Aug 2022 00:38:17 +0000 (09:38 +0900)]
Modify FastConnectable flag true in robot

This change is able to reduce the page timeout

Change-Id: I8a408b47b9fe9204b3dc268bd5ec5d81d44e7b51

22 months agoUse the different key file with kernel for certification 07/277207/1
Dohyun Pyun [Mon, 4 Jul 2022 00:06:24 +0000 (09:06 +0900)]
Use the different key file with kernel for certification

Change-Id: I0ad8a2b7013a4b3776c019f2dabea0c5b229c428
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
22 months agoModify GATT tools for Certification 17/277117/1 accepted/tizen/6.5/unified/20220707.134142 submit/tizen_6.5/20220701.023001
Dohyun Pyun [Fri, 1 Jul 2022 01:53:54 +0000 (10:53 +0900)]
Modify GATT tools for Certification

Change-Id: I38b0573bc084fc4fcd5ef7aafe2fbb07282d756f
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
22 months agoUse HCI error code instead of MGMT disconnection reason 48/276548/1 accepted/tizen/6.5/unified/20220621.140242 submit/tizen_6.5/20220620.221710
Dohyun Pyun [Mon, 20 Jun 2022 08:37:27 +0000 (17:37 +0900)]
Use HCI error code instead of MGMT disconnection reason

Change-Id: If715b847372b0be82ebdd8404a8b2a39bca01970
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
22 months agoAdd PTS certification logic 80/276480/2 accepted/tizen/6.5/unified/20220620.131708 submit/tizen_6.5/20220617.070028
Dohyun Pyun [Fri, 17 Jun 2022 06:24:07 +0000 (15:24 +0900)]
Add PTS certification logic

GATT/SR/GAW/BV-06-C
GATT/SR/GAW/BV-10-C

Change-Id: I37e37a23f132674e9d5d82b08c914bccb87d0d77
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
22 months agoModify the justwork repairing logic for certification 69/276069/1
Dohyun Pyun [Thu, 9 Jun 2022 06:29:27 +0000 (15:29 +0900)]
Modify the justwork repairing logic for certification

This change is related with GAP/SEC/AUT/BV-26-C

Change-Id: I423379a24b664d536b2b5e20b561c0053d1287a0
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
23 months agoadapter: Unset secure conn setting in robot 51/275851/2
Wootak Jung [Fri, 3 Jun 2022 04:15:54 +0000 (13:15 +0900)]
adapter: Unset secure conn setting in robot

Change-Id: Ic602460dc962d013b818b8e1370026bfa81aed17

23 months agoRemove the ceritifcate definition 79/275479/1
Dohyun Pyun [Wed, 25 May 2022 22:34:14 +0000 (07:34 +0900)]
Remove the ceritifcate definition

We will handle the certification logic in the runtime

Change-Id: I0025873d3ed69c6c2b2b09deb7829fa926051568
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
23 months agoCheck the certification mode in the runtime 48/275348/1
Dohyun Pyun [Mon, 23 May 2022 05:25:26 +0000 (14:25 +0900)]
Check the certification mode in the runtime

Change-Id: I6d646248178de5d08193088864d7da4e60eceabf
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
23 months agoshared/gatt-client: Add PTS certification logic 46/275046/1
Wootak Jung [Mon, 16 May 2022 01:22:52 +0000 (10:22 +0900)]
shared/gatt-client: Add PTS certification logic

Change-Id: Id256ce2dd79bceeb8242b0ae2c93a2262bc4d4e7

23 months agoModify the packaging for hcidump 90/274890/2
Dohyun Pyun [Wed, 11 May 2022 11:18:15 +0000 (20:18 +0900)]
Modify the packaging for hcidump

Change-Id: I443586fcbc5fe01dae47a8edd826f5875e98751e
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
23 months agoshared/gatt-server: Add PTS certification logic 48/274748/1
Wootak Jung [Mon, 9 May 2022 01:31:26 +0000 (10:31 +0900)]
shared/gatt-server: Add PTS certification logic

GATT/CL/GAI/BI-01-C
GATT/SR/GAR/BI-04-C
GATT/SR/GAR/BI-10-C
GATT/SR/GAW/BI-12-C

Change-Id: I4fce46e7f2ea669b445767b597d0a6475e71381f

2 years agoaudio/avrcp: Add PTS certification related logic 07/273907/4 accepted/tizen/6.5/unified/20220420.135542 submit/tizen_6.5/20220419.002229
Wootak Jung [Mon, 18 Apr 2022 00:55:02 +0000 (09:55 +0900)]
audio/avrcp: Add PTS certification related logic

IOPT/SR/SDSS/BV-02-I

Change-Id: I8d209bd6f2e541870d8e6446522dceb533dfdb0d

2 years agoshared/gatt-server: Add PTS certification related logic 06/273906/4
Wootak Jung [Mon, 18 Apr 2022 00:52:10 +0000 (09:52 +0900)]
shared/gatt-server: Add PTS certification related logic

GATT/SR/GAW/BI-05-C
GATT/SR/GAR/BI-34-C
GATT/SR/GAR/BI-35-C
GATT/SR/GAW/BI-12-C

Change-Id: I049f410d9eecdc490ba275c907891def179ee8c7

2 years agoAdd certificate definition for PTS 05/273905/1
Wootak Jung [Mon, 18 Apr 2022 00:46:42 +0000 (09:46 +0900)]
Add certificate definition for PTS

Change-Id: I3619e2dc82cdd7253e08109ee1345e9e1527c1fd

2 years agoIncrease the version 49/271549/1
Dohyun Pyun [Wed, 23 Feb 2022 02:17:00 +0000 (11:17 +0900)]
Increase the version

Change-Id: I789d239abb8926bc1c7a987b6136475acf81f097
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
2 years agoReset disconnect timer for the incoming connection 48/271548/1
Dohyun Pyun [Wed, 23 Feb 2022 02:16:08 +0000 (11:16 +0900)]
Reset disconnect timer for the incoming connection

Change-Id: Id3bc0c4a188b0d93478297c711856f1be47645fe
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
2 years agoa2dp: Fix crash on connection lost 99/271499/1
Ayush Garg [Tue, 28 Dec 2021 16:04:42 +0000 (21:34 +0530)]
a2dp: Fix crash on connection lost

when the channel is removed on connection lost, the
setup->chan pointer becomes dangling which causes crash
in find_remote_sep.
So mark this pointer as NULL whenever the channel is removed.

Change-Id: I1b3fe81df18d4ea8eed00739a9db7d0e7232dda0
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
2 years agoMerge "Fix response_needed setting logic" into tizen_6.5 accepted/tizen/6.5/unified/20220210.032432 submit/tizen_6.5/20220209.062506
Pyun DoHyun [Wed, 9 Feb 2022 06:19:37 +0000 (06:19 +0000)]
Merge "Fix response_needed setting logic" into tizen_6.5

2 years agoFix response_needed setting logic 97/270797/1
Wootak Jung [Wed, 9 Feb 2022 05:59:03 +0000 (14:59 +0900)]
Fix response_needed setting logic

response_needed should be true in case opcode is EXEC_WRITE_REQ.
EXEC_WRITE_REQ is used if the data size to write is bigger than
mtu size. otherwise, WRITE_REQ is used.

Change-Id: Ie9fbbeae9c0f0148c5dbd4938dafb1dbc6078cc2

2 years agoIncrease the version 93/270793/1
Dohyun Pyun [Wed, 9 Feb 2022 05:16:55 +0000 (14:16 +0900)]
Increase the version

Change-Id: I41cfaaba53495ab67dbfa92685be40bb97937ed5
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
2 years agoSet the default MTU size as 512 byte for Robot 92/270792/1
Dohyun Pyun [Wed, 9 Feb 2022 05:15:38 +0000 (14:15 +0900)]
Set the default MTU size as 512 byte for Robot

Change-Id: I017e84872e66d909c3365e5e7d233517cb831753
Signed-off-by: Dohyun Pyun <dh79.pyun@samsung.com>
2 years agoIncrease the version 82/270682/1 accepted/tizen/6.5/unified/20220208.130644 submit/tizen_6.5/20220207.225449
dh79pyun [Mon, 7 Feb 2022 22:54:06 +0000 (07:54 +0900)]
Increase the version

Change-Id: I36546b42e343d424647045916531fe91e2e0fd6b
Signed-off-by: dh79pyun <dh79.pyun@samsung.com>
2 years agoGATT: Fix crash in ccc_write_cb. 81/270681/1
Anuj Jain [Fri, 28 Jan 2022 11:08:38 +0000 (16:38 +0530)]
GATT: Fix crash in ccc_write_cb.

When gatt client is disconnected after notification enable,
The pending_op becomes null which when used in stop_notify_setup
causes bluetoothd to crash.
This patch will fix the same.

Change-Id: I34ab72af291763fe6d7ae50ae517dc71ebf441e8
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: dh79pyun <dh79.pyun@samsung.com>
2 years agoIncrease the version 11/270311/1
dh79pyun [Fri, 28 Jan 2022 02:19:36 +0000 (11:19 +0900)]
Increase the version

Change-Id: I0502c8ca616c7cd8777be0a99222373e314875cc
Signed-off-by: dh79pyun <dh79.pyun@samsung.com>
2 years agoDon't remove the device, if LE connection exist 09/270309/1 submit/tizen_6.5/20220128.020446
dh79pyun [Fri, 28 Jan 2022 01:33:54 +0000 (10:33 +0900)]
Don't remove the device, if LE connection exist

Change-Id: Idb006cc0ceebc1a7315443fb3f06513da65b7f50
Signed-off-by: dh79pyun <dh79.pyun@samsung.com>
2 years agoIncrease the version 11/267811/1 accepted/tizen/6.5/unified/20211212.212914 submit/tizen_6.5/20211210.052054
dh79pyun [Fri, 10 Dec 2021 05:12:42 +0000 (14:12 +0900)]
Increase the version

Change-Id: Iac5203904bfc746077bd50153740aa9895131c12
Signed-off-by: dh79pyun <dh79.pyun@samsung.com>
2 years agoSupport the multi-advertisement for the robot reference 09/267809/1
dh79pyun [Fri, 10 Dec 2021 04:57:02 +0000 (13:57 +0900)]
Support the multi-advertisement for the robot reference

Change-Id: I671fc3d6c5cd87a823e3d4485498bac7a0d2a6fc
Signed-off-by: dh79pyun <dh79.pyun@samsung.com>
2 years agoModify the dbus policy for robot profile 43/266343/3 accepted/tizen/6.5/unified/20211111.224620 submit/tizen/20211114.231048 submit/tizen_6.5/20211111.022315
dh79pyun [Wed, 10 Nov 2021 23:04:00 +0000 (08:04 +0900)]
Modify the dbus policy for robot profile

Change-Id: I16389887221197cd24b1e84445090077d4e4cee6
Signed-off-by: dh79pyun <dh79.pyun@samsung.com>
2 years agoIncrease the version 00/266100/1
dh79pyun [Sun, 7 Nov 2021 23:11:43 +0000 (08:11 +0900)]
Increase the version

Change-Id: Iacc44f2912922fe269d2eaea898d7ad07e52624b
Signed-off-by: dh79pyun <dh79.pyun@samsung.com>
2 years agoa2dp: Handle remote SEP disappearing 99/266099/1
Luiz Augusto von Dentz [Thu, 21 Jan 2021 00:25:09 +0000 (16:25 -0800)]
a2dp: Handle remote SEP disappearing

Some devices (Sony WH-1000XM4) seems to dinamically change its endpoints
depending on the configuration which may leave behind endpoints loaded
from cache that are no longer valid.

gh-issue: https://github.com/bluez/bluez/issues/85

Change-Id: I0e5ac965cc09da7e7d1ac1c554d77d75a0d65e22
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
2 years agoIncrease the version 08/266008/1 accepted/tizen/unified/20211108.181239 submit/tizen/20211105.042734
dh79pyun [Wed, 3 Nov 2021 04:08:24 +0000 (13:08 +0900)]
Increase the version

Change-Id: I7e0eed9586d869fc0ad97048adc24c0406144013
Signed-off-by: dh79pyun <dh79.pyun@samsung.com>
2 years agoFix A2DP sink disconnection issue on streaming 07/266007/1
dh79pyun [Wed, 3 Nov 2021 02:38:43 +0000 (11:38 +0900)]
Fix A2DP sink disconnection issue on streaming

The logic of disconnect_timeout was changed in bluez 5.55.
So we should modify Tizen specific logic for that.

Change-Id: Ic54b39d08b7f403407ae7dfa9ca6c9207bb1c4c5
Signed-off-by: dh79pyun <dh79.pyun@samsung.com>
2 years agoEnable Multi ADV only for wearable profile 25/265225/1 accepted/tizen/unified/20211102.024808 submit/tizen/20211101.051752
dh79pyun [Wed, 13 Oct 2021 02:31:54 +0000 (11:31 +0900)]
Enable Multi ADV only for wearable profile

Change-Id: Ieeec8d5f2278e0cc72e613c81f0725da3a8bab54
Signed-off-by: dh79pyun <dh79.pyun@samsung.com>
2 years agoGATT: Send client address to HAL layer on Notification state change 69/262169/4 accepted/tizen/6.5/unified/20211028.224421 accepted/tizen/unified/20210805.131621 submit/tizen/20210804.223925 submit/tizen_6.5/20211028.163301 tizen_6.5.m2_release
Anuj Jain [Tue, 3 Aug 2021 08:46:59 +0000 (14:16 +0530)]
GATT: Send client address to HAL layer on Notification state change

In gatt Server role Client address is added to dbus method calls
corresponding to StartNotify and StopNotify methods at BLUEZ layer.

This patchset should be merged with the following capi and
bluetooth-frwk's patchset in order to match API and avoid crash:
bluetooth-frwk Change-Id: Ib54ba54c318692b4ee0eaef9b2310c60dadeb661
capi Change-Id: Ic4868234a4fc682f9bff2c66ac1aee2683f3d6c6

Change-Id: I81a0994f2299e988f8ef6428537647c899700fda
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
2 years agoFix code unreachable issue 19/259819/1 accepted/tizen/unified/20210617.124929 submit/tizen/20210615.223409
Wootak Jung [Tue, 15 Jun 2021 07:31:07 +0000 (16:31 +0900)]
Fix code unreachable issue

Change-Id: Ibe19389b7c27ec24191a3ecb965f741b83fc4c14
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
2 years agoAdd robot conf file 78/259178/1 accepted/tizen/unified/20210607.124421 submit/tizen/20210606.232858
Wootak Jung [Tue, 1 Jun 2021 00:12:07 +0000 (09:12 +0900)]
Add robot conf file

Change-Id: Id601ff4b3972ed3bff86d00b1d35180973366db5
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
2 years agoFix the coverity issue (resource leak) 07/258707/1
Anuj Jain [Mon, 24 May 2021 08:46:43 +0000 (14:16 +0530)]
Fix the coverity issue (resource leak)

Variable str must be free after its usage.
This change fixes the same.

Change-Id: I880aa48cbf31d13a27a47b7fc08807a56af18fd3
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
2 years agoa2dp: Fix crash on discover_cb 15/258115/5
Wootak Jung [Tue, 11 May 2021 02:10:53 +0000 (11:10 +0900)]
a2dp: Fix crash on discover_cb

There have been reports of crashes on discover_cb where the setup
would most likely already have been freed but discover_cb would still
be called, so instead of assuming the setup pointer would be valid try
to lookup the list of active setups and log a warning when it happens.

Change-Id: Icca1608c48be43174492d69204c8d31b158a99df
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
3 years agoUpdate the version to 5.55 bluez_upgrade_5.55
Ayush Garg [Mon, 12 Apr 2021 10:15:09 +0000 (15:45 +0530)]
Update the version to 5.55

Change-Id: I9028e219dc378c0f3218d85b267d646541da7ddd
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoRelease 5.55
Marcel Holtmann [Sun, 6 Sep 2020 13:51:06 +0000 (15:51 +0200)]
Release 5.55

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agobuild: Update library version
Marcel Holtmann [Sun, 6 Sep 2020 13:50:53 +0000 (15:50 +0200)]
build: Update library version

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agolib: Update company identifiers
Marcel Holtmann [Sat, 5 Sep 2020 19:18:52 +0000 (21:18 +0200)]
lib: Update company identifiers

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoavrcp: Implement Press/Hold/Release method for MediaPlayer1
Archie Pusaka [Thu, 3 Sep 2020 03:50:39 +0000 (11:50 +0800)]
avrcp: Implement Press/Hold/Release method for MediaPlayer1

This allows us to send any passthrough command, complete with the
support to hold down the key. Using Press() will automatically
release the key, while using Hold() will keep the key held until
an explicit call to Release() is received.

This doesn't allow us to hold multiple keys simultaneously, since
according to the AV/C Panel Subunit Specification, part 9.4, when the
target receive a pressed command without receiving a release command
of the previous key, it will be treated as if the release command is
sent but not received.

Previously, the rewind and fast_forward keys are unique in terms that
they are treated as holdable keys, this patch preserves that behavior
of calling Rewind() and FastForward(). A rewind event which is
reported via the new Press() method will automatically be released
instead.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc/media-api: Add Press/Hold/Release methods for MediaPlayer1
Archie Pusaka [Thu, 3 Sep 2020 03:50:37 +0000 (11:50 +0800)]
doc/media-api: Add Press/Hold/Release methods for MediaPlayer1

This allows us to send any passthrough command. The button can also
be held for an extended amount of time.

Reviewed-by: Michael Sun <michaelfsun@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoclient: Fix typo in bluetoothctl
Barry Byford [Sun, 30 Aug 2020 07:11:08 +0000 (08:11 +0100)]
client: Fix typo in bluetoothctl

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Add support for Suspend and Resume events
Abhishek Pandit-Subedi [Sat, 29 Aug 2020 01:02:09 +0000 (18:02 -0700)]
monitor: Add support for Suspend and Resume events

Add support to pretty print Suspend and Resume mgmt events in btmon.

Example:

@ MGMT Event: Controller Suspended (0x002d) plen 1
        Suspend state: Page scanning and/or passive scanning (2)

@ MGMT Event: Controller Resumed (0x002e) plen 8
        Wake reason: Remote wake due to peer device connection (2)
        LE Address: CD:F3:CD:13:C5:9A (OUI CD-F3-CD)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomgmt: Add controller suspend and resume events
Abhishek Pandit-Subedi [Sat, 29 Aug 2020 01:02:08 +0000 (18:02 -0700)]
mgmt: Add controller suspend and resume events

Add the controller suspend and resume events.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoprofiles/network: Log connection event after setting device name
edef [Thu, 27 Aug 2020 11:27:59 +0000 (11:27 +0000)]
profiles/network: Log connection event after setting device name

Without reordering these two statements, the logs look like this:

    bnep%d connected
    bnep0 disconnected

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agogatt: Accept empty array in parse_includes()
Jie Jiang [Wed, 26 Aug 2020 06:37:42 +0000 (23:37 -0700)]
gatt: Accept empty array in parse_includes()

Currently parse_includes() will return false if the "Includes" property
is an empty array. Empty array in the "Includes" property should be
treated as valid.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Mark device temporary state pairing failure
Yu Liu [Mon, 24 Aug 2020 18:19:03 +0000 (11:19 -0700)]
adapter: Mark device temporary state pairing failure

This caused the device hanging around as a discovered device forever
even if it is turned off or not in present.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodevice: Fix race condition between device connection and disconnection
Sonny Sasaka [Fri, 21 Aug 2020 18:01:06 +0000 (11:01 -0700)]
device: Fix race condition between device connection and disconnection

When Connect() is called and waiting for return, dev_disconnected may be
called due to MGMT_EV_DEVICE_DISCONNECTED event from kernel. In that
case reply to client that the connection failed otherwise the dbus
method will timeout because bluetoothd never replies.

Tested with simulation of a lot of Connect() to bluetooth devices and
check that error is returned from bluetoothd rather than dbus timeout
when this race condition happens.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Fix crash in discovery_disconnect
Sonny Sasaka [Fri, 21 Aug 2020 17:58:38 +0000 (10:58 -0700)]
adapter: Fix crash in discovery_disconnect

discovery_disconnect crashed because the adapter pointer has been freed
before. This patch makes sure that discovery list is cleaned up before
adapter pointer is freed.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoinput/device: Unregister all UHID event listeners at UHID_DESTROY
Sonny Sasaka [Fri, 21 Aug 2020 04:35:36 +0000 (21:35 -0700)]
input/device: Unregister all UHID event listeners at UHID_DESTROY

When destroying UHID, we should also unregister all event listeners so
that they don't get double registered at reconnection. It fixes a bug
where battery report is not available to kernel after reconnection and
also prevents memory leak.

Tested with Logitech M535 mouse:
* Connect mouse to the device running BlueZ
* cat /sys/class/power_supply/hid-{addr}-battery/capacity # works
* Disconnect mouse
* Reconnect mouse
* cat /sys/class/power_supply/hid-{addr}-battery/capacity # still works

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoclient: Add cancel-pairing command
Miao-chen Chou [Fri, 21 Aug 2020 07:28:12 +0000 (00:28 -0700)]
client: Add cancel-pairing command

This adds cancel-pairing command which can be used to cancel the ongoing
pairing.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomain: add configurable refresh_discovery parameter
Archie Pusaka [Tue, 18 Aug 2020 07:34:10 +0000 (15:34 +0800)]
main: add configurable refresh_discovery parameter

This is to configure the default behavior of issuing SDP query
to update the services upon profile connection.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodevice: Don't browse SDP if HIDSDPDisable is set
Archie Pusaka [Tue, 18 Aug 2020 07:34:09 +0000 (15:34 +0800)]
device: Don't browse SDP if HIDSDPDisable is set

According to the HID1.1 spec, part 5.3.4.9:
The HIDSDPDisable attribute is a Boolean value, which indicates
whether connection to the SDP channel and Control or Interrupt
channels are mutually exclusive. This feature supports Bluetooth
HID devices that have minimal resources, and multiplex those
resources between servicing the initialization (SDP) and runtime
(Control and Interrupt) channels.

However, Bluez still tries to connect SDP upon HID connection,
regardless of the existence of the HIDSDPDisable attribute.

This patch prevents the connection of SDP after HID has been
established, if the device has HIDSDPDisable attribute.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/ad: move MAX_ADV_DATA_LEN macro to the header
Miao-chen Chou [Tue, 18 Aug 2020 06:19:39 +0000 (23:19 -0700)]
shared/ad: move MAX_ADV_DATA_LEN macro to the header

This moves MAX_ADV_DATA_LEN macro to src/shared/ad.h and rename it to
BT_AD_MAX_DATA_LEN.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadvertising: Fix dbus response for over-advertising
Daniel Winkler [Fri, 14 Aug 2020 22:58:18 +0000 (15:58 -0700)]
advertising: Fix dbus response for over-advertising

client_free would always send a dbus method_return to fix the case where
a request to Unregister occurred before the MGMT call returned. However,
in the code path where too many advertisements are registered, this
method_return prevents the failure from being sent properly. This patch
makes sure the reference to the register_advertisement DBusMessage is
not stored in the client structure until the end of
register_advertisement. This ensures that we only respond once, either
in register_advertisement or in client_free, not both.

It also changes the dbus response in the fast unregister_advertisement
case from a method_return to a btd_error_failed, since the registration
was never allowed to complete, and thus was not successful.

The patch was tested in the following ways:

To verify it did not break the segfault fix in
caff2b48ca54bbc57b5da3f63317767489aa5b48, I repro'd the failure by
quickly unregistering after registering, and verified that the segfault
is still fixed with this change.

Ran through our automated tests that register too many advertisements
and verify that the registration fails with the intended "Maximum
Advertisements Reached" error response.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoavrcp: include all player settings in notif event
Howard Chung [Wed, 5 Aug 2020 02:05:36 +0000 (10:05 +0800)]
avrcp: include all player settings in notif event

According to AVRCP 1.6.2 spec section 6.7.2 table 6.39, all player
application settings should be returned to the CT and let CT to
determine which settings have changed. Currently bluez only returns
the changed attribute instead. This patch also addresses a potential
issue on which the number of application settings mismatches with
the actual number returned.

Change-Id: I3fbedd0d73f72c9de5d24af173aded4adf0b9a19
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoinput/device: Send UHID_DESTROY upon disconnection
Archie Pusaka [Mon, 3 Aug 2020 06:52:24 +0000 (14:52 +0800)]
input/device: Send UHID_DESTROY upon disconnection

According to the uhid documentation: "If your device disconnects,
you should send an UHID_DESTROY event"

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoinput/device: Implement handle for UHID_SET_REPORT
Archie Pusaka [Mon, 3 Aug 2020 06:52:23 +0000 (14:52 +0800)]
input/device: Implement handle for UHID_SET_REPORT

This patch listens to UHID_SET_REPORT event and forwards this
message to the hid device. Upon reply, we also send a report back
to the kernel as UHID_SET_REPORT_REPLY.

hidp_send_set_report no longer listen UHID_OUTPUT events, that is
handled by hidp_send_output instead.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoinput/device: Replace UHID_FEATURE with UHID_GET_REPORT
Archie Pusaka [Mon, 3 Aug 2020 06:52:22 +0000 (14:52 +0800)]
input/device: Replace UHID_FEATURE with UHID_GET_REPORT

According to kernel's uhid.h, UHID_FEATURE is obsolete and is
replaced with UHID_GET_REPORT.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoinput: Remove bonding info when receiving virtual cable unplug
Archie Pusaka [Thu, 16 Jul 2020 18:04:33 +0000 (02:04 +0800)]
input: Remove bonding info when receiving virtual cable unplug

From Bluetooth HID Profile 1.1 Spec: If a Virtual Cable is
unplugged via a HID control Virtual Unplug command, then both the
Bluetooth HID device and Bluetooth HID Host shall destroy or
invalidate all Bluetooth bonding and Virtual Cable information
that was previously stored in persistent memory for the respective
Virtually Cabled devices and hosts.

This patch removes the bonding information upon receiving and/or
sending a "virtual cable unplug".

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodevice: add device_remove_bonding function
Archie Pusaka [Thu, 16 Jul 2020 18:04:32 +0000 (02:04 +0800)]
device: add device_remove_bonding function

This patch splits the "bonding removal" function in device.c,
because we need to remove bonding information when receiving
"virtual cable unplug" in HID profile.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoinput: encrypt on receive conn req if classic_bonded_only
Archie Pusaka [Wed, 22 Jul 2020 16:20:33 +0000 (00:20 +0800)]
input: encrypt on receive conn req if classic_bonded_only

According to bluetooth HID1.1 spec, section 5.4.3.5.3:
If the Bluetooth HID Host is bonded to a Bluetooth HID device:
If encryption is not already enabled, the Bluetooth HID Host shall
enable encryption with the Bluetooth HID device before sending an
L2CAP Connect Response with a result code of “Connection Successful”
(0x0000) after an L2CAP Connect Request is received.

This patch raises the security level to medium when listening for
incoming connection if the flag classic_bonded_only is set,
effectively starting encryption.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoinput: authenticate when connecting to a bonded device
Archie Pusaka [Wed, 22 Jul 2020 16:20:32 +0000 (00:20 +0800)]
input: authenticate when connecting to a bonded device

According to bluetooth HID1.1 spec, part 5.4.3.4.3:
If the Bluetooth HID Host is bonded to a Bluetooth HID device:
If encryption is not already enabled, the Bluetooth HID Host shall
enable encryption with the Bluetooth HID device before sending an
L2CAP Connect Request to open the HID L2CAP Control channel.

When creating connection, this patch checks whether the target
device is bonded, if yes then we use the medium security level
instead of the low one to enable encryption.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoaudio/transport: supply volume on transport init
Archie Pusaka [Thu, 23 Jul 2020 07:23:40 +0000 (15:23 +0800)]
audio/transport: supply volume on transport init

Sometimes the response of RegisterNotification for volume change
event came before we create the transport for the corresponding
device. If that happens, the volume will be stuck to an
uninitialized invalid value. The property Volume of
MediaTransport1 will also be left unaccessible.

This patch supplies the initial volume when creating a new
transport. The value is obtained from the media_player object.
However, since the avrcp session might not be created by the time
the transport is created, we also try to initialize the volume
when creating avrcp session.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoaudio/transport: change volume to 8bit
Archie Pusaka [Thu, 23 Jul 2020 07:23:39 +0000 (15:23 +0800)]
audio/transport: change volume to 8bit

The valid range of volume is 0 - 127, yet it is stored in 16bit
data type. This patch modifies it so we use 8bit data type to
store volume instead. Furthermore we also use signed type, so
negative values can be used to indicate invalid volume.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Don't remove temporary devices on disconnect
Luiz Augusto von Dentz [Sat, 18 Jul 2020 00:34:38 +0000 (17:34 -0700)]
adapter: Don't remove temporary devices on disconnect

This makes the disconnect logic just update last seen field of the
device so in case it is temporary it would trigger its timer and be
removed after the timeout which is consistent with the discovery
session givin a grace time for application to react to such events.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodevice: Fix not removing temporary timer when connected
Luiz Augusto von Dentz [Sat, 18 Jul 2020 00:25:52 +0000 (17:25 -0700)]
device: Fix not removing temporary timer when connected

Devices with random addresses will not have its temporary flag (as they
cannot be persisted in storage) reset even in case they are connected
which could cause and unintended disconnection.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/gatt-client: Consolidate code parsing services
Luiz Augusto von Dentz [Sat, 18 Jul 2020 00:22:08 +0000 (17:22 -0700)]
shared/gatt-client: Consolidate code parsing services

This makes code parsing primary/secondary services which was mostly
duplicated into a function so it can be reused.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/gatt-client: Fix possible crash
Luiz Augusto von Dentz [Fri, 17 Jul 2020 21:09:42 +0000 (14:09 -0700)]
shared/gatt-client: Fix possible crash

This fixes the following crash which was the cause of CI failing with
the latest changes:

Invalid read of size 8
   at 0x15A5ED: queue_remove_if (queue.c:289)
   by 0x15181E: chrc_removed (gatt-client.c:278)
   by 0x15A4BC: queue_foreach (queue.c:220)
   by 0x157870: notify_attribute_changed (gatt-db.c:396)
   by 0x157870: notify_service_changed (gatt-db.c:407)
   by 0x15793C: gatt_db_service_destroy (gatt-db.c:433)
   by 0x15A741: queue_remove_all (queue.c:354)
   by 0x15A774: queue_destroy (queue.c:73)
   by 0x15776F: gatt_db_destroy (gatt-db.c:459)
   by 0x15776F: gatt_db_unref (gatt-db.c:471)
   by 0x15776F: gatt_db_unref (gatt-db.c:463)
   by 0x15211A: bt_gatt_client_free (gatt-client.c:2250)
   by 0x152565: notify_cb (gatt-client.c:2228)
   by 0x14D0F8: handle_notify (att.c:972)
   by 0x14D0F8: can_read_data (att.c:1063)
   by 0x1597F4: watch_callback (io-glib.c:170)
   by 0x48B67AE: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.3)
   by 0x48B6B37: ??? (in /usr/lib64/libglib-2.0.so.0.6400.3)
   by 0x48B6E52: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6400.3)
   by 0x159DE4: mainloop_run (mainloop-glib.c:79)
   by 0x15A1C1: mainloop_run_with_signal (mainloop-notify.c:201)
   by 0x14B27B: tester_run (tester.c:870)
   by 0x147C8E: main (test-gatt.c:4488)
 Address 0x4f51498 is 8 bytes inside a block of size 32 free'd
   at 0x483B9F5: free (vg_replace_malloc.c:538)
   by 0x1520A8: bt_gatt_client_free (gatt-client.c:2235)
   by 0x152565: notify_cb (gatt-client.c:2228)
   by 0x14D0F8: handle_notify (att.c:972)
   by 0x14D0F8: can_read_data (att.c:1063)
   by 0x1597F4: watch_callback (io-glib.c:170)
   by 0x48B67AE: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.6400.3)
   by 0x48B6B37: ??? (in /usr/lib64/libglib-2.0.so.0.6400.3)
   by 0x48B6E52: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.6400.3)
   by 0x159DE4: mainloop_run (mainloop-glib.c:79)
   by 0x15A1C1: mainloop_run_with_signal (mainloop-notify.c:201)
   by 0x14B27B: tester_run (tester.c:870)
   by 0x147C8E: main (test-gatt.c:4488)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoprofile: Add exception to battery profile for external access
Sonny Sasaka [Wed, 15 Jul 2020 22:47:40 +0000 (15:47 -0700)]
profile: Add exception to battery profile for external access

This gives exception to battery profile to be shared both internally and
externally.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agogatt: Support DeviceInfo Service when vid/pid is specified
Alain Michaud [Fri, 17 Jul 2020 14:40:07 +0000 (14:40 +0000)]
gatt: Support DeviceInfo Service when vid/pid is specified

This patch adds support for the PNPID characteristic when configured in
main.conf.

This was validated as read correclty both by manually reading the valud
and confirming in the Ellisys Analyzer.

ATT Read (PnP ID: Source=Bluetooth ID, Vendor=224, Product=50181,
ATT Read Response Packet (Source=Bluetooth ID, Vendor=224,
Product=50181, Version=86)     | OK     | 7 bytes (01 E0 00 05 C4 56 00)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/gatt-client: Fix handling of service changed
Luiz Augusto von Dentz [Fri, 17 Jul 2020 19:08:14 +0000 (12:08 -0700)]
shared/gatt-client: Fix handling of service changed

When handling multiple service changed multiple discovery operations
would be performed but at the end of each one the hash would be read
which not only would create extra traffic but also prevents the code
to properly detection services disappering.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/gatt-client: Don't remove active services
Luiz Augusto von Dentz [Fri, 17 Jul 2020 19:07:01 +0000 (12:07 -0700)]
shared/gatt-client: Don't remove active services

If discovery was aborted (i.e due to a disconnect) check if pending
services were active so only staled services which were not completed
fetched are removed.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/gatt-client: Remove notification if its attribute is removed
Luiz Augusto von Dentz [Thu, 16 Jul 2020 22:07:42 +0000 (15:07 -0700)]
shared/gatt-client: Remove notification if its attribute is removed

If the attribute is being removed from the database it means the
notification shall also be dropped, that way users don't have to
cleanup its subscriptions themselves.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/gatt-db: Add support for notifying attribute changes
Luiz Augusto von Dentz [Thu, 16 Jul 2020 22:02:27 +0000 (15:02 -0700)]
shared/gatt-db: Add support for notifying attribute changes

This enables to get notified when an attribute has been changed e.g.
it is being removed so the code can detect changes changes at attribute
level.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/att: Fix possible crash on disconnect
Luiz Augusto von Dentz [Thu, 16 Jul 2020 01:25:37 +0000 (18:25 -0700)]
shared/att: Fix possible crash on disconnect

If there are pending request while disconnecting they would be notified
but clients may endup being freed in the proccess which will then be
calling bt_att_cancel to cancal its requests causing the following
trace:

Invalid read of size 4
   at 0x1D894C: enable_ccc_callback (gatt-client.c:1627)
   by 0x1D247B: disc_att_send_op (att.c:417)
   by 0x1CCC17: queue_remove_all (queue.c:354)
   by 0x1D47B7: disconnect_cb (att.c:635)
   by 0x1E0707: watch_callback (io-glib.c:170)
   by 0x48E963B: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.6400.4)
   by 0x48E9AC7: ??? (in /usr/lib/libglib-2.0.so.0.6400.4)
   by 0x48E9ECF: g_main_loop_run (in /usr/lib/libglib-2.0.so.0.6400.4)
   by 0x1E0E97: mainloop_run (mainloop-glib.c:79)
   by 0x1E13B3: mainloop_run_with_signal (mainloop-notify.c:201)
   by 0x12BC3B: main (main.c:770)
 Address 0x7d40a28 is 24 bytes inside a block of size 32 free'd
   at 0x484A2E0: free (vg_replace_malloc.c:540)
   by 0x1CCC17: queue_remove_all (queue.c:354)
   by 0x1CCC83: queue_destroy (queue.c:73)
   by 0x1D7DD7: bt_gatt_client_free (gatt-client.c:2209)
   by 0x16497B: batt_free (battery.c:77)
   by 0x16497B: batt_remove (battery.c:286)
   by 0x1A0013: service_remove (service.c:176)
   by 0x1A9B7B: device_remove_gatt_service (device.c:3691)
   by 0x1A9B7B: gatt_service_removed (device.c:3805)
   by 0x1CC90B: queue_foreach (queue.c:220)
   by 0x1DE27B: notify_service_changed.isra.0.part.0 (gatt-db.c:369)
   by 0x1DE387: notify_service_changed (gatt-db.c:361)
   by 0x1DE387: gatt_db_service_destroy (gatt-db.c:385)
   by 0x1DE3EF: gatt_db_remove_service (gatt-db.c:519)
   by 0x1D674F: discovery_op_complete (gatt-client.c:388)
   by 0x1D6877: discover_primary_cb (gatt-client.c:1260)
   by 0x1E220B: discovery_op_complete (gatt-helpers.c:628)
   by 0x1E249B: read_by_grp_type_cb (gatt-helpers.c:730)
   by 0x1D247B: disc_att_send_op (att.c:417)
   by 0x1CCC17: queue_remove_all (queue.c:354)
   by 0x1D47B7: disconnect_cb (att.c:635)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Remove timer for removing temporary devices
Luiz Augusto von Dentz [Wed, 15 Jul 2020 20:29:24 +0000 (13:29 -0700)]
adapter: Remove timer for removing temporary devices

Now that each temporary device object can cleanup after it has detected
that it has disappeared it is no longer necessary to keep this logic as
well in the adapter.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodevice: Add timer for removing temporary devices
Luiz Augusto von Dentz [Wed, 15 Jul 2020 20:23:23 +0000 (13:23 -0700)]
device: Add timer for removing temporary devices

This adds a timer for how long to keep temporary devices, it is updated
everytime the device is seen so devices will be removed even during an
active discovery session which means the discovering for a long period
will no longer just grow without removing devices that disappeared.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoaudio/avrcp: Always update transport volume regardless of player
Marijn Suijten [Sat, 11 Jul 2020 11:50:31 +0000 (13:50 +0200)]
audio/avrcp: Always update transport volume regardless of player

`Volume` is a special property that not only exists on players but also
on the transport (see org.bluez.MediaTransport1). A player is not
attached when the controller does not support FEATURE_CATEGORY_1, which
is common on headphones without media browsing capabilities.

On such audio devices (headphones, in-ears and the like) Absolute Volume
is not available unless an external player is registered
(org.bluez.Media1.RegisterPlayer) and the device sends a volume event
back after that to set a2dp->volume in transport.c to a valid value
(causing volume_exists to finally return true).

This [1] mail thread denoting the same issue has a solution to at least
request capabilities from the controller, but the proposed player object
is not created on category 2 devices. Any notifications received on
AVRCP_EVENT_VOLUME_CHANGED (avrcp_volume_changed) that is subsequently
registered, or handling the result of avrcp_set_volume in
avrcp_handle_set_volume will be ignored unless said player is present.

This issue is not addressed by adding a fake player but instead dealing
with the fact that volume is "special" and available on the transport
regardless of the existence of a player. This is confirmed in
avrcp_get_capabilities_resp as well which requires a player to register
any event except AVRCP_EVENT_VOLUME_CHANGED.

The applied solution moves media_transport_update_device_volume out of
the player and into avrcp_volume_changed/avrcp_handle_set_volume where
it is unconditionally called. These functions are the only users of
avrcp_player->set_volume.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: Fix not cleanup temporary devices
Luiz Augusto von Dentz [Wed, 8 Jul 2020 21:14:59 +0000 (14:14 -0700)]
adapter: Fix not cleanup temporary devices

When an adapter is powered down or unplugged remove its temporary
devices immediatelly as the application will no longer be able to
connect to them.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoclient: Add support for the Roles property.
Alain Michaud [Tue, 7 Jul 2020 02:19:20 +0000 (02:19 +0000)]
client: Add support for the Roles property.

This adds support for reading the Roles property through bluetootctl's
show option.

[bluetooth]# show
...
Roles: central
Roles: peripheral
Roles: central-peripheral

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoadapter: add support for the Roles property
Alain Michaud [Tue, 7 Jul 2020 02:19:18 +0000 (02:19 +0000)]
adapter: add support for the Roles property

This patch adds support for the Roles property as defined in
adapter-api.txt.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoinput: Make HID devices support wake
Abhishek Pandit-Subedi [Mon, 6 Jul 2020 20:25:18 +0000 (13:25 -0700)]
input: Make HID devices support wake

HID devices can wake the host from a suspended state. Mark the profiles
to support wake when they are accepted. If the device hasn't already
been configured with a Wake Allowed configuration, it will default to
yes when the profile is accepted.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodoc/device-api: Add WakeAllowed
Abhishek Pandit-Subedi [Mon, 6 Jul 2020 20:25:17 +0000 (13:25 -0700)]
doc/device-api: Add WakeAllowed

Add documentation for WakeAllowed, which allows a device to wake the
system from suspend.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoclient: Display wake allowed property with info
Abhishek Pandit-Subedi [Mon, 6 Jul 2020 20:25:16 +0000 (13:25 -0700)]
client: Display wake allowed property with info

Display whether the device is configured as wake allowed when queried
with cmd_info.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agodevice: Support marking a device with wake allowed
Abhishek Pandit-Subedi [Mon, 6 Jul 2020 20:25:15 +0000 (13:25 -0700)]
device: Support marking a device with wake allowed

If a device is allowed to wake the host system from suspend, it should
be marked as wake allowed. We add support for a new property that is
sent to the kernel via set device flags mgmt op. We also add the dbus
endpoint to allow the wake allowed setting to be controlled.

In order for wake allowed to be set, the profile must also support wake.
This setting isn't exposed to the user but must be set by profiles that
intend to support wake from suspend.

If a device is connecting for the first time, it will be marked
WakeAllowed if the profile supports it. On subsequent reloads of bluez,
the stored setting "WakeAllowed" will be used to override any other
setting.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomonitor: Decode device flags mgmt ops and event
Abhishek Pandit-Subedi [Mon, 6 Jul 2020 20:25:14 +0000 (13:25 -0700)]
monitor: Decode device flags mgmt ops and event

Add support for Get Device Flags and Set Device Flags mgmt operations
and Device Flags Changed mgmt event.

Sample trace:
@ MGMT Command: Set Device Flags (0x0050) plen 11     {0x0002} [hci0]
        LE Address: CD:F3:CD:13:C5:91 (Static)
        Current Flags: 0x00000000
@ MGMT Event: Device Flags Changed (0x002a) plen 15   {0x0001} [hci0]
        LE Address: CD:F3:CD:13:C5:91 (Static)
        Supported Flags: 0x00000001
          Remote Wakeup
        Current Flags: 0x00000000
@ MGMT Event: Device Flags Changed (0x002a) plen 15   {0x0004} [hci0]
        LE Address: CD:F3:CD:13:C5:91 (Static)
        Supported Flags: 0x00000001
          Remote Wakeup
        Current Flags: 0x00000000
@ MGMT Event: Device Flags Changed (0x002a) plen 15   {0x0003} [hci0]
        LE Address: CD:F3:CD:13:C5:91 (Static)
        Supported Flags: 0x00000001
          Remote Wakeup
        Current Flags: 0x00000000
@ MGMT Event: Command Complete (0x0001) plen 10       {0x0002} [hci0]
      Set Device Flags (0x0050) plen 7
        Status: Success (0x00)
        LE Address: CD:F3:CD:13:C5:91 (Static)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agomgmt: Add mgmt op and events for device flags
Abhishek Pandit-Subedi [Mon, 6 Jul 2020 20:25:13 +0000 (13:25 -0700)]
mgmt: Add mgmt op and events for device flags

Add Get Device Flags, Set Device Flags and Device Flags Changed.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoclient: Add battery percentage to info command
Sonny Sasaka [Thu, 2 Jul 2020 18:01:55 +0000 (11:01 -0700)]
client: Add battery percentage to info command

This adds the Battery Percentage to the info command based on
org.bluez.Battery1 API. Example usage:

[bluetooth]# info XX:XX:XX:XX:XX:XX
Device XX:XX:XX:XX:XX:XX (random)
        Name: ...
        Alias: ...
        ...
        Modalias: ...
        Battery Percentage: 0x64 (100)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agounit/test-gatt: Fix test /TP/GAR/CL/BI-16-C/auto
Luiz Augusto von Dentz [Thu, 2 Jul 2020 17:20:35 +0000 (10:20 -0700)]
unit/test-gatt: Fix test /TP/GAR/CL/BI-16-C/auto

Test has been using Read Blob Response (0x0d) opcode instead of the
expected Read Response (0x0b) to Read Resquest (0x0a).

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoshared/gatt-client: Fix not return error to callback
Luiz Augusto von Dentz [Thu, 2 Jul 2020 16:01:05 +0000 (09:01 -0700)]
shared/gatt-client: Fix not return error to callback

If a CCC request has been cancelled the pdu given to the callback will
be NULL which was not translated to a proper error.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agoscanparam: Use configured values when available
Alain Michaud [Wed, 1 Jul 2020 13:13:28 +0000 (13:13 +0000)]
scanparam: Use configured values when available

This patch updates the scan parameter service to use the configured scan
parameters when available rather than the hardcoded kernel defaults.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
3 years agogobex: Fix segfault caused by interrupted transfer
Denis Grigorev [Tue, 30 Jun 2020 13:47:31 +0000 (16:47 +0300)]
gobex: Fix segfault caused by interrupted transfer

When a obex transfer is interrupted by a peer in the middle, the response
G_OBEX_RSP_FORBIDDEN comes and the transfer is freed in transfer_complete.
However gobex is still ref'ed and gobex->io continues to be writable,
so write_data() and then g_obex_abort() are called. When the abort response
comes, struct obc_transfer is already freed, which leads to the crash.

Backtrace :
__GI___pthread_mutex_lock (mutex=0x65732f74) at pthread_mutex_lock.c:67
0xecc6eeda in dbus_connection_get_object_path_data () from libdbus-1.so.3
0x000457d4 in g_dbus_emit_property_changed_full () at gdbus/object.c:1794
0x00045868 in g_dbus_emit_property_changed () at gdbus/object.c:1832
0x000367f0 in transfer_set_status () at obexd/client/transfer.c:211
0x0003681e in transfer_set_status () at obexd/client/transfer.c:206
xfer_complete () at obexd/client/transfer.c:672
0x00022df6 in transfer_complete () at gobex/gobex-transfer.c:103
0x00022f44 in transfer_abort_response () at gobex/gobex-transfer.c:124
0x00020a0e in handle_response () at gobex/gobex.c:1128
0x00020dde in incoming_data () at gobex/gobex.c:1373

This commit introduces g_obex_drop_tx_queue(), which will be called if
a transfer error detected. After the tx queue is dropped, obex shuts
down gracefully.

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