platform/upstream/bluez.git
5 years agogobex: Fix compiler warning from casting functions 94/204994/1
Marcel Holtmann [Wed, 23 May 2018 14:32:22 +0000 (16:32 +0200)]
gobex: Fix compiler warning from casting functions

Change-Id: Ia92479c68ee53ffdab6b1e5031311e0a8fee6cab
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Fix use of g_free 93/204993/1
Luiz Augusto von Dentz [Mon, 21 May 2018 11:25:50 +0000 (14:25 +0300)]
client: Fix use of g_free

g_free shall only be used with pointer allocated with g_* functions.

Change-Id: I3785e6d68878094d7384aa803eaac1f003a98087
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Fix use of g_free 92/204992/1
Luiz Augusto von Dentz [Mon, 21 May 2018 08:35:06 +0000 (11:35 +0300)]
client: Fix use of g_free

g_free shall only be used with pointer allocated with g_* functions.

Change-Id: I21104ef31d029e65544f5a087d2881c8088837dc
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient/gatt : Add support for Included Service 91/204991/1
Avichal Agarwal [Thu, 17 May 2018 17:01:16 +0000 (22:31 +0530)]
client/gatt : Add support for Included Service

included service support implemented at service registration

Change-Id: Ia2c17d43018085cc13f9c82c8d5a4da5cf2c33ae
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoFix possible invalid memory access 90/204990/1
Nagaraj D R [Fri, 18 May 2018 03:58:16 +0000 (09:28 +0530)]
Fix possible invalid memory access

Uninitialized data is read from local variable 'addr'

Change-Id: I9ad5b9be4a578f5450a08d0aa60a22c530dff8c5
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Define maximum attribute value length as initial value 89/204989/1
Grzegorz Kolodziejczyk [Wed, 16 May 2018 13:52:27 +0000 (15:52 +0200)]
client: Define maximum attribute value length as initial value

Initial registered attribute value is set as maximal attribute length.

Change-Id: Ic3ecd011e1a46348e6cee53a99a86158c004608b
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add missing duplicated string free 88/204988/1
Grzegorz Kolodziejczyk [Wed, 16 May 2018 13:52:26 +0000 (15:52 +0200)]
client: Add missing duplicated string free

This patch free duplicated strings in read, write attribute callbacks.

Change-Id: I07368a2fc03c66c125868490655a2e503aa816f2
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agosrc/profile: Updates HFP version to 1.7 87/204987/1
Ankit Navik [Thu, 10 May 2018 09:32:03 +0000 (15:02 +0530)]
src/profile: Updates HFP version to 1.7

Add changes to update HFP version to 0x0107 for HFP_HS_UUID and
HFP_AG_UUID. Ofono get this version from bluez and enable HFP 1.7
specific commands.

Change-Id: Ic4093b2e5f57c7a3a5028c906608ce4d90d46f73
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agotest/example-advertisement: add python3 support 86/204986/1
Hunt, Preston [Fri, 4 May 2018 14:59:18 +0000 (14:59 +0000)]
test/example-advertisement: add python3 support

This adds support for python3 to the existing script. The script will
now work with either python2 or python3.

Change-Id: I1c74860c1aaca0adafb99746772590a7e38b6fde
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoobexd: Fix memory leak when loading plugins 85/204985/1
Sahil Pai [Thu, 3 May 2018 12:05:38 +0000 (17:35 +0530)]
obexd: Fix memory leak when loading plugins

On failure to open plugin directory, memory allocated to 'patterns'
and 'excludes' is not being freed, and the following memory leak is
logged:

Direct leak of 28 byte(s) in 1 object(s) allocated from:
    #0 0xb6aa1c49 in malloc (/usr/lib/liblsan.so+0x9c49)
    #1 0xb6976e89 in g_malloc (/lib/libglib-2.0.so.0+0x3ae89)
    #2 0xb69886f1 in g_strsplit_set (/lib/libglib-2.0.so.0+0x4c6f1)
    #3 0xb6f82f3b in plugin_init (/usr/libexec/bluetooth/obexd+0x20f3b)
    #4 0xb6f70dc9 in main (/usr/libexec/bluetooth/obexd+0xedc9)

Change-Id: I9c930ba8fcd4cd04a25f4329ee02c5696c19cf39
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agotest/example-advertisement: Add Data property 84/204984/1
Luiz Augusto von Dentz [Wed, 2 May 2018 09:17:17 +0000 (12:17 +0300)]
test/example-advertisement: Add Data property

This adds Data property using TDS AD type:

@ MGMT Command: Add Advertising (0x003e) plen 59
        Instance: 1
        Flags: 0x00000001
          Switch into Connectable mode
        Duration: 0
        Timeout: 0
        Advertising data length: 29
        16-bit Service UUIDs (complete): 2 entries
          Heart Rate (0x180d)
          Battery Service (0x180f)
        Company: internal use (65535)
          Data: 0001020304
        Service Data (UUID 0x9999): 0001020304
        Transport Discovery Data
          Organization: Bluetooth SIG (0x01)
          Flags: 0x01
            Role: 0x01
              Seeker Only
            Transport Data Incomplete: False (0x00)
            Transport State: 0x00
              Off
          Length: 0
          Data:
        Scan response length: 19
        Name (complete): TestAdvertisement

Change-Id: If00bfc0f9208caf5ad8c9d48c123c4c414523265
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Make info command print Advertising{Flags,Data} 83/204983/1
Luiz Augusto von Dentz [Fri, 20 Apr 2018 12:57:46 +0000 (15:57 +0300)]
client: Make info command print Advertising{Flags,Data}

Change-Id: Ib2be54fdf70ef8ff8f290a4d480e8c84a4276039
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add support for setting advertising Data property 82/204982/1
Luiz Augusto von Dentz [Wed, 18 Apr 2018 10:11:10 +0000 (13:11 +0300)]
client: Add support for setting advertising Data property

This adds data command to advertise menu which can be used to set
an arbitrary/profile specific advertising type and data:

[bluetooth]# data 0x26 0x01 0x01 0x00

Change-Id: I8a5fdbf2d098366aedab00a8c137036f8ec5ae7e
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agomonitor: Add support for Transport Discovery AD 81/204981/1
Luiz Augusto von Dentz [Tue, 17 Apr 2018 13:57:47 +0000 (16:57 +0300)]
monitor: Add support for Transport Discovery AD

This adds support for decoding Transport Discovery Data:

