platform/upstream/bluez.git
2 years agotools: Cleanup deprecated symbolic file permissions
Brian Gix [Tue, 23 Feb 2021 18:51:20 +0000 (10:51 -0800)]
tools: Cleanup deprecated symbolic file permissions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agosrc: Cleanup deprecated symbolic file permissions
Brian Gix [Tue, 23 Feb 2021 18:46:15 +0000 (10:46 -0800)]
src: Cleanup deprecated symbolic file permissions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoprofiles: Cleanup deprecated symbolic file permissions
Brian Gix [Tue, 23 Feb 2021 18:45:02 +0000 (10:45 -0800)]
profiles: Cleanup deprecated symbolic file permissions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoperipheral: Cleanup deprecated symbolic file permissions
Brian Gix [Tue, 23 Feb 2021 18:43:42 +0000 (10:43 -0800)]
peripheral: Cleanup deprecated symbolic file permissions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoobexd: Cleanup deprecated symbolic file permissions
Brian Gix [Tue, 23 Feb 2021 18:36:38 +0000 (10:36 -0800)]
obexd: Cleanup deprecated symbolic file permissions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomesh: Cleanup deprecated symbolic file permissions
Brian Gix [Tue, 23 Feb 2021 18:39:57 +0000 (10:39 -0800)]
mesh: Cleanup deprecated symbolic file permissions

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix handling of BT_HCI_EVT_LE_BIG_SYNC_ESTABILISHED
Luiz Augusto von Dentz [Tue, 23 Feb 2021 19:07:16 +0000 (11:07 -0800)]
monitor: Fix handling of BT_HCI_EVT_LE_BIG_SYNC_ESTABILISHED

This adds the missing fields for BT_HCI_EVT_LE_BIG_SYNC_ESTABILISHED
event.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix handling of BT_HCI_EVT_LE_BIG_COMPLETE
Luiz Augusto von Dentz [Tue, 23 Feb 2021 19:02:53 +0000 (11:02 -0800)]
monitor: Fix handling of BT_HCI_EVT_LE_BIG_COMPLETE

This adds the missing fields for BT_HCI_EVT_LE_BIG_COMPLETE event.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoRelease 5.56
Marcel Holtmann [Mon, 22 Feb 2021 20:12:40 +0000 (21:12 +0100)]
Release 5.56

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobuild: Update library version
Marcel Holtmann [Mon, 22 Feb 2021 20:00:05 +0000 (21:00 +0100)]
build: Update library version

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: fix set_mode MGMT_OP_SET_BONDABLE
Archie Pusaka [Mon, 22 Feb 2021 06:07:43 +0000 (14:07 +0800)]
adapter: fix set_mode MGMT_OP_SET_BONDABLE

Currently pending_settings is assigned MGMT_SETTING_DISCOVERABLE,
but it should have been MGMT_SETTING_BONDABLE instead.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Check whether adapter is pending powered
Archie Pusaka [Mon, 22 Feb 2021 05:18:45 +0000 (13:18 +0800)]
adapter: Check whether adapter is pending powered

The powered setting of adapter is frequently being checked, but the
check only accounts for whether it currently is powered. When powering
off the adapter, there is a brief moment when the adapter is already
off kernel-wise, but powered property is still true.

If powered property is accessed at this time, some problems might
occur. For example, if RemoveDevice DBus API is called, we would still
carry out the request and remove the device from the user space, but
we would fail to remove it from the kernel, therefore resulting an
error when we want to re-pair the device.

This patch addresses this issue by also checking whether adapter is
being powered off when checking for powered.

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt-database: Fix notifying on indicatable attr
Curtis [Fri, 19 Feb 2021 17:49:46 +0000 (12:49 -0500)]
gatt-database: Fix notifying on indicatable attr

When a local GATT characteristic has both the indicate and notify
properties, notifications will not be send to clients requesting them.
This change fixes this, allowing for notifications to be sent.

Also simplifies logic about when notifications/indications should
be sent.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agosixaxis: Fix Bluetooth PS3 clone joypad being named like the original
Szymon Janc [Thu, 11 Feb 2021 15:39:13 +0000 (16:39 +0100)]
sixaxis: Fix Bluetooth PS3 clone joypad being named like the original

When cable pairing a PS3 clone device, we should try and keep the USB device
name to create a new btd_device so that the joypad is named after its USB name
when connecting through Bluetooth.

If that isn't done, "Shanwan" clone joypads are named like the genuine joypads, and
kernel Bluetooth quirks aren't applied.

gh-issue: https://github.com/bluez/bluez/issues/46
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Fix not sending ISO packets
Luiz Augusto von Dentz [Fri, 19 Feb 2021 23:19:25 +0000 (15:19 -0800)]
btdev: Fix not sending ISO packets

ISO packets were not correctly parsed causing them to not be sent
properly.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator: Add option for enabling debug with btvirt
Luiz Augusto von Dentz [Fri, 19 Feb 2021 23:18:24 +0000 (15:18 -0800)]
emulator: Add option for enabling debug with btvirt

