OSDN Git Service

android-x86/system-bt.git
8 years agoAdd a log message to capture NULL pointer in l2c_link_hci_disc_comp()
Pavlin Radoslavov [Tue, 17 May 2016 00:14:03 +0000 (17:14 -0700)]
Add a log message to capture NULL pointer in l2c_link_hci_disc_comp()

Added a log message inside l2c_link_hci_disc_comp() to help capture
a NULL pointer p_lcb->p_fixed_ccbs[xx] that triggers SIGSEGV crash.
Also, updated the typedef of bdstr_t and moved it to
file "btcore/include/bdaddr.h"

Bug: 28765514
Change-Id: Iacd9376cfb9e18b58e18865581da8edad9f68821

8 years agoMerge "HID: Prevent incoming and outgoing SDP collision"
Treehugger Robot [Tue, 17 May 2016 19:21:54 +0000 (19:21 +0000)]
Merge "HID: Prevent incoming and outgoing SDP collision"

8 years agoMerge "Fix pairing state change in collision scenario"
Treehugger Robot [Tue, 17 May 2016 18:38:56 +0000 (18:38 +0000)]
Merge "Fix pairing state change in collision scenario"

8 years agoHID: Prevent incoming and outgoing SDP collision
Hemant Gupta [Wed, 7 Oct 2015 06:38:10 +0000 (12:08 +0530)]
HID: Prevent incoming and outgoing SDP collision

SDP is performed 2 times as part of HID connection in BD stack,
one after successful authentication, and one in HID stack layer
as SDP data is not stored currently in stack. When there is outgoing and
incoming connections, SDP failed message was posted which was resulting
in SDP failure for HID host resulting in improper disconnection of
HID interrupt channel.

Change-Id: I5b4813dc916696e2c0f76be27a85c1a89c2d8be0

8 years agoMerge "Check CCB state before executing channel state machine events"
Treehugger Robot [Tue, 17 May 2016 18:09:14 +0000 (18:09 +0000)]
Merge "Check CCB state before executing channel state machine events"

8 years agoFix pairing state change in collision scenario
venkata Jagadeesh [Thu, 1 Oct 2015 06:25:03 +0000 (11:55 +0530)]
Fix pairing state change in collision scenario

Symptom:
DUT Stuck in pairing state forever with selfy stick
during repair.

Steps:
1. Pair and connect remote devices with DUT.
2. Now un pair selfy stick from DUT.
3. Keep remote in discoverable mode.
4. Start inquiry and try to pair with device.

Failure:
Pairing with selfy stick always fails after collision.

Root Cause:
As we return from btm_sec_dd_create_conn with out
moving pairing state in connection collision scenario. Pairing
state will remains idle and pairing won't proceed further.

Fix:
Move the pairing state in collision scenario so that pairing
can proceed further.

Change-Id: Ic5c446ad3902b0ce16c7223ec2d8e4a625831446

8 years agoIncreasing LE Properties to broadcast.
Balraj Selvaraj [Wed, 6 Jan 2016 05:48:32 +0000 (11:18 +0530)]
Increasing LE Properties to broadcast.

Use case: Remote BD_NAME is not broadcasted when BLE device
pairing is done by using NFC where we broadcasted only UUID.

steps:
Connect with BLE device by using NFC and check the remote name.

Failure: Remote device name is not available.

Root cause: BD_NAME is not broadcasted when BLE device pairing
is done.

Fix: Added property to broadcast remote BD_NAME also as part
BLE device pairing using NFC.

Change-Id: Ie6cda489aabff15a0ebbc692a16f9428729a7dba

8 years agoCheck CCB state before executing channel state machine events
Gurpreet Ghai [Sun, 13 Mar 2016 16:18:30 +0000 (21:48 +0530)]
Check CCB state before executing channel state machine events

Use Case:
When a disconnect response is being executed, a timeout may
occur and timeout event gets enqueued in BTU process. When
processing of the disconnect event completes, timout event is received
at csm and is executed. However, by this time the Channel
Control Block is already released during previous event causing
errors.

Steps:
Various connection/disconnection scenario.

Failure:
If ccb is already released while processing of
previous event, the occurance of new enqueued event causes
crash.

Root cause:
Disconnection response event has already released
ccb and set lcb for this channel to null. The occurance of
timer event after this results in crash because lcb is
dereferenced while header creation to send disc response to
peer device.

Fix:
Added check for ccb state for whether it is currently in
use or released before executing events in csm.

Change-Id: I9110e6dd5273fa162b51c8aa15bd0030567d664b

8 years agoL2CAP: Handle invalid HCI packets
Matadeen Mishra [Wed, 3 Feb 2016 12:43:39 +0000 (18:13 +0530)]
L2CAP: Handle invalid HCI packets

- Handled Buffer over flow for uint16_t
- Discard invalid HCI packets from Codenomican test
  tool as data length and actual data not matching
  during reassembly

Use case:
Execute L2CAP test suit from Defensics Codenomican

Steps:
1. Pair and connect DUT to Codenomican tool
2. Execute L2CAP test suit from Defensics Codenomican

Failure:
Crash observed on DUT and Codenomican tool stuck in execution.

Root cause:
Codenomican tool sending invalid HCI packets to DUT and
there are no checks to handle buffer over flow and other invalid data
from Codenomican tool.

Change-Id: I6f93c80244fc39d607ad285185136bbbca83d7ae

8 years agoDon't process pair request when controller is not ready
Srinu Jella [Thu, 24 Sep 2015 07:53:36 +0000 (13:23 +0530)]
Don't process pair request when controller is not ready