@ MGMT Command: Add Advertising (0x003e) plen 16
        Instance: 1
        Flags: 0x00000001
          Switch into Connectable mode
        Duration: 0
        Timeout: 0
        Advertising data length: 5
        Transport Discovery Data
          Organization: Bluetooth SIG (0x01)
          Flags: 0x01
            Role: 0x01
              Seeker Only
            Transport Data Incomplete: False (0x00)
            Transport State: 0x00
              Off
          Length: 0
          Data:
        Scan response length: 0

Change-Id: Ib4df36ec7bc44eef963c3b6854f03c1ac6010272
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadvertising: Add Data implementation 80/204980/1
Luiz Augusto von Dentz [Tue, 17 Apr 2018 13:56:18 +0000 (16:56 +0300)]
advertising: Add Data implementation

This adds the support for Data property.

Change-Id: I1e2f7ad6c05b9e470e49c30563eb5573a4453e90
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodoc/advertising-api: Add Data property 79/204979/1
Luiz Augusto von Dentz [Tue, 17 Apr 2018 13:51:05 +0000 (16:51 +0300)]
doc/advertising-api: Add Data property

Data property can be used to add advertising data with arbitrary/profile
specific type.

Change-Id: I8904912649df7720c7ce631a207f309290097795
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodevice: Add implementation of AdvertisingData 78/204978/1
Luiz Augusto von Dentz [Tue, 17 Apr 2018 13:26:10 +0000 (16:26 +0300)]
device: Add implementation of AdvertisingData

This adds the implementation of AdvertisingData property:

[CHG] Device 00:1B:DC:07:31:88 AdvertisingData Key: 0x26
[CHG] Device 00:1B:DC:07:31:88 AdvertisingData Value:
  01 01 00                                         ...

Change-Id: Idb4d29968e84d10c2643a1e8bc0dc6c981acd716
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodoc/device-api: Add AdvertisingData property 77/204977/1
Luiz Augusto von Dentz [Tue, 17 Apr 2018 13:15:11 +0000 (16:15 +0300)]
doc/device-api: Add AdvertisingData property

This adds AdvertisingData which exposes data being advertised which is
may be useful for profiles not handled by bluetoothd.

Change-Id: I50623393e2beba866f371a46c14306c2bd0e9ac1
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/ad: Add support for arbritary type 76/204976/1
Luiz Augusto von Dentz [Tue, 17 Apr 2018 13:07:56 +0000 (16:07 +0300)]
shared/ad: Add support for arbritary type

This adds APIs to include data of arbritary type as long as it is not
of a type which blacklisted due to being handled already or it is
considered to safe to be set by an application.

Change-Id: Ica6e25c20719c98c81858751d4af23687abb9f66
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add support for optional gatt write offset parameter 75/204975/1
Grzegorz Kolodziejczyk [Thu, 26 Apr 2018 12:32:00 +0000 (14:32 +0200)]
client: Add support for optional gatt write offset parameter

This patch extends missing optional gatt write offset parameter.

Change-Id: I192723597acb784ce6f86d3a7b36ca99d6b4cedf
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add support for optional gatt read offset parameter 74/204974/1
Grzegorz Kolodziejczyk [Thu, 26 Apr 2018 12:31:59 +0000 (14:31 +0200)]
client: Add support for optional gatt read offset parameter

This patch extends missing optional gatt read offset parameter.

Change-Id: I74c8bf0ed060310a9d1c87f4d13e81e1f348c510
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Fix writing attribute values 73/204973/1
Grzegorz Kolodziejczyk [Thu, 26 Apr 2018 12:31:58 +0000 (14:31 +0200)]
client: Fix writing attribute values

Attribute values is not copied with dbus_message_iter_get_fixed_array,
so gatt write callback needs to replace old value with reallocation and
copy.

Change-Id: I7a22c69f50d289d2d4c8430e938ec2516071d7cc
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadapter: Fix accessing NULL adv_manager 72/204972/1
Szymon Janc [Fri, 20 Apr 2018 10:45:05 +0000 (12:45 +0200)]
adapter: Fix accessing NULL adv_manager

adv_manager might be NULL also if BR/EDR only mdoe is set in main.conf
or if btd_adv_manager_new failed so checking for LE in supported
settings is not enough. This also makes btd_adv_manager_refresh
consistent with other adv_manager API regarding passing NULL manager
as function parameter.

Change-Id: I5130015896a413de89150d2e669f473e3526c6aa
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/shell: Fix artifacts related to prompt 71/204971/1
Luiz Augusto von Dentz [Fri, 13 Apr 2018 14:42:40 +0000 (17:42 +0300)]
shared/shell: Fix artifacts related to prompt

Both bt_shell_prompt_input and bt_shell_input could cause the prompt to
be printed incorrectly, so they now rely on bt_shell_printf which
properly check if input and prompt shall be saved/restored.

Change-Id: Idf305cd6c29515aaca28a240103d5b08bfe3dc52
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Fix crash with BR/EDR only adapter 70/204970/1
Szymon Janc [Wed, 4 Apr 2018 07:28:56 +0000 (09:28 +0200)]
gatt: Fix crash with BR/EDR only adapter

adapter->database can be NULL if controller is BR/EDR only or LE was
disabled. Make btd_gatt_database_restore_svc_chng_ccc accept NULL
pointer and silently ignore it similiar to rest of btd_gatt_database
API.

Invalid read of size 8
   at 0x164DCB: btd_gatt_database_restore_svc_chng_ccc (src/bluez-git/src/bluetoothd)
   by 0x17B70F: read_info_complete (src/bluez-git/src/bluetoothd)
   by 0x1A7E58: request_complete (src/bluez-git/src/bluetoothd)
   by 0x1A89AD: can_read_data (src/bluez-git/src/bluetoothd)
   by 0x1B5752: watch_callback (src/bluez-git/src/bluetoothd)
   by 0x4E852C5: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.5600.0)
   by 0x4E856A0: ??? (in /usr/lib/libglib-2.0.so.0.5600.0)
   by 0x4E859D1: g_main_loop_run (in /usr/lib/libglib-2.0.so.0.5600.0)
   by 0x125058: main (src/bluez-git/src/bluetoothd)
 Address 0x40 is not stack'd, malloc'd or (recently) free'd

Change-Id: Ibec4e5ced0c2218d96499c47afcd2863484212eb
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Add support for storing Service Changed CCC value 69/204969/1
Szymon Janc [Wed, 28 Mar 2018 10:10:55 +0000 (12:10 +0200)]
gatt: Add support for storing Service Changed CCC value