This adds -d/--debug options which enables debug of vhci instance on
btvirt.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agovhci: Add vhci_set_debug
Luiz Augusto von Dentz [Fri, 19 Feb 2021 23:17:02 +0000 (15:17 -0800)]
vhci: Add vhci_set_debug

This enables debug with btdev_set_debug.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomesh: Combine common functions for NetKeys and AppKeys
Inga Stotland [Thu, 18 Feb 2021 00:39:56 +0000 (16:39 -0800)]
mesh: Combine common functions for NetKeys and AppKeys

No change in functionality, code tightening.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoavdtp: Remove use of G_PRIORITY_LOW
Luiz Augusto von Dentz [Tue, 16 Feb 2021 22:55:45 +0000 (14:55 -0800)]
avdtp: Remove use of G_PRIORITY_LOW

G_PRIORITY_LOW was used in order to prioritize the AVDTP media transport
channel over the signalling channel but this has the side effect of
delaying the dispatching of other conditions such as HUP/NVAL, so now
that BtIO use G_PRIORITY_HIGH for its watches we no longer need to
deprioritize session_cb.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtio: Use G_PRIORITY_HIGH for watches
Luiz Augusto von Dentz [Tue, 16 Feb 2021 22:51:04 +0000 (14:51 -0800)]
btio: Use G_PRIORITY_HIGH for watches

This makes btio watches default to G_PRIORITY_HIGH instead of
G_PRIORITY_DEFAULT so it takes priority over regular traffic or
timeout handling.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoavdtp: Fix setting disconnect timer when there is no local endpoints
Luiz Augusto von Dentz [Tue, 16 Feb 2021 22:02:10 +0000 (14:02 -0800)]
avdtp: Fix setting disconnect timer when there is no local endpoints

If there are not local endpoints left there is no point in starting
the disconnect timer as without any endpoint it is not possible to
configure streams anymore so the code should proceed to disconnect
immediately.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mesh-cfg-client:
Inga Stotland [Fri, 12 Feb 2021 21:42:44 +0000 (13:42 -0800)]
tools/mesh-cfg-client:

Make sure that the values of Device UUID supplied in
CreateNetwork and AddRemoteNode methods are compliant with
RFC 4122.
Also, use a compliant value for Mesh UUID.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotest/test-mesh: Generate correct value for Device UUID
Inga Stotland [Fri, 12 Feb 2021 21:42:43 +0000 (13:42 -0800)]
test/test-mesh: Generate correct value for Device UUID

This ensures that the value of Device UUID when invoking
Join method is compliant with RFC 4122.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomesh: Add validation of Device UUID value
Inga Stotland [Fri, 12 Feb 2021 21:42:42 +0000 (13:42 -0800)]
mesh: Add validation of Device UUID value

Validate that the value of Device UUID supplied in
CreateNetwork/Join/Import methods is compliant with RFC 4122.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/mesh-api: Add notion of Device UUID compliance
Inga Stotland [Fri, 12 Feb 2021 21:42:41 +0000 (13:42 -0800)]
doc/mesh-api: Add notion of Device UUID compliance

Add requirement that the value of Device UUID supplied in
CreateNetwork/Join/Import methods should be compliant with
RFC 4122.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomesh: Clear node's agent pointer after agent removal
Inga Stotland [Thu, 11 Feb 2021 02:55:58 +0000 (18:55 -0800)]
mesh: Clear node's agent pointer after agent removal

When a node is created/provisioned/imported, the new node's agent
is removed. The corresponding pointer in the node structure needs
to be set to NULL to avoid pointing to freed memory.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoa2dp: set session to NULL when freeing channel
Archie Pusaka [Fri, 5 Feb 2021 03:47:46 +0000 (11:47 +0800)]
a2dp: set session to NULL when freeing channel

There is a possibility that avdtp_channel is freed when avdtp_setup
is not yet freed. This could cause crashes because setup->chan will
then point to an invalid address.

Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/bluemoon: Add support for checking other firmware file types
Tedd Ho-Jeong An [Tue, 2 Feb 2021 03:40:05 +0000 (19:40 -0800)]
tools/bluemoon: Add support for checking other firmware file types

There are more firmware files for Intel devices like .ddc, and .bseq.
This patch checks the file extension and analyze the firmware file.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/bluemoon: Display FW version of firmware file
Tedd Ho-Jeong An [Tue, 2 Feb 2021 03:40:04 +0000 (19:40 -0800)]
tools/bluemoon: Display FW version of firmware file

This patch displays a FW version after parsing the WRITE_BOOT_PARAMS
command in the firmeare file. It also change the display type for
Module vendor and Date in the CSS header to hex for easy read.

Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobuild: Fix build error with missing ell/pkcs5.h
Luiz Augusto von Dentz [Tue, 26 Jan 2021 23:45:53 +0000 (15:45 -0800)]
build: Fix build error with missing ell/pkcs5.h