Use case: when one application is trying to pair and
other application is turning off Bluetooth.

Steps: when one application is trying to pair and
other application is turning off Bluetooth.

Failure: Bluetooth process crashed.

Root Cause: Bluetooth process crashed due to assertion,
as controller module is not ready.

Fix: Made a checks for controller module is ready or not, If
it is ready then only go for pairing.

Change-Id: I72c72f6b5545c845e79874212359854023ffad98

8 years agoGAP: Save pin code length for incoming legacy SAP connection
venkata Jagadeesh [Wed, 2 Sep 2015 13:55:33 +0000 (19:25 +0530)]
GAP: Save pin code length for incoming legacy SAP connection

Use case: Carkit cannot reconnect to DUT in Sim Access Profile mode

Steps:
1. Pair with a car-kit (Agree all SAP, MAP, PBAP requests)
2. Initiate disconnection on DUT
3. Initiate re-connection on the car-kit.

Failure: SAP profile reconnection failing as dut gives negetive
linkkey reply.

Root Cause: sec_flags not getting updated without pin len and stack
triggering negative link key reply even linkkey is proper for 16 digit
authentication of SAP.

Fix: Save pin length during BTM_PINCodeReply.

Change-Id: I8300dd3ff497058291143313b169190910e0a7c5

8 years agoPrevent crash due to second attempt to clean up eager_reader
Srinu Jella [Tue, 29 Sep 2015 14:37:42 +0000 (20:07 +0530)]
Prevent crash due to second attempt to clean up eager_reader

Null out the eager readers once they are cleaned up, so we
don't try to clean them up later if an error occurs opening
the HAL again later.

Change-Id: I07df1010a1a619cb67b306d64e274d450234a002

8 years agobtif: Remove dead code from btif_storage
Marie Janssen [Mon, 16 May 2016 20:51:31 +0000 (13:51 -0700)]
btif: Remove dead code from btif_storage

Change-Id: I3ee4d8fd3a7697e0113d955982b21db123354a86

8 years agoAdd missing arguments to log messages
Pavlin Radoslavov [Sat, 14 May 2016 04:10:22 +0000 (21:10 -0700)]
Add missing arguments to log messages

Bug: 28769522
Change-Id: I37c2b8400619646a8711099cf0bd369c3cf8eb51

8 years agoAdd missing include for OSI_NO_INTR
Stefan Stanacar [Mon, 16 May 2016 11:25:39 +0000 (14:25 +0300)]
Add missing include for OSI_NO_INTR

Fixes building bt_vendor_linux since
OSI_NO_INTR is defined in osi.h

Change-Id: Ib95a3126ed4a7b8f0bdc7db3dd2ef162825f2cbe
Signed-off-by: Stefan Stanacar <stefan.stanacar@intel.com>
8 years agoFail gracioulsy when GATT_MAX_APPS reached
Jakub Pawlowski [Fri, 13 May 2016 20:09:08 +0000 (13:09 -0700)]
Fail gracioulsy when GATT_MAX_APPS reached

Bug: 28677905
Change-Id: I092494ab3f9e9ae4330d5d2a6f6ef010c61fe2a4

8 years agoaudio HAL: improve control socket error handling
Eric Laurent [Thu, 12 May 2016 01:18:54 +0000 (18:18 -0700)]
audio HAL: improve control socket error handling

Implement retry upon control socket receive error
in a2dp_ctrl_receive() if EAGAIN or EINTR.

Implement recovery from previous socket error in
a2dp_command().

Increase socket receive timeout to account for
headsets will long activation time.

Fixed state update error in start_audio_datapath()
in case the data socket is already opened.

Added missing mutex around state updated in oput_write()
and in_read()

Made read and write code symmetric.

Bug: 28727517
Change-Id: I68d7fe63f298bbd1e387ec42fdb1277b2dcdfef5

8 years agoRestart failed system calls interrupted with errno of EINTR
Pavlin Radoslavov [Thu, 12 May 2016 18:36:44 +0000 (11:36 -0700)]
Restart failed system calls interrupted with errno of EINTR

In number of places we don't handle properly system calls failures
when the errno is EINTR (i.e., the system call was interrupted
by a signal). In all our use cases, the system calls should be
restarted. The handling of the following system calls (as used in the code)
has been updated/fixed:

  poll, send, recv, sendmsg, nanosleep, epoll_wait
  read - mostly (e.g., socket-like fds)
  write - mostly (e.g., socket-like fds)
  select, accept, connect

Bug: 28471477
Bug: 28658141
Change-Id: I03e6f0f67e33876780fb6d02c33eb84547ba8f95

8 years agoAdd sync to write the backup file to the filesystem
Ajay Panicker [Thu, 12 May 2016 22:52:01 +0000 (15:52 -0700)]
Add sync to write the backup file to the filesystem

Bug: 27354612
Change-Id: I5a7751b6f08831d43647391774501f211336e9eb

8 years agoBuild fix for feldspar-dev
Jakub Pawlowski [Thu, 12 May 2016 22:02:55 +0000 (15:02 -0700)]
Build fix for feldspar-dev

Bug: 28485365
Change-Id: I25db2fe7577e98715eb10e105176c536fddb043a

8 years agoAdd config logging, make parsing stricter, and move sync
Ajay Panicker [Thu, 12 May 2016 18:03:39 +0000 (11:03 -0700)]
Add config logging, make parsing stricter, and move sync

The functions that parse the config file will report failure if
the config file is improperly formatted or is missing the necessary
Adapter section. Also moved sync to sync the filesystem after the
config file is saved.

