platform/upstream/bluez.git
2 years agomgmt-tester: Update set_connectable_off_adv_param
Luiz Augusto von Dentz [Tue, 3 Nov 2020 23:38:56 +0000 (15:38 -0800)]
mgmt-tester: Update set_connectable_off_adv_param

Parameters have been changed in the kernel which now uses the following:

< HCI Command: LE Set Advertising Parameters (0x08|0x0006) plen 15
        Min advertising interval: 62.500 msec (0x0064)
        Max advertising interval: 93.750 msec (0x0096)
        Type: Scannable undirected - ADV_SCAN_IND (0x02)
        Own address type: Random (0x01)
        Direct address type: Public (0x00)
        Direct address: 00:00:00:00:00:00 (OUI 00-00-00)
        Channel map: 37, 38, 39 (0x07)
        Filter policy: Allow Scan Request from Any, Allow Connect Request from Any (0x00)

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomgmt-tester: Print out the HCI received and expected cmd value
Luiz Augusto von Dentz [Tue, 3 Nov 2020 23:36:28 +0000 (15:36 -0800)]
mgmt-tester: Print out the HCI received and expected cmd value

This make it simpler to debug when the kernel has been updated and
parameters no longer match:

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotest-runner: Fix using removed options
Luiz Augusto von Dentz [Tue, 3 Nov 2020 23:15:08 +0000 (15:15 -0800)]
test-runner: Fix using removed options

This removes -nodefconfig and -balloon which are not longer valid
options:

  qemu-system-x86_64: -nodefconfig: invalid option
  qemu-system-x86_64: -balloon: invalid option

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc: Add tester.config
Luiz Augusto von Dentz [Tue, 3 Nov 2020 23:09:43 +0000 (15:09 -0800)]
doc: Add tester.config

This adds tester.config which can be used as a reference to create
kernel images to be run with test-runner.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Fix a crash caused by lingering discovery client pointer
Miao-chen Chou [Mon, 2 Nov 2020 22:30:03 +0000 (14:30 -0800)]
adapter: Fix a crash caused by lingering discovery client pointer

This cleans up the lingering pointer, adapter->client, during powering
off the adapter. The crash occurs when a D-Bus client set Powered
property to false and immediately calls StopDiscovery() when there is
ongoing discovery. As a part of powering off the adapter,
adapter->discovery_list gets cleared, and given that adapter->client
refers to one of the clients in adapter->discovery_list, adapter->client
should be cleared along with it.

(1) Connect to a BT audio device from BT system tray.
(2) Once the audio device is connected, power off BT and immediately
power off the audio device.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/smp-tester: Enable hciemu debug
Luiz Augusto von Dentz [Mon, 2 Nov 2020 19:09:12 +0000 (11:09 -0800)]
tools/smp-tester: Enable hciemu debug

This enable hciemu debug when debug is enabled.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/sco-tester: Enable hciemu debug
Luiz Augusto von Dentz [Mon, 2 Nov 2020 19:08:39 +0000 (11:08 -0800)]
tools/sco-tester: Enable hciemu debug

This enable hciemu debug when debug is enabled.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/rfcomm-tester: Enable hciemu debug
Luiz Augusto von Dentz [Mon, 2 Nov 2020 19:08:12 +0000 (11:08 -0800)]
tools/rfcomm-tester: Enable hciemu debug

This enable hciemu debug when debug is enabled.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/bnep-tester: Enable hciemu debug
Luiz Augusto von Dentz [Mon, 2 Nov 2020 19:07:19 +0000 (11:07 -0800)]
tools/bnep-tester: Enable hciemu debug

This enable hciemu debug when debug is enabled.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/mgmt-tester: Enable hciemu debug
Luiz Augusto von Dentz [Mon, 2 Nov 2020 19:06:35 +0000 (11:06 -0800)]
tools/mgmt-tester: Enable hciemu debug

This enable hciemu debug when debug is enabled.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools/l2cap-tester: Enable hciemu debug
Luiz Augusto von Dentz [Fri, 30 Oct 2020 00:20:11 +0000 (17:20 -0700)]
tools/l2cap-tester: Enable hciemu debug

This enable hciemu debug when debug is enabled.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator/bthost: Add support for LE CIS Request
Luiz Augusto von Dentz [Fri, 30 Oct 2020 22:05:06 +0000 (15:05 -0700)]
emulator/bthost: Add support for LE CIS Request

This enables bthost to act as acceptor of LE CIS Request.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator: Fix not gerating proper advertisement
Luiz Augusto von Dentz [Fri, 30 Oct 2020 21:48:38 +0000 (14:48 -0700)]
emulator: Fix not gerating proper advertisement

When a btdev instance advertise using the legacy command and the other
instance uses the extended version to scan the report type are not
actually setting the legacy PDU properly.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator/hciemu: Add debug support
Luiz Augusto von Dentz [Thu, 29 Oct 2020 21:45:55 +0000 (14:45 -0700)]
emulator/hciemu: Add debug support

This adds bthost_set_debug which can be used to debug internals of
hciemu.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator/bthost: Add debug support
Luiz Augusto von Dentz [Thu, 29 Oct 2020 21:16:50 +0000 (14:16 -0700)]
emulator/bthost: Add debug support

This adds bthost_set_debug which can be used to debug internals of
bthost.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator/btdev: Add debug support
Luiz Augusto von Dentz [Thu, 29 Oct 2020 21:15:34 +0000 (14:15 -0700)]
emulator/btdev: Add debug support

This adds btdev_set_debug which can be used to debug internals of
btdev.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadv_monitor: Issue Remove Adv Monitor mgmt call
Alain Michaud [Sat, 31 Oct 2020 00:52:56 +0000 (17:52 -0700)]
adv_monitor: Issue Remove Adv Monitor mgmt call

This calls Remove Adv Monitor command to kernel and handles the callback
during a monitor removal initiated by a D-Bus client. This also
registers callback for getting notified on Adv Monitor Removed event, so
that the Adv monitor manager can invalidate the monitor by calling
Release() on its proxy.

The following tests were performed.
- In bluetoothctl console, add a monitor and remove the monitor by its
index and verify the removal in both the output of btmgmt and syslog.
- In bluetoothctl console, add a monitor, remove the monitor via
btmgmt and verify the removal in syslog.

Change-Id: Ib51b9e6ce76e816e66bb7248e48be7364ca9812e
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadv_monitor: Fix return type of RegisterMonitor() method
Miao-chen Chou [Sat, 31 Oct 2020 00:52:54 +0000 (17:52 -0700)]
adv_monitor: Fix return type of RegisterMonitor() method

This modifies the D-Bus call return type to be asynchronous for
RegisterMonitor() method call.

The following test was performed:
- Enter bluetoothctl, exit the console and re-enter the console without
AlreadyExist error for RegisterMonitor() upon bring-up of the console.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadv_monitor: Implement Add Adv Patterns Monitor cmd handler
Howard Chung [Sat, 31 Oct 2020 00:52:52 +0000 (17:52 -0700)]
adv_monitor: Implement Add Adv Patterns Monitor cmd handler

- Send the MGMT_OP command to kernel upon registration of a Adv patterns
monitor.
- Call Activate() or Release() to client depending on the reply from
  kernel

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Clear all Adv monitors upon bring-up
Miao-chen Chou [Sat, 31 Oct 2020 00:52:50 +0000 (17:52 -0700)]
adapter: Clear all Adv monitors upon bring-up

This clears all Adv monitors upon daemon bring-up by issuing
MGMT_OP_REMOVE_ADV_MONITOR command with monitor_handle 0.

The following test was performed:
- Add an Adv Monitor using btmgmt, restart bluetoothd and observe the
monitor got removed.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadv_monitor: Implement RSSI filtering and content matching
Manish Mandlik [Sat, 31 Oct 2020 00:52:48 +0000 (17:52 -0700)]
adv_monitor: Implement RSSI filtering and content matching