This adds support for storing CCC value of Service Changed
characteristic. Once bluetoothd is restart stored values are read
and any device subscribed to indications will receive Service Changed
indication with 0x00010-0xffff value. This is to invalidate any
non-core services since there is no way to verify if applications
will register their services in same order (or at all).

This fix accessing invalid handles by stacks that rely only on Service
Changed indication for rediscovery ie. Apple iOS.

Change-Id: I742bb2520a02d73aa69ca0ab5ac8c885e701c498
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadapter: Don't refresh adv_manager for non-LE devices 68/204968/1
antoine.belvire@laposte.net [Tue, 27 Mar 2018 18:30:26 +0000 (20:30 +0200)]
adapter: Don't refresh adv_manager for non-LE devices

btd_adv_manager_refresh is called upon MGMT_SETTING_DISCOVERABLE setting change
but as only LE adapters have an adv_manager, this leads to segmentation fault
for non-LE devices:

0  btd_adv_manager_refresh (manager=0x0) at src/advertising.c:1176
1  0x0000556fe45fcb02 in settings_changed (settings=<optimized out>,
    adapter=0x556fe53f7c70) at src/adapter.c:543
2  new_settings_callback (index=<optimized out>, length=<optimized out>,
    param=<optimized out>, user_data=0x556fe53f7c70) at src/adapter.c:573
3  0x0000556fe462c278 in request_complete (mgmt=mgmt@entry=0x556fe53f20c0,
    status=<optimized out>, opcode=opcode@entry=7, index=index@entry=0,
    length=length@entry=4, param=0x556fe53eb5f9) at src/shared/mgmt.c:261
4  0x0000556fe462cd9d in can_read_data (io=<optimized out>,
    user_data=0x556fe53f20c0) at src/shared/mgmt.c:353
5  0x0000556fe46396e3 in watch_callback (channel=<optimized out>,
    cond=<optimized out>, user_data=<optimized out>)
    at src/shared/io-glib.c:170
6  0x00007fe351c980e5 in g_main_context_dispatch ()
   from /usr/lib64/libglib-2.0.so.0
7  0x00007fe351c984b0 in ?? () from /usr/lib64/libglib-2.0.so.0
8  0x00007fe351c987c2 in g_main_loop_run () from /usr/lib64/libglib-2.0.so.0
9  0x0000556fe45abc75 in main (argc=<optimized out>, argv=<optimized out>)
    at src/main.c:770

This commit prevents the call to btd_adv_manager_refresh for non-LE devices.

Change-Id: Ibc9d6631cf5f3918fc4078fc39b87d54c7643497
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Attempt to convert the device path to address 67/204967/1
Luiz Augusto von Dentz [Mon, 26 Mar 2018 12:43:06 +0000 (15:43 +0300)]
client: Attempt to convert the device path to address

Printing the object path is not only long but it also may change.

Change-Id: I9c67ba57485afb0a87b30ee8173eab1976e4127a
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add envs for proxies 66/204966/1
Luiz Augusto von Dentz [Mon, 26 Mar 2018 12:09:05 +0000 (15:09 +0300)]
client: Add envs for proxies

This adds envs for device and adapter proxies found so other files are
able to access them.

Change-Id: I3e2c0911a2d44224f6046399d62ca4999e579e89
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Fix checking for paired flag instead of bonded 65/204965/1
Luiz Augusto von Dentz [Tue, 27 Mar 2018 15:38:20 +0000 (18:38 +0300)]
gatt: Fix checking for paired flag instead of bonded

Device state should remain valid for devices that are bonded/stored not
only paired.

Change-Id: I7b87d8f75a18c040b52cc6210e468d984b71938c
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodevice: Fix storing GATT attributes 64/204964/1
Szymon Janc [Mon, 26 Mar 2018 14:11:53 +0000 (16:11 +0200)]
device: Fix storing GATT attributes

This fix two issues:
 - not storing attributes after pairing if device is using RPA
 - storing attributes for temporary device if it is using static
   or public address

Change-Id: I06cfed13e4c347a15138494cfae0be65e283ae30
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodevice: Change storage warning to debug messages 63/204963/1
Szymon Janc [Mon, 26 Mar 2018 14:11:52 +0000 (16:11 +0200)]
device: Change storage warning to debug messages

It is normal for device to have private address so there is no reason
to issue warning message when not storing data for it.

Change-Id: I9c432f6513c5e581fdc8f60f951a4639fcb6b41b
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agotools/bluetooth-player: Return exit status for non-interactive 62/204962/1
ERAMOTO Masaya [Mon, 26 Mar 2018 08:31:04 +0000 (17:31 +0900)]
tools/bluetooth-player: Return exit status for non-interactive

Change-Id: I654ed7a5e3bee27a057047c0bed1567e4b4b4866
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Return exit status for non-interactive 61/204961/1
ERAMOTO Masaya [Mon, 26 Mar 2018 08:31:02 +0000 (17:31 +0900)]
client: Return exit status for non-interactive

Change-Id: Icf727225fca0f15fb3c14061181a825133b9d175
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoAdd support for requiring min key size for access GATT characteristics 60/204960/1
Szymon Janc [Fri, 23 Mar 2018 13:08:21 +0000 (14:08 +0100)]
Add support for requiring min key size for access GATT characteristics

This allows to configure bluetoothd to require minimum encryption key
size when accessing GATT server characteristics. It is a global
configuration option affecting whole GATT database.

Change-Id: Ibec567f17447d35421f016c5e0021ef49aa713ef
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Parse all options passed for GATT attribute 59/204959/1
Luiz Augusto von Dentz [Fri, 23 Mar 2018 13:32:12 +0000 (15:32 +0200)]
client: Parse all options passed for GATT attribute

This parses the options given to Acquire*, WriteValue and ReadValue.

Change-Id: If324abcc5b02f4e36137998dc4c8d4bd77b43e8b
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Send device and link options with AcquireNotify 58/204958/1
Luiz Augusto von Dentz [Fri, 23 Mar 2018 09:16:03 +0000 (11:16 +0200)]
gatt: Send device and link options with AcquireNotify

This adds the device and link options to AcquireNotify as mentioned in
the documentation.

Change-Id: I65ba0bc1ecc8a4c4adf90b7bc1ba515b061ee4fd
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodoc/gatt-api: Update documentation regarding link option 57/204957/1
Luiz Augusto von Dentz [Fri, 23 Mar 2018 09:23:56 +0000 (11:23 +0200)]
doc/gatt-api: Update documentation regarding link option

