OSDN Git Service

android-x86/system-bt.git
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

8 years agoFix a race condition during alarm_cleanup()
Pavlin Radoslavov [Mon, 25 Apr 2016 19:29:29 +0000 (12:29 -0700)]
Fix a race condition during alarm_cleanup()

Fix a race condition inside function alarm_cleanup() that
could be triggered during shutdown.

Also, fix few other issues:
 * Add missing "timer_delete(akeup_timer)" statement inside
   alarm_cleanup()
 * Fix the argument when calling "timer_delete(timer)"
 * Call "semaphore_free(alarm_expired)" inside alarm_cleanup()
   after the corresponding "timer" and "wakeup_timer" have
   been deleted.
 * Fix the argument type when calling eventfd_read() inside
   semaphore_wait()

Bug: 26982349
Change-Id: I2b00cd7ee7f56f755775f8e7b370006e31c6eb08

8 years agoUse audio_session_t consistently
Glenn Kasten [Tue, 8 Mar 2016 20:12:33 +0000 (12:12 -0800)]
Use audio_session_t consistently

Bug: 27562099
Change-Id: I10780c8bfc84af568795a2c15557020fbe89a1c4

8 years agoAdd const guarantees
Jakub Pawlowski [Mon, 25 Apr 2016 17:43:02 +0000 (10:43 -0700)]
Add const guarantees

This patch adds const qualifiers to parameter of some methods.
It adds no value right now, but will make conversion of btif to C++
much easier.

Change-Id: I380a63484230f92aedfd4ff5e1ee72f30307d9d9

8 years agoFix a Floating point exception for periodic timers
Pavlin Radoslavov [Wed, 20 Apr 2016 00:30:19 +0000 (17:30 -0700)]
Fix a Floating point exception for periodic timers

Fix a Floating point exception for periodic timers that are
scheduled with interval of 0ms, and add a corresponding unit test.
Also, fix a typo when printing "Action counts" statistics.

Bug: 28278593
Change-Id: Ic381efc573ed9954c36980c26a89318d2de40b29

8 years agoImprove debug-ability of the stack manager
Pavlin Radoslavov [Wed, 20 Apr 2016 02:20:01 +0000 (19:20 -0700)]
Improve debug-ability of the stack manager

Add or update existing log messages in the stack manager,
so it is clear when each of the init/startup/shutdown/cleanup
steps is executed and completed.
The added/updated log messages are at INFO level.

Bug: 26982349
Change-Id: Ie84aa8e96133999eb76c5b351ddd4fea56404ef0

8 years agoAdd missing mutex lock/unlock inside alarm_cleanup()
Pavlin Radoslavov [Wed, 20 Apr 2016 02:16:26 +0000 (19:16 -0700)]
Add missing mutex lock/unlock inside alarm_cleanup()

Bug: 26982349
Change-Id: I32f4e6450491adcc1e12e71fb8bb582d6397a91a

8 years agoFix FD leak caused by module wrapper thread
Manu Viswanadhan [Tue, 19 Apr 2016 09:28:40 +0000 (14:58 +0530)]
Fix FD leak caused by module wrapper thread

Use Case: Repeated BT ON/OFF

Failure: FD leak is observed with ON/OFF stress test
which eventually leads to crash due to unavailability
of FDs.

Steps:
BT ON/OFF.

Root Cause: During cleanup the module wrapper thread is
stopped but the resources are not freed, leading to FD leak.

Fix: Cleanup the module wrapper thread properly so that there
are no resource leaks.

Bug: 28312228
Change-Id: I4de2fba9c98a0e4ae73315759ec6bc8bf273948e

8 years agoFix 64-bit build break.
Dan Albert [Fri, 22 Apr 2016 18:24:14 +0000 (11:24 -0700)]
Fix 64-bit build break.

Master (aosp and internal) has been broken for nearly two days now.

Was broken by https://android-review.googlesource.com/#/c/212244/
because no one checked 64-bit before merging.

No one noticed post-submit because the build servers aren't
checkbuilding any 64-bit targets (aside from mips64, which is broken
for other reasons).