This implements the following logic for background scanning.
- Implement RSSI tracking based on high/low RSSI thresholds and timers.
- Create an entry point in adapter to start the matching of Adv based
on all monitors and invoke the RSSI tracking for Adv reporting.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/ad: Add support of bt_ad_pattern
Miao-chen Chou [Sat, 31 Oct 2020 00:52:46 +0000 (17:52 -0700)]
shared/ad: Add support of bt_ad_pattern

This adds struct bt_ad_pattern and helpers functions to facilitate
pattern matching.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Split loading of BREDR and LE defaults
Luiz Augusto von Dentz [Fri, 30 Oct 2020 19:57:33 +0000 (12:57 -0700)]
adapter: Split loading of BREDR and LE defaults

Avoid loading default parameters for modes that are disabled.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agocore: Fix mistakes of using mgmt_tlv_add_fixed
Howard Chung [Fri, 30 Oct 2020 09:11:02 +0000 (17:11 +0800)]
core: Fix mistakes of using mgmt_tlv_add_fixed

Fix mistakes on checking the result of mgmt_tlv_add_fixed.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agocore: Add param to disable interleave scan
Howard Chung [Fri, 30 Oct 2020 09:11:01 +0000 (17:11 +0800)]
core: Add param to disable interleave scan

This patch adds parameter to enable/disable the interleave scan feature.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agocore: Add parmas to set interleaving durations
Howard Chung [Fri, 30 Oct 2020 09:11:00 +0000 (17:11 +0800)]
core: Add parmas to set interleaving durations

This patch adds parameters to control the durations of allowlist scan
and no-filter scan when the kernel is doing interleaving scan.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Add new MGMT adv commands and events to monitor
Daniel Winkler [Thu, 29 Oct 2020 23:06:22 +0000 (16:06 -0700)]
monitor: Add new MGMT adv commands and events to monitor

This change adds the following to packet monitor:
-Add Ext Adv Params command and response
-Add Ext Adv Data command and response

This patch was manually tested by registering advertisements with
various features and verifying in btmon log.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoclient: Add SupportedCapabilities to bluetoothctl
Daniel Winkler [Thu, 29 Oct 2020 23:06:21 +0000 (16:06 -0700)]
client: Add SupportedCapabilities to bluetoothctl

This patch adds the new "SupportedCapabilities" property to the
bluetoothctl "show" view.

The change is tested by verifying bluetoothctl shows the desired
properties.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadvertising: Expose SupportedCapabilities for advertising
Daniel Winkler [Thu, 29 Oct 2020 23:06:20 +0000 (16:06 -0700)]
advertising: Expose SupportedCapabilities for advertising

To help our advertising clients understand the device capabilities, this
patch adds a SupportedCapabilities dbus endpoint for the advertising
manager. The primary reason behind this is to provide the valid LE tx
power range the controller supports (populated if controller supports
BT5), so a client can know the valid power range before requesting a tx
power for their advertisement.

I also thought it would be useful to indicate the max advertising data
length and scan response length in this endpoint, since some clients
will find it useful to set their advertising data (currently
experimental feature) or scan response data (possible future feature)
directly.

This patch has been tested on Hatch (BT5 support) and Kukui (No BT5
support) chromebooks to verify that the dbus endpoint contains the
correct data.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadvertising: Query LE TX range at manager initialization
Daniel Winkler [Thu, 29 Oct 2020 23:06:19 +0000 (16:06 -0700)]
advertising: Query LE TX range at manager initialization

This patch calls the new MGMT command to get controller capabilities,
and parses the min and max LE tx power range when the manager is
initialized. This will be used to populate a client-facing dbus entry so
that the client will know the advertising capabilities of the controller
before registering an advertisement.

This patch is tested by manually verifying the data is parsed correctly
from the MGMT response.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadvertising: Use new mgmt interface for advertising add
Daniel Winkler [Thu, 29 Oct 2020 23:06:18 +0000 (16:06 -0700)]
advertising: Use new mgmt interface for advertising add

This patch allows bluetoothd to use the new extended advertising add
mgmt interface if it is available. The new interface will be used by
default, as it allows the client to set advertising intervals, and tx
power if the controller and kernel support extended advertising.

Each new registered advertisement will submit two requests to kernel;
the first sets the advertising parameters for the advertising instance,
and the second sets the advertising data and scan response for the
instance.

The parameters MGMT request will return the tx power selected by the
controller (if applicable), which is propagated to the client via a dbus
Set method.

Note: This patch also fixes a small bug in the packet monitor, where the
tx power value 0xff is considered as "Host has no preference". However,
the spec states this value to be 0x7f. It is corrected in this patch

This change has been tested extensively on Hatch (extended advertising)
and Kukui (no extended advertising) chromebooks. Manual tests do the
following:
- Configure advertisement with custom intervals, tx power with valid and
  invalid values and combinations
- Ensure that with valid parameters, they are propagated and set in hci
  requests. With invalid parameters, ensure that the registration fails.

Automatic tests verify 25 advertising usage scenarios involving single
and multi-advertising registration, over-registration, parameter
validation, etc. These tests don't test new intervals and tx power, but
validate that the new MGMT interface does not regress compatibility in
these 25 scenarios.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadvertising: Parse intervals and tx power from adv
Daniel Winkler [Thu, 29 Oct 2020 23:06:17 +0000 (16:06 -0700)]
advertising: Parse intervals and tx power from adv

This change adds parsers for the advertising intervals and tx power
properties of the LEAdvertisement1 object. It validates that each field
adheres to the 5.2 spec, and that min and max intervals are compatible
with each other, i.e. that min interval is less than max interval.

A note here for maintainers: The tx power that is sent in the hci
parameter command is an int8_t, but as far as I can tell, there is no
clean way to use a signed 8-bit integer in dbus. The dbus byte type
seems incompatible with negative values in high-level languages (python)
without awkward usage manipulation on the client side. For this reason,
I chose to use an int16_t type for the tx power dbus field, which is
then downcasted to the int8_t in bluetoothd, which at least makes the
signed-ness of the type crystal clear to the dbus client that uses it.

This change is manually verified by ensuring the intervals and tx power
parameters are correctly parsed from the LEAdvertisement1 object, and
that the parse fails if the parameters are incorrect or not compatible
with each other.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadvertising: Detect if extended advertising mgmt commands are supported
Daniel Winkler [Thu, 29 Oct 2020 23:06:16 +0000 (16:06 -0700)]
advertising: Detect if extended advertising mgmt commands are supported

We need to know if kernel supports the new MGMT interface. To do so, we
check the return from adapter's MGMT_OP_READ_COMMANDS call for the new
commands. This will later be used to route our requests for new
advertisements.

The change is tested by manually verifying that the correct MGMT
commands are used when the feature is and is not available in kernel.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/mgmt-api: Update controller capabilities MGMT command in mgmt-api
Daniel Winkler [Thu, 29 Oct 2020 23:06:15 +0000 (16:06 -0700)]
doc/mgmt-api: Update controller capabilities MGMT command in mgmt-api

This patch changes Read Security Info MGMT to be called Read Controller
Capabilities Command

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/mgmt-api: Add new Advertising MGMT interfaces to mgmt-api
Daniel Winkler [Thu, 29 Oct 2020 23:06:14 +0000 (16:06 -0700)]
doc/mgmt-api: Add new Advertising MGMT interfaces to mgmt-api

This patch adds the following to mgmt-api:
- Add Extended Advertising Parameters Command
- Add Extended Advertising Data Command

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/advertising-api: update API with new interface
Daniel Winkler [Thu, 29 Oct 2020 23:06:13 +0000 (16:06 -0700)]
doc/advertising-api: update API with new interface