This reflects what the code has already doing so any server operation which
requires the device option shall also get the link type as well.

Change-Id: Ic5f78954160ec80e053a8b83b169ea918f2ac38e
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Fail to register service with invalid Includes property 56/204956/1
Szymon Janc [Thu, 22 Mar 2018 20:07:55 +0000 (21:07 +0100)]
gatt: Fail to register service with invalid Includes property

This is optional property but if it is present it must be of
proper type.

Change-Id: I0a144bc7ce0e7b55a5f8ba0f94d7608397491dfa
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-client: Fix tracking current service during discovery 55/204955/1
Andrzej Kaczmarek [Thu, 22 Mar 2018 15:21:01 +0000 (16:21 +0100)]
shared/gatt-client: Fix tracking current service during discovery

We should mark service as completed before trying to insert another
characteristic - in case inserting characteristic for new service
fails, previous one won't be discarded.

Change-Id: I14b6af270aebc358a88ffd2419c39573a1728b31
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-client: Fix discovery of discontinuous database 54/204954/1
Andrzej Kaczmarek [Thu, 22 Mar 2018 15:21:00 +0000 (16:21 +0100)]
shared/gatt-client: Fix discovery of discontinuous database

If local cache of peer's database has gaps where new services appear
after reconnection, GATT client will attempt to discover all included
services and characteristics definitions between starting handle of
first service and end handle of last service. This means the result
will contain also attributes which are already present in active
services in local database and thus attempting to add them again will
fail.

To fix this, instead of discovering whole range we'll only discover
ranges for missing services - starting with included services then
characteristics. To optimize this process we'll merge ranges of
adjacent services and any empty spaces in between - the result is
basically set of ranges without any known service. In most cases this
works the same or very similar to current implementation.

This issue can sometimes be observed with iOS devices as ANCS and CTS
services may not be available all the time.

Change-Id: I2b73f0204f2e3cb7177b97799182f608156138ef
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-client: Fix removing services from pending list 53/204953/1
Andrzej Kaczmarek [Thu, 22 Mar 2018 15:20:59 +0000 (16:20 +0100)]
shared/gatt-client: Fix removing services from pending list

We should remove from pending list service which was just processed,
not the one that has just started being processed.

Change-Id: I045bc1964f0951f6fae4d116acb973d70161a801
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Fix stay on error handling in non-interactive 52/204952/1
ERAMOTO Masaya [Mon, 19 Mar 2018 08:40:48 +0000 (17:40 +0900)]
client: Fix stay on error handling in non-interactive

Returns the FAILURE status since there is no meaning of stay in
non-interactive mode when executing some commands with an invalid
argument or with no controller. Also returns with the SUCCESS status
when getting a scan filtering value or disconnecting a non-default
device.

Change-Id: Iac437afcd04648ba9bb4580201c70e1e8396a329
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Properly handle service changes when offline 51/204951/1
Luiz Augusto von Dentz [Mon, 19 Mar 2018 12:44:27 +0000 (14:44 +0200)]
gatt: Properly handle service changes when offline

If remote peer is disconnected the indication shall be cached so when
the peer connects again it receives the changes.

Change-Id: Ic887ae4f56fdd80efa998e12f6d42f018ad7a6b3
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Add confirmation callback 50/204950/1
Luiz Augusto von Dentz [Mon, 19 Mar 2018 12:44:26 +0000 (14:44 +0200)]
gatt: Add confirmation callback

This replaces indicate flag with confirmation callback to enable
setting custom callback if necessary.

Change-Id: I2378e4dc42a1a241eb79fe7f947a5ab20bf5c5e0
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodoc/gatt-api: Includes shall not be mandatory 49/204949/1
Luiz Augusto von Dentz [Thu, 22 Mar 2018 09:19:14 +0000 (11:19 +0200)]
doc/gatt-api: Includes shall not be mandatory

It is perfectly fine to have a service without any Includes.

Change-Id: Ibc8746d3a961d0900fa90c7b0be04e2a10b64aca
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agobuild: Fix make distcheck 48/204948/1
Luiz Augusto von Dentz [Thu, 22 Mar 2018 09:16:26 +0000 (11:16 +0200)]
build: Fix make distcheck

Change-Id: I2ac28241236a7367f63610ae040487c9fce86099
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agobuild: Fix not disabling obexd when given --disable-obex 47/204947/1
Luiz Augusto von Dentz [Wed, 21 Mar 2018 16:52:55 +0000 (18:52 +0200)]
build: Fix not disabling obexd when given --disable-obex

--disable-obex shall disable building obexd daemon.

Change-Id: I978627b477f7ec25236e49ab1f6ac43263abf497
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add authorization request handling for attribute operations 46/204946/1
Grzegorz Kolodziejczyk [Tue, 20 Mar 2018 14:05:19 +0000 (15:05 +0100)]
client: Add authorization request handling for attribute operations

This patch adds optional authorization request for reading, writing of
gatt database attributes.

Change-Id: Iffeabaa1ebd44b8fbf521194f603b2836e0042eb
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Update read callbacks with invalid offset error handlers 45/204945/1
Grzegorz Kolodziejczyk [Tue, 20 Mar 2018 14:05:18 +0000 (15:05 +0100)]
client: Update read callbacks with invalid offset error handlers

This patch adds invalid offset handlers to read callbacks of attributes.

Change-Id: I7c9184e0f0caf0e43c7b37eeaa40a6a12a1fd883
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt: Add org.bluez.Error.InvalidOffset for long read procedure 44/204944/1
Grzegorz Kolodziejczyk [Tue, 20 Mar 2018 14:05:17 +0000 (15:05 +0100)]
gatt: Add org.bluez.Error.InvalidOffset for long read procedure

This patch adds handling of invalid offset error for gatt database in
case if offset in read blob would be invalid.

"The Read Blob Request is repeated until the Read Blob Response’s Part
Attribute Value parameter is zero or an Error Response is sent by the server
with the Error Code set to Invalid Offset." Bluetooth Core 5.0, 4.12.2

"If the prepare Value Offset is greater than the current length of the attribute
value then all pending prepare write values shall be discarded for this client,
the queue shall be cleared and then an Error Response shall be sent with the
«Invalid Offset»." Bluetooth Core 5.0, 3.4.6.3

Change-Id: I678ca6984bde4502a3b325fd1822d21d98e6a1a9
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Fix reading long values 43/204943/1
Grzegorz Kolodziejczyk [Tue, 20 Mar 2018 14:05:16 +0000 (15:05 +0100)]
client: Fix reading long values