Bug: 27354612
Change-Id: Ia75ff628d83bdc933c4bc16761d6c55eef19b757

8 years agoMerge "btif: only save config when bonded devices change"
Treehugger Robot [Thu, 12 May 2016 20:51:59 +0000 (20:51 +0000)]
Merge "btif: only save config when bonded devices change"

8 years agoRemove dead HID code
Jakub Pawlowski [Thu, 12 May 2016 16:24:38 +0000 (09:24 -0700)]
Remove dead HID code

This patch removes dead code in HID related to setting scan parameters
on remote device.

Change-Id: I96e0036b65d2ebb3b099d817683ed3d5a11b6bb7

8 years agobtif: only save config when bonded devices change
Marie Janssen [Wed, 11 May 2016 21:58:48 +0000 (14:58 -0700)]
btif: only save config when bonded devices change

Bug: 27354612

Change-Id: I15f816c85d3ab1991abf076f7c1ae2914d773d54

8 years agoRename all *.cpp files to *.cc to follow new style
Jakub Pawlowski [Thu, 12 May 2016 18:16:46 +0000 (11:16 -0700)]
Rename all *.cpp files to *.cc to follow new style

Change-Id: Ia79ee09348e67ff4a1712ee11a1e8480180a2623

8 years agoRewrite btif_gatts_register_app to new style
Jakub Pawlowski [Thu, 5 May 2016 18:16:00 +0000 (11:16 -0700)]
Rewrite btif_gatts_register_app to new style

Bug: 28485365
Change-Id: I5b9bd5a807492b254a5486c80dfb56769e95943f

8 years agoRewrite btif_gatts_open to new style
Jakub Pawlowski [Thu, 5 May 2016 18:09:12 +0000 (11:09 -0700)]
Rewrite btif_gatts_open to new style

Bug: 28485365
Change-Id: I20fdb5ffe6d52db291e9862f7e24fb43e060950f

8 years agoRewrite btif_gatts_close to new style
Jakub Pawlowski [Thu, 5 May 2016 18:03:32 +0000 (11:03 -0700)]
Rewrite btif_gatts_close to new style

Bug: 28485365
Change-Id: Ib8d7ed81cf958ab3dd5403c46409cbd506ac3dc1

8 years agoRewrite btif_gatts_add_included_service to new style
Jakub Pawlowski [Thu, 5 May 2016 17:47:14 +0000 (10:47 -0700)]
Rewrite btif_gatts_add_included_service to new style

Bug: 28485365
Change-Id: I4465493532578942045b979e542608972c5fa2ec

8 years agoRewrite btif_gatts_start_service to new style
Jakub Pawlowski [Thu, 5 May 2016 17:40:17 +0000 (10:40 -0700)]
Rewrite btif_gatts_start_service to new style

Bug: 28485365
Change-Id: I2c8b02ce42fd2bde3a4c448f6fb19ef8e3eb169a

8 years agoRewrite btif_gatts_stop_service to new style
Jakub Pawlowski [Thu, 5 May 2016 17:17:02 +0000 (10:17 -0700)]
Rewrite btif_gatts_stop_service to new style

Bug: 28485365
Change-Id: I79aaaa57139dca373fdf7c0424353cd5de0cb48f

8 years agoRewrite btif_gatts_send_indication to new style
Jakub Pawlowski [Thu, 5 May 2016 17:09:44 +0000 (10:09 -0700)]
Rewrite btif_gatts_send_indication to new style

Bug: 28485365
Change-Id: I1d3221be272e53245e09077dad9d291829350b45

8 years agoRewrite btif_gatts_send_response to new style
Jakub Pawlowski [Thu, 5 May 2016 17:03:35 +0000 (10:03 -0700)]
Rewrite btif_gatts_send_response to new style

Bug: 28485365
Change-Id: Id0dbfe28b0f77f542cd6961c041e70f90d0aa78b

8 years agoUse unnamed namespace in btif_gatt_client
Jakub Pawlowski [Thu, 5 May 2016 21:23:00 +0000 (14:23 -0700)]
Use unnamed namespace in btif_gatt_client

Instead of marking each function as const, we can enclose them in
namespace, which will have same effect.
This patch also format rest of the file to follow cc style guide.

Change-Id: I5e07d80558de06851c8b5f696d8a239fd4de73e2

8 years agoUse unordered_set to keep p_dev_cb
Jakub Pawlowski [Wed, 4 May 2016 23:53:42 +0000 (16:53 -0700)]
Use unordered_set to keep p_dev_cb

Bug: 28485365
Change-Id: I5c6c45153c04b1ac9215addf436c7731f376dd15

8 years agoRemove unused structures from btif_gatt_client
Jakub Pawlowski [Wed, 4 May 2016 23:26:28 +0000 (16:26 -0700)]
Remove unused structures from btif_gatt_client

Bug: 28485365
Change-Id: If1a4c0d721966255038381b3a0f045910fa923dd

8 years agoRewrite bta_scan_results_cb to new style
Jakub Pawlowski [Wed, 4 May 2016 23:24:25 +0000 (16:24 -0700)]
Rewrite bta_scan_results_cb to new style

Bug: 28485365
Change-Id: I1029053c9417e6224e365c42aaeba09759e85ff2

8 years agoRewrite multi adv callbacks to new style
Jakub Pawlowski [Wed, 4 May 2016 23:02:05 +0000 (16:02 -0700)]
Rewrite multi adv callbacks to new style

Bug: 28485365
Change-Id: I94e8378515543135b51d0d27c988f6dc2ffb6a70