./ell/ell.h:24:10: fatal error: ell/pkcs5.h: No such file or directory
   24 | #include <ell/pkcs5.h>
      |          ^~~~~~~~~~~~~

Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobuild: Fix undefined references when using slibtool
Luiz Augusto von Dentz [Tue, 26 Jan 2021 19:20:05 +0000 (11:20 -0800)]
build: Fix undefined references when using slibtool

gh issue: https://github.com/bluez/bluez/issues/86

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoELL: Up-rev the ELL file list to version Rel 0.37
Brian Gix [Thu, 14 Jan 2021 21:09:24 +0000 (13:09 -0800)]
ELL: Up-rev the ELL file list to version Rel 0.37

This has no functional change.  It simply changes the ELL file list used
for the statically linked version of ELL into BlueZ executables.

Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools: Fix static analysis warnings
Brian Gix [Fri, 22 Jan 2021 19:40:14 +0000 (11:40 -0800)]
tools: Fix static analysis warnings

Usage of potentially NULL pointers

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoinput/hog: Fix double registering report value callbacks
Sonny Sasaka [Mon, 25 Jan 2021 19:33:54 +0000 (11:33 -0800)]
input/hog: Fix double registering report value callbacks

In commit 23b69ab3e484 ("input/hog: Cache the HID report map"), we
optimized HOG reconnection by registering report value callbacks early,
but there was a bug where we also re-register the same report value
callbacks after at CCC write callback. We should handle this case by
avoiding the second callback register if we know we have done it
earlier.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Fix auto-disable Extended Adv Set
Luiz Augusto von Dentz [Fri, 22 Jan 2021 22:46:30 +0000 (14:46 -0800)]
btdev: Fix auto-disable Extended Adv Set

For a Set to be disable there is a dedicated event that terminates the
set otherwise it should be considered enabled even when connected.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Fix using CIG settings from the peripheral not the central
Luiz Augusto von Dentz [Tue, 19 Jan 2021 21:51:12 +0000 (13:51 -0800)]
btdev: Fix using CIG settings from the peripheral not the central

SetCIGParameters is only used by the central while accept/reject CIS is
performed on in the peripheral so le_cis_estabilished shall use the
parameters set in the conn->link->dev.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: Fix crash when a device is removed
Luiz Augusto von Dentz [Tue, 19 Jan 2021 19:29:51 +0000 (11:29 -0800)]
gatt: Fix crash when a device is removed

If a device is removed with notifications enabled that would lead to
device_state being freed while att_disconnected has not been called
yet.

gh-issue: https://github.com/bluez/bluez/issues/82
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Decode add advmon with RSSI parameter
Archie Pusaka [Fri, 15 Jan 2021 11:50:45 +0000 (19:50 +0800)]
monitor: Decode add advmon with RSSI parameter

Add support for MGMT command of add advertisement monitor with RSSI
parameter (0x0056).

@ MGMT Command: Add Advertisement.. (0x0056) plen 76  {0x0003}
        RSSI data:
          high threshold: 1 dBm
          high timeout: 0 seconds
          low threshold: -2 dBm
          low timeout: 3 seconds
          sampling: just once (0xFF)
        Number of patterns: 2
          Pattern 1:
            AD type: 0
            Offset: 1
            Length: 2
            Value : c504
          Pattern 2:
            AD type: 255
            Offset: 10
            Length: 4
            Value : 9a55beef

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobluetoothctl: advmon rssi support for mgmt
Archie Pusaka [Fri, 15 Jan 2021 11:50:43 +0000 (19:50 +0800)]
bluetoothctl: advmon rssi support for mgmt

Using the new opcode MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI to
monitor advertisement according to some RSSI criteria.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtmgmt: advmon add rssi support
Archie Pusaka [Fri, 15 Jan 2021 11:50:41 +0000 (19:50 +0800)]
btmgmt: advmon add rssi support

Using the new opcode MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI to
monitor advertisement according to some RSSI criteria.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agosrc/adv_monitor: add monitor with rssi support for mgmt
Archie Pusaka [Fri, 15 Jan 2021 11:50:39 +0000 (19:50 +0800)]
src/adv_monitor: add monitor with rssi support for mgmt

Using the new opcode MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI to
monitor advertisement according to some RSSI criteria.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/advmon-api: Introduce sampling period property
Archie Pusaka [Fri, 15 Jan 2021 11:50:37 +0000 (19:50 +0800)]
doc/advmon-api: Introduce sampling period property

The sampling period is used to align with the new MGMT opcode which
also have sampling period.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agolib/mgmt: Adding Add Adv Patterns Monitor RSSI opcode
Archie Pusaka [Fri, 15 Jan 2021 11:50:34 +0000 (19:50 +0800)]
lib/mgmt: Adding Add Adv Patterns Monitor RSSI opcode