This updates the advertising documentation to include the following
features:

LE Advertising Manager:
- New SupportedCapabilities property

LE Advertisement:
- New min/max interval properties
- New tx power property

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Decode Remove ADV Monitor
Howard Chung [Thu, 29 Oct 2020 10:09:45 +0000 (18:09 +0800)]
monitor: Decode Remove ADV Monitor

Add support for Remove Advertisement Monitor MGMT command and event.

@ MGMT Command: Remove Advertisement Monitor (0x0053) plen 2
Handle: 1
@ MGMT Event: Advertisement Monitor Added (0x002c) plen 2
        Handle: 1
@ MGMT Event: Command Complete (0x0001) plen 5
      Remove Advertisement Monitor (0x0053) plen 2
        Status: Success (0x00)
        Handle: 1

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Decode Add ADV monitor command
Howard Chung [Thu, 29 Oct 2020 10:09:44 +0000 (18:09 +0800)]
monitor: Decode Add ADV monitor command

Add support for Add Advertisement Monitor MGMT command and event.

@ MGMT Command: Add Advertisement Monitor (0x0052) plen 69
        Number of patterns: 2
          Pattern 1:
            AD type: 0
            Offset: 1
            Length: 2
            Value : ...
          Pattern 2:
            AD type: 1
            Offset: 10
            Length: 4
            Value : ...
@ MGMT Event: Advertisement Monitor Added (0x002b) plen 2
        Handle: 1
@ MGMT Event: Command Complete (0x0001) plen 5
      Add Advertisement Monitor (0x0052) plen 2
        Status: Success (0x00)
        Handle: 1

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Decode ADV Monitor read feature command
Howard Chung [Thu, 29 Oct 2020 10:09:43 +0000 (18:09 +0800)]
monitor: Decode ADV Monitor read feature command

Add support for Read Advertisement Monitor Features mgmt operation.

@ MGMT Command: Read Advertisement Monitor Features (0x0051) plen 0
@ MGMT Event: Command Complete (0x0001) plen 20
      Read Advertisement Monitor Features (0x0051) plen 17
        Status: Success (0x00)
        Supported Features: 0x00000000
        Enabled Features: 0x00000000
        Max number of handles: 32
        Max number of patterns: 16
        Number of handles: 2
          Handle: 1
          Handle: 3

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agocore: Rename hcid.h to btd.h
Luiz Augusto von Dentz [Wed, 28 Oct 2020 21:53:36 +0000 (14:53 -0700)]
core: Rename hcid.h to btd.h

Since we use btd term for daemon APIs it makes sense to use it also
for the header name instead of hcid.

Change-Id: Ib2c8e730fa5fd4bf4119fb245c958fa0450e3e11
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agocore: Rename main_opts to btd_opts
Luiz Augusto von Dentz [Wed, 28 Oct 2020 21:50:00 +0000 (14:50 -0700)]
core: Rename main_opts to btd_opts

Use btd_ prefix since this is a daemon API.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agocore: Split LE and BR/EDR parameters
Luiz Augusto von Dentz [Wed, 28 Oct 2020 21:45:36 +0000 (14:45 -0700)]
core: Split LE and BR/EDR parameters

This splits LE and BR/EDR config parameters and checks main_conf.mode
when parsing them.

Change-Id: Ib42be9ad8c6cffe7b6b04d5d40caa7fac66fb7a9
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/mgmt: Add mgmt_tlv_add_fixed
Luiz Augusto von Dentz [Wed, 28 Oct 2020 21:43:35 +0000 (14:43 -0700)]
shared/mgmt: Add mgmt_tlv_add_fixed

This adds mgmt_tlv_add_fixed macro which can be used to add fixed sized
value.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomgmt: Add support of mgmt TLV API
Howard Chung [Wed, 28 Oct 2020 11:52:46 +0000 (19:52 +0800)]
mgmt: Add support of mgmt TLV API

This adds API to send multiple TLVs to kernel, it is useful for
mgmt set system config command.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoaudio/media: Destroy transport if SetConfiguration fails
Marijn Suijten [Mon, 26 Oct 2020 19:54:08 +0000 (20:54 +0100)]
audio/media: Destroy transport if SetConfiguration fails

set_configuration creates a transport before calling SetConfiguration on
the MediaEndpoint1 DBus interface.  If this DBus call fails the
transport sticks around while it should instead be cleaned up.

When the peer retries or reconnects (in case of BlueZ which cuts the
connection due to a missing recount [1]) set_configuration finds this
old transport and returns FALSE.  The peer will never succeed this call
unless it randomly decides to call clear_configuration or BlueZ is
restarted.

[1]: https://marc.info/?l=linux-bluetooth&m=160364326629847&w=2

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoavdtp: Fix not setting timeout when reconfiguring
Luiz Augusto von Dentz [Mon, 26 Oct 2020 23:36:11 +0000 (16:36 -0700)]
avdtp: Fix not setting timeout when reconfiguring

When reconfiguring a codec avdtp_close will be used which resets
dc_timeout which can cause early disconnection if the new
configuration fails making it impossible to try other configurations.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator: Fix not setting CIG ID properly
Luiz Augusto von Dentz [Mon, 26 Oct 2020 23:03:01 +0000 (16:03 -0700)]
emulator: Fix not setting CIG ID properly

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agolib: Fix using spaces to align BT_PKT_STATUS
Luiz Augusto von Dentz [Thu, 22 Oct 2020 17:16:36 +0000 (10:16 -0700)]
lib: Fix using spaces to align BT_PKT_STATUS

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodevice: fix temporary_timer double free
Archie Pusaka [Tue, 20 Oct 2020 10:02:45 +0000 (18:02 +0800)]
device: fix temporary_timer double free

One instance of freeing temporary_timer is not followed by setting
the variable to 0, causing potential double free.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/timeout-ell: Fix timeout wrapper implementation
Inga Stotland [Mon, 5 Oct 2020 04:19:32 +0000 (21:19 -0700)]
shared/timeout-ell: Fix timeout wrapper implementation

This fixes the following issues:
- Correct user data is passed around to l_timeout_create():
  locally allocated timeout data is a valid "user data" to
  associate with a newly created timeout. Previously, user_data
  passed as an argument to timeout_add() was incorrectly used as
  an argument to l_timeout_create()
- To maintain common API and work around the issue when the conversion
  of a pointer to an unsigned int truncates the initial value, a queue
  of active timeouts is maintained where pointer each l_timeout structure
  is associate with a unique id. This id is returned when timeout_create()
  API is called and can be subsequently used with timeout_remove().

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/io-ell: Add reference count to io structure
Inga Stotland [Fri, 25 Sep 2020 22:38:49 +0000 (15:38 -0700)]
shared/io-ell: Add reference count to io structure

This adds reference count to io wrapper structure.
Also, correctly handles IO destroy case by unsetting
read/write/disconnect halers and freeing the corresponding
resources.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agolib: Add BT_PKT_STATUS
Luiz Augusto von Dentz [Mon, 19 Oct 2020 20:03:00 +0000 (13:03 -0700)]
lib: Add BT_PKT_STATUS

BT_PKT_STATUS has been introduced to the kernel but userspace has not
been updated to reflect that.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoavrcp: Notify Addressed Player Changed if player is unregistered
Luiz Augusto von Dentz [Mon, 12 Oct 2020 17:18:04 +0000 (10:18 -0700)]
avrcp: Notify Addressed Player Changed if player is unregistered

If current addressed player is unregistered notify Addressed Player
Changed so the controller is informed of the player changes.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoavrcp: Fix segfault when using headset controls
Daniel Å imko [Sat, 10 Oct 2020 22:27:28 +0000 (22:27 +0000)]
avrcp: Fix segfault when using headset controls

This fixes a segmentation fault caused by controls trying to notify an
unregistered player.