8 years agoRewrite batch scan related functions to new style
Jakub Pawlowski [Wed, 4 May 2016 20:44:24 +0000 (13:44 -0700)]
Rewrite batch scan related functions to new style

Bug: 28485365
Change-Id: Id82aa6abb0cf9f809567ee8f728ccd8256d43096

8 years agoRewrite bta_track_adv_event_cb to new style
Jakub Pawlowski [Wed, 4 May 2016 20:31:51 +0000 (13:31 -0700)]
Rewrite bta_track_adv_event_cb to new style

Bug: 28485365
Change-Id: Iebf02592cb279a4aca48c9593923b67ddeabf428

8 years agoRewrite btm_read_rssi_cb to new style
Jakub Pawlowski [Wed, 4 May 2016 20:29:28 +0000 (13:29 -0700)]
Rewrite btm_read_rssi_cb to new style

Bug: 28485365
Change-Id: Iec6114714d0201556bee27a8311356168c7afcac

8 years agoRewrite scan filter related callbacks to new style
Jakub Pawlowski [Wed, 4 May 2016 20:23:07 +0000 (13:23 -0700)]
Rewrite scan filter related callbacks to new style

Bug: 28485365
Change-Id: Icd5c3529ed2938e095dacc53df716dcd0e69a56d

8 years agoRewrite btif_gattc_scan_filter_add_remove to new style
Jakub Pawlowski [Wed, 4 May 2016 19:32:18 +0000 (12:32 -0700)]
Rewrite btif_gattc_scan_filter_add_remove to new style

Bug: 28485365
Change-Id: I618644b08ecffbb8d22186a7dc70189fb8e50a53

8 years agoRewrite register/unregister app to new style
Jakub Pawlowski [Tue, 3 May 2016 23:00:08 +0000 (16:00 -0700)]
Rewrite register/unregister app to new style

Bug: 28485365
Change-Id: I9e709cc54990769bb5e3cee4328ce36ee992927d

8 years agoRewrite scan start/stop to new style
Jakub Pawlowski [Tue, 3 May 2016 22:49:53 +0000 (15:49 -0700)]
Rewrite scan start/stop to new style

Bug: 28485365
Change-Id: I1b659d063181adef85cc835a350717bbb7bfe483

8 years agoRewrite btif_gattc_open to new style
Jakub Pawlowski [Tue, 3 May 2016 22:47:50 +0000 (15:47 -0700)]
Rewrite btif_gattc_open to new style

Bug: 28485365
Change-Id: Idc0e12a00f155a128806b1c2a7f3f71daf6cd23f

8 years agoRewrite btif_gattc_close to new style
Jakub Pawlowski [Tue, 3 May 2016 22:44:44 +0000 (15:44 -0700)]
Rewrite btif_gattc_close to new style

Bug: 28485365
Change-Id: Ic82a28cc3659b4ac9936861310578ee07f46ee31

8 years agoRewrite btif_gattc_search_service to new style
Jakub Pawlowski [Tue, 3 May 2016 21:34:57 +0000 (14:34 -0700)]
Rewrite btif_gattc_search_service to new style

Bug: 28485365
Change-Id: I80ad14db9cfa69cbbfeee3cf362017ca0da70c8e

8 years agoRewrite btif_gattc_execute_write to new style
Jakub Pawlowski [Tue, 3 May 2016 21:33:06 +0000 (14:33 -0700)]
Rewrite btif_gattc_execute_write to new style

Bug: 28485365
Change-Id: Id93cf6e3ee1d2c9eded20d98ba791c462ff0b5af

8 years agoRewrite btif_gattc_write_char to new style
Jakub Pawlowski [Tue, 3 May 2016 21:23:37 +0000 (14:23 -0700)]
Rewrite btif_gattc_write_char to new style

Bug: 28485365
Change-Id: Ibe0c1386befb77ddb55d20effd7ba1fda6135d7b

8 years agoRewrite btif_gattc_reg_for_notification to new style
Jakub Pawlowski [Tue, 3 May 2016 21:08:45 +0000 (14:08 -0700)]
Rewrite btif_gattc_reg_for_notification to new style

Bug: 28485365
Change-Id: I227634b11be381977135f7c6668c4d15b7cca31b

8 years agoRewrite btif_gattc_listen to new style
Jakub Pawlowski [Tue, 3 May 2016 21:00:12 +0000 (14:00 -0700)]
Rewrite btif_gattc_listen to new style

Bug: 28485365
Change-Id: I63c677262b316210ab5f59908fd2e30fb9d5eebc

8 years agoRewrite btif_gattc_set_adv_data to new style
Jakub Pawlowski [Tue, 3 May 2016 20:48:20 +0000 (13:48 -0700)]
Rewrite btif_gattc_set_adv_data to new style

Bug: 28485365
Change-Id: Id3868d321226bc3c251bb15f3176c6e2d4b66e82

8 years agoRewrite read RSSI and set MTU to new style
Jakub Pawlowski [Tue, 3 May 2016 20:43:58 +0000 (13:43 -0700)]
Rewrite read RSSI and set MTU to new style

Bug: 28485365
Change-Id: Ife20d1ce569a1feff561a1b7b3e7b22560a4f108

8 years agoRewrite btif_gattc_conn_parameter_update to new style
Jakub Pawlowski [Tue, 3 May 2016 19:06:36 +0000 (12:06 -0700)]
Rewrite btif_gattc_conn_parameter_update to new style

Bug: 28485365
Change-Id: Ibc5e085d381855ec139383545cfbec2750efb33f

8 years agoRewrite btif_gattc_scan_filter_param_setup to new style
Jakub Pawlowski [Tue, 3 May 2016 18:59:28 +0000 (11:59 -0700)]
Rewrite btif_gattc_scan_filter_param_setup to new style