The new op is to utilize RSSI in advertisement monitor

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/crypto: Transform bt_cryto in a singleton
Luiz Augusto von Dentz [Fri, 15 Jan 2021 18:52:42 +0000 (10:52 -0800)]
shared/crypto: Transform bt_cryto in a singleton

This makes bt_crypto always return the same instance thus avoiding the
problem of having multiple PF sockets opened which may hit the file
descriptor limit.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator: Fix sending CIS Requested to Create CIS device
Luiz Augusto von Dentz [Thu, 14 Jan 2021 20:54:13 +0000 (12:54 -0800)]
emulator: Fix sending CIS Requested to Create CIS device

CIS Requested shall be send to the remote peer not the originating one.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: Fix assuming service changed has been subscribed
Luiz Augusto von Dentz [Fri, 8 Jan 2021 21:08:25 +0000 (13:08 -0800)]
gatt: Fix assuming service changed has been subscribed

Unfortunately assuming service changed has been subscribed may cause
indication to time out in some peripherals (Logitech M720 Triathlon, Mx
Anywhere 2, Lenovo Mice N700, RAPOO BleMouse and Microsoft Designer
Mouse) even though the expect actually mandates that the client responds
with confirmation these peripherals just ignores it completely which
leads them to be disconnected whenever bluetoothd is restarted or the
system reboots.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodevice: Enable ATT layer debugging
Luiz Augusto von Dentz [Fri, 8 Jan 2021 18:57:04 +0000 (10:57 -0800)]
device: Enable ATT layer debugging

This uses bt_att_set_debug to enable ATT debugging which is useful for
detecting error such as an ATT transaction timing out.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/att: Add debug level to bt_att_set_debug
Luiz Augusto von Dentz [Fri, 8 Jan 2021 18:54:24 +0000 (10:54 -0800)]
shared/att: Add debug level to bt_att_set_debug

This creates different levels of debugging which can be passed to
bt_att_set_debug as depending on the application it may not need to
print everything which can pollute the logs quite a bit.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoutil: Introduce util_debug_va
Luiz Augusto von Dentz [Fri, 8 Jan 2021 18:51:58 +0000 (10:51 -0800)]
util: Introduce util_debug_va

This introduces util_debug_va which can take a va_list that enables
callers to create wrapper functions if they need to.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/gatt-server: Fix not accepting multiple requests
Luiz Augusto von Dentz [Wed, 6 Jan 2021 23:22:41 +0000 (15:22 -0800)]
shared/gatt-server: Fix not accepting multiple requests

With introduction of EATT it is possible to send multiple requests using
different channels therefore bt_gatt_server shall not attempt to check
if there is already an outstanding request.

gh issue: https://github.com/bluez/bluez/issues/75

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Remove temporary devices before power off
Archie Pusaka [Wed, 6 Jan 2021 09:26:58 +0000 (17:26 +0800)]
adapter: Remove temporary devices before power off

If adapter is powered off when a currently connected device is
being removed, there is a possibility that we haven't finish waiting
for the disconnection but the adapter is already powered down.

When this happens, the kernel would fail to clean the device's
information, for example the pairing information. This causes
disagreement between the user space and the kernel about whether the
device is already paired, because the device is successfully removed
from the user space's perspective.

This patch enforces the removal of such devices before allowing the
adapter to power off.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: Make use of gatt_db_attribute_set_fixed_length
Luiz Augusto von Dentz [Wed, 6 Jan 2021 00:45:37 +0000 (16:45 -0800)]
gatt: Make use of gatt_db_attribute_set_fixed_length

This makes use of gatt_db_attribute_set_fixed_length so the database is
aware of the length of the values and perform bounds checking.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/gatt-db: Introduce gatt_db_attribute_set_fixed_length
Luiz Augusto von Dentz [Wed, 6 Jan 2021 00:38:03 +0000 (16:38 -0800)]
shared/gatt-db: Introduce gatt_db_attribute_set_fixed_length

This enables user to inform if an attribute has a fixed length so it can
automatically perform bounds checking.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/mgmt: Fix memory leak in mgmt_tlv_list
Howard Chung [Tue, 5 Jan 2021 03:12:57 +0000 (11:12 +0800)]
shared/mgmt: Fix memory leak in mgmt_tlv_list

This patch freed the mgmt_tlv properly in mgmt_tlv_list_free.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtmgmt: Add command set-sysconfig
Howard Chung [Tue, 5 Jan 2021 03:12:56 +0000 (11:12 +0800)]
btmgmt: Add command set-sysconfig

Add command set-sysconfig in btmgmt

Example usage:
[mgmt]# set-sysconfig -h
Parameters:
        -v <type:length:value>...
e.g.:
        set-sysconfig -v 001a:2:1234 001f:1:00
[mgmt]# set-sysconfig -v 8:2:abcd 1:02:0100 0016:2:0600

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtmgmt: Add command read-sysconfig
Howard Chung [Tue, 5 Jan 2021 03:12:55 +0000 (11:12 +0800)]
btmgmt: Add command read-sysconfig