When an unregistered player is replaced by another valid player from the
list, the session is not referenced in the sessions list of the player
and when this player is unregistered, its reference is not removed from
the session.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agolib: Replace malloc/memset(..0..) with bt_malloc0
Aravind Machiry [Mon, 28 Sep 2020 19:20:02 +0000 (12:20 -0700)]
lib: Replace malloc/memset(..0..) with bt_malloc0

This patch replaces various instances of malloc and subsequent
memset(..,0,..) with bt_malloc0 (i.e., calloc) for efficiency.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agolib/sdp.c: Validate attribute search return value
Aravind Machiry [Mon, 28 Sep 2020 06:44:46 +0000 (23:44 -0700)]
lib/sdp.c: Validate attribute search return value

The calls to gen_[searchseq|attridseq]_seq functions return negative
value on failure. The return value should be checked to gracefully
exit with a proper exit code.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools: Add SPDX License Identifier
Tedd Ho-Jeong An [Tue, 29 Sep 2020 21:24:48 +0000 (14:24 -0700)]
tools: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 GPL-2.0-or-later     :     97
 LGPL-2.1-or-later    :     38
 GPL-2.0-only         :      2

License: GPL-2.0-or-later
   tools/l2cap-tester.c
   tools/hcisecfilter.c
   tools/ciptool.c
   tools/btsnoop.c
   tools/check-selftest.c
   tools/btpclientctl.c
   tools/hci-tester.c
   tools/hcitool.c
   tools/btiotest.c
   tools/oobtest.c
   tools/btinfo.c
   tools/hwdb.c
   tools/hciattach_bcm43xx.c
   tools/mgmt-tester.c
   tools/hex2hcd.c
   tools/hciattach_st.c
   tools/smp-tester.c
   tools/bluetooth-player.c
   tools/hciattach_tialt.c
   tools/gap-tester.c
   tools/bluemoon.c
   tools/bneptest.c
   tools/gatt-service.c
   tools/rctest.c
   tools/rfcomm-tester.c
   tools/hcieventmask.c
   tools/hciattach_ti.c
   tools/seq2bseq.c
   tools/scotest.c
   tools/bcmfw.c
   tools/hciconfig.c
   tools/btattach.c
   tools/l2ping.c
   tools/obexctl.c
   tools/l2test.c
   tools/hciattach_intel.c
   tools/hciattach.h
   tools/create-image.c
   tools/bnep-tester.c
   tools/userchan-tester.c
   tools/rfcomm.c
   tools/btmon-logger.c
   tools/hcidump.c
   tools/rtlfw.c
   tools/hciattach_qualcomm.c
   tools/btproxy.c
   tools/nokfw.c
   tools/hciattach_ath3k.c
   tools/3dsp.c
   tools/bdaddr.c
   tools/sco-tester.c
   tools/hciattach.c
   tools/amptest.c
   tools/btgatt-server.c
   tools/btgatt-client.c
   tools/cltest.c
   tools/ibeacon.c
   tools/mcaptest.c
   tools/hid2hci.c
   tools/btmgmt.c
   tools/advtest.c
   tools/eddystone.c
   tools/avtest.c
   tools/mpris-proxy.c
   tools/avinfo.c
   tools/sdptool.c
   tools/btconfig.c
   tools/update_compids.sh
   tools/parser/parser.h
   tools/parser/obex.c
   tools/parser/amp.c
   tools/parser/sdp.c
   tools/parser/tcpip.c
   tools/parser/sap.c
   tools/parser/cmtp.c
   tools/parser/avctp.c
   tools/parser/lmp.c
   tools/parser/ppp.c
   tools/parser/rfcomm.h
   tools/parser/hci.c
   tools/parser/sdp.h
   tools/parser/parser.c
   tools/parser/rfcomm.c
   tools/parser/avdtp.c
   tools/parser/avrcp.c
   tools/parser/ericsson.c
   tools/parser/hcrp.c
   tools/parser/bpa.c
   tools/parser/hidp.c
   tools/parser/bnep.c
   tools/parser/capi.c
   tools/parser/att.c
   tools/parser/l2cap.c
   tools/parser/smp.c
   tools/parser/csr.c
   tools/parser/l2cap.h
   tools/parse_companies.pl

License: LGPL-2.1-or-later
   tools/test-runner.c
   tools/btpclient.c
   tools/meshctl.c
   tools/mesh-cfgclient.c
   tools/mesh/model.h
   tools/mesh/util.h
   tools/mesh/config-model.h
   tools/mesh/cfgcli.h
   tools/mesh/mesh-db.c
   tools/mesh/mesh-db.h
   tools/mesh/keys.c
   tools/mesh/util.c
   tools/mesh/agent.h
   tools/mesh/remote.c
   tools/mesh/keys.h
   tools/mesh/agent.c
   tools/mesh/cfgcli.c
   tools/mesh/remote.h
   tools/mesh-gatt/prov.c
   tools/mesh-gatt/util.h
   tools/mesh-gatt/prov.h
   tools/mesh-gatt/net.c
   tools/mesh-gatt/util.c
   tools/mesh-gatt/prov-db.h
   tools/mesh-gatt/crypto.c
   tools/mesh-gatt/crypto.h
   tools/mesh-gatt/gatt.c
   tools/mesh-gatt/config-server.c
   tools/mesh-gatt/keys.h
   tools/mesh-gatt/onoff-model.c
   tools/mesh-gatt/net.h
   tools/mesh-gatt/gatt.h
   tools/mesh-gatt/node.c
   tools/mesh-gatt/config-client.c
   tools/mesh-gatt/mesh-net.h
   tools/mesh-gatt/node.h
   tools/mesh-gatt/onoff-model.h
   tools/mesh-gatt/prov-db.c

License: GPL-2.0-only
   tools/obex-server-tool.c
   tools/obex-client-tool.c

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodevice: Fix codying style
Luiz Augusto von Dentz [Tue, 29 Sep 2020 00:03:29 +0000 (17:03 -0700)]
device: Fix codying style

Single line statements don't require curly braces.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodevice: Disable auto connect for temporary devices
Yu Liu [Thu, 24 Sep 2020 23:17:42 +0000 (16:17 -0700)]
device: Disable auto connect for temporary devices

When connecting a LE keyboard, if the user input the wrong passkey, the
stack would keep auto connect and thus allow the user to retry the
passkey indefinitely which is a security concern. This fix would
disallow the auto connect if the authentication failed.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotools: Remove legacy code for CSR controllers
Luiz Augusto von Dentz [Fri, 25 Sep 2020 22:03:44 +0000 (15:03 -0700)]
tools: Remove legacy code for CSR controllers

This code has not been touched for ages and very unlikely that someone
will be using this nowadays as most of these controller specific
transports are handled by the kernel nowadays.

Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoshared/io-ell: Fix ELL io wrapper
Inga Stotland [Thu, 24 Sep 2020 18:20:02 +0000 (11:20 -0700)]
shared/io-ell: Fix ELL io wrapper

This modifies the internal io structure inside io-ell to retain
correct user data associated with write and read handlers and
to return these data with the corresponding callbacks.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoavdtp: Handle case where remote send L2CAP connect ahead of Open
Luiz Augusto von Dentz [Tue, 22 Sep 2020 22:58:52 +0000 (15:58 -0700)]
avdtp: Handle case where remote send L2CAP connect ahead of Open

This stores the channel if it had been connected ahead of Open
procedure so it can later be processed.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoLICENSES: Add License files
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:46:16 +0000 (12:46 -0700)]
LICENSES: Add License files

This patch adds the full text of licenses used in the BlueZ.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agotest: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:39:18 +0000 (12:39 -0700)]
test: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 LGPL-2.1-or-later    :     35