Bug: 28485365
Change-Id: I290af35e0de35f4fbb7fa18ffc40eb5349027343

8 years agoRewrite scan filter related methods to new style
Jakub Pawlowski [Tue, 3 May 2016 18:50:08 +0000 (11:50 -0700)]
Rewrite scan filter related methods to new style

Bug: 28485365
Change-Id: I68e270e4d7bceee6a9a67ef2a7c50a047cf2d574

8 years agoRewrite btif_gattc_multi_adv_enable to new style
Jakub Pawlowski [Tue, 3 May 2016 18:33:36 +0000 (11:33 -0700)]
Rewrite btif_gattc_multi_adv_enable to new style

Bug: 28485365
Change-Id: I7e055c4930fc39dd3b83ea0086f0c0e12f7d815f

8 years agoRewrite btif_gattc_multi_adv_update to new style
Jakub Pawlowski [Tue, 3 May 2016 18:20:01 +0000 (11:20 -0700)]
Rewrite btif_gattc_multi_adv_update to new style

Bug: 28485365
Change-Id: I59a908560856eff0b46b2bf5040c2ecb990ae350

8 years agoRewrite multi adv set data to new style.
Jakub Pawlowski [Tue, 3 May 2016 18:12:49 +0000 (11:12 -0700)]
Rewrite multi adv set data to new style.

Bug: 28485365
Change-Id: I28f1fd875998b039b5df969771e7b07c08d7fd3e

8 years agoRewrite btif_gattc_multi_adv_disable to new style
Jakub Pawlowski [Tue, 3 May 2016 16:11:29 +0000 (09:11 -0700)]
Rewrite btif_gattc_multi_adv_disable to new style

Bug: 28485365
Change-Id: Ifa5e4b4812ec236cc9a41a2129eaa43c328fa28f

8 years agoRewrite btif batch scan methods to new style.
Jakub Pawlowski [Tue, 3 May 2016 16:03:11 +0000 (09:03 -0700)]
Rewrite btif batch scan methods to new style.

Bug: 28485365
Change-Id: I62dfa6911ca0e26d490a9702d391aa30a09829a9

8 years agoRewrite btif_get_gatt_db to new style
Jakub Pawlowski [Tue, 3 May 2016 15:55:11 +0000 (08:55 -0700)]
Rewrite btif_get_gatt_db to new style

Bug: 28485365
Change-Id: Iec63e595bfb82a4ac33564f3095cf0e7c4c37e39

8 years agoRewrite btif_gattc_set_scan_parameters to new style
Jakub Pawlowski [Tue, 3 May 2016 01:12:11 +0000 (18:12 -0700)]
Rewrite btif_gattc_set_scan_parameters to new style

Bug: 28485365
Change-Id: I29cb2e11b3e407676e312fe83248fc8b551e60ad

8 years agoRewrite GATT read operations to use new style
Jakub Pawlowski [Tue, 3 May 2016 00:50:25 +0000 (17:50 -0700)]
Rewrite GATT read operations to use new style

Bug: 28485365
Change-Id: I3c5918abdf79da7d6b566506ad53fa38656bcb65

8 years agoUse MessageLoop in bt_jni_workqueue thread
Jakub Pawlowski [Sat, 30 Apr 2016 21:37:40 +0000 (14:37 -0700)]
Use MessageLoop in bt_jni_workqueue thread

Up till now, to execute anyting on bt_jni_workqueue thread, we were
sending events to workqueue associated with this thread. Flow was:
btif_transfer_context -> btif_sendmsg -> thread_post.
Events were containing defined action, i.e. BTIF_GATTC_SCAN_START and
pointer to struct that contained all required data to execute it.
This was very cumbersome - figuring out what is executed when event is
send was hard. Also everything have to be packed into structure which
means that
we have to define lots of structures, or have one big super-structure
holding data for all events (like in btif_gatt_client.cc). Event sending
and receiving
logic is a huge percent of all code.

From now on, there will be a MessageLoop running inside bt_jni_workqueue
that will execute all tasks that will be posted with PostTask. The
benefit of having PostTask method, is that we can simply create Closure
that will be run in bt_jni_workqueue thread. It will take care of
transferring all associated values, and their cleanup. It will also do
compile-time check of all parameters. We no longer have to create
events, structs, and separate call logic from execution logic.

Bug: 28485365
Change-Id: I5014ef680757c0d3c6c69781aadc5139c8e1c3c4

8 years agoAdd additional VW car kits to absolute volume blacklist
Andre Eisenbach [Wed, 11 May 2016 19:20:23 +0000 (12:20 -0700)]
Add additional VW car kits to absolute volume blacklist

Change-Id: I8b0b73595e9183b9c1540b06e9e0378312c6a63d
Fixes: 25613423

8 years agoFix double mutex unlock and if() condition
Andre Eisenbach [Wed, 11 May 2016 03:27:20 +0000 (20:27 -0700)]
Fix double mutex unlock and if() condition

Commit "L2CAP and SDP Search API for BT profiles (2/2)" introduced two
separate issues in btsock_rfc_signaled():

1. The "slot_lock" potentially gets unlocked twice, causing
   undefined behaviour.

2. The call to BTA_JvRfcommWrite() was incorrectly taken outside
   of the conditional if() block that only executes the code if
   data is available.

This patch reverts the relevant locking change and fixes the if()
condition.

Bug: 27204458
Change-Id: I63b1257d21ca7bdd248858ec67e28f64e37a7895