Add command read-sysconfig in btmgmt

Example usage:
localhost ~ # btmgmt
[mgmt]# read-sysconfig
Type: 0x0000    Length: 02      Value: 0000
Type: 0x0001    Length: 02      Value: 0008
...
Type: 0x001f    Length: 01      Value: 01

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/mgmt: Add supports of parsing mgmt tlv list
Howard Chung [Tue, 5 Jan 2021 03:12:54 +0000 (11:12 +0800)]
shared/mgmt: Add supports of parsing mgmt tlv list

Response from Read System Default Configuration is a list of mgmt_tlv,
which requires further processing to get the values of each parameters.

This adds APIs for parsing response into mgmt_tlv_list, retrieving
parameter from mgmt_tlv_list.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: Fix potential buffer out-of-bound
Luiz Augusto von Dentz [Mon, 4 Jan 2021 18:38:31 +0000 (10:38 -0800)]
gatt: Fix potential buffer out-of-bound

When client features is read check if the offset is within the cli_feat
bounds.

Fixes: https://github.com/bluez/bluez/issues/70
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agocfg: Add check for newly used function in ELL
Brian Gix [Mon, 4 Jan 2021 18:33:53 +0000 (10:33 -0800)]
cfg: Add check for newly used function in ELL

ELL has a new dependency on rawmemchr() which needs to be accounted for
at configure time.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomesh: Update AppKeys on transition to Phase 0
Michael N. Moran [Mon, 4 Jan 2021 03:48:37 +0000 (22:48 -0500)]
mesh: Update AppKeys on transition to Phase 0

At the end of the mesh Key Refresh procedure when a subnet
transitions to Phase 0, local AppKeys that were updated were
not updating until the bluetooth-meshd daemon was restarted.

This patch iterates the AppKeys at the end of mesh Key Refresh
when the subnet transitions to Phase 0, setting the new state
of each updated AppKey.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mgmt-tester: Adds new test data with updated tx power
Tedd Ho-Jeong An [Wed, 23 Dec 2020 00:26:33 +0000 (16:26 -0800)]
tools/mgmt-tester: Adds new test data with updated tx power

This patch adds new test data for the ext advertising test cases that
presets the advertising parameter and toggles the connectable flags.

When the adv instance is created, it updates the default tx power with
the value read from the controller. After toggling the connectable flag,
the host uses the tx_power stored in the adv list cache, which is the
value read from the controller, instead of the default tx power
value(127).

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator/btdev: Add support LE_READ_TX_POWER command
Tedd Ho-Jeong An [Wed, 23 Dec 2020 00:26:32 +0000 (16:26 -0800)]
emulator/btdev: Add support LE_READ_TX_POWER command

This patch adds support for LE_READ_TX_POWER command.
It uses a random values for min and max tx power since these values is
read from the controller.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mgmt-tester: Update sample data for adv features
Tedd Ho-Jeong An [Wed, 23 Dec 2020 00:26:31 +0000 (16:26 -0800)]
tools/mgmt-tester: Update sample data for adv features

This patch updates the expected sample data for advertising feature to
include the changes for tx power.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtmon: fix buffer bound checks
Jacob Siverskog [Tue, 22 Dec 2020 20:45:47 +0000 (21:45 +0100)]
btmon: fix buffer bound checks

index_list is of size MAX_INDEX - correct the checks that is meant to
catch out-of-bounds access.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/mgmt-api: Add opcode for adding advertisement monitor with RSSI
Archie Pusaka [Tue, 15 Dec 2020 10:10:36 +0000 (18:10 +0800)]
doc/mgmt-api: Add opcode for adding advertisement monitor with RSSI

This is to leverage the filtering by RSSI feature on those controllers
which supports advertisement packet filtering. To avoid changing the
existing API and breaking it, a new opcode is required.

Reviewed-by: Manish Mandlik <mmandlik@chromium.org>
Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Reviewed-by: Yun-Hao Chung <howardchung@google.com>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobthost: Add support for address types other then public
Luiz Augusto von Dentz [Thu, 17 Dec 2020 23:18:29 +0000 (15:18 -0800)]
bthost: Add support for address types other then public

This properly initialize the address type according to the connection
address.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agohciemu: Add support for multiple clients
Luiz Augusto von Dentz [Wed, 25 Nov 2020 21:13:04 +0000 (13:13 -0800)]
hciemu: Add support for multiple clients

This adds support for creating multiple clients (bthost).

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Add support for multiple connections
Luiz Augusto von Dentz [Thu, 19 Nov 2020 23:58:53 +0000 (15:58 -0800)]
btdev: Add support for multiple connections

This adds support for assigning different handles for connection
instead of always using fixed handles.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobthost: Always use conn->prnd for Pairing Random
Luiz Augusto von Dentz [Thu, 17 Dec 2020 18:24:47 +0000 (10:24 -0800)]
bthost: Always use conn->prnd for Pairing Random