While value has more than single MTU can carry long read procedure will
be triggered. In such cases offset need to bo considered while getting
value from storage.

Change-Id: Ide2d67c7562a83f317e699627a7c22ba058c47f8
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agogatt-database: Add support for Included service 42/204942/1
Avichal Agarwal [Mon, 19 Mar 2018 12:02:26 +0000 (17:32 +0530)]
gatt-database: Add support for Included service

Parse Includes property and register any object path found as included
service.

Change-Id: Id0a311b31bebf6f307a621ce3d66858f209b25f5
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodoc/gatt-api.txt: Add support for Included Service 41/204941/1
Avichal Agarwal [Tue, 20 Mar 2018 05:09:41 +0000 (10:39 +0530)]
doc/gatt-api.txt: Add support for Included Service

included service support implemented at server side

Change-Id: I1577d5a1a5cb3d469bff2bf65a918740135ddcb5
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-client: Fix attempting to discovery with handle 0 40/204940/1
Luiz Augusto von Dentz [Wed, 14 Mar 2018 12:51:29 +0000 (14:51 +0200)]
shared/gatt-client: Fix attempting to discovery with handle 0

If a service was removed an no other service was added it may happen
that pending_svc has not empty but first_svc and last_svc has not been
set causing the following request:

< ACL Data TX: Handle 76 flags 0x00 dlen 11
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0000-0x0000
        Attribute type: Include (0x2802)

Change-Id: Id628ff103fee0abfcb961aaa4e0032737b0c805c
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-client: Fix secondary service discovery 39/204939/1
Luiz Augusto von Dentz [Wed, 14 Mar 2018 12:46:05 +0000 (14:46 +0200)]
shared/gatt-client: Fix secondary service discovery

If the error returned is either BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND or
BT_ATT_ERROR_UNSUPPORTED_GROUP_TYPE the discovery shall be marked as
successful and no error shall be printed.

Change-Id: I3caf7be943e0457137732ee4427a38b914c7115f
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-client: Omit valid errors for primary discovery 38/204938/1
Luiz Augusto von Dentz [Wed, 14 Mar 2018 12:56:30 +0000 (14:56 +0200)]
shared/gatt-client: Omit valid errors for primary discovery

BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND shall not cause anything to be printed
since it is a valid response and just mark the end of primary discovery.

Change-Id: Ideebfd3b7646f5082f07edb0ae03c74272f23ec5
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-server: Fix crash on read multiple 37/204937/1
Szymon Janc [Tue, 13 Mar 2018 07:47:27 +0000 (08:47 +0100)]
shared/gatt-server: Fix crash on read multiple

When read multiple includes external characteristic, call to
gatt_db_attribute_read's complete callback is asynchronous.