8 years agoMove extern "C" to top of headers and remove tBTA_HF_CLIENT_HDR.
Bryce Lee [Wed, 11 May 2016 00:10:09 +0000 (17:10 -0700)]
Move extern "C" to top of headers and remove tBTA_HF_CLIENT_HDR.

Previously, extern "C" was placed in various locations within the header
files, sometimes below actual struct declarations. Doing so would lead to
alignment issues between C and C++ code.

tBTA_HF_CLIENT_HDR was removed from bta_hf_client_api since it was
extraneous and empty - leading to alignment issues.

Change-Id: Icdd338f1affe4c3a70c7bbd716249be6a16443d2

8 years agoChange initial order of commands after establishing an LE connection
Jakub Pawlowski [Tue, 10 May 2016 23:43:41 +0000 (16:43 -0700)]
Change initial order of commands after establishing an LE connection

This patch changes order of commands send to LE device after connecting.
This will cause update connection parameters to be send after read
remote version. Having it other way around cause some problems with
broadcom chips, even though it should work both ways.

Bug: 28435172
Change-Id: I8ecf76217b036842e1d9ec7df714da94a99df7d5

8 years agoChange initial order of commands after establishing an LE connection
Jakub Pawlowski [Tue, 10 May 2016 20:29:59 +0000 (13:29 -0700)]
Change initial order of commands after establishing an LE connection

This patch changes order of commands send to LE device after connecting.
This will cause update connection parameters to be send after read
remote features. Having it other way around cause some problems with
broadcom chips, even though it should work both ways.

Bug: 28435172
Change-Id: I280993d40b63d41729f5a8ccf246809c3abf617d

8 years agoA2DP_SINK: create avrcp connection only if a2dp is successful
AnubhavGupta [Thu, 7 Apr 2016 17:35:53 +0000 (23:05 +0530)]
A2DP_SINK: create avrcp connection only if a2dp is successful

 Scenario: Pair and connect carkit to a remote mobile
           Disconnect from carkit
           Initiate connection from carkit and turn BT-OFF
           on remote mobile phone
 Issuses: Even though A2DP connection is unsuccessful we
          try to connect AVRCP connectoin
 Solution:
  - for a2dp sink, we should not send pending play command
  - we should create avrcp connection only if a2dp connection
    is successful

Change-Id: If2c6a3710b6ebdaa382a3d8bcae5c137aaef1f2c

8 years agoPTS: Read SMP pairing options from bt_stack.conf
Nitin Arora [Sat, 12 Mar 2016 00:37:51 +0000 (16:37 -0800)]
PTS: Read SMP pairing options from bt_stack.conf

Use Case:
A number of cenrtification test cases require the host
to change the pairing options including auth request,
I/O capabilities, key distribution mask, key length
and Out of band capability.

Test Case: TP/PKE/BV-02-C

Failure:
Host currently only supports fixed SMP options and only
a few test cases involving pairing, are executed due
to that limitation.

Fix:
Added changes to read the SMP options from the bt_stack.conf
file at run time.
The pairing options are entered as a comma separated list eg:
SMPOptions=0xD,0x4,0xf,0xf,0x10
where the included hex values are in the following order:
\#auth, io, ikey, rkey, ksize
If all 5 options are not present, the host falls back to the
default values

Bug: 27852645
Change-Id: I693b05966695cf4660c5da10249c5f7c0663e53a

8 years agoPTS: Avoid BR SDP after LE pairing
Nitin Arora [Fri, 11 Mar 2016 02:27:24 +0000 (18:27 -0800)]
PTS: Avoid BR SDP after LE pairing

Use Case: Certification test case requiring LE secure pairing
with PTS.

Test Case: TP/SCJW/BV-01-C

Failure:
While pairing with PTS for certification test cases, LE secure
pairing followed by BR/EDR cross key derivation results in the
host initiating the SDP to gather the remote BR/EDR services.
PTS considers it as a test failure.

Fix: Added run time flag in bt_stack.conf file
"PTS_DisableSDPOnLEPair" to disable the SDP immidiately after
LE pairing followed by cross key derivation.

Bug: 27852645
Change-Id: Ib5a05c47b99c2ef8256967a608ae9ebbdfba60ee

8 years agoPTS: Allow disabling connection updates
Nitin Arora [Thu, 11 Jun 2015 00:10:57 +0000 (17:10 -0700)]
PTS: Allow disabling connection updates

Use Case: Certification test case requiring LE secure pairing
with PTS.

Failure:
LE pairing test cases follow the host behavior where
connection parameters are switched to fast parameters
for SMP and service discovery and switched back to the
default values after SMP/LE discovery is complete.
PTS disconnects to these series of connection updates.

Fix:
This change disables connection updates based on run time
flag "PTS_DisableConnUpdates" fetched from bt_stack.conf

Bug: 27852645
Change-Id: I1da213fd143ccfcb0ac82c7049a94094d2716ff1

8 years agoPTS: Add a Secure Only mode.
Nitin Arora [Fri, 11 Mar 2016 20:26:51 +0000 (12:26 -0800)]
PTS: Add a Secure Only mode.

Use Case:
Certification test cases require BLE to be in secure only
mode and reject legacy pairing requests.

Test Case: TP/SEC/SEM/BV-28-C

Failure:
Currently the host doesn't have a method of putting host into
a mode where it can only perform secure pairing.
This prevents execution of certification test cases
requiring Secure Only mode.

Fix:
Made changes to read the value of a tag "PTS_SecurePairOnly"
at runtime from the file "bt_stack.conf".

Bug: 27852645
Change-Id: I32cd6412621efeed2cb31c760a031762d9f369f9