Since it is now properly set with random bytes it shall be used when
responding.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotest: add test app for Advertisement Monitor API
Manish Mandlik [Tue, 8 Dec 2020 22:58:47 +0000 (14:58 -0800)]
test: add test app for Advertisement Monitor API

The python test app to test working of the Advertisement Monitor API.

This app:
- registers itself with bluez by invoking the RegisterMonitor with the
  app root path
- exposes multiple monitor objects with both valid and invalid monitor
  parameters
- implements Activate/Release/DeviceFound/DeviceLost methods on the
  monitor object

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobthost: Use bt_crypto_random_bytes to generate a Pairing Random
Luiz Augusto von Dentz [Thu, 17 Dec 2020 00:28:00 +0000 (16:28 -0800)]
bthost: Use bt_crypto_random_bytes to generate a Pairing Random

This makes it more consistent with how stacks are implemented instead
of setting the response all zero which is not secure.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Add option to disable time offset
Luiz Augusto von Dentz [Wed, 16 Dec 2020 22:58:08 +0000 (14:58 -0800)]
monitor: Add option to disable time offset

This adds option -N/--no-time which disables the time offset which
sometimes is useful when diffing traces where timing information is not
relevant.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Fix not responding with the same CIG ID
Luiz Augusto von Dentz [Tue, 15 Dec 2020 21:47:00 +0000 (13:47 -0800)]
btdev: Fix not responding with the same CIG ID

BT_HCI_CMD_LE_SET_CIG_PARAMS shall be responded using the same CIG ID.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoinput/hog: Cache the HID report map
Sonny Sasaka [Mon, 14 Dec 2020 22:15:02 +0000 (14:15 -0800)]
input/hog: Cache the HID report map

To optimize BLE HID devices reconnection response, we can cache the
report map so that the subsequent reconnections do not need round trip
time to read the report map.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoRevert "input/hog: Remove HID device after HoG device disconnects"
Sonny Sasaka [Mon, 14 Dec 2020 22:15:01 +0000 (14:15 -0800)]
Revert "input/hog: Remove HID device after HoG device disconnects"

This reverts commit d6cafa1f0c3ea1989f8a580e52f418b0998a3552.

In commit d6cafa1f0c3e ("input/hog: Remove HID device after HoG device
disconnects"), the bt_hog structure is destroyed in order to fix a bug
where the UHID connection is not destroyed. This fix has the cost of
increasing reconnection time because every reconnection would need to
re-read the report map again. An improvement to this fix is, instead of
removing the bt_hog structure, we can just destroy the UHID with
UHID_DESTROY event and use the existing bt_hog structure to keep the
cache of the report map to avoid re-reading the report map at
reconnection.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc: Fix qemu unable to mount root fs for test-runner
Tedd Ho-Jeong An [Wed, 25 Nov 2020 07:57:07 +0000 (23:57 -0800)]
doc: Fix qemu unable to mount root fs for test-runner

This patch fixes the kernel panic while loading the kernel image built
with the current config for test-runner.

 Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
 CPU: 0 PID: 1 Comm: swapper Not tainted 5.10.0-rc2-702835-ged93facee36e #6
 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-1ubuntu1 04/01/2014
 Call Trace:
  panic+0xee/0x27c
  mount_block_root+0x315/0x324
  ? rest_init+0x7a/0x7a
  prepare_namespace+0x128/0x157
  ? rest_init+0x7a/0x7a
  kernel_init+0x5/0xf6
  ret_from_fork+0x22/0x30
 Kernel Offset: 0x2a200000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbf)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtdev: Fix not handling BT_HCI_CMD_HOST_NUM_COMPLETED_PACKETS
Luiz Augusto von Dentz [Tue, 8 Dec 2020 01:06:51 +0000 (17:06 -0800)]
btdev: Fix not handling BT_HCI_CMD_HOST_NUM_COMPLETED_PACKETS

System such as Zephyr do use BT_HCI_CMD_HOST_NUM_COMPLETED_PACKETS
since BT_HCI_CMD_SET_HOST_FLOW_CONTROL is also supported.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadv_monitor: Update log messages
Manish Mandlik [Wed, 25 Nov 2020 20:18:46 +0000 (12:18 -0800)]
adv_monitor: Update log messages

Update log messages to avoid breaking of user-visible log strings
to make it easy to grep for them.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoclient: Use correct root path for RegisterMonitor
Manish Mandlik [Thu, 3 Dec 2020 03:46:52 +0000 (19:46 -0800)]
client: Use correct root path for RegisterMonitor

Bluetoothctl uses "/" as the app root path. So, use the same
app root path while invoking RegisterMonitor method. This will
also ensure that InterfacesAdded/InterfacesRemoved signals are
emitted on the correct app root path.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadv_monitor: Register client app with app-root-path
Manish Mandlik [Thu, 3 Dec 2020 03:46:51 +0000 (19:46 -0800)]
adv_monitor: Register client app with app-root-path