Fix following crash:
Use of uninitialised value of size 8
   at 0x49718A: read_multiple_complete_cb (gatt-server.c:994)
   by 0x498999: pending_read_result (gatt-db.c:136)
   by 0x49A84B: gatt_db_attribute_read_result (gatt-db.c:1787)
   by 0x451F4C: read_reply_cb (gatt-database.c:1712)
   by 0x48B221: method_call_reply (client.c:972)
   by 0x53AB601: ??? (in /usr/lib64/libdbus-1.so.3.19.3)
   by 0x53AEF7E: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.19.3)
   by 0x486FEF: message_dispatch (mainloop.c:72)
   by 0x50CB576: ??? (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x50CEB76: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x50CEF1F: ??? (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x50CF231: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.5400.3)

Invalid read of size 8
   at 0x49718A: read_multiple_complete_cb (gatt-server.c:994)
   by 0x498999: pending_read_result (gatt-db.c:136)
   by 0x49A84B: gatt_db_attribute_read_result (gatt-db.c:1787)
   by 0x451F4C: read_reply_cb (gatt-database.c:1712)
   by 0x48B221: method_call_reply (client.c:972)
   by 0x53AB601: ??? (in /usr/lib64/libdbus-1.so.3.19.3)
   by 0x53AEF7E: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.19.3)
   by 0x486FEF: message_dispatch (mainloop.c:72)
   by 0x50CB576: ??? (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x50CEB76: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x50CEF1F: ??? (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x50CF231: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.5400.3)
 Address 0x8 is not stack'd, malloc'd or (recently) free'd

Change-Id: Id0aca942b2c5229e798c2d4fb9d9d8c3ac86cdde
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoRelease 5.49 36/204936/1
Marcel Holtmann [Sat, 10 Mar 2018 15:35:21 +0000 (16:35 +0100)]
Release 5.49

Change-Id: Icf519908cc6e44b9e760ac7a904052d7a39bcffd
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoavctp: Fix crash when disconnecting 35/204935/1
Luiz Augusto von Dentz [Fri, 9 Mar 2018 09:26:04 +0000 (11:26 +0200)]
avctp: Fix crash when disconnecting

When disconnecting the channel queue shall not be destroyed before
freeeing all requests including those that already have been processed
otherwise the following crash may happen:

4 errors in context 2 of 103:
Invalid read of size 4
   at 0x12A5C2: control_req_destroy (avctp.c:762)
   by 0x12A539: pending_destroy (avctp.c:517)
   by 0x48A0D48: g_slist_foreach (in /usr/lib/libglib-2.0.so.0.3600.0)
   by 0x12A77B: avctp_channel_destroy (avctp.c:553)
   by 0x12A801: avctp_disconnected (avctp.c:570)
   by 0x12A0F1: control_disconnect (control.c:134)
   by 0x1306B9: avrcp_disconnect (avrcp.c:4471)
   by 0x17DAE9: btd_service_disconnect (service.c:307)
   by 0x18437D: dev_disconn_service (device.c:1405)
   by 0x48A0D48: g_slist_foreach (in /usr/lib/libglib-2.0.so.0.3600.0)
   by 0x187D87: device_request_disconnect (device.c:1437)
   by 0x187EC6: dev_disconnect (device.c:1522)
 Address 0x4fde068 is 0 bytes inside a block of size 16 free'd
   at 0x48252B3: free (vg_replace_malloc.c:446)
   by 0x4888172: g_free (in /usr/lib/libglib-2.0.so.0.3600.0)
   by 0x12AB64: avctp_queue_destroy (avctp.c:537)
   by 0x48A0D48: g_slist_foreach (in /usr/lib/libglib-2.0.so.0.3600.0)
   by 0x48A0D91: g_slist_free_full (in /usr/lib/libglib-2.0.so.0.3600.0)
   by 0x12A75E: avctp_channel_destroy (avctp.c:552)
   by 0x12A801: avctp_disconnected (avctp.c:570)
   by 0x12A0F1: control_disconnect (control.c:134)
   by 0x1306B9: avrcp_disconnect (avrcp.c:4471)
   by 0x17DAE9: btd_service_disconnect (service.c:307)
   by 0x18437D: dev_disconn_service (device.c:1405)
   by 0x48A0D48: g_slist_foreach (in /usr/lib/libglib-2.0.so.0.3600.0)

Change-Id: Ida52cd46ad8d1754e8afa84ab52f7e84b68f1065
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodevice: Fix missing Paired property change on non-bonded device 34/204934/1
Szymon Janc [Tue, 6 Mar 2018 14:15:14 +0000 (15:15 +0100)]
device: Fix missing Paired property change on non-bonded device

If device is paired but not bonded than Paired property should be
also updated when device is disconnected.

Change-Id: Ic4b49d25692dd09807196444f20be76212b96b30
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoFixed the session list for obex 33/204933/1
Amit Purwar [Wed, 10 Apr 2019 09:38:02 +0000 (15:08 +0530)]
Fixed the session list for obex

Change-Id: Ic86fba8e3089b0d29c80260f9335ecda7e64c62d
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoFix storage for adapters without public address 32/204932/1
Szymon Janc [Tue, 6 Mar 2018 13:28:07 +0000 (14:28 +0100)]
Fix storage for adapters without public address

Since those have adapter folder prefixed with "static-" this needs
to be taken into account when storing data.

Change-Id: I3a444ac00c36ee064538629284a466633a01e1e3
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadvertising: Fix crash when if client invalidate property 31/204931/1
Luiz Augusto von Dentz [Fri, 19 Jan 2018 13:37:07 +0000 (11:37 -0200)]
advertising: Fix crash when if client invalidate property

If a property is invalidated the iter is set to NULL which should be
checked and properly reset.

Change-Id: I4981b56b9d8b68bb589d0ced2f429c71441a7ce8
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadvertising: Fix creating another mgmt instance 30/204930/1
Luiz Augusto von Dentz [Wed, 28 Feb 2018 12:09:08 +0000 (14:09 +0200)]
advertising: Fix creating another mgmt instance

adapter already instanciate a instance of mgmt so just reuse that
instead of creating a new one.

Change-Id: I0a1fd65ff2d6f6cbae5783a25f1adbd547992432
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoRemove obsolete Debian notes from HACKING 29/204929/1
David Frey [Mon, 5 Mar 2018 20:01:16 +0000 (12:01 -0800)]
Remove obsolete Debian notes from HACKING

The HACKING document says that Debian's automake version doesn't satisfy
the automake >= 1.10 requirement, but this is no longer true. The
automake version in Debian 8 (oldstable) is 1.14 and the version in
Debian 9 (stable) is 1.15.

Change-Id: I2428584f070a52d6aac2b8b766f9a9793b018f91
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodevice: Fix bearer selection with single mode controller 28/204928/1
Szymon Janc [Mon, 5 Mar 2018 16:16:35 +0000 (17:16 +0100)]
device: Fix bearer selection with single mode controller

If remote device is dual mode and advertises without "BR/EDR flag
not supported" set than device is marked as supporting BR/EDR
even if controller is doing LE only. This results in bluetoothd
trying to connect over BR/EDR since this is prefered transport
if none is connected.

Fix this by checking if adapter supports specified technology
before doing heuristic transport selection.

Change-Id: Icb51c40a4327759817c637f90821c0bea866edc4
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Fix lines going beyond 80 columns 27/204927/1
Luiz Augusto von Dentz [Thu, 1 Mar 2018 09:11:17 +0000 (11:11 +0200)]
client: Fix lines going beyond 80 columns

Change-Id: I31dfc94aa5314362a7d5b18aeb8ecb4ebbe11a71
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodbus-common: Remove unused functions 26/204926/1
ERAMOTO Masaya [Thu, 1 Mar 2018 04:27:42 +0000 (13:27 +0900)]
dbus-common: Remove unused functions

Change-Id: I580a497600bbe7c2521f5303fdbd2069b60a558b
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agounit/test-gdbus-client: Use g_dbus_dict_append_entry() 25/204925/1
ERAMOTO Masaya [Thu, 1 Mar 2018 04:27:38 +0000 (13:27 +0900)]
unit/test-gdbus-client: Use g_dbus_dict_append_entry()

Change-Id: I63b356bd82ffee5f40ba4b53756d384874c7ee59
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Use g_dbus_dict_append_*() 24/204924/1
ERAMOTO Masaya [Thu, 1 Mar 2018 04:27:21 +0000 (13:27 +0900)]
client: Use g_dbus_dict_append_*()

Change-Id: Ifeeed4631fc3408ef3225c6356cabb7179c3d472
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoobexd: Remove unused source/header files for dbus 23/204923/1
ERAMOTO Masaya [Thu, 1 Mar 2018 04:27:16 +0000 (13:27 +0900)]
obexd: Remove unused source/header files for dbus

Due to using g_dbus_emit_property_changed() and g_dbus_get_properties(),
obex_dbus_signal_property_changed() is unused since commit 96063756
("obex-client: Rename org.bluez.obex.Transfer to Transfer1"), and
OBC_PROPERTIES_ARRAY_SIGNATURE macro is unused since commit 3eadc034
("obex-client: Make use of g_dbus_get_properties to get transfer properties").

Change-Id: If237f40dea006c9b96e16dc3e446dff80e591aed
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoobexd: Use g_dbus_dict_append_entry() 22/204922/1
ERAMOTO Masaya [Thu, 1 Mar 2018 04:27:10 +0000 (13:27 +0900)]
obexd: Use g_dbus_dict_append_entry()

Change-Id: I7119b0a9dbf1d5491fe869e59efca3ab0e18d313
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Quit when done with command 21/204921/1
Luiz Augusto von Dentz [Fri, 23 Feb 2018 14:34:58 +0000 (16:34 +0200)]
client: Quit when done with command

This ensures that the commands don't stay hanging since bt_shell no
longer quits immediatelly after executing a command.

Change-Id: I69dd2faa6c1c55039d7d19d2e4effcf2cd4919d7
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/btp: Fix return type in btp_send 20/204920/1
Szymon Janc [Fri, 23 Feb 2018 13:40:09 +0000 (14:40 +0100)]
shared/btp: Fix return type in btp_send

This function returns bool.

Change-Id: Ie7d30dcb11a2e400a43e7f29ae92006caee1366e
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/btp: Allow to call btp_send without valid btp 19/204919/1
Szymon Janc [Fri, 23 Feb 2018 13:40:10 +0000 (14:40 +0100)]
shared/btp: Allow to call btp_send without valid btp

This allows to unconditionally call btp_send from code that generates
events eg when mapping those from D-Bus events.

Change-Id: Id47fb80d7116d0fd8ac4f48567ee115ca43c3e89
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Don't auto register agent on non-interactive mode 18/204918/1
Luiz Augusto von Dentz [Wed, 21 Feb 2018 11:02:42 +0000 (13:02 +0200)]
client: Don't auto register agent on non-interactive mode

There is no use to register an agent when on non-interactive mode.

Change-Id: Idbbac0630b0ea901cceeb710bdae32a4e03fbe45
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadapter: Add ConnectDevice method 17/204917/1
Szymon Janc [Mon, 19 Feb 2018 13:40:19 +0000 (14:40 +0100)]
adapter: Add ConnectDevice method

This allows to connect device without doing general discovery. This is
needed for some of qualification tests where there is no general
discovery upfront and we need to do connection to device with provided
address.

Another usecase is for scenario where scanning happen on one controller
but connection handling on another.

New device object is announced only if physical connection was
successful. On success this method returns path to created device
object. After ConnectProfile return bluetoothd continue with
services discovery and profile connection.

This patch implements bare minimum properties needed for connection -
address and address type. If needed eg. for non-NFC based OOB it could
be extended with more options.

Change-Id: I08bbd114ac9c46bf377879694175c58d0e8fea02
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/shell: Fix history display with no saved prompt 16/204916/1
Szymon Janc [Tue, 20 Feb 2018 11:09:40 +0000 (12:09 +0100)]
shared/shell: Fix history display with no saved prompt

Prompt needs to be restored always since default prompt is provided.
This fix issues with history line being clobbered by offset of prompt
length.

[bluetooth]# connect 9C:5C:F9:AB:C5:82
Attempting to connect to 9C:5C:F9:AB:C5:82
[bluetooth]# disconnect 9C:5C:F9:AB:C5:82
Attempting to disconnect from 9C:5C:F9:AB:C5:82
Failed to connect: org.bluez.Error.Failed
Successful disconnected
[bluetooth]# discoverable on
Changing discoverable on succeeded
[CHG] Controller 5C:E0:C5:34:AE:1C Discoverable: yes
[bluetooth]# disconnect discoverable on

after pressing up-down
[bluetooth]# disconnect dis5C:F9:AB:C5:82

Change-Id: I83d4d5e15cb67f51256359d7e73c19a840c85a34
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/io: Don't process HUP cond before others 15/204915/1
Luiz Augusto von Dentz [Tue, 20 Feb 2018 09:11:26 +0000 (11:11 +0200)]
shared/io: Don't process HUP cond before others

When a HUP happens there maybe data left to be processed so the
disconnect handler shall be called last.

Change-Id: Ic4a4ec535cc628f01118c5ade20d5e36bc25671a
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agodevice: Fix probing service twice 14/204914/1
Luiz Augusto von Dentz [Mon, 19 Feb 2018 12:51:50 +0000 (14:51 +0200)]
device: Fix probing service twice

If there is already a service for a given profile there is no point in
probing it again.

Change-Id: I932148183acaf832763e7cc9e419312957d91d72
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadapter: Fix not clearing connectable setting on power off 13/204913/1
Szymon Janc [Mon, 19 Feb 2018 12:43:35 +0000 (13:43 +0100)]
adapter: Fix not clearing connectable setting on power off

When kernel control of connectable is used daemon doesn't enable
connectable setting unless discoverable. Both settings are permanent
over power toggle unless discoverable timeout was set. In that case
discoverable flag is cleared by kernel on power off. This leads to
connectable flag being left enabled when toggling power on discoverable
adapter with timeout set.

This has some implications on system behaviour:
 - accepting connection from unknown devices
 - not being able to advertise as broadcaster

Since kernel doens't know the reason for enabling connectable flag (and
thus if disable if on power off) this needs to be handled in bluetoothd.