License: LGPL-2.1-or-later
   test/agent.py
   test/bluezutils.py
   test/dbusdef.py
   test/example-advertisement
   test/example-endpoint
   test/example-gatt-client
   test/example-gatt-server
   test/example-player
   test/exchange-business-cards
   test/ftp-client
   test/get-managed-objects
   test/get-obex-capabilities
   test/list-devices
   test/list-folders
   test/map-client
   test/monitor-bluetooth
   test/opp-client
   test/pbap-client
   test/sap_client.py
   test/simple-endpoint
   test/simple-obex-agent
   test/simple-player
   test/test-adapter
   test/test-device
   test/test-discovery
   test/test-gatt-profile
   test/test-health
   test/test-health-sink
   test/test-hfp
   test/test-manager
   test/test-mesh
   test/test-nap
   test/test-network
   test/test-profile
   test/test-sap-server

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobuild: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:00:38 +0000 (12:00 -0700)]
build: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 GPL-2.0-or-later     :      6

License: GPL-2.0-or-later
   Makefile.am
   Makefile.mesh
   Makefile.obexd
   Makefile.plugins
   Makefile.tools
   configure.ac

Change-Id: I454a1299e5cb820af9812df678f552234cf02bfd
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agosrc: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:36:20 +0000 (12:36 -0700)]
src: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 LGPL-2.1-or-later    :     62
 GPL-2.0-or-later     :     51
 BSD-2-Clause         :      2

License: LGPL-2.1-or-later
   src/adv_monitor.c
   src/adv_monitor.h
   src/shared/mainloop-glib.c
   src/shared/btp.c
   src/shared/tester.c
   src/shared/btsnoop.c
   src/shared/gatt-helpers.h
   src/shared/log.h
   src/shared/util.h
   src/shared/mainloop-ell.c
   src/shared/hci-crypto.c
   src/shared/mainloop.c
   src/shared/hfp.h
   src/shared/mainloop-notify.c
   src/shared/io-mainloop.c
   src/shared/btsnoop.h
   src/shared/uhid.h
   src/shared/util.c
   src/shared/ringbuf.c
   src/shared/btp.h
   src/shared/shell.h
   src/shared/io-glib.c
   src/shared/queue.h
   src/shared/gatt-server.h
   src/shared/crypto.c
   src/shared/crypto.h
   src/shared/io-ell.c
   src/shared/timeout-glib.c
   src/shared/mgmt.c
   src/shared/gatt-db.c
   src/shared/mainloop-notify.h
   src/shared/hfp.c
   src/shared/timeout-ell.c
   src/shared/shell.c
   src/shared/hci.c
   src/shared/log.c
   src/shared/ringbuf.h
   src/shared/gatt-helpers.c
   src/shared/queue.c
   src/shared/tty.h
   src/shared/timeout-mainloop.c
   src/shared/tester.h
   src/shared/gap.h
   src/shared/mgmt.h
   src/shared/gatt-db.h
   src/shared/uhid.c
   src/shared/mainloop.h
   src/shared/timeout.h
   src/shared/att-types.h
   src/shared/pcap.c
   src/shared/gap.c
   src/shared/att.c
   src/shared/pcap.h
   src/shared/hci.h
   src/shared/gatt-client.h
   src/shared/io.h
   src/shared/gatt-client.c
   src/shared/ad.c
   src/shared/att.h
   src/shared/gatt-server.c
   src/shared/hci-crypto.h
   src/shared/ad.h

License: GPL-2.0-or-later
   src/attrib-server.h
   src/advertising.h
   src/textfile.c
   src/attrib-server.c
   src/uinput.h
   src/log.h
   src/eir.h
   src/sdpd.h
   src/sdpd-request.c
   src/service.h
   src/sdpd-database.c
   src/adapter.h
   src/plugin.h
   src/uuid-helper.h
   src/plugin.c
   src/main.c
   src/sdp-xml.c
   src/error.h
   src/oui.c
   src/device.c
   src/agent.h
   src/sdp-client.c
   src/oui.h
   src/device.h
   src/gatt-database.c
   src/error.c
   src/backtrace.c
   src/sdpd-server.c
   src/adapter.c
   src/log.c
   src/agent.c
   src/backtrace.h
   src/sdp-xml.h
   src/hcid.h
   src/dbus-common.h
   src/uuid-helper.c
   src/storage.c
   src/profile.c
   src/advertising.c
   src/storage.h
   src/dbus-common.c
   src/profile.h
   src/sdpd-service.c
   src/eir.c
   src/sdp-client.h
   src/gatt-database.h
   src/gatt-client.h
   src/rfkill.c
   src/gatt-client.c
   src/service.c
   src/textfile.h

License: BSD-2-Clause
   src/shared/ecc.h
   src/shared/ecc.c

Change-Id: Ib1c3dec2724d329657c0c4003375bbbe50bcf578
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agounit: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:00:35 +0000 (12:00 -0700)]
unit: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 GPL-2.0-or-later     :     25
 LGPL-2.1-or-later    :      1
 GPL-2.0-only         :      2
 BSD-2-Clause         :      1

License: GPL-2.0-or-later
   unit/test-hog.c
   unit/test-eir.c
   unit/test-gobex-header.c
   unit/test-crc.c
   unit/test-avrcp.c
   unit/test-ringbuf.c
   unit/test-gobex-apparam.c
   unit/test-gobex.c
   unit/test-hfp.c
   unit/test-textfile.c
   unit/test-avdtp.c
   unit/test-sdp.c
   unit/test-gatt.c
   unit/test-avctp.c
   unit/test-gattrib.c
   unit/test-queue.c
   unit/test-gobex-packet.c
   unit/test-uuid.c
   unit/test-crypto.c
   unit/test-uhid.c
   unit/test-gdbus-client.c
   unit/test-midi.c
   unit/test-lib.c
   unit/test-mgmt.c
   unit/test-gobex-transfer.c

License: LGPL-2.1-or-later
   unit/test-mesh-crypto.c

License: GPL-2.0-only
   unit/util.h
   unit/util.c

License: BSD-2-Clause
   unit/test-ecc.c

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoprofiles: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:00:34 +0000 (12:00 -0700)]
profiles: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 GPL-2.0-or-later     :     72
 LGPL-2.1-or-later    :      6

License: GPL-2.0-or-later
   profiles/deviceinfo/dis.c
   profiles/deviceinfo/deviceinfo.c
   profiles/health/hdp_types.h
   profiles/health/mcap.c
   profiles/health/hdp_manager.c
   profiles/health/hdp_main.c
   profiles/health/mcap.h
   profiles/health/hdp_util.h
   profiles/health/hdp_manager.h
   profiles/health/hdp_util.c
   profiles/health/hdp.c
   profiles/health/hdp.h
   profiles/network/server.c
   profiles/network/connection.h
   profiles/network/connection.c
   profiles/network/manager.c
   profiles/network/bnep.c
   profiles/network/server.h
   profiles/network/bnep.h
   profiles/battery/battery.c
   profiles/cups/cups.h
   profiles/cups/sdp.c
   profiles/cups/main.c
   profiles/cups/spp.c
   profiles/cups/hcrp.c
   profiles/scanparam/scpp.c
   profiles/scanparam/scan.c
   profiles/audio/transport.h
   profiles/audio/avdtp.h
   profiles/audio/source.c
   profiles/audio/player.c
   profiles/audio/avctp.c
   profiles/audio/control.h
   profiles/audio/a2dp.c
   profiles/audio/source.h
   profiles/audio/transport.c
   profiles/audio/sink.c
   profiles/audio/avrcp.h
   profiles/audio/avdtp.c
   profiles/audio/a2dp.h
   profiles/audio/avrcp.c
   profiles/audio/media.h
   profiles/audio/avctp.h
   profiles/audio/control.c
   profiles/audio/sink.h
   profiles/audio/player.h
   profiles/audio/media.c
   profiles/sap/server.c
   profiles/sap/sap-dummy.c
   profiles/sap/main.c
   profiles/sap/sap.h
   profiles/sap/manager.c
   profiles/sap/server.h
   profiles/sap/manager.h
   profiles/iap/main.c
   profiles/gap/gas.c
   profiles/midi/midi.c
   profiles/midi/libmidi.c
   profiles/midi/libmidi.h
   profiles/input/server.c
   profiles/input/suspend.h
   profiles/input/uhid_copy.h
   profiles/input/device.c
   profiles/input/hog.c
   profiles/input/device.h
   profiles/input/hidp_defs.h
   profiles/input/manager.c
   profiles/input/suspend-none.c
   profiles/input/sixaxis.h
   profiles/input/hog-lib.c
   profiles/input/suspend-dummy.c
   profiles/input/server.h