When a client app is registered with g_dbus_client_new(), bluez root
path, i.e. "/", is used as the app root path and signal watches are
added at that root path.

Because of this, InterfacesAdded/InterfacesRemoved signals emitted by
app - while creating/removing advertisement monitor objects at the
app root path - are not received by bluetoothd.

Use g_dbus_client_new_full() to register a client app with the correct
app root path.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomain.conf: Fix using wrong field for PageTimeout
Luiz Augusto von Dentz [Tue, 1 Dec 2020 23:10:30 +0000 (15:10 -0800)]
main.conf: Fix using wrong field for PageTimeout

The correct field is btd_opts.defaults.br.page_timeout.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomain.conf: Use BR instead of BREDR as group name
Luiz Augusto von Dentz [Tue, 1 Dec 2020 22:24:50 +0000 (14:24 -0800)]
main.conf: Use BR instead of BREDR as group name

This align with latest version of main.conf that does use [BR] instead
of [BREDR].

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mgmt-tester: Add tests for individual ext adv MGMT commands
Daniel Winkler [Tue, 24 Nov 2020 17:31:23 +0000 (09:31 -0800)]
tools/mgmt-tester: Add tests for individual ext adv MGMT commands

The new extended advertising MGMT commands are paired, requiring both a
Set Parameters and Set Data command to configure a new advertisement.
This patch adds the following new tests to test these APIs:

1. Verify that if the adapter is unpowered, MGMT_OP_ADD_EXT_ADV_PARAMS
will return a rejected status.

2. Verify that MGMT_OP_ADD_EXT_ADV_PARAMS will return an invalid
parameters status if the data payload is malformed.

3. Verify that MGMT_OP_ADD_EXT_ADV_PARAMS is successful on BT4 if
request is valid by checking MGMT return value.

4. Verify that MGMT_OP_ADD_EXT_ADV_PARAMS is successful on BT5 if
request is valid by checking MGMT return value and that HCI traffic
contains a correct advertising parameters request.

5. Verify that if a MGMT_OP_ADD_EXT_ADV_DATA request is received for an
advertising instance that is unknown, i.e. MGMT_OP_ADD_EXT_ADV_PARAMS
was not yet called, an invalid parameters status is returned.

Tests 6-8 first call MGMT_OP_ADD_EXT_ADV_PARAMS successfully in setup to
then validate the contents of the subsequent MGMT_OP_ADD_EXT_ADV_DATA
call.

6. Verify that if MGMT_OP_ADD_EXT_ADV_DATA is passed an invalid tlv
structure, an invalid parameters status is returned.

7. Verify that if MGMT_OP_ADD_EXT_ADV_DATA contains a valid structure,
the hci traffic contain a correctly formed Adv Data hci request.

8. Verify that if MGMT_OP_ADD_EXT_ADV_DATA contains a valid structure,
the hci traffic contain a correctly formed Adv Scan Response hci
request.

Reviewed-by: Manish Mandlik <mmandlik@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 mgmt-tester coverage for controller capabilities
Daniel Winkler [Tue, 24 Nov 2020 17:31:22 +0000 (09:31 -0800)]
tools/mgmt-tester: Add mgmt-tester coverage for controller capabilities

This patch adds two test cases for the new Read Controller
Capabilities MGMT command. Since the command itself is simple, the test
cases are simple as well:

1. Ensures that providing invalid parameters to the request will result
in a failed MGMT response.

2. Ensures that if the controller is BT5 compliant, the Read Controller
Capabilities command will return a valid TX power range as expected,
otherwise fail.

Reviewed-by: Manish Mandlik <mmandlik@chromium.org>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobattery: Implement Battery Provider API
Sonny Sasaka [Mon, 30 Nov 2020 21:56:02 +0000 (13:56 -0800)]
battery: Implement Battery Provider API

This patch implements the BatteryProvider1 and BatteryProviderManager1
API. This is a means for external clients to feed battery information to
BlueZ if they handle some profile and can decode battery reporting.

The battery information is then exposed externally via the existing
Battery1 interface. UI components can consume this API to display
Bluetooth peripherals' battery via a unified BlueZ API.

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 agoadapter: Add a public function to find a device by path
Sonny Sasaka [Mon, 30 Nov 2020 21:56:01 +0000 (13:56 -0800)]
adapter: Add a public function to find a device by path

The public function is motivated by the Battery Provider API code which
needs to probe whether a device exists.

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 agotest: Add test app for Battery Provider API
Sonny Sasaka [Mon, 30 Nov 2020 21:56:00 +0000 (13:56 -0800)]
test: Add test app for Battery Provider API

The python test app simulates an application registering to BlueZ as a
Battery Provider providing three fake batteries drained periodically.

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 agodoc: Add Battery Provider API doc
Sonny Sasaka [Mon, 30 Nov 2020 21:55:59 +0000 (13:55 -0800)]
doc: Add Battery Provider API doc