8 years agoChanges to allow LE key upgrade
Nitin Arora [Tue, 30 Jun 2015 22:04:23 +0000 (15:04 -0700)]
Changes to allow LE key upgrade

Use Case: Certifiation test cases require the LE key upgrade
to happen when the current MITM level of the device has
been upgraded. In that case, a repairing is performed,
leading to more authenticated LTK.

Test Case: TP/SEC/AUT/BV-17-C

Steps:
1. Perform LE pairing between two devices using no MITM.
2. Change the IO capability of the devices, so that a
repair would involve authentication.
3. Reconnect the devices and expect key upgrade.

Failure:
No key upgrade is seen at reconnection and the devices
continue to use the old key.

Fix:
Added changes to re-calulate the requirement of key
upgrade when the LE channel is already encrypted.

Bug: 27852645
Change-Id: If62f334dcf298b2ce9840e95035b4398cb951c84

8 years agoFix undefined usage of snprintf
Ajay Panicker [Thu, 5 May 2016 21:51:34 +0000 (14:51 -0700)]
Fix undefined usage of snprintf

Using a buffer as both the format and output for snprintf could
cause undefinied behaviour on certain platforms. Instead just
use a temporary variable.

Bug: 27882028
Change-Id: If9f96fba4b3447b3248917ab9fb994bd80cbca0f

8 years agoRemove redefine of ARRAY_SIZE
Ajay Panicker [Fri, 6 May 2016 21:01:24 +0000 (14:01 -0700)]
Remove redefine of ARRAY_SIZE

Bug: 28621069
Change-Id: Ie3db0ff733052113493d0e53bb35e2d617c31bff

8 years agoUpdate l2c_fcr_clone_buf() to allocate large enough buffer
Pavlin Radoslavov [Mon, 9 May 2016 02:12:53 +0000 (19:12 -0700)]
Update l2c_fcr_clone_buf() to allocate large enough buffer

Apparently, in some parts of the code we assumed the original
buffer size is large enough and we can extend it and write
few more octets at the end.

Bug: 28351270
Change-Id: Idc53d8f68e55808c9f6bf7f18568288304a9bfb9

8 years agoLower unnecesary high log level
Jakub Pawlowski [Fri, 6 May 2016 20:26:45 +0000 (13:26 -0700)]
Lower unnecesary high log level

Change-Id: Id4d255d79c844cd8dbf044e5bda073b8f5d784e7

8 years agoCall BTA_VendorCleanup() during actual cleanup of the stack
Pavlin Radoslavov [Thu, 5 May 2016 23:20:15 +0000 (16:20 -0700)]
Call BTA_VendorCleanup() during actual cleanup of the stack

Previously, BTA_VendorCleanup() was called during the shutdown
process, and this created race condition crashing the stack.

Bug: 28450506
Change-Id: Ibee90d406036862b95d18e2ef00b08b820c70f68

8 years agoMerge "Return handle if an RFCOMM port is already open"
Treehugger Robot [Thu, 5 May 2016 23:29:24 +0000 (23:29 +0000)]
Merge "Return handle if an RFCOMM port is already open"

8 years agoMerge "Fix size of SDP black list array"
Treehugger Robot [Thu, 5 May 2016 22:31:40 +0000 (22:31 +0000)]
Merge "Fix size of SDP black list array"

8 years agoReturn handle if an RFCOMM port is already open
Andre Eisenbach [Thu, 5 May 2016 17:57:44 +0000 (10:57 -0700)]
Return handle if an RFCOMM port is already open

By returning the handle, the upper layer (BTA) will attempt to
disconnect on failure to connect. Thus the attempt to open the port will
still fail, but any subsequent attempts will be able to recover.

Bug: 27204458
Change-Id: I0f8489b98adeb7f5e217201ffbbb35132a66f210

8 years agoFix size of SDP black list array
Ajay Panicker [Thu, 5 May 2016 19:51:49 +0000 (12:51 -0700)]
Fix size of SDP black list array

Bug: 28617843
Change-Id: Iff5690e3aae42d9907ed9351f1059461985c8a20

8 years agoAllow C++ code to check bt_stack_config options
Myles Watson [Thu, 5 May 2016 18:57:54 +0000 (11:57 -0700)]
Allow C++ code to check bt_stack_config options

Stack configuration options are parsed in C.

Bug: 28485365
Change-Id: I046ef5c676256a8da23bf8c0a7d1eeb1e9603c05

8 years agoFixed test_periodic_unregister_processing_queue unit test
Pavlin Radoslavov [Wed, 4 May 2016 06:00:15 +0000 (23:00 -0700)]
Fixed test_periodic_unregister_processing_queue unit test

Removed a copy-and-paste check in the
test_periodic_unregister_processing_queue unit test.
The removed check adds little value - it has time-dependency,
and is not robust.

Bug: 26982349
Change-Id: I4adb948713b9946b5eb821d6fe52b7ada1400182

8 years agoAvoid NULL pointer usage of startup_future in case of HCI startup timeout
Pavlin Radoslavov [Wed, 4 May 2016 03:20:06 +0000 (20:20 -0700)]
Avoid NULL pointer usage of startup_future in case of HCI startup timeout

Previously, the startup_timer was created within the HCI layer start_up()
function, and after several vendor calls, we created the startup_future
that is used elsewhere. However, if any of the vendor calls blocks for
very long time, the startup_timer will timeout.
The startup_timer_expired() callback will try to use startup_future
that is still NULL, and that will trigger an assert.

The issue is avoided by creating the startup_future right before
the startup_timer is scheduled.