Change-Id: Id454bbd69027affc08a9a11bccfd90e0a2da12a9
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Add clear command for advertise 12/204912/1
ERAMOTO Masaya [Fri, 16 Feb 2018 05:51:48 +0000 (14:51 +0900)]
client: Add clear command for advertise

Adds the clear command to advertise-related commands to clear individual
fields or whole of advertise configuration.

Change-Id: I947e47a73830cfc28d370e1c5f3a47d3cf6fb254
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Introduce ad_disable_{uuids,service,manufacturer} 11/204911/1
ERAMOTO Masaya [Fri, 16 Feb 2018 05:51:37 +0000 (14:51 +0900)]
client: Introduce ad_disable_{uuids,service,manufacturer}

Change-Id: Id0555a1433d234f42dd1d0faa08f3274b30a1cc8
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Introduce data_clear() calling ->clear() 10/204910/1
ERAMOTO Masaya [Fri, 16 Feb 2018 05:51:29 +0000 (14:51 +0900)]
client: Introduce data_clear() calling ->clear()

Change-Id: I96e980ea20bffa99096c367db92478f6aea1ab10
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Improve help messages for advertise 09/204909/1
ERAMOTO Masaya [Fri, 16 Feb 2018 05:51:21 +0000 (14:51 +0900)]
client: Improve help messages for advertise

Change-Id: Id56c9df117e6c817b4d3b5dda6b54941441349b4
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Fix data growth if reconfiguring ad service 08/204908/1
ERAMOTO Masaya [Fri, 16 Feb 2018 05:51:15 +0000 (14:51 +0900)]
client: Fix data growth if reconfiguring ad service

Since commit 65eff5c2 ("client: Rename set-service to service"), data
are appended in every run of advertise service with data arguments as
below:

  [bluetooth]# service 1 1 2
  [bluetooth]# service
  UUID: SDP(1)
    01 02                                            ..
  [bluetooth]# service 1 1 2 3
  [bluetooth]# service
  UUID: SDP(1)
    01 02 01 02 03                                   .....

Change-Id: I1e8f6f19adbbd967b2ddc06837ddf7103ea18167
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Not output ad service info if no uuid sets 07/204907/1
ERAMOTO Masaya [Fri, 16 Feb 2018 05:51:08 +0000 (14:51 +0900)]
client: Not output ad service info if no uuid sets