This patch add the documentation of the Battery Provider which lets
external clients feed battery information to BlueZ if they are able to
decode battery reporting via any profile. BlueZ UI clients can then use
the org.bluez.Battery1 API as a single source of battery information
coming from many different profiles.

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 agobattery: Add Source property to Battery API
Sonny Sasaka [Mon, 30 Nov 2020 21:55:58 +0000 (13:55 -0800)]
battery: Add Source property to Battery API

As Battery API will be generalized for other battery reporting
protocols, the Source property is useful for diagnostics purposes.

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 agoprofiles/battery: Refactor to use battery library
Sonny Sasaka [Mon, 30 Nov 2020 21:55:57 +0000 (13:55 -0800)]
profiles/battery: Refactor to use battery library

This refactors profiles/battery to use the internal battery library that
handles the D-Bus intricacies so that profiles/battery only handles the
GATT BAS concerns.

Reviewed-by: Daniel Winkler <danielwinkler@google.com>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobattery: Add the internal Battery API
Sonny Sasaka [Mon, 30 Nov 2020 21:55:56 +0000 (13:55 -0800)]
battery: Add the internal Battery API

This patch adds an API for internal BlueZ code to expose battery
information to org.bluez.Battery1 interface. The motivation behind this
is that there is going to be other places than GATT BAS handler that
exposes battery information, for example internal plugins and the
BatteryProvider1 D-Bus API for external clients.

Reviewed-by: Daniel Winkler <danielwinkler@google.com>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoa2dp: Fix crash if setup is freed while reconfiguring
Luiz Augusto von Dentz [Mon, 30 Nov 2020 19:16:11 +0000 (11:16 -0800)]
a2dp: Fix crash if setup is freed while reconfiguring

This fixes the crash reported on:

https://github.com/bluez/bluez/issues/60
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomain.conf: use correct key for BREDR configuration
Ronan Pigott [Tue, 24 Nov 2020 22:46:58 +0000 (15:46 -0700)]
main.conf: use correct key for BREDR configuration

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agolib: Fix the unchecked return value
Tedd Ho-Jeong An [Fri, 20 Nov 2020 20:07:12 +0000 (12:07 -0800)]
lib: Fix the unchecked return value

This patch fixes the unchecked return value.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoprofile/bnep: Fix the unchecked return value
Tedd Ho-Jeong An [Fri, 20 Nov 2020 20:07:11 +0000 (12:07 -0800)]
profile/bnep: Fix the unchecked return value

This patch fixes the unchecked return value.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator: Fix the unchecked return value
Tedd Ho-Jeong An [Fri, 20 Nov 2020 20:07:10 +0000 (12:07 -0800)]
emulator: Fix the unchecked return value

This patch fixes the unchecked return value.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtio: Fix the unchecked return value
Tedd Ho-Jeong An [Fri, 20 Nov 2020 20:07:09 +0000 (12:07 -0800)]
btio: Fix the unchecked return value

This patch fixes the unchecked return value.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix the unchecked return value
Tedd Ho-Jeong An [Fri, 20 Nov 2020 20:07:08 +0000 (12:07 -0800)]
monitor: Fix the unchecked return value

This patch fixes the unchecked return value.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Fix potential memory leak
Tedd Ho-Jeong An [Fri, 20 Nov 2020 20:07:07 +0000 (12:07 -0800)]
monitor: Fix potential memory leak

If the mainloop_add_fd() returns with failure, the destroy callback is
never called so any reosurces need to be released never freed/closed.

This potential leakage is checked with valgrind after failing the
mainloop_add_fd() function manually.

   ==258684== 1,500 bytes in 1 blocks are definitely lost in loss record 3 of 3
   ==258684==    at 0x483BB1A: calloc (vg_replace_malloc.c:760)
   ==258684==    by 0x123F1A: open_channel (control.c:1058)
   ==258684==    by 0x125B09: control_tracing (control.c:1540)
   ==258684==    by 0x122764: main (main.c:255)
   ==258684==
   ==258684== LEAK SUMMARY:
   ==258684==    definitely lost: 1,500 bytes in 1 blocks
   ==258684==    indirectly lost: 0 bytes in 0 blocks
   ==258684==      possibly lost: 0 bytes in 0 blocks
   ==258684==    still reachable: 48 bytes in 2 blocks
   ==258684==         suppressed: 0 bytes in 0 blocks

This patch frees/closes the resources if the function returns with
failure.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoa2dp: Fix crash when SEP codec has not been initialized
Luiz Augusto von Dentz [Mon, 23 Nov 2020 18:20:06 +0000 (10:20 -0800)]
a2dp: Fix crash when SEP codec has not been initialized

If SEP has not been properly discovered avdtp_get_codec may return NULL
thus causing crashes such as:

https://github.com/bluez/bluez/issues/57
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>