License: LGPL-2.1-or-later
   profiles/deviceinfo/dis.h
   profiles/battery/bas.h
   profiles/battery/bas.c
   profiles/scanparam/scpp.h
   profiles/audio/a2dp-codecs.h
   profiles/input/hog-lib.h

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoplugins: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:00:33 +0000 (12:00 -0700)]
plugins: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 GPL-2.0-or-later     :      7

License: GPL-2.0-or-later
   plugins/autopair.c
   plugins/hostname.c
   plugins/neard.c
   plugins/policy.c
   plugins/sixaxis.c
   plugins/wiimote.c
   plugins/external-dummy.c

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoperipheral: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:00:32 +0000 (12:00 -0700)]
peripheral: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 LGPL-2.1-or-later    :     11

License: LGPL-2.1-or-later
   peripheral/log.h
   peripheral/main.c
   peripheral/efivars.c
   peripheral/attach.h
   peripheral/gatt.c
   peripheral/attach.c
   peripheral/log.c
   peripheral/gap.h
   peripheral/efivars.h
   peripheral/gap.c
   peripheral/gatt.h

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoobexd: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:00:31 +0000 (12:00 -0700)]
obexd: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 GPL-2.0-or-later     :     65

License: GPL-2.0-or-later
   obexd/src/mimetype.c
   obexd/src/transport.h
   obexd/src/server.c
   obexd/src/obex.c
   obexd/src/log.h
   obexd/src/service.h
   obexd/src/plugin.h
   obexd/src/plugin.c
   obexd/src/main.c
   obexd/src/mimetype.h
   obexd/src/transport.c
   obexd/src/obexd.h
   obexd/src/obex.h
   obexd/src/obex-priv.h
   obexd/src/log.c
   obexd/src/map_ap.h
   obexd/src/manager.c
   obexd/src/service.c
   obexd/src/server.h
   obexd/src/manager.h
   obexd/plugins/opp.c
   obexd/plugins/vcard.h
   obexd/plugins/pbap.c
   obexd/plugins/vcard.c
   obexd/plugins/messages.h
   obexd/plugins/phonebook.h
   obexd/plugins/pcsuite.c
   obexd/plugins/messages-tracker.c
   obexd/plugins/phonebook-tracker.c
   obexd/plugins/irmc.c
   obexd/plugins/ftp.c
   obexd/plugins/ftp.h
   obexd/plugins/filesystem.c
   obexd/plugins/messages-dummy.c
   obexd/plugins/phonebook-ebook.c
   obexd/plugins/syncevolution.c
   obexd/plugins/bluetooth.c
   obexd/plugins/phonebook-dummy.c
   obexd/plugins/filesystem.h
   obexd/plugins/mas.c
   obexd/client/transport.h
   obexd/client/opp.c
   obexd/client/pbap.c
   obexd/client/transfer.h
   obexd/client/opp.h
   obexd/client/driver.c
   obexd/client/map-event.h
   obexd/client/bluetooth.h
   obexd/client/sync.h
   obexd/client/transport.c
   obexd/client/pbap.h
   obexd/client/driver.h
   obexd/client/transfer.c
   obexd/client/ftp.c
   obexd/client/map.h
   obexd/client/ftp.h
   obexd/client/bluetooth.c
   obexd/client/manager.c
   obexd/client/session.h
   obexd/client/session.c
   obexd/client/map.c
   obexd/client/sync.c
   obexd/client/map-event.c
   obexd/client/mns.c
   obexd/client/manager.h

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agomonitor: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:00:30 +0000 (12:00 -0700)]
monitor: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 LGPL-2.1-or-later    :     47

License: LGPL-2.1-or-later
   monitor/bt.h
   monitor/hcidump.h
   monitor/avdtp.h
   monitor/crc.c
   monitor/sdp.c
   monitor/hwdb.c
   monitor/intel.h
   monitor/avctp.c
   monitor/control.h
   monitor/display.c
   monitor/a2dp.c
   monitor/ll.c
   monitor/ll.h
   monitor/jlink.h
   monitor/broadcom.h
   monitor/lmp.c
   monitor/keys.c
   monitor/ellisys.c
   monitor/main.c
   monitor/ellisys.h
   monitor/hwdb.h
   monitor/display.h
   monitor/jlink.c
   monitor/rfcomm.h
   monitor/packet.c
   monitor/crc.h
   monitor/keys.h
   monitor/sdp.h
   monitor/rfcomm.c
   monitor/avdtp.c
   monitor/a2dp.h
   monitor/avctp.h
   monitor/vendor.h
   monitor/hcidump.c
   monitor/intel.c
   monitor/tty.h
   monitor/control.c
   monitor/lmp.h
   monitor/analyze.c
   monitor/bnep.c
   monitor/l2cap.c
   monitor/vendor.c
   monitor/packet.h
   monitor/broadcom.c
   monitor/analyze.h
   monitor/l2cap.h
   monitor/bnep.h

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agolib: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:00:28 +0000 (12:00 -0700)]
lib: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 GPL-2.0-or-later     :     18
 GPL-2.0-only         :      1

License: GPL-2.0-or-later
   lib/sco.h
   lib/sdp.c
   lib/a2mp.h
   lib/uuid.h
   lib/bluetooth.h
   lib/hidp.h
   lib/rfcomm.h
   lib/hci.c
   lib/sdp.h
   lib/sdp_lib.h
   lib/bluetooth.c
   lib/mgmt.h
   lib/hci.h
   lib/uuid.c
   lib/l2cap.h
   lib/bnep.h
   lib/hci_lib.h
   lib/cmtp.h

License: GPL-2.0-only
   lib/amp.h

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogobex: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:00:27 +0000 (12:00 -0700)]
gobex: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 GPL-2.0-or-later     :     12

License: GPL-2.0-or-later
   gobex/gobex-defs.h
   gobex/gobex-transfer.c
   gobex/gobex.c
   gobex/gobex-apparam.h
   gobex/gobex-header.h
   gobex/gobex-header.c
   gobex/gobex.h
   gobex/gobex-packet.h
   gobex/gobex-defs.c
   gobex/gobex-debug.h
   gobex/gobex-apparam.c
   gobex/gobex-packet.c

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogdbus: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:35:09 +0000 (12:35 -0700)]
gdbus: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 GPL-2.0-or-later     :      6

License: GPL-2.0-or-later
   gdbus/mainloop.c
   gdbus/object.c
   gdbus/polkit.c
   gdbus/client.c
   gdbus/watch.c
   gdbus/gdbus.h

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoemulator: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:00:25 +0000 (12:00 -0700)]
emulator: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 LGPL-2.1-or-later    :     20
 GPL-2.0-or-later     :      2

License: LGPL-2.1-or-later
   emulator/server.c
   emulator/amp.c
   emulator/hciemu.c
   emulator/vhci.c
   emulator/btdev.c
   emulator/serial.h
   emulator/le.h
   emulator/le.c
   emulator/main.c
   emulator/amp.h
   emulator/hciemu.h
   emulator/bthost.h
   emulator/btdev.h
   emulator/vhci.h
   emulator/serial.c
   emulator/phy.c
   emulator/smp.c
   emulator/phy.h
   emulator/bthost.c
   emulator/server.h