Change-Id: I2f3db46b13b7d33a952993dcc1c1421e01b4ce1c
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Fix null output for ad service uuid 06/204906/1
ERAMOTO Masaya [Fri, 16 Feb 2018 05:51:03 +0000 (14:51 +0900)]
client: Fix null output for ad service uuid

If getting the advertise service information without setting, outputs
null as UUID as below:

  [bluetooth]# service
  UUID: ((null))

Change-Id: I47ce8f6c380b90bf17acfa0db112bfc93b234e14
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadapter: Fix initializing GATT server for BR/EDR only controllers 05/204905/1
Luiz Augusto von Dentz [Wed, 14 Feb 2018 13:58:15 +0000 (15:58 +0200)]
adapter: Fix initializing GATT server for BR/EDR only controllers

Controller that do not support LE bearer shall not use GATT server for
anything.

Change-Id: Iffde6329966bb828a43262f3af41f6f294ce5667
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoobexd: Fix null response name 04/204904/1
ERAMOTO Masaya [Wed, 14 Feb 2018 07:20:31 +0000 (16:20 +0900)]
obexd: Fix null response name

Prints out "<unknown>" string if there is no response name as below:

  obexd[8117]: obexd/src/obex.c:cmd_connect()
  obexd[8117]: CONNECT(0x0), (null)(0xffffffff)

Change-Id: I3229def9a31f1397001f9c101550e0f30da17641
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadvertising: only parse adv from adv interfaces 03/204903/1
Matt Schulte [Wed, 7 Feb 2018 07:48:56 +0000 (23:48 -0800)]
advertising: only parse adv from adv interfaces

client_proxy_added is called for every interface on an object passed in
to the dbus RegisterAdvertisement method. This can cause a NULL
dereference to occur and a failure status in the reply on dbus
RegisterAdvertisement method calls. The fix is to return early from
client_proxy_added if the proxy interface is not
org.bluez.LEAdvertisement1. If this early return is not there, two
different error paths could occur.

1) client_proxy_added is first called with the
org.bluez.LEAdvertisement1 interface and then with another interface.
The second call will fail the parse_advertisement call and possibly
cause a NULL dereference on the dbus_message_unref if
add_client_complete has already occurred.

2) client_proxy_added is first called with an unknown interface and then
org.bluez.LEAdvertisement1. The first call will cause
parse_advertisement to fail and a failure to be replied to the client
calling RegisterAdvertisement. The advertisement may be successfully
registered on the second client_proxy_added call but a NULL dereference
will occur on the call to dbus_message_new_method_return in
add_client_complete.

Change-Id: I5fa0dbaad9568d0ebdd1c358246f10b20cbe2bcc
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-db: Fix declaration attributes permission 02/204902/1
Konstantin Zhukov [Mon, 12 Feb 2018 10:40:30 +0000 (14:40 +0400)]
shared/gatt-db: Fix declaration attributes permission

According to Bluetooth Core specification v4.2 (Vol. 3, part G,
section 3.1), service declararion attributes should have only READ
permission. The same obligation has charateristic declaration and
include service declaration attributes.

Without this permission connected clients could corrupt GATT database
by writing to declaration attributes. After thatm service discovery
fails in other clients.

Change-Id: Ib18c4de213e9c242a09a770d9f24cd850a1af6a0
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoobexd: Emit Size property of transfer after open() 01/204901/1
ERAMOTO Masaya [Fri, 9 Feb 2018 09:11:41 +0000 (18:11 +0900)]
obexd: Emit Size property of transfer after open()

Emits the Size property of transfer after calling ->open() because it
may update the size information.

Change-Id: I343e2f9c5993a9c91107e75f7a0af747f262308c
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoobexd: Use emitting function wrapped for transfer 00/204900/1
ERAMOTO Masaya [Fri, 9 Feb 2018 09:10:57 +0000 (18:10 +0900)]
obexd: Use emitting function wrapped for transfer

Also replaces emit_transfer_progress() with the new wrapper function
because the total/transferred arguments have not been used since commit
a5c2b6e8 ("obexd: Align client and server spec of org.bluez.obex.Transfer1")
and g_dbus_emit_property_changed_full() checks if the path argument is
NULL.

Change-Id: I2733ee5de2de15d008d45724abffafefa87fc045
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoshared/gatt-client: Reset callbacks when unregistering 99/204899/1
Luiz Augusto von Dentz [Fri, 9 Feb 2018 10:46:55 +0000 (12:46 +0200)]
shared/gatt-client: Reset callbacks when unregistering

If user application is unregistering a notification handler its
callbacks shall not be called even CCC write is still holding a
reference to notify_data.

Change-Id: Ib16702e9d0437478487daf6571844b55ceac5266
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadapter: Remove spurious propery changed signal 98/204898/1
Szymon Janc [Thu, 8 Feb 2018 16:03:06 +0000 (17:03 +0100)]
adapter: Remove spurious propery changed signal

There is no "Connectable" property on Adapter1 interface.

Change-Id: I2673bfc3bf9a5b18ceac1dffacbf47b05181e1a4
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoadvertising: Configure discoverable flag based on adapter settings 97/204897/1
Szymon Janc [Wed, 7 Feb 2018 10:02:24 +0000 (11:02 +0100)]
advertising: Configure discoverable flag based on adapter settings

Until now advertising as peripheral was always setting General Discoverable
flag set. With this patch this is set based on adapter discoverable setting.

Change-Id: Ic4db27d37f94ab6a99250f919d9e9432cfa40886
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agocore: Fixes order InterfaceAdded 96/204896/1
Luiz Augusto von Dentz [Wed, 7 Feb 2018 11:35:07 +0000 (09:35 -0200)]
core: Fixes order InterfaceAdded

Registering on the callback of MGMT_OP_READ_ADV_FEATURES causes
InterfacesAdded to be reschedule after the device objects which causes
tools such as PulseAudio to consider it invalid.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1534857

Change-Id: I5e485ccbeb9d0cd81b0a34bbe970306333ef948e
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
5 years agoclient: Fix not cleaning up notify pipe 95/204895/1
Luiz Augusto von Dentz [Tue, 6 Feb 2018 10:01:19 +0000 (08:01 -0200)]
client: Fix not cleaning up notify pipe

If remote unsubscribe, disconnects or the daemon closes the socket the
io shall be destroyed properly otherwise it will prevent new
subscriptions.

Change-Id: I9cd77b61e7bfdd38ecd160edd0b9316d8285c7b0
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>