I've uploaded a build change to get treehugger building a 64-bit
target (http://cr/120564724), and also to make all the targets
checkbuilds again (http://cr/120568746).

Change-Id: I195000284de5b52a539a47ad8b308990e72eea96

8 years agoProtect config module init and add date to config file
Ajay Panicker [Mon, 18 Apr 2016 18:31:48 +0000 (11:31 -0700)]
Protect config module init and add date to config file

Bug: 27354612
Change-Id: I45c3c46cf9be81b9d235cfef68343413c98b6d4a

8 years agoMerge "Fix assertion failure in btif_sock_rfc"
Sharvil Nanavati [Thu, 21 Apr 2016 21:54:55 +0000 (21:54 +0000)]
Merge "Fix assertion failure in btif_sock_rfc"

8 years agoAdd missing init/destroy of state_lock mutex
Pavlin Radoslavov [Wed, 20 Apr 2016 19:06:08 +0000 (12:06 -0700)]
Add missing init/destroy of state_lock mutex

Add missing init/destroy of state_lock mutex inside file
btif_sock_l2cap.c.
Also, add a missing unlock for the same mutex.

Bug: 28296454
Change-Id: I48b8deb911d29e8dcc6b7243fd61fc3ba69046dd

8 years agoFix assertion failure in btif_sock_rfc
Sharvil Nanavati [Wed, 20 Apr 2016 17:49:10 +0000 (10:49 -0700)]
Fix assertion failure in btif_sock_rfc

The BTIF RFCOMM code was ignoring the status code on RFCOMM writes. In
the failure case, the slot id is 0 which is invalid. But the slot id
shouldn't even be referenced since the result was failure.

Stack trace:

__assert2+20               bionic/libc/bionic/assert.cpp:40
find_rfc_slot_by_id+18     system/bt/main/../btif/src/btif_sock_rfc.c:144
on_rfc_write_done          system/bt/main/../btif/src/btif_sock_rfc.c:537
rfcomm_cback+632           system/bt/main/../btif/src/btif_sock_rfc.c:585
bta_jv_rfcomm_write+74     system/bt/bta/./jv/bta_jv_act.c:2121
bta_jv_sm_execute+18       system/bt/bta/./jv/bta_jv_main.c:93
bta_sys_event+56           system/bt/bta/./sys/bta_sys_main.c:523
run_reactor+254            system/bt/osi/./src/reactor.c:278
run_thread+142             system/bt/osi/./src/thread.c:209
__pthread_start(void*)+30  bionic/libc/bionic/pthread_create.cpp:199
__start_thread+6           bionic/libc/bionic/clone.cpp:41

Bug: 27819511
Change-Id: Ifcd19fdfb214559f345567f04db8146b30037363

8 years agoFix sluggish HID devices
Bluetooth Build Test [Wed, 13 Apr 2016 14:39:53 +0000 (16:39 +0200)]
Fix sluggish HID devices

Right now, when connecting to HID devices, preferred connection
parameters are not being used. This is because of bug in GAP profile.
This make all HID devices use default connection parameters, which
mean that they behave sluggish. This patch fixes that by forcing
HID devices to re-read connection parameters on each reconnection.

This is a temporary workaround until GAP is rewritten.

Change-Id: I74b70ad8e96c29517cace808632fe4d8e0251994

8 years agoEnable test_vendor_lib compilation on Linux
Bluetooth Build Test [Wed, 20 Apr 2016 19:35:28 +0000 (12:35 -0700)]
Enable test_vendor_lib compilation on Linux

8 years agovendor_libs: create Android.mk
Cristian Iorga [Tue, 15 Mar 2016 14:33:08 +0000 (16:33 +0200)]
vendor_libs: create Android.mk

all-subdir-makefiles call works for only one
nested sublevels, so we need to add a default
Android.mk in order to be able to build libbt-vendor module.

BUG=28014054

Change-Id: I7cc004d2a4dd6216a80d13c6384d9dcde328323e
Signed-off-by: Cristian Iorga <cristian.iorga@intel.com>
8 years agoMerge "vendor_libs: test_vendor_lib: fix build"
Jakub Pawlowski [Wed, 20 Apr 2016 15:51:39 +0000 (15:51 +0000)]
Merge "vendor_libs: test_vendor_lib: fix build"

8 years agovendor_libs: test_vendor_lib: fix build
Cristian Iorga [Mon, 18 Apr 2016 13:09:31 +0000 (16:09 +0300)]
vendor_libs: test_vendor_lib: fix build

Change-Id: I1ba531c5289adea3fa5d6f9e0f68cf241a127219
Signed-off-by: Cristian Iorga <cristian.iorga@intel.com>
8 years agoAdd guest mode functionality (2/4)
Ajay Panicker [Fri, 18 Mar 2016 00:09:24 +0000 (17:09 -0700)]
Add guest mode functionality (2/4)

Add a flag to enable() to start Bluetooth in restricted
mode. In restricted mode, all devices that are paired during
restricted mode are deleted upon leaving restricted mode.
Right now restricted mode is only entered while a guest
user is active.

Bug: 27410683
Change-Id: I19ff91d1d7fb8c60230fee7a05d32574b5b2aeda

8 years agoUse base from libchrome
Jakub Pawlowski [Mon, 18 Apr 2016 17:00:26 +0000 (10:00 -0700)]
Use base from libchrome

Change-Id: I57230618ef8653a168d69f871f88714ab339408a

8 years agoFix Linux libbt-vendor build
Cristian Iorga [Wed, 30 Mar 2016 17:14:36 +0000 (20:14 +0300)]
Fix Linux libbt-vendor build

Fix enumeration values not explicitly handled in switch;
Fix the undefined reference to functions from libosi.

Change-Id: I64ab3d57d1c4879ad47ae1a03f8996287877535d
Signed-off-by: Cristian Iorga <cristian.iorga@intel.com>
8 years agoAllow A2DP SNK audio track focus gain interface.
Sanket Agarwal [Fri, 8 Apr 2016 18:26:04 +0000 (11:26 -0700)]
Allow A2DP SNK audio track focus gain interface.

In order to duck music we need to adjust the gain of the audio track
handled by A2DP SNK. Since SNK is implemented in native we need to add
interface to adjust the gain.

Bug: b/28065071

Change-Id: I60634cfadb502e276596bcb3aafc62ef81d9023a

8 years agoFix LE central device not being able to disconnect
Jakub Pawlowski [Thu, 14 Apr 2016 10:06:54 +0000 (03:06 -0700)]
Fix LE central device not being able to disconnect

This fixes issue introduced in
https://android-review.googlesource.com/#/c/202278

Bug: 28211048
Change-Id: I08e62149358f1c1fc1759a4ca9eb375cb0ad8230

8 years agoAVRCP: Update sdp record correctly for CT or TG.
AnubhavGupta [Tue, 22 Mar 2016 18:03:33 +0000 (23:33 +0530)]
AVRCP: Update sdp record correctly for CT or TG.

 -Issuses: SDP records are faulty
  - AVRCP versions are faulty
  - Nexus configuration shows browsing supported
  - Both Cat-1 and Cat-2 is supported for Nexus CT

 -Solution
  - pass sdp version as parameter
  - update sdp records for avrcp controller in case of client
    profiles being enabled
  - BTA_AV_FEAT_BROWSE flag was incorrecly set during AV registration
    causing AVRCP TG version to upgrade to 1.4 even though browsing
    feature is not supported.
  - Use AVRC_CTLR_INCLUDED feature flag instead of AVRC_ADV_CTRL_INCLUDED
    for guarding Avrcp controller code in build/parse apis for
    command/response
  - update categories supported for CT properly for mobile phone config

Bug: b/28149547

Change-Id: I3ff4082453a2624a72d8f152d75af83a8efb4937

8 years agovendor_libs: linux: Fix build
Cristian Iorga [Thu, 14 Apr 2016 08:00:28 +0000 (11:00 +0300)]
vendor_libs: linux: Fix build

LOG_DEBUG, LOG_VERBOSE definition changed in libosi.
This triggers:
"error: use of undeclared identifier 'true'" at
build time. Fixed by the inclusion of stdbool.h.

Change-Id: Ie2ed0d6b07bc28c26669b19a2584ea248e2782a9
Signed-off-by: Cristian Iorga <cristian.iorga@intel.com>
8 years agoMerge "HID: Fix regression caused by commit "3a2c2d61""
Treehugger Robot [Thu, 14 Apr 2016 20:27:53 +0000 (20:27 +0000)]
Merge "HID: Fix regression caused by commit "3a2c2d61""

8 years agoAllow unused private field
Christopher Wiley [Thu, 14 Apr 2016 17:32:56 +0000 (10:32 -0700)]
Allow unused private field

This field is unused when we build unittests for OSX.

Bug: 28117776
Test: Compiles

Change-Id: I6add6946896a8cc2838309e6188812d4c7c497cb

8 years agoEnsure PIN code dialog is shown after remote name request
Andre Eisenbach [Wed, 13 Apr 2016 16:44:00 +0000 (09:44 -0700)]
Ensure PIN code dialog is shown after remote name request

If pairing is locally initiated and results in a remote name request
being performed before the PIN code is requested, then the PIN code
dialog will not be shown correctly.

This patch removes the check for locally initated pairing to ensure the
dialog is shown in all cases.

Bug: 27347017
Change-Id: I607c1c071af502fb2990b14cce676590e577b4c2

8 years agoMove autopair blacklist to interop database
Andre Eisenbach [Mon, 11 Apr 2016 21:50:41 +0000 (14:50 -0700)]
Move autopair blacklist to interop database

Blacklist by partial name etc. was not working and had no effect; all
BDAs in the config file start with 00:, which is implausible at best, so
deleted...

Added new mechanism to blacklist by BDA only initially and added Subaru
car kit to blacklist.

Bug: 27347017
Change-Id: Ie2941cb1ab663b5444b02c44f85032f13be4ab46

8 years agobtif: add count of devices loaded on startup
Marie Janssen [Wed, 13 Apr 2016 19:43:03 +0000 (12:43 -0700)]
btif: add count of devices loaded on startup

Report devices initially loaded from the config file.

Also removes the config mutex from btif_debug_config_dump as the config
is not modified.

Bug: 27354612
Change-Id: I25033ce28744051412f0d2bd554f0651e807ba7c

8 years agoMerge "Fix use of uninitialized value in btm_acl_update_busy_level"
Sharvil Nanavati [Wed, 13 Apr 2016 18:53:16 +0000 (18:53 +0000)]
Merge "Fix use of uninitialized value in btm_acl_update_busy_level"

8 years agoMerge "Fix use of uninitialized value in BTA_PanSetRole"
Sharvil Nanavati [Wed, 13 Apr 2016 18:53:12 +0000 (18:53 +0000)]
Merge "Fix use of uninitialized value in BTA_PanSetRole"

8 years agoFix use of uninitialized value in btm_acl_update_busy_level
Sharvil Nanavati [Mon, 11 Apr 2016 00:29:11 +0000 (17:29 -0700)]
Fix use of uninitialized value in btm_acl_update_busy_level

Caught by valgrind:

Thread 7 bt_jni_workqueue:
Conditional jump or move depends on uninitialised value(s)
   at 0x5682870: btif_dm_upstreams_evt (btif_dm.c:1800)
   by 0x56817EF: btif_context_switched (btif_core.c:180)
   by 0x56817EF: bt_jni_msg_ready (btif_core.c:290)
   by 0x571D1D7: work_queue_read_cb (thread.c:233)
   by 0x571C1F9: run_reactor (reactor.c:275)
   by 0x571CF3D: run_thread (thread.c:206)
   by 0x4A5B7B3: __pthread_start(void*) (in /system/lib/libc.so)
 Uninitialised value was created by a stack allocation
   at 0x56D9CC6: btm_acl_update_busy_level (btm_acl.c:503)

Bug: 28113318
Change-Id: I21ffa2f6c48d3bb96dcdc71fee6ab74634e57333

8 years agoHID: Fix regression caused by commit "3a2c2d61"
Hemant Gupta [Wed, 13 Apr 2016 11:12:18 +0000 (16:42 +0530)]
HID: Fix regression caused by commit "3a2c2d61"

uhid_event function returned 0 in normal case and with below
commit polling thread was being exited resulting in user space
not able to read the events sent by uhid kernel driver leading
to IOT issues with HID devices using the vendor hid usb drivers.
Eg: Apple Magic Mouse scroll functionality was not working as
for normal functionality of Apple Magic mouse, output report
needs to be sent to hid device, which was not being sent with
current implemenation.

commit 3a2c2d61f4c8769ea9c1615208a6daf2fa162084
Author: Myles Watson <mylesgw@google.com>
Date:   Tue Nov 10 14:35:57 2015 -0800

    Retry HID Polling when EINTR is returned

    While I'm here
     - use __func__ consistently in btif_hh_poll_event_thread.
     - remove braces around a single line

    BUG: 24647083
    Change-Id: I80b99ff0d3ba6336f5ab7a517269fdf63df59b37
Signed-off-by: Myles Watson <mylesgw@google.com>
Change-Id: If1f69c8d024fd7d03e2d79f19b962653fe2dd8b9

8 years agoMerge "Pull in libmedia's exported headers in libbtif"
Treehugger Robot [Tue, 12 Apr 2016 21:14:33 +0000 (21:14 +0000)]
Merge "Pull in libmedia's exported headers in libbtif"

8 years agoFix use of uninitialized value in BTA_PanSetRole
Sharvil Nanavati [Mon, 11 Apr 2016 00:15:29 +0000 (17:15 -0700)]
Fix use of uninitialized value in BTA_PanSetRole

Caught by valgrind:

Conditional jump or move depends on uninitialised value(s)
   at 0x57616E8: PAN_SetRole (pan_api.c:170)
   by 0x56C0193: bta_pan_set_role (bta_pan_act.c:370)
   by 0x56BFD65: bta_pan_hdl_event (bta_pan_main.c:387)
   by 0x56D24DD: bta_sys_event (bta_sys_main.c:495)
   by 0x5777029: run_reactor (reactor.c:275)
   by 0x5777D6D: run_thread (thread.c:206)
   by 0x49A77B3: __pthread_start(void*) (in /system/lib/libc.so)
 Uninitialised value was created by a heap allocation
   at 0x495883C: malloc (in /system/lib/valgrind/vgpreload_memcheck-arm-linux.so)
   by 0x5774857: osi_malloc (allocator.c:67)
   by 0x56C07A9: BTA_PanSetRole (bta_pan_api.c:107)
   by 0x56FBF31: btpan_enable (btif_pan.c:226)
   by 0x56DB3AB: btif_enable_bluetooth_evt (btif_core.c:524)
   by 0x56DE3EB: btif_dm_upstreams_evt (btif_dm.c:1742)
   by 0x56DC60F: btif_context_switched (btif_core.c:180)
   by 0x56DC60F: bt_jni_msg_ready (btif_core.c:290)
   by 0x5778007: work_queue_read_cb (thread.c:233)
   by 0x5777029: run_reactor (reactor.c:275)
   by 0x5777D6D: run_thread (thread.c:206)
   by 0x49A77B3: __pthread_start(void*) (in /system/lib/libc.so)

Bug: 28113318
Change-Id: Icdba2b7a557254d29f8c3a62c6d1a7aafa4fdde4

8 years agoRemoved unused functions
Pavlin Radoslavov [Thu, 7 Apr 2016 18:47:48 +0000 (11:47 -0700)]
Removed unused functions

Removed unused functions and defines that are not needed:
 - l2c_bcst_msg()
 - GAP_ConnBTWrite()
 - gap_proc_btu_event()
 - AVDT_WriteDataReq()
 - L2CAP_BCST_MIN_OFFSET
 - L2CAP_BCST_OVERHEAD
 - AVDT_MAX_MEDIA_SIZE
 - LOG_NDDEBUG in btif/src/bluetooth.c

Bug: 28068134
Change-Id: If0edda2bf86caf83027db2c897537c82a0d80667

8 years agoPull in libmedia's exported headers in libbtif
Christopher Wiley [Mon, 11 Apr 2016 22:14:23 +0000 (15:14 -0700)]
Pull in libmedia's exported headers in libbtif

Do this by listing libmedia as a shared library linked by libbtif.
We won't actually be able to link against libmedia because static
libraries don't work like that, but surrounding logic about headers
is triggered.

Bug: 27804373
Test: libbtif compiles in the presence of a new exported header path
      in libmedia.

Change-Id: Ic1e776966daaf70b7b9ae6ea99af89bc9a0b3885

8 years agoFix ambiguous base::TimeDelta reference
Christopher Wiley [Mon, 11 Apr 2016 22:18:14 +0000 (15:18 -0700)]
Fix ambiguous base::TimeDelta reference

base::TimeDelta cannot be resolved when both libbase's
android::base namespace and libchrome's base:: namespace
are included via transitive header dependencies.

Bug: 27804373
Test: Compiles.

Change-Id: I9854c92763728fb85ad21183f37c94a4d7bd61a5

8 years agoTrigger a compilation error when LOG_TAG is not provided
Jakub Pawlowski [Mon, 11 Apr 2016 08:54:54 +0000 (01:54 -0700)]
Trigger a compilation error when LOG_TAG is not provided

When compiling for OS_GENERIC, lack of LOG_TAG causes a compilation error.
Most developement happens on Android, which compiles this without an
error. This patch triggers a compilation failure on Android when LOG_TAG is not
provided.

Bug: 28118588
Change-Id: I316aa01952fb88d77bbabb197c77e4287a3fc39b