License: GPL-2.0-or-later
   emulator/b1ee.c
   emulator/hfp.c

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoclient: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:00:24 +0000 (12:00 -0700)]
client: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 GPL-2.0-or-later     :      11

License: GPL-2.0-or-later
   client/adv_monitor.c
   client/adv_monitor.h
   client/advertising.h
   client/display.c
   client/main.c
   client/display.h
   client/agent.h
   client/gatt.c
   client/agent.c
   client/advertising.c
   client/gatt.h

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agobtio: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:00:23 +0000 (12:00 -0700)]
btio: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 GPL-2.0-or-later     :      2

License: GPL-2.0-or-later
   btio/btio.h
   btio/btio.c

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoattrib: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:00:22 +0000 (12:00 -0700)]
attrib: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 GPL-2.0-or-later     :     13

License: GPL-2.0-or-later
   attrib/att-database.h
   attrib/gattrib.h
   attrib/gatttool.h
   attrib/gatt-service.c
   attrib/interactive.c
   attrib/utils.c
   attrib/gatt.c
   attrib/gattrib.c
   attrib/gatt-service.h
   attrib/att.c
   attrib/gatt.h
   attrib/att.h
   attrib/gatttool.c

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoandroid: Add SPDX License Identifier
Tedd Ho-Jeong An [Mon, 21 Sep 2020 19:37:46 +0000 (12:37 -0700)]
android: Add SPDX License Identifier

This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 Apache-2.0           :     80
 LGPL-2.1-or-later    :     42
 GPL-2.0-or-later     :      9

License: Apache-2.0
   android/bluetoothd-wrapper.c
   android/tester-hidhost.c
   android/tester-map-client.c
   android/hal-audio-aptx.c
   android/hal-audio.c
   android/hal-handsfree-client.c
   android/tester-gatt.c
   android/hal-pan.c
   android/hal-socket.c
   android/tester-hdp.c
   android/tester-pan.c
   android/tester-avrcp.c
   android/hal-a2dp-sink.c
   android/hal-gatt.c
   android/hal-avrcp.c
   android/tester-a2dp.c
   android/hal-audio.h
   android/hal-bluetooth.c
   android/tester-socket.c
   android/hal-health.c
   android/hal-a2dp.c
   android/hal-ipc.c
   android/hal-avrcp-ctrl.c
   android/hal-sco.c
   android/hal-ipc.h
   android/tester-main.c
   android/hal-audio-sbc.c
   android/hal-utils.c
   android/hal-map-client.c
   android/hal-handsfree.c
   android/hal-log.h
   android/hal.h
   android/hal-utils.h
   android/tester-bluetooth.c
   android/hal-hidhost.c
   android/audio_utils/resampler.h
   android/audio_utils/resampler.c
   android/system/audio.h
   android/hardware/bt_sock.h
   android/hardware/bt_gatt_client.h
   android/hardware/bt_hh.h
   android/hardware/bluetooth.h
   android/hardware/hardware.h
   android/hardware/bt_hf_client.h
   android/hardware/bt_rc.h
   android/hardware/bt_hf.h
   android/hardware/bt_pan.h
   android/hardware/bt_gatt_types.h
   android/hardware/hardware.c
   android/hardware/audio_effect.h
   android/hardware/audio.h
   android/hardware/bt_gatt_server.h
   android/hardware/bt_gatt.h
   android/hardware/bt_hl.h
   android/hardware/bt_mce.h
   android/hardware/bt_av.h
   android/client/if-hh.c
   android/client/if-sco.c
   android/client/pollhandler.h
   android/client/haltest.c
   android/client/tabcompletion.c
   android/client/if-hf-client.c
   android/client/history.h
   android/client/if-audio.c
   android/client/terminal.h
   android/client/if-av.c
   android/client/if-main.h
   android/client/if-av-sink.c
   android/client/terminal.c
   android/client/if-mce.c
   android/client/if-hf.c
   android/client/pollhandler.c
   android/client/if-sock.c
   android/client/if-rc-ctrl.c
   android/client/if-rc.c
   android/client/history.c
   android/client/if-pan.c
   android/client/if-gatt.c
   android/client/if-bt.c
   android/client/if-hl.c

License: LGPL-2.1-or-later
   android/sco.h
   android/socket.c
   android/tester-main.h
   android/hidhost.h
   android/map-client.h
   android/utils.h
   android/hal-msg.h
   android/health.h
   android/avrcp-lib.c
   android/bluetoothd-snoop.c
   android/a2dp.c
   android/bluetooth.h
   android/a2dp-sink.c
   android/handsfree-client.c
   android/audio-msg.h
   android/main.c
   android/pan.c
   android/ipc-tester.c
   android/health.c
   android/socket.h
   android/handsfree.h
   android/avrcp-lib.h
   android/a2dp-sink.h
   android/system-emulator.c
   android/gatt.c
   android/avrcp.h
   android/pan.h
   android/test-ipc.c
   android/hidhost.c
   android/a2dp.h
   android/avrcp.c
   android/sco-msg.h
   android/bluetooth.c
   android/map-client.c
   android/handsfree-client.h
   android/ipc.c
   android/handsfree.c
   android/gatt.h
   android/ipc.h
   android/ipc-common.h
   android/compat/wordexp.h
   android/cutils/properties.h

License: GPL-2.0-or-later
   android/avdtp.h
   android/avctp.c
   android/avdtptest.c
   android/sco.c
   android/log.c
   android/avdtp.c
   android/avctp.h
   android/compat/readline/history.h
   android/compat/readline/readline.h

Change-Id: I838215f902a81a7f789345a2bd47e2685e331619
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoavdtp: Fix not checking if stream is already set as pending open
Luiz Augusto von Dentz [Fri, 18 Sep 2020 01:03:31 +0000 (18:03 -0700)]
avdtp: Fix not checking if stream is already set as pending open

When receiving a Open command the stream will be set as pending_open but
the remote may attempt to send yet another Open command in the meantime
resulting in another setup and yet another timer leaving the old timer
active which will likely cause a crash when it expires.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc: Add Suspend and Resume events
Abhishek Pandit-Subedi [Fri, 11 Sep 2020 17:03:17 +0000 (10:03 -0700)]
doc: Add Suspend and Resume events

Add Controller Suspend Event and Controller Resume Event to identify
suspend or resume of the Bluetooth stack has occurred.

Also update Device Disconnected Event to indicate a new disconnect
reason: "Connection terminated by local host for suspend"

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agosixaxis: Fix crash caused by return of udev_device_get_property_value
Miao-chen Chou [Wed, 16 Sep 2020 22:34:53 +0000 (15:34 -0700)]
sixaxis: Fix crash caused by return of udev_device_get_property_value

This adds a NULL check before calling sscanf().

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc/gatt-api: Add new error for StartNotify
Joseph Hwang [Fri, 21 Aug 2020 06:16:43 +0000 (23:16 -0700)]
doc/gatt-api: Add new error for StartNotify

When a device is disconnecting, StartNotify is not allowed. This adds a
new error type to the doc.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogatt: StartNotify is not allowed when device is disconnecting
Joseph Hwang [Fri, 21 Aug 2020 06:16:42 +0000 (23:16 -0700)]
gatt: StartNotify is not allowed when device is disconnecting

This patch fixed a bluetoothd crash in register_notify_cb(). The
crash is incurred by an exception that under some situation, a
characteristic may be freed when register_notify_cb() is invoked.