Bug: 28528815
Change-Id: Ib9f2c6581a86d3df0fd4d02d0b4c290663b5cfa1

8 years agoMerge "Update alarm_unregister_processing_queue() to cancel scheduled alarms"
Treehugger Robot [Tue, 3 May 2016 23:57:18 +0000 (23:57 +0000)]
Merge "Update alarm_unregister_processing_queue() to cancel scheduled alarms"

8 years agoUpdate alarm_unregister_processing_queue() to cancel scheduled alarms
Pavlin Radoslavov [Mon, 2 May 2016 17:52:07 +0000 (10:52 -0700)]
Update alarm_unregister_processing_queue() to cancel scheduled alarms

Update the alarm_unregister_processing_queue() implementation
so it cancels all alarms that are scheduled on the corresponding
queue.
This fixes a race condition during Bluetooth shutdown: if an alarm
expires right after an alarm processing queue is invalidated,
the alarm processing would try to use the invalidated queue.

Added the corresponding unit tests.

Also, added a missing call to alarm_unregister_processing_queue().

Bug: 26982349
Change-Id: I09a111e8080b6dbc354dffa03a487f7a8c578ce6

8 years agoSimplify btif multi adv data handling
Jakub Pawlowski [Tue, 3 May 2016 16:42:34 +0000 (09:42 -0700)]
Simplify btif multi adv data handling

Use static fixed size arrays to transport advertisement data instead of
dynamically allocated ones. This simplifies memory allocation and
cleanup handling.

Bug: 28485365
Change-Id: I3a2642e3b11a272eeec50fd959e10820ea3de74f

8 years agoFix google-explicit-constructor warnings.
Chih-Hung Hsieh [Tue, 3 May 2016 17:23:34 +0000 (10:23 -0700)]
Fix google-explicit-constructor warnings.

Bug: 28341362
Change-Id: I7ed9eb20b9b378a25a5454ce2ebfa113428baaf4

8 years agoBuild fix
Jakub Pawlowski [Tue, 3 May 2016 04:06:16 +0000 (21:06 -0700)]
Build fix

Change-Id: I6fd0ebe5e1d650ef307b22f96869c0004f6c956f

8 years agoAdd read/write timeout to the audio sockets
Pavlin Radoslavov [Mon, 2 May 2016 20:40:26 +0000 (13:40 -0700)]
Add read/write timeout to the audio sockets

Add read/write timeout of 2 seconds when reading/writing
from/to the audio-related control and data sockets.
Also, removed unnecessary poll(POLLOUT), because it is not needed anymore.

Bug: 27996931
Change-Id: Ib214a85f4837760b17cded155464957f56806bd3

8 years agoFix test_set_zero_periodic unit test failure
Pavlin Radoslavov [Mon, 2 May 2016 22:53:22 +0000 (15:53 -0700)]
Fix test_set_zero_periodic unit test failure

Removed an "EXPECT_EQ(cb_counter, 0)" statement
right after a timer of value 0 is scheduled.
The EXPECT_EQ statement shouldn't be there,
because by the time it is reached, the callback might
have been called already.

Change-Id: I61fbec96c436787321c6b36006a2bc1c0e627667

8 years agoConvert BTIF code from C to C++
Jakub Pawlowski [Thu, 21 Apr 2016 20:16:45 +0000 (13:16 -0700)]
Convert BTIF code from C to C++

Modifications required:
 * added proper casting
 * moved variable definitions before goto statements
 * added 'extern "C"' markers where needed
 * renamed 'operator' to 'operator_name'

Bug: 28485365
Change-Id: I903357967387207e678866c02e008f047f8263f6

8 years agoFix issues during cleanup stage of the Bluetooth stack
Pavlin Radoslavov [Tue, 26 Apr 2016 19:18:36 +0000 (12:18 -0700)]
Fix issues during cleanup stage of the Bluetooth stack

 * Moved free-ing of bta_av_cb timers from the init function
   to the cleanup stage.
 * Changed the usage of btif_jni_disassociate() so it is called
   synchronously. Its previous usage was complicated -
   the function was called asynchronously on a different thread,
   and we had to wait on a future for its completion.
 * Renamed function btif_shutdown_bluetooth() to
   btif_cleanup_bluetooth() to represent better its purpose.
   Similarly, bte_main_shutdown() is renamed to bte_main_cleanup()

Also:
 * Removed function btif_init_fail(), because it is not used.
 * Updated an error log message inside function
   btif_in_execute_service_request() so the log information
   is accurate and more useful.
 * Updated the log messages related to the lifecycle of a module
   in btcore/src/module.c

Bug: 26982349
Change-Id: Icd6f159d993bdb9c8ef09bfb5b1386b3d6ea4ff2

8 years agoHID: Fix compilation error when HID_HOST_REPAGE_WIN is set to 0
Hemant Gupta [Fri, 22 Apr 2016 07:11:39 +0000 (12:41 +0530)]
HID: Fix compilation error when HID_HOST_REPAGE_WIN is set to 0

Update invalid function call to hidh_process_repage_process with
valid function call hidh_try_repage as this was leading to compilation
error when HID_HOST_REPAGE_WIN is set to 0

Change-Id: Ib94233ec83ac30dcae701a16c588a2e2a63cac99

8 years agoDo not log unsolicited NOOP command complete events
Andre Eisenbach [Tue, 26 Apr 2016 16:51:06 +0000 (09:51 -0700)]
Do not log unsolicited NOOP command complete events

Bug: 27744135
Change-Id: I683e3a9f0a116f83763ebcf4d0583ea1c89ef5b2