When a device is disconnecting, the device interface would hold valid
for a while until the disconnection procedure between the client and
the server is completed. If another process happens to request to start
notification of a characteristic on the disconnecting device, it may
incur a problem. In this case, the client would still send the
StartNotify request since the characteristic object is still valid.
However, the characteristic may be freed soon and become invalid
when the corresponding callback function is invoked later. This
leads to the bluetoothd crash due to the segmentation fault.

To handle the exception, if another process requests to start
notification when the device is disconnecting, it should reject the
request.

Tested on Chrome OS that this patch fixes bluetoothd crash in
register_notify_cb().

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agocore: Add AdvertisementMonitor to bluetooth.conf
Howard Chung [Wed, 16 Sep 2020 07:16:52 +0000 (15:16 +0800)]
core: Add AdvertisementMonitor to bluetooth.conf

AdvertisementMonitor must be included in bluetooth.conf in order to
be able to call Release

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoclient: Expose ADV monitor objects
Howard Chung [Wed, 16 Sep 2020 07:16:51 +0000 (15:16 +0800)]
client: Expose ADV monitor objects

This adds logic to expose user-defined advertisement monitor to dbus and
also implements methods for exposed objects.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoclient: Implement more interfaces of ADV monitor in bluetoothctl
Howard Chung [Wed, 16 Sep 2020 07:16:50 +0000 (15:16 +0800)]
client: Implement more interfaces of ADV monitor in bluetoothctl

This patch creates a submenu in bluetoothctl and implements several
commands.

new commands:
[bluetooth]# menu monitor
[bluetooth]# add-or-pattern 1 2 ab0011
Advertisement Monitor 0 added
[bluetooth]# add-or-pattern-rssi -80, ,5 1 2 aa 3 4 ff
Advertisement Monitor 1 added
[bluetooth]# get-pattern all
Advertisement Monitor 0
path: /org/bluez/adv_monitor_app/0
type: or_patterns
pattern 1:
start position: 1
AD data type: 2
content: ab0011
Advertisement Monitor 1
path: /org/bluez/adv_monitor_app/1
type: or_patterns
rssi:
high threshold: -50
high threshold timer: 5
low threshold: -80
low threshold timer: 5
pattern 1:
start position: 1
AD data type: 2
content: aa
pattern 2:
start position: 3
AD data type: 4
content: ff
[bluetooth]# get-supported-info
Supported Features:
Supported Moniter Types: or_patterns
[bluetooth]# remove-pattern 0
Monitor 0 deleted

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoclient: Implement basic interface of ADV monitor in bluetoothctl
Howard Chung [Wed, 16 Sep 2020 07:16:49 +0000 (15:16 +0800)]
client: Implement basic interface of ADV monitor in bluetoothctl

This patch implements some basic functions for ADV monitor in
bluetoothctl

[bluetooth]# show
...
Advertisement Monitor Features:
SupportedMonitorTypes: or_patterns

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Add btd_ prefix to has_kernel_feature
Luiz Augusto von Dentz [Tue, 15 Sep 2020 17:45:06 +0000 (10:45 -0700)]
adapter: Add btd_ prefix to has_kernel_feature

APIs exposed to plugins shall have btd_ prefix.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodevice: don't wait for timeout if RemoveDevice is called
Archie Pusaka [Tue, 15 Sep 2020 03:04:19 +0000 (11:04 +0800)]
device: don't wait for timeout if RemoveDevice is called

RemoveDevice on adapter interface used to remove a device, even when
the device is connected. However, since the introduction of the new
30 seconds timeout when setting a device as temporary, RemoveDevice
doesn't immediately remove a connected device, but only disconnects
it and waits for the timer to expire before effectively removes it.

This patch removes the device as soon as it gets disconnected,
provided the disconnection is triggered by a call to RemoveDevice.
The regular timeout still applies for other cases.

Tested manually by calling RemoveDevice on a connected device,
and with ChromeOS autotest setup.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agopolicy: Reconnect audio on controller resume
Abhishek Pandit-Subedi [Fri, 11 Sep 2020 22:30:37 +0000 (15:30 -0700)]
policy: Reconnect audio on controller resume

During system suspend, all peer devices are disconnected. On resume, HID
devices will reconnect but audio devices stay disconnected. As a quality
of life improvement, mark audio devices that were disconnected due to
suspend and attempt to reconnect them when the controller resumes (after
a delay for better co-existence with Wi-Fi).

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agopolicy: Enable reconnect for a2dp-sink in defaults
Abhishek Pandit-Subedi [Fri, 11 Sep 2020 22:30:36 +0000 (15:30 -0700)]
policy: Enable reconnect for a2dp-sink in defaults

Add a2dp-sink to default reconnects list.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Handle controller resume and notify drivers
Abhishek Pandit-Subedi [Fri, 11 Sep 2020 22:30:35 +0000 (15:30 -0700)]
adapter: Handle controller resume and notify drivers

Register for controller resume notification and notify the adapter
drivers when it occurs. Also adds the resume event kernel feature to
make sure the kernel supports this event.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadapter: Refactor kernel feature globals
Abhishek Pandit-Subedi [Fri, 11 Sep 2020 22:30:34 +0000 (15:30 -0700)]
adapter: Refactor kernel feature globals

Move all the kernel specific feature globals into a single
kernel_features bitfield and replace all uses with the bitfield instead.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agodoc: Update Advertisement Monitor API description
Miao-chen Chou [Sat, 12 Sep 2020 06:51:33 +0000 (23:51 -0700)]
doc: Update Advertisement Monitor API description

This modifies the following description to Advertisement Monitor API.
- Add org.bluez.Error.Failed to RegisterMonitor() method.
- Add more description about the usage of RegisterMonitor() and
UnregisterMonitor() methods.
- Add description about the ranges for the fields in property
RSSIThresholdsAndTimers.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadv_monitor: Handle D-Bus proxy event of an ADV monitor
Miao-chen Chou [Sat, 12 Sep 2020 06:51:31 +0000 (23:51 -0700)]
adv_monitor: Handle D-Bus proxy event of an ADV monitor

This adds two handlers, one for adding and one for removing, of D-Bus proxy
events. The handler of property changes is set to NULL as intended,
since for simplicity no further changes on monitor's properties would
affect the ongoing monitoring.

The following test steps were performed with bluetoothctl.
- After registering the root path, expose two monitors and verify that
the proxy added event are received.
- Have two monitors added, unexpose the monitors, and verify that the
proxy removed events are received for those two monitors.
- Have two monitors added, unregister the monitors and verify that the
proxy removed events are received for those two monitors.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agogdbus: Make g_dbus_proxy_get_path take const proxy
Luiz Augusto von Dentz [Mon, 14 Sep 2020 19:43:09 +0000 (12:43 -0700)]
gdbus: Make g_dbus_proxy_get_path take const proxy

This makes g_dbus_proxy_get_path take const proxy since it doesn't
change anything on the proxy and avoid pointless casts.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadv_monitor: Handle D-Bus client ready events
Miao-chen Chou [Sat, 12 Sep 2020 06:51:29 +0000 (23:51 -0700)]
adv_monitor: Handle D-Bus client ready events

This adds a handler of client ready events. The handler replies to the
RegisterMonitor() method call.

The following tests were performed.
- Call RegisterMonitor() and expect to receive a return.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
2 years agoadv_monitor: Implement UnregisterMonitor()
Miao-chen Chou [Sat, 12 Sep 2020 06:51:27 +0000 (23:51 -0700)]
adv_monitor: Implement UnregisterMonitor()

This implements the UnregisterMonitor() method handler of ADV monitor
manager interface.

The following tests were performed.
- Issue a UnregisterMonitor() call with a nonexistent path and expect
org.bluez.Error.DoesNotExist as the return.
- Issue a UnregisterMonitor() call with a invalid path and expect
org.bluez.Error.InvalidArguments as the return.
- Issue RegisterMonitor() with a path, issue UnregisterMonitor() and
expect a successful method call return.

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