History log of /system/bt/btif/src/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
e6560eec3e6572898dc82e7a2154c118bdf371a7 09-Aug-2017 Andre Eisenbach <eisenbach@google.com> SDP: Bounds check 'id' parameter for free_sdp_slot()

Merged-In: I34e8296ec7ec6b4ffbe1fa0452754f2a421e6ec7

Test: manual
Fixes: 37502513
Change-Id: I34e8296ec7ec6b4ffbe1fa0452754f2a421e6ec7
(cherry picked from commit b413f1b1365af4273647727e497848f95312d0ec)
(cherry picked from commit 82e4754aaafe820619a51f8eeaa858db8735d9c1)
tif_sdp_server.c
5a9925784a4a34811ae29608b67dee4a580c226b 20-Jan-2017 Jack He <siyuanh@google.com> Corrected default value assignments in Bluetooth A2DP Metrics

* In certain cases btif_media_task_stop_aa_req() could be called before
btif_media_task_start_aa_req() is called, resulting in session_start_us
to be 0. In this case, audio_duration_ms = time_now_us() - 0 will be a
very large number that is not the actual audio duration.This CL marks
audio_duration_ms as -1 in the above situation so that we can
differentiate between valid and invalid audio durations
* Set default timer and counter values to 0 when
tx_queue_dequeue_stats.total_updates > 1
* Move update_scheduling_stats for tx_queue_enqueue_stats to
btif_media_task_aa_handle_timer as we intend to capture the time
intervals for enqueue scheduling instead of time intervals between
frame enqueue (i.e. one scheduling event can enqueue multiple frames)
* Use tx_queue_enqueue_stats instead of *dequeue* since only enqueue is
triggered by timer event

Bug: 33694310
Test: Code compilation, BtFunhausMetricsTest
Change-Id: I10984920afd4d77f07a5ac75736f8dcd69b13af8
tif_media_task.c
7ab4b59672013eddcb706e288962ab7309a75628 18-Jan-2017 Jack He <siyuanh@google.com> Fix A2DP Metrics Logging Capacity

* Set the maximum number of wake events logged to 1000
* Stop logging wake log name as it takes too much memory
* Add counters for each of the repeated values in BluetoothLog so that
the true number of events can be determined while oldest event get
dropped
* Log Bluetooth session disconnect reasons using enum instead of string
in order to save memory usage
* Apply changes to bluetooth.proto in ag/1460462 on system/bt

Bug: 33694310
Test: Code compilation and unit tests
Change-Id: I2cc6f9304725938b63b211d615eb1941eac60edf
tif_media_task.c
4f92ffdeb14bd621f2e197a0270e85a50053cdbd 10-Jan-2017 Gurpreet Ghai <gghai@codeaurora.org> Serialize stack shutdown, state change callback and cleanup
am: 352b8e89ea

Change-Id: Icace606e4c596074c4a120678d65511c78f683c4
14248c4ce8cb2a4e156006a868ef6f0ad0d41fa6 09-Dec-2016 Jack He <siyuanh@google.com> Fix A2DP metrics session duration

* Fixed A2DP duration counting. It is now counting from music play start
to music play end.
* Start logging a2dp connection as Bluetooth sessions. Currently, only
A2DP connections are logged. Thus the bluetooth session length will be
the total connection length and the length within A2DP session message
will be the audio connection length.
* Add a audio_duration_millis field in A2DPSession to record audio duration
* Add bonded memory constraint for metrics entries
* Use a builder mechanism to only build metrics upon dumping
* Refactor metrics module into BluetoothMetricsLogger class
* Created unit test for BluetoothMetricsLogger

Bug: 33694310
Test: Code compilation, Unit test, BtFunhausMetricsTest
Merged-In: Iea2a997c4ea074687a5d50860e9229f0e1b82659
Change-Id: Iea2a997c4ea074687a5d50860e9229f0e1b82659
(cherry picked from commit f3175629208a64b190dde4dcf5f92cacef70d3e9)
luetooth.c
tif_dm.c
tif_media_task.c
352b8e89eac539fe45b3f4314cd111eff38b9e1e 12-Sep-2016 Gurpreet Ghai <gghai@codeaurora.org> Serialize stack shutdown, state change callback and cleanup

Use Case: Bluetooth On/Off scenario, User switch

Steps:
1. Turn ON Bluetooth
2. Switch user
Also observed on occurrence of enable/disable timeout during On/Off testing.

Failure: Crash while sending state change HAL callback.

Root Cause: In the event when stack cleanup is queued to stack manager
thread when stack shutdown is being processed, stack cleanup starts
execution as soon as stack shutdown is finished.
If the function event_signal_stack_down posted to btif thread at the
end of stack shutdown is executed after stack cleanup crash occurs.

Fix: Serialized the execution of stack shutdown, state change callback
execution and stack cleanup to happen in same order.

Test: code compilation.

Change-Id: Ic96205b5c304acb44eab53f4e2cb150726643bda
(cherry picked from commit 16e112b1861d8f1147325372608c905627e00e88)
tack_manager.c
5e7cf0c1640c408f00173c228d111558091ebe9a 11-Nov-2016 Jakub Pawlowski <jpawlowski@google.com> Fix incorrect check for empty out-of-band pairing data

Bug: 32780409
Test: try pairing with nRF52DK using OOB LE SC
Change-Id: I3c165843bb76c372b76bdc18a7d9226345d39037
(cherry picked from commit a638cc509bf8fe4157c0aa5d3e39011063d3587a)
tif_dm.c
76f0078459f751ddb4a85adf89b86a801c05f328 10-Nov-2016 Jakub Pawlowski <jpawlowski@google.com> BLE OOB Pairing - parse address type (1/5)

When address type is not parsed, creating bond to devices not using
random address is impossible.

Bug: 32780409
Test: try pairing with nRF52DK using random address
Change-Id: Idc0315e9e3f9e17c3cf56fa483c8e21eb3590f01
(cherry picked from commit 7921e8f594079e00e90173a8fe7483ad72443b34)
tif_dm.c
59e0b06149584a9ded4efe4de5c24d0e84535fd0 28-Jul-2016 Jakub Pawlowski <jpawlowski@google.com> Add LE Secure Connection data parsing (3/4)

Bug: 30460956
Change-Id: I216142090fe99b25ef7697fceceb278b761a182b
tif_dm.c
d14ee8b81854452b713b0c04da5c2194411e5238 03-Nov-2016 Andre Eisenbach <eisenbach@google.com> [DO NOT MERGE] Remove incorrect assert in btm_read_rssi_cb

|data| may be NULL if the RSSI request times out.
See btm_read_rssi_timeout implementation for details.

Bug: 32587130
Test: manual
Change-Id: Ide9dee819e1db24a39c05b086cd4c0b558ca23ef
tif_media_task.c
eac369fc1713966a6394576670b972d8d028e976 28-Oct-2016 Jacky Cheung <jackyc@google.com> DO NOT MERGE ANYWHERE Auto Connection Parameter Update for Whitelisted Address

Auto adjust connection interval parameter after a certain idle
period on the connection.

BUG: 32380838

Change-Id: I28cf4f6d5dcfb7a0bfb6aa652d939e16fbdcdcde
tif_dm.c
tif_gatt_client.c
f4314979baa2cbee2ccb34eda063f9e697651acf 28-Oct-2016 Jacky Cheung <jackyc@google.com> DO NOT MERGE ANYWHERE LE Connection Parameter Update Callback

The callback ends at the btif layer and does not go up to the HAL layer.
Event logging is added to track success rate.

BUG: 28800115

Change-Id: I73ad281437760e1d61dd4e504401b270eb77e3e6
tif_gatt_client.c
0cb0e9346d4aa06f4a04261b6f99f5124c7c6cc8 19-Oct-2016 Jacky Cheung <jackyc@google.com> DO NOT MERGE ANYWHERE Add Wear-specific feature to override LE IO capability

Force the first bond to use Just Works pairing when
WEAR_LE_IO_CAP_OVERRIDE is set to TRUE.

Bug: 32234733
Change-Id: I1732be86dd888586c603112fb6c3010974b54a13
tif_storage.c
7edffcd4746841a24ceb35f46fcfbb4bec7078fe 27-Sep-2016 Jakub Pawlowski <jpawlowski@google.com> Fix unnecessary error message during GATT discovery
am: f2e3bea844

Change-Id: Ied4363b52980f4a1e146c6186ffe920770f65866
f2e3bea844ea343c80c219f2dc59a75ea57f50c2 26-Sep-2016 Jakub Pawlowski <jpawlowski@google.com> Fix unnecessary error message during GATT discovery

Bug: 31637098
Change-Id: Ib2545e7827bd338d2e22c88836818fce23e7a057
tif_gatt_client.c
7b50114544f03082890e8e3d6193bde601383fa2 16-Sep-2016 Jakub Pawlowski <jpawlowski@google.com> Add a missing case for BTA_DM_SEARCH_CANCEL_CMPL_EVT
am: 5f98c2410f

Change-Id: Ic93722a25b865313ef94fcd84a7008b737f8a567
5f98c2410fd68bbf06f5a33e75036e9b10b2145d 15-Sep-2016 Jakub Pawlowski <jpawlowski@google.com> Add a missing case for BTA_DM_SEARCH_CANCEL_CMPL_EVT

Cancelling discovery was not handled properly in
btif_dm_search_services_evt and was causing crashes due to assert in
default case.

Bug: 31442085
Change-Id: If9a2c203730c9b06df5ff8d8e251f0c35addcb82
(cherry picked from commit 7df43240c4a7cf5ecd58a39f03d235bf52929d79)
tif_dm.c
854768185802a50f52df3cd2c8f65bf03b18cd75 19-Aug-2016 Jakub Pawlowski <jpawlowski@google.com> Make gatt_attr use opportunistic connection
am: 8ed030ff4a

Change-Id: I7f9926fa32daaf286de667b9faf8ef92f81d43f2
8ed030ff4a36b248e1b115f94ddd4650d4b5e360 18-Jul-2016 Jakub Pawlowski <jpawlowski@google.com> Make gatt_attr use opportunistic connection

This patch creates new connection mode - opportunistic connection. When
such connection is made, no call to gatt_update_app_hold_link_status
will be made when it's started.

This means that connecting and disconnecting in this mode won't trigger
disconnect timer. When other, app creates regular connection and then
disconnects, the physical connection might get disconnected.

Opportunistic connection is used only for code setting CCC right now.

Bug: 30186455
Change-Id: Ia5be7682b6c3dcb4993060f818dee603aef3e19e
tif_gatt_test.c
87c30d8eea0584b2a80bda343ee79aa52c4193dd 05-Aug-2016 Jakub Pawlowski <jpawlowski@google.com> Fix APR crashes in read rssi callback
am: 17be4ae79a

Change-Id: I3d36ea5bc06e20be72103c9028e2719bc393a4de
17be4ae79a4d2890398a31bc15eedbe083b4142c 05-Aug-2016 Jakub Pawlowski <jpawlowski@google.com> Fix APR crashes in read rssi callback

When read RSSI timeouts, callback is called with NULL result. This was
causing crash.

Bug: 30562545
Change-Id: If379c2de4ceab48c021601851a8c83f995440460
tif_gatt_client.c
99abd318ba26480d38500da9dfd8eece68e7aa25 30-Jul-2016 Jacky Cheung <jackyc@google.com> Add dumpsys support for LE connection parameter updates

Change-Id: Ia79483c72d3b0cfc1e339f9f4ac65295e68e8e5d
luetooth.c
tif_debug_l2c.c
b82a27ed327739ca5de7924cc577f5bfb8b8060b 22-Jul-2016 Ayan Ghosh <abghosh@codeaurora.org> Proper handling of AV connection collision

Use case:
1. Pair to Remote
2. Turn OFF/ON BT on DUT
3. After DUT's BT is turned ON, Remote would reconnect to DUT

Failure:
Bluetooth settings UI continues to display Connecting when
BT was Turned OFF and ON.

Root cause:
- This is a connection collision case where remote is not responding
to DUT initiated SDP attribute fetch request for AV. AV holds outgoing
connection for sometime and meanwhile remote starts AV connection
from its end. Then DUT disconnects the SDP channel after a second
without waiting to fetch requested info, and this confuses DUT's AV
state machine. The outgoing connection could not proceed as incoming
AV L2CAP connects, because DUT's AV state machine is not equipped
with handling this scenario. On incoming connection timer expiry, it
does not start AV media channel as it finds AV Open has not been done
from upper layer after incoming L2CAP got connected.

- When the incoming path 2s timer expires, the DUT checks whether Open
has been called after incoming state is set. This is not the case here,
because Open was triggered earlier as as part of the outgoing
connection. As a result, A2DP cannot connect at all.

Fix:
- Properly set collision flags for handling AV connection collision.
- Update BTA AV handle even when BTIF AV state machine is yet to be built.

Bug: 30362987
Change-Id: I02a3adb62479b0f762bc792a5727d06e11eaaa52
(cherry picked from commit db1e3a5fbb41cd1faf572c5f89ec9212c5ff2986)
tif_av.c
ecfeff6782aeb61adfaf19f70e6a55ff97c3a9d6 30-Jun-2016 Ajay Panicker <apanicke@google.com> Add logs for AVRCP commands that originate from a remote device

Change-Id: I02b213913685d831bfe00e1938baef953428e048
tif_rc.c
6984b19d95736d7205fc6302a21e8be564617287 07-Jul-2016 Jacky Cheung <jackyc@google.com> New status code for two SMP authorization failures

On BTA_DM_AUTH_SMP_UNKNOWN_ERR and BTA_DM_AUTH_SMP_CONN_TOUT, bond state
status will be notified as BT_STATUS_AUTH_FAILURE. This is observed during
the pairing flow with iOS devices.

Plus minor cleanup on SMP errors and fail reasons.

Bug: 29779689
Change-Id: Ia32fe6bb84b07272d5159409f65217a06a2e5f8e
tif_dm.c
21f534ba2a47ee3fae5cb0b30ecd069f6caef295 07-Jul-2016 Andre Eisenbach <eisenbach@google.com> Disable auto-pairing for hands-free devices

Fixes: 30004157
Change-Id: Id170856fbee5ea345f02f55d3a6e3376d846c2de
tif_dm.c
b4a1f3abe22831d654dea4f386b747f8d5e928cf 23-May-2016 Jacky Cheung <jackyc@google.com> Add BT_HCI_TIMEOUT and BT_CONFIG_SOURCE log events.

These events are used to track HCI timeout and configuration file
usage respectively.

Change-Id: I5c8b6ef20b61f03b9ccb74f3b1c9784e4653b770
tif_config.c
ade5776f2b292c4dcb367aaf542d3e5d7956c4cd 29-Jun-2016 Andre Eisenbach <eisenbach@google.com> Log RSSI when A2DP buffers are flushed

To add another datapoint and potentially narrow down *why* we had to
flush the buffers, add RSSI logging to keep track of signal strength
during audio drop-out events.

Change-Id: Ie52f56290951130165a9f375a898a9bacf459d55
tif_media_task.c
1a1fc4959eb48c8d0ee100aa2f19c6c0321352b0 25-Jun-2016 Andre Eisenbach <eisenbach@google.com> A2DP media task: Flush full TX queue on congestion
am: d881c4b467

Change-Id: Ie00432fcec7e869c212a04374d6fcd58094eb643
d881c4b46776fe03a5861a3021bbe739b1f3cc58 24-Jun-2016 Andre Eisenbach <eisenbach@google.com> A2DP media task: Flush full TX queue on congestion

Currently, our TX queue does not allow for quick recovery of minor
congestion. As we only clear as much room in the queue as is needed to
fix the news frames needed for a given timer tick, any minor congestion
on the TX path can result in single frames to be dropped over an
excessively long amount of time.

From the "just rip the band-aid off" school of thought, drop the whole
queue instead to cause a single drop-out on congestion and catch up to
the live stream immediately, hoping that the stream recovers...

Bug: 29601962
Change-Id: I482c3cfef6d8b51143e54733eb2da5f70663636f
tif_media_task.c
c0fe2498468b64d3ae37d339dabf1012728062f9 24-Jun-2016 Andre Eisenbach <eisenbach@google.com> Merge \"Remove SBC frame scrambling\" into nyc-dev
am: 6b142ed4b5

Change-Id: I7dd99e2af5ec4b09a9cba9830df9cf0c677ca46b
b97a1599e74020aa4dc5d88496c1912fa6e4b296 24-Jun-2016 Andre Eisenbach <eisenbach@google.com> Remove log spam in btif_gattc_update_properties
am: ffdb33b5fc

Change-Id: I1df2268b7ddd28220f69d4eeeaee30097a976e7c
6b142ed4b50a47b41a080fea12ad1c182062e58c 24-Jun-2016 Andre Eisenbach <eisenbach@google.com> Merge "Remove SBC frame scrambling" into nyc-dev
470aee234664fd75094c16dd2c70313ee28354c1 24-Jun-2016 Andre Eisenbach <eisenbach@google.com> Remove SBC frame scrambling

Bug: 29601962
Change-Id: I30ce09f1c7550a1be9fd1c8ed70745f9aa0cdb44
tif_media_task.c
ffdb33b5fcfa0a652e9fa368f7f8c3bb0654b46e 23-Jun-2016 Andre Eisenbach <eisenbach@google.com> Remove log spam in btif_gattc_update_properties

Bug: 29601962
Change-Id: I4a86b786609b0203a72b750a1c4a38c82fcc5f97
tif_gatt_client.c
a3e2f211f65499232b14e6bb3fa5555eb85691dd 17-Jun-2016 Pavlin Radoslavov <pavlin@google.com> Add missing NULL pointers assignments
am: ba64c39c8c

Change-Id: I4c010baf150c5daf88de73efdc3041a30cf90ddd
ba64c39c8caa2f04f3d78765b48d661b7e9d19ee 17-Jun-2016 Pavlin Radoslavov <pavlin@google.com> Add missing NULL pointers assignments

Each pointer that was freed by one of the following functions should
be reset to NULL:
- config_free()
- data_dispatcher_free()
- fixed_queue_free()
- list_free()

Bug: 29421693
Change-Id: Ie55a04ed986393994564edcf872d7413b0767a85
(cherry picked from commit 8cbc291080730cd7d04990a8fc0e11249b06aa08)
tif_hl.c
tif_sock_rfc.c
8bba740103cc6a2ff78ab51bc31b495bef7f5aee 10-Jun-2016 AnubhavGupta <anubhavg@codeaurora.org> Do not request AVRC_CAP_COMPANY_ID if A2DP Sink is not enabled
am: 470466e6be

Change-Id: Ibc2f939f4e07dcccac95c88b8ac163d9a22586ff
470466e6beea7ee10675ec780a2afa23bd8a3cd4 06-Apr-2016 AnubhavGupta <anubhavg@codeaurora.org> Do not request AVRC_CAP_COMPANY_ID if A2DP Sink is not enabled

Also fixed AVRC_PDU_GET_PLAY_STATUS timeout response.

Bug: 28177785
Change-Id: Icde64a5c1806453850abe101f9707fff61566566
(cherry picked from commit 1c512b851d76deac860fce1232e4a1fa1a097f1c)
tif_av.c
tif_rc.c
82fd51249a4bdfe3f308cc40a084e9c11761eefc 08-Jun-2016 Nitin Arora <niarora@codeaurora.org> Remote device changes for SMP certification
am: 9ded3b71de

Change-Id: I94cf61e64d92b8bf2658941059507958c7feec75
9ded3b71deeb06a6de8bdba36dca198d481ca34c 15-Mar-2016 Nitin Arora <niarora@codeaurora.org> Remote device changes for SMP certification

Use Case:
Certification test cases for SMP require various scenarios
where the remote device needs to show a specific behavior
where it fails the pairing in a certain way, and the DUT is
required to abort the pairing properly.
In abcense of a proper PTS suite to execute these test cases,
we can use another device running the same host by configuring
certain run time property.

Test Cases:
TP/SCJW/BI-02-C
TP/SCJW/BV-02-C
TP/SCPK/BI-03-C
TP/SCPK/BI-04-C
TP/SCPK/BV-02-C
TP/SCPK/BV-03-C
TP/SCJW/BI-01-C
TP/SCCT/BV-01-C
TP/SCCT/BV-02-C
TP/SCPK/BI-01-C
TP/SCPK/BI-02-C
TP/SCPK/BV-04-C
TP/SCPK/BV-01-C

Fix:
Added a property in the bt_stack.conf file. The property name
is "SmpFailureCase". The values 2 to 6(inclusive), are forcausing SMP
failures with various failure reasons.
Failure case 1 and 9 are for producing error "Confirm value failure".
Cases 7 and 8 are for generating specific errors at pair cancel.

Note:
The default use of this feature is controlled using a compile
time flag BTM_BLE_SMP_CERTIFICATION.
The BTM_BLE_SMP_CERTIFICATION = TRUE is needed only while we
wait for the PTS support for the LE Secure connections.

Bug: 27852645
Change-Id: I1f7a8ff2659d85b5978b75870c57162a34d394d0
(cherry picked from commit 0bd0c8fc88a7141691a7ca839b11cb711945ee33)
tif_dm.c
e5bed64926d6ae45501617052f90932287da135b 29-Feb-2016 Mudumba Ananth <ananthm%broadcom.com@gtempaccount.com> HFP 1.7 profile update (1/4)

-> Added AG support for HFP 1.7 version upgrade which
adds new type of indicator called HF(headset) indicators.
-> Added support for two new AT commands AT + BIND and AT + BIEV
which have been appended to Hands-Free SLC sequence.
-> Added support to propagate the above commands and their data to
the upper layers.

Bug: 19983867
Change-Id: I93d5b2af949f9fb99507a954e623cd0927ddc976
tif_hf.c
tif_util.c
3114ad623ca39bf6cbcee7f4841c00077faafcba 19-May-2016 Jacky Cheung <jackyc@google.com> Improve config file sync during configuration save.

Add fsync() calls to force sync to disk while saving configuration
file. It is necessary to do a sync on the temp file before rename,
and to sync again on its parent directory to ensure both the
file content and the directory are up-to-date.

Bug: 27354612

Change-Id: I3a862ad59c8ae5beb8ea2c727eb5f275a2d5823e
(cherry picked from commit 95dbe03a693f4a920204b8c6acbba5269915a59f)
tif_config.c
8bbbee165d2c8bb17353b11de1a3e74e089eff73 11-Nov-2013 Ayan Ghosh <abghosh@codeaurora.org> Limit number of SBC frames to fit into single MTU

- Calculate number of SBC frames to fit into single MTU for EDR capable
remote devices. This makes sure the maximum utilization of the
available bandwidth, keeping the bitrate at high quality.
- This change helps to address the discrepancy seen with a few available
2 Mbps headsets which set the AVDTP media MTU size greater than the
2DH5 packet payload size which eventually forces AVDTP packets to get
fragmented in the controller. This change ensures packing of the SBC
frames in a way that AVDTP packet size fits within the 2DH5 payload
size.
- As packet size is restricted to meet the required bit rate more than
one AVDTP packet can be sent to the controller in a given iteration
based on the bit rate requirement.

Bug: 24875861
Change-Id: Icae7656ad563bbbdef65ecbfa15a89b26cf9edb2
tif_av.c
tif_media_task.c
d76f9fd10a809bc63fb5815fbf66a1caf0e0cd4b 24-May-2016 Jakub Pawlowski <jpawlowski@google.com> Fix crashes in btif_sendmsg when worqueue not initialized

Instead of crashing whole stack when trying to post task to
uninitialized queue, log error message. This can happen in two cases:
stack is not initialized yet, or we're shutting down and already cleaned
up the workqueue thread.

Bug: 28889608
Change-Id: I9b8652d27abc2489b2489997c928634b68433a3e
tif_core.c
0821bffadc77a3fd0a9a191dc23ffd2c4c9c81c1 20-May-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Improve poll(2) handling and log messages" into nyc-dev
1817d9d5329d65ccb9ec44f2e30727d4c3097e86 18-May-2016 Pavlin Radoslavov <pavlin@google.com> Improve poll(2) handling and log messages

* Better error handling and log messages inside
uipc_flush_ch_locked()
* Add missing error check inside UIPC_Read()
* Add missing OSI_NO_INTR() wrapper around poll()
inside function btu_exec_tap_fd_read()

Bug: 28823662
Change-Id: I5f1c720861bea594d53ed6465a5ff327ba352598
tif_pan.c
aee67ece726e9b5d0e2e02562fe013ae85c46d63 18-May-2016 Pavlin Radoslavov <pavlin@google.com> Add error log messages for A2DP commands

Bug: 28823662
Change-Id: Ifa9950dd2277b444bedd5108beff2db029a5ed93
tif_media_task.c
6ea2168e8f65b43431381ea364939ec5738258e0 19-May-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Add L2CAP signaling headers and more ACL data to btsnooz" into nyc-dev
ae3ba35cfd03f21225bbf58dd3d5f0034b13fe09 17-May-2016 Andre Eisenbach <eisenbach@google.com> Add L2CAP signaling headers and more ACL data to btsnooz

Increase the BTSNOOZ log buffer to 256kb and adds complete L2CAP
signaling headers as well as more data per ACL data packet. This will
allow additional RFCOMM debugging.

Fixes: 28845518
Change-Id: I19e1a4a40bb1c8d332a25283fb50635d791bc275
tif_debug_btsnoop.c
180b9725ee4f5d342b72d5f718762db64201e8b8 14-May-2016 Pavlin Radoslavov <pavlin@google.com> Add missing arguments to log messages

Bug: 28769522
Change-Id: I37c2b8400619646a8711099cf0bd369c3cf8eb51
tif_hh.c
b7e9cb4c35abbacce5313c6f1e2f5a51dc0946bb 13-May-2016 Ajay Panicker <apanicke@google.com> Add sync to write the backup file to the filesystem

Bug: 27354612
Change-Id: I5a7751b6f08831d43647391774501f211336e9eb
tif_config.c
9eb556804ae753b6fabc66329952dae596f378b7 12-May-2016 Ajay Panicker <apanicke@google.com> 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
tif_config.c
49196d04536bfd22534d1080236a983f49ef8a2e 13-May-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Restart failed system calls interrupted with errno of EINTR" into nyc-dev
574dcfb73e3741d715f7d4394fe5d3bd587cb0d2 12-May-2016 Pavlin Radoslavov <pavlin@google.com> 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
tif_hl.c
tif_pan.c
tif_rc.c
tif_sock_l2cap.c
tif_sock_rfc.c
tif_sock_thread.c
tif_sock_util.c
86453b65c60aec465f8e32cf515944f3f69db809 11-May-2016 Marie Janssen <jamuraa@google.com> btif: only save config when bonded devices change

Bug: 27354612

Change-Id: I15f816c85d3ab1991abf076f7c1ae2914d773d54
tif_storage.c
c04eb3d3bc80e056af87bc3a82037d145d99937e 11-May-2016 Andre Eisenbach <eisenbach@google.com> Merge changes I693b0596,Ib5a05c47,I1da213fd,I32cd6412,If62f334d, ... into nyc-dev

* changes:
PTS: Read SMP pairing options from bt_stack.conf
PTS: Avoid BR SDP after LE pairing
PTS: Allow disabling connection updates
PTS: Add a Secure Only mode.
Changes to allow LE key upgrade
Allow C++ code to check bt_stack_config options
807268aca9eb541fbca9b11b4220ec706025c040 12-Mar-2016 Nitin Arora <niarora@codeaurora.org> 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
tif_dm.c
f4cb73aeb0878b7b49c7e60298ec004150cc3b91 11-Mar-2016 Nitin Arora <niarora@codeaurora.org> 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
tif_dm.c
2d7ddd09c163c84eacddd101cf08fd8021a35370 11-May-2016 Andre Eisenbach <eisenbach@google.com> 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
tif_sock_rfc.c
bd194901dbbd2abebfe2510a1e97bb8d3a75102b 05-May-2016 Ajay Panicker <apanicke@google.com> 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
tif_debug_conn.c
tif_dm.c
641d33861c1845f11593b3e8494f18f2fa64c185 06-May-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Call BTA_VendorCleanup() during actual cleanup of the stack" into nyc-dev
b79022741353c2c4438147b4cd75578e96ba06bb 05-May-2016 Ajay Panicker <apanicke@google.com> Fix size of SDP black list array

Bug: 28617843
Change-Id: Iff5690e3aae42d9907ed9351f1059461985c8a20
tif_dm.c
ebb5ebd18ceaa555a80a4cd0451be4ce643305ca 06-May-2016 Pavlin Radoslavov <pavlin@google.com> 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
tif_core.c
3a44a7a4f6b2dec169097152739d7fdd38482b72 26-Apr-2016 Pavlin Radoslavov <pavlin@google.com> 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
tif_core.c
tif_dm.c
tack_manager.c
1f37a674dca99e0e3f2b856c98b97040ae22948e 20-Apr-2016 Pavlin Radoslavov <pavlin@google.com> 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
tack_manager.c
995c7d63e15923a1a8bdfb2456cc4086468e281c 18-Apr-2016 Ajay Panicker <apanicke@google.com> Protect config module init and add date to config file

Bug: 27354612
Change-Id: Ie956faddaa69101211e554722d682c18ed00a20a
tif_config.c
97253ccb9e6706d9db1333ba44f4c868398dfa25 22-Apr-2016 Sridhar Vashist <svashist@motorola.com> Make default SBC bitrate configurable by device. am: 5f308397b7
am: b2019873c6

* commit 'b2019873c6253f29026b473ad92e417796c7a166':
Make default SBC bitrate configurable by device.

Change-Id: I2257bf7a4f6e24d1995f93469268021476c1f829
271e208b7a48a78664f34e1476a4542bf7b3f7d5 21-Apr-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Add missing init/destroy of state_lock mutex" into nyc-dev
a042f8a02288e69154c405bbdf93c412a14da8bd 13-Apr-2016 Marie Janssen <jamuraa@google.com> 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
tif_config.c
c00ae7734133c91cab3c0cec7b56c9e059f1b3fe 20-Apr-2016 Pavlin Radoslavov <pavlin@google.com> 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
tif_sock_l2cap.c
c7087d2466a291185853a6b2a16f789233e3420f 18-Mar-2016 Ajay Panicker <apanicke@google.com> Add guest mode functionality (2/5)

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: I8f23d28ef0aa3a8df13d469c73005c8e1b894d19
luetooth.c
tif_config.c
tif_storage.c
17a1dfbadd39101faf713b2cd03a3428bda5e8da 06-Apr-2016 Sharvil Nanavati <sharvil@google.com> Delete unused JV code

Bug: 28068134

Change-Id: I16d017ef90269a435b8f66a58ed06d2fc89d407f
tif_sock_l2cap.c
tif_sock_rfc.c
41a1dc21d9279406b90e333b60c44a55753617ac 22-Mar-2016 AnubhavGupta <anubhavg@codeaurora.org> 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
tif_av.c
38487b9f71842a294b9a56843efcfa3a3d672822 08-Apr-2016 Sanket Agarwal <sanketa@google.com> 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
tif_av.c
tif_avrcp_audio_track.cpp
tif_media_task.c
1e7ad16b752c4965d113d2e8b825a8a1d8c8827a 07-Apr-2016 Pavlin Radoslavov <pavlin@google.com> 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
luetooth.c
95673843582fccf026d8af7592428f9b864f52fd 11-Apr-2016 Andre Eisenbach <eisenbach@google.com> 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
tif_dm.c
tif_rc.c
tif_storage.c
23f905d18bb33e10f8c423445ae4288942ad9463 06-Apr-2016 Marie Janssen <jamuraa@google.com> Merge changes I26563b75,If7ee9d96 into nyc-dev

* changes:
Fix memory leak when saving paired devices
btif: Don't persist remote devices to the config
da576af1312568c4892e6b217d89a82897d60d91 05-Apr-2016 Marie Janssen <jamuraa@google.com> Fix memory leak when saving paired devices

Followup from r.android.com/210955

Minor style fixes for osi/config also included.

Bug: 26071376
Change-Id: I26563b75a59a6f0ae074676754889cb988a69358
tif_config.c
b9d28c30f9ef9f8f046bb08238abef9cba445be6 25-Mar-2016 Marie Janssen <jamuraa@google.com> btif: Don't persist remote devices to the config

We don't need to persist the unpaired devices to NVRAM
so skip saving them.

This fixes a regression in a previous patch where the most recent
instead of the least recent devices would be removed, making some
devices unpairable in extremely busy environments.

Bug: 26071376

Change-Id: If7ee9d960f70c836bf08b78da5f3fc852ba60a85
tif_config.c
4a58ac919bcd03a825a811ac1c799ccd22a857da 05-Apr-2016 Pavlin Radoslavov <pavlin@google.com> Updated the A2DP statistics

* Added "Frame expected" and "Frames limited" statistics in the
bugreport about expected and limited number of frames per tick.
Also, added corresponding "Counts (expected/limited)":

A2DP State:
TxQueue:
Counts (enqueue/dequeue/readbuf) : 386 / 386 / 768
Last update time ago in ms (enqueue/dequeue/readbuf) : 12644 / 12643 / 12600
Frames expected (total/max/ave) : 2632 / 8 / 6
Frames limited (total/max/ave) : 0 / 0 / 0
Counts (expected/limited) : 382 / 0
Frames per packet (total/max/ave) : 2618 / 7 / 6
...

* Renamed "tx_queue_max_frames" to "tx_queue_max_frames_per_packet"

* Fixed the computation of actual transmitted frames:
tx_queue_total_frames, tx_queue_max_frames_per_packet

* Computed / added buffer_overruns_max_count and
buffer_underruns_average to the Protobuf stats.

Bug: 27500656
Change-Id: Id58cfb0b5de2296742c84aa0b743e0eed398f41f
tif_media_task.c
236141f48707c5ed3ebc9549b3a9db5151fbb482 01-Mar-2016 Ajay Panicker <apanicke@google.com> Allow factory reset when bluetooth is off (2/2)

Bug: 27348444
Change-Id: Idf0c0bda892c76be037fd28ed352237d4c5b8263
tif_config.c
7c6f8f332c42199748082edfa4aaf5ee45a373d7 30-Mar-2016 Alain Vongsouvanh <alainv@google.com> Bring back support for legacy bt_config.xml

If a device migrates directly from L or earlier to a version using this
new implementation, all bt_config will be lost, requiring to repair to
the devices.

Bug: 27824878
Change-Id: Ifdca0d8cad8efaa9f503ca40ac0725547a06f15c
tif_config.c
tif_config_transcode.cpp
968265f3f4408ee5edb08628a1fccb8a995ba87e 30-Mar-2016 Sanket Agarwal <sanketa@google.com> A2DP_SINK: initialize track handle to null

- initialize track handle to null
- prevent invoking audiotrack API in case handle is null

Bug: 27613411

Change-Id: I1a8637fd2cbb3012b29c1930f978100e7f0c58d8
tif_avrcp_audio_track.cpp
tif_media_task.c
8bda4e143fb0e3357e343ace90056965312d5a99 01-Apr-2016 Ajay Panicker <apanicke@google.com> Fix line wrapping for btsnooz

Change-Id: I4558c652577ffeb3f1ac4f273472ccf98d70924b
tif_debug_btsnoop.c
29dca0643501998b14bb17c10402256417eea8aa 26-Mar-2016 Pavlin Radoslavov <pavlin@google.com> Don't destroy BTIF Device Management state during shutdown

Don't call btif_dm_cleanup() during stack shutdown stage,
because it will destroy/free internal state that might be used
later in the shutdown process.
Instead, btif_dm_cleanup() should happen during the stack
cleanup stage.

Also, added an unit test to capture the original issue.

Bug: 27856457
Change-Id: I8575537ad744cf4e6770046b779b6a53de93d66e
tif_core.c
tif_dm.c
20af7c3cc040e82124184ad869d840ad6fa1eacf 28-Mar-2016 Ajay Panicker <apanicke@google.com> Revert "Add guest mode functionality (2/5)"

This reverts commit 45ee419b233480060548f19b09de6726d28a06ea.

Change-Id: I7d24acbe09305611c4e0bbfe7d40348d0fd1c365
luetooth.c
tif_config.c
tif_storage.c
45ee419b233480060548f19b09de6726d28a06ea 18-Mar-2016 Ajay Panicker <apanicke@google.com> Add guest mode functionality (2/5)

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
luetooth.c
tif_config.c
tif_storage.c
2a6246f85c515f33eb4f9ff708f50680b1cb1653 07-Jan-2014 Ayan Ghosh <abghosh@codeaurora.org> Move to idle when remote disconnects during connection.

Chrysler Uconnect Touch initiates disconnect for a2dp on
l2cap just after discovery on AVDTP channel, stack does not
send any message to BTIF layer for disconnection, this
causes btif getting stuck in opening state and later no stable
connection update is sent to app. Since it is intermediate
state all subsequent connection trials fails.

Send disconnect event from incoming state to closing state
and then closing state will send proper msg to btif layer. Add
closing msg handling in btif layer so that we can update app
for connection disconnect when initiated from remote and move to
proper stable state for accepting/initiating connection.

Bug: 27852645
Change-Id: I011d9ffe9d721235217320c1e5281f70328c7f13
tif_av.c
d14f97c87685e480ee1a88829497651bccf2b358 03-Mar-2016 Ayan Ghosh <abghosh@codeaurora.org> Process AV HAL start only when previous instance is cleaned up

Bug: 27852645
Change-Id: Iee232dacd3b79e6e94d26c73fb3e563fddced75c
tif_media_task.c
f3758bdc1f38dcd237f4a39c6af3d4faf0f27832 01-Mar-2016 Sharvil Nanavati <sharvil@google.com> Don't clear the btsnoop log ringbuffer on compress.

Change-Id: I0bf4279104e87b151553eba913491d934f3cde41
tif_debug_btsnoop.c
5034d67fde55ccb8ac790ca76e7563f756261db5 15-Mar-2016 Sharvil Nanavati <sharvil@google.com> Don't send AT+BCC if local device doesn't support codec negotiation.

The current code only checked if the peer supported codec negotiation
before sending AT+BCC. But if codec negotation is disabled on the
local device, we should definitely not send AT+BCC.

Bug: 27213013
Change-Id: Id372a32a61a3d96d5c093bc50594ef0b8c2eff2e
tif_hf_client.c
ab99638f9a05ae7ed04ab0a75d48cbd1d78b36e8 09-Mar-2016 Navin Kochar <navin.kochar@intel.com> Add LE L2CAP Connection Oriented Channel

This implementation for LE L2CAP Connection Oriented Channel (a Bluetooth
Core Spec 4.1 feature) has been tested on the following formal and informal
IOP events conducted by BT SIG Sport and Fitness Working Group.

* Informal IOP – Tokyo 2014
* UPF 49 – Berlin 2014
* Formal IOP – Tokyo 2014
* Formal IOP – Santa Clara 2015

Bug: 27852645
Change-Id: Ia6de62f9321a78b98930629f65078884157a9c0d
Signed-off-by: Navin Kochar <navin.kochar@intel.com>
tif_sock_l2cap.c
8d0a6a408ff57cb221e67963a95822f080911f20 10-Mar-2016 Marie Janssen <jamuraa@google.com> osi: add osi_rand()

Provide a replacement for rand() which has a better random source.

Change-Id: I38a8c74d86b89ec160b43b0f648f53b463be89bb
tif_core.c
65cf62811c3a0bd46fff19f82beae43874ab3391 24-Jul-2015 Subramanian Srinivasan <subrsrin@codeaurora.org> Update device type in NVRAM correctly during inquiry

If the NVRAM device type for a device is not dual mode and the inquiry
result is received for BLE or BR/EDR transport, then this patch updates
the NVRAM device type to dual mode.

Bug: 27852645
Change-Id: I688e7c5e3bd8d844288d095cb97c2e55ddf652c6
tif_dm.c
1c4150bee59b5e3f76ddd54e1696f9e1e53dfede 04-Mar-2016 Jacky Cheung <jackyc@google.com> Default missing DevType and DevClass in NVRAM.

Missing DevType and DevClass in NVRAM were not properly set to a
default values previously.

Bug: 27852645
Change-Id: I79fbc333d7b6dda0fb795776b2dbe1e1e101352c
tif_storage.c
9b4de840e65ce051f9585c12071f4bcf5fa26ea3 20-Sep-2015 Srinu Jella <sjella@codeaurora.org> Cleanup L2CAP socket properly on close

Use case:
1. Sometimes pairing pop up occurs during Android beam
transfer though it is not required.
2. No OPP Tx request over OBEX if we cancel during file transfer.

Precondition
1. WIFI ON and conneted with AP.

Steps:
1. Pair and connect from DUT to remote.
2. Go to gallery and send a file.
3. Accept same file and stop it from remote during transfer.
4. Repeat step 2-4 10 times.

Failure:
OPP Tx should not fail.

Root cause:
Close request was not properly handled from BT-IF layer.

Fix:
1. Handled the close request properly from BT-IF layer
to close the socket variables and instruct the BTA layer
close from there as well.
2. Clean up L2CAP socket properly on closure to free
the entry registered with security manager to avoid
leak in security manager records.

Bug: 27852645
Change-Id: I4f5d6ac92317bcaee5f9285ba71d13eea84c737c
tif_sock_l2cap.c
08ca0bbfab6cc3ae32998aa1840d977abcb80360 11-Aug-2015 Srinu Jella <sjella@codeaurora.org> Added fd for monitoring when the channel is not congested

Use case:
Skips and Media Audio Loss are Observed During PAN Connection

Steps:
1. Launched Local Music and Media Audio was in Headset.
2. Paired and Connected to other Phone to DUT Over BT Tethering.
3. While Listening to Media Audio in DUT, Started Watching
Youtube in other phone.
4. Observed Below Observations During Some 30mins of PAN Connection.

Failure:
Skips and Media Audio Loss are Observed During PAN Connection

Root Cause:
socket monitor thread keeps polling for PAN fd, eventually
it will make the BTU thread also busy, inturn NOCP processing
gets delayed.

Fix:
Add PAN fd for monitoring only when L2CAP channel related to
PAN profile is not congested. It will break loop by checking the
congestion status to put the fd for polling.

Bug: 27852645
Change-Id: I2119c6c86d8e4798e516c512ad7aac7630b85a6a
tif_pan.c
37cf570429128f88012b72bdedd354341a43a3bb 11-Dec-2015 Hemant Gupta <hemantg@codeaurora.org> HID: Remove bond for device in case Virtual unplug is ongoing

Remove bond for remote device in case virtual unplug was initiated from
local device, and ACL got disconnected while processing the VUP request.
this can happen when aaplication is sending disconnect and remove bond
in quick succession. Without this fix it was observed that device was
getting disconnected, but was not getting unpaired even when user
tried to unpair from UI.

Bug: 27852645
Change-Id: Ife1fc99ed59b13daf0bcf0dce3e0a59c7d9e87d7
tif_hh.c
6524408c255586136b6b336bd00c464706947b36 29-Oct-2015 Subramanian Srinivasan <subrsrin@codeaurora.org> Use correct transport type for GATT client and server connections

Use correct transport type for GATT client and server connect
API calls. This change uses the transport used while calling
the connect frameworks API instead of relying on the NVRAM to
find the transport on which the connect call needs to be sent
to the BT stack.

Bug: 27852645
Change-Id: Idf5817b8980e848c6ebebf1e9a79dbce61d8cfc8
tif_gatt_client.c
tif_gatt_server.c
69682acf0149e9e51cda5b8747866ca9dc37b907 03-Dec-2013 Ayan Ghosh <abghosh@codeaurora.org> Peer support of Absolute Volume to be updated only if device supports A2DP

Peer support of absolute Volume feature should be updated to Audio
frameworks only for device which supports A2DP Sink and AVRCP Absolute
Volume TG roles together.
Audio manager need not be updated for AVRCP only peer devices as
that would cause sudden rise in ongoing stream volume when avrcp only
device connects, if it is set to some lower value with other device
connected for A2DP.

Bug: 27852645
Change-Id: I75509d0b0fd1b06fa08390940a327dd2887d7562
tif_av.c
tif_rc.c
68ad33b15a1becf87bca8f0a420b29ffb3342a0a 07-Aug-2013 Ayan Ghosh <abghosh@codeaurora.org> Allow Carkit to trigger play immediately after call

Removing check in stack where AVRCP Play and Pause commands
are being dropped if carkit initiates play or pause within
six seconds.
This addresses the scenario where JCI-Mazda CK pauses the
streaming by initiating Avrcp Pause right before making call
and can not resume the streaming by sending Avrcp Play right
after call ends.

Bug: 27852645
Change-Id: Ibb04223de746f528b356e78bd65130d3fd526a44
tif_rc.c
2998946db9b820806d4a3e6decf1d01f090a8031 24-Feb-2016 Jakub Pawlowski <jpawlowski@google.com> Move properties get/set code to osi

Currently we use Android-specific property_get and property_set
through the code. This patch adds osi_property_get and osi_property_set
that is encapsulating all external dependencies. This is step further
for errorless compilation on linux.

Bug: 27324453
Change-Id: I97c34344617a5855b683328bcd196a21a2fae6f9
tif_core.c
tif_dm.c
tif_hf_client.c
tif_rc.c
26f8828cdb5f02b0b01bafaccd4ad0b0ba9d57ab 17-Mar-2016 Jakub Pawlowski <jpawlowski@google.com> Use handles to identify GATT attributes (1/4)

Bug: 27778668
Change-Id: Id7454450c1ce2164001a1f9ca0b91f18d84e3fd6
tif_gatt_client.c
tif_gatt_server.c
tif_gatt_util.c
1af906353999b8f25ddd1030803292a4c84087f6 22-Mar-2016 Andre Eisenbach <eisenbach@google.com> Merge changes from topic 'bug-27455533-to-nyc-dev-merge-1' into nyc-dev

* changes:
Remove bta_gattc_id2handle
Use attribute handle instead of id in GATT cache
HID multi-device refactoring
GATT cache storage refactoring
Remove dead methods and callbacks
Simplify UUID handling in GATT cache
63ddbe8813aac242071dffc0bd413ba60e6dd7bf 21-Mar-2016 Ajay Panicker <apanicke@google.com> Add config source to dumpsys output

This logs where the config file was loaded from in the Bluetooth
Manager dumpsys output.

Bug: 27354612
Change-Id: I50d4aaa0be4f4d1d890580b03742713f4345c80f
luetooth.c
tif_config.c
1b1bcbb3b0bc812410a3ee4f798570d40e0463bc 17-Mar-2016 Glenn Kasten <gkasten@google.com> Merge "Use audio_session_t consistently" into nyc-dev
fcc536af189dfe534e5e7c6b352ee114de71b3a1 10-Mar-2016 Marie Janssen <jamuraa@google.com> DO NOT MERGE Check size of pin before replying

If a malicious client set a pin that was too long it would overflow
the pin code memory.

Bug: 27411268
Change-Id: I9197ac6fdaa92a4799dacb6364e04671a39450cc
tif_dm.c
fecf606348a0751e0be30e376c9817195afe68ca 11-Mar-2016 Ajay Panicker <apanicke@google.com> Add pair event device class and fix timestamp

Added a function to get the device class to use with pair events.
Also update check_cod_hid as it was only being used with COD_HID_MAJOR.
Also fixed an issue with pair event timestamps where they were
using the wrong clock.

Bug: 27499938
Change-Id: I0805d7a3f82b28e7d7e73d80818948843f51a82b
tif_dm.c
tif_hh.c
6a66c4425c0d4926fd61a0ad4ff73447aefc4cac 08-Mar-2016 Glenn Kasten <gkasten@google.com> Use audio_session_t consistently

Bug: 27562099
Change-Id: I10780c8bfc84af568795a2c15557020fbe89a1c4
tif_avrcp_audio_track.cpp
9fa6990ba980202a42017ada939c4f6cc9794c53 29-Feb-2016 Jakub Pawlowski <jpawlowski@google.com> Remove dead methods and callbacks

Bug: 27455533
Change-Id: Ie5661577320810468dd635022027a1e1a2f70a3e
tif_gatt_client.c
597ce3bd08533c24cd61be0ef4ad8a237571770f 08-Mar-2016 Dimitry Ivanov <dimitry@google.com> Fix the build

Change-Id: Ib226f087a76ddd426e40f4d6d94f2ed758660c36
tif_media_task.c
547b7b52578fddbd9e42ce1cc7e7bba9dded1d7d 11-Feb-2016 Sanket Agarwal <sanketa@google.com> Move focus handling entirely to component calling fluoride.

Audio focus handling for A2DP sink currently split between Fluoride and
the component sitting on top of it. Since this is not the best place to
decide policies, we move all such decisions to the upper layer.

Bug: b/26928143

Change-Id: I67a1a2a50782289e7e31447b01ee29a21bc8dac2
tif_av.c
tif_media_task.c
a5090f2c33919f57c82107ec62ce5ec5705e7e21 26-Feb-2016 Prashant Malani <pmalani@google.com> Fix miscellaneous compilation errors

- Move variables within #defines to avoid unused errors.
- Place #define's correctly to avoid unused function errors.
- Correct parameter passed into a function.

Bug: 27336841
Change-Id: I7c2ab24b3bd3725d126c90483473af83b88687a2
tif_gatt_util.c
tif_rc.c
cb090050e3f45905a33f595cee9e12b3e2c66e86 01-Mar-2016 Pavlin Radoslavov <pavlin@google.com> Reset queue pointer to NULL after fixed_queue_free()

Add missing reset of queue pointers to NULL affter
fixed_queue_free() calls.

Bug: 26742590
Change-Id: Ib9035d58c0f98a47ce2935e073c6f288ae03ac92
tif_media_task.c
2ae9b0a22e24538097a44670ff42aea6806d230d 27-Feb-2016 Andre Eisenbach <eisenbach@google.com> Ensure inquiry is always stopped before service discovery

Service discovery cannot be initiated when the dm search state machine
is not in idle state. This patch ensures that service discovery is
always cancelled regardless of the current state of inquiry.

Bug: 27368986
Change-Id: Ib83d4c8d389e50a1c65e52b343f4996455747836
tif_dm.c
8efca14b7f6570659d5e7a73327e2288cc544922 22-Feb-2016 Ajay Panicker <apanicke@google.com> Clean A2DP dump output

Before:
TxQueue:
Counts (enqueue/dequeue/readbuf) : 0 / 0 / 0
Last update time ago in ms (enqueue/dequeue/readbuf) : 0 / 0 / 0
Frames per packet (total/max/ave) : 0 / 0 / 0
Counts (flushed/dropped/dropouts) : 0 / 0 / 0
Last update time ago in ms (flushed/dropped) : 0 / 0
Counts (underflow/underrun) : 0 / 0
Bytes (underflow/underrun) : 0 / 0
Last update time ago in ms (underflow/underrun) : 0 / 0
Enqueue deviation counts (overdue/premature) : 0 / 0
Enqueue overdue scheduling time in ms (total/max/ave) : 0 / 0 / 0
Enqueue premature scheduling time in ms (total/max/ave) : 0 / 0 / 0
Dequeue deviation counts (overdue/premature) : 0 / 0
Dequeue overdue scheduling time in ms (total/max/ave) : 0 / 0 / 0
Dequeue premature scheduling time in ms (total/max/ave) : 0 / 0 / 0

After:
TxQueue:
Counts (enqueue/dequeue/readbuf) : 0 / 0 / 0
Last update time ago in ms (enqueue/dequeue/readbuf) : 0 / 0 / 0
Frames per packet (total/max/ave) : 0 / 0 / 0
Counts (flushed/dropped/dropouts) : 0 / 0 / 0
Last update time ago in ms (flushed/dropped) : 0 / 0
Counts (underflow/underrun) : 0 / 0
Bytes (underflow/underrun) : 0 / 0
Last update time ago in ms (underflow/underrun) : 0 / 0
Enqueue deviation counts (overdue/premature) : 0 / 0
Enqueue overdue scheduling time in ms (total/max/ave) : 0 / 0 / 0
Enqueue premature scheduling time in ms (total/max/ave) : 0 / 0 / 0
Dequeue deviation counts (overdue/premature) : 0 / 0
Dequeue overdue scheduling time in ms (total/max/ave) : 0 / 0 / 0
Dequeue premature scheduling time in ms (total/max/ave) : 0 / 0 / 0

Bug: 27294154
Change-Id: I2952ceed7b02db0d8497b67de0f57e4f9128e5bf
tif_media_task.c
5931d375cd7a727b6bfaadf01e7d23bc40b2c2ca 24-Feb-2016 Ajay Panicker <apanicke@google.com> Remove extra newline before Btsnoop log summary

Bug: 27294154
Change-Id: Ice69835cdddfc01e2222a47b0ceeb30d243442f5
tif_debug_btsnoop.c
7bde09fe4aead831a63cad90d7c6f4931d5a0e00 19-Feb-2016 Ajay Panicker <apanicke@google.com> Clean up bond event dump printout

Bug: 27294154
Change-Id: I0b7e5a9dda30875c9fc877baffa0daac9184cd42
tif_dm.c
f2b7708eaf2de443100e5f22e759c125401b9c07 23-Feb-2016 Jakub Pawlowski <jpawlowski@google.com> Add missing log tag in config_clear()

Bug: 27324453
Change-Id: Icebf0273c39040ff6b1bb29dcc4d0a827e25b4a8
luetooth.c
4e6b1c82b78aa17c887376c14cf323bed02e1fd4 18-Feb-2016 Pavlin Radoslavov <pavlin@google.com> Add support for collecting A2DP Protobuf metrics

* Add new function metrics_a2dp_session() to
connect A2DP metrics into Protobuf

* Add new function btif_update_a2dp_metrics()
that is called when the metrics should be
callected

* Add few more statistics to the BTIF media stats.

Change-Id: I5862ac82e55b3546dc1fbde0c78cb4683e40d19e
luetooth.c
tif_media_task.c
0e888661a5dc23e516429b3e80f1f6a1aac12015 17-Feb-2016 Andre Eisenbach <eisenbach@google.com> Instrument and fix calls to strncmp()

Bug: 27222508
Change-Id: I0075b4480aff52dcdc326b7bdb7154ca919ccee9
luetooth.c
a72c96f8dbfcb4db1e45c4954fc96d3da93a4008 06-Feb-2016 Ajay Panicker <apanicke@google.com> Additional logging for bond information

Log the bond state, the funciton that updated the bond state, as well as the
device that was updated. Also added in functionality for protobuff logging.

Example output
Bond Events:
Total Number of events: 8
Time BD_ADDR Function State
00:01:12.353 ac:9e:17:07:58:d8 btif_dm_create_bond BOND_STATE_NONE
00:01:12.354 ac:9e:17:07:58:d8 bond_state_changed BOND_STATE_BONDING
00:01:13.999 ac:9e:17:07:58:d8 bond_state_changed BOND_STATE_BONDING
00:01:14.778 ac:9e:17:07:58:d8 bond_state_changed BOND_STATE_BONDED
00:01:14.827 ac:9e:17:07:58:d8 bond_state_changed BOND_STATE_BONDED
00:01:31.534 34:36:3b:c4:bf:99 btif_dm_create_bond BOND_STATE_NONE
00:01:31.535 34:36:3b:c4:bf:99 bond_state_changed BOND_STATE_BONDING
00:01:32.771 34:36:3b:c4:bf:99 bond_state_changed BOND_STATE_BONDING

Change-Id: I01ab3a232300203704a356a17aa045e638f97463
luetooth.c
tif_dm.c
a0c02f62a49c4ae9de5789731cdbb99b686a938d 14-Jan-2016 Andre Eisenbach <eisenbach@google.com> Add ability to add interop entries dynamically (2/2)

Add ability and interface for adding dynamic entries to the interop
workaround database.

Bug: 26548845
Change-Id: Id886e4233fc1548727e79f1581cdc0c6f0738d59
luetooth.c
3aa58c5fad5be75c559109ddce3ccd79ac807af9 15-Feb-2016 Pavlin Radoslavov <pavlin@google.com> Fix compilation warnings/errors on fugu

Fix compilation warnings/errors on fugu about unused
variables.

Change-Id: Ib68097122f27c631ab36b71a6815d4e1f3b60558
tif_pan.c
12265e39b511f28425236b0dc97c78e7d837304b 13-Feb-2016 Pavlin Radoslavov <pavlin@google.com> Fix C/C++ compiler generated warnings

* Remove unused functions: -Wno-unused-function
* Fix logical operations that are missing parentheses:
-Wno-logical-not-parentheses, -Wno-parentheses
* Add missing braces in initializers: -Wno-missing-braces
* Remove unused variables: -Wno-unused-variable
* Fix printf()-like formatting issues: -Wno-format
* Avoid using unitialized variables:
-Wno-maybe-uninitialized, -Wno-uninitialized
* Fix a bug inside bta_gattc_get_gatt_db_impl()
when the processed GATT DB attribute type is unknown.
* Fix warnings about missing field initializers:
-Wno-missing-field-initializers
* Re-implement macro COMPILE_ASSERT(COND) to fix a compilation warning:
-Wno-non-literal-null-conversion
* Fix sign mismatch comparison warnings:
-Wno-sign-compare
* Fix warnings related to enum conversion:
-Wno-enum-conversion
* Fix warnings related to incompatible pointer types:
-Wno-incompatible-pointer-types
* Fix warnings related to enum conversion:
-Wno-enum-conversion

Bug: 26879229
Change-Id: I522931fe156aeab23ae841051a9e25ceab00b1c2
tif_av.c
tif_avrcp_audio_track.cpp
tif_debug_btsnoop.c
tif_dm.c
tif_rc.c
tif_sock_thread.c
f621aa868f2d980d7a8a1afaa6d70dcf42866bc5 11-Feb-2016 Ajay Panicker <apanicke@google.com> Create backup for bt_config.conf

Move current config file to a backup when a new config file is
saved. This backup can be used in case there is an error loading
the current config file.

Change-Id: Icc210c457dc71a72fc2e82ff72c91207b25deaf1
tif_config.c
12339a801146d45f8aab010b38c099082bfc80e5 11-Feb-2016 Jakub Pawlowski <jpawlowski@google.com> Add handle range to BTA_GATTC_GetGattDb

Change-Id: Iaf0280853278a4f28dde5b952b646096cfb12d97
tif_gatt_client.c
5fe6f0cf6b223e3ed6be4912d55b3ed5b41ce0cd 06-Feb-2016 Pavlin Radoslavov <pavlin@google.com> Removed checks for NULL returns after osi_calloc() / osi_malloc()

Removed explicit checks for NULL pointer returns after calls
to osi_calloc() and osi_malloc(), because those are not needed.
If the memory allocation fails, osi_calloc() and osi_malloc()
will trigger an assert.

Bug: 27048759
Change-Id: I2791eb2f69c08f991f8fcdef10e101a41568cd95
tif_av.c
tif_config.c
tif_core.c
tif_dm.c
tif_gatt_client.c
tif_gatt_multi_adv_util.c
tif_gatt_server.c
tif_hh.c
tif_hl.c
tif_media_task.c
tif_profile_queue.c
tif_rc.c
tif_sm.c
tif_sock_l2cap.c
tif_sock_sco.c
tif_storage.c
37f7f8380f91221f5f49248ee09be927434b0875 10-Feb-2016 Ajay Panicker <apanicke@google.com> Remove code related to legacy config file

Change-Id: Ia82d9bbffcc5df1ec4cddff28d812ca221505ab9
tif_config.c
tif_config_transcode.cpp
7dc23e85a659853c4b2eadb6d179232459c9e123 06-Feb-2016 Satya Calloji <satyac%broadcom.com@gtempaccount.com> Add Privacy 1.0/1.1 check for BG connection

Check for privacy 1.0 and 1.1 controller and do not start
background connection, if RPA offloading is not supported,
since it will not connect after change of random address

Bug: 22102400
Change-Id: Ida618f8dc70e0a3860f76f856bb88de8b55b90d7
tif_gatt_client.c
90b71eac9b45f90ff3267fa0a400cc1daaec88d4 09-Feb-2016 Andre Eisenbach <eisenbach@google.com> Add Developer menu entry to disable Bluetooth absolute volume

Bug: 27078729
Change-Id: I24ac605c6d02dc3fe3904c441ec416cb66b63168
tif_rc.c
abd70abb5e42c9431df94fe9d2c4a78a0d8d9af9 05-Feb-2016 Pavlin Radoslavov <pavlin@google.com> Replaced osi_getbuf()/osi_freebuf() with osi_malloc()/osi_free()

Removed the alternative buffer allocation osi_getbuf() / osi_freebuf()
and use instead osi_malloc() / osi_free().

Correspondingly, replaced usage of osi_freebuf_and_reset()
with osi_free_and_reset().

Bug: 24914560
Change-Id: I7a9599ba7fa900321f087da684428133eb0ddd6b
tif_core.c
tif_dm.c
tif_gatt_client.c
tif_gatt_multi_adv_util.c
tif_gatt_server.c
tif_gatt_util.c
tif_hh.c
tif_hl.c
tif_media_task.c
tif_pan.c
tif_rc.c
tif_sock_l2cap.c
tif_sock_rfc.c
a41dbb156068a33e7cccafe93c4b520406781c9f 08-Feb-2016 Jakub Pawlowski <jpawlowski@google.com> Add missing log tags

When building for Linux, missing log tags cause errors.

Change-Id: I0b3cda3333c059251b00a25bbfc7e764057286be
tif_av.c
tif_dm.c
d2e3b538edf83060d163c603e6ffd0c0977604ee 13-Feb-2016 Sanket Agarwal <sanketa@google.com> Remove %s from Log message.

This crashes when A2DP SNK role is executed in print statement.

Change-Id: Iceca09ecc5977a5379d7f98f265fc2d52332c6e4
tif_rc.c
aa11644f763b1d33123b3f71d1a6c3977e7d69cf 16-Jan-2016 Marie Janssen <jamuraa@google.com> osi: add metrics API

Add a metrics API, which supports creating events which are eventually
passed up to the clearcut logging to track pairings and other events.

Connect this to the dumpsys call when it is called.

Change-Id: Idcf75541fd18b0413cc843d6c7e23a5f08a634a5
luetooth.c
ea46bfaeafb9498c8a288b7d2021ac4d333e61a9 05-Feb-2016 Pavlin Radoslavov <pavlin@google.com> Fix a call to osi_freebuf_and_reset()

Add missing ampersand in a call to osi_freebuf_and_reset()

Bug: 27038970
Change-Id: Idcbd406a8c790bdddfe1c4fbc0381577bedd8c9c
tif_gatt_client.c
20524d393e8b3bea4c573f7980cd843500b0e6a4 03-Feb-2016 Pavlin Radoslavov <pavlin@google.com> Refactor usage of osi_free() and osi_freebuf()

* Allow to call osi_freebuf(ptr) on NULL pointers. This simplifies
the code: a notable number of "if (foo != NULL)" checks are removed.
* Add new function osi_free_and_reset(p_ptr) that frees the buffer,
and explicitly resets the pointer to NULL.
This prevents unintended usage of free memory.
* Add corresponding function osi_freebuf_and_reset(p_ptr)
* Minor cleanup around usages of osi_free() and osi_freebuf()

Also:
* Removed unused function btif_gattc_cleanup()
* Replaced usage of the following functions with osi_freebuf_and_reset()
- mca_free_buf()
- utl_freebuf()
- btif_hl_free_buf()
* Replaced usage of rc_supported_event_free() with osi_freebuf()
* Replaced usage of btif_hl_get_buf() with osi_getbuf()
* Eliminate some of the osi_get_buf_size() calls

Bug: 22948224
Change-Id: Ife860658b26274da6f228d7353cb0f1531587337
tif_av.c
tif_dm.c
tif_gatt_client.c
tif_gatt_multi_adv_util.c
tif_gatt_server.c
tif_gatt_util.c
tif_hh.c
tif_hl.c
tif_pan.c
tif_rc.c
f94e67c2d96d25f221e0503f334f4a0a277bc68c 02-Feb-2016 Pavlin Radoslavov <pavlin@google.com> Fix the processing of AVRCP Rcvd Pass Through messages

The assignment and handling of the optional tAVRC_MSG_PASS.p_pass_data
data buffer pointer was inconsistent:
- For originating AVRCP packets, it was assigned to osi_getbuf()
allocated memory.
- For received AVRCP packets, it was a pointer in the middle of the
received data buffer.
However, in the common function avrc_pass_msg(), the p_pass_data pointer
was deallocated by osi_freebuf(). This triggered an assert when processing
AVRCP Rcvd Pass Through messages with non-zero Data Length field.

Bug: 26865159
Change-Id: I1b2eb6713636c290caca16e77226c114d99dcb8e
tif_rc.c
16856640e6179a73abf955e24dc7acf0699b66e4 30-Jan-2016 Andre Eisenbach <eisenbach@google.com> Fixed paired device config UUID parsing logic

Also added unit tests to cover this bug.

Bug: 26883553
Change-Id: Ice8641fad5c38ee43f1b080665dde70979f9d60f
tif_storage.c
tif_util.c
e37dcf393f815e8d3eee4239af1dd2dacdbc808e 29-Jan-2016 Andre Eisenbach <eisenbach@google.com> Merge "Make BTIF a static library; add unit test framework"
e11cc0b0f9c5b21ecdf3d574333d100ce918a3a0 22-Jan-2016 Andre Eisenbach <eisenbach@google.com> Make BTIF a static library; add unit test framework

Moving BTIF to a static library allows it to be loaded for unit tests.
The framework has been put in place to add unit tests to
'net_test_btif'.

Change-Id: Ie7e0984e90f11f6e3df5c0f34c77cc976627f1d2
tif_util.c
533fdbf46fb623aefbe4d0107b5cccd41aec097a 22-Jan-2016 Jakub Pawlowski <jpawlowski@google.com> Add new HAL method get_gatt_db

Currently getting GATT database from HAL requires multiple calls
and iterating over each element. This is long, unnecessary
complicated process, error prone process. This patch adds new
method, get_gatt_db that can be used to grab whole GATT database
for remote device just in one call.

Change-Id: Ib5d88fbc28d09d5c191e7c0152ca61d6a34f7a81
tif_gatt_client.c
8eea109d265c7c03d80ceb681f05b3604ec939ad 28-Jan-2016 Pavlin Radoslavov <pavlin@google.com> Add missing include statements

This fixes "implicit declaration of function ..." warnings/errors.

Change-Id: I07d0f6a60fdb34acef6a11a00f6e528adece150f
luetooth.c
ffba52aeef45451226991d9443c4442a33a7f231 14-Jan-2016 Pavlin Radoslavov <pavlin@google.com> Added metrics for A2DP transmission queue

Collect and display A2DP metrics related to the A2DP transmission queue.
The result can be displayed by "adb shell dumpsys bluetooth_manager":

A2DP State:

TxQueue:
Counts (enqueue/dequeue/readbuf) : 1767 / 1767 / 3504
Last update time ago in ms (enqueue/dequeue/readbuf) : 3 / 3 / 3
Frames per packet (total/max/ave) : 12210 / 11 / 6
Counts (flushed/dropped/dropouts) : 0 / 0 / 0
Last update time ago in ms (flushed/dropped) : 0 / 0
Counts (underflow/underrun) : 0 / 0
Bytes (underflow/underrun) : 0 / 0
Last update time ago in ms (underflow/underrun) : 0 / 0
Enqueue deviation counts (overdue/premature) : 893 / 871
Enqueue overdue scheduling time in ms (total/max/ave) : 242 / 12 / 0
Enqueue premature scheduling time in ms (total/max/ave) : 842 / 20 / 0
Dequeue deviation counts (overdue/premature) : 869 / 897
Dequeue overdue scheduling time in ms (total/max/ave) : 604 / 11 / 0
Dequeue premature scheduling time in ms (total/max/ave) : 1204 / 19 / 1

Change-Id: I75c8f24a26cf9ce7a4164a142d4ac286ff17f322
luetooth.c
tif_debug.c
tif_media_task.c
adca1518b51935a446d968d4c893a4fd46a00621 28-Jan-2016 Pavlin Radoslavov <pavlin@google.com> Fix the calling pattern of the debug dump functions

Group together the calls to the internal foo_dump() functions,
so the output file descriptor is not closed prematurely.

Bug: 26847370
Change-Id: I3afc9502169424081efcc5deae055fbbd91ed5f1
luetooth.c
tif_debug.c
9ca88af1d964c546af1c3dc2c16c4c98071fd5b1 26-Jan-2016 Sharvil Nanavati <sharvil@google.com> Fix return value for HAL function config_clear.

Change-Id: I75712f721f7031705d0accb4ffe89467d52d7aa3
luetooth.c
tif_config.c
da35bbce704acff55b9748264106162d33a7ff2a 12-Jan-2016 Marie Janssen <jamuraa@google.com> service: Update HAL call for arguments

The HAL now takes an additional argument for dumpsys arguments.

Change-Id: I286149e4d86ea50c4830a9f6d32e1d57025d01a7
luetooth.c
78bcff79e1b1f0efce436b33bdd6da88745bfc8a 05-Dec-2015 Pavlin Radoslavov <pavlin@google.com> Refactor the Bluetooth timers

* Updated the alarm API:
- Existing API alarm_new() is modified to take an alarm name
as an argument.
- New API alarm_new_periodic() is used to create a periodic
alarm.
- Added new API alarm_is_scheduled() to test whether an alarm is
scheduled.
- Existing API alarm_set_periodic() is removed: a periodic
alarm is created by alarm_new_periodic().
- Added new API alarm_set_on_queue() to set an alarm whose
callback is executed on a specific queue.
- Added new API alarm_register_processing_queue() and
alarm_unregister_processing_queue() to register/unregister
a queue and the corresponding thread for alarm processing.
- Added corresponding unit tests.

* Updated the alarm internals:
- Added alarm_info_t for collecting alarm-related information
and statistics.
- Collect and store alarm-related statistics into alarm_info_t
per alarm.
- Include the alarm-related statistics and info into the native
dumpsys output for Bluetooth.
- Once an alarm expires, the alarm execution is scheduled for
processing on another internal alarm-specific thread, not
on the thread that is maintaining the alarms.
- Implemented callback execution ordering guarantee among
timers on the same thread with exactly same timeout values.

* Refactor some of the usage of alarm_set() and simplify the
code by using alarm_set_on_queue() instead.

* Removed the non_repeating timers wrapper, and use directly
the alarm mechanism / API.

* Refactored all timer_entry_t timers and replaced them with alarm_t
timers:
- Replaced the btu_start_timer() / btu_stop_timer() /
btu_start_quick_timer() / btu_stop_quick_timer() /
btu_oneshot_alarm() mechanism with alarm_set_on_queue() and
alarm_cancel()
- Removed the whole mechanism around the BTU_TTYPE_* timers.

* Fixed a bug when processing the GATT indication confirmation timer
expiration (timer tGATT_TCB.conf_timer: b/26610829).

* Renamed and/or split misc. timeout functions, fields, and timers

* Renamed time-related constants and changed the values from seconds
to milliseconds

* Replaced timer tAVDT_CCB.timer_entry with three mutually exclusive timers:
idle_ccb_timer, ret_ccb_timer, rsp_ccb_timer
The reason we are using three timers, is because in the original code
function avdt_ccb_chk_timer() used the timer type in its logic: it
would stop the timer only if the type is "idle".

* Removed btm_ble_timeout() and replaced it with multiple timeout
callback functions (per timer)

* Fix the actual value of the global constant BT_1SEC_TIMEOUT and
rename it to BT_1SEC_TIMEOUT_MS

* Removed btu_cb and associated timers and events, because they are
never used.

* Removed unused timers, functions, struct and declarations that are
not used / needed.

Bug: 26611369
Bug: 26610829

Change-Id: I812c8c31710a5daefc58b01fcf35c353768f390f
luetooth.c
tif_av.c
tif_config.c
tif_gatt_client.c
tif_gatt_multi_adv_util.c
tif_hh.c
tif_hl.c
tif_media_task.c
tif_rc.c
d2e250824fca5c42b87b3b6f5fa19646ffa2d321 25-Aug-2015 Pavlin Radoslavov <pavlin@google.com> Add support for native kernel and callout wakelocks

* Moved wakelock-related code to osi/src/wakelock.c
The API is in osi/include/wakelock.h

* Use wakelock_set_os_callouts() to specify native kernel
or callout-based wakelock.
On Android, wakelock_set_os_callouts() is called to
set the bt_os_callouts_t callbacks into the Java layer.

* Renamed alarm_set_wake_lock_paths() to wakelock_set_paths()

Also, added Bluetooth Wakelock Statistics to the bugreport.
Sample output:

$ adb shell dumpsys bluetooth_manager
...
Bluetooth Wakelock Statistics:
Wakelock is acquired : false
Wakelock acquired/released count : 5 / 5
Wakelock acquired/released errors : 0 / 0
Wakelock last acquired time (ms) : 1524
Wakelock acquired time min/max/avg (ms) : 1511 / 8104 / 3167
Wakelock total acquired time (ms) : 15836
Bluetooth total run time (ms) : 44123

Bug: 26645431
Change-Id: I42bfb7db5b016719faea39e47ebc77c3ad02467b
luetooth.c
tif_debug.c
e8c3dde6cfec13e8a0b3f87397319eab4cb86ad5 15-Jan-2016 Sharvil Nanavati <sharvil@google.com> Update btsnooz log file format to log ACL and SCO headers.

Change-Id: I72db1769197150f34ebba6fcb9c0e3db2404f342
tif_debug_btsnoop.c
0620f9706d9aa06ba7f8982840eeb7ab2ad90e7a 03-Dec-2015 Adam Lesinski <adamlesinski@google.com> Add socket tx/rx accounting

Records network traffic going over bluetooth sockets. This patch adds support
for L2CAP and RFCOMM.

Bug: 26039657
Change-Id: Id30d69e4cd648f0e88ab23517e3b94f29b393995
tif_core.c
tif_dm.c
tif_sock.c
tif_sock_l2cap.c
tif_sock_rfc.c
tif_uid.c
69a34362c65533155578623d30845b04fa6285b1 20-Jan-2016 Pavlin Radoslavov <pavlin@google.com> Support for A2DP Sink - Follow-up fix

Update the code so it matches the corresponding code in the internal tree.

Change-Id: I7cb143cde31e2cfca54b2172737cf262ae478186
tif_rc.c
6b84f291c4edce7e4102efd8d4052a63bcb4b9dc 05-May-2015 Anubhav Gupta <anubhavg@codeaurora.org> Support for A2DP Sink and Proper initialization of profiles

- Register SDP and SEP (Stream End Point) for the profile
whose init is called. We achieve this by making registration
api aware of profile id being called.
- Register A2DP Src + Avrcp Target + Avrcp Controller. We need
to support Absolute Volume as well, so Avrcp Controller is
required here.
- Register A2DP Sink + Avrcp Controller. In this case we do not
support absolute volume. Support would be added in AVRCP
controller change
- Adapter property is updated with profile ID for which init is
called.This is required to make changes in btService for Profile
initialization
- Start listening for incoming AVRCP connection if we have
only AVRCP Controller
- Update default peer_features based on feature mask. In case
of incoming AVRCP connection, SDP will be done later.
In such a scenario default peer features sent to btif should
be based on features-set selected during initialization.
- Drop Control, Meta and Browse commands when TG is not up.
- Not to call AVRCP app callbacks when mentioned service is down.
- Close audio socket on suspend

A2DP Sink: Support for AudioTrack

- implemetation for audiotrack to take care of audio rendering
- support for audio focus state in bluedroid

Bluetooth: Support for Avrcp 1.3 Controller

- support for SDP registration
- support for sending vendor dependant commands
- support for abs vol
- support for receiving vendor dependant response
- serialization of connection and rc_features callback

Avrcp_Ctrl: handling of commands and events for AVRCP Controller

- support of parsing cmd and event pdus
- timeout handling

Change-Id: I1e8d49b087eff6301373e1e90e8d868f15847c34
tif_av.c
tif_avrcp_audio_track.cpp
tif_media_task.c
tif_rc.c
tif_storage.c
tif_util.c
32b3a8a408b23aa28324ad9f56654c98fe2ac914 24-Dec-2015 Srinu Jella <sjella@codeaurora.org> Offload config save functionality to BTIF thread

Offload config save functionality to btif thread from
timer thread as timer callback thread is critical in
a2dp playback case.

If the timer callback thread is busy in config save due
to IO operations, it may lead to a2dp audio choppy.

Fix to avoid the "bt_config.conf" file corruption from
the file system. This will avoid losing the paired
information in some corner case, such as abrupt power
off and on. This patch will ensure bt_config is saved to
NVRAM.

Bug: 24875861
CRs-Fixed: 953993
Change-Id: I893e9afefa89cbab6e7ddd8835ca77d3e316874c
tif_config.c
1a5bb5f30385af44d11ffba10e0f5af79f0ae422 01-Dec-2015 Jakub Pawlowski <jpawlowski@google.com> Implement OOB pairing for LE devices using TK.

This patch implements OOB pairing for LE devices using TK. Patches
for other pairing methods, and other transports will follow.

Bug: 22932952
Change-Id: Iad3c0c035de3b5a62ef24d3e3b655773fa03d5c1
luetooth.c
tif_dm.c
e04dbb3707806be965f5669d3213263c0178ef26 06-Jan-2016 Ajay Panicker <apanicke@google.com> A2DP task media alarm non-null protection

Prevent the alarm from being started multiple times.

Bug: 26277592
Change-Id: I764f93bab5490bf5f3942a1beb706457197d3ec1
tif_media_task.c
0b7fc589089ce4a96daa668b9d293ce01982424d 06-Jan-2016 Sharvil Nanavati <sharvil@google.com> Fix bug where a bonded device could enter BONDING and BONDED states again.

The following sequence of events was observed:
- start bonding with device A
- bond state for A goes from 10 -> 11 -> 12
- everyone's happy
- start bonding with device B
- bond state for B goes from 10 -> 11
- bond state for A goes from 12 -> 11 -> 12

The bond state for A should not have been changed in the last step
since it was not participating in any bonding procedure at the time.

The above sequence can be reproduced if a device D bonds with
A and takes on the slave role and then D bonds with B and switches
to a master role. When D performs the role switch, it receives an
updated link key from A.

Since the link key update procedure is tied in with the pairing flow,
we see spurious bond state changes. This CL checks the pairing control
block to see if D is, in fact, pairing with A and if not, it skips the
bond state updates.

Bug: 25870383
Change-Id: Ic6ff548dbe4e960c965bdc9ef5c50a263b9b3b22
tif_dm.c
c0231ad1f96ac76cf31db0afde550bfc10b6ac7a 05-Jan-2016 Sharvil Nanavati <sharvil@google.com> Merge "Fix absolute volume reporting if AVRC_ADV_CTRL_INCLUDED is false"
5bcbaa498c0d12806a4d57a3b09a05dff5aa5a9e 17-Dec-2015 Sharvil Nanavati <sharvil@google.com> Fix absolute volume reporting if AVRC_ADV_CTRL_INCLUDED is false

Without this change, setting AVRC_ADV_CTRL_INCLUDED to false would
result in the native code reporting the remote device supports
absolute volume even though we don't.

Bug: 26070064
Change-Id: I5b88fa0adb89983de28a216898a1d8957fa454a1
tif_rc.c
a459df848e03b0f2fb3f15d54404b48b94cff560 05-Jan-2016 Sharvil Nanavati <sharvil@google.com> Only send first 16 characters of operator name in +COPS.

According to the HFP spec, the operator name is required to be at
most 16 characters long.

Bug: 24871011
Change-Id: I9987de57a327348fc2203b9502e9df446a87793f
tif_hf.c
d0aa6cc53abaf122a2426c20691ccfa025ca7369 11-Dec-2015 Andre Eisenbach <eisenbach@google.com> Blacklist devices for absolute volume control

Some devices do not play well with absolute volume control. They either
play back music at unacceptably loud volume levels or provide
insufficiently granular volume control where a single "step" of volume
change results in unexpectedly large jumps in volume.

Bug: 26070064, 26060431
Change-Id: I5a336fba87119325b47a5ad385e9c48a631f2121
tif_rc.c
581622f8349b7677db971eecca7f72c9d3598bf0 17-Dec-2015 yanlaijun <yan.laijun@gmail.com> Remove repeated code in HF BTIF init function.

Change-Id: I25a07e9cdb29ef31696a156c6f7ff5b57f4f5cfb
Signed-off-by: yanlaijun <yan.laijun@gmail.com>
tif_hf.c
d77f1999ecece56c1cbb333f4ddc26f0b5bac2c5 09-Dec-2015 Marie Janssen <jamuraa@google.com> Fix crashes with lots of discovered LE devices

When loads of devices are discovered a config file which is too large
can be written out, which causes the BT daemon to crash on startup.

This limits the number of config entries for unpaired devices which
are initialized, and prevents a large number from being saved to the
filesystem.

Bug: 26071376
Change-Id: I4a74094f57a82b17f94e99a819974b8bc8082184
tif_config.c
668c69faaa8e7b04ae77557a1cb5e615d3150c9f 03-Dec-2015 Scott James Remnant <keybuk@google.com> Merge changes I9333236a,Ie4e5992c

* changes:
Switch to osi_getbuf.
A2DP SRC offload support
47b4310e6aa9a508b47e6cd4631327c53b464440 19-May-2015 Abhijit Adsule <abhijit@motorola.com> A2DP SRC offload support

bluedroid changes to support A2DP SRC offload to BT FW.
add functionality to relay a2dp offload requests and responses
between AudioHAL & the BT vendor library.

Change-Id: Ie4e5992c48e95b0efb372a405e8537e4fd3ea071
Signed-off-by: Sridhar Vashist <svashist@motorola.com>
tif_av.c
tif_media_task.c
c28849aa58c10a4e57d6cb7e5f6d876cba4f8d99 02-Dec-2015 Ajay Panicker <apanicke@google.com> Synchronize Bluetooth stack init and cleanup

Bug: 25972918
Change-Id: Ia4fb4d74f8340862233dc5073596f3082863c941
luetooth.c
tack_manager.c
175da70b6d60349dffdee3a9cd13182b293edf4c 13-Nov-2015 Jakub Pawlowski <jpawlowski@google.com> Remove BTM_OOB_INCLUDED

Bug: 22932952
Change-Id: I35dbcd1881a8bd627d1b1c6759761a356d07bcb2
tif_dm.c
5f308397b7fe8a8da3f88b0f8910c3863ed1ec0b 15-Oct-2015 Sridhar Vashist <svashist@motorola.com> Make default SBC bitrate configurable by device.

Configurable default SBC bitrate so that audio quality can be maintained
for sampling rates other than 44.1kHz

Change-Id: Ia4197c0a500088cfa48a8ba821e9738a16c3fc6e
Signed-off-by: Sridhar Vashist <svashist@motorola.com>
tif_media_task.c
6ff83ab9dd38bdefc5d252325f0cfbd3f1754d78 19-May-2015 Abhijit Adsule <abhijit@motorola.com> A2DP SRC offload support

bluedroid changes to support A2DP SRC offload to BT FW.
add functionality to relay a2dp offload requests and responses
between AudioHAL & the BT vendor library.

Change-Id: Ie4e5992c48e95b0efb372a405e8537e4fd3ea071
Signed-off-by: Sridhar Vashist <svashist@motorola.com>

Conflicts:
audio_a2dp_hw/audio_a2dp_hw.h
bta/Android.mk
bta/av/bta_av_aact.c
btif/include/btif_media.h
btif/src/btif_av.c
btif/src/btif_media_task.c
hci/Android.mk
hci/src/vendor.c
include/bt_target.h
stack/include/l2c_api.h
tif_av.c
tif_media_task.c
c3e8824f8d5266ee5d33be18c690b8de8f0562aa 01-Dec-2015 Pavlin Radoslavov <pavlin@google.com> Fix a race condition in the HCI module start_up()

* Fix a race condition when using the static startup_future
inside hci_layer.c
The future_new() allocation happens inside function start_up()
and the allocated "startup_future" value is returned, so the caller can
call future_await(future).
However, if firmware_config_callback() is called on another thread
BEFORE the "return startup_future;" statement is reached, then
"startup_future" is reset to NULL. As a result, the caller
will call future_await(NULL), and we have memory leak: startup_future
is never freed.

* Fix other similar potential race conditions inside stack_manager.c
where the static "hack_future" variable could be reassigned between
the future_new() and future_await() calls.

Bug: 25766403
Change-Id: I0ef1165efba7412c190dfa2a7660189b28fa78a6
tack_manager.c
592afafb911cccc8aaa7d74c54f638e6bfb0a62d 25-Nov-2015 Pavlin Radoslavov <pavlin@google.com> Add missing initialization of module OSI_MODULE

Also, fix a resource leak (memory + file descriptors)
inside function AVDT_WriteReqOpt().
The leak was exposed by the module OSI_MODULE initialization fix
when audio is playing.

Bug: 21743601
Change-Id: Ia220042b9060b0640ac0851f4f9132ddf2773264
tack_manager.c
3f06e14fddc0e674347ae28ea4a25218d4ce1d2a 10-Nov-2015 Pavlin Radoslavov <pavlin@google.com> Fix SIGBUS crash when copying data

We have the following memory alignment-related issue, that seems
to be architecture/compiler/memcpy(3) specific.

Within struct tBTIF_CONTEXT_SWITCH_CBACK, the beginning of the
zero-length array "char p_param[]" is not aligned (because of the
struct internals).
However, this p_param pointer is casted within function
btif_gattc_deep_copy() to the struct pointer (btif_adv_data_t *).
By definition, the memory pointed to by such pointer is suppose
to be aligned:

btif_adv_data_t *dst = (btif_adv_data_t*) p_dest;

It seems that on some architectures/compilers the executed memcpy()
instructions are optimized for such memory alignment.
If the memory was not aligned, we get SIGBUS.

Apparently, just using (void *) casting for the memcpy() destination,
avoids using the optimized memory aligned instructions:
memcpy((void *)dst, src, ...);

The solutions are twofold:
* Make sure that "char p_param[]" within struct
tBTIF_CONTEXT_SWITCH_CBACK is aligned. Otherwise, the casting
to "(btif_adv_data_t*)" can be problematic.
* Add (void *) casting to all memcpy() calls which might be
referring to such mis-aligned memory.
This is done by using the new macro maybe_non_aligned_memcpy()
in all places that such casting might be needed.

Either solution is sufficient to prevent the crash as identified in
this particular case. We need to apply both solutions, to reduce the
chance of running again into a similar issue.

Bug: 25601669
Change-Id: I6c49645c00f10c594a5d1e53a9fac202c506657c
tif_av.c
tif_dm.c
tif_gatt_client.c
tif_gatt_server.c
tif_mce.c
tif_sdp.c
7b9fe757f5df8c529c506b1c41403f2f3f204f9e 06-Nov-2015 Andre Eisenbach <eisenbach@google.com> Always update remote address type during LE scan

This will ensure that devices which do not contain a device name in the
advertising record are stored with the correct address type to ensure
re-connection to the device succeeds.

Bug: 25499163
Change-Id: I85f18ce2de267844c5d5ed49beeb448b9b074d74
tif_gatt_client.c
03d171170c7ad4e40454a9575cfd4919d2e1ef2f 06-Nov-2015 Andre Eisenbach <eisenbach@google.com> Always update remote address type during LE scan

This will ensure that devices which do not contain a device name in the
advertising record are stored with the correct address type to ensure
re-connection to the device succeeds.

Bug: 25499163
Change-Id: I85f18ce2de267844c5d5ed49beeb448b9b074d74
tif_gatt_client.c
b7a077b6aa2af20e9505a7baf0b1d6dfa2ad24e6 29-Oct-2015 Andre Eisenbach <eisenbach@google.com> Rename net_test_bluedroid to net_test_bluetooth

Also remove other bluedroid references.

Change-Id: I349e48e50b0a0a45ca1267a765145299837601d3
luetooth.c
tif_av.c
tif_sock_l2cap.c
58593a02736ff9ac9bdccd0e3186602f17452cdf 20-Oct-2015 Andre Eisenbach <eisenbach@google.com> Remove absolute volume control whitelist

Remove the absolute volume control whitelist to enable absolute volume
control for all compatible devices.

Bug: 25081918
Change-Id: Iab0e4b4c4fd3dac0fefdf62ec80419dd64b56c0c
tif_rc.c
02a29284a26a9d63210865ae9f086c0ad730ca78 20-Oct-2015 Scott James Remnant <keybuk@google.com> Resolve merge resolution differences between branches

Change-Id: I7b2f5bcf3a43aacdfbb740589ca1538ade149473
tif_pan.c
8289925079c40ec91fa99d0ea6817f796a66681a 20-Oct-2015 Andre Eisenbach <eisenbach@google.com> Remove absolute volume control whitelist

Remove the absolute volume control whitelist to enable absolute volume
control for all compatible devices.

Bug: 25081918
Change-Id: Iab0e4b4c4fd3dac0fefdf62ec80419dd64b56c0c
tif_rc.c
258c2538e3b62a8cdb403f2730c45d721e5292b4 28-Sep-2015 Pavlin Radoslavov <pavlin@google.com> GKI cleanup - moved GKI buffer allocation wrappers to OSI

* Moved the following GKI buffer allocation functions to OSI:
- GKI_getbuf() -> osi_getbuf()
- GKI_freebuf() -> osi_freebuf()
- GKI_get_buf_size() -> osi_get_buf_size()

For now we need the osi_getbuf() / osi_freebuf() allocation wrapper,
because we need to be able to call osi_get_buf_size() on the allocated
buffer.
In the future those should be replaced with osi_malloc() / osi_free().
Currently, the osi_malloc() buffer size internal allocation tracker
does not always track the size, hence we need the osi_getbuf() wrapper.

* Replaced GKI_MAX_BUF_SIZE with BT_DEFAULT_BUFFER_SIZE

* Added new file include/bt_common.h that can be usee to include
few files that should be included alost everywhere (e.g. bt_target.h"
NOTE: This file might be removed in the future and we should include
everywhere the right set of header files.

* Removed some of the GKI-related references

* Removed file include/gki_target.h

Change-Id: Ie87830e73143de200746d54235aa99f228a95024
tif_av.c
tif_core.c
tif_dm.c
tif_gatt_client.c
tif_gatt_multi_adv_util.c
tif_gatt_server.c
tif_gatt_util.c
tif_hh.c
tif_hl.c
tif_media_task.c
tif_pan.c
tif_profile_queue.c
tif_rc.c
tif_sm.c
tif_sock_l2cap.c
tif_sock_rfc.c
tif_sock_sdp.c
tif_sock_util.c
tif_storage.c
tif_util.c
9f1c9ad85759c7663e3bbc494f8e75b2f107da67 28-Sep-2015 Pavlin Radoslavov <pavlin@google.com> GKI cleanup - Moved struct TIMER_LIST_ENT to OSI

* Moved struct TIMER_LIST_ENT to file osi/include/non_repeating_timer.h
and renamed it to timer_entry_t
NOTE: This is a short-term solution. timer_entry_t should be
removed, and its usage everywhere should be replaced by
struct non_repeating_timer_t .
* Renamed TIMER_CBACK to timer_callback_t
* Renamed TIMER_PARAM_TYPE to timer_param_t

Change-Id: I9ca830718bf900195f9c0a513a97f6995322693b
tif_av.c
tif_gatt_client.c
tif_gatt_multi_adv_util.c
tif_hh.c
tif_hl.c
1a3844f933bd63c8a381371dabfb35c6a0249e3e 25-Sep-2015 Pavlin Radoslavov <pavlin@google.com> GKI cleanup - Replaced usage of GKI queue with OSI fixed_queue

* Added new functions to OSI:
- fixed_queue_init()
- fixed_queue_length()
- fixed_queue_try_remove_from_queue()
- fixed_queue_try_peek_last()

* Renamed fixed_queue_try_peek() to fixed_queue_try_peek_first()

* Replaced usage of GKI queue functions with OSI fixed_queue functions:
- GKI_init_q() -> fixed_queue_new(SIZE_MAX)
NOTE: unlike GKI_init_q(), fixed_queue_new() allocates memory /
state that needs to be released by calling fixed_queue_free()
- GKI_enqueue() -> fixed_queue_enqueue()
- GKI_dequeue() -> fixed_queue_try_dequeue()
NOTE: fixed_queue_try_dequeue() is non-blocking
- GKI_queue_length() -> fixed_queue_length()
- GKI_queue_is_empty() -> fixed_queue_is_empty()
- GKI_getfirst() -> fixed_queue_try_peek_first()
- GKI_getlast() -> fixed_queue_try_peek_last()
- GKI_remove_from_queue() -> fixed_queue_try_remove_from_queue()
- Queue elements iteration.
In the fixed_queue implementation we have to use the underlying
list_t mechanism to iterate over the elements.
OLD:
p = GKI_getfirst(queue);
...
while ((p = GKI_getnext(p) != NULL) {
...
}
NEW:
list_t *list = fixed_queue_get_list(queue);
for (const list_node_t *node = list_begin(list);
node != list_end(list); node = list_next(node)) {
p = list_node(node);
}

* Remove initialization of the GKI module, because it is not needed
anymore

* Removed unused files in GKI:
gki/common/gki_common.h
gki/ulinux/gki_int.h
gki/ulinux/gki_ulinux.c

Change-Id: I3ff9464db75252d6faf7476a9ca67c88e535c51c
tif_media_task.c
tif_sock_l2cap.c
1eb1ea0cf2da992a3193506806e571dcbe3ec947 25-Sep-2015 Pavlin Radoslavov <pavlin@google.com> GKI cleanup - Moved functions GKI_disable() and GKI_enable() to OSI

Added new functions mutex_global_lock() and mutex_global_unlock()
within the OSI module, and replaced GKI_disable() and GKI_enable()
with those functions.

Also, minor cleanup in the gki.h header file.

Change-Id: I5f410e3174541224fcf30f37e1524ef099c25193
tif_media_task.c
2181f1a4a428926da214b94327c3bcef9d283522 06-Sep-2015 Nitin Shivpure <nshivpur@codeaurora.org> Fix PAN crash due to fd mismatch

A case, where tap read thread is always exist, Sometimes
data packets get recieved on older fd, which is not available.
which is causing assert due to fd mismatch in race condition.
when next pan connection is immediately available. If last pan
connection gets disconnected, then tap_read_thread should be
destroyed in btif context to fix this issue.

Bug: 24093456
Change-Id: Ic1053200a7be4c2091d6c394634831ca3fbd61df
tif_pan.c
70ae7de9451e3dc074a048ba98b672a6ba3a4551 23-Sep-2015 Pavlin Radoslavov <pavlin@google.com> GKI cleanup - Remove GKI pool related defines

* Removed pool ID related defines
* Updated / renamed / cleanup buffer size related defines
* Added new #define BT_DEFAULT_BUFFER_SIZE
* Removed unused defines

Change-Id: Ib1fbf463d1e6fda2c71631347de0c365a37ba5ce
tif_media_task.c
tif_pan.c
tif_sock_l2cap.c
2e3d006b96eafb0651fe7f78d28250faf89405de 18-Sep-2015 Pavlin Radoslavov <pavlin@google.com> GKI cleanup - Eliminate usage of pool buffers

* Replace usage of function GKI_getpoolbuf() with GKI_getbuf()
* Remove usage of function GKI_poolutilization()
* Remove usage of function GKI_poolfreecount()

Change-Id: Ide938192b878bbfb4912642c903fce548f2b5368
tif_hl.c
tif_media_task.c
tif_pan.c
8c24123f9897991d228865c7eec35e33569e46bb 18-Sep-2015 Andre Eisenbach <eisenbach@google.com> Change UHID socket to be non-blocking

On some platforms, the logs indicate that the BTU task is stalled by
UHID driver when writing the HID descriptor to the kernel. This patch
converts the UHID socket to non-blocking to avoid stalling the main
BTU task.

Bug: 23978964
Change-Id: I5a7a3e106fb2c967d68f077faedcd4fe62bbd912
tif_hh.c
642f233005cdcbbbcb92b77d6297fc080b7f072e 16-Sep-2015 Pavlin Radoslavov <pavlin@google.com> GKI cleanup - Eliminated function GKI_delay

Removed function GKI_delay from the GKI module, and replaced
it with a local static function inside file btif/src/btif_rc.c - the
only place it is (still) used.

Change-Id: Id8f3f700efd22d6e31c70aa8b1724ffa9afbc631
tif_rc.c
20a1555a0665efaab69ff25b3e7842d5f6c110c8 08-Sep-2015 tturney <tturney@google.com> Allow BT inquiry while discovery is in progress.

BT Inquiry is disallowed when service discovery
is in progress. Innitially when GATT discovery
is in progress (crosskey pairing), it resulted
in inquiry requests being rejected. During an
insecure connection like OPP, bonding link key
is not stored. In an earlier patch (b820aec7),
BR/EDR discovery was bypassed if the bonding was
temporary. However, this was not done for LE.
Applying the same logic to LE, resolved the
inquiry issue reported in this bug.

Bug: 23468169
Change-Id: I6111c80a420aeb0bc36a0393eb215c112512d251
tif_dm.c
28f294b94f6e05f4572672671535f66bb60f0c0a 04-Aug-2015 Ajay Panicker <apanicke@google.com> Load factory Bluetooth address from system property

Implemented a check to grab the ro.boot.btmacaddr property in case the
device fails to receive an address beforehand.

Bug: 22618015
Change-Id: Ie322888e114a732f8e85c81793e3e5e5eacffc7a
tif_core.c
2af0bb6e5f6b380f374d510c54eabdf74c32bdf2 22-May-2015 Andre Eisenbach <eisenbach@google.com> Fix merge discrepencies and resulting compile errors

Change-Id: I29fbec9f668ee9218b90a222801c9ddcb9352017
tif_core.c
bb2a4faddd9a7f03d13d37a23eb0da1ef52f9088 06-Sep-2015 Nitin Shivpure <nshivpur@codeaurora.org> Fix PAN crash due to fd mismatch

A case, where tap read thread is always exist, Sometimes
data packets get recieved on older fd, which is not available.
which is causing assert due to fd mismatch in race condition.
when next pan connection is immediately available. If last pan
connection gets disconnected, then tap_read_thread should be
destroyed in btif context to fix this issue.

Bug: 24093456
Change-Id: Ic1053200a7be4c2091d6c394634831ca3fbd61df
tif_pan.c
ef7d8cb8b012e77c9b0c596c5ad4b0ffb7e5dde9 18-Sep-2015 Andre Eisenbach <eisenbach@google.com> Change UHID socket to be non-blocking

On some platforms, the logs indicate that the BTU task is stalled by
UHID driver when writing the HID descriptor to the kernel. This patch
converts the UHID socket to non-blocking to avoid stalling the main
BTU task.

Bug: 23978964
Change-Id: I5a7a3e106fb2c967d68f077faedcd4fe62bbd912
tif_hh.c
2a1b8ac5b15f3026fac1c697fc3b9c04228051f0 08-Sep-2015 tturney <tturney@google.com> Allow BT inquiry while discovery is in progress.

BT Inquiry is disallowed when service discovery
is in progress. Innitially when GATT discovery
is in progress (crosskey pairing), it resulted
in inquiry requests being rejected. During an
insecure connection like OPP, bonding link key
is not stored. In an earlier patch (b820aec7),
BR/EDR discovery was bypassed if the bonding was
temporary. However, this was not done for LE.
Applying the same logic to LE, resolved the
inquiry issue reported in this bug.

Bug: 23468169
Change-Id: I6111c80a420aeb0bc36a0393eb215c112512d251
tif_dm.c
1a1b3ebb41aa89f0ab38ea6ef41444f7f9b010f5 24-Aug-2015 Ian Coolidge <icoolidge@google.com> am bc6ad53e: Merge "Improve adv_data transfer between contexts."

* commit 'bc6ad53e310c2b6b1734883e8d92f5c147279d23':
Improve adv_data transfer between contexts.
d4c103624b3d7672110abeb753ed79113ee48989 08-Aug-2015 Ian Coolidge <icoolidge@google.com> Improve adv_data transfer between contexts.

- Drops some unused members from btgatt_multi_adv_inst_cb.
- Flatten tBTA_BLE_ADV_DATA to only require one allocation.
- Copy all of tBTA_BLE_ADV_DATA contents to bt_workqueue_thread.

Bug: 23042223
Change-Id: I5f4d25d5cdd39731a2dfe64394928b7fb77c7c7c
tif_gatt_client.c
tif_gatt_multi_adv_util.c
bc1a074d837d0c493d6ab9e8812ee1aca423cd0f 07-Aug-2015 Marie Janssen <jamuraa@google.com> am 4161eb61: build: fix missing include

* commit '4161eb610dc8152fad833aa1f187a9af52fd7c0d':
build: fix missing include
1efdfe4aa1949f3f6884618ebdd7a69e4b71236e 07-Aug-2015 Marie Janssen <jamuraa@google.com> am 8f247258: build: fixes for breakages on tilapia

* commit '8f247258317bfd015806badce0cc41df901fa6e7':
build: fixes for breakages on tilapia
08393054f0867d0f86a7f9c2eb156e67a86382c7 07-Aug-2015 Marie Janssen <jamuraa@google.com> resolved conflicts for merge of 49a86709 to mnc-dev-plus-aosp

Change-Id: Icd7ec2fd78ac4383da430708a88abaeba9009437
4161eb610dc8152fad833aa1f187a9af52fd7c0d 07-Aug-2015 Marie Janssen <jamuraa@google.com> build: fix missing include

fatfingered this needed include out of this file

Change-Id: Id4c8d3223b25d0747a2739891e43652c475d399c
tif_gatt_multi_adv_util.c
8f247258317bfd015806badce0cc41df901fa6e7 07-Aug-2015 Marie Janssen <jamuraa@google.com> build: fixes for breakages on tilapia

Only include advertising when we can actually advertise on LE.

Change-Id: I380c67db4391650591b94611c4d522bf49fac750
tif_gatt_multi_adv_util.c
tif_hl.c
c1553d3cab1a17cad8713ee61e1833903c0a6d89 04-Aug-2015 Ajay Panicker <apanicke@google.com> Load factory Bluetooth address from system property

Implemented a check to grab the ro.boot.btmacaddr property in case the
device fails to receive an address beforehand.

Bug: 22618015
Change-Id: Ie322888e114a732f8e85c81793e3e5e5eacffc7a
tif_core.c
49a86709488e5cfd5e23759da18bf9613e15b04d 08-Jul-2015 Marie Janssen <jamuraa@google.com> build: LOG_TAG consistency, include order, build fixes

Fix the order of includes across a bunch of files, and declare LOG_TAG
at the top of every file in which it is used.

Consistently use bt_ as a LOG_TAG prefix.
Fix issues with LOG macro usage.
Remove unused includes and double-includes (when in related .h)

Add includes as necessary to compile cleanly (problems surfaced by
reordering includes)

Change-Id: Ic55520c8302b06bbc1942c10c448b20844669da6
luetooth.c
tif_av.c
tif_config.c
tif_dm.c
tif_gatt.c
tif_gatt_client.c
tif_gatt_multi_adv_util.c
tif_gatt_server.c
tif_gatt_test.c
tif_gatt_util.c
tif_hf.c
tif_hf_client.c
tif_hh.c
tif_hl.c
tif_mce.c
tif_profile_queue.c
tif_rc.c
tif_sdp.c
tif_sdp_server.c
tif_sm.c
tif_sock_l2cap.c
tif_sock_sdp.c
tif_sock_thread.c
tif_sock_util.c
tif_storage.c
tif_util.c
tack_manager.c
6fc5461ea7f0f39bf658684564e25cd3551ca284 05-Aug-2015 Ajay Panicker <apanicke@google.com> am aa3be1a6: Implement Bluetooth settings factory reset (3/5)

* commit 'aa3be1a696b9ae1142fe9f358ad5f97e99da7892':
Implement Bluetooth settings factory reset (3/5)
aa3be1a696b9ae1142fe9f358ad5f97e99da7892 29-Jul-2015 Ajay Panicker <apanicke@google.com> Implement Bluetooth settings factory reset (3/5)

Implemented the factory reset function to be used to reset all bluetooth
settings on device to factory default

Bug: 16161518
luetooth.c
tif_config.c
61d666852fc7f4982d73c5d1ec3f2f512e0a02da 04-Aug-2015 Pavlin Radoslavov <pavlin@google.com> am caaa00f5: Fix a crash for a race condition during Bluetooth shutdown

* commit 'caaa00f5ede96461e11de866ac15f5224442d1eb':
Fix a crash for a race condition during Bluetooth shutdown
caaa00f5ede96461e11de866ac15f5224442d1eb 04-Aug-2015 Pavlin Radoslavov <pavlin@google.com> Fix a crash for a race condition during Bluetooth shutdown

This is same race condition observed in btif_media_task_aa_tx_flush_req()
because btif_media_task_aa_tx_flush_req() and btif_media_task_stop_aa_req()
are called back-to-bach.

This race condition is triggered when A2DP audio is streaming on shutdown:
"btif_a2dp_on_stopped() -> btif_media_task_stop_aa_req()" is called
to stop the particular audio stream, and this happens right after
the "cleanup() -> btif_a2dp_stop_media_task()" processing during
the shutdown of the Bluetooth stack.

Bug: 22700411
Change-Id: Ia0c98d44a108cf0f57731ac8129e4d76c9934542
tif_media_task.c
49ae04e9a6af853a4de9ecab821d295b48e624f8 29-Jul-2015 Andre Eisenbach <eisenbach@google.com> am b61d25c5: Fix memory leak in A2DP event handler

* commit 'b61d25c52fcfa1853c7555acda61d848ef6be3e9':
Fix memory leak in A2DP event handler
b61d25c52fcfa1853c7555acda61d848ef6be3e9 29-Jul-2015 Andre Eisenbach <eisenbach@google.com> Fix memory leak in A2DP event handler

btif_av_event_free_data() was not called in all states (idle state only)
leading to potential memory leaks.

Bug: 22822688
Change-Id: I40520c605c9a806e6cd5ee6e36c101d0aa8d4355
tif_av.c
e9d2d9bf736c83398be134d2b930fd2475a73145 24-Jul-2015 Arman Uguray <armansito@google.com> am f2d6434a: gn-build: Add bluetooth-service target

* commit 'f2d6434a6b7ad98e20c7a601d2a0950237514837':
gn-build: Add bluetooth-service target
ff6bf3f0797ad255352c6d2eb931e3a5d059bea3 24-Jul-2015 Andre Eisenbach <eisenbach@google.com> am 196413f5: Fix TX queue overflow detection

* commit '196413f5ca088ef97866092f02bb7571d2a44390':
Fix TX queue overflow detection
196413f5ca088ef97866092f02bb7571d2a44390 22-Jul-2015 Andre Eisenbach <eisenbach@google.com> Fix TX queue overflow detection

- Prevent possible endless loop if |nb_frame| is too high
- Remove off-by-one calculation before sending frames
- Remove log spam and add better debug info

Bug: 22658329
Change-Id: I374ee980aec48763beb49b4f6f8b076124cadf40
tif_media_task.c
f2d6434a6b7ad98e20c7a601d2a0950237514837 09-Jul-2015 Arman Uguray <armansito@google.com> gn-build: Add bluetooth-service target

This patch makes the Bluetooth system service (service/) buildable using GN:

1. Added new BUILD.gn file for service/
2. Added conditional compilation for global config paths, with TODOs for
generalizing them later.
3. Added a shim for loading the Bluetooth library that calls hw_get_module on
Android and explicitly calls dlopen on OS_GENERIC.
4. Fixed compile warnings and errors.
5. Did some minor clean up in gatt_server.cpp for better readability.

Bug: 22124644
Change-Id: I3226537a3a5211a6762651a35707638df29956b0
tif_config.c
tif_core.c
tif_storage.c
551714190f58ccfab196c9adc3ffe462ecf2280e 22-Jul-2015 Pavlin Radoslavov <pavlin@google.com> am 197ee685: Fix a crash for a race condition during Bluetooth shutdown

* commit '197ee6856b43d8eea137a7f37798ee2a012ce518':
Fix a crash for a race condition during Bluetooth shutdown
fd73552668d27e3ccdff5b95757f9ccfde501c91 22-Jul-2015 Nitin Arora <niarora@codeaurora.org> am ac72840a: Update device type correctly in the NVRAM at inquiry result

* commit 'ac72840a3d7409adbb3ee4904ab1ed5de2d66586':
Update device type correctly in the NVRAM at inquiry result
197ee6856b43d8eea137a7f37798ee2a012ce518 22-Jul-2015 Pavlin Radoslavov <pavlin@google.com> Fix a crash for a race condition during Bluetooth shutdown

This race condition is triggered when A2DP audio is streaming on shutdown:
"btif_a2dp_on_stopped() -> btif_media_task_aa_tx_flush_req()" is called
to stop the particular audio stream, and this happens right after
the "cleanup() -> btif_a2dp_stop_media_task()" processing during
the shutdown of the Bluetooth stack.

Bug: 22602117
Change-Id: I5de6a8f15b6a2771dde2e299a5b60554063696a2
tif_media_task.c
ac72840a3d7409adbb3ee4904ab1ed5de2d66586 27-Jun-2015 Nitin Arora <niarora@codeaurora.org> Update device type correctly in the NVRAM at inquiry result

This patch checks for the NVRAM data when inquiry result
is received from the remote device. In case the device is
marked as LE only or BR/EDR only, and inquiry result is
received from the alternate transport, the device type is
marked as Dual mode in the NVRAM

Bug: 22604450
Change-Id: Id925e8bad152a33c2bd3c371ca42a6f9c694e3b0
tif_dm.c
51a5f0fef5ebee14e5e41e3b180f2795b2d6c771 21-Jul-2015 Nitin Arora <niarora@codeaurora.org> am b4365c55: Adding transport type while initiating remote discovery

* commit 'b4365c55ccb2e985d00619c30dc14d5c156771b7':
Adding transport type while initiating remote discovery
cf0189a1a73e9ab14a420db403bb36bd5e97b10f 21-Jul-2015 Andre Eisenbach <eisenbach@google.com> am 280368c7: Fix potential crash when transcoding legacy config files

* commit '280368c7aa3b3e1dc5236a824f1f6c765967e253':
Fix potential crash when transcoding legacy config files
b4365c55ccb2e985d00619c30dc14d5c156771b7 26-Jun-2015 Nitin Arora <niarora@codeaurora.org> Adding transport type while initiating remote discovery

This change ensures that the completion of SMP pairing for LE
devices specifically requests remote device discovery based on
transport type set to LE to prevent initiation of BR/EDR
connection due to incorrect transport type info

Bug: 22515456
Change-Id: Id1e5603d3cc53ca3dff427b93059a00f8d9150a7
tif_dm.c
280368c7aa3b3e1dc5236a824f1f6c765967e253 21-Jul-2015 Andre Eisenbach <eisenbach@google.com> Fix potential crash when transcoding legacy config files

Bug: 22634292
Change-Id: I64745671f3b69fc7e6913213aeec55267e9bc49b
tif_config_transcode.cpp
8ad14e310bf2e535c09e67c6a20e1caf989fb3a6 21-Jul-2015 Pavlin Radoslavov <pavlin@google.com> resolved conflicts for merge of 65f9c04a to mnc-dev-plus-aosp

Change-Id: I4d7f657175347b2625f222b3cf6ab60fd37fb238
65f9c04aa36af5379ba3a28dba36a5de16686024 17-Jul-2015 Pavlin Radoslavov <pavlin@google.com> Fix the logic for removing bonded devices

* Removed btif_storage_is_device_bonded(), because it is not needed,
and it was giving the wrong answer in use cases like Smart Setup
with BR/EDR connections.

* Added a call to btif_storage_remove_ble_bonding_keys()
within btif_storage_remove_bonded_device() so the bonded device
state is properly removed.

* Don't save the BLE bonding keys if it is temporary bonding

Bug: 22233299
Change-Id: I33d9f76a124acc60173f0acaa517bc29ee6603e8
tif_dm.c
tif_storage.c
b2fc085f97092557226016d5c9eba2b77c3d40dd 15-Jul-2015 Srinu Jella <sjella@codeaurora.org> am 21331c62: Store the link key derived from cross tranport link key

* commit '21331c62310dda2f523712c536da3e65afce0f38':
Store the link key derived from cross tranport link key
21331c62310dda2f523712c536da3e65afce0f38 16-Jun-2015 Srinu Jella <sjella@codeaurora.org> Store the link key derived from cross tranport link key

Use case: PTS test case for cross transport link key
derivation

Steps to reproduce:
1. Start Test case GAP TP/LEP/DM/BV-15 in PTSv6.0

Failure: PTS test case TP/LEP/DM/BV-15 fails as the link
key is not stored when the key is derived from other
transport key. So it will again go for pairing even though
it has link key but not stored.

Root cause: Link key is stored only when bond type is
presistent, but it sets the bond type to persistent only
when it receives SSP request but not link key is derived.

Fix: So making the solution generic to store always when the
link key type is authenticated combination key with P-256.

Bug: 22486860
Change-Id: I3eb201262f72c86a9438351cad14a6698065fa90
tif_dm.c
59522cee564a6a647d8c49dd15f34d6d21d26560 13-Jul-2015 Andre Eisenbach <eisenbach@google.com> resolved conflicts for merge of 27c4e634 to mnc-dev-plus-aosp

Change-Id: Id6d78e484d58042e93e4d4ea34522d15a6e1ba59
27c4e634cb0d6e618bc3e53da7c0f9a305d1593b 07-Jul-2015 Andre Eisenbach <eisenbach@google.com> Move pairing auto-retry workaround to new interop db

Change-Id: I7177aaa0e2d0c3b0fa79ae655c0171f0703c54f3
tif_dm.c
9a78e8d25416325308fa700bb38459817eeb5c7a 08-Jul-2015 Marie Janssen <jamuraa@google.com> am 49120dc8: build: Fix LOG_TAG define breakage, macro usage

* commit '49120dc867c7818511b5afec461dfc97d17eef58':
build: Fix LOG_TAG define breakage, macro usage
49120dc867c7818511b5afec461dfc97d17eef58 08-Jul-2015 Marie Janssen <jamuraa@google.com> build: Fix LOG_TAG define breakage, macro usage

Fixes build breakages related to r.android.com/156982

Change-Id: Ib1143c41fe05a17c296226998afdb41a8cb6294a
tif_config.c
tif_core.c
tif_dm.c
tif_gatt_client.c
tif_gatt_server.c
tif_gatt_test.c
tif_gatt_util.c
tif_hh.c
tif_media_task.c
tif_pan.c
tif_profile_queue.c
tif_sdp.c
tif_sdp_server.c
tif_sock.c
tif_sock_l2cap.c
tif_sock_rfc.c
tif_sock_sco.c
tif_storage.c
tack_manager.c
d33e39f14834ddfcfad27b9bef5ffb87919a8644 07-Jul-2015 Marie Janssen <jamuraa@google.com> am db554581: build: Update osi log functions, use consistently

* commit 'db554581079863974af8e1289646f5deea6fc044':
build: Update osi log functions, use consistently
35c23212a797bf67e8c41114a60ed4dca10c134c 07-Jul-2015 Anubhav Gupta <anubhavg@codeaurora.org> am fd0e9f19: Properly handle outgoing connection requests in opening/opened state

* commit 'fd0e9f1915dab624282c9d11ac6a1c7228c18c75':
Properly handle outgoing connection requests in opening/opened state
843101be012626fcc5843269e8edc4ff592866d9 07-Jul-2015 Anubhav Gupta <anubhavg@codeaurora.org> am 9c5d0727: Override remote suspend flag on local play state changes

* commit '9c5d0727dd4cd09e44c032506c28ab4120ad3b88':
Override remote suspend flag on local play state changes
e116777afad843f097c48755ef00fbb68969138a 07-Jul-2015 Srinu Jella <sjella@codeaurora.org> am f1029c7a: Remove stored link key for temporarily paired devices

* commit 'f1029c7afb9b4c9fcf95b3f98ce9c68b10d5a02c':
Remove stored link key for temporarily paired devices
fd0e9f1915dab624282c9d11ac6a1c7228c18c75 04-Sep-2013 Anubhav Gupta <anubhavg@codeaurora.org> Properly handle outgoing connection requests in opening/opened state

This happens in race conditions when we try to connect to a remote
A2DP device from Bluetooth Settings UI and simultaneously there is incoming
connection request from previously connected remote. This fix addresses
the scenario where because of first A2DP connection btif moves to opening/
opened state and then the second connect request is received.
This scenario is handled by gracefully rejecting the second connect request
from btif layer if it is already connected or about to be connected by the
first connect request.

Bug: 22028876
Change-Id: I53be400d1d7c9a84ca9d9a75b6b6f010975cf0cf
tif_av.c
9c5d0727dd4cd09e44c032506c28ab4120ad3b88 27-Jul-2013 Anubhav Gupta <anubhavg@codeaurora.org> Override remote suspend flag on local play state changes

- Remote device may initiate AVDTP Suspend within 3s of AVRCP pause,
which sets remote suspend flag. Later on resumption of local playback
A2DP packets can not be processed further as Remote suspend flag
remains set. current change overrides remote suspend flag if local
suspend is triggered later.
- This change covers the usecase where play is pressed from DUT UI
before local suspend triggers in such scenarios current change takes
care of resetitng remote suspend flag on AVRCP play state change event.
- Moreover this change will drop A2DP packets when the setparameter
is called with A2dpSuspended=true and resumes when the mentioned parameter
is reset.

This change along with corresponding app change helps mitigating
issues reported due to A2Dp, HFP synchronizations and local and remote
device initiated AVDTP suspend handling.

Bug: 22028876
Change-Id: I3bb334373414170254744d9233cbd2e66219bfa0
tif_av.c
tif_hf.c
tif_media_task.c
tif_rc.c
f1029c7afb9b4c9fcf95b3f98ce9c68b10d5a02c 02-Sep-2014 Srinu Jella <sjella@codeaurora.org> Remove stored link key for temporarily paired devices

Problem: Device shows up in paired list during just work pairing

1. Create a connection from DUT to remote.
2. Remove the link key in remote.
3. Send a file from remote to DUT.
4. Turn OFF BT. Turn ON.

Failure: Device should not move to paired list after BT on/off
as device removed from UI during just work pairing

Root cause: remote device is not removed from btif but
its removed from UI during justworks pairing

Fix: remote device is removed from btif during justworks
pairing to sync up UI and btif paired list

Bug: 19417758
Change-Id: I73de0a94c4f7ada644d258790a9e3e4bf11fc4e5
tif_dm.c
tif_storage.c
289bfeae1303b3407a77b7c088a47672913d171a 07-Jul-2015 Nitin Arora <niarora@codeaurora.org> am 4f6c9b4f: Use correct transport type while encrypting link

* commit '4f6c9b4f68d152baf7aa029cbe9b570994584101':
Use correct transport type while encrypting link
db554581079863974af8e1289646f5deea6fc044 26-Jun-2015 Marie Janssen <jamuraa@google.com> build: Update osi log functions, use consistently

Update the LOG_* functions to take a tag argument which makes them more
consistent with the Android Log.*(TAG, s) common syntax and removes
some #define-dependency with osi/include/log.h.

Also update to never use Android log functions directly.

Also contains minor cleanup of some header includes.

Bug: 21569831
Change-Id: If07385cafbea062232ecdbc7c673f908d5ef8921
luetooth.c
tif_config.c
tif_config_transcode.cpp
tif_core.c
tif_dm.c
tif_gatt_client.c
tif_gatt_server.c
tif_gatt_test.c
tif_gatt_util.c
tif_hh.c
tif_hl.c
tif_media_task.c
tif_pan.c
tif_profile_queue.c
tif_sock.c
tif_sock_l2cap.c
tif_sock_rfc.c
tif_sock_sco.c
tif_sock_util.c
tif_storage.c
tack_manager.c
4f6c9b4f68d152baf7aa029cbe9b570994584101 10-Jun-2015 Nitin Arora <niarora@codeaurora.org> Use correct transport type while encrypting link

This patch uses the transport type from the GATT event instead
of using the device type stored in NVRAM, to determine the
transport type while encrypting the link. The issue is seen
with dual mode devices, when the connection on LE transport
causes encryption request on the BR/EDR transport

Bug: 21652097
Change-Id: I895756f9c0048b5a559ea00f633b1100109e52b8
tif_gatt_client.c
tif_gatt_server.c
tif_gatt_util.c
557064ccf0b7e0722a152fbf341adab3c969269d 27-Jun-2015 Pavlin Radoslavov <pavlin@google.com> am 3a2fa83d: Copy an AVRC packet before sending a response back

* commit '3a2fa83dac1b07b661a20e2412aad9bf81492106':
Copy an AVRC packet before sending a response back
3a2fa83dac1b07b661a20e2412aad9bf81492106 26-Jun-2015 Pavlin Radoslavov <pavlin@google.com> Copy an AVRC packet before sending a response back

Don't reuse AVRC buffers for responding back. Apparently,
in the AVRC packets we transmit the offset with the payload must
be at least 15 octets. If the original buffer is not large enough,
this results in memory corruption.

Also, use an explicit check for 'bt_rc_ctrl_callbacks' as a workaround
until the upper layer does the right thing with the callbacks registration.

Bug: 22006014

Change-Id: I28c248d1580bdddbda76298d19faadf8985187fc
tif_rc.c
607cbdac9199d416043bcb1ff10c47f7834794b8 25-Jun-2015 Avish Shah <avshah@broadcom.com> am 8bc9ca59: Resolved incorrect AV startup sequence

* commit '8bc9ca592a1c80d50f85b4dafba24ba2394b4ab7':
Resolved incorrect AV startup sequence
8bc9ca592a1c80d50f85b4dafba24ba2394b4ab7 25-Jun-2015 Avish Shah <avshah@broadcom.com> Resolved incorrect AV startup sequence

Issue:
-> In AV start-up sequence, State machine initialization was being
called after enabling Btif A2dp service.
-> In that case, State machine handle will be empty and it will
prevent enable and register events to enter into BTIF.
-> Because of the absence of enable/register events, AV module in
stack will be unaware of upper layer registration and will not
proceed for connection.

Fix:
-> Changed the sequence in AV start-up, initialized State machine
first before dispatching any events to State machine.
-> So, the handle will not be empty and will not block events like
BTA_AV_ENABLE_EVT and BTA_AV_REGISTER_EVT to enter into BTIF.

Bug: 21451237
Change-Id: I5d47e20ed68ea5730a7c149c316446eb8a1d41af
tif_av.c
50356f0e5be2bb857e4eb52c9a1ee76640bdfcaf 25-Jun-2015 Miao Chou <mcchou@google.com> am 10969128: build: Eliminate cutils/sockets dependencies from system/bt

* commit '109691281c0135fd4298debcdec37fdc5855261e':
build: Eliminate cutils/sockets dependencies from system/bt
109691281c0135fd4298debcdec37fdc5855261e 10-Jun-2015 Miao Chou <mcchou@google.com> build: Eliminate cutils/sockets dependencies from system/bt

Eliminate cutils/sockets dependencies by pulling sources files from
core/libcutils into osi/.
- Pulled source files from cutils/ into osi/ and modified GN files and
Android.mk
- Updated includes to use the headers in osi/ and removed unused/duplicated
headers.
- Renamed the functions of osi/sockets and updated wherever they are called
to avoid usign symbols from cutils/sockets, since other cutils
dependencies have not been eliminated yet.

Bug: 21667795
Change-Id: I3dd4371d585f120d97ac0433ab1f35edb820dbb9
tif_hl.c
tif_sock_thread.c
tif_sock_util.c
96111f705bf17273e22c90181a0ef7b275400d6b 23-Jun-2015 Hemant Gupta <hemantg@codeaurora.org> am 0bcf0c6e: HID: Allow reconnection from Host on paired HID Devices.

* commit '0bcf0c6e6b5b09b9bc7f856f739e57321120f67b':
HID: Allow reconnection from Host on paired HID Devices.
0bcf0c6e6b5b09b9bc7f856f739e57321120f67b 04-Aug-2014 Hemant Gupta <hemantg@codeaurora.org> HID: Allow reconnection from Host on paired HID Devices.

Host can send connection request when paired HID device
is in disconnected state. We are not checking the
NORMALLY_CONNECTABLE flags from sdp record, and by default
sending this request from host, for subsequent user initiated
connection to paired remote HID Devices.
If the remote HID is in page scan mode, it will get connected
and if not, connection will fail after retrying until
HID_HOST_MAX_CONN_RETRY times.

Without this patch, if remote hid device sdp record shows that
device's NORMALLY_CONNECTABLE flag is false, host will not be
able to create outgoing connection to remote device even if the
device is in pairing mode until device is unpaired giving bad
user experience.

Bug: 22028876
Change-Id: I2b3c5c25dc7b08ab6ed0c3667897e5ea0f05f914
tif_hh.c
1ee74df81106f6e5293d3216c1952d4629c4de14 23-Jun-2015 Anubhav Gupta <anubhavg@codeaurora.org> am a0124571: Suspend AVDTP link in remote initiated AVDTP Start

* commit 'a0124571e3d5455448dbfcea7617f583b20210f9':
Suspend AVDTP link in remote initiated AVDTP Start
a0124571e3d5455448dbfcea7617f583b20210f9 12-Aug-2013 Anubhav Gupta <anubhavg@codeaurora.org> Suspend AVDTP link in remote initiated AVDTP Start

As media player is not started as part of remote initiated
AVDTP start, hence if link is kept in Started state when
remote initiated START is received it unncessarily blocks
power manager to trigger sniff on that link which increases
power number.
Related issue is seen with Moto HS820, Denso08.
These peer devices send AVDTP start on AVDTP connect and
does not suspend causing link not to go to sniff.
This change takes care of sending suspend in such scenarios
DUT initiated start gets triggered when local playback starts.
Moreover this change helps in suspending streaming if remote
initiates avdtp start during an ongoing call. This helps
remote and DUT's a2dp state to be in sync.

Bug: 22028876
Change-Id: I8ebee009c95148cf733e39d897bc8ffe5af7791e
tif_av.c
a918eb91348acf453c426f316146f8f1f464f632 18-Jun-2015 Andre Eisenbach <eisenbach@google.com> am ee039728: Add deep copy of AVRCP metadata commands

* commit 'ee03972892ca31fe47a759f69be15dd46b0abefe':
Add deep copy of AVRCP metadata commands
ee03972892ca31fe47a759f69be15dd46b0abefe 16-Jun-2015 Andre Eisenbach <eisenbach@google.com> Add deep copy of AVRCP metadata commands

The data structure for RC metadata event contains pointers within.
Added deep copy of the data structures to avoid memory corruption.

Bug: 20017069
Change-Id: Ibc5bc75cfd62abda9611060b5b435bed9e472376
tif_av.c
5de94fbdceb7af83ac6d0eabdbb4c0b67863072d 13-Jun-2015 Arman Uguray <armansito@google.com> am bb954527: build: Fix ptr <-> integer cast warnings

* commit 'bb95452741bfd65723ea417c25dbd326c7568ab7':
build: Fix ptr <-> integer cast warnings
f4b0c9242b09316b228234219b67efcbffd7eaec 13-Jun-2015 Arman Uguray <armansito@google.com> am cab5fc17: gn-build: Remove all -Wno-unused-* flags from build files

* commit 'cab5fc179730ce6910989307680b275195876c4d':
gn-build: Remove all -Wno-unused-* flags from build files
bb95452741bfd65723ea417c25dbd326c7568ab7 03-Jun-2015 Arman Uguray <armansito@google.com> build: Fix ptr <-> integer cast warnings

This CL removes the -Wno-pointer-to-integer-cast and
-Wno-integer-to-pointer-cast flags from GN build files. The resulting errors
were fixed using the following:

1. All ptr <-> integer casts are now done by using the new
PTR_TO_INT/INT_TO_PTR macros defined in osi.h

2. The TIMER_PARAM_TYPE macro, defined in gki/common/gki.h and
include/bt_target.h have been redefined as void* rather than UINT32. This
is better, since "void*" can act as a simple container without any
precision loss that would be caused by a type such as UINT32 on 64-bit
systems. void* inherently is a safer container for all pointer types but
UINT32 isn't.

BUG=21570302

Change-Id: I4a82c4a40c91caa31e372382c40d424be220cbe3
tif_av.c
tif_gatt_client.c
tif_gatt_multi_adv_util.c
tif_hh.c
tif_hl.c
tif_pan.c
tif_sdp.c
tif_sdp_server.c
tif_sock_l2cap.c
tif_sock_rfc.c
cab5fc179730ce6910989307680b275195876c4d 02-Jun-2015 Arman Uguray <armansito@google.com> gn-build: Remove all -Wno-unused-* flags from build files

This CL removes the -Wno-unused-variable, -Wno-unused-value, and
-Wno-unused-function flags from all GN build and Android.mk files
(except in test/ & tools/, which are not built using GN yet). Compile
warnings, caused by the newly enabled flags, have been fixed throughout
the code base.

Bug: 21570302

Change-Id: I1c128b62256faa17668124798341005bcd0f7315
tif_hl.c
tif_sdp.c
tif_sdp_server.c
tif_sock_l2cap.c
tif_storage.c
9df517bb2e81f29e51a4da8b8dd436c7649b6211 12-Jun-2015 Pavlin Radoslavov <pavlin@google.com> am 74626115: Re-enable the OSI memory allocation tracker.

* commit '74626115db17478a12d1d39bcefd5af500fadfda':
Re-enable the OSI memory allocation tracker.
74626115db17478a12d1d39bcefd5af500fadfda 11-Jun-2015 Pavlin Radoslavov <pavlin@google.com> Re-enable the OSI memory allocation tracker.

Previously, the OSI memory allocation tracker was disabled as
a temporary workaround for Bug 21561735.
The root cause for the original issue is now addressed by using the
appropriate linker flags when generating the bluetooth.default.so
shared library:

LOCAL_LDLIBS := -Wl,-Bsymbolic,-Bsymbolic-functions

Also, added missing #include in file "btif/src/btif_sock_sco.c"

Bug: 21561735
Change-Id: I384a6f3d1d03c74f8d1e3c96bf7e0b5961206feb
luetooth.c
tif_sock_sco.c
979e3421c8111a56ebfcf176f6383df58eed52ea 11-Jun-2015 Andre Eisenbach <eisenbach@google.com> Fix mnc-dev <-> master merge errors

Change-Id: If4d56229de7d47289560a12205feb7e33ac6fcf5
tif_dm.c
tif_gatt_client.c
6fc4832730341b0ba944e5de72ffe5171089f8b7 11-Jun-2015 Arman Uguray <armansito@google.com> am 625ec341: gn-build: Fix GN build after the merges

* commit '625ec34106a70d9299c68593279a0d9c77bfd87f':
gn-build: Fix GN build after the merges
625ec34106a70d9299c68593279a0d9c77bfd87f 11-Jun-2015 Arman Uguray <armansito@google.com> gn-build: Fix GN build after the merges

This CL fixes the GN build after the recent merges to aosp/master.

Change-Id: I0c9d8178986165d5a4a67261532e8a08b6923d22
tif_sdp_server.c
tif_sock_sco.c
ab813119d61a3ca8ac8ecb5239b73bf77e2c05bb 11-Jun-2015 Andre Eisenbach <eisenbach@google.com> Fix more BLE_INCLUDED == FALSE build breakage

Change-Id: I2da6dcdaced78d3a3bce6002fc3885c7480fba82
tif_storage.c
087d1acc3f41829e9ce982e6172260d35527e85e 10-Jun-2015 Dan Albert <danalbert@google.com> Add missing include.

osi_malloc was never included, so it was implicitly defined as
returning an integer (thank you, C). Clang caught the int to pointer
conversion error.

Change-Id: I0d8a3363d92cb72a22780d049a53e193d2e50ec5
tif_sdp_server.c
2a527108d22861aa4091143c740e09235b3692c5 15-Oct-2014 Hemant Gupta <hemantg@codeaurora.org> Add proper checks for PAN & BNEP in BD stack

This patch fixes issues for PAN & BNEP in BD stack identified
by static analysis tool.

Change-Id: I29417dae982abb5cef11379f8d03baad11ffde8b
tif_pan.c
4633fb8d4b0376474f6d38c58ee5ee563a392ef5 07-Nov-2014 Mallikarjuna GB <gbmalli@codeaurora.org> Fix issues in A2dp, Avrcp, HF and AG reported by static analysis tool

- Fixes to validate Array Index Value and Null Pointer
Dereference reported by static analysis tool.

Change-Id: Id1492315f68378fdcfa517bd0a5cacefc8ebfddb
tif_hf.c
335c208713b3c9eadcc301acac947b2f96e31da6 17-Nov-2014 Anubhav Gupta <anubhavg@codeaurora.org> Ignore STOP command if A2DP stream is suspended

Ignore STOP command if A2DP stream is already suspended.
Some carkits send STOP command before VOIP call initiation
but don't send PLAY when call ends which hinders DUT to resume
audio playback after call termination.

Change-Id: I41cc1fc6f4b6cfaa1560d729baa0ca27f6dfe8c8
tif_rc.c
5e45edb7f50497436d00423327c55707588211eb 07-Oct-2014 Anubhav Gupta <anubhavg@codeaurora.org> Remove check for stream type in a2dp hal_callbacks.

Stream type is invalid till signalling channel
connection establishment is completed. Do not
check stream type while calling HAL callback.

Change-Id: I69fb19636f3e9bb72202c450dcef9e7bc2e53731
tif_av.c
c3aa28eb96782e966d3b044eb9edeeedaa95bd39 13-Mar-2014 Anubhav Gupta <anubhavg@codeaurora.org> Reject second AVRCP connection.

This change rejects the RC connection from
second device if the DUT is already connected
to RC of first device.
This addresses the problem of improper closure
of Uinput device on disconnection of Avrcp
to make sure Avrcp passthrough commands work
as desired.

Change-Id: If2e39cd90575baffd0e4442b8e7cd2a91eebdf56
tif_rc.c
b92ab7d8d5154b9539cf3a5355a0adc1d736773a 21-May-2015 Mallikarjuna GB <gbmalli@codeaurora.org> Initialize btif_max_hf_clients with proper value

btif_max_hf_clients which is an unsigned 16bit integer is
initialized with -1(0xFFFF) in btif_hf.c. Later on, when
application calls init with max_hf_clients as 1, btif_max_hf_clients
will be set to 1. But, before this happens, context switch happened
from application context to btif context with btif_max_hf_clients as -1.
In the btif context, BTA_AgRegister gets called in for loop for 0xFFFF
times. We are running out of scbs due to this.
Initialize btif_max_hf_clients with 1. Assign it to max_hf_clients
before context switch happens.

Change-Id: Ibde1bebbab2eb64442027164236f1d82e4269d23
tif_hf.c
9c264e92305f84a5e8a92bc859812def0ce71792 14-Jul-2014 Anubhav Gupta <anubhavg@codeaurora.org> Set the proper authentication level for AvOpen

During Avopen security was made none hence A2DP
connection was happening without bonding when
DUT is paired with DUT and then pairing entry
is deleted from remote and then only A2dp is
tried to be reconnected from DUT. A2dp appears
to be connected in this usecase but the device
entry is shown in available devices list instead
of paired one.
Changes made from No security to SEC Authenticate

Change-Id: I7fc39fe8acef874f0031c9b78d4269a62b94e4b0
tif_av.c
6b359689a482fae92f26aae6252fddfc296aaabf 19-Sep-2014 Mallikarjuna GB <gbmalli@codeaurora.org> Don't open SCO for 2nd MO call if a call is active

When user dials a 2nd call, do not open SCO if 1st call was
active on DUT earpiece or speaker.

Change-Id: I974f5bcf917e6972705e60cf1da195eae23f885a
tif_hf.c
684d136447a93311a7ebd2e6daf931b77e802120 08-Oct-2014 Mallikarjuna GB <gbmalli@codeaurora.org> SCO connection should happen after SLC.

This change makes sure that SCO audio
connection request is not processed until
HFP SLC connection is done.

Change-Id: Ia2fcad49882deaaf049ae190d90442e5ca7ad71b
tif_hf.c
39b9f827e1f9f0599070928465f84b69c4d5dfc0 21-May-2015 Mallikarjuna GB <gbmalli@codeaurora.org> Don't open SCO on state change for multi party call on DUT.

When multi party calls(1 active, 1 held) are ongoing on phone
speaker and any of these call drops, do not open SCO for
other call since user expects call to still remain on phone
speaker.

Change-Id: I9079c809ac665fc1c6e890302e37d23a12f8d4f4
tif_hf.c
616e7417c9520db24adf20b7c0aaf967ce6e106d 22-May-2015 Mallikarjuna GB <gbmalli@codeaurora.org> Handle multi party call states

UseCase:
1. Set up Bluetooth connection between phone and remote device.
2. Disconnect BT link by turning off remote device.
3. Start Mo call from phone.
4. Receive MT call from far end.
5. Turn on remote device.
6. BT connection gets established successfully, but audio
doesn't get transferred to headset.

Failure:
Call audio not routed to BT HS. SCO not established.

Root cause:
When a HS connects while in an active call and 2nd call
(incoming/outgoing/alerting) setup ongoing, incorrect post SLC
call setup updates might cause HS to get confused as phone had
already updated correct call states in CIND response during SLC.
This may cause HS to behave abnormally like delayed response to
BCS as seen with jabra wave +.

Fix:
Avoid sending incorrect call updates post SLC since we already
have sent correct updates during SLC as reponse to CIND.

Change-Id: I53e57baf7cca782af6f374a043667971c66a956d
tif_hf.c
06c0eca504910115020b86676fae60bb171b7a47 21-May-2015 Mallikarjuna GB <gbmalli@codeaurora.org> Update held call state to connected headset

In a three way call scenario, when an active
call is dropped by remote, the single held call
state is not updated to the connected headset.
This change will make sure that it is updated
properly.

Change-Id: I558602e791279d510edb23989b125cd8f7a7ebde
tif_hf.c
eae61663a5c44f2a5757ae3df80cbc3b97fa6d60 02-Jun-2015 Pavlin Radoslavov <pavlin@google.com> Replace malloc/calloc/free with osi_malloc/osi_calloc/osi_free

There were several leftover places that were still using
malloc/calloc/free .
Those are replaced to use osi_malloc/osi_calloc/osi_free like
majority of the rest of the code.

Note: There are few remaining places that are still using
malloc/calloc/free:
* Some of the unit tests
* audio_a2dp_hw/audio_a2dp_hw.c
It is used as part of the audio.a2dp.default.so library,
and the bluetooth.default.so library
Its usage of malloc/calloc/free should be refactored
independently.

Change-Id: Iafbed996e5f1ae8eb1343fb2acfadf32e515e419
tif_config.c
tif_sdp_server.c
tif_sock_l2cap.c
tif_sock_sco.c
tif_storage.c
38798e1b7cc7873aa849c3c7c58902f713d909be 19-Nov-2014 Hemant Gupta <hemantg@codeaurora.org> HID: Handle closing of uhid driver in case failure

This patch handles closure of the uhid driver in case of following:
- Due to concurrency of disconnection from a conencted device
and an incoming connection request from another device, the error
code for the ACL disconnection becomes HCI_ERR_HOST_REJECT_SECURITY
in the stack.
- On reception of disconnection with that error codes, the uhid driver
was not closed from the btif layer leading to issues in reconnection
with same device that got disconnected.

Change-Id: I13c83757051850cc631aa1c24a036a2e1a4d0087
tif_hh.c
0933b4075e16589a073e85d8230677238b29b780 02-Jun-2015 Pavlin Radoslavov <pavlin@google.com> Moved the OSI alarm_shutdown() operations to alarm_cleanup()

Also, removed the OSI module's start_up and shut_down steps,
because now they are no-op.

Bug: 21558791
Change-Id: I24259b327f399af57c37937111158baa9704f644
tack_manager.c
5febd64b95260672d41964337377fb312ea2c07b 01-Jun-2015 Pavlin Radoslavov <pavlin@google.com> Disable the OSI allocation tracker.

Temporary disable the allocation tracker initialization
(even for BLUEDROID_DEBUG) when initializing Bluetooth.
This is a short-term workaround solution for several issues related to
the usage of the allocation tracker.

* Inconsistent usage of osi_malloc()/osi_calloc() and osi_free()
- Within some of the Bluetooth-related unit tests we have two copies
of the same libosi library: one copy statically linked against the
unit test, and another dlopen() at runtime as part of bluetooth.default.so
Each of those copy has its own static variables.
- For the dlopen() copy we do call allocation_tracker_init(), while for the
static copy within the unit test we don't call allocation_tracker_init()
- Occasionally, there is a memory allocation via osi_calloc()
within the dlopen()-ed library, and then it is osi_free()-ed
within the statically linked library.
Such (mis)usage creates issues in two ways: (1) free()-ing incorrect
pointer, and (2) the osi hash_map() in the dlopen()-ed library still considers
the osi-tracked memory as allocated.
NOTE: (1) could trigger random crashes, while (2) is the reason the unit
test triggers an assert

* Avoid potential issues that could result from the fact that calling
allocation_tracker_init() is not mandatory; i.e., the same
issue described above could be triggered if osi_malloc()/osi_callod()
was called before the call to allocation_tracker_init()

* There is still code that uses malloc(3)/calloc(3) and free(3) instead
of osi_malloc()/osi_calloc() and osi_free()

Also, add missing pthread_mutex_lock()/pthread_mutex_unlock() guards,
and fix the allocation_tracker_uninit() implementation so it works
properly even if void allocation_tracker_init() wasn't called.

Bug: 21561735
Change-Id: Ic83d6cd40af1189c4ee9c1dbfd0ad8e4666e1502
luetooth.c
73022dcde0411cb5a5684aaa78554c698916d4af 28-May-2015 Andre Eisenbach <eisenbach@google.com> Reduce GATT log verbosity

Change-Id: I55e6ec1afdd8a13f4401809ef89ef2d80efb7f66
tif_gatt_client.c
tif_gatt_server.c
7dac79e3614a7956637b7dd294cf9f38afcf09f4 23-May-2015 Pavlin Radoslavov <pavlin@google.com> Add missing clean_up step for the OSI module.

Now the OSI module's shut_down processing is split into "shut_down"
and "clean_up".

Previously, there was an ordering issue manipulating some of the
internal state during graceful shutdown/cleanup. Some of the modules
had two steps: shut_down, followed by clean_up, while other had only
shut_down step. This triggered the following assert in file alarm.c

alarm_cancel: assertion "alarms != NULL" failed

Bug: 21406940
Change-Id: Iab1f033a69cbff646a6b0f346760ae82f8b00b8f
tack_manager.c
a2c8cab51ae8c570c32e3c97347d41c3cc60ffc5 10-Jun-2015 Andre Eisenbach <eisenbach@google.com> am af753a25: Do not ask for confirmation for temporary pairing

* commit 'af753a253bb3e40f11be33d2c70368adc205cca6':
Do not ask for confirmation for temporary pairing
af753a253bb3e40f11be33d2c70368adc205cca6 09-Jun-2015 Andre Eisenbach <eisenbach@google.com> Do not ask for confirmation for temporary pairing

Bug: 20187234
Change-Id: I4213a3c2cafecdb39fcf3f19464c91776180267a
tif_dm.c
38a610d27984a682bb75f8309ee84292fa7a650d 10-Jun-2015 Dan Albert <danalbert@google.com> am 8f310904: Add missing include.

* commit '8f31090414c4660a010216383e17cb932f34ec6f':
Add missing include.
8f31090414c4660a010216383e17cb932f34ec6f 10-Jun-2015 Dan Albert <danalbert@google.com> Add missing include.

osi_malloc was never included, so it was implicitly defined as
returning an integer (thank you, C). Clang caught the int to pointer
conversion error.

Change-Id: I0d8a3363d92cb72a22780d049a53e193d2e50ec5
tif_sdp_server.c
db66271013bc4b845008ed2a1daf53ca0b82eb97 10-Jun-2015 Casper Bonde <c.bonde@samsung.com> am 818d0f2a: SAP: Make it possible to enforce a 16-digit pin code (1/5)

* commit '818d0f2afb10c75125b0df9ea2bce6108268a269':
SAP: Make it possible to enforce a 16-digit pin code (1/5)
818d0f2afb10c75125b0df9ea2bce6108268a269 21-May-2015 Casper Bonde <c.bonde@samsung.com> SAP: Make it possible to enforce a 16-digit pin code (1/5)

This change enable the posibility to enforce using a
16-digit pin or MITM for a RFCOMM or L2CAP connection.

This is needed for the SIM access profile.

Change-Id: I02886ce284f27295205def3c66fb76372f5dab4f
Signed-off-by: Casper Bonde <c.bonde@samsung.com>
tif_dm.c
tif_sock_l2cap.c
tif_sock_rfc.c
tif_storage.c
70b9598970e5b18ba53c282319e68faea6eb5681 24-Apr-2015 Satya Calloji <satyac@broadcom.com> Static address is seen on scanner after unpairing

Fix for bonded devices that cannot be removed from resolving list when
scanning, advertising or when a connection is being initiated.
Suspend all active adv, scanning or connection initiation upon
completion of any resolving list operation.

Original author: Chaojing Sun <cjsun@broadcom.com>
Change-Id: Id104dace2944b1878eaf65b93aba3d01e477191d
tif_dm.c
935324abbe8706307297f09cf79bbcd4efb73367 31-Mar-2015 Satya Calloji <satyac@broadcom.com> LE low power scan feature

LE low power extended scan feature stack changes
based on Google BLE spec v0.95

Bug: 20029342
Change-Id: I1db2d9bb648295340d0e93ca89d27e1b938d33d3
tif_core.c
tif_dm.c
tif_gatt_client.c
033edab9780481ca743d1f14cc893dc533c3c3f2 07-May-2015 Satya Calloji <satyac@broadcom.com> Fix GATT connection failure after BT reset

Handles the address type incorrect value storage issue
and removes usage of DMT supported flag which was based
on legacy code

Bug: 20912064
Change-Id: I5bd20dc9cd0997ac3dbd4b346cc0513f1809f241
tif_dm.c
tif_gatt_client.c
tif_gatt_server.c
tif_storage.c
350b0b0d148ca9bf7cbf20018b47286165fa86e8 19-May-2015 Satya Calloji <satyac@broadcom.com> Fix for IRK and IR key write issue

Fixes the incorrect flipping of values
for IRK and IR keys in bt_config.conf file

Change-Id: Ia4f9c274b6a3f7594ec31d8bd89b27d1ae54ac78
tif_dm.c
73378f5fad7b2fc348073c313b226d0e1d5cfc12 19-May-2015 Chih-Hung Hsieh <chh@google.com> Fix format-security warning found by clang/llvm.

BUG: 21299815
Change-Id: I3dd7e92444a9b439c210f7e6ce677307a38113ab
tif_debug_btsnoop.c
8f1a16b13f8d11da9e783a64e1d38e8b20c10d6c 19-May-2015 Andre Eisenbach <eisenbach@google.com> Fix string template in connection event debug log

Also fixed timestamp/bdname buffer confusion.

Change-Id: Idab9746a87ec665cba836c79978f03e13c36d17b
tif_debug_conn.c
cae219fe70124f1fc39cd7a78c239c4870422d5d 18-May-2015 Andre Eisenbach <eisenbach@google.com> Shutdown alarm callbacks on stack disable; added OSI module

Change-Id: Iecf1e2258da012bdac69a4f57d38b12a272e3edd
tack_manager.c
f4f744f7a9812e2dfd306382eab80c2caf25db37 06-May-2015 Mudumba Ananth <ananthm@broadcom.com> Fix BT PAN crash by re-ordering callback initialization

Bug: 20868163
Change-Id: I8e3bb844b96b762f90a85d8d9d678a1a9cec9c32
tif_pan.c
1bd76059e72b7a0d54f6b325882f6eccd311f874 05-Dec-2014 Andre Eisenbach <eisenbach@google.com> Bluetooth native dumpsys logging support (2/5)

Includes support for BTSnoop logging in memory.

Bug: 18508263
Change-Id: I175da528cbcdc00d40622647d518a74210cfe6fd
luetooth.c
tif_debug.c
tif_debug_btsnoop.c
tif_debug_conn.c
4e3e372af6bba32d27a154679e39cada3034df41 11-May-2015 Andre Eisenbach <eisenbach@google.com> Only register key types with uinput that we can actually map

Bug: 20641307
Change-Id: I40cb1e22c35963429481a2cc9da897b5b2f554fe
tif_rc.c
0bf5438a93c1f93c13352ef3021a84b6d5703716 05-Jun-2015 Mallikarjuna GB <gbmalli@codeaurora.org> am 74f0bd0e: Initialize btif_max_hf_clients with proper value

* commit '74f0bd0e8c5cce69690eb7a7c6c7429013082647':
Initialize btif_max_hf_clients with proper value
e4ca062746a280e3a95952cf1756cd197f33e179 05-Jun-2015 Mallikarjuna GB <gbmalli@codeaurora.org> am 46d706a9: Fix issues in A2dp, Avrcp, HF and AG reported by static analysis tool

* commit '46d706a9849dcd027d562200a0a43e6e9156aceb':
Fix issues in A2dp, Avrcp, HF and AG reported by static analysis tool
74f0bd0e8c5cce69690eb7a7c6c7429013082647 21-May-2015 Mallikarjuna GB <gbmalli@codeaurora.org> Initialize btif_max_hf_clients with proper value

btif_max_hf_clients which is an unsigned 16bit integer is
initialized with -1(0xFFFF) in btif_hf.c. Later on, when
application calls init with max_hf_clients as 1, btif_max_hf_clients
will be set to 1. But, before this happens, context switch happened
from application context to btif context with btif_max_hf_clients as -1.
In the btif context, BTA_AgRegister gets called in for loop for 0xFFFF
times. We are running out of scbs due to this.
Initialize btif_max_hf_clients with 1. Assign it to max_hf_clients
before context switch happens.

Change-Id: Ibde1bebbab2eb64442027164236f1d82e4269d23
tif_hf.c
86fd008e1ca09ebaad8b4b72255b27de2b6fbe6d 05-Jun-2015 Anubhav Gupta <anubhavg@codeaurora.org> am 1f9dfcbb: Ignore STOP command if A2DP stream is suspended

* commit '1f9dfcbb526c8d0cba080e02df7c4613b7433f18':
Ignore STOP command if A2DP stream is suspended
c5ef1d4b3619e3d4ff3b6b41fe4abcbef2d16010 05-Jun-2015 Anubhav Gupta <anubhavg@codeaurora.org> am a4f66355: Remove check for stream type in a2dp hal_callbacks.

* commit 'a4f66355a304e869d22195fb7177756bb2243cff':
Remove check for stream type in a2dp hal_callbacks.
46d706a9849dcd027d562200a0a43e6e9156aceb 07-Nov-2014 Mallikarjuna GB <gbmalli@codeaurora.org> Fix issues in A2dp, Avrcp, HF and AG reported by static analysis tool

- Fixes to validate Array Index Value and Null Pointer
Dereference reported by static analysis tool.

Change-Id: Id1492315f68378fdcfa517bd0a5cacefc8ebfddb
tif_hf.c
1f9dfcbb526c8d0cba080e02df7c4613b7433f18 17-Nov-2014 Anubhav Gupta <anubhavg@codeaurora.org> Ignore STOP command if A2DP stream is suspended

Ignore STOP command if A2DP stream is already suspended.
Some carkits send STOP command before VOIP call initiation
but don't send PLAY when call ends which hinders DUT to resume
audio playback after call termination.

Change-Id: I41cc1fc6f4b6cfaa1560d729baa0ca27f6dfe8c8
tif_rc.c
a4f66355a304e869d22195fb7177756bb2243cff 07-Oct-2014 Anubhav Gupta <anubhavg@codeaurora.org> Remove check for stream type in a2dp hal_callbacks.

Stream type is invalid till signalling channel
connection establishment is completed. Do not
check stream type while calling HAL callback.

Change-Id: I69fb19636f3e9bb72202c450dcef9e7bc2e53731
tif_av.c
9aa7804e3e363950af1b58d4bde41b4a0a5144d7 05-Jun-2015 Anubhav Gupta <anubhavg@codeaurora.org> am 137bed02: Reject second AVRCP connection.

* commit '137bed026881654febddfa2d797e06ce9f8e58fa':
Reject second AVRCP connection.
404945ba3ac161f624f5420246f6c845b5c821c5 05-Jun-2015 Anubhav Gupta <anubhavg@codeaurora.org> am d59ee6c2: Set the proper authentication level for AvOpen

* commit 'd59ee6c25920cf9db218f2d5ac46624c69c3ba09':
Set the proper authentication level for AvOpen
137bed026881654febddfa2d797e06ce9f8e58fa 13-Mar-2014 Anubhav Gupta <anubhavg@codeaurora.org> Reject second AVRCP connection.

This change rejects the RC connection from
second device if the DUT is already connected
to RC of first device.
This addresses the problem of improper closure
of Uinput device on disconnection of Avrcp
to make sure Avrcp passthrough commands work
as desired.

Change-Id: If2e39cd90575baffd0e4442b8e7cd2a91eebdf56
tif_rc.c
d59ee6c25920cf9db218f2d5ac46624c69c3ba09 14-Jul-2014 Anubhav Gupta <anubhavg@codeaurora.org> Set the proper authentication level for AvOpen

During Avopen security was made none hence A2DP
connection was happening without bonding when
DUT is paired with DUT and then pairing entry
is deleted from remote and then only A2dp is
tried to be reconnected from DUT. A2dp appears
to be connected in this usecase but the device
entry is shown in available devices list instead
of paired one.
Changes made from No security to SEC Authenticate

Change-Id: I7fc39fe8acef874f0031c9b78d4269a62b94e4b0
tif_av.c
bd2e552d70a6fc7afaafd77366b859b3432f7c60 04-Jun-2015 Mallikarjuna GB <gbmalli@codeaurora.org> am 8a67ac70: Don\'t open SCO for 2nd MO call if a call is active

* commit '8a67ac702cd4d4a4cbebd1e765800141b84e6fc0':
Don't open SCO for 2nd MO call if a call is active
8a67ac702cd4d4a4cbebd1e765800141b84e6fc0 19-Sep-2014 Mallikarjuna GB <gbmalli@codeaurora.org> Don't open SCO for 2nd MO call if a call is active

When user dials a 2nd call, do not open SCO if 1st call was
active on DUT earpiece or speaker.

Change-Id: I974f5bcf917e6972705e60cf1da195eae23f885a
tif_hf.c
35eb26229589fda2353ca7e0cfa5396a79d799ce 04-Jun-2015 Mallikarjuna GB <gbmalli@codeaurora.org> am c8c082b7: SCO connection should happen after SLC.

* commit 'c8c082b730910b64dbc38a7ee89bb141be46daa6':
SCO connection should happen after SLC.
91ab5e5ebfc2baa9d7193755f8c8cdb89e9a2937 04-Jun-2015 Mallikarjuna GB <gbmalli@codeaurora.org> am 902ba021: Don\'t open SCO on state change for multi party call on DUT.

* commit '902ba02141c5cea3320ec1746c0fe0fad80122bc':
Don't open SCO on state change for multi party call on DUT.
82981fb891c719730bd7d48a4d793918cb05d2e9 04-Jun-2015 Mallikarjuna GB <gbmalli@codeaurora.org> am d345bb20: Handle multi party call states

* commit 'd345bb208fe35923b60bca6af76b0a6e023fc56f':
Handle multi party call states
d80a3f2056477cf106e52994123305d6f9a67dd4 04-Jun-2015 Mallikarjuna GB <gbmalli@codeaurora.org> am c2c8a1fc: Update held call state to connected headset

* commit 'c2c8a1fce4a577fc1a14a96fe96cab3043db4140':
Update held call state to connected headset
c8c082b730910b64dbc38a7ee89bb141be46daa6 08-Oct-2014 Mallikarjuna GB <gbmalli@codeaurora.org> SCO connection should happen after SLC.

This change makes sure that SCO audio
connection request is not processed until
HFP SLC connection is done.

Change-Id: Ia2fcad49882deaaf049ae190d90442e5ca7ad71b
tif_hf.c
902ba02141c5cea3320ec1746c0fe0fad80122bc 21-May-2015 Mallikarjuna GB <gbmalli@codeaurora.org> Don't open SCO on state change for multi party call on DUT.

When multi party calls(1 active, 1 held) are ongoing on phone
speaker and any of these call drops, do not open SCO for
other call since user expects call to still remain on phone
speaker.

Change-Id: I9079c809ac665fc1c6e890302e37d23a12f8d4f4
tif_hf.c
d345bb208fe35923b60bca6af76b0a6e023fc56f 22-May-2015 Mallikarjuna GB <gbmalli@codeaurora.org> Handle multi party call states

UseCase:
1. Set up Bluetooth connection between phone and remote device.
2. Disconnect BT link by turning off remote device.
3. Start Mo call from phone.
4. Receive MT call from far end.
5. Turn on remote device.
6. BT connection gets established successfully, but audio
doesn't get transferred to headset.

Failure:
Call audio not routed to BT HS. SCO not established.

Root cause:
When a HS connects while in an active call and 2nd call
(incoming/outgoing/alerting) setup ongoing, incorrect post SLC
call setup updates might cause HS to get confused as phone had
already updated correct call states in CIND response during SLC.
This may cause HS to behave abnormally like delayed response to
BCS as seen with jabra wave +.

Fix:
Avoid sending incorrect call updates post SLC since we already
have sent correct updates during SLC as reponse to CIND.

Change-Id: I53e57baf7cca782af6f374a043667971c66a956d
tif_hf.c
c2c8a1fce4a577fc1a14a96fe96cab3043db4140 21-May-2015 Mallikarjuna GB <gbmalli@codeaurora.org> Update held call state to connected headset

In a three way call scenario, when an active
call is dropped by remote, the single held call
state is not updated to the connected headset.
This change will make sure that it is updated
properly.

Change-Id: I558602e791279d510edb23989b125cd8f7a7ebde
tif_hf.c
1839e76a6313e9979ef027521916797fdf95348b 03-Jun-2015 Casper Bonde <c.bonde@samsung.com> am a954124f: Add support for MITM for BluetoothSockets (4/4)

* commit 'a954124fc5429f259e47258af64e159c621cc6e0':
Add support for MITM for BluetoothSockets (4/4)
a954124fc5429f259e47258af64e159c621cc6e0 21-May-2015 Casper Bonde <c.bonde@samsung.com> Add support for MITM for BluetoothSockets (4/4)

This change adds an option to enforce Man-in-the-middle protection
for the authentication process. This feature is needed for the Sim
Access Profile.

Change-Id: I2eda507ffdcb4a194434adedf207e1e9951b80c3
Signed-off-by: Casper Bonde <c.bonde@samsung.com>
tif_sock_rfc.c
2abcbc3ab3788c77fbe82463698295f3206d56aa 03-Jun-2015 Pavlin Radoslavov <pavlin@google.com> am 56a3be0d: Replace malloc/calloc/free with osi_malloc/osi_calloc/osi_free

* commit '56a3be0d6eaa1bc264736e399fb32d3094f0b513':
Replace malloc/calloc/free with osi_malloc/osi_calloc/osi_free
61ea384f18fbf2699c41e534e4c04db5ac4a75f1 03-Jun-2015 Casper Bonde <c.bonde@samsung.com> am 1b0f1077: SAP: Change to use new SDP Api (1/4)

* commit '1b0f107768ba1a0f93abf68851bacbe650f27eff':
SAP: Change to use new SDP Api (1/4)
56a3be0d6eaa1bc264736e399fb32d3094f0b513 02-Jun-2015 Pavlin Radoslavov <pavlin@google.com> Replace malloc/calloc/free with osi_malloc/osi_calloc/osi_free

There were several leftover places that were still using
malloc/calloc/free .
Those are replaced to use osi_malloc/osi_calloc/osi_free like
majority of the rest of the code.

Note: There are few remaining places that are still using
malloc/calloc/free:
* Some of the unit tests
* audio_a2dp_hw/audio_a2dp_hw.c
It is used as part of the audio.a2dp.default.so library,
and the bluetooth.default.so library
Its usage of malloc/calloc/free should be refactored
independently.

Change-Id: Iafbed996e5f1ae8eb1343fb2acfadf32e515e419
tif_config.c
tif_sdp_server.c
tif_sock_l2cap.c
tif_sock_sco.c
tif_storage.c
1b0f107768ba1a0f93abf68851bacbe650f27eff 16-Apr-2015 Casper Bonde <c.bonde@samsung.com> SAP: Change to use new SDP Api (1/4)

Added support for Sim Access Profile (SAP) in the SDPManager.
To make it easier to test, both SDP record creation and seach
is added.

Change-Id: Idae480fb64224e0e5dec7fb07ff4efb9312a5461
Signed-off-by: Casper Bonde <c.bonde@samsung.com>
tif_sdp_server.c
tif_sock_sdp.c
b0d12262ccf88d86b558f664c747e8c899f52c49 02-Jun-2015 Hemant Gupta <hemantg@codeaurora.org> am 87072892: HID: Handle closing of uhid driver in case failure

* commit '87072892dc006f4c037aae0a346eda6c18e6b8ba':
HID: Handle closing of uhid driver in case failure
551965451fa43a1e503a6a51c84b162aea13e245 02-Jun-2015 Hemant Gupta <hemantg@codeaurora.org> am 6ba8fda6: Add proper checks for PAN & BNEP in BD stack

* commit '6ba8fda60a9137a9f53f7e14edd87184610744fc':
Add proper checks for PAN & BNEP in BD stack
190b24470159b053c5c4cb405b8ae17bad30f791 02-Jun-2015 Pavlin Radoslavov <pavlin@google.com> am a9130e07: Moved the OSI alarm_shutdown() operations to alarm_cleanup()

* commit 'a9130e07646835a8550611bed32138ed79385a38':
Moved the OSI alarm_shutdown() operations to alarm_cleanup()
9a5a37174f84708130be8531bd0cd251305365b5 02-Jun-2015 Pavlin Radoslavov <pavlin@google.com> am b65ec7bd: Disable the OSI allocation tracker.

* commit 'b65ec7bdb30115ce0d39cf7ee1e355b61fc2a360':
Disable the OSI allocation tracker.
87072892dc006f4c037aae0a346eda6c18e6b8ba 19-Nov-2014 Hemant Gupta <hemantg@codeaurora.org> HID: Handle closing of uhid driver in case failure

This patch handles closure of the uhid driver in case of following:
- Due to concurrency of disconnection from a conencted device
and an incoming connection request from another device, the error
code for the ACL disconnection becomes HCI_ERR_HOST_REJECT_SECURITY
in the stack.
- On reception of disconnection with that error codes, the uhid driver
was not closed from the btif layer leading to issues in reconnection
with same device that got disconnected.

Change-Id: I13c83757051850cc631aa1c24a036a2e1a4d0087
tif_hh.c
6ba8fda60a9137a9f53f7e14edd87184610744fc 15-Oct-2014 Hemant Gupta <hemantg@codeaurora.org> Add proper checks for PAN & BNEP in BD stack

This patch fixes issues for PAN & BNEP in BD stack identified
by static analysis tool.

Change-Id: I29417dae982abb5cef11379f8d03baad11ffde8b
tif_pan.c
99d68906fa80be84821d0fba6472f04f7f9bff10 02-Jun-2015 Arman Uguray <armansito@google.com> am d30195cb: gn-build: Get btif to compile as its own module

* commit 'd30195cbf09735da593e186c4c99cce6232b072e':
gn-build: Get btif to compile as its own module
d30195cbf09735da593e186c4c99cce6232b072e 30-May-2015 Arman Uguray <armansito@google.com> gn-build: Get btif to compile as its own module

This CL adds support to build //btif:btif as its own target as a static library
by introducing a new module-level BUILD.gn file, adding missing includes, and
conditionally compiling code that is Android-specific (depends on libcutils).
This removes/breaks some functionality on non-Android builds since the
corresponding features are missing until we have a more unified replacement.

BUG=21339022

Change-Id: Ibb0372da45f256c55fa894fdda3d70319ea008c9
tif_config.c
tif_core.c
tif_dm.c
tif_hf.c
tif_hf_client.c
tif_hh.c
tif_pan.c
tif_rc.c
tif_sock_rfc.c
tif_sock_sco.c
tif_sock_util.c
a9130e07646835a8550611bed32138ed79385a38 02-Jun-2015 Pavlin Radoslavov <pavlin@google.com> Moved the OSI alarm_shutdown() operations to alarm_cleanup()

Also, removed the OSI module's start_up and shut_down steps,
because now they are no-op.

Bug: 21558791
Change-Id: I24259b327f399af57c37937111158baa9704f644
tack_manager.c
b65ec7bdb30115ce0d39cf7ee1e355b61fc2a360 01-Jun-2015 Pavlin Radoslavov <pavlin@google.com> Disable the OSI allocation tracker.

Temporary disable the allocation tracker initialization
(even for BLUEDROID_DEBUG) when initializing Bluetooth.
This is a short-term workaround solution for several issues related to
the usage of the allocation tracker.

* Inconsistent usage of osi_malloc()/osi_calloc() and osi_free()
- Within some of the Bluetooth-related unit tests we have two copies
of the same libosi library: one copy statically linked against the
unit test, and another dlopen() at runtime as part of bluetooth.default.so
Each of those copy has its own static variables.
- For the dlopen() copy we do call allocation_tracker_init(), while for the
static copy within the unit test we don't call allocation_tracker_init()
- Occasionally, there is a memory allocation via osi_calloc()
within the dlopen()-ed library, and then it is osi_free()-ed
within the statically linked library.
Such (mis)usage creates issues in two ways: (1) free()-ing incorrect
pointer, and (2) the osi hash_map() in the dlopen()-ed library still considers
the osi-tracked memory as allocated.
NOTE: (1) could trigger random crashes, while (2) is the reason the unit
test triggers an assert

* Avoid potential issues that could result from the fact that calling
allocation_tracker_init() is not mandatory; i.e., the same
issue described above could be triggered if osi_malloc()/osi_callod()
was called before the call to allocation_tracker_init()

* There is still code that uses malloc(3)/calloc(3) and free(3) instead
of osi_malloc()/osi_calloc() and osi_free()

Also, add missing pthread_mutex_lock()/pthread_mutex_unlock() guards,
and fix the allocation_tracker_uninit() implementation so it works
properly even if void allocation_tracker_init() wasn't called.

Bug: 21561735
Change-Id: Ic83d6cd40af1189c4ee9c1dbfd0ad8e4666e1502
luetooth.c
8799fc559b40df8dad4271d92271d76b85fcdf4e 28-May-2015 Andre Eisenbach <eisenbach@google.com> am 8a7e179c: Reduce GATT log verbosity

* commit '8a7e179c9ebe76c0c16a71c33bf322b77e0aa439':
Reduce GATT log verbosity
8a7e179c9ebe76c0c16a71c33bf322b77e0aa439 28-May-2015 Andre Eisenbach <eisenbach@google.com> Reduce GATT log verbosity

Change-Id: I55e6ec1afdd8a13f4401809ef89ef2d80efb7f66
tif_gatt_client.c
tif_gatt_server.c
0856be81a95ac7c067f7543fcd59dd500bf09a9b 28-May-2015 Pavlin Radoslavov <pavlin@google.com> am 0d6a501d: Add missing clean_up step for the OSI module.

* commit '0d6a501d0517c186f11cbee294ae2c509073de91':
Add missing clean_up step for the OSI module.
961e049f33f6af622b6c12f3b44a5fe578a910e6 28-May-2015 Ian Coolidge <icoolidge@google.com> am 0d45f25e: DO NOT MERGE Fix use-after-free while setting advertisement data.

* commit '0d45f25e4102b14d942efa530f0e6a1a6c19787a':
DO NOT MERGE Fix use-after-free while setting advertisement data.
b959a4070b56c9b08132eb8756759046c24c1384 28-May-2015 Ian Coolidge <icoolidge@google.com> resolved conflicts for merge of 1f81b64b to mnc-dev-plus-aosp

Change-Id: I7997086b1d83bc5ee06068f82ca31c290389bc44
660fd9ef8dad381066d797b39778ff2667631f1e 28-May-2015 Ian Coolidge <icoolidge@google.com> Merge "Fix use-after-free while setting advertisement data."
0d6a501d0517c186f11cbee294ae2c509073de91 23-May-2015 Pavlin Radoslavov <pavlin@google.com> Add missing clean_up step for the OSI module.

Now the OSI module's shut_down processing is split into "shut_down"
and "clean_up".

Previously, there was an ordering issue manipulating some of the
internal state during graceful shutdown/cleanup. Some of the modules
had two steps: shut_down, followed by clean_up, while other had only
shut_down step. This triggered the following assert in file alarm.c

alarm_cancel: assertion "alarms != NULL" failed

Bug: 21406940
Change-Id: Iab1f033a69cbff646a6b0f346760ae82f8b00b8f
tack_manager.c
0d45f25e4102b14d942efa530f0e6a1a6c19787a 21-May-2015 Ian Coolidge <icoolidge@google.com> DO NOT MERGE Fix use-after-free while setting advertisement data.

Producer context was freeing data buffers without
performing a deep copy on the passed structure.

Also added some const correctness so we can reason
about the state of btif_adv_data_t as its data
gets associated with the advertising instance.

Bug: 21343750
Change-Id: Ifea0209e8426b61d8456c299c836ba640bd30f31
tif_gatt_client.c
tif_gatt_multi_adv_util.c
1f81b64b337832452e9ba1f530e612a685aebb82 22-Apr-2015 Ian Coolidge <icoolidge@google.com> Set default symbol visibility to 'hidden'.

Bug: 20427982
Change-Id: I003469d6dfce681a38baa71b5709236a1a4a2189
luetooth.c
tif_config.c
484dc303627eb82e7c5edf4f03e542fec2d3f4ea 21-May-2015 Ian Coolidge <icoolidge@google.com> Fix use-after-free while setting advertisement data.

Producer context was freeing data buffers without
performing a deep copy on the passed structure.

Also added some const correctness so we can reason
about the state of btif_adv_data_t as its data
gets associated with the advertising instance.

Bug: 21343750

Change-Id: Ifea0209e8426b61d8456c299c836ba640bd30f31
tif_gatt_client.c
tif_gatt_multi_adv_util.c
08fc100f684f8a140d346742795a35c90ed87289 24-Apr-2015 Satya Calloji <satyac@broadcom.com> Static address is seen on scanner after unpairing

Fix for bonded devices that cannot be removed from resolving list when
scanning, advertising or when a connection is being initiated.
Suspend all active adv, scanning or connection initiation upon
completion of any resolving list operation.

Original author: Chaojing Sun <cjsun@broadcom.com>
Change-Id: Id104dace2944b1878eaf65b93aba3d01e477191d
tif_dm.c
877123f5b9df90e7a71ea7b15997c521229decc1 24-Apr-2015 Satya Calloji <satyac@broadcom.com> Static address is seen on scanner after unpairing

Fix for bonded devices that cannot be removed from resolving list when
scanning, advertising or when a connection is being initiated.
Suspend all active adv, scanning or connection initiation upon
completion of any resolving list operation.

Original author: Chaojing Sun <cjsun@broadcom.com>
Change-Id: Id104dace2944b1878eaf65b93aba3d01e477191d
tif_dm.c
2020a2a43b656d43020a2a1ff8ee606908fd7091 20-May-2015 Satya Calloji <satyac@broadcom.com> am 7cb76b42: Fix GATT connection failure after BT reset

* commit '7cb76b4277d603e5abfe7f9222a45ebdf7a715e2':
Fix GATT connection failure after BT reset
7cb76b4277d603e5abfe7f9222a45ebdf7a715e2 07-May-2015 Satya Calloji <satyac@broadcom.com> Fix GATT connection failure after BT reset

Handles the address type incorrect value storage issue
and removes usage of DMT supported flag which was based
on legacy code

Bug: 20912064
Change-Id: I5bd20dc9cd0997ac3dbd4b346cc0513f1809f241
tif_dm.c
tif_gatt_client.c
tif_gatt_server.c
tif_storage.c
9b65d40b027c37e849e3a8f758706b0d2b761831 20-May-2015 Satya Calloji <satyac@broadcom.com> am 7bd4038e: Fix for IRK and IR key write issue

* commit '7bd4038ea9a2f1953dc98fa67aec413b6247c584':
Fix for IRK and IR key write issue
6a7697f8310a48e16fbbc5f1724face7eea39101 20-May-2015 Chih-Hung Hsieh <chh@google.com> am 1536a0e3: Fix format-security warning found by clang/llvm.

* commit '1536a0e3d6a8b149644dfe3f7238ae5c6f6e853a':
Fix format-security warning found by clang/llvm.
7bd4038ea9a2f1953dc98fa67aec413b6247c584 19-May-2015 Satya Calloji <satyac@broadcom.com> Fix for IRK and IR key write issue

Fixes the incorrect flipping of values
for IRK and IR keys in bt_config.conf file

Change-Id: Ia4f9c274b6a3f7594ec31d8bd89b27d1ae54ac78
tif_dm.c
1536a0e3d6a8b149644dfe3f7238ae5c6f6e853a 19-May-2015 Chih-Hung Hsieh <chh@google.com> Fix format-security warning found by clang/llvm.

BUG: 21299815
Change-Id: I3dd7e92444a9b439c210f7e6ce677307a38113ab
tif_debug_btsnoop.c
3589ebe5baddbf0cae3f14c230408da1febb1bcf 19-May-2015 Andre Eisenbach <eisenbach@google.com> am 873ca2f9: Fix string template in connection event debug log

* commit '873ca2f973321f67df845e8658ede02bf5d9ee0b':
Fix string template in connection event debug log
873ca2f973321f67df845e8658ede02bf5d9ee0b 19-May-2015 Andre Eisenbach <eisenbach@google.com> Fix string template in connection event debug log

Also fixed timestamp/bdname buffer confusion.

Change-Id: Idab9746a87ec665cba836c79978f03e13c36d17b
tif_debug_conn.c
958523868bc90b0a8f35a854ed48262c377aa825 19-May-2015 Andre Eisenbach <eisenbach@google.com> am 3e3d2a1d: Shutdown alarm callbacks on stack disable; added OSI module

* commit '3e3d2a1d3bb9ada4fa612bf9d58c05b629385af2':
Shutdown alarm callbacks on stack disable; added OSI module
3ba10094f250cfdfc1b00ecde4e83dae97c4be85 19-May-2015 Chih-Hung Hsieh <chh@google.com> am 56350d68: Include gki.h to get correct function declarations.

* commit '56350d683a15117b9e80ff3bf3b83671f3a7491a':
Include gki.h to get correct function declarations.
7e92f745d88520a456d0b04bbec58478a193b985 18-May-2015 Chih-Hung Hsieh <chh@google.com> Include gki.h to get correct function declarations.

BUG: 21119653
Change-Id: I8e4caf1946f525ea57fadf003ca3fd7d303976cb
(cherry picked from commit 56350d683a15117b9e80ff3bf3b83671f3a7491a)
tif_gatt_util.c
56350d683a15117b9e80ff3bf3b83671f3a7491a 18-May-2015 Chih-Hung Hsieh <chh@google.com> Include gki.h to get correct function declarations.

BUG: 21119653
Change-Id: I8e4caf1946f525ea57fadf003ca3fd7d303976cb
tif_gatt_util.c
3e3d2a1d3bb9ada4fa612bf9d58c05b629385af2 18-May-2015 Andre Eisenbach <eisenbach@google.com> Shutdown alarm callbacks on stack disable; added OSI module

Change-Id: Iecf1e2258da012bdac69a4f57d38b12a272e3edd
tack_manager.c
1287166da9c34f041d54a78800b79cb2738675a9 09-May-2015 Andre Eisenbach <eisenbach@google.com> DO NOT MERGE Fix compilation on platforms with BLE_INCLUDED == FALSE

This is not a comprehensive fix. More work is necessary to ensure the
correct separation of BLE_INCLUDED TRUE/FALSE as well as removing many
of the hacked-up if() statements resulting from this patch.

Change-Id: I1812594feba0bf43369096e472a8b18cde305255
tif_dm.c
fe38a5609bf2b8bbcb781291f20c1cdcfb583ba1 13-May-2015 Mudumba Ananth <ananthm@broadcom.com> am b4180cf8: Fix BT PAN crash by re-ordering callback initialization

* commit 'b4180cf8a5d70f9e1e815b64ba5e1df25d2fdda4':
Fix BT PAN crash by re-ordering callback initialization
b4180cf8a5d70f9e1e815b64ba5e1df25d2fdda4 06-May-2015 Mudumba Ananth <ananthm@broadcom.com> Fix BT PAN crash by re-ordering callback initialization

Bug: 20868163
Change-Id: I8e3bb844b96b762f90a85d8d9d678a1a9cec9c32
tif_pan.c
c7d97b97949bf5f09736be11d27f46f3e4b29a31 13-May-2015 Andre Eisenbach <eisenbach@google.com> am 91fbc7e5: Fix compilation on platforms with BLE_INCLUDED == FALSE

* commit '91fbc7e560bb9c9f344980a18983d32e51f0360a':
Fix compilation on platforms with BLE_INCLUDED == FALSE
91fbc7e560bb9c9f344980a18983d32e51f0360a 09-May-2015 Andre Eisenbach <eisenbach@google.com> Fix compilation on platforms with BLE_INCLUDED == FALSE

This is not a comprehensive fix. More work is necessary to ensure the
correct separation of BLE_INCLUDED TRUE/FALSE as well as removing many
of the hacked-up if() statements resulting from this patch.

Change-Id: I1812594feba0bf43369096e472a8b18cde305255
tif_dm.c
c2b5c0e995202dd72f91037378a6f39ae88580d8 12-May-2015 Andre Eisenbach <eisenbach@google.com> am 89f5e411: Bluetooth native dumpsys logging support (2/5)

* commit '89f5e411d9ef31436741288a2267e46dd744e273':
Bluetooth native dumpsys logging support (2/5)
89f5e411d9ef31436741288a2267e46dd744e273 05-Dec-2014 Andre Eisenbach <eisenbach@google.com> Bluetooth native dumpsys logging support (2/5)

Includes support for BTSnoop logging in memory.

Bug: 18508263
Change-Id: I175da528cbcdc00d40622647d518a74210cfe6fd
luetooth.c
tif_debug.c
tif_debug_btsnoop.c
tif_debug_conn.c
185592b5d0f2102032fcc6f1eaf72bca97fa4274 11-May-2015 Andre Eisenbach <eisenbach@google.com> am a778a64c: Only register key types with uinput that we can actually map

* commit 'a778a64c053acdb99b7a14b5837b4f12d83009a1':
Only register key types with uinput that we can actually map
a778a64c053acdb99b7a14b5837b4f12d83009a1 11-May-2015 Andre Eisenbach <eisenbach@google.com> Only register key types with uinput that we can actually map

Bug: 20641307
Change-Id: I40cb1e22c35963429481a2cc9da897b5b2f554fe
tif_rc.c
f6c48a09e398de804f7d563a44904e917afd2c32 08-May-2015 Brian Carlstrom <bdc@google.com> Resetting system/bt

git reset --hard fa5fec7c98ff3c56bd825bc51a1d28bdc3bad0bb^^
git reset --soft aosp/master
git commit -a

Change-Id: I2939d9bbd825110a42a71008e5255945e38a77e1
tif_core.c
tif_dm.c
tif_gatt_client.c
5725fc6d2c639a8c22a08b9b6629309eeda3715e 31-Mar-2015 Satya Calloji <satyac@broadcom.com> LE low power scan feature

LE low power extended scan feature stack changes
based on Google BLE spec v0.95

Bug: 20029342
Change-Id: I1db2d9bb648295340d0e93ca89d27e1b938d33d3
tif_core.c
tif_dm.c
tif_gatt_client.c
59606cc1f9861f7f8c53b2dba6431e882fd2870b 05-May-2015 Andre Eisenbach <eisenbach@google.com> Ensure PAN is initialized before invoking callbacks

Fix minor conditional check and clean up surrounding code.

Bug: 20717705
Change-Id: I581fda37708062327c86cc0548b2665c9811be25
tif_pan.c
e87ef6dba42ebaa94c7f0200d9e5223d1259b9d9 01-May-2015 Andre Eisenbach <eisenbach@google.com> Use BTM structures for LE pairink keys and store LTK

The long term key (LTK) was not assigned to the correct struct element
before saving the key to NVRAM.

Change-Id: Icfce82f5b70518e725875771756edde0b9caeb88
tif_dm.c
tif_gatt_util.c
tif_storage.c
1f293a50abf0bd37d149604c674ae5a6dbab7750 01-May-2015 Nitin Arora <niarora@codeaurora.org> Stop media task alarm when task is exiting

Bug: 20717705
Change-Id: I76e76cf33d7c9f4366f921daf2230e4f681098f7
tif_media_task.c
8a05724400085c56bdb2c4d7293226a7aa1ace37 30-Apr-2015 Andre Eisenbach <eisenbach@google.com> Fix LE pairing LTK storage issue

Two separate issues prevented the correct LTK from being storred in
non-volatile storage and thus prevented an LE device from working after
Bluetooth was restarted:

1. tBTM_SEC_BLE_KEYS contained a field "pltk" which stored the LTK, but
downstream the field "ltk" in the same structure was used to access
the key.

2. The structure element p_key_value was not deep-copied for
BTA_DM_BLE_KEY_EVT events, causing data corruption and instabilities.

This patch addresses both issues.

Bug: 20091926
Change-Id: I9f9481a44bfe83cacd351f9e578451e77b573564
tif_dm.c
97bcfbe83216e6a76c0ad0c27fb2cc33494acc61 29-Apr-2015 Andre Eisenbach <eisenbach@google.com> Add LE device to device database before adding LE keys

A small bug in btif_read_le_key() would prevent a paired LE device from
being added back into the internal device database after reboot, causing
the security keys not being loaded.

Also added a debug statement to trace keys being loaded.

Bug: 20091926
Change-Id: Id2d6c69497857edc21e2d4c6a67ad9e8dadabcaa
tif_storage.c
198bf210100fa97cedfa664321144e400fabb268 27-Apr-2015 Nitin Shivpure <nshivpur@codeaurora.org> Fix PAN initialization

Change-Id: I32d8975f0f6e1ea18a361a19260ffea7a3ec8467
tif_pan.c
e28055315f96c0d06e73a66a9bb06df85247b5a7 22-Apr-2015 Chaojing Sun <cjsun@broadcom.com> Cross transport key mapping fixes

Change-Id: I22d97303054eccc876c4a9c7c0a50e369ff4fa62
tif_dm.c
tif_storage.c
9f2120c15220a8bc865d3a065e6121a1b4d6cf57 24-Apr-2015 Etan Cohen <etancohen@google.com> Merge commit '00e8f5e' into merge2

Change-Id: Ifa83bd342458eba33fdd11a9db38d2f9e818b759
ed57886be70b58873e5fe7103171b341b8784277 23-Apr-2015 Andre Eisenbach <eisenbach@google.com> Add missing __func__ in btif_hf init()

Change-Id: I0fe4ea75c6448f43f1638614a9a6519fa58962de
tif_hf.c
4434876dcf758e8f3881af50a39822af7cbd94ea 23-Apr-2015 Andre Eisenbach <eisenbach@google.com> Fix possible race conditoi in hands-free initialization

With the LE-only mode changes in place, there is a potential race
condition between the audio-gateway (AG) registration and the hands-free
service initialization as the core stack is now initialized before the
hands-free service starts.

Modified from patch submitted by Nitin Arora <niarora@codeaurora.org>.

Bug: 20481584
Change-Id: I78d62329aa5e4113c72fac2d40efa671442bae2d
tif_hf.c
98b744f270323db14705c1251bc7bc89d196e16d 21-Apr-2015 Andre Eisenbach <eisenbach@google.com> Fix A2DP source double initialization problem

Fixed a problem where A2DP source was initialized twice. Once before
btif was properly initialize and then a second time when the JNI
requests A2DP to be initialized, which would then fail.

Change-Id: Ia5f10a5bda344fe3bd66818a302b6b3f9db32a20
tif_av.c
tif_core.c
tif_pan.c
949baaef237d08f482b5132dc389ae84b05113f8 16-Apr-2015 Ian Coolidge <icoolidge@google.com> Fix missing includes under glibc on new code.

Change-Id: I2451f782ce3f51147ebaddc559c616eac0a2b7d9
tif_sdp.c
tif_sdp_server.c
tif_sock_l2cap.c
8a0b80ebad0cb187ff7856d14b83fa74aed51d98 07-Apr-2015 Casper Bonde <c.bonde@samsung.com> Add support for Bluetooth Sim Access Profile (1/4)

Change-Id: Ie1dd95ee00976255f74b6747a1d3fc3ed59152f3
tif_sock_sdp.c
f54df6b47616eeae11001b1d2e977548fe316227 15-Apr-2015 Vinit Deshpande <vinitd@google.com> Fix build issues after the merge

Change-Id: Ia856311187a0b2168cb859bd8b2300ff59df6569
tif_sdp_server.c
tif_sock_l2cap.c
tif_sock_rfc.c
4b555d5fa4df83fe5a415d0f4f50ccea85c32441 07-Apr-2015 Casper Bonde <c.bonde@samsung.com> Add support for Bluetooth Sim Access Profile (1/4)

Change-Id: Ie1dd95ee00976255f74b6747a1d3fc3ed59152f3
tif_sock_sdp.c
2cd086a11a972f2e437dd521a121ed76ea79a15a 15-Apr-2015 Vinit Deshpande <vinitd@google.com> am f29a2fb..e07ad10 from mirror-m-wireless-internal-release

e07ad10 merge in m-wireless-internal-release history after reset to d232721ae5e5b6949a5249f0d116408b8a3c5f1d
d232721 L2CAP socket - fix merge errors
899b771 BR/EDR secure connections support
7fb0da6 Support numeric comparison in SMP
aa351f2 merge in m-wireless-internal-release history after reset to 399e89150b3df87172bdf92d54712b379324b149
399e891 Fix for AVRCP CTRL stops sending pass through command
daddea9 Free Avrcp Controller callbacks on Cleanup
764babe Protect reset of out stream with mutex
444a8da LE Privacy 1.2 and LE secure connections
8372aa5 L2CAP and SDP Search API for BT profiles (2/2)
fd422a7 Update Service Availability.
2a0652a merge in m-wireless-internal-release history after reset to 0b47e0a35c16f5b7d77c30ec1c095ed92ff4fd74
78d0f4c merge in m-wireless-internal-release history after reset to m-wireless-internal-dev
0b47e0a Avoid duplicate disconnection callbacks for fixed channel connections
5646973 Add a section on assertions to the style guide.
d768767 Merge "Avoid null-pointer dereference in l2c_release_lcb()" into m-wireless-dev
ef92b53 Avoid null-pointer dereference in l2c_release_lcb()
4bf68bf merge in m-wireless-internal-release history after reset to f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56
de6ac86 Add a 'Bluedroid conventions' section to the style guide.
1b80439 Add a section to the style guide on variable declarations.
485f19e merge in m-wireless-internal-release history after reset to 4540f59bc447dc2b7b31a3e974b74a60b2417e7d
bef8940 merge in m-wireless-internal-release history after reset to 841c9103cad1898ceca87b734acd4d4537f9f452
ab4c38c merge in m-wireless-internal-release history after reset to a7e698f5a9e062f62e21bc435643975c30bab846
2807a74 merge in m-wireless-internal-release history after reset to a7e698f5a9e062f62e21bc435643975c30bab846
99dbe9a merge in m-wireless-internal-release history after reset to 78c0b060f29b7b7014adddb2f98bf6ae9755c488
f7f8399 merge in m-wireless-internal-release history after reset to a5371c238b4e874d8313ac56a23451e7345ff541
3aa60d7 Make A2DP audio HAL a shared library again
3256a31 Move unused include file out of hci_audio.h
b866b69 Add option for schedule_next_instance to force rescheduling
4ae5e3e Ensure alarms are called back when they expire in the past
a7bd03e Rewrite alarms to use a single posix timer instance
88e7b15 Resolved hardware error observed during SCO Connection setup

Change-Id: Ib9a0a2ffca1d4811a9a9e56674bf43275d8b2205
7fb0da6c0df9491f06c61ab0ba4183129502a065 30-Jan-2015 Satya Calloji <satyac@broadcom.com> Support numeric comparison in SMP

Enable support for numeric comparison in SMP when LE Secure connection
is supported. The change will distinguish between passkey confirmation
in case of Security grant and Passkey confirm.

Original author: Priti Aghera <paghera@broadcom.com>

Bug: 19816438
Change-Id: Id1fd072d1e567a80b020b4ba217486c3308ad39d
tif_dm.c
399e89150b3df87172bdf92d54712b379324b149 06-Sep-2014 Anubhav Gupta <anubhavg@codeaurora.org> Fix for AVRCP CTRL stops sending pass through command

Issue is due to BTA_AV_REMOTE_RSP_EVT is not handled in btif_av
handler. Swtich case added to handle remote response event in
btif_av_opened_handler and btif_av_started_handler.

Change-Id: I58a7bd8bfe5b07a7339d93d2b66928131836d431
tif_av.c
daddea9cf1f5dbf51b9a2e9c2b02956a41d77a6c 08-Sep-2014 Anubhav Gupta <anubhavg@codeaurora.org> Free Avrcp Controller callbacks on Cleanup

Free AVRCP Controller callbacks on cleanup so that callbacks
are initialized properly on next initialization.

Change-Id: Ieaf4c1989a7c40c591adfb7cb47912532ceee46e
tif_rc.c
444a8da807abaf5f9e813ce70c56a79160495fb3 06-Mar-2015 Satya Calloji <satyac@broadcom.com> LE Privacy 1.2 and LE secure connections

Bug: 19816438
Original author: Chaojing Sun <cjsun@broadcom.com>
Change-Id: I5951f4d4e038f8348a62aa6d19b2111bae0b3ecc
tif_config.c
tif_dm.c
tif_storage.c
8372aa5fa535ee4f09c09981b6125b54ace31fe2 25-Mar-2015 Kim Schulz <k.schulz@samsung.com> L2CAP and SDP Search API for BT profiles (2/2)

Added support for exposing L2CAP to Java such that OBEX over L2CAP
is made possible.

Added support to create SDP records as a seperate step.(as opposed to
creating a SDP record when a BluetoothSocket is created).
This allows both a RFCOMM channel and a L2CAP PSM to be included in a
SDP record. (Additionally the content of the SDP record is set by the
profile in Java, in stead of beeing hardcoded in the socket layer.)
This completes the L2CAP channel exposure to Java.

Change-Id: Iaf68a07d910145cdd33e940d73cd680f79164100
luetooth.c
tif_core.c
tif_dm.c
tif_sdp.c
tif_sdp_server.c
tif_sock.c
tif_sock_l2cap.c
tif_sock_rfc.c
tif_sock_sdp.c
tif_sock_thread.c
tif_sock_util.c
b246a1a750c5a337faaa6033b39e78c8bdd4c2fb 10-Apr-2015 Prerepa Viswanadham <dham@google.com> Merge commit '4bf68bf020c7fd1aabcdc4b5d8f5fbb8bacdec9d' into merge_work

Change-Id: Ibc6d6e691b7f97611d16f96220346dfd6ffbbf52
9c8dface40b8427b3dc03ddd13ca7532f7d855d5 08-Apr-2015 Rakesh Iyer <rni@google.com> Fix init sequence for BT AV sink.

BTA_AvEnable_Sink() was being called to early causing
a crash loop when the BT AV_SINK was included. This patch
changes up the init sequence to match that of the av
source. Also, rename a few constants for clarity.

Change-Id: I3e6a7e22a2643eeceb4afc082979d1d9967b0b99
tif_av.c
tif_dm.c
f538707fe64c62b1dbb8e4210e4a1bfa0bab2b56 10-Feb-2015 Satya Calloji <satyac@broadcom.com> OnFound/OnLost feature changes based on Google spec v0.90

Bug: 19609671
Change-Id: If9e61b405a141cb77fb65741d08227284cb22ccd
tif_core.c
tif_dm.c
tif_gatt_client.c
tif_gatt_util.c
4540f59bc447dc2b7b31a3e974b74a60b2417e7d 05-Feb-2015 VenkatRaghavan VijayaRaghavan <venkatrv@broadcom.com> Static code analysis cleanups and minor bug fixes

- Fix for initializing all the un-initialized variables
- Handling system call failure like socket,fcntl etc...
- In btpan_tap_close validate tap_if_down and close the socket.
- Invalid memset size, which could have potential memory issue
- Change -1 to INVALID_FD where appropriate

Bug: 19417758
Change-Id: Id31832f8678b2d72c80740c29b946a94e7ae0197
tif_dm.c
tif_pan.c
tif_rc.c
tif_sock_thread.c
aba88aee024266b4b8375d9b27b94469f15c2716 03-Feb-2015 Ian Coolidge <icoolidge@google.com> Fix pthread_t confusion.

Don't assign pthread_t to pid_t or UINT32.
Just use pthread_t throughout.

(cherry picked from commit df3459935a4c12744a9a78812157890b60ccb77d)

Change-Id: I1ab086a547a731358003471be867cfb189f61c56
tif_sock_thread.c
aea27ef29bd0be1d9faa5dcf94588107e9b6a51d 03-Apr-2015 Rakesh Iyer <rni@google.com> Fix build in BT AV_SINK.

Change-Id: Ie20165ee69597e3287283322d14773ac3699c323
tif_media_task.c
47d68ee6229ccec3deeaaf694fa86438d97333a4 03-Apr-2015 Scott James Remnant <keybuk@google.com> osi: add compat code for glibc

glibc doesn't declare strlcpy(), strlcat() or gettid(). Add a header
of compatibility routines that only get included when compiling on this.

Change-Id: I889ac7f1d22cf7056757890fcff0403107488d62
tif_config.c
tif_sock_rfc.c
tif_storage.c
656c5a8c9ca254ce12f7acf4336fbc63998cc9e6 03-Apr-2015 Scott James Remnant <keybuk@google.com> Fix non-standard pthread mutex interactions.

pthread_mutex_t is intended to be opaque.
pthread_attr_t is intended to be opaque.

Change-Id: Ie0f5558a96f8e5fc8b2f59763acbfe5340fa81a4
tif_sock_rfc.c
tif_sock_thread.c
7d165d984733ec92c4ae3327c8c791aa3a038684 03-Apr-2015 Scott James Remnant <keybuk@google.com> btif_pan: Grab interface declarations from net/if.h only.

This is the libc interface file.
Using linux/if.h produces definition collisions on glibc.

Change-Id: I8744258ba0c4698d8f9f5b1215bb3cb1d86618fe
tif_pan.c
933926c92e1378cc76bc9c149107e670c4872d4e 03-Apr-2015 Scott James Remnant <keybuk@google.com> Fix missing #includes needed for glibc

Some standard library functions are used while relying on bionic headers
including the headers the functions were actually declared on. Add those
missing #includes so that bluetooth.default.so will compile on glibc.

Change-Id: Ied9f89ce5a05911fca63f6bfe1b8cc8196ab3b1c
luetooth.c
tif_dm.c
tif_gatt_multi_adv_util.c
tif_hf.c
tif_hf_client.c
tif_mce.c
tif_pan.c
tif_profile_queue.c
tif_rc.c
tif_sock_rfc.c
tif_sock_sco.c
d0f0847216d7cfd5f0544da6efdc290f7a76c19b 27-Mar-2015 Wei Wang <weiwa@google.com> Remove BLE_PERIPHERAL_ADV_NAME flag.

BLE_PERIPHERAL_ADV_NAME forces inclusion of device name
in advertise data. Since setIncludeDeviceName is already
available in advertise API to control the presence of
device name the flag should be removed.

Change-Id: I8637529b2d809bb9829783f60bd7e9889784c8b7
tif_gatt_multi_adv_util.c
1f01b26f7a9a49107eb489917351736a57ab8520 02-Apr-2015 Andre Eisenbach <eisenbach@google.com> Fix compile error on Fugu

Change-Id: I389acc5c5034e1b232da0307f77577b939af68ac
tif_pan.c
3e59b5b6f2ce1295e3e2711afcd2cdf0dd7e22b6 01-Apr-2015 Etan Cohen <etancohen@google.com> Fix build issues in bluedroid on master

Change-Id: I0d3e93ea61dd03505fe9db902ed90bdd4141cab2
tif_sock_rfc.c
tif_sock_sco.c
tif_sock_sdp.c
e1a9e52ff59d36bd1bb5b7b3a02fafba6394edfe 31-Mar-2015 Etan Cohen <etancohen@google.com> Merge commit 'f7f839985b3931682363d2ef3b7c5cae55a842ee' into merge

Change-Id: Iaaec1ea0bf3009b7e32a9a60f697631a3f56e889
582f20aa0f390d1c0f6aeff4e2e8f42f7b69d404 27-Mar-2015 Wei Wang <weiwa@google.com> Remove BLE_PERIPHERAL_ADV_NAME flag.

BLE_PERIPHERAL_ADV_NAME forces inclusion of device name
in advertise data. Since setIncludeDeviceName is already
available in advertise API to control the presence of
device name the flag should be removed.

Change-Id: I8637529b2d809bb9829783f60bd7e9889784c8b7
tif_gatt_multi_adv_util.c
80349eb4a14e74b6e28dac7829dcf2a199bd1de5 24-Mar-2015 Mallikarjuna GB <gbmalli@codeaurora.org> am 0d65d4cd: AVRCP: Proper handling of Fragmented AVCTP packet

* commit '0d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7':
AVRCP: Proper handling of Fragmented AVCTP packet
0d65d4cdafc165484dfc8d1c5af4ac1cb7453fd7 10-Nov-2013 Mallikarjuna GB <gbmalli@codeaurora.org> AVRCP: Proper handling of Fragmented AVCTP packet

- AVCTP : Allocate bigger buffer for reassembly
- AVRCP : Handle getelimentattr to eliminate duplicates
and invalid attributes, this also fixes BOF.

Change-Id: I99f6e0fc4dc0cc0fac8854a8ee8671249d67f745
CRs-Fixed: 576831
tif_rc.c
7b85efab9d5921642e841f0145047093571cce20 26-Sep-2014 Nitin Arora <niarora@codeaurora.org> Delete 0 index LE scan filter at inquiry cancel

This patch ensures that the 0 index filter is deleted when the
inquiry is cancelled due to initiation of a direct connection
from inquiry or due to return from the Settings menu screen

Change-Id: I281c6ace15b17fb7e413c42d36e016b8f82d2ace
tif_dm.c
f8027005333c88a2f097cfd70d15c3d54c7764ae 12-Mar-2015 Chris Manton <cmanton@google.com> Demote, cleanup and extend observed logging
luetooth.c
tif_av.c
tif_core.c
tif_dm.c
tif_gatt.c
tif_gatt_client.c
tif_gatt_multi_adv_util.c
tif_gatt_server.c
tif_gatt_test.c
tif_gatt_util.c
tif_hf.c
tif_hf_client.c
tif_hh.c
tif_hl.c
tif_mce.c
tif_media_task.c
tif_pan.c
tif_profile_queue.c
tif_rc.c
tif_sm.c
tif_sock.c
tif_sock_rfc.c
tif_sock_sco.c
tif_sock_sdp.c
tif_sock_thread.c
tif_sock_util.c
tif_storage.c
tif_util.c
95b74f252f534ec757aab1fc08e086e02b2cfe8d 12-Mar-2015 Sharvil Nanavati <sharvil@google.com> Use fully qualified path for btcore includes.
tif_config.c
tif_core.c
tif_dm.c
tif_gatt_client.c
tif_gatt_util.c
tif_hf.c
tif_hf_client.c
tif_mce.c
tif_pan.c
tif_storage.c
tack_manager.c
0f9b91e150e153229235c163861198e23600e636 12-Mar-2015 Sharvil Nanavati <sharvil@google.com> Use fully qualified path for OSI includes.
luetooth.c
tif_config.c
tif_core.c
tif_hl.c
tif_media_task.c
tif_pan.c
tif_profile_queue.c
tif_sm.c
tif_sock.c
tif_sock_rfc.c
tif_sock_sco.c
tif_storage.c
tack_manager.c
71864f490d4dc31857df0b31924cd62a337e9f1a 11-Mar-2015 Zach Johnson <zachoverflow@google.com> Add ability to set periodic alarms

Adds alarm_set_periodic so the alarm code can have more
contextual information when rescheduling alarms.

Problem: A2DP would stream for a few seconds and then
stop working.

Cause: The Java garbage collector. Bluedroid reaches out
to javaland to acquire and release the wake lock. Alarm was
always reaching out to get the wake lock when it scheduled a
short timeout. If GC kicked in during that call out to make
sure we have the wake lock, it could take more than 100ms to
get back us. That would screw over the alarm implementation
particularly for small 20ms timers.

So now if the wake lock was already acquired, we don't try to
reacquire it.

Cool. But we still have thrashing. Why? Because the alarm code
doesn't know the alarm is actually being used in a periodic way.

Here's what used to happen:

alarm expires
alarm is removed
reschedule
alarm callback is called
alarm callback sets the alarm again
alarm is added
reschedule

The problem is the first reschedule will get rid of the wake lock
if the next alarm is too far out or doesn't exist, meaning the next
reschedule needs to get the wake lock again.

With the extra periodicity information we can eliminate the
unnecessary intermediate reschedule, meaning no thrashing on the
wake lock. yay!
tif_media_task.c
1d8e6b8e7fcf6bc691be94a362030915ac15b23b 06-Feb-2015 VenkatRaghavan VijayaRaghavan <venkatrv@broadcom.com> Prevent Memory overbound and initialize variables

1. Fix for initializing all the un-initialized variables
2. Potential strncpy overbound

Bug: 19417758
tif_dm.c
tif_hl.c
e13fbfafe2105d264357ac41133f0ac0e054429c 28-Dec-2014 Sharvil Nanavati <sharvil@google.com> Remove more GKI code.

This change removes all remaining GKI task remnants as well as
a few timer and buffer bits.
tif_av.c
tif_media_task.c
23e561a1f374557d6030b497337a1c96e9bb6aa4 03-Mar-2015 Sharvil Nanavati <sharvil@google.com> Remove dependency on GKI tasks from BTIF media task.

The previous code started a thread and posted a long-running function
to the thread's event loop. In essence, it created a thread and ran
a custom thread main that did its own event handling using GKI_wait.

The new code doesn't use GKI_wait or GKI_send_event at all. Instead,
it uses thread_post and the thread's reactor to enqueue and dispatch
events.
tif_media_task.c
c0a87fe60f79ddf41595a30e75a77f43c19cd323 02-Mar-2015 Sharvil Nanavati <sharvil@google.com> Remove GKI timers
tif_media_task.c
1ece3a37fca9ced4f9f3c3a66fac99b0e5cabf92 12-Jan-2015 Zach Johnson <zachoverflow@google.com> Drop duplicate profile connection requests

If profile connection requests come in too quickly
for us to handle, clients can effectively DoS the bluetooth
stack.

We used to see out of buffer errors because the requests
were batched up and sitting on buffers the rest of the stack
needed. With the switch to pure allocation we didn't see that
specific problem anymore, but we were still running into the
sanity assert.

Bug: 18323666
tif_profile_queue.c
8ff3fea05b0d01f7a011326542161f892e2b31d6 07-Jan-2015 Chris Manton <cmanton@google.com> Rename legacy uuid_copy to not conflict
tif_dm.c
tif_storage.c
tif_util.c
364a1e7be4d38d83f51f1363d9a1837de57bcd2d 26-Dec-2014 Sharvil Nanavati <sharvil@google.com> Remove unnecessary newlines at the end of log statements.
tif_core.c
44802768c447ab480d4227b3a852a97d923b816d 24-Dec-2014 Sharvil Nanavati <sharvil@google.com> Add platform-independent logging macros to OSI.

These macros should replace ALOG* and the various trace macros
used throughout bluedroid. This change eliminates all uses of the
ALOG* macros in favor of the new ones.
luetooth.c
tif_config.c
tif_config_transcode.cpp
tif_core.c
tif_dm.c
tif_gatt_client.c
tif_gatt_server.c
tif_gatt_test.c
tif_gatt_util.c
tif_hh.c
tif_hl.c
tif_pan.c
tif_sock.c
tif_sock_rfc.c
tif_sock_sco.c
tif_sock_sdp.c
tif_sock_thread.c
tif_sock_util.c
tif_storage.c
tack_manager.c
c0745da4fb23eea23abac3c3cfd51cc7f1d38f6d 13-Nov-2014 Sharvil Nanavati <sharvil@google.com> Enable allocation tracking for eng and userdebug builds.

This change will result in a constant increase in memory utilization
per allocation but will help us catch memory errors earlier.
luetooth.c
9de511d7b2bff064949799081f447342db036d2e 19-Sep-2014 Chris Manton <cmanton@google.com> Replace BUFFER_Q with list_t

soc_queue
tif_hl.c
2487018e0ad31e8962eed0131be08b27dde5d25c 04-Dec-2014 Zach Johnson <zachoverflow@google.com> ungkibufferize the profile queue, use assert

ASSERTC isn't a real assert. It just prints a message and allows the
code to carry on. Switch to asserts so the exception condition is
evident in the crash log.

Make the profile queue use osi_malloc/free instead of gki buffers, so it
can't drain the buffer pool.
tif_profile_queue.c
a50fc88c9f784a2422ceac014fea47ac1717647b 31-Oct-2014 Zach Johnson <zachoverflow@google.com> Remove BTA_CheckEirData, a direct redefinition of BTM_CheckEirData

Gentle move towards using more of BTM directly.
tif_dm.c
tif_gatt_client.c
9609cee33087141eeb7b5adede488d7e13bfcebd 16-Oct-2014 Sharvil Nanavati <sharvil@google.com> Use correct service ID for A2DP source to make way for A2DP sink.
tif_av.c
tif_dm.c
tif_storage.c
79ecab5d0418fde77e9afcdd451bd713af73e180 31-Oct-2014 Chris Manton <cmanton@google.com> Move controller module to device directory
tif_core.c
tif_pan.c
tack_manager.c
eacc69d09256ecaa7c01ea066cd70b0049edc23b 28-Oct-2014 Sharvil Nanavati <sharvil@google.com> Don't dispatch connections in the connection queue until stack comes up.

Bug: 18139425
tif_profile_queue.c
tack_manager.c
f3bf1b74aba6466a13924d419a4e81cd356ee7e6 21-Oct-2014 Zach Johnson <zachoverflow@google.com> Remove uncompiled unused PBAP support

Like OPP, the phone book access profile is implemented in
java for android. Cleaning up some references to uncompiled phone book
support in bluedroid.

Left the few definitions SDP relies on. We can consolidate that later.
tif_sock_sdp.c
794f3b5f126fffc3dd1129a710187591348bbf23 01-Oct-2014 Chris Manton <cmanton@google.com> Removal of bd.[c|h]

Consolidate legacy types into bt_types.h
tif_av.c
tif_config.c
tif_core.c
tif_dm.c
tif_gatt.c
tif_gatt_client.c
tif_gatt_server.c
tif_gatt_test.c
tif_gatt_util.c
tif_hf.c
tif_hf_client.c
tif_hh.c
tif_hl.c
tif_mce.c
tif_pan.c
tif_rc.c
tif_sock.c
tif_sock_rfc.c
tif_sock_sdp.c
tif_sock_thread.c
tif_storage.c
tif_util.c
b4f21b5ca0ebb8130eb0047c0af17b0b38317c98 19-Sep-2014 June R. Tate-Gans <jtgans@google.com> Moving btif_sock_sdp to stdint and stdbool.
tif_sock_sdp.c
ad7c19ea9a164c3f7ebe3786114c5d98870eee05 16-Sep-2014 Zach Johnson <zachoverflow@google.com> Fix how add_sdp_by_uuid passes the uuid to SDP_AddSequence

SDP_AddSequence expects to dereference the passed
pointer and find a pointer there, and that pointer
pointing to UINT8s.

Before, we were passing &type_buf, which gives the
address of the first UINT8 in the array on the stack.
This meant SDP_AddSequence was treating the first few
bytes of the uuid as a pointer to somewhere, leading
to a segfault when it tried to follow it.
tif_sock_sdp.c
75b22fd55f44923054b411cc7cd2ca312e6fca9e 11-Sep-2014 June R. Tate-Gans <jtgans@google.com> Refactoring btif_sock_sdp.c for clarity
tif_sock_sdp.c
cb7ce537fda7d0013e8297e94130581634194fbc 26-Feb-2015 Zach Johnson <zachoverflow@google.com> Revert "BT MAP: added support for email sharing over BT"

Another change being backed out until the megamerge is over.

This reverts commit c331807e3c3a0e15180a11325e1635ae5268aa39.
tif_sock_sdp.c
396768efd615a5f6ffa60d16575a56cc01c7ca96 26-Feb-2015 Zach Johnson <zachoverflow@google.com> Revert "MAP: SDP corruption"

Backing out so our rewrite merges cleanly.

This reverts commit 54e24af853a77a057995ee4f234bae4d490b32e5.
tif_sock_sdp.c
f1c764fab01c929f71e185b97433bf40938026d3 24-Feb-2015 Sharvil Nanavati <sharvil@google.com> Make build more strict by adding more warning flags.

This change introduces -Wunused-but-set-variable to help catch
programming errors. It also undefines NDEBUG so assertions are
fatal and defines LOG_NDEBUG=1 to suppress LOGV.
tif_dm.c
tif_hl.c
tif_pan.c
tif_rc.c
be1cd678150609b3ec23498805f7df50c959d23d 20-Oct-2014 June R. Tate-Gans <jtgans@google.com> Removing a duplicate call to socket_register.
tif_sock_sco.c
39110ec88460421618330863807804e03594ef67 06-Oct-2014 Zach Johnson <zachoverflow@google.com> Remove duplicate local bdaddr management functions
tif_core.c
tif_dm.c
tif_pan.c
30e58068c1adaac7c5ccb3aa9cfb045d41d2a10e 27-Sep-2014 Zach Johnson <zachoverflow@google.com> Refactor btm_devctl reset sequence

* Controller bring up on blockable thread now
* Removed some duplicate and commands during controller bring up
* The code to make commands for controller bring up is smaller and better
tack_manager.c
96363ff2b78c10e2b2e106464f337b58ec1a616a 25-Sep-2014 Zach Johnson <zachoverflow@google.com> Modulizification of bt_utils
tif_core.c
tack_manager.c
9b0fbce37260e69cb116be1cdcbceb1f43bf9346 24-Sep-2014 Zach Johnson <zachoverflow@google.com> Modulizification of btif_config
tif_config.c
tif_core.c
tack_manager.c
8675d884479deca722ef5d7776a165241457dd75 27-Sep-2014 Zach Johnson <zachoverflow@google.com> Move module_management_stop to clean_up

Module management isn't done when the stack is shut_down (bluetooth disabled)
tack_manager.c
9891f32471b5c01cf58e4d7dadb04cb3024a9a88 23-Sep-2014 Zach Johnson <zachoverflow@google.com> Refactor btsnoop and stack config into modules

Moves stack config out of the combined bte_config, and into
its own module.

Makes btsnoop more self sufficient and removes uneccessary
levels of indirection.

Refactor logging slightly into a (temporary) module to disassociate
from the direct calls from config. Eliminates some useless stuff in
the module as well.
luetooth.c
tif_core.c
72f308ee6d3983ae2c0d67be3de2451f2dd72dcb 23-Sep-2014 Zach Johnson <zachoverflow@google.com> First pass at implementing modules

This first step creates the notion of a module and corresponding
lifecycle functions, with helpers to simplify working with them.

Once everything is converted over to this module format, then we
can make the stack manager automagically find the correct order for
init/start_up/shut_down/clean_up
tack_manager.c
753173dee0b92efdbdc0eb4d44338cd1a84dbdb2 26-Sep-2014 Chris Manton <cmanton@google.com> Replace bt media GKI task with thread_t
tif_media_task.c
4ada04168dbdbfac48281b7c91186a885b46f7c0 23-Sep-2014 Zach Johnson <zachoverflow@google.com> Rewerite btif_sendmsg in terms of thread_post
tif_core.c
efea7821780cdea2b30e944b08e418d1f2781878 25-Sep-2014 Zach Johnson <zachoverflow@google.com> Post adapter_state_changed events to the JNI workqueue

Otherwise, JNI rejects the callbacks. Fix for b/17655336
tif_core.c
tack_manager.c
1924dac3811575d594c11b76874b24ee0ad24e71 25-Sep-2014 Zach Johnson <zachoverflow@google.com> Don't send adapter change until stack manager updates state

Since the callback occurred before the stack manager updated its
state to say the stack was fully loaded, there was a chance that
the adapter name change would be attempted before the state was
updated.

This would cause the adapter property change function to return
a "not ready" status.
tif_core.c
tack_manager.c
f5153bf62b6cee3f3c740504e94360130c3a9186 22-Sep-2014 Sharvil Nanavati <sharvil@google.com> Eliminate memory leak in stack initialization.

A heap allocated semaphore was not freed after use.
tack_manager.c
f450ba53dfd7b36989c1ea6ed9c6508c7a1b895e 19-Sep-2014 Zach Johnson <zachoverflow@google.com> Remove btif enable state management

It's no longer necessary with the stack manager.

With these changes I don't think we'll be able to handle clean_up
as a result of an enable timeout coming down from Java.
But I think I'm ok with that.

At that point we're already hosed because of something else
which should be fixed. And if we wanted to handle clean_up during
start_up we'd violate the mutually exclusive guarantees the stack
management thread makes about init/start_up/shut_down/clean_up.
tif_core.c
tack_manager.c
8ea8188a481504641fc6a72087704eb808d0bd87 19-Sep-2014 Zach Johnson <zachoverflow@google.com> Make stack manager functions not finish until action complete

It's a bit hacky at the moment, but this incremental update means the
stack manager booleans should be correct now and we can start removing
code that relies on the btif states.
tif_core.c
tack_manager.c
2e241dbe76facf02450c86d9fb4bf3d76d6dde21 19-Sep-2014 Zach Johnson <zachoverflow@google.com> s/async_result/future/g and also improve the future API

Freeing now happens implicitly upon await, and immediate
futures will allow a uniform usage pattern for calls
that are async and calls that are not.
tack_manager.c
8df0d80f0227554d95ed51a443439ee9e7fe7e42 10-Sep-2014 Zach Johnson <zachoverflow@google.com> Move all stack init/start_up/shut_down/clean_up on a single known thread

Execution happens on the same thread, but the next step will be to
ensure each of the functions do not complete until start_up/shut_down/clean_up
complete. That will ensure each is mutually exclusive.
luetooth.c
tack_manager.c
63721d5265985c5041774a6d71858ba82fdf772c 16-Sep-2014 Sharvil Nanavati <sharvil@google.com> Add a check for a NULL root element from tinyxml2's XMLDocument.

This shouldn't really be necessary since a parsed document
should have at least a root element. In practice, however, tinyxml2
sometimes returns success on LoadFile() and NULL on RootElement().

Bug: 17504829
tif_config_transcode.cpp
0eefef0f35dbf400f295e4be8c4c1ee295042d88 09-Sep-2014 Chris Manton <cmanton@google.com> btif task removal and reactor insertion
tif_core.c
8d9d02862b1e00d27681846e3de9c4cf4f6634fc 07-Sep-2014 Sharvil Nanavati <sharvil@google.com> GKI task entry points should have a consistent signature.

Previously, GKI task entry points had inconsistent signatures. For
example, we had:

int btif_media_task(void *p)
void btif_task(UINT32 params)
void btu_task (UINT32 param)

The single argument was universally ignored and the caller always
set it to 0. This change consolidates all of that and defines the
entry point as having 0 arity and no return value.
tif_core.c
tif_media_task.c
dae73b19ce2316b72f44116bc743eec3792de6b4 07-Sep-2014 Sharvil Nanavati <sharvil@google.com> Eliminate GKI_os_malloc and GKI_os_free.
tif_sm.c
0d5de78354b5f7c819950fc5680a6cfd0052f78a 07-Sep-2014 Sharvil Nanavati <sharvil@google.com> Eliminate unused 'stack' concept for GKI tasks.

This change also fixes the type for task names: should be a const
string, not a mutable INT8*.
tif_core.c
tif_media_task.c
860a9af89f8dbf8ef65785d5db960c1fa488d2ba 27-Aug-2014 Chris Manton <cmanton@google.com> Replace mailboxes with fixed queues.

Also refactored btu_task a bit.
tif_core.c
tif_media_task.c
8d360989c2be863798d48cc8b7e923832be5c156 17-Sep-2014 Zach Johnson <zachoverflow@google.com> Make SCO sockets request eSCO instead of SCO

This fixes some audio routing problems.
tif_sock_sco.c
39e8abd1f33dbc7cd3514b2af9c8226bc492e07f 30-Aug-2014 Sharvil Nanavati <sharvil@google.com> Fix memory leak in RFCOMM sockets where some lists were not being freed.
tif_sock_rfc.c
2e7e6eb6cd32df950d789ff5655e8aea098e1b49 23-Aug-2014 Sharvil Nanavati <sharvil@google.com> Remove unncessary socket write to SCO socket.

I've verified that the BluetoothSocket is terminated in a timely manner
even without the write(2).
tif_sock_sco.c
c8aaee2c9393ef28fdbdcf28be80172f387205fc 22-Aug-2014 Sharvil Nanavati <sharvil@google.com> Update SCO sockets to use OSI.

This change brings us one step closer to eliminating btsock_thread.
tif_sock.c
tif_sock_sco.c
fe4ec6ba40c011cfd3599d45fbda3c6575a07189 21-Aug-2014 Sharvil Nanavati <sharvil@google.com> Rewrite the btif_sock module.

The initialization flow now handles errors. The btif_sock module is
now solely responsible for managing the lifetime of the btsock_thread
it creates.

This change lays the foundation for switching all btif sockets to use
the OSI primitives.
tif_sock.c
29e83d4ba9b1554b4383d65fdada049a287600bf 30-Aug-2014 Sharvil Nanavati <sharvil@google.com> Fix heap memory leak by placing the BT device struct in static storage
luetooth.c
ce0bab413c2c1a0a5e9f4a82a6b2833685333bce 28-Aug-2014 Sharvil Nanavati <sharvil@google.com> Fix issue where last character of device name is missing

The device name stored on disk is correct but has a missing character
at the end when read off of disk. This happened because the returned
|length| parameter to |btif_config_get_str| is in number of *bytes*,
not in number of characters (i.e. must add one for NULL character).
tif_config.c
8a6a89faa942aed4f176b0c98402d01c8bdd6aa6 20-Aug-2014 Sharvil Nanavati <sharvil@google.com> Introduce btcore, a low-level library to manipulate Bluetooth data types.

This change adds a single module to btcore: bdaddr. The bdaddr module
is reponsible for manipulating and working with Bluetooth addresses.
tif_config.c
tif_core.c
tif_dm.c
tif_gatt_client.c
tif_gatt_util.c
tif_hf.c
tif_hf_client.c
tif_mce.c
tif_pan.c
tif_storage.c
tif_util.c
b2f0447afd5db6579e380439ad596519276e91d1 21-Aug-2014 Zach Johnson <zachoverflow@google.com> Fix digital transposition in saving binary config data

Was causing link keys to be saved/read incorrectly, causing reconnect on reboot to fail.
tif_config.c
9d52f88bfc07556cb01ab3055f5b1242c9b467aa 19-Aug-2014 Sharvil Nanavati <sharvil@google.com> Eliminate unused arguments to btif_config and clarify variable names
tif_config.c
tif_core.c
tif_dm.c
tif_gatt_client.c
tif_storage.c
b95c4ef4ac9e86953050a7ae6b3b4260df935713 16-Aug-2014 Sharvil Nanavati <sharvil@google.com> Switch over from an XML based file format to .INI-style conf files

This change moves us to using a single file format for all configuration
throughout bluedroid. I've provided a transcoder that converts the
previous config file to the new format so settings will be preserved.

In a future revision of bluedroid, we should remove the transcoder and
drop our dependency on tinyxml2.
tif_config.c
tif_config_transcode.cpp
tif_config_util.cpp
tif_core.c
tif_gatt_client.c
tif_storage.c
f866204ea74d594ba209522eebb7d1e5469ba7b0 19-Feb-2015 June R. Tate-Gans <jtgans@google.com> Rewrite the SCO socket implementation to be more robust.

This code presents a socket interface for SCO connections. Like the
previous implementation, it does not support sending/receiving data
over the sockets; rather, it only provides a mechanism to establish
and tear down connections. It is assumed that all SCO data routing is
done out-of-band over PCM/I2S.

A SCO socket is represented internally by a file descriptor and SCO
handle. The file descriptor is one end of a socketpair (the other
end is sent to the Java process) and the SCO handle represents a
server (listening) or client (connecting) socket owned by the BTM
layer of the stack.

The most notable implementation detail is that, unlike typical
sockets, listening SCO sockets get "upgraded" when a connection is
established. In other words, a SCO handle for a listening socket
turns into a handle for a connected socket. To present a BSD-style
API to Java processes, we play a trick: when a listening socket gets
upgraded, we create a new listening SCO socket and reassociate the
SCO handle for the two sockets. The reassociation allows the Java
process to continue listening for new incoming SCO connections on
the same file descriptor.
tif_sock.c
tif_sock_sco.c
tif_sock_thread.c
e19791cae2c40f3dbbb6bc176d2e7a82c5330e64 20-Feb-2014 Ian McKellar <ianloic@google.com> Move the disconnect_immediately logic so that it's only in effect for data sockets
tif_sock_sco.c
601ffb4e62c3147242e1f58411eedfd16f4f95ab 13-Feb-2014 Ian McKellar <ianloic@google.com> Clear connected & disconnect_immediately flags when intializing SCO sockets
tif_sock_sco.c
3c8771aa24054ce4b578f38e4c314dcc3d633dbd 11-Feb-2014 Ian McKellar <ianloic@google.com> Fix a race condition where closing a SCO connection that was not yet fully open would silently fail.
tif_sock_sco.c
95da994055a580525a72338c506ca35ddba54f14 10-Jan-2014 Ian McKellar <ianloic@google.com> Clean up closed SCO listen sockets
tif_sock_sco.c
0f34c8953c91703ddf99f18fe4533f4cc8271426 09-Jan-2014 Ian McKellar <ianloic@google.com> Fix locking in btsock_sco_signaled
tif_sock_sco.c
a1d7cf239b03d9cb3ea36fdbc6bf848a34013ded 16-Dec-2013 Ian McKellar <ianloic@google.com> Refactor SCO code to allow closing
tif_sock_sco.c
e93ac125b887651e835fe59f4d1f9b3c5baa844c 08-Nov-2013 Ian McKellar <ianloic@google.com> SCO socket support in bluedroid
tif_sock.c
tif_sock_sco.c
fe7216ca12f91baae733e7c93063db73121af308 06-May-2014 Chris Manton <cmanton@google.com> Enforce GKI API buffer usage

Also add another API GKI_queue_length(BUFFER_Q *)
tif_media_task.c
284440f0c9f9fe15b162e37ef2bf6af439407447 22-Aug-2014 Sharvil Nanavati <sharvil@google.com> Refactor RFCOMM code; also fixes a random-disconnect / performance bug.

The majority of this change is just style cleanup and eliminating
unnecessary code. There was a bug in the code where, if an entire
data buffer gets successfully written to the app, the rest of the
queue is not drained and the connection may get dropped. This bug
came about due to an early function exit from a switch statement
instead of breaking out of the switch.
tif_sock_rfc.c
30a34f15f51bd74a23128a7b70f17f67a3f890c8 16-Aug-2014 Sharvil Nanavati <sharvil@google.com> Add a function to check if a string represents a bdaddr
tif_util.c
8c65ba9290470dc4ed26c22830200dc626fc1827 16-Aug-2014 Sharvil Nanavati <sharvil@google.com> Const-correctness for str2bd.
tif_util.c
8d546df22536ce78e19d15e5e70e0dc8109796c3 12-Aug-2014 Chris Manton <cmanton@google.com> btpan thread signal function workaround

btsock does not provide a reliable teardown
procedure. Stale file descriptors may continue
to actively invoke signal callbacks from the
btsock thread. Extra logic to handle gracefully.
tif_pan.c
61cdda4fb1a02eee21ac85dfaf6d218650c8bdf1 05-Aug-2014 Steve Gu <sgu@google.com> Replace magic number used instead of MAX_RFC_CHANNEL number.
tif_sock_rfc.c
a40848a8810b95ad279d4294c8e6cbba2b09347a 05-Dec-2014 Andre Eisenbach <eisenbach@google.com> DO NOT MERGE ANYWHERE Bluetooth native dumpsys logging support (2/4)

Includes support for BTSnoop logging in memory.

Bug: 18508263
Change-Id: Iade200283dca3545b7bbd0872c583731eb115d34
luetooth.c
tif_debug.c
tif_debug_btsnoop.c
tif_debug_conn.c
tif_gatt_client.c
tif_media_task.c
3210f865592835629eae0e172dc55bbe1a822041 03-Mar-2015 Erik Kline <ek@google.com> am 3e12cd50: Merge "reword channle to channel"

* commit '3e12cd500a06053da91f5cb69837838ea7455067':
reword channle to channel
4fe846855ff0f9bf9313fd7c35beeb7b3bda6115 25-Feb-2015 Erik Kline <ek@google.com> reword channle to channel

Change-Id: Ic45f99db717e1efcad4385cbbe1dd658e3a18bfb
tif_sock_rfc.c
1b8b1397dad3ba82ec2b7d10233922e13cf510cf 10-Feb-2015 Andre Eisenbach <eisenbach@google.com> am dfb3b2f2: Add flag indicating encrypted connections to btif_dm_get_connection_state()

* commit 'dfb3b2f2595dc16fe7f576a4b0c2f5e73db0327f':
Add flag indicating encrypted connections to btif_dm_get_connection_state()
dfb3b2f2595dc16fe7f576a4b0c2f5e73db0327f 06-Feb-2015 Andre Eisenbach <eisenbach@google.com> Add flag indicating encrypted connections to btif_dm_get_connection_state()

Add a check to btif_dm_get_connection_state() to see if the currently
active connection is encrypted.

Bug: 19186961
Change-Id: I27bcc6e296d272ffd17c0bbe97631ffa4df57ccd
tif_dm.c
b68105ca4a4fc37da18321472e2f823c6c0f4c40 04-Feb-2015 Elliott Hughes <enh@google.com> am ff50e75d: Merge "Fix pthread_t confusion."

* commit 'ff50e75d69b5cee253c213f91999e8f6f6129c58':
Fix pthread_t confusion.
40cc40843d88f79b151b7880f33e59a96f4f0182 04-Feb-2015 Elliott Hughes <enh@google.com> am 481b0546: Merge "Fix non-standard pthread mutex interactions."

* commit '481b0546db69274145ee129d19bb03cce4763c6f':
Fix non-standard pthread mutex interactions.
df3459935a4c12744a9a78812157890b60ccb77d 03-Feb-2015 Ian Coolidge <icoolidge@google.com> Fix pthread_t confusion.

Don't assign pthread_t to pid_t or UINT32.
Just use pthread_t throughout.

Change-Id: Icb8315c591b4131314c834beebd94f37651eaafb
tif_sock_thread.c
5381efce1f4fa20401df26b18b779e5b00cd5f1e 03-Feb-2015 Ian Coolidge <icoolidge@google.com> Fix non-standard pthread mutex interactions.

pthread_mutex_t is intended to be opaque.
pthread_attr_t is intended to be opaque.

Change-Id: I9b4f32b695783a4391851269977aa748dcc4f241
tif_config.c
tif_sock_rfc.c
tif_sock_thread.c
df61acbd523271cc9b01b81dbbf5c45799bee6b5 03-Feb-2015 Elliott Hughes <enh@google.com> am 1efdda75: Merge "btif_pan: Grab interface declarations from net/if.h only."

* commit '1efdda75d0e7cf4223ba8958a56c2aeafa5129c5':
btif_pan: Grab interface declarations from net/if.h only.
767f6a7bd1db9c94602cfa59460bc122dc375a7f 03-Feb-2015 Ian Coolidge <icoolidge@google.com> btif_pan: Grab interface declarations from net/if.h only.

This is the libc interface file.
Using linux/if.h produces definition collisions on glibc.
tif_pan.c
7c5823798cccb6731a164edff7127ebfce074558 28-Jan-2015 Andre Eisenbach <eisenbach@google.com> am 89363761: Change pairing_cb to assume temporary pairing by default

* commit '893637614568b8ac7dc996c2e9bdbde481fbdc08':
Change pairing_cb to assume temporary pairing by default
893637614568b8ac7dc996c2e9bdbde481fbdc08 26-Jan-2015 Andre Eisenbach <eisenbach@google.com> Change pairing_cb to assume temporary pairing by default

When pairing takes place, the pairing_cb.is_temp flag indicates whether
a pairing is temporary or permanent. Link keys are not stored for
temporary pairings. Since this is a "positive" flag, resetting the
pairing_cb control block (ex. memset to 0), it will assume persistent
pairing by default. Under certain circumstances, this can lead to a link
key being stored for temporarily secured connection.

This patch reverses the flag to be a "negative" flag. Renamed to
"persistent_bond", the default 0 meaning is now used to indicate a
temporary bond. If the lag is not properly set now, it will default to a
temporary bond and will not save the link key erronously.

Bug: 18345373
Change-Id: I6e821595877ff30d64dc6e33602ac049cab3dd1e
tif_dm.c
7fbc6954fac90dd7148ac73aa478fcc5e2d75be8 25-Jan-2015 Elliott Hughes <enh@google.com> am f976082e: Merge "Fix omitted libc includes."

* commit 'f976082eead2b7c19bf8c00d79e4723e6c4eb8e9':
Fix omitted libc includes.
c7503db23f91676b2df732becb9579d5ccdcc7a7 24-Jan-2015 Ian Coolidge <icoolidge@google.com> Fix omitted libc includes.

Change-Id: I72c08984aeef60e4833e600b4351759b9687a014
luetooth.c
tif_av.c
tif_dm.c
tif_gatt_multi_adv_util.c
tif_hf.c
tif_hf_client.c
tif_mce.c
tif_pan.c
tif_profile_queue.c
tif_rc.c
tif_sock_rfc.c
tif_sock_sdp.c
fb17c122b09171492d99b208c1fdd6b76d2c431c 16-Jan-2015 Andre Eisenbach <eisenbach@google.com> am 335bc32b: Merge "Relax max PCM frames per tick a bit" into lmp-mr1-dev

* commit '335bc32bc7dae893358bde20557927e6ed6ad58c':
Relax max PCM frames per tick a bit
26e80aad86fae4e468a330d64ee02291f3a1980e 07-Jan-2015 Andre Eisenbach <eisenbach@google.com> Relax max PCM frames per tick a bit

Also made the value overwrite-able in bt_target.h.

Bug: 18913091
Change-Id: I64bbe453b35fdce6f127b3c23c0552b14d4ac49b
tif_media_task.c
f68506e24bc8e9783b40202d01b4154f9f24940a 06-Jan-2015 Tobias Melin <tobias.melin@sonymobile.com> am 2cfcf51e: Added check if the device address is random

* commit '2cfcf51ea3447f2b5cf95dbe7515d230de1e7df7':
Added check if the device address is random
2cfcf51ea3447f2b5cf95dbe7515d230de1e7df7 17-Dec-2014 Tobias Melin <tobias.melin@sonymobile.com> Added check if the device address is random

A check if the device address is random is needed since in a
public device address the two most significatant bits can also be
equal to 01 (see Bluetooth specification Core_v4.1.pdf, page 2021
and page 2500).

Bug: 18784040
Change-Id: I4f967a426ebb825731461e202c0741ae0540ef6a
tif_gatt_client.c
11cf5ccd5cd6dd1568bf69e4b6cbc27c95f5026d 11-Dec-2014 Chih-Hung Hsieh <chh@google.com> resolved conflicts for merge of ed0bdd42 to lmp-mr1-dev-plus-aosp

Change-Id: Ife8b72d3688ed78a95ccb8d5e0b60f40e7fec9e9
ed0bdd422da488289ec829d2d59b74e7be3eaaec 11-Dec-2014 Chih-hung Hsieh <chh@google.com> Merge "Cleanups needed to make clang happy"
104e3f238f500cacdb8afaccdc672dfc34eae7ee 12-Nov-2014 Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org> Cleanups needed to make clang happy

This patch removes a slew of unused variables and some unused functions,
fixes some incomplete initializations of structs and an sprintf
parameter mismatching the format string.

Change-Id: I35f22fdccc8350f885cd357d3685b869224fa433
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
tif_config.c
tif_core.c
tif_dm.c
tif_gatt_client.c
tif_gatt_multi_adv_util.c
tif_gatt_util.c
tif_hf.c
tif_hf_client.c
tif_hh.c
tif_hl.c
tif_media_task.c
tif_rc.c
tif_sock_rfc.c
tif_sock_thread.c
tif_storage.c
2f51cdec0acc9c43c2986ed24b3019719bb4b2d7 04-Dec-2014 Matthew Xie <mattx@google.com> am d6984958: Merge "Revert "Correct the OBEX OPP Profile version""

* commit 'd6984958c38b202d47cdce002429006d5a8ede9e':
Revert "Correct the OBEX OPP Profile version"
6fadce76d56cebb4821856127cd89a2eada3d80a 04-Dec-2014 Wei Wang <weiwa@google.com> am e608a529: Merge "Remove unnecessary check of multiple advertise instance count." into lmp-mr1-dev

* commit 'e608a529718bb64accdf9f18cb196a9a3c45c90e':
Remove unnecessary check of multiple advertise instance count.
5faeaa8755679cef4d4aa529db813973b7f59380 04-Dec-2014 Matthew Xie <mattx@google.com> am 8a75ab5b: Merge "PAN TAP fd is not monitored in all cases" into lmp-mr1-dev

* commit '8a75ab5b918c4e65e1b8fe55ec193b047ddfcb06':
PAN TAP fd is not monitored in all cases
d6984958c38b202d47cdce002429006d5a8ede9e 04-Dec-2014 Matthew Xie <mattx@google.com> Merge "Revert "Correct the OBEX OPP Profile version""
e608a529718bb64accdf9f18cb196a9a3c45c90e 04-Dec-2014 Wei Wang <weiwa@google.com> Merge "Remove unnecessary check of multiple advertise instance count." into lmp-mr1-dev
8a75ab5b918c4e65e1b8fe55ec193b047ddfcb06 03-Dec-2014 Matthew Xie <mattx@google.com> Merge "PAN TAP fd is not monitored in all cases" into lmp-mr1-dev
d0f99244a8fef1c25444ee3fd1bc2cd417a1b33e 02-Dec-2014 Andre Eisenbach <eisenbach@google.com> am e79be3d6: Add server-side callback for change in MTU (2/4)

* commit 'e79be3d6ca41ed6349012c73a3374aca3714a053':
Add server-side callback for change in MTU (2/4)
e79be3d6ca41ed6349012c73a3374aca3714a053 26-Nov-2014 Andre Eisenbach <eisenbach@google.com> Add server-side callback for change in MTU (2/4)

When a client requests to update the LE transport MTU, the server
currently does not get notified and can therefor not properly size
notifications appropriate to the current MTU.

Bug: 18388114
Change-Id: Ice355f8919d4f69876574df1d90ce7d31f42bc4f
tif_gatt_server.c
ffaf9c5358decc3102252e76cc00da5c910bb065 26-Nov-2014 Wei Wang <weiwa@google.com> Remove unnecessary check of multiple advertise instance count.

Bug:18539121
Change-Id: I841e4323ed4995bd9f8117681a759f52995d071f
tif_gatt_multi_adv_util.c
285f7c6527244c749aafdc1edec39787e12bd871 26-Nov-2014 Zhenye Zhu <zhenye@broadcom.com> PAN TAP fd is not monitored in all cases

Bug: 18271987
Change-Id: I348f3851a955b5277e7cdf0102583eaaef2ef0f3
tif_pan.c
b5a1e48e9476df8c25f0c3bc88fa9bce447695e4 25-Nov-2014 Matthew Xie <mattx@google.com> am c113e4db: Merge "Enforce Authentication for incoming HID connection" into lmp-mr1-dev

* commit 'c113e4db5218901b7ef4b09b1f08727da70971e1':
Enforce Authentication for incoming HID connection
c113e4db5218901b7ef4b09b1f08727da70971e1 24-Nov-2014 Matthew Xie <mattx@google.com> Merge "Enforce Authentication for incoming HID connection" into lmp-mr1-dev
c28dac0bbd8d7d090bf96d9e18ad28cfcba39806 20-Nov-2014 Satya Calloji <satyac@broadcom.com> Clean up SetADV and ScanResp data memory leak.
automerge: 3770c47

* commit '3770c47387d3dfc6d2e2d32f4409a82119e726e3':
Clean up SetADV and ScanResp data memory leak.
3770c47387d3dfc6d2e2d32f4409a82119e726e3 20-Oct-2014 Satya Calloji <satyac@broadcom.com> Clean up SetADV and ScanResp data memory leak.

Bug:18045480
Change-Id: Ic433f4aa26bd08e84c53c447be9d5278e16ebd55
tif_gatt_client.c
tif_gatt_multi_adv_util.c
2334344102581597532dbb6cff5c921091ce7754 18-Nov-2014 Matthew Xie <mattx@google.com> am 86f97eda: Use the device type from saved properties instead of assuming default

* commit '86f97eda524568f2d264186844450db5e56dac36':
Use the device type from saved properties instead of assuming default
bda59f88101f39f82bb81a0d21e8ca1f73d36e4f 18-Nov-2014 Andre Eisenbach <eisenbach@google.com> am c5916e97: Remove overflow rate limiting when reading A2DP frames

* commit 'c5916e97384f07ec5a2e061e6af24f70107c74a2':
Remove overflow rate limiting when reading A2DP frames
d79fb192585822a76b833403dfc61468d225d0b3 12-Nov-2014 Priti Aghera <paghera@broadcom.com> Enforce Authentication for incoming HID connection

Enforce Authentication in addition to encryption for all incoming
HID connections.

Bug 17887668

Change-Id: Ib0d6cd6d8e793823c541a1b4468dcce89f297181
(cherry picked from commit 6d6502909c1dd1766db1fea2cb638866e137a7bf)
tif_hh.c
86f97eda524568f2d264186844450db5e56dac36 10-Nov-2014 Matthew Xie <mattx@google.com> Use the device type from saved properties instead of assuming default

DUMO device can do both BLE and BREDR operations. It was wrong
to assign BLE or BREDR type to it.
Bug: 18275230

Change-Id: I8d6c17e5157ba29a1af459629de9e2d6f6dc5e99
tif_config.c
tif_dm.c
tif_gatt_client.c
tif_gatt_server.c
tif_gatt_util.c
tif_sock_util.c
tif_util.c
c5916e97384f07ec5a2e061e6af24f70107c74a2 08-Nov-2014 Andre Eisenbach <eisenbach@google.com> Remove overflow rate limiting when reading A2DP frames

A2DP now supports adjusting the number of A2DP frames sent per timer
tick to adjust for timer drift and missed media task ticks. When the
signal to the headset/speakers becomes interrupted, the number of
packets to be read can queue up and rate limiting will not allow for the
queue to be cleared.

The overflow mechanism introduced in commit 4aebca4 will cause the media
task to stop sending packets completely, which can underflow the jutter
buffer on the remote device and lead to audio drop-outs.

This patch removes the overflow mechanism and also adds code do discard
audio frames that could not be sent to the remote device (weak signal
etc) to allow the device to stay in sync and not build up audio delays.

Also added additional debug logging and changed the UIPC flush mechanism
to address an issue where reading byte by byte causes an endless flush
loop if remote UIPC producer writes data faster than the flush loop
consumes it.

Bug: 18326405
Change-Id: I9a424984806bb2a464877399804b3355b2c439c3
tif_media_task.c
068d6f9e9deacdb2be4a41d441b00165cb18f4fe 07-Nov-2014 Satya Calloji <satyac@broadcom.com> am 16451571: am b407515f: Fix "no instances found for adv" when stop BLE scanning.

* commit '16451571a5461ab3be535d25cbb62ab03b6b6157':
Fix "no instances found for adv" when stop BLE scanning.
16451571a5461ab3be535d25cbb62ab03b6b6157 06-Nov-2014 Satya Calloji <satyac@broadcom.com> am b407515f: Fix "no instances found for adv" when stop BLE scanning.

* commit 'b407515ffa145b1a2cab01467da03c92aeb0e8eb':
Fix "no instances found for adv" when stop BLE scanning.
b407515ffa145b1a2cab01467da03c92aeb0e8eb 10-Oct-2014 Satya Calloji <satyac@broadcom.com> Fix "no instances found for adv" when stop BLE scanning.

Bug:17703806
Change-Id: I103d3637ad38d33b4370850a300b0d72bdaeb562
tif_gatt_client.c
tif_gatt_multi_adv_util.c
d27b30890beab706898064b925073d78b3f82048 27-Oct-2014 Andre Eisenbach <eisenbach@google.com> LE: Make local privacy configurable
automerge: 3e0dc73

* commit '3e0dc7324e7b0127f9d15609bab395100a22098d':
LE: Make local privacy configurable
c60e5d965b217e5bc1701a64edae34f09314d7d1 25-Oct-2014 yusuke kawabe <yusuke.yk@gmail.com> Revert "Correct the OBEX OPP Profile version"

This reverts commit e26f7c2a59ca3cd4e7d084846a3d0b9d97bae27d.
SDP record of OPP v1.1 should be used 0x0100.

Change-Id: Ida36f00688e7e6f032b25e796a55433ea1e12706
tif_sock_sdp.c
3e0dc7324e7b0127f9d15609bab395100a22098d 24-Oct-2014 Andre Eisenbach <eisenbach@google.com> LE: Make local privacy configurable

Bug: 17753401
Change-Id: I288ea8b6194d91d18485d0f3f1bbf997f97a26dd
tif_dm.c
e455d394478e58330aabcbc803e62f1aade45670 22-Oct-2014 Andre Eisenbach <eisenbach@google.com> am f8938276: am 5e808468: LE: Do not remove bond on encryption failure

* commit 'f89382760380cc3a2dd5d56366344eed2c00e561':
LE: Do not remove bond on encryption failure
1c020326c12a6e2dac849c6bde9a366c26157a8e 22-Oct-2014 Chaojing Sun <cjsun@broadcom.com> am b94c47a5: am 433fe016: Cache HOGP HID report map

* commit 'b94c47a5407b29bf3bcb8d3c5f94773d9697ce50':
Cache HOGP HID report map
758c559e0ffcf19dfd5e63ce775a751746935e11 22-Oct-2014 Prem Kumar <premk@google.com> am f4d88b93: am 25249f76: Merge "Retry pairing if the device did not respond (page timeout)" into lmp-dev

* commit 'f4d88b93db3796b3c0915d8068ea14e60913f377':
Retry pairing if the device did not respond (page timeout)
52b851f106f4b298395a8d38aa54316a7c9dd244 22-Oct-2014 Andre Eisenbach <eisenbach@google.com> am 6b5262a6: am 01d102b3: A2DP: Lowering maximum PCM frame limit to avoid audio breaks

* commit '6b5262a6943444848a377aa882f8be91449211d1':
A2DP: Lowering maximum PCM frame limit to avoid audio breaks
f89382760380cc3a2dd5d56366344eed2c00e561 22-Oct-2014 Andre Eisenbach <eisenbach@google.com> am 5e808468: LE: Do not remove bond on encryption failure

* commit '5e808468e0667a6a2a8a1e6de80efbc4f42fa0f0':
LE: Do not remove bond on encryption failure
5e808468e0667a6a2a8a1e6de80efbc4f42fa0f0 21-Oct-2014 Andre Eisenbach <eisenbach@google.com> LE: Do not remove bond on encryption failure

If the encryption fails during the re-connection process with a
previously paired LE device, the pairing is removed. Thus, a single
connection failure could lead to the device be unpaired.

This patch prevents unpairing when encryption fails.

Additionally, the IRK is restored from NV ram to fix reconnection to
dual-mode devices.

Bug: 18072300
Change-Id: I077a16d0715fdaa07b95b1c664c18bd839754896
tif_dm.c
tif_gatt_util.c
tif_storage.c
b94c47a5407b29bf3bcb8d3c5f94773d9697ce50 21-Oct-2014 Chaojing Sun <cjsun@broadcom.com> am 433fe016: Cache HOGP HID report map

* commit '433fe016392c7ae003033530f1b3994f2ddad313':
Cache HOGP HID report map
f4d88b93db3796b3c0915d8068ea14e60913f377 21-Oct-2014 Prem Kumar <premk@google.com> am 25249f76: Merge "Retry pairing if the device did not respond (page timeout)" into lmp-dev

* commit '25249f7663d75244b5a2abcac08e301d584fcd8d':
Retry pairing if the device did not respond (page timeout)
6b5262a6943444848a377aa882f8be91449211d1 21-Oct-2014 Andre Eisenbach <eisenbach@google.com> am 01d102b3: A2DP: Lowering maximum PCM frame limit to avoid audio breaks

* commit '01d102b3b187ab0d24050c1e12f96e6ee1ce50be':
A2DP: Lowering maximum PCM frame limit to avoid audio breaks
433fe016392c7ae003033530f1b3994f2ddad313 17-Oct-2014 Chaojing Sun <cjsun@broadcom.com> Cache HOGP HID report map

HID reports from a bonded device can be missed when Bluetooth is
restarted HOGP report discovery is still active. Caching the
report information and loading it back when the stack resets
will ensure incoming HID reports can be processed immediately.

Bug: 17999991
Change-Id: I4608935f8749537d6b05625b894445a21f844ee0
tif_hh.c
6fa7d957a3ffe77120f9a3852a97c32182f80ed9 18-Oct-2014 Prem Kumar <premk@google.com> Merge "Retry pairing if the device did not respond (page timeout)" into lmp-dev
automerge: 25249f7

* commit '25249f7663d75244b5a2abcac08e301d584fcd8d':
Retry pairing if the device did not respond (page timeout)
86ec3ba8f1eed2d449651ea836b4a26ea3e2c9ed 18-Oct-2014 Andre Eisenbach <eisenbach@google.com> A2DP: Lowering maximum PCM frame limit to avoid audio breaks
automerge: 01d102b

* commit '01d102b3b187ab0d24050c1e12f96e6ee1ce50be':
A2DP: Lowering maximum PCM frame limit to avoid audio breaks
25249f7663d75244b5a2abcac08e301d584fcd8d 18-Oct-2014 Prem Kumar <premk@google.com> Merge "Retry pairing if the device did not respond (page timeout)" into lmp-dev
01d102b3b187ab0d24050c1e12f96e6ee1ce50be 17-Oct-2014 Andre Eisenbach <eisenbach@google.com> A2DP: Lowering maximum PCM frame limit to avoid audio breaks

Some car kits (notably Renesas car kits used in Nissan/Infiniti models)
will throttle incoming A2DP frames if too many frames are sent at once.
This patch lowers the maximum number of frames sent per tick to not
overwhelm the remote device.

Bug: 17880920
Change-Id: I7bfbba625405c96159d1c94eebd8dc498f100daa
tif_media_task.c
31a640079c9a7b9a2bf014f06f6c371afb66cc63 14-Oct-2014 Andre Eisenbach <eisenbach@google.com> Retry pairing if the device did not respond (page timeout)

Implements a "blacklist" identifying troublesome remote devices which
may require multiple pairing attempts to succeed.

Change-Id: I11b6b7da7230e37fbd5ec4c07cd38b30dc12b40e
tif_dm.c
1424bc84ad68ecd427d09c82f930112010b08bd1 14-Oct-2014 Wei Wang <weiwa@google.com> am 494b3bf7: Merge "Add support of advertising through standard instance.(4/4)" into lmp-sprout-dev

* commit '494b3bf7403723560709949f8c2d337d6d63310a':
Add support of advertising through standard instance.(4/4)
494b3bf7403723560709949f8c2d337d6d63310a 14-Oct-2014 Wei Wang <weiwa@google.com> Merge "Add support of advertising through standard instance.(4/4)" into lmp-sprout-dev
8ed9bcb8636a1d1c010d87e2c41fa3647f2ccd5f 11-Oct-2014 Andre Eisenbach <eisenbach@google.com> am 12ca0ec5: Merge "Added missing A2DP priority on java alarm service" into lmp-dev

* commit '12ca0ec54796e31405a880de6675015c88857158':
Added missing A2DP priority on java alarm service
4ad4c4b997bd96ee09827b39a49fbbb3322690d1 10-Oct-2014 Andre Eisenbach <eisenbach@google.com> am 12ca0ec5: Merge "Added missing A2DP priority on java alarm service" into lmp-dev

* commit '12ca0ec54796e31405a880de6675015c88857158':
Added missing A2DP priority on java alarm service
f061e74b81863771b174d1717a6165034dbad8e5 09-Oct-2014 Mattias Agren <magren@broadcom.com> Added missing A2DP priority on java alarm service

Running GKI timer engine via JAVA alarm service was causing severe
timer preemption at times which affects A2DP media task timer. This in
turn was stressing the compensation logic towards UIPC resulting in
very bursty reads of up to 40 UIPC frames at a time. This led to
instabilities on the UIPC pipe and trickled upwards in audio framework.
Inclusion of java alarm thread in A2DP high priority thread list results
in a much smoother data flow for entire A2DP data path and improved
audio quality.

Bug: 17520043
Change-Id: I7cea6ec64aa5b973b5fff767389a8827e681619e
tif_media_task.c
cafed88eb2caeaece08da1110625f4567a16ddd1 27-Sep-2014 Satya Calloji <satyac@broadcom.com> Add support of advertising through standard instance.(4/4)

Handled the case of standard ADV when Multi ADV is not
supported by controller

Bug:17641092

Change-Id: I129a7faaf027985c63197e7298dbd2507905d29f
tif_gatt_multi_adv_util.c
952ce61cb5ea48093a9093e8e2e98759f9abc283 06-Oct-2014 Satya Calloji <satyac@broadcom.com> am d5aa2475: LE: Peer device\'s latest RPA is not being applied

* commit 'd5aa24750c2202ce944560c2c27ead0214e8350d':
LE: Peer device's latest RPA is not being applied
87b9ca2209c0ee8a9b436e20dfd147115783c05e 06-Oct-2014 Satya Calloji <satyac@broadcom.com> am d5aa2475: LE: Peer device\'s latest RPA is not being applied

* commit 'd5aa24750c2202ce944560c2c27ead0214e8350d':
LE: Peer device's latest RPA is not being applied
d5aa24750c2202ce944560c2c27ead0214e8350d 24-Sep-2014 Satya Calloji <satyac@broadcom.com> LE: Peer device's latest RPA is not being applied

The latest discovered address is not used when reconnecting to devices
using resolvable private addresses, if RPA resolution offloadin is not
supported in the controller.
This patch also address the exception case where BT off is memseting
all control value while the IRK list is still being cleaned up.

Bug: 17187661
Change-Id: Ifeb5b8297e7eadb0e34ec1afbd41f46bdd836cf3
Author: Chaojing Sun <cjsun@broadcom.com>
tif_core.c
f9b5cb757eaf064eb592628d8abd1a060e59a9af 17-Sep-2014 Matthew Xie <mattx@google.com> am 303d4ac5: Merge "For pairing over le transport, set default device type and address type" into lmp-dev

* commit '303d4ac5ff7758ab2cdde4040cb8db6cf37552f5':
For pairing over le transport, set default device type and address type
4358907bb4fbbfb76cca22076b5e7c440cc90c9d 17-Sep-2014 Matthew Xie <mattx@google.com> am 303d4ac5: Merge "For pairing over le transport, set default device type and address type" into lmp-dev

* commit '303d4ac5ff7758ab2cdde4040cb8db6cf37552f5':
For pairing over le transport, set default device type and address type
303d4ac5ff7758ab2cdde4040cb8db6cf37552f5 17-Sep-2014 Matthew Xie <mattx@google.com> Merge "For pairing over le transport, set default device type and address type" into lmp-dev
64c5479fc050c537ef6d39625de2032c77fc5676 16-Sep-2014 Matthew Xie <mattx@google.com> For pairing over le transport, set default device type and address type

When the LE pairing is initiated over NFC, skipping device scan, there is
no device type or address type info. We set the default as le and public.
bug 17497942
Change-Id: I3dcbb9029ead6ea0f7c48e62f46c8a055f1bc293
tif_dm.c
9be59d6512633ada50301e0942a6bf6f9a4102ab 14-Sep-2014 Matthew Xie <mattx@google.com> am e3b1d0da: Merge "Correct the OBEX OPP Profile version"

* commit 'e3b1d0da533fbb01da67f7ccfa976a9e3d54ed94':
Correct the OBEX OPP Profile version
976990f872bb0873fedbb74649d0bf704bb70d05 13-Sep-2014 Wei Wang <weiwa@google.com> Merge "Fix issues with manufacturer ID prefix scan filter." into lmp-dev
1a5f8105337cd41efad09d4ec8812311e8adaaec 13-Sep-2014 Wei Wang <weiwa@google.com> Merge "Fix ADV data exceeding max adv packet length" into lmp-dev
a015a8348b9e09caf5261689f4c288a4d2ff6acd 11-Sep-2014 Andre Eisenbach <eisenbach@google.com> LE: Use random address when initiating background connections

When re-connecting to HID devices, the first reconnection immediately
after a reboot incorrectly uses the static, public Bluetooth address of
the phone/tablet as the own address.

This patch fixes the Bluetooth initialization sequence to make sure
privacy is enabled before any Bluetooth services are started.

Bug: 16952502
Change-Id: I43e595ddc7e347fab972b059382b512fb03e9459
tif_dm.c
7ddf2d88501a2dd17045fb2f126ec99dcac9b5d9 06-Sep-2014 Satya Calloji <satyac@broadcom.com> Fix ADV data exceeding max adv packet length

Fixed the 128-bit UUID handling during setting up
of adv data/scan response

Bug:16799331
Change-Id: I81e4ab0a80a5c1b7abf012dccc29eead54229b21
tif_gatt_multi_adv_util.c
f5140468dc83dafcd75ffe607e1a56c514b9a8a4 09-Sep-2014 Andre Eisenbach <eisenbach@google.com> Merge "LE: Disable background connections if RPA offloading is not supported" into lmp-dev
a1e649b2566040d1f9e620753f18ca1fc088c64f 18-Aug-2014 Andre Eisenbach <eisenbach@google.com> LE: Disable background connections if RPA offloading is not supported

If the local device does not support RPA offloading, background
connections to a resolvable random address will not work. Added callback
to indicate to the application writer that the requested operation is
not supported.

Bug: 16831527
Change-Id: I083d66b16704e997f52a40ea4daced3056b50ad5
tif_gatt_client.c
6cbb113e7863888f62c49b4b7a89f12a04fe07f4 03-Sep-2014 Satya Calloji <satyac@broadcom.com> Fix issues with manufacturer ID prefix scan filter.

Handled the case of no manufacturer data in filter configuration

Bug:17324059
Change-Id: I87c2c44644f808bd88f4d8681ff53e2d92815658
tif_gatt_client.c
5e02098d563a7a8ff62ab71413d9878b88b7d484 04-Sep-2014 Andre Eisenbach <eisenbach@google.com> Merge "Limit the time PAN can occupy the BTU stack thread" into lmp-dev
ae13ec986e188d66eaad3c69bb916ea18c142fef 03-Sep-2014 Andre Eisenbach <eisenbach@google.com> Avoid race condition in SBC encoder initialization

In the A2DP media task, btif_a2dp_encoder_update() relies on the fact
that btif_a2dp_encoder_init() is called beforehand. Otherwise division
by zero errors will occur.

Since _init() called after the audio stream is opened, and _update() is
called in resonse the the audio stream being opened, a race condition
could ensue where _update() was called before open.

This patch changes the A2DP stream start sequence to ensure the SBC
encoder is initialized before the updated parameters are calculated.

Bug: 17339248
Change-Id: I6ed36a7fff0e4aa672a8866727030681eb4b3dfc
tif_av.c
tif_media_task.c
95ca3c43eae763465bbd7bddc927279f17b16106 26-Aug-2014 Zhenye Zhu <zhenye@broadcom.com> Limit the time PAN can occupy the BTU stack thread

Also make sure tap read/write are non-blocking and PAN does not use the
complete shared buffer pool to avoid GKI buffer overruns.

Bug: 16374840
Change-Id: I6f96d1c8d2804d253d33fe37ff87275e03e55ddd
tif_pan.c
ec2777e6a3e8516deff362e5cc732811d0afb1c8 03-Sep-2014 Matthew Xie <mattx@google.com> Clean up fd when failed to add monitor thread

Bug: 10773872
Change-Id: I7f5b5f976ee7fa522e02b9ee4369b8f152b15cfb
tif_sock_rfc.c
e9ff1332e0c74c01be43cbff6daff48a271bcf03 29-Aug-2014 Andre Eisenbach <eisenbach@google.com> Merge "Add LE device to inquiry DB before pairing" into lmp-dev
3baff79dcd63bc33b17f475939d0e282526d9995 29-Aug-2014 lungtsai_lin <lungtsai_lin@htc.com> Add LE device to inquiry DB before pairing

There is no remote device type info wgeb OOB pairing LE
devices. Add device type according to transport.

Bug: 17156993
Change-Id: I29182ca13f801f8a7f2c3a95969d6ae23312dd7e
tif_dm.c
adb7bb50469db992969295792a7ba3b73f9e24b3 13-Aug-2014 Satya Calloji <satyac@broadcom.com> GKI_exception on running longer batch scans

Fixed GKI memory leak in btif_gatt_client.c file
besides few needed logic improvements which will
help in preventing leaks on exception conditions

Bug:16829603
Change-Id: Id39267fbedeb7435cdc2c3a9eda25d4b3cd82c2f
tif_gatt_client.c
eebf155a282baedbeb2579cde4e7fafc58d991ab 25-Aug-2014 Matthew Xie <mattx@google.com> Merge "MAP: SDP corruption" into lmp-dev
54e24af853a77a057995ee4f234bae4d490b32e5 18-Aug-2014 Casper Bonde <c.bonde@samsung.com> MAP: SDP corruption

Terminate strings before parsing to values.

Might be related to:
bug: 16877287

Change-Id: I0c46861229a90f37e266bd06bcba9ac78e3fc155
Signed-off-by: Casper Bonde <c.bonde@samsung.com>
tif_sock_sdp.c
e26f7c2a59ca3cd4e7d084846a3d0b9d97bae27d 19-Aug-2014 Robert Chiras <robert.chiras@intel.com> Correct the OBEX OPP Profile version

Currently, the OPP Profile is registered using version 0x0100 (1.0), but
the initial version of this profile was 1.1. Since, there is no version
1.0, correct the version or this profile to 0x0101 (1.1).

Change-Id: I0befafb3656be5e33a8c9a0853207e53b46851a4
Signed-off-by: Robert Chiras <robert.chiras@intel.com>
tif_sock_sdp.c
962f1d1f9dc22d939bea4e9fb34a67028ff185fd 17-Aug-2014 Andre Eisenbach <eisenbach@google.com> LE: Remove general/limited discoverability bits for non-connectable adv

According to the Bluetooth spec, section 9.1.1.2, "A device in the
broadcast mode shall not set the ‘LE General Discoverable Mode’
flag or the ‘LE Limited Discoverable Mode’ flag in the Flags AD Type.

This patch masks out the specific bits for non-connectable
advertisements.

Bug: 16924631
Change-Id: Ia2c0011fb31de3e4166a8bd2c2732e50aad3a610
tif_gatt_multi_adv_util.c
3e278d3f114907775626a3826c69e52a2278fe07 13-Aug-2014 Andre Eisenbach <eisenbach@google.com> Merge "LE: Fix limited advertising not stopping after timeout" into lmp-dev
cf32e8d4e0cabac8432a3c6c6d8ece27d6067770 13-Aug-2014 Andre Eisenbach <eisenbach@google.com> LE: Fix limited advertising not stopping after timeout

When starting to advertise with a given timeout, the alarm did not fire
and thus not stop the advertising. This patch switchs from the new alarm
system to use BTU timers.

Also fixes a bug in the oneshot timer handling where adding a new timer
with a short timeout value would not actually restart the timer to pull
in the deadline.

Bug: 16988160
Change-Id: Ia556562675636be440ddca7682ac7d092bc0b48b
tif_gatt_client.c
tif_gatt_multi_adv_util.c
d437d1192a7812987b2f9caf197839086a105f13 13-Aug-2014 Andre Eisenbach <eisenbach@google.com> Merge "A2DP: Protect against division-by-zero error in bitpool calculation" into lmp-dev
a391bf1d4f4250e27b6f157a1a8d2493c36934dc 09-Aug-2014 Andre Eisenbach <eisenbach@google.com> A2DP: Protect against division-by-zero error in bitpool calculation

If the encoder parameters have not been configured correctly before the
SBC encoder is initialized, a division-by-zero can occur resulting in a
SIGFPE.

Bug: 16902125
Change-Id: Ie4c6715b6b374a2d62fcfa0a1a99d40c689d0e2a
tif_media_task.c
169cd7a221a79474d36e5c1697e862c1d640c064 08-Aug-2014 Andre Eisenbach <eisenbach@google.com> Additional rebase fixes

Change-Id: I0bb6c9f96987a7e8b8d91473681f5e208d3b844f
tif_gatt_multi_adv_util.c
1097ff0b2c493e1541ca989681267dfa6a61ed6b 08-Aug-2014 Andre Eisenbach <eisenbach@google.com> Fix Bluedroid rebase error

Change-Id: I80a2f3767acaee6095389bb9579aad4241d7c42f
tif_gatt_multi_adv_util.c
9dd5a9c11f2022fa9709f0c34f04560c21105152 08-Aug-2014 Andre Eisenbach <eisenbach@google.com> LE: Add limited advertising duration capability (2/3)

Change-Id: Id2ebc353f1bcd94978c5c8dc55a235c92ebc7658
tif_gatt_client.c
tif_gatt_multi_adv_util.c
16fe0822ccd3eb6f66d3afd9965d25a0a0cb4c30 07-Aug-2014 Prerepa Viswanadham <dham@google.com> Use run time parameters to control LE features

Use values read from controller to enable and control LE features such as
multi advertising, RPA offload, maximum irk size etc

bug 15393216

Change-Id: I193e2b9a0dc61b86f667e986803571440e390160
tif_core.c
tif_gatt_client.c
tif_gatt_multi_adv_util.c
c331807e3c3a0e15180a11325e1635ae5268aa39 27-Mar-2014 Matthew Xie <mattx@google.com> BT MAP: added support for email sharing over BT

- added more dynamic SDP record name setting for MAP in order to support
multiple mas instances with different name strings.

Change-Id: I7a78da3ba9707a08d1f6a6245c27fc3f1b86d244
tif_sock_sdp.c
62a54c5b374c1eb9d3664da2717f82fdeea8bb7e 05-Aug-2014 Andre Eisenbach <eisenbach@google.com> Merge "Add transport parameter to createBond() function (2/4)" into lmp-dev
b0daa5d79d4e2950701fb9a5f76a306e1da42de0 05-Aug-2014 Andre Eisenbach <eisenbach@google.com> Add transport parameter to createBond() function (2/4)

Change-Id: I8176b932da705f8d0a230abd56bc5faa00005eb6
luetooth.c
tif_dm.c
f877e4c6990a05c6a609980efa4fc575aa7eb51e 04-Aug-2014 Wei Wang <weiwa@google.com> Merge "LE batchscan consolidated reports" into lmp-dev
f1dba910daa5f0ce9ca89f840bb7e6269f07af1d 16-Jul-2014 Satya Calloji <satyac@broadcom.com> LE batchscan consolidated reports

Provide consolidated batchscan reports

Change-Id: Ie3da240c38b014fe29d4394438f3858fd4e731fa
tif_gatt_client.c
372a9f7d53682a853f4c5f5fc7d2c36c044f2513 05-Aug-2014 Matthew Xie <mattx@google.com> Merge "Blacklist Apple HID devices to skip SDP" into lmp-dev
c0edf9f2038d23a3ba0cd424e187cb0d8fa201e8 26-Jun-2014 Priti Aghera <paghera@broadcom.com> Blacklist Apple HID devices to skip SDP

Remote initiated HID connection fails as Apple devices goes out of resource.
During incoming connection SDP is performed after authentication is successful.
Apple device is out of resources and thus sends No resources available error
for SDP request. In order to avoid this situation a apple HID devices are blacklisted
to skip SDP after authentication in case of incoming connections.

bug 15566403

Change-Id: Ic7fdfd2543c90e81341b4d5b7bef9c1d1c11b928
tif_dm.c
694988f6aadc9ff9611c595a9863661c85da2e0f 01-Aug-2014 Zhenye Zhu <zhenye@broadcom.com> Fixed wrong return condition when all RFCOMM data was sent succesfully

Bug: 16566991
Change-Id: I4e0d2487b71e2d8ad8e571e88d2623db2852bb1e
tif_sock_rfc.c
3489ca9d44bbf0d3f00b1f5cd9675694774d48a8 31-Jul-2014 Satya Calloji <satyac@broadcom.com> ADV data override issue

Setting scan response overrides advertiseData

Bug 16577710

Change-Id: I5ca28568495c8e487648a5f36d945e4443cba639
tif_gatt_multi_adv_util.c
d773c2cfd3675aaec431a42b79b26b24e0555ed9 30-Jul-2014 Satya Calloji <satyac@broadcom.com> Incorrect data type in local LE features
bt_local_le_features_t of wrong size

b/16653133

Change-Id: I81da7f8c6b9151b8def8d4e3c655cf746d0e3db9
tif_core.c
tif_dm.c
4a7ad9be81cc2b515502f2c1fb1b7ec7e3104146 30-Jul-2014 Satya Calloji <satyac@broadcom.com> Tx power is 0 in ADV packet

b/15412969 Tx power is always 0 in advertising packet

Change-Id: I7eb1f16b5fb1ab4ed669ba6a72f9603885cebc99
tif_gatt_multi_adv_util.c
efaddcb2cec21bfcdcadfa86720d3ca720a4253d 29-Jul-2014 Satya Calloji <satyac@broadcom.com> Bug 16498557 Inconsistent energy reporting

Fix for inconsistent energy reporting

Change-Id: Iddd77354624a631ca8db52f12086d3afa5751d36
tif_dm.c
e85eb5a7c3ea7eaca09cbb33920435d809b4dd3d 03-Oct-2013 Nitin Shivpure <nshivpur@codeaurora.org> Bluetooth: Cleaning up pan_conn DB, if connection is not successful. - do not merge

A case where DUT is paired with remoteDeviceA & remoteDeviceB.
remoteDeviceA is not pagable(turned off or some other reason).
DUT(PANU) try to connect remoteDeviceA(NAP). But connection is
unsuccessful, Because remoteDeviceA is not pagable, In this scenario
btpan_conn Database is not cleaning up at btif layer. Later
remoteDeviceB(PANU) connect to DUT(NAP) & connection is succesful,
When remoteDeviceB disconnect existing connection. As database
still has remoteDeviceA BD address at Btif layer. remoteDeviceA
BD address is passed instead of remoteDeviceB BD address from Btif
to UI. So remoteDeviceB still shows connected on UI. Cleaning up
pan_conn database for particular pan connection at BTIF layer,
whichever connection is not successful will solve this issue.

Change-Id: I31dfe3ef46295e74bbfb57563e4fd4fc7155f006
tif_pan.c
76f645ea6f5cd22e464dcbdb1e73ecb50c5ea87c 29-Aug-2013 Hemant Gupta <hemantg@codeaurora.org> Bluetooth: Update security for HID Devices to Encrypt on BT On. - do not merge

This patch updates HID Devices security mask to BTA_SEC_ENCRYPT from
BTA_SEC_NONE. Without this change it was observed that on BT Reset,
authentication and encryption were not initiated by DUT for incoming
HID Control L2CAP Connection Request from remote HID Keyboard device.

Change-Id: I484fbae1294fde386bd7959467214f9968e381e9
tif_hh.c
6e2d9db5148176d88d7f48c3b2ad5b27c57ca14d 09-Jul-2014 Satya Calloji <satyac@broadcom.com> Settings app does not show BLE devices

Settings does not show all BLE devices when scan filter is set

Change-Id: I669ef3b87a9a21dfce26c1e22b5d984a5ea6f75c
tif_dm.c
tif_gatt_client.c
81b03192d4284acc7c9903f5b183927797dceca4 24-Jul-2014 Prerepa Viswanadham <dham@google.com> Fix build for non BLE supported targets(nakasi and manta)

Change-Id: I0de46e1dfce3a51367bc0e2640e91cdefc8a21c6
tif_dm.c
e5ba8841cd39e17c05aeb4ab65b5b761d41577da 04-Jul-2014 Satya Calloji <satyac@broadcom.com> LE energy info feature

Stack and BT-IF changes for LE energy feature

Change-Id: I671e63aaead210c6352b45a5e20ad5e4bbbb77b7
luetooth.c
tif_core.c
tif_dm.c
tif_util.c
25067c0afc4d3ed95181b91801d3d638d9aa3f8f 22-Jul-2014 Andre Eisenbach <eisenbach@google.com> Fix integer overflow in GKI timer calculation

Fix an integer overflow in the GKI timer elapsed time calculation that
would cause Bluetooth Stereo Audio (A2DP) playback to stop suddenly
after a period of INT32_MAX microseconds (about 35 minutes) of
continuous uptime of the phone/tablet.

Bug: 16412377
Change-Id: I28cd3155a23444e41b26b3f3b8424cc2a3c5bf91
tif_media_task.c
d356ffbf6f6095489c73266e6e591b1167cfa5e6 19-Jul-2014 Elliott Hughes <enh@google.com> Fix implicit declaration of function 'prctl' in bluedroid.

Change-Id: I288dd19bd478a3ff716d4f7f4179cc2b7574473a
tif_hl.c
5e17049abe2158303a9423439f324d1a24d68b87 19-Jul-2014 Elliott Hughes <enh@google.com> Fix implicit declaration of function 'prctl' in bluedroid.

(cherry picked from commit d356ffbf6f6095489c73266e6e591b1167cfa5e6)

Change-Id: Icc160c758c126e48fd6490cd14211a8685e4cdba
tif_hl.c
1ef4ba488d259f6523b6e650fb80820d3a363302 19-Jul-2014 Matthew Xie <mattx@google.com> Merge "Bluetooth: fix the HOGP device(iBUFFALO BSMBB09DS) pair and reconnect problem." into lmp-dev
52a2cd609897c04bb6440e14ef2ec8871143d028 17-Jul-2014 Andre Eisenbach <eisenbach@google.com> LE: Add connection parameter update request API (2/4)

Change-Id: I131bfa7fb0a8cc970e1ac3e26e9d86ed2bee80a7
tif_gatt_client.c
2772dac59971dd9c135cfac73a1ba77a912324f4 17-Jul-2014 Thomas.TT_Lin <Thomas.TT_Lin@htc.com> Bluetooth: fix the HOGP device(iBUFFALO BSMBB09DS) pair and reconnect problem.

in bta_hh_le.c (fix reconnect issue)
Since new LE security flags are import, (BTM_SEC_LE_AUTHENTICATED, BTM_SEC_LE_ENCRYPTED,
BTM_SEC_LE_NAME_KNOWN, BTM_SEC_LE_LINK_KEY_KNOWN, BTM_SEC_LE_LINK_KEY_AUTHED),
we have to use new BTM_GetSecurityFlagsByTransport() function with LE transport to get right sec_flag,
or will cause cannot correctly add to white list and cause reconnect fail.

in btif_dm.c (fix HOGP mouse pair issue)
the HOGP mouse will become abnormal if we update connection parameter too many times.
Therefore the is_hid case is not suitable for HOGP mouse,
it will trigger call to L2CA_EnableUpdateBleConnParams() several times due to service discovery and bonded state.
L2CA_EnableUpdateBleConnParams() update connection cause mouse abnormal.
The change will make the flow: complete bonding procedure first, then do service discovery, connect to mouse.

in gap_ble.c (fix HOGP device pair issue)
After pairing status is bonded, host start to create ATT layer to get some information from HOGP device.
If host send "disconnect" command during period. Device will stop to feedback anything.
Suggest to delete it.

in smp_act.c (fix HOGP device pair issue)
update connection parameter too many times may cause mouse abnormal,
so remove this code since this will be called again after service discovery.
Suggest to delete it.

Change-Id: I4b722343c2b08d33530bc6b928bc9ffe89fd09e9
Signed-off-by: Thomas.TT_Lin <Thomas.TT_Lin@htc.com>
tif_dm.c
288f5cf88113e9fd107e914e41e01b9618195872 12-Jul-2014 Andre Eisenbach <eisenbach@google.com> Merge "Calculate A2DP frames to send based on elapsed time"
f13db8a534adf5281ee915c4b73b3141957ed17b 12-Jul-2014 Andre Eisenbach <eisenbach@google.com> Calculate A2DP frames to send based on elapsed time

This patch is aimed at improving A2DP audio quality by sending the
correct number of frames based on the actual time elapes between "ticks"
in order to account for timer drift.

Change-Id: If5b7cde90f5eb10b926ad247f51cff0eb60bbff7
tif_media_task.c
a3c936eae6fd686658dd84d546326908904029c8 11-Jul-2014 Priti Aghera <paghera@broadcom.com> am 156c52bb: Send correct status for SMP AUTH failure

* commit '156c52bb003a14147db99d8a151edc08f591bd34':
Send correct status for SMP AUTH failure
8cbb1f60fa29b736e8ea42a361fdb59195b84cb9 12-Jul-2014 Mike J. Chen <mjchen@google.com> Merge "Fix deadlock and non-working socket msg throttling"
335aa36bca8532874c23c1afe5bfc2aff7fc01a5 01-Jul-2014 Mike J. Chen <mjchen@google.com> Fix deadlock and non-working socket msg throttling

Two major bugs in btif_config.c. One is that due to improper
locking order, a deadlock could occur (symptom is generally
out of GKI buffers because BTIF thread stops processing it's
mailbox because it is blocked sending a msg to the socket
thread, which in turn is blocked because BTIF is holding
the lock it needs to do the config save that BTIF requested
in the first place).

The other is also lock related. The mechanism to throttle
socket messages based on whether there was one already
in flight wasn't working because there wasn't locking
when that variable was being used. The compiler would be
free to cache it in a register on SMP machines, so it would
never look like there as a value in flight. This would
cause a bunch of messages to be queued up, and then the
way the handling worked in cfg_cmd_callback(), every
cmd would cause a 3 second sleep, even if there was nothing
to do. Modified the loop to check if there was nothing
to do before sleeping.

I was running into both bugs when repeatedly pairing and
unpairing a BLE device. The deadlock would hit first, causing
out of GKI buffers. Once I fixed the deadlock, I would still
run out of GKI buffers because the socket thread wasn't working
fast enough to clear the backlog of socket messages it had
received.

Also optimized some string termination code which was using
a memset of the full buffer before and then copying over
every entry except the last. Now we do the copy and just
set the last buffer entry to null.

Change-Id: Ic06ef0b8e15d8f1fe669fb88439851ffbad560de
Signed-off-by: Mike J. Chen <mjchen@google.com>
tif_config.c
156c52bb003a14147db99d8a151edc08f591bd34 09-Jul-2014 Priti Aghera <paghera@broadcom.com> Send correct status for SMP AUTH failure

Send correct corresponding status for SMP AUTH failure to JAVA layer.
This will enable BluetoothEventManager to display correct error message
for bond state changed callback.
Bug 15677623

Change-Id: I6a8742926bac862f960890417b5d68c23b33e010
tif_dm.c
0317a401142e927be82a0259f54cfa10a686e0fe 09-Jul-2014 Andre Eisenbach <eisenbach@google.com> Merge "Prevent A2DP bit pool calculation endless loops."
4e3593a9a1c596904a844286fbe704e969e7230e 08-Jul-2014 Andre Eisenbach <eisenbach@google.com> Prevent A2DP bit pool calculation endless loops.

This prevents log spam and endless loops in the A2DP bit pool
calculation. Protecting against the endless loop with prevent battery
draining issues and phone unresponsiveness.

This patch addresses the symptom. A separate patch will be submitted
once root cause is determined to address the problem.

Change-Id: I045b724c1c1638551b9333249f39eee109fa9ba1
tif_media_task.c
6718c6d9fcfe373a679a529aca003d32062f81dc 02-Jul-2014 lungtsai_lin <lungtsai_lin@htc.com> Bluetooth: Rename BTA_AVK_INCLUDED flag to BTA_AV_SINK_INCLUDED (bt_target.h)

Now OEM could enable/disable A2DP SINK role

Change-Id: I62cf17b0397a86c5f886a2c1ca724ca77a7f9bd4
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
tif_media_task.c
85b4ee5df4208fd06e836f40d7a19a84545f4e93 05-Jul-2014 Matthew Xie <mattx@google.com> Merge "DO NOT MERGE: Send to local UUID for AV connection" into klp-wireless-dev
7bc6e981a647ea7c246d2d37b425ee187218eeb3 02-Jul-2014 Ravi Nagarajan <nravi@broadcom.com> DO NOT MERGE: Send to local UUID for AV connection

BTA expects local UUID to be passed into BTA_AvOpen. The value of source/sink
was reversed in the btif layer thus causing connection failure
bug 15837817

Change-Id: If159ac0491afcb75659336c98caba3cefe71ee7b
tif_av.c
a92c04f2dbd7f88853d6380d66c1f4d200674f97 01-Jul-2014 Matthew Xie <mattx@google.com> DO NOT MERGE Fix compilation issue

This patch fixes broken compilation on KWD branch

Change-Id: I9a1da11e33e938910dc556ed3e015bd3456e21ef
tif_hl.c
e3eecc1515a278520665bbf87a91837a5bebec46 02-Jul-2014 Sharvil Nanavati <sharvil@google.com> Fix build: change macro call from _DEBUG0 to _DEBUG.

Change-Id: Iacbf4c33a7b690e2065471b85a6a4d82dd4a7fca
tif_hl.c
6ac369a8381a61fef594cd64c4ee89c7919cf00d 02-Jul-2014 Matthew Xie <mattx@google.com> am 23ae7c52: Merge "Added code to reuse the signal fds and avoid fd close" into klp-wireless-dev

* commit '23ae7c526b529cf1c76c4a4cc8a341545493404d':
Added code to reuse the signal fds and avoid fd close
5ded33915f458e2de4a3a459b7b893ac9b57dd32 02-Jul-2014 git-zhenye.broadcom.com <zhenye@broadcom.com> am 359895ef: Fixed deadlock issue for concurrent multiple rfcomm connections.

* commit '359895efb36a7e4f65fbcc9a28221b6ede44aadd':
Fixed deadlock issue for concurrent multiple rfcomm connections.
6397cfb5b415d2622f81a27c646a441b108ee13f 02-Jul-2014 Mike Lockwood <lockwood@google.com> Fix problem with A2DP initialization due to merge error

btif_av_init() would fail when called a second time due to
erroneous nulling of btif_av_cb.sm_handle

Bug: 16014877
Change-Id: I7e6b213759e93372ac8ecaadc2b81452572f3f7d
tif_av.c
23ae7c526b529cf1c76c4a4cc8a341545493404d 02-Jul-2014 Matthew Xie <mattx@google.com> Merge "Added code to reuse the signal fds and avoid fd close" into klp-wireless-dev
bf0ce82611b5133d61a0e544ec5bf53b567edfe7 20-Jun-2014 git-zhenye.broadcom.com <zhenye@broadcom.com> Added code to reuse the signal fds and avoid fd close

Bug 15436535

Change-Id: Ica5b1915dd94699eb19c57b6904154493b0cc08c
tif_hl.c
359895efb36a7e4f65fbcc9a28221b6ede44aadd 13-Jun-2014 git-zhenye.broadcom.com <zhenye@broadcom.com> Fixed deadlock issue for concurrent multiple rfcomm connections.

Bug 15469934

Change-Id: I77a3dc97c92f0ccd5764220e8e0bf5c0689d7b12
tif_sock_rfc.c
2dc999935d4c69ae31ea93d9014165965dd373d6 17-Apr-2014 Hemant Gupta <hemantg@codeaurora.org> Bluetooth: Support MAP Client role on Bluedroid.

Implementation changes from BTA and BTIF layer to support
MCE role on Bluedroid stack.

Change-Id: I8547b0f28338e83edabae969121872ca23fdcb36
luetooth.c
tif_core.c
tif_dm.c
tif_mce.c
7ae3f9eebc4e930d51e6b61f845ffd0f9a8cb9f8 15-Jun-2014 Satya Calloji <satyac@broadcom.com> LE Onfound and Onlost feature

BTIF and stack layer changes for onfound/onlost feature

DO NOT MERGE

Change-Id: Id52cdd5855ca8c0ff276b42613b51c4cd3882bfc
tif_gatt_client.c
5e177043e3dfcd70676761a40425179d16c4a7ce 05-Jun-2014 Satya Calloji <satyac@broadcom.com> LE ADV Filter changes

BTIF and stack layer changes for ADV filter feature

DO NOT MERGE

Change-Id: I865e57c41802751e172248547b8510598261ec94
tif_core.c
tif_gatt_client.c
b9b1f4e7a5cc96c57873a991f4ea3c3c08934c26 11-May-2014 Satya Calloji <satyac@broadcom.com> LE batch scan feature

BTIF and stack changes for batch scan feature

DO NOT MERGE

Change-Id: I4dd2d551435e9f1f0e43906bd695294e97ed4bba
tif_gatt_client.c
ff7f41e67b7c3fb3f35a082d7123196f78e685ff 01-Jul-2014 Matthew Xie <mattx@google.com> am 66432dcf: Add WBS support on Bluedroid (2/6)

* commit '66432dcffe211e317d35978283a04a96d5620bdf':
Add WBS support on Bluedroid (2/6)
66432dcffe211e317d35978283a04a96d5620bdf 27-Apr-2014 Matthew Xie <mattx@google.com> Add WBS support on Bluedroid (2/6)

Bug 13764086

Change-Id: I12bf302f7dd19efb497ad49d4d1d638a7a926049
tif_hf.c
tif_util.c
1acb61ce065053f91a0f8d43e8328c9eeec4b5ed 15-Jun-2014 Satya Calloji <satyac@broadcom.com> LE Onfound and Onlost feature

BTIF and stack layer changes for onfound/onlost feature

Change-Id: Id52cdd5855ca8c0ff276b42613b51c4cd3882bfc
tif_gatt_client.c
1a9247a1229aa65b3d1dce16426177bc5828e54d 05-Jun-2014 Satya Calloji <satyac@broadcom.com> LE ADV Filter changes

BTIF and stack layer changes for ADV filter feature

Change-Id: I865e57c41802751e172248547b8510598261ec94
tif_core.c
tif_gatt_client.c
c4e2596a112a0dd63ac681b1226548c0f95e828c 11-May-2014 Satya Calloji <satyac@broadcom.com> LE batch scan feature

BTIF and stack changes for batch scan feature

Change-Id: I4dd2d551435e9f1f0e43906bd695294e97ed4bba
tif_gatt_client.c
63084199d86b31721e7265a1b72e218b019ece5b 29-Jun-2014 Hemant Gupta <hemantg@codeaurora.org> am e146869f: GAP: Remove device info from storage on Pairing Cancel

* commit 'e146869fec903400e601d2ac7b0a59bd05934f0e':
GAP: Remove device info from storage on Pairing Cancel
84b98f6d0c9dcd5ba148f58daedd4ec450f4c91c 29-Jun-2014 Hemant Gupta <hemantg@codeaurora.org> am b4801441: GAP:Add authentication failed error code in auth_compl_evt.

* commit 'b4801441a5b7a093bc78f2143a8ed28605c51dc6':
GAP:Add authentication failed error code in auth_compl_evt.
40ea618b79ee366fbe5fe267effa492e2c4bd5b6 29-Jun-2014 Hemant Gupta <hemantg@codeaurora.org> am aef7a671: [2/2] Bluetooth: Security: Handle authentication rejected error status

* commit 'aef7a6716e72e9304af36469500ee53c97350c21':
[2/2] Bluetooth: Security: Handle authentication rejected error status
5eb938bacd3a214d55b34ef99448e36c1ecc8e67 29-Jun-2014 Hemant Gupta <hemantg@codeaurora.org> am 59a88ec2: Bluetooth: Handle missing key event

* commit '59a88ec207ead601c7ba5e767fd1373c7f2df70b':
Bluetooth: Handle missing key event
4dbb90f07682b1d348ddf22189fce8e9e96b66ad 29-Jun-2014 Hemant Gupta <hemantg@codeaurora.org> am 831423ea: Bluetooth: Fix to avoid NULL pointer dereferences

* commit '831423ea1879244e746f39d7696ad4a66681f306':
Bluetooth: Fix to avoid NULL pointer dereferences
e146869fec903400e601d2ac7b0a59bd05934f0e 14-Nov-2013 Hemant Gupta <hemantg@codeaurora.org> GAP: Remove device info from storage on Pairing Cancel

Remove paired device information for SSP devices from the BT-IF
layer storage on pairing cancel.

Change-Id: I4660e3659866bd66339350b5cdb92bf3ad3cc850
tif_dm.c
b4801441a5b7a093bc78f2143a8ed28605c51dc6 07-Jan-2014 Hemant Gupta <hemantg@codeaurora.org> GAP:Add authentication failed error code in auth_compl_evt.

There is an unhandle failed HCI error code when pairing with
symbian OS phone nokia n95 which will cause no prompt when
auth failed.

Change-Id: I3a37c7732d1bf71c090bb968380d8c5f0af2ff79
tif_dm.c
aef7a6716e72e9304af36469500ee53c97350c21 31-Jul-2013 Hemant Gupta <hemantg@codeaurora.org> [2/2] Bluetooth: Security: Handle authentication rejected error status

Handle error codes in authentication complete event with failures
like reject pairing , unspecified error.

Change-Id: I392b7531a8625efbf91bf80f7f617a6954229892
tif_dm.c
59a88ec207ead601c7ba5e767fd1373c7f2df70b 19-Mar-2014 Hemant Gupta <hemantg@codeaurora.org> Bluetooth: Handle missing key event

This change handles HCI_ERR_KEY_MISSING event
coming to the stack when user doesn't enter any
key and timeout happens.

Change-Id: If530e8acce3f105e4f1e2841bf350ee5330f389e
tif_dm.c
831423ea1879244e746f39d7696ad4a66681f306 07-Jan-2014 Hemant Gupta <hemantg@codeaurora.org> Bluetooth: Fix to avoid NULL pointer dereferences

This fix for avoiding NULL pointer dereferences:
- Added check for state checking in btm_remove_acl function
to avoid sending disconnect command if already in Disconnecting
state.
- Added NULL check for 'pin_code' in btif_dm_pin_reply function
- Null check before accessing in BD interface layer configuration
node variables.
- Add NULL check before accessing p_bd_addr variable to avoid null
pointer exception while referring to invalid memory.

Change-Id: Ib7ed45b6a1692785a45224d739a564f767e5b10f
tif_config.c
tif_dm.c
afa6e1abbedaad8fe854b0f43999b8aeb801af91 28-Jun-2014 Matthew Xie <mattx@google.com> resolved conflicts for merge of e8c3d75b to master

Change-Id: I78ef69c4d54a36243620ae14296d3507e3339567
d5ebf6b695a5b40563b5fddca97c0591e39557f1 28-Jun-2014 Matthew Xie <mattx@google.com> handle link key check in non_ble case

Change-Id: Ibbdf3c4fbff9e53f8e2a85db9d6de62cd2925c60
tif_storage.c
1b5fda660a24f4c2884f94691f7537f40f67685c 28-Jun-2014 Matthew Xie <mattx@google.com> am f219040f: Merge "Reload Hid info only for bonded device" into klp-wireless-dev

* commit 'f219040fb458fe4bb19d55d39c28d4535865a908':
Reload Hid info only for bonded device
8e50f047de2999e89b6a19ec9bf513017fcde3f9 28-Jun-2014 Matthew Xie <mattx@google.com> resolved conflicts for merge of 6449e497 to master

Change-Id: I01ef7ea6c4ce49c9d775b355fb5b082b25ffbc39
13594e6e4fbfb8a8458c3f25f5336d3996283c24 28-Jun-2014 Matthew Xie <mattx@google.com> am bf611504: Merge "Save remote device name immediately" into klp-wireless-dev

* commit 'bf611504d460adb10cc8c31f731504750104a1f3':
Save remote device name immediately
249f600c1518c015f5cb45720cb022a203ba744e 18-Jun-2014 Andre Eisenbach <eisenbach@google.com> LE: Add is_connected() function (2/3)

Change-Id: I73c4ea7f13982bf9c208996f9c749d2dfbe698be
luetooth.c
tif_dm.c
493a98a8de29a35808db28470736819af5fd22d2 28-Mar-2014 Andre Eisenbach <eisenbach@google.com> LE: Add notification sent and congestion callbacks (2/4)

This change introduces two new callbacks for applications to better
handle LE notification flow control and transport congestion. The
notification callback is invoked when the remote platform confirms an
indication or when a local notification has been passed to the
controller. No new notifications should be sent until a callback is
received.

Congestion callbacks are triggered when a GATT operation cannot be sent
to the local Bluetooth controller. Repeatedly calling
writeCharacteristic() for example will eventually trigger a congestion
callback. Applications cannot send additional data until a further
callback is received, indicating that the congestion has cleared up.

Also fixes a memory leak issue that can trigger GKI exception for
certain GATT operations.

Change-Id: I7112bdfc1fedec2e390bd0ea52655d238683917f
tif_gatt_client.c
tif_gatt_server.c
tif_gatt_test.c
9536abefc8761390566030f570f3ff034639a81d 27-Jun-2014 Andre Eisenbach <eisenbach@google.com> Merge "LE: Add notification sent and congestion callbacks (2/4)"
93912473fde12ab5ab4b1be8774bbf43d47c7ddc 26-Jun-2014 Mike Lockwood <lockwood@google.com> Merge some missing pieces of AVRCP controller support from klp-wireless-dev

Change-Id: I1dc99496a6ed0e7d13cab9d7c95972d32ad88769
tif_rc.c
aa859a9af3767b5ee62ec882f83a922234a39cda 26-Jun-2014 Mike J. Chen <mjchen@google.com> Merge "Change btif_gatt_client to use BTIF_TRACE_XXX macros instead of raw ALOGX"
bcbf9cd0727f6903f9cf6c165453539fc55b6072 26-Jun-2014 Mike J. Chen <mjchen@google.com> Change btif_gatt_client to use BTIF_TRACE_XXX macros instead of raw ALOGX

This allows the trace flags in bt_trace.h to control whether these
logs are enabled or not, to be consistent with rest of bluedroid.

Change-Id: Ia4abeac42da181fd748a668d3ec5a9624ae8c19d
Signed-off-by: Mike J. Chen <mjchen@google.com>
tif_gatt_client.c
17b04bd498405f2bb109a85562ebbdcb6bb06e95 28-Mar-2014 Andre Eisenbach <andre@broadcom.com> LE: Add notification sent and congestion callbacks (2/4)

This change introduces two new callbacks for applications to better
handle LE notification flow control and transport congestion. The
notification callback is invoked when the remote platform confirms an
indication or when a local notification has been passed to the
controller. No new notifications should be sent until a callback is
received.

Congestion callbacks are triggered when a GATT operation cannot be sent
to the local Bluetooth controller. Repeatedly calling
writeCharacteristic() for example will eventually trigger a congestion
callback. Applications cannot send additional data until a further
callback is received, indicating that the congestion has cleared up.

Also fixes a memory leak issue that can trigger GKI exception for
certain GATT operations.

Change-Id: Ib470c15ca1f577573a632e9afe4cb9e86680fd8c
tif_gatt_client.c
tif_gatt_server.c
tif_gatt_test.c
3c36809a32db64eccd21df7415477810c98d9e3f 22-Jun-2014 Matthew Xie <mattx@google.com> Merge "switch a2dp sync and source to the correct uuids"
d6151e9811a35ac965bfb96ad77c427d9a4f1325 22-Jun-2014 Matthew Xie <mattx@google.com> switch a2dp sync and source to the correct uuids

bug 15687722

Change-Id: I09e5fdc7bf7c1bb0ff3c87dc43b228e3761cfa36
tif_av.c
40a1994ae3043eb31d2d7993294ca9faaeafffb9 21-Jun-2014 Andre Eisenbach <eisenbach@google.com> Merge "LE: Add is_connected() function (2/3)"
5c0b052090a57b3926669c23349b0f0db68853f8 18-Jun-2014 Andre Eisenbach <eisenbach@google.com> LE: Add is_connected() function (2/3)

Change-Id: I73c4ea7f13982bf9c208996f9c749d2dfbe698be
luetooth.c
tif_dm.c
93f6651217c7cf1eda0c46de1ecd718b397edbae 19-Jun-2014 Sharvil Nanavati <sharvil@google.com> Fix build, replace logging macro.

Change-Id: Ib1189b887d57253940fa38e8af24ea03462c403e
tif_storage.c
e8c3d75b75493911ebf0f99c83676359657178f7 04-May-2014 Sharvil Nanavati <sharvil@google.com> Logging cleanup: BTIF and APPL.

Change-Id: I5b1214642bbb4b9aecc0fd2c899a6ec2c9793286
tif_av.c
tif_core.c
tif_dm.c
tif_gatt_client.c
tif_gatt_multi_adv_util.c
tif_gatt_server.c
tif_gatt_util.c
tif_hf.c
tif_hf_client.c
tif_hh.c
tif_hl.c
tif_media_task.c
tif_pan.c
tif_rc.c
tif_sm.c
tif_sock.c
tif_sock_rfc.c
tif_sock_sdp.c
tif_sock_thread.c
tif_sock_util.c
tif_storage.c
01364c729dd8f94be9959300188c94324960e0df 08-Apr-2014 Loic Poulain <loic.poulain@intel.com> Bluedroid: Avoid multicast address for tun-tap interface

Linux Kernel disallows to set an ethernet multicast
address as ethernet device address.

The IEEE has specified that the most significant bit
of the most significant byte of a mac address is used
for multicast. If its a 1, that means multicast, 0
means unicast.

Bluedroid uses the BD address to set the tun-tap intf
mac address. This BD address can be randomly auto
generated, possibly with the multicast bit.

To avoid any address issue, this patch masks this bit
before setting the ethernet mac address.

Change-Id: Ifff4ec7237ae6cbef3b8d4c23096c5df65e1431c
Signed-off-by: Loic Poulain <loic.poulain@intel.com>
Reviewed-on: https://android.intel.com/184768
Reviewed-by: Zhang, Jianxun <jianxun.zhang@intel.com>
Tested-by: Zhang, Jianxun <jianxun.zhang@intel.com>
tif_pan.c
f281b43fbf6832b80651e0dbf300294ba9808f20 15-May-2014 Priti Aghera <paghera@broadcom.com> Reload Hid info only for bonded device

Check if the device is bonded before loadind HID device information
after BT reset. If the HID info exists in NVRAM for unbonded device,
the device will not be able to repair.
bug 14837902

Change-Id: I5e6d5e8c5344ca8ae18f102e40867745d3f460ab
tif_storage.c
533cc76a012444993eb5e566238f71fc9f24ba0d 19-Jun-2014 Matthew Xie <mattx@google.com> am 27232899: am 283aa16d: Merge "Bluedroid: Avoid multicast address for tun-tap interface"

* commit '2723289960c3eca333aa25369bde59cf8d36dcf4':
Bluedroid: Avoid multicast address for tun-tap interface
2723289960c3eca333aa25369bde59cf8d36dcf4 19-Jun-2014 Matthew Xie <mattx@google.com> am 283aa16d: Merge "Bluedroid: Avoid multicast address for tun-tap interface"

* commit '283aa16d5f16bc10b5491661b5729c5f25635731':
Bluedroid: Avoid multicast address for tun-tap interface
c4262059511336139735f410dd8d3ff303576057 18-Jun-2014 Andre Eisenbach <eisenbach@google.com> Merge "LE: Add ability to pass address type to GATT test command"
4ad470e33021be4246ae539e1bcb7a346dbb4405 03-Jun-2014 Mike Lockwood <lockwood@google.com> Move AVRCP controller support to separate HAL interface

Change-Id: Ib7dcd7b90f85cf3b25148e2929d8921c6db37aa2
luetooth.c
tif_av.c
tif_rc.c
3e8a242fcbeebea2857fa964ca48624d8433333e 23-May-2014 Mike Lockwood <lockwood@google.com> More work on A2DP Sink:

Output audio data through A2DP audio HAL rather than playing directly
to native AudioTrack API.

Add separate HAL interface for A2DP sink

Change-Id: I6c6cb6088c350e104b4a7354f328b29c7178e295
luetooth.c
luetoothTrack.cpp
tif_av.c
tif_core.c
tif_media_task.c
ce24765fe7620c34e8d88ed4f826c8a6917582b2 20-Mar-2014 Hemant Gupta <hemantg@codeaurora.org> SBC Decoder for A2DP SINK

Change-Id: Ic8d1dd81d1788324ec140fe0d1379dfff33deb54
tif_media_task.c
f7dd9f5779680da37dc89e5df2b26d436487818c 24-Oct-2013 Hemant Gupta <hemantg@codeaurora.org> Add A2DP Sink Support

Change-Id: I9affefdd2d00597545e49c593ef3bddb110d4c9c
luetoothTrack.cpp
tif_av.c
tif_hf.c
tif_hf_client.c
tif_media_task.c
tif_profile_queue.c
41d4a266ceca77bb09ab1bf5c04c30d15f3ded3a 19-Aug-2013 Hemant Gupta <hemantg@codeaurora.org> Bluetooth: Add support for HFP Client role.

Implementation changes in BTA and BTIF layer to support
HFP Client role.

Change-Id: I9f939c18e8f989a50f298d0b313c5a0959c030a7
luetooth.c
tif_dm.c
tif_hf_client.c
tif_storage.c
tif_util.c
1628d79747b33b5b655ef813ee133fbc322a5991 04-Jun-2014 Sharvil Nanavati <sharvil@google.com> Parse auto_pair_devlist.conf file with the generic config parser.

Change-Id: Idfd1aca2417d74725a8f9ac67b1ca946a33bf14d
tif_storage.c
10aecea0649e523ad9e94b5d0256e72729ec5875 29-May-2014 Sharvil Nanavati <sharvil@google.com> Implement GKI timers based on wake alarms and wake locks.

Before this change, bluedroid was unable to acquire wake locks
because the Bluetooth process didn't have permissions to write to
/sys/power/wake_*. We are now making wake locks accessible to
bluedroid through a HAL callout back into Java code.

The previous design did not use wake alarms. Bluedroid would attempt
to hold a wake lock until all pending timers expired, which is awful
if a timer is scheduled seconds or minutes from now. There is a
15min timer in bluedroid now so holding a wake lock for the entire
duration of pending alarms is unacceptable (power cost). The new
implementation uses a hybrid approach: if the next deadline is < 3s
away, we take a wake lock. If it is further than 3s away, we set a
wake alarm and release the wake lock.

As a result of this change, we have also eliminated a thread whose
sole purpose was to wake up every 10ms and update timers.

Change-Id: I46cd4edfcad2f5dce23c4003a14a617e7bf00541
luetooth.c
2a00176ae263607dd2de9408fd804d4c4028b511 11-Jun-2014 Prerepa Viswanadham <dham@google.com> Fix build for aosp_manta

Change-Id: Ic1e2363e7fb7d23dcaef8e989cae37606f2af664
tif_core.c
8d41691e6b16ba945711e8c3846df1ec70fdb724 31-May-2014 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Support for reading LE specific controller features

Support for reading LE specific controller features via get adapter properties
API

Change-Id: Ia0b813be45fb826ce27d1d7a31ca41650d7286dd
tif_core.c
tif_dm.c
da271ee4a0afcf5516208dc8df18a4da41a47124 31-May-2014 Sharvil Nanavati <sharvil@google.com> Whitelist IPv6 packets so they can be sent over PAN.

Change-Id: I68e96bc34af1dfded2761c9bc780c089076d15e0
tif_pan.c
1a3006f317b1b493dde1b80c4debbcf1bf5f6727 04-May-2014 Sharvil Nanavati <sharvil@google.com> Eliminate dead code (helped by compiler warnings).

I've removed all functions that the compiler decided were unused.

Change-Id: I0cbddf874ebd1586abe29b80e8d6390680679542
tif_config.c
tif_dm.c
tif_hh.c
tif_hl.c
tif_media_task.c
tif_sock_rfc.c
tif_storage.c
847ea13e09f3fc1d2a46a8b75109ef89243ace31 26-Apr-2014 Sharvil Nanavati <sharvil@google.com> Update RFCOMM socket code to use list data structure.

Change-Id: I70402d8bfaa36b36d3d4b8f3cec98371691e86c9
tif_sock_rfc.c
fe10dd40a0b5b553467fff293a6addc56e4eae90 26-Apr-2014 Sharvil Nanavati <sharvil@google.com> Update btif_profile_queue to use the list data structure.

The profile queue maintains a list of pending connect operations
for each profile. If a connect is followed by a disconnect before
the queued connect is dispatched, the disconnect will have no
effect and the connect will proceed.

This code clearly needs to be re-thought; it may be a good idea to
abandon the connect queue entirely in the long-run.

Change-Id: Ic0e85654abcf7a47f65953edb301eb9524394950
tif_profile_queue.c
e7c4f99f1ca3da0ac46aa7425a37b383177c699f 05-Sep-2013 Hemant Gupta <hemantg@codeaurora.org> Bluetooth: On Suspend ignore media task timer event

On Recieving Suspend confirmation from remote device,
Media task timer reload and tx_timer is made false,
hence media task will not be stopped at that instant.
Media task timer expires causing buffer to be allocated.
Changes done to ensure buffer is allocated only if tx_timer
is true.

Change-Id: I971a82cccc64ba033475ad532b096862968de942
tif_media_task.c
b804e2114b4e9c2d2481d62538f4d450d7b67128 11-Jun-2014 Andre Eisenbach <eisenbach@google.com> LE: Add ability to pass address type to GATT test command

Currently the GATT test command to connect a remote device assumes a
public Bluetooth device address. This patch adds the ability to pass in
the address type via the test command interface.

Change-Id: Ia50792738796b97d1d02d6f33cb0586c82dcd477
tif_gatt_test.c
80fcd9447bc862b321f5bd5c507c2f5839e01c24 11-Jun-2014 Matthew Xie <mattx@google.com> am 8b8050ad: am 197a801b: Merge "Bluedroid: Fix UUID unsigned/signed comparison"

* commit '8b8050ad5f2f4fd64766c99378fa0866d89230c6':
Bluedroid: Fix UUID unsigned/signed comparison
0c4ec0dae97523cadc9207e98c4a1edff7e2e7cf 11-Jun-2014 Prerepa Viswanadham <dham@google.com> Fix build for aosp_manta

Change-Id: Ic1e2363e7fb7d23dcaef8e989cae37606f2af664
tif_core.c
8b8050ad5f2f4fd64766c99378fa0866d89230c6 11-Jun-2014 Matthew Xie <mattx@google.com> am 197a801b: Merge "Bluedroid: Fix UUID unsigned/signed comparison"

* commit '197a801bb5f12675d025bf1b7d2cac40924abe77':
Bluedroid: Fix UUID unsigned/signed comparison
3a1ca50d0def4078a0db82bcdeecfe408ca4af64 03-Jun-2014 Mike Lockwood <lockwood@google.com> Move AVRCP controller support to separate HAL interface

Change-Id: Ib7dcd7b90f85cf3b25148e2929d8921c6db37aa2
luetooth.c
tif_av.c
tif_rc.c
309243751678f395e6f7323e45433e5476dc17ef 23-May-2014 Mike Lockwood <lockwood@google.com> More work on A2DP Sink:

Output audio data through A2DP audio HAL rather than playing directly
to native AudioTrack API.

Add separate HAL interface for A2DP sink

Change-Id: I6c6cb6088c350e104b4a7354f328b29c7178e295
luetooth.c
luetoothTrack.cpp
tif_av.c
tif_core.c
tif_media_task.c
8e08ad12eae66877f9725ca2d66fc69fe6762340 20-Mar-2014 Hemant Gupta <hemantg@codeaurora.org> SBC Decoder for A2DP SINK

Change-Id: Ic8d1dd81d1788324ec140fe0d1379dfff33deb54
tif_media_task.c
cc35559160745c60b42ae182002a59337d844d09 24-Oct-2013 Hemant Gupta <hemantg@codeaurora.org> Add A2DP Sink Support

Change-Id: I9affefdd2d00597545e49c593ef3bddb110d4c9c
luetoothTrack.cpp
tif_av.c
tif_hf.c
tif_hf_client.c
tif_media_task.c
tif_profile_queue.c
6449e497dfe4d500810c3e7b4d7d056027c33a0e 06-Jun-2014 Sharvil Nanavati <sharvil@google.com> Eliminate more dead code in GKI.

Change-Id: I4c0000445535e5300b83a18f5f6ca45f1ef797da
tif_media_task.c
197a801bb5f12675d025bf1b7d2cac40924abe77 11-Jun-2014 Matthew Xie <mattx@google.com> Merge "Bluedroid: Fix UUID unsigned/signed comparison"
479a9a3750e243b40663ddbd1ac44d4fc1c3ec4e 04-Jun-2014 Sharvil Nanavati <sharvil@google.com> Parse auto_pair_devlist.conf file with the generic config parser.

Change-Id: Idfd1aca2417d74725a8f9ac67b1ca946a33bf14d
tif_storage.c
9bce2266bae83dfeb57319076dee569324a6d0a8 29-May-2014 Sharvil Nanavati <sharvil@google.com> Implement GKI timers based on wake alarms and wake locks.

Before this change, bluedroid was unable to acquire wake locks
because the Bluetooth process didn't have permissions to write to
/sys/power/wake_*. We are now making wake locks accessible to
bluedroid through a HAL callout back into Java code.

The previous design did not use wake alarms. Bluedroid would attempt
to hold a wake lock until all pending timers expired, which is awful
if a timer is scheduled seconds or minutes from now. There is a
15min timer in bluedroid now so holding a wake lock for the entire
duration of pending alarms is unacceptable (power cost). The new
implementation uses a hybrid approach: if the next deadline is < 3s
away, we take a wake lock. If it is further than 3s away, we set a
wake alarm and release the wake lock.

As a result of this change, we have also eliminated a thread whose
sole purpose was to wake up every 10ms and update timers.

Change-Id: I46cd4edfcad2f5dce23c4003a14a617e7bf00541
luetooth.c
bf611504d460adb10cc8c31f731504750104a1f3 05-Jun-2014 Matthew Xie <mattx@google.com> Merge "Save remote device name immediately" into klp-wireless-dev
ed999f5e92ef9e718f4e6a5d6e68caf1001961c8 05-Jun-2014 Matthew Xie <mattx@google.com> Save remote device name immediately

bug 7381249

Change-Id: Ief1910c608116ebc28f5dc3e5804be65797ec53c
tif_storage.c
9546abf9fc4400853803ee220482ae63e63f0d9d 31-May-2014 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Support for reading LE specific controller features

Support for reading LE specific controller features via get adapter properties
API

Change-Id: Ia0b813be45fb826ce27d1d7a31ca41650d7286dd
tif_core.c
tif_dm.c
f1d9b90f44336264a7dfee8708f208cd7b7fd541 31-May-2014 Sharvil Nanavati <sharvil@google.com> Whitelist IPv6 packets so they can be sent over PAN.

Change-Id: I68e96bc34af1dfded2761c9bc780c089076d15e0
tif_pan.c
477057cc54dde60732f9a97232f0042c2c64f3a8 24-May-2014 Matthew Xie <mattx@google.com> Revert "add wakelock control callback"

This reverts commit cd7896c5c4bffa5a6f9a414177ea0038d6172964.
luetooth.c
8075fbd743d5eb3937a11156abf2c9a4f051434c 23-May-2014 Dmitry Grinberg <dmitrygr@google.com> am 262685fe: am cd7896c5: add wakelock control callback

* commit '262685fe26c0ccc7e196def7db1d7447c51efdbb':
add wakelock control callback
262685fe26c0ccc7e196def7db1d7447c51efdbb 23-May-2014 Dmitry Grinberg <dmitrygr@google.com> am cd7896c5: add wakelock control callback

* commit 'cd7896c5c4bffa5a6f9a414177ea0038d6172964':
add wakelock control callback
cd7896c5c4bffa5a6f9a414177ea0038d6172964 22-May-2014 Dmitry Grinberg <dmitrygr@google.com> add wakelock control callback

Change-Id: Iffa8f33767a037fceb4757cdff07f25f30acf453
luetooth.c
44c6f8d6c7cb3929a5b49e5d0ef8c471798f552f 07-Feb-2014 Hemant Gupta <hemantg@codeaurora.org> [2/4] Add Support for AVRCP Controller Feature

- Provide support for AVRCP Controller CAT 1 and CAT 2
Passthrough commands.

Change-Id: Ia3ca08c1139d9a98b86919b51d7480e0245c35f3
tif_av.c
tif_rc.c
bf0e4b26d8f0748ff4f9522a2ac7001bfb9ca5cc 20-May-2014 Wei Wang <weiwa@google.com> Fix build issue for devices without BLE features.

Change-Id: I6499663d253c791cc739ed76b839eb3aefe6613a
tif_dm.c
tif_gatt_multi_adv_util.c
2a647f406c94a3a85e984c23428260dddea3f4ee 20-May-2014 Wei Wang <weiwa@google.com> Add bt_target.h header

Change-Id: I6b584e3e610d20348bf410f434164b8a5e738f04
tif_gatt_multi_adv_util.c
29fa7d710857881b6c61cff949d42922b70e8df2 20-May-2014 Wei Wang <weiwa@google.com> Fix build issue for devices without BLE features.

Change-Id: I6499663d253c791cc739ed76b839eb3aefe6613a

Conflicts:
btif/src/btif_dm.c
btif/src/btif_gatt_multi_adv_util.c

Conflicts:
btif/src/btif_dm.c
btif/src/btif_gatt_multi_adv_util.c
tif_dm.c
tif_gatt_multi_adv_util.c
ed534e330bf63c72e778fc8daae09ddd63c395b2 20-May-2014 Wei Wang <weiwa@google.com> Revert "Revert "LE: Add RRA offloading and vendor specific PCF commands""

This reverts commit 146bb736bc1cdfd679bbafcf3f33c7af612096b9.

Change-Id: Ie4e6b4d7118a622d04c46623add1073906366edf
tif_dm.c
a6ce7751d84218c193eb90d390aef23217b1737e 20-May-2014 Wei Wang <weiwa@google.com> Revert "Revert "LE Multi ADV feature""

This reverts commit ea85048a8e86b1e1b6b725649f6bb0834ba17301.

Change-Id: I9a9305db4fabff07b4309a38f65361dca3f5f37c
tif_gatt_client.c
tif_gatt_multi_adv_util.c
ea85048a8e86b1e1b6b725649f6bb0834ba17301 20-May-2014 Wei Wang <weiwa@google.com> Revert "LE Multi ADV feature"

This reverts commit 87776cf5e201b18646cbc16f11a7110d5ffe510c.

Change-Id: I5b544a5c965999096b665b1bd2edb021e3054be8
tif_gatt_client.c
tif_gatt_multi_adv_util.c
146bb736bc1cdfd679bbafcf3f33c7af612096b9 20-May-2014 Wei Wang <weiwa@google.com> Revert "LE: Add RRA offloading and vendor specific PCF commands"

This reverts commit 15fa3be8ecd576b9ef88e20cf9a6f4bd765cbc6b.

Change-Id: Iaa484508ac664d4cb6c94758c2984d53263a902a
tif_dm.c
15fa3be8ecd576b9ef88e20cf9a6f4bd765cbc6b 12-May-2014 Satya Calloji <satyac@broadcom.com> LE: Add RRA offloading and vendor specific PCF commands

Change-Id: Iadca8e73ceaadcd0429421ea70f1b76644e88c42
tif_dm.c
87776cf5e201b18646cbc16f11a7110d5ffe510c 01-May-2014 Satya Calloji <satyac@broadcom.com> LE Multi ADV feature

BTIF and stack changes for LE multi ADV feature

Change-Id: I5e009ff8cbac5fc6f92ca943c61c4faf98e4e2ce
tif_gatt_client.c
tif_gatt_multi_adv_util.c
0943c10ed5713a08659f08e39e13de4894aaba61 12-May-2014 Satya Calloji <satyac@broadcom.com> LE: Add RRA offloading and vendor specific PCF commands

Change-Id: Iadca8e73ceaadcd0429421ea70f1b76644e88c42
tif_dm.c
ffb3960bb05f9acb0717d213612403487e9ad433 01-May-2014 Satya Calloji <satyac@broadcom.com> LE Multi ADV feature

BTIF and stack changes for LE multi ADV feature

Change-Id: I5e009ff8cbac5fc6f92ca943c61c4faf98e4e2ce
tif_gatt_client.c
tif_gatt_multi_adv_util.c
bfa5cf78dc26b971236190c6fb42353a8d30a649 15-May-2014 Mike Lockwood <lockwood@google.com> Merge "[2/4] Bluetooth: Add support for HFP Client role." into klp-wireless-dev
4a1a92a5f945ecbadc8a8c95ba18cca2c396c26a 15-May-2014 Mike Lockwood <lockwood@google.com> Merge "Submitted on behalf of 3rd party copied from external/bluetooth/bluedroid" into klp-wireless-dev
7d208f286865ff58ba5e79299c42b9686cca25cb 10-May-2014 Prerepa Viswanadham <dham@google.com> LE: Add API to set scan interval and window (2/4)
Delete client_if from scan api's
Change-Id: I66e0e17221601cd07ea77cf3d61ad9ce20a603a4
tif_gatt_client.c
714078d91aa0ecbe29661aac869dc397d8884042 10-May-2014 Prerepa Viswanadham <dham@google.com> LE: Add API to set scan interval and window (2/4)
Delete client_if from scan api's
Change-Id: I66e0e17221601cd07ea77cf3d61ad9ce20a603a4
tif_gatt_client.c
bea4131cac3214e0ad26ea8258e270448f23f1f3 09-May-2014 Matthew Xie <mattx@google.com> Init variables to fix compiler error

Change-Id: Ib41ecc8be53f64f10446b758c54eaf41f2a2e725
tif_hl.c
1025687c6679608fe9df918f37011414ffc72b62 19-Aug-2013 Hemant Gupta <hemantg@codeaurora.org> [2/4] Bluetooth: Add support for HFP Client role.

Implementation changes in BTA and BTIF layer to support
HFP Client role.

Change-Id: I9f939c18e8f989a50f298d0b313c5a0959c030a7
luetooth.c
tif_dm.c
tif_hf_client.c
tif_storage.c
tif_util.c
3fe1b49071420903cb8e3082ec04e76296352690 29-Apr-2014 Hemant Gupta <hemantg@codeaurora.org> Submitted on behalf of 3rd party copied from external/bluetooth/bluedroid

Initial commit for HFP Client

Change-Id: I26b7d49b76ab28b019314ddb514e8f46b3bc4772
tif_hf_client.c
740def526e757f5ea8f30d9d28d1e7a668dadc42 04-May-2014 Sharvil Nanavati <sharvil@google.com> Eliminate dead code (helped by compiler warnings).

I've removed all functions that the compiler decided were unused.

Change-Id: I0cbddf874ebd1586abe29b80e8d6390680679542
tif_config.c
tif_dm.c
tif_hh.c
tif_hl.c
tif_media_task.c
tif_sock_rfc.c
tif_storage.c
d9e5b3490bf41f912823af920cc616e57e0fec28 26-Apr-2014 Sharvil Nanavati <sharvil@google.com> Update RFCOMM socket code to use list data structure.

Change-Id: I70402d8bfaa36b36d3d4b8f3cec98371691e86c9
tif_sock_rfc.c
3542d5a93129b6a8026501f87877017173530ae0 26-Apr-2014 Sharvil Nanavati <sharvil@google.com> Update btif_profile_queue to use the list data structure.

The profile queue maintains a list of pending connect operations
for each profile. If a connect is followed by a disconnect before
the queued connect is dispatched, the disconnect will have no
effect and the connect will proceed.

This code clearly needs to be re-thought; it may be a good idea to
abandon the connect queue entirely in the long-run.

Change-Id: Ic0e85654abcf7a47f65953edb301eb9524394950
tif_profile_queue.c
7e4c60ce7757d935901f53d1f21ecc696aa89979 05-Sep-2013 Hemant Gupta <hemantg@codeaurora.org> Bluetooth: On Suspend ignore media task timer event

On Recieving Suspend confirmation from remote device,
Media task timer reload and tx_timer is made false,
hence media task will not be stopped at that instant.
Media task timer expires causing buffer to be allocated.
Changes done to ensure buffer is allocated only if tx_timer
is true.

Change-Id: I971a82cccc64ba033475ad532b096862968de942
tif_media_task.c
27c81965d8bcf9050b6fa66e004373ca2dea52a1 05-May-2014 Hemant Gupta <hemantg@codeaurora.org> MHF: Route call to correct HS in multi call scenario.

- This change makes sure that audio routes back to correct
headset in multi call scenario even though the other
headset tries to answer or dial.
- Ignore setting hf_idx for ATA/BLDN received from HS
for a waiting call when an active/held call is already
present.

Change-Id: I19949471d481bf911fda2222dc6d730d1a821b65
tif_hf.c
550b319b217739808fe95c57aa0f422dbf5db9d1 29-Apr-2014 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Resolve Pairing failure with IPhone

When pairing is initiated from the iPhone side, it sets Bonding bit
without MITM. We responded to this with No bonding, No MITM. This resulted
in JustWorks & Unauthenticated link key. After pairing iPhone initiates a
RFCOMM connection. This caused a link key upgrade to be done, which the iPhone
rejected, resulting in pairing failure. To resolve this the following
enhancements were made
1. If locally initiated pairing always set Bonding bit + MITM
2. If remote initiated
a. copy over the bonding bit
b. if peer has DisplayYesNo set MITM
3. As a fallback if remote had MITM, enable MITM in our response
This forces pairing to use Bonding bit+MITM thus resulting in authenticated
combination linkkey

Change-Id: I08f16c80821bc822023180d01868614ba41e6d88
tif_dm.c
6ef30dba0eb77593c9c6ce5843848961ba12d57b 06-Jan-2014 Hemant Gupta <hemantg@codeaurora.org> GAP: Update local device name immediately

Though the function btif_config_set_str requests to
save device name immediately, sometimes it doesn't
call save device name if the cached changes are more.

So calling the "btif_config_save" explicitly to avoid
failure cases.

Change-Id: I9fb05caf284d6a6feb906f87a4db19896182d2c9
tif_storage.c
7fa4fba6f59f97df00aff07dbe8fb21b114b3c2c 17-Apr-2014 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Merge BT 4.1 features

The features include:
- LE Peripheral Mode
- Link Layer topology (LE Central & Peripheral Concurrency)
- Dual Mode Topology (Ability to choose LE transport when connecting with
other Dual Mode devices)
- Fast advertising Interval
- Limited Discovery Time Changes
- GAP Authentication and Lost Bond
- Dual Mode Addressing
- Common Profile and Service Error Code
- 32 bit UUIDs

Change-Id: Ic6701da4cf6aaa390ff2c8816b43157f36b7fb42

Conflicts:
stack/btu/btu_hcif.c
luetooth.c
tif_dm.c
tif_gatt_client.c
tif_gatt_server.c
tif_gatt_test.c
tif_gatt_util.c
tif_storage.c
3b8b972a8151c081905f3c1273e5d6cdd3401354 30-Apr-2014 Ganesh Ganapathi Batta <ganeshg@broadcom.com> fix random crashes in bd2str caused by exceeding string array

remove all casts to avoid sign extension of bd address as this may
exceed the size of destination str buffer

Change-Id: I27dc7e61b52440c6b284b7e9931e6daa66afbf12
tif_util.c
90a32530e8b9908f2af64ce98931684fa20c061b 15-Mar-2014 Nitin Srivastava <nitinsr@codeaurora.org> Add support for Multi-HFP devices

1. Add multi headset support in stack.
2. Each HS will be associated with unique CB in BTIF
and also corresponding SCB in BTA.
3. Upstream event callbacks will be sent to
specific HS based on BD_ADDR.
4. Similiarly all commands to BTIF will be for
specific HS.

Change-Id: I0dc6b1b54f16244b802d818ae60944877a41d020
tif_hf.c
68c53ded6523113ddcc1932fa5bcb7d378b12209 13-Feb-2014 Nitin Srivastava <nitinsr@codeaurora.org> Bluetooth: Clear Notification array on AVRCP disconnect

DUT does not clear previous AVRCP notification registration
on AVCTP disconnect hence DUT sends response even when remote
device hasn't registered.
Changes made to clear notification array and while sending
notification respose check if event is registered.

Change-Id: I610f8ae6381a63236378f179bb2a619ec0c6549e
tif_rc.c
fc07218666349142c0de3b461921b8cda792aa76 27-Nov-2013 Zhihai Xu <zhihaixu@google.com> Bluetooth: GAP: Remove bonded device info on Authentication fail

Remove bonded device information from the BT-IF layer storage
on authentication failure if already bonded with just works
model.
from QCOM
Change-Id: Ia3c1635c446f39b1dbd4cdd0122c2f70cbbc8dd7
tif_dm.c
tif_storage.c
f7083df9c30849fabfb2d03ce95701f110a2df99 29-Apr-2014 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Fix issue of HDP select thread not exiting during BT OFF

Change-Id: I52a0a3caff327a7a51e293c431ddbc99db690180
tif_hl.c
ad7a6009746430da82ad7d8ee4a4784db7087ae4 21-Apr-2014 Hemant Gupta <hemantg@codeaurora.org> HID: Use dynamic memory while sending data

This patch uses dynamic memory allocation while sending HID output data to
remote device depending on size of data to be sent. Without this patch
fixed size static buffer of 200 bytes was being used for sending data to
remote device, which was resulting in crash in case data size to be sent
to remote device was greater than 200 bytes.

Change-Id: I5ed12422355e88d7ef0391668800d7619ca3b685
tif_hh.c
8cd229d4765330b554eedd6919b9f41ca7989e7e 25-Oct-2013 Hemant Gupta <hemantg@codeaurora.org> HID: Parse paired hid devices from bluez.

This patch adds support for parsing SDP records of paired HID devices
from bluez device storage path and store the parsed hid sdp data into
bluedroid storage path. Without this patch, it was not possible to
have paired HID devices during upgrade from BlueZ to Bluedroid Stack.

Change-Id: I7db4a801f3cf9ca46fc0eabfd929e8d7c16b5edb
tif_config_util.cpp
dda369e3a6b39c7df25072fc880fbd4903553f5c 28-Nov-2013 Hemant Gupta <hemantg@codeaurora.org> GAP: Try to retrieve CoD from NVRAM if 0

This patch tries to retreive CoD from NVRAM if CoD is 0. This is
because in scenarios when airplane mode on/off, inquiry is not
performed again on devices shown in Available devices List of
UI, so CoD is 0 during SSP information as database of stack is
not properly updated since inquiry is not performed again. Without
this patch it was observed because of wrong CoD info device icon
for HID mouse was changed to Joystick and device is not shown in
Paired List. Also some extra debug logs are added in code for
better debugging.

Change-Id: I14858ccee04728cb4b9cd60d397b79fa6494b842
tif_dm.c
ee27b932f65a3c5a0a52067dac8a1be729c7a435 13-Dec-2013 Zhihai Xu <zhihaixu@google.com> HID: Remove device from nvram on auth failure

This patch removed hid pointing device from nvram on authentication failure
due to pairing timeout or when wrong passkey is entered. Without this patch
it was observed that hid pointing device was always shown in paired list
when DUT was restarted after authentication failure.
CL from qcom(Hemant Gupta)
Change-Id: I69c43d2ed982d5d5abfd5707db90ef4b5c65b34f
tif_dm.c
f11d21fa60be8a2cd072968bf5e1bb23ce5caabf 21-Apr-2014 Zhihai Xu <zhihaixu@google.com> HID: Use dynamic memory while sending report

This patch uses dynamic memory allocation while sending HID output data to
remote device depending on size of data to be sent. Without this patch
fixed size static buffer of 200 bytes was being used for sending data to
remote device, which was resulting in crash in case data size to be sent
to remote device was greater than 200 bytes.

CL from qcom(Hemant Gupta)
Change-Id: Icc8cd4a4ecfd4bc30cbf848a7c865fcf9308ddf8
tif_hh.c
8029dc8f0332d1135aa93e8e5daa46e3eb7b2500 21-Apr-2014 Hemant Gupta <hemantg@codeaurora.org> HID: Update SSR parameters during copy.

This patch correctly stores SSR parameters (max latency and min timeout)
retrieved from remote device SDP record in NVRAM.

Change-Id: I87d8b6181981090df21ab746deac7053a1d0e938
tif_hh.c
4186b0ec7e0b7efe17c3b7cb8546ff359e099408 07-Apr-2014 Sharvil Nanavati <sharvil@google.com> Add flow control for PAN.

This change reads from the TAP fd only when btpan_cb.flow == 1.
The value of this flag changes based on L2CAP congestion events.

http://b/13246629

Change-Id: Ic28bf65737dbd74c41b68198fceee58e3bff08d4

Conflicts:
btif/src/btif_pan.c
tif_pan.c
b203d478f4835f5e35217874a1787e1914328f7c 21-Nov-2013 Andre Eisenbach <andre@broadcom.com> LE: Add controller based advertising filter API (2/2)

Change-Id: I444654bf19a048d5fcef33f79edbf1cdda3d3b62
tif_core.c
tif_gatt_client.c
tif_gatt_util.c
04c45382988247e04d50f8599c5e4501e0934553 24-Dec-2013 Hemant Gupta <hemantg@codeaurora.org> Bluetooth: GAP: Send bond none in case of temp pairing

Send BOND_NONE in case of temporary device pairing on
receiving the authentication complete, so that UI
doesn't get stucked in pairing for that device.

Change-Id: Ided412ef89d928f958a0052362be145232411c0a
tif_dm.c
54db2c249efa91082c5a167a924a527ec73ff38d 13-Apr-2014 Sharvil Nanavati <sharvil@google.com> Remove executable bit on source files.

Change-Id: Id456478aea626f57fed3479346e8fb4dbd0fafa6
luetooth.c
tif_av.c
tif_media_task.c
tif_util.c
4974d81a88dd7ffa1951242dfc830d329f3cf378 05-May-2014 Hemant Gupta <hemantg@codeaurora.org> MHF: Route call to correct HS in multi call scenario.

- This change makes sure that audio routes back to correct
headset in multi call scenario even though the other
headset tries to answer or dial.
- Ignore setting hf_idx for ATA/BLDN received from HS
for a waiting call when an active/held call is already
present.

Change-Id: I19949471d481bf911fda2222dc6d730d1a821b65
tif_hf.c
d8e742ff26096ed599623285047aca39b9e7a87a 05-May-2014 Matthew Xie <mattx@google.com> Merge "fix random crashes in bd2str caused by exceeding string array" into klp-wireless-dev
a217ab9a0294a8285641b141efccf7d54b437a33 29-Apr-2014 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Resolve Pairing failure with IPhone

When pairing is initiated from the iPhone side, it sets Bonding bit
without MITM. We responded to this with No bonding, No MITM. This resulted
in JustWorks & Unauthenticated link key. After pairing iPhone initiates a
RFCOMM connection. This caused a link key upgrade to be done, which the iPhone
rejected, resulting in pairing failure. To resolve this the following
enhancements were made
1. If locally initiated pairing always set Bonding bit + MITM
2. If remote initiated
a. copy over the bonding bit
b. if peer has DisplayYesNo set MITM
3. As a fallback if remote had MITM, enable MITM in our response
This forces pairing to use Bonding bit+MITM thus resulting in authenticated
combination linkkey

Change-Id: I08f16c80821bc822023180d01868614ba41e6d88
tif_dm.c
2a55a6e1955be41227ebe850090c925867d9b98b 02-May-2014 Matthew Xie <mattx@google.com> Merge "Fix issue of HDP select thread not exiting during BT OFF" into klp-wireless-dev
f5726daa6c720685cbc0e5250a2a5ee6b4860210 25-Mar-2014 lpoulain <loic.poulain@intel.com> Bluedroid: Fix UUID unsigned/signed comparison

UUID type was never detected as a 16 bits UUID due to a comparison
between signed and unsigned char in uuidType().

Change-Id: I6205ab4c2568f03b4692e0ce8a1dec216f1cdc0e
Signed-off-by: lpoulain <loic.poulain@intel.com>
Signed-off-by: Yong Yao <yong.yao@intel.com>
tif_gatt_util.c
fbf76881316471faf631dc543089efaeaf72df8d 06-Jan-2014 Hemant Gupta <hemantg@codeaurora.org> GAP: Update local device name immediately

Though the function btif_config_set_str requests to
save device name immediately, sometimes it doesn't
call save device name if the cached changes are more.

So calling the "btif_config_save" explicitly to avoid
failure cases.

Change-Id: I9fb05caf284d6a6feb906f87a4db19896182d2c9
tif_storage.c
8fe58875ce67c6e1099e7ba2339dcd2b979491b0 17-Apr-2014 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Merge BT 4.1 features

The features include:
- LE Peripheral Mode
- Link Layer topology (LE Central & Peripheral Concurrency)
- Dual Mode Topology (Ability to choose LE transport when connecting with
other Dual Mode devices)
- Fast advertising Interval
- Limited Discovery Time Changes
- GAP Authentication and Lost Bond
- Dual Mode Addressing
- Common Profile and Service Error Code
- 32 bit UUIDs

Change-Id: Ic6701da4cf6aaa390ff2c8816b43157f36b7fb42
luetooth.c
tif_dm.c
tif_gatt_client.c
tif_gatt_server.c
tif_gatt_test.c
tif_gatt_util.c
tif_storage.c
9b4676076ba984de33984276694347797f240a9d 30-Apr-2014 Ganesh Ganapathi Batta <ganeshg@broadcom.com> fix random crashes in bd2str caused by exceeding string array

remove all casts to avoid sign extension of bd address as this may
exceed the size of destination str buffer

Change-Id: I27dc7e61b52440c6b284b7e9931e6daa66afbf12
tif_util.c
2cb90bc58fc075ec2f814ada5ae8f728380566c1 15-Mar-2014 Nitin Srivastava <nitinsr@codeaurora.org> Add support for Multi-HFP devices

1. Add multi headset support in stack.
2. Each HS will be associated with unique CB in BTIF
and also corresponding SCB in BTA.
3. Upstream event callbacks will be sent to
specific HS based on BD_ADDR.
4. Similiarly all commands to BTIF will be for
specific HS.

Change-Id: I0dc6b1b54f16244b802d818ae60944877a41d020
tif_hf.c
ad0b6c784a5684812f828b68fd8b5f952c62a443 13-Feb-2014 Nitin Srivastava <nitinsr@codeaurora.org> Bluetooth: Clear Notification array on AVRCP disconnect

DUT does not clear previous AVRCP notification registration
on AVCTP disconnect hence DUT sends response even when remote
device hasn't registered.
Changes made to clear notification array and while sending
notification respose check if event is registered.

Change-Id: I610f8ae6381a63236378f179bb2a619ec0c6549e
tif_rc.c
a0a1c864abe6076442cd2c9e48d8f65b8d3a3c6e 29-Apr-2014 Bill Yi <byi@google.com> Merge commit 'b48f9962d57d9c500bfa8c8dbe65ce04f67918e5' into HEAD
a7ea809912e5a945d657957491753260826422f4 27-Nov-2013 Zhihai Xu <zhihaixu@google.com> Bluetooth: GAP: Remove bonded device info on Authentication fail

Remove bonded device information from the BT-IF layer storage
on authentication failure if already bonded with just works
model.
from QCOM
Change-Id: Ia3c1635c446f39b1dbd4cdd0122c2f70cbbc8dd7
tif_dm.c
tif_storage.c
744ad4713df103183916de11796b0e1e27b5a5d8 29-Apr-2014 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Fix issue of HDP select thread not exiting during BT OFF

Change-Id: I52a0a3caff327a7a51e293c431ddbc99db690180
tif_hl.c
73e68297292dd901a170bcf6434ed0a10f1ec450 07-Apr-2014 Zhihai Xu <zhihaixu@google.com> flounder64: bluetooth: Adjust volume level on BT HS and DUT side

MW600 Bluetooth address is "58:17:0c:e8:b0:7a". It is not included in
AVRCP profile white list. So it can't support absolute volume. We need
to whitelist it by device name "MW600" instead device address method.

Signed-off-by: Thomas.TT_Lin <Thomas.TT_Lin@htc.com>
Change-Id: I41b27fbab13dcf9d0005e8d5ae25ffb95eb546d4
tif_rc.c
79eb1a643a2e627e5fb2c9dae1cb6a56a15ff0cf 21-Apr-2014 Hemant Gupta <hemantg@codeaurora.org> HID: Use dynamic memory while sending data

This patch uses dynamic memory allocation while sending HID output data to
remote device depending on size of data to be sent. Without this patch
fixed size static buffer of 200 bytes was being used for sending data to
remote device, which was resulting in crash in case data size to be sent
to remote device was greater than 200 bytes.

Change-Id: I5ed12422355e88d7ef0391668800d7619ca3b685
tif_hh.c
fbaeb4a7b64a89c08a98b53766e250eb7bad8830 25-Oct-2013 Hemant Gupta <hemantg@codeaurora.org> HID: Parse paired hid devices from bluez.

This patch adds support for parsing SDP records of paired HID devices
from bluez device storage path and store the parsed hid sdp data into
bluedroid storage path. Without this patch, it was not possible to
have paired HID devices during upgrade from BlueZ to Bluedroid Stack.

Change-Id: I7db4a801f3cf9ca46fc0eabfd929e8d7c16b5edb
tif_config_util.cpp
87b7cce18f64b1b5f1cdff81d883a5c8720ead77 28-Nov-2013 Hemant Gupta <hemantg@codeaurora.org> GAP: Try to retrieve CoD from NVRAM if 0

This patch tries to retreive CoD from NVRAM if CoD is 0. This is
because in scenarios when airplane mode on/off, inquiry is not
performed again on devices shown in Available devices List of
UI, so CoD is 0 during SSP information as database of stack is
not properly updated since inquiry is not performed again. Without
this patch it was observed because of wrong CoD info device icon
for HID mouse was changed to Joystick and device is not shown in
Paired List. Also some extra debug logs are added in code for
better debugging.

Change-Id: I14858ccee04728cb4b9cd60d397b79fa6494b842
tif_dm.c
8d2128d5740c8a7282e2336cd9f5901e98d3eb63 13-Dec-2013 Zhihai Xu <zhihaixu@google.com> HID: Remove device from nvram on auth failure

This patch removed hid pointing device from nvram on authentication failure
due to pairing timeout or when wrong passkey is entered. Without this patch
it was observed that hid pointing device was always shown in paired list
when DUT was restarted after authentication failure.
CL from qcom(Hemant Gupta)
Change-Id: I69c43d2ed982d5d5abfd5707db90ef4b5c65b34f
tif_dm.c
45c71b0647cba0f199a8dfd1321c1b59a916cfe5 21-Apr-2014 Zhihai Xu <zhihaixu@google.com> HID: Use dynamic memory while sending report

This patch uses dynamic memory allocation while sending HID output data to
remote device depending on size of data to be sent. Without this patch
fixed size static buffer of 200 bytes was being used for sending data to
remote device, which was resulting in crash in case data size to be sent
to remote device was greater than 200 bytes.

CL from qcom(Hemant Gupta)
Change-Id: Icc8cd4a4ecfd4bc30cbf848a7c865fcf9308ddf8
tif_hh.c
4c5f9ef5fa88891f073b38d5e15f2705ed5c235e 21-Apr-2014 Hemant Gupta <hemantg@codeaurora.org> HID: Update SSR parameters during copy.

This patch correctly stores SSR parameters (max latency and min timeout)
retrieved from remote device SDP record in NVRAM.

Change-Id: I87d8b6181981090df21ab746deac7053a1d0e938
tif_hh.c
33a3ae6aa2334c5df1cd0aadea3597b46a7a59ee 21-Apr-2014 Matthew Xie <mattx@google.com> am 72f5ce63: am 4b416130: Merge "Bluetooth: Adding Sniff feature for PAN Profile"

* commit '72f5ce63c2dbf31c7cfbb903c687ea71ad29b3ea':
Bluetooth: Adding Sniff feature for PAN Profile
72f5ce63c2dbf31c7cfbb903c687ea71ad29b3ea 21-Apr-2014 Matthew Xie <mattx@google.com> am 4b416130: Merge "Bluetooth: Adding Sniff feature for PAN Profile"

* commit '4b41613019829b40e8ca75a87219a415c51ae3a1':
Bluetooth: Adding Sniff feature for PAN Profile
496765df63a103d46aff536f9e1c094bf58d52b7 21-Apr-2014 Zhihai Xu <zhihaixu@google.com> Merge "Fix GKI exception of calling free on an already freed buffer" into klp-wireless-dev
c0f7987d626a70b1a23a28348ece8be69ce61a16 25-Feb-2014 Zhihai Xu <zhihaixu@google.com> Fix GKI exception of calling free on an already freed buffer

Various parts of btif_hh.c were creating GKI buffers and
keeping references to them and freeing them in odd and
unnecessary ways. The buffer is freed by lower levels
of the stack once the buffer has been sent to the chip
at the l2c layer and shouldn't be freed by btif_hh itself
since it's possible to double free, and there could
also be race conditions with other threads already processing
the buffer while the reference is freed if the API calls
are invoked again before the previous invocation was completely
processed.

Also added a helper routine to simplify buffer creation and
initialization.

Change-Id: Ia6039983502e2670b2325d90310244edf843b692
Signed-off-by: Mike J. Chen <mjchen@google.com>
tif_hh.c
17888ed7fa01bf266e3847b308f4091fd93f719c 21-Apr-2014 Zhihai Xu <zhihaixu@google.com> Merge "bluetooth: hid: store ssr_max_latency and ssr_min_tout in bonding db" into klp-wireless-dev
6efaf223753108aa84f55332898340db0c9d5ebf 27-Jan-2014 Zhihai Xu <zhihaixu@google.com> bluetooth: hid: store ssr_max_latency and ssr_min_tout in bonding db

Store the ssr_max_latency and ssr_min_tout parameters in the
bonding database. Previously these parameters were not stored for HID
devices. This caused an inconsistency in sniff behavior between
when the HID device was paired and following a reboot of the host.

When the HID device is paired the SSR parameters are retrieved
from the HID device and are stored in the HID Host's device list.
If the host is rebooted then the HID Host's device list is
constructed from the bonding database.

If the SSR max latency is non-zero then the SSR parameters are
sent to the firmware and SSR is used. In the event that the SSR
max latency is 0, as it is if the parameters are not found, then
SSR is disabled.

Bug: 12764547

Change-Id: I63637575fdfcf4cb4ca0ce8dc2e4ccda9cccaf66
Signed-off-by: Adam Hampson <ahampson@google.com>
tif_hh.c
tif_storage.c
f4b8f8aa313d3b7d88b683bfe0e5f9eb0a29b3b3 07-Apr-2014 Sharvil Nanavati <sharvil@google.com> Add flow control for PAN.

This change reads from the TAP fd only when btpan_cb.flow == 1.
The value of this flag changes based on L2CAP congestion events.

http://b/13246629

Change-Id: Ic28bf65737dbd74c41b68198fceee58e3bff08d4

Conflicts:
btif/src/btif_pan.c
tif_pan.c
2d75441cc17236564a431c6a5fc4c9e356fb7294 21-Nov-2013 Andre Eisenbach <andre@broadcom.com> LE: Add controller based advertising filter API (2/2)

Change-Id: I444654bf19a048d5fcef33f79edbf1cdda3d3b62
tif_core.c
tif_gatt_client.c
tif_gatt_util.c
fd2e0f21623a8e38460c140281500ea1f658f422 17-Apr-2014 Matthew Xie <mattx@google.com> Merge "Bluetooth: GAP: Send bond none in case of temp pairing" into klp-wireless-dev
6d4a9e9cbfc0ea3b91b9dd1933d2646065e665cd 16-Apr-2014 Zhihai Xu <zhihaixu@google.com> Merge "LE: Add API to configure MTU for a given connection (2/4) This patch from broadcom(andre) bug:13571470 Change-Id: I932905590ee9c40cb67e7d09715c0f8e59d2f662" into klp-wireless-dev
9291a71c28b2eedff2c1ad760ebe3b3c1f5a6a29 25-Mar-2014 Zhihai Xu <zhihaixu@google.com> LE: Add API to configure MTU for a given connection (2/4)
This patch from broadcom(andre)
bug:13571470
Change-Id: I932905590ee9c40cb67e7d09715c0f8e59d2f662
tif_gatt_client.c
3aafefbb0fe4c1577635ddb455c764c8da91860a 16-Apr-2014 Zhihai Xu <zhihaixu@google.com> Merge "remove all advertised services in SDP btif_av_init is called twice. Don't need call it in enable. disable EDR ATT SDP record" into klp-wireless-dev
d92e3cf7b26fe2dd64e7c27b43428d3cab85e371 05-Apr-2014 Zhihai Xu <zhihaixu@google.com> remove all advertised services in SDP
btif_av_init is called twice. Don't need call it in enable.
disable EDR ATT SDP record

bug:13558005
Change-Id: Id834697eae150018f9a0382d9c1e6c972e885739
tif_core.c
d0f17781e92806065b04aa95a9b9ff9cbe5b2cad 16-Apr-2014 Zhihai Xu <zhihaixu@google.com> Merge "Workaround IPHONE problem" into klp-wireless-dev
facc510f94c02440e9004f31110463cd1d367221 18-Mar-2014 Zhihai Xu <zhihaixu@google.com> Workaround IPHONE problem

When we send LL_ENC_REQ to iphone early, iphone didn't send
LL_ENC_RESPONSE back to us, later the iphone will disconnect from us.
The workaround is to send LL_ENC_REQ after receive first ATT read request
from iphone, Iphone will be ready at that time by experiment.

bug:13417692
Change-Id: Ic42dda36b927df260113771152cff67032b22e5f
tif_gatt_util.c
51356020fb8fec90a01eeaa23faaf9d3cb0b6322 16-Apr-2014 Zhihai Xu <zhihaixu@google.com> Merge "treat BTA_BUSY as success to avoid unpair the BLE device" into klp-wireless-dev
b9238669b5ad298980d60540e8019c4b90a866b1 13-Mar-2014 Zhihai Xu <zhihaixu@google.com> treat BTA_BUSY as success to avoid unpair the BLE device

when switch from peripheral mode, both server and client will
call btif_gatt_check_encrypted_link, the first call will start the
encryption. the second call will get callback with BTA_BUSY status,
before encryption complete, which cause unpair with the remote device.
we shouldnot treat BTA_BUSY as error.

bug:13417692
Change-Id: I065432dde2553e8ccee3a14a7b321b85bca8d3ba
tif_gatt_util.c
43d8f252240611ad2b67f9587f91058edd9955a0 16-Apr-2014 Zhihai Xu <zhihaixu@google.com> Merge "support peripheral mode feature to connect iphone to android device." into klp-wireless-dev
5f72121ddc2f0249e896e19b186a05888bce2331 10-Feb-2014 Zhihai Xu <zhihaixu@google.com> support peripheral mode feature to connect iphone to android device.

enable BLE_PERIPHERAL_MODE_SUPPORT flag and fix the bug
the discoverability flag is not set in advertisement packet,
which cause the central device(iphone) can not find android device
during scan.
use displayOnly IO cap for dory, so dory can display the pin,
and the iphone(central device) will input the pin.
bug:12797572

Change-Id: Ie15ea9e340e3692df846399b9a85aa6d2a97eba7
tif_gatt_client.c
b820aec7a022231fa30a3493af861db9d9aa625d 24-Dec-2013 Hemant Gupta <hemantg@codeaurora.org> Bluetooth: GAP: Send bond none in case of temp pairing

Send BOND_NONE in case of temporary device pairing on
receiving the authentication complete, so that UI
doesn't get stucked in pairing for that device.

Change-Id: Ided412ef89d928f958a0052362be145232411c0a
tif_dm.c
d2ccbbb73c7851d2fa28dc212d2fffc0ad4e5d50 13-Apr-2014 Sharvil Nanavati <sharvil@google.com> Remove executable bit on source files.

Change-Id: Id456478aea626f57fed3479346e8fb4dbd0fafa6
luetooth.c
tif_av.c
tif_media_task.c
tif_rc.c
tif_util.c
36f43cc4b0ce38007c29d573f251ec594d95b180 29-Aug-2013 Nitin Shivpure <nshivpur@codeaurora.org> Bluetooth: Adding Sniff feature for PAN Profile

Sniff feature for PAN profile was not implemented in power
manager module of the stack, which was causing higher power
consumption after connecting PAN profile, Even though PAN
ACL link is idle & there is no data communication between
DUT & remote device. Adding sniff feature for PANU role &
NAP role to reduce power consumption.

Change-Id: Idf568f53a317abd536edf34fbdf1733fdf53b7d0
tif_pan.c
c9fbcde6d2077ee03dc497824cd98e4d782f7cea 07-Apr-2014 Thomas.TT_Lin <Thomas.TT_Lin@htc.com> flounder64: bluetooth: Adjust volume level on BT HS and DUT side

MW600 Bluetooth address is "58:17:0c:e8:b0:7a". It is not included in
AVRCP profile white list. So it can't support absolute volume. We need
to whitelist it by device name "MW600" instead device address method.

Signed-off-by: Thomas.TT_Lin <Thomas.TT_Lin@htc.com>
Change-Id: I41b27fbab13dcf9d0005e8d5ae25ffb95eb546d4
tif_rc.c
be9ef59a58c2cf3f8c3cd5a834841cd74965a599 08-Apr-2014 Matthew Xie <mattx@google.com> am 4ec26844: am c7d4ce67: Merge "Bluetooth:GAP: Add NULL check before accessing accept socket"

* commit '4ec26844f88e37dda00f1319ce6ab44fa87539f2':
Bluetooth:GAP: Add NULL check before accessing accept socket
4ec26844f88e37dda00f1319ce6ab44fa87539f2 08-Apr-2014 Matthew Xie <mattx@google.com> am c7d4ce67: Merge "Bluetooth:GAP: Add NULL check before accessing accept socket"

* commit 'c7d4ce671ccc74ee05813bef10639fd34e1bf81f':
Bluetooth:GAP: Add NULL check before accessing accept socket
07410e996c151f12852ab9216deb3cac6293ff17 07-Apr-2014 Zhihai Xu <zhihaixu@google.com> am 2f2d9f41: am a0cf8d6f: remove all advertised services in SDP btif_av_init is called twice. Don\'t need call it in enable. disable EDR ATT SDP record

* commit '2f2d9f412f7dc999eee87161cb2c30c786523ff2':
remove all advertised services in SDP btif_av_init is called twice. Don't need call it in enable. disable EDR ATT SDP record
2f2d9f412f7dc999eee87161cb2c30c786523ff2 07-Apr-2014 Zhihai Xu <zhihaixu@google.com> am a0cf8d6f: remove all advertised services in SDP btif_av_init is called twice. Don\'t need call it in enable. disable EDR ATT SDP record

* commit 'a0cf8d6f47fd6709085b9ad2c8626986f7ae7f21':
remove all advertised services in SDP btif_av_init is called twice. Don't need call it in enable. disable EDR ATT SDP record
a0cf8d6f47fd6709085b9ad2c8626986f7ae7f21 05-Apr-2014 Zhihai Xu <zhihaixu@google.com> remove all advertised services in SDP
btif_av_init is called twice. Don't need call it in enable.
disable EDR ATT SDP record

bug:13558005
Change-Id: Id834697eae150018f9a0382d9c1e6c972e885739
tif_core.c
6c15f743cac323570d7adcb9a2344824221a569f 02-Apr-2014 Mike J. Chen <mjchen@google.com> am 4927e67f: am 3576c564: Fix compiler/linker errors when BTA_PAN_INCLUDED is FALSE

* commit '4927e67fb8cd3cd09b2607241c3da875f85ed852':
Fix compiler/linker errors when BTA_PAN_INCLUDED is FALSE
4927e67fb8cd3cd09b2607241c3da875f85ed852 02-Apr-2014 Mike J. Chen <mjchen@google.com> am 3576c564: Fix compiler/linker errors when BTA_PAN_INCLUDED is FALSE

* commit '3576c564b33c20b5e2e90fdd3bca7ce24392ca50':
Fix compiler/linker errors when BTA_PAN_INCLUDED is FALSE
3576c564b33c20b5e2e90fdd3bca7ce24392ca50 01-Apr-2014 Mike J. Chen <mjchen@google.com> Fix compiler/linker errors when BTA_PAN_INCLUDED is FALSE

Change-Id: I14acefd66291adc2119daf97bd364b2eecf18d51
Signed-off-by: Mike J. Chen <mjchen@google.com>
tif_pan.c
e96ce0e945e210b22bbf6a3869809852c7e1d35e 06-Mar-2014 Andre Eisenbach <andre@broadcom.com> DO NOT MERGE: LE: Add status callback function for LE broadcasts
Cherry pick from master

Change-Id: If4342050ce1141a9c2111286e7b3cccdc012a91e
tif_gatt_client.c
7d3d17fb9e62720b8060b333662e7fa63f231cd3 01-Apr-2014 Zhihai Xu <zhihaixu@google.com> am a27b6503: am 221b822c: Merge "Workaround IPHONE problem" into klp-modular-dev

* commit 'a27b650322c6ad1d5cea2d0b4fcb7815e3176d1e':
Workaround IPHONE problem
a27b650322c6ad1d5cea2d0b4fcb7815e3176d1e 01-Apr-2014 Zhihai Xu <zhihaixu@google.com> am 221b822c: Merge "Workaround IPHONE problem" into klp-modular-dev

* commit '221b822ce1c42f4a51abc384cf09ca09b6180a9c':
Workaround IPHONE problem
221b822ce1c42f4a51abc384cf09ca09b6180a9c 01-Apr-2014 Zhihai Xu <zhihaixu@google.com> Merge "Workaround IPHONE problem" into klp-modular-dev
5702d5c6197404823f5e594764e2c67cf2416da1 18-Mar-2014 Zhihai Xu <zhihaixu@google.com> Workaround IPHONE problem

When we send LL_ENC_REQ to iphone early, iphone didn't send
LL_ENC_RESPONSE back to us, later the iphone will disconnect from us.
The workaround is to send LL_ENC_REQ after receive first ATT read request
from iphone, Iphone will be ready at that time by experiment.

bug:13417692
Change-Id: Ic42dda36b927df260113771152cff67032b22e5f
tif_gatt_util.c
3860c0c6ad3c09e094d2254ba44b410f8c3f7203 31-Mar-2014 Zhihai Xu <zhihaixu@google.com> am d86082bf: am 9b971dc5: Merge "treat BTA_BUSY as success to avoid unpair the BLE device" into klp-modular-dev

* commit 'd86082bfabffa25f2af77cc69c590d6e0b14260c':
treat BTA_BUSY as success to avoid unpair the BLE device
d86082bfabffa25f2af77cc69c590d6e0b14260c 31-Mar-2014 Zhihai Xu <zhihaixu@google.com> am 9b971dc5: Merge "treat BTA_BUSY as success to avoid unpair the BLE device" into klp-modular-dev

* commit '9b971dc52f5933c04e4f49ad99c9949df961afc5':
treat BTA_BUSY as success to avoid unpair the BLE device
9b971dc52f5933c04e4f49ad99c9949df961afc5 31-Mar-2014 Zhihai Xu <zhihaixu@google.com> Merge "treat BTA_BUSY as success to avoid unpair the BLE device" into klp-modular-dev
5a607b4fe2109f9ba602e932fde16f527b7a2139 31-Mar-2014 Zhihai Xu <zhihaixu@google.com> am 20222380: am 2011d136: Merge "LE: Add API to configure MTU for a given connection (2/4)" into klp-modular-dev

* commit '20222380588aa9a5e9b5e83b653e3c2a744da6aa':
LE: Add API to configure MTU for a given connection (2/4)
20222380588aa9a5e9b5e83b653e3c2a744da6aa 31-Mar-2014 Zhihai Xu <zhihaixu@google.com> am 2011d136: Merge "LE: Add API to configure MTU for a given connection (2/4)" into klp-modular-dev

* commit '2011d136791ec93c0670edc00e64122415c926a0':
LE: Add API to configure MTU for a given connection (2/4)
9426d530e9bbc5d3ffae55515388d49185c61325 25-Mar-2014 Andre Eisenbach <andre@broadcom.com> LE: Add API to configure MTU for a given connection (2/4)

bug:13571470
Change-Id: I932905590ee9c40cb67e7d09715c0f8e59d2f662
tif_gatt_client.c
96f50348c6b38ee4ac660fabf4b5676515c542e0 20-Mar-2014 Andre Eisenbach <andre@broadcom.com> am a4611ac0: DO NOT MERGE: cherrypick from master to fix b/13289050

* commit 'a4611ac05f07360785adcff8640da01a3894e4c5':
DO NOT MERGE: cherrypick from master to fix b/13289050
64ed24148d570f5a1c8ebeb2f0336b24ecc95b9c 20-Mar-2014 Andre Eisenbach <andre@broadcom.com> am 67020954: am a4611ac0: DO NOT MERGE: cherrypick from master to fix b/13289050

* commit '670209545cbf585165029d8866972ade111785c5':
DO NOT MERGE: cherrypick from master to fix b/13289050
670209545cbf585165029d8866972ade111785c5 20-Mar-2014 Andre Eisenbach <andre@broadcom.com> am a4611ac0: DO NOT MERGE: cherrypick from master to fix b/13289050

* commit 'a4611ac05f07360785adcff8640da01a3894e4c5':
DO NOT MERGE: cherrypick from master to fix b/13289050
a4611ac05f07360785adcff8640da01a3894e4c5 06-Mar-2014 Andre Eisenbach <andre@broadcom.com> DO NOT MERGE: cherrypick from master to fix b/13289050

LE: Add status callback function for LE broadcasts

Change-Id: If4342050ce1141a9c2111286e7b3cccdc012a91e
tif_gatt_client.c
487f9e43faeab586967f035e115af8bd63034ace 06-Mar-2014 Andre Eisenbach <andre@broadcom.com> LE: Add status callback function for LE broadcasts

Change-Id: If4342050ce1141a9c2111286e7b3cccdc012a91e
tif_gatt_client.c
fc3fba5db90f29b072ebecc231245c8f134b594b 13-Mar-2014 Zhihai Xu <zhihaixu@google.com> treat BTA_BUSY as success to avoid unpair the BLE device

when switch from peripheral mode, both server and client will
call btif_gatt_check_encrypted_link, the first call will start the
encryption. the second call will get callback with BTA_BUSY status,
before encryption complete, which cause unpair with the remote device.
we shouldnot treat BTA_BUSY as error.

bug:13417692
Change-Id: I065432dde2553e8ccee3a14a7b321b85bca8d3ba
tif_gatt_util.c
ea5a91bd3223b62712106e4b707301919bc6d32b 14-Mar-2014 Zhihai Xu <zhihaixu@google.com> am 07ea194a: Merge "DO NOT MERGE use bluetooth HID remote device name as input device name." into klp-dev

* commit '07ea194ac2518e98961632c4d1909f0af0809ea9':
DO NOT MERGE use bluetooth HID remote device name as input device name.
07ea194ac2518e98961632c4d1909f0af0809ea9 13-Mar-2014 Zhihai Xu <zhihaixu@google.com> Merge "DO NOT MERGE use bluetooth HID remote device name as input device name." into klp-dev
0d56a323a8ec323d4cf1d35edf4811781b7c781f 11-Mar-2014 Matthew Xie <mattx@google.com> am 1d454d1b: am f677f810: Merge "DO NOT MERGE Bluetooth: Cleanup bt_config.xml during BLE Scan" into klp-dev

* commit '1d454d1b88846b75bdd70508e51bd2a33211b0f8':
DO NOT MERGE Bluetooth: Cleanup bt_config.xml during BLE Scan
d9ba1402d356b77c274bdb6e00697512935d9b61 11-Mar-2014 Narayan Kamath <narayan@google.com> am 277ba466: Merge "Various fixes for LP64"

* commit '277ba466eb30755d2b158ebed650fd50b5701bee':
Various fixes for LP64
ad73b9c59961a622a5ec09b22a23a93f4c7bda1b 06-Dec-2013 Zhihai Xu <zhihaixu@google.com> DO NOT MERGE use bluetooth HID remote device name as input device name.

bug:12003067
Change-Id: I74e4921047a27ee79fa1e3cd58056fde2958e60f
tif_hh.c
1d454d1b88846b75bdd70508e51bd2a33211b0f8 11-Mar-2014 Matthew Xie <mattx@google.com> am f677f810: Merge "DO NOT MERGE Bluetooth: Cleanup bt_config.xml during BLE Scan" into klp-dev

* commit 'f677f81068640857f791276c472e34b08d08f3e6':
DO NOT MERGE Bluetooth: Cleanup bt_config.xml during BLE Scan
14225c9b89c9c45efa4fa069edfc749e6d06bfcb 11-Mar-2014 Matthew Xie <mattx@google.com> am 6bc62a36: Merge "Bluetooth: GAP: Update bonded device info immediately on NVRAM"

* commit '6bc62a368da0a434a4e01f7bcb3273bd52a07568':
Bluetooth: GAP: Update bonded device info immediately on NVRAM
5ef95e13f6e494ed586aa740aac41b6e95b836cc 10-Mar-2014 Matthew Xie <mattx@google.com> am f677f810: Merge "DO NOT MERGE Bluetooth: Cleanup bt_config.xml during BLE Scan" into klp-dev

* commit 'f677f81068640857f791276c472e34b08d08f3e6':
DO NOT MERGE Bluetooth: Cleanup bt_config.xml during BLE Scan
f677f81068640857f791276c472e34b08d08f3e6 10-Mar-2014 Matthew Xie <mattx@google.com> Merge "DO NOT MERGE Bluetooth: Cleanup bt_config.xml during BLE Scan" into klp-dev
a59793fda4f5a3b83a7c989db30f6cf61828dc2f 10-Mar-2014 Zhihai Xu <zhihaixu@google.com> am 27420a03: Merge "DO NOT MERGE BLE HID device connection failure due to security error." into klp-dev

* commit '27420a0327c04ce9407d2fe9138dde7f6dfe94e0':
DO NOT MERGE BLE HID device connection failure due to security error.
d3e78c06b112fe50959b4e30a5d4f90f8f83e4a3 10-Mar-2014 Zhihai Xu <zhihaixu@google.com> am ea8acc97: Merge "DO NOT MERGE fix a potential native crash during bluetooth sutdown" into klp-dev

* commit 'ea8acc971f7c01427fd239e54344b43ac1a31e1c':
DO NOT MERGE fix a potential native crash during bluetooth sutdown
9fc2745f361388e8dee879518ee292369e2124f8 10-Mar-2014 Zhihai Xu <zhihaixu@google.com> am 1e0849e9: Merge "DO NOT MERGE the HID device state is out of sync after upair." into klp-dev

* commit '1e0849e99bdd716b7e172269cdad1d78b60a7ded':
DO NOT MERGE the HID device state is out of sync after upair.
b9912730d082c7bca7d94bb9ddac4447cfad362f 13-Nov-2013 Zhihai Xu <zhihaixu@google.com> DO NOT MERGE BLE HID device connection failure due to security error.

When HID BLE device start encryption, if some other GATT application
already start encryption(but not finished yet) by calling
gatt_security_check_start. The HID BLE device will be failed to start
encryption, which will cause it to disconnect the BLE HID connection.
The solution is to check whether we already started the encryption
, If the encryption is already started, wait until the encryption
finished, then continue to start security check for BLE HID device.
add encrytion complete event to notify all GATT client encryption done.
filter the event just for BTA HH LE GATT client.

bug:11636246
Change-Id: If58e57c623cc8cfa05208587b010bec68c71306c
tif_gatt_test.c
5a79e080ef667e7c623ef46da6086915087c7488 26-Nov-2013 Zhihai Xu <zhihaixu@google.com> DO NOT MERGE fix a potential native crash during bluetooth sutdown

When bluetooth is initialized which call gki_buffer_init,
the buffer pool is allocated by GKI_os_malloc which is
to call libc malloc function.
When bluetooth is cleanup which call GKI_shutdown,
the buffer pool will be freed by GKI_os_free
which is to call libc free function.
So if we access the buffer, after the whole buffer pool is freed,
we will get this native crash.
if we call cleanup during bluetooth disabling:
the state is still BTIF_CORE_STATE_DISABLING,
then GKI_shutdown will call before bte_main_disable
( bt_hc_if->cleanup();), which is before userial thread exit.
Then we may trigger this native crash.

bug:11793775
Change-Id: Ic8ced12848d25f918a28f4d5ba29b803d6ac5bd7
luetooth.c
tif_core.c
35f6b7f3f8b483065e9d97c18542286818e02544 16-Nov-2013 Zhihai Xu <zhihaixu@google.com> DO NOT MERGE the HID device state is out of sync after upair.

the HID device state is out of sync between java layer and bluedroid stack after upair.
This will cause the HID device can't be connected after repair.
YOu can find the following error message
E/HidService( 1452): Hid Device not disconnected: 00:15:9E:20:29:41

bug:11718702
Change-Id: I271bb77a2cc205c5a0ef396db86b87902d29966b
tif_hh.c
89d4f0a9fcfe66618fb771a5f85bf4e50693ee23 08-Mar-2014 Andre Eisenbach <andre@broadcom.com> am b74fe9e2: DO NOT MERGE LE: Add service UUIDs and data to advertising data

* commit 'b74fe9e2c9fc0939f5c18282c985622f20b78d2a':
DO NOT MERGE LE: Add service UUIDs and data to advertising data
0798eb9cf9259bcfa3b8583d1de2c73456649cf3 07-Mar-2014 Mike J. Chen <mjchen@google.com> am bac0e60f: am 303a1272: am f6918978: Add HID handshake_callback

* commit 'bac0e60f37d577e5b1a47ff52c8f2a96142ee4e7':
Add HID handshake_callback
303a12727c96f6e39c31b0ef6a6017b5ef7972c0 07-Mar-2014 Mike J. Chen <mjchen@google.com> am f6918978: Add HID handshake_callback

* commit 'f691897800e086b6caf238ee78d560526e69c67d':
Add HID handshake_callback
a7bd2a1084569fb7170ebc62b1a2030a6865b797 24-Jan-2014 Srinu Jella <sjella@codeaurora.org> Bluetooth:GAP: Add NULL check before accessing accept socket

Add NULL check before accessing accept_rs variable to
avoid null pointer exception while referring to invalid
memory.

Change-Id: Ibc38d1c2fb19eb171cf136c47248ad8828676ac1
tif_sock_rfc.c
aefcb184639ff24bf294dfa4f91bd22202d1f93e 20-Nov-2013 Sunny Kapdi <sunnyk@codeaurora.org> DO NOT MERGE Bluetooth: Cleanup bt_config.xml during BLE Scan

BLE Scan needs to clean up the bt_config.xml periodically so that
new entries could be added to bt_config.xml. Also, there is no
need to add BLE Random bd_addr to the bt_config.xml

Change-Id: I00ba2e50dd39a021099052cb569786f6cb2cc8b9

b/12912008
(cherry picked from commit 377cb1407ee6ee1ff91b15bfa7052abed1023d18)

Change-Id: I3fa0286c96782822a8fdac14b05bbb6f98636e50
tif_gatt_client.c
tif_storage.c
b74fe9e2c9fc0939f5c18282c985622f20b78d2a 08-Nov-2013 Andre Eisenbach <andre@broadcom.com> DO NOT MERGE LE: Add service UUIDs and data to advertising data

Add support for UUIDs and custom service data in the advertising and
scan response records.

Cherry picking ble advertising changes from master to KLP MR2.
b/13137996

Change-Id: I6470427ad194871488cc90f3ab384b9ecf326b15
tif_gatt_client.c
bbd585e19920a0eaa209057a5c4f97ead9063fee 05-Mar-2014 Mike J. Chen <mjchen@google.com> am 8dfc3e29: am 84516150: am be6d58f3: Fix GKI exception of calling free on an already freed buffer

* commit '8dfc3e2992456539ee6c740199f543cdb0d5a9d3':
Fix GKI exception of calling free on an already freed buffer
845161504098dcfdf8874f6ec592642f40b57547 05-Mar-2014 Mike J. Chen <mjchen@google.com> am be6d58f3: Fix GKI exception of calling free on an already freed buffer

* commit 'be6d58f35e66b9e57cf4978be68840cbc8ac2fc9':
Fix GKI exception of calling free on an already freed buffer
f691897800e086b6caf238ee78d560526e69c67d 25-Feb-2014 Mike J. Chen <mjchen@google.com> Add HID handshake_callback

It is called when the equivalent pkt is received from the HID
client as a normal response to set_report() and set_protocol_mode(),
and for errors for get_report() and get_protocol_mode().

Change-Id: I26ec37348e597f294f83907bbd256c88db5ac2ef
Signed-off-by: Mike J. Chen <mjchen@google.com>
tif_hh.c
be6d58f35e66b9e57cf4978be68840cbc8ac2fc9 25-Feb-2014 Mike J. Chen <mjchen@google.com> Fix GKI exception of calling free on an already freed buffer

Various parts of btif_hh.c were creating GKI buffers and
keeping references to them and freeing them in odd and
unnecessary ways. The buffer is freed by lower levels
of the stack once the buffer has been sent to the chip
at the l2c layer and shouldn't be freed by btif_hh itself
since it's possible to double free, and there could
also be race conditions with other threads already processing
the buffer while the reference is freed if the API calls
are invoked again before the previous invocation was completely
processed.

Also added a helper routine to simplify buffer creation and
initialization.

Change-Id: Ia6039983502e2670b2325d90310244edf843b692
Signed-off-by: Mike J. Chen <mjchen@google.com>
tif_hh.c
2eda01018250d9253bc54da9f6896d58dba1f601 27-Feb-2014 Narayan Kamath <narayan@google.com> am de34aea5: am 5303f9d3: resolved conflicts for merge of 277ba466 to klp-modular-dev-plus-aosp

* commit 'de34aea544cb4222f24e4157b96962b09445e2c5':
Various fixes for LP64
5303f9d369946f43167b5e2423799d30c4455df1 27-Feb-2014 Narayan Kamath <narayan@google.com> resolved conflicts for merge of 277ba466 to klp-modular-dev-plus-aosp

Change-Id: Idc42f72a94c205cfe94feb220651a483cf418e84
22c6e505dc65ab3d624e4ccd7c48c95fe2128703 12-Feb-2014 Kévin PETIT <kevin.petit@arm.com> Various fixes for LP64

Changes include
- Cast numbers to their proper length before casting to a pointer.
- Use intptr_t when pointers are stored as integers.
- Eliminate 'implicit declaration' warnings

Signed-off-by: Matthew Leach <matthew.leach@arm.com>
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>

Change-Id: I5664a087c5fbc322baa9178552404dbe9a992359
tif_sock_rfc.c
tif_sock_thread.c
0977fc84e0314b7b71668885a433f5ad4b6ec49c 26-Feb-2014 Matthew Xie <mattx@google.com> am e736740d: am 5834e63b: am 759280ee: Merge "bluetooth: hid: store ssr_max_latency and ssr_min_tout in bonding db" into klp-modular-dev

* commit 'e736740ded718c76c0007baa97b7f55e69ceb1b1':
bluetooth: hid: store ssr_max_latency and ssr_min_tout in bonding db
5834e63bd410d708d8764f69ede256ca0ed98635 26-Feb-2014 Matthew Xie <mattx@google.com> am 759280ee: Merge "bluetooth: hid: store ssr_max_latency and ssr_min_tout in bonding db" into klp-modular-dev

* commit '759280ee1f92945ed7c1c13f5ff8a037fa3bf3e4':
bluetooth: hid: store ssr_max_latency and ssr_min_tout in bonding db
759280ee1f92945ed7c1c13f5ff8a037fa3bf3e4 26-Feb-2014 Matthew Xie <mattx@google.com> Merge "bluetooth: hid: store ssr_max_latency and ssr_min_tout in bonding db" into klp-modular-dev
afd4a5740e2193e7ce8dbedb8787b19f7c0016cd 25-Feb-2014 Zhihai Xu <zhihaixu@google.com> am 2ac65164: am 75c7597c: am 4fbbe711: Merge "support peripheral mode feature to connect iphone to android device." into klp-modular-dev

* commit '2ac6516450336e2ec5ccbbefa0221276ea291695':
support peripheral mode feature to connect iphone to android device.
75c7597c94a7d8ee5c79b75ccaede02f53dd7c9f 25-Feb-2014 Zhihai Xu <zhihaixu@google.com> am 4fbbe711: Merge "support peripheral mode feature to connect iphone to android device." into klp-modular-dev

* commit '4fbbe7115dd7c2f8b0df386fad4085f411beeef3':
support peripheral mode feature to connect iphone to android device.
4fbbe7115dd7c2f8b0df386fad4085f411beeef3 25-Feb-2014 Zhihai Xu <zhihaixu@google.com> Merge "support peripheral mode feature to connect iphone to android device." into klp-modular-dev
602162a13c6ed8abae53aee6deeda48b79f30911 10-Feb-2014 Zhihai Xu <zhihaixu@google.com> support peripheral mode feature to connect iphone to android device.

enable BLE_PERIPHERAL_MODE_SUPPORT flag and fix the bug
the discoverability flag is not set in advertisement packet,
which cause the central device(iphone) can not find android device
during scan.
use displayOnly IO cap for dory, so dory can display the pin,
and the iphone(central device) will input the pin.
bug:12797572

Change-Id: Ie15ea9e340e3692df846399b9a85aa6d2a97eba7
tif_gatt_client.c
7e6b379268f973752863e333b55e6068373e1664 24-Feb-2014 Matthew Xie <mattx@google.com> am 9d368b68: am 1292dd82: am 6bc62a36: Merge "Bluetooth: GAP: Update bonded device info immediately on NVRAM"

* commit '9d368b68841dee6e6f581a3890433dcdc022fbb8':
Bluetooth: GAP: Update bonded device info immediately on NVRAM
1292dd82812d76c54568796fbdafd1fdadc816eb 24-Feb-2014 Matthew Xie <mattx@google.com> am 6bc62a36: Merge "Bluetooth: GAP: Update bonded device info immediately on NVRAM"

* commit '6bc62a368da0a434a4e01f7bcb3273bd52a07568':
Bluetooth: GAP: Update bonded device info immediately on NVRAM
ffc69cc3173ffc190fd77686ae12cf3fa95a5b07 22-Feb-2014 Matthew Xie <mattx@google.com> Merge "Bluetooth: Cleanup bt_config.xml during BLE Scan"
377cb1407ee6ee1ff91b15bfa7052abed1023d18 20-Nov-2013 Sunny Kapdi <sunnyk@codeaurora.org> Bluetooth: Cleanup bt_config.xml during BLE Scan

BLE Scan needs to clean up the bt_config.xml periodically so that
new entries could be added to bt_config.xml. Also, there is no
need to add BLE Random bd_addr to the bt_config.xml

Change-Id: I00ba2e50dd39a021099052cb569786f6cb2cc8b9

b/12912008
tif_gatt_client.c
tif_storage.c
5e08d1ec92555e2cb3d80f1a9a3c746c76ed3e5d 21-Nov-2013 Srinu Jella <sjella@codeaurora.org> Bluetooth: GAP: Update bonded device info immediately on NVRAM

As the new bt-if config updation have delay in writing items
to the NVRAM, some times there is a chance of not updating
incase of battery removal happens before the actual write onto
NVRAM.

As the bonded device info is important data to store, it will
update bonded info immediately onto NVRAM.

Change-Id: I9699c8225a77d9272420334b4c76b3c1df87e459
tif_storage.c
8351ea3d6dcc6c1663d07969c16b2fd9d059ea5b 15-Feb-2014 Mike J. Chen <mjchen@google.com> am 0c880603: am 6a342588: am 136e4b1c: Merge "Don\'t send a dummy 0 HID event when connection is closed" into klp-modular-dev

* commit '0c880603dba9f9f09523509f19c6808ba8f52e12':
Don't send a dummy 0 HID event when connection is closed
bf6cab9332f81f7bcd4b3040c2c1edd3062ecb40 14-Feb-2014 Mike J. Chen <mjchen@google.com> Don't send a dummy 0 HID event when connection is closed

This was put there by Broadcom to try to handle held keys
on disconnect, but the best place to do that is in InputManager.
There's no guarantee that a report_id 1 is keyboard, and
in particular it causes game controllers to get a false
joystick move event to 0,0.

Bug 12785130

Change-Id: I85fbafa44d927082def3848132344550e8b94bb0
Signed-off-by: Mike J. Chen <mjchen@google.com>
tif_hh.c
3a7ff0d45c2086bc990c2fbbdb862e4e962916b7 12-Feb-2014 Mike J. Chen <mjchen@google.com> am e80e4df1: am b45e54f0: Merge "Fix warnings when BLE_INCLUDED is FALSE" into klp-modular-dev

* commit 'e80e4df1f9b9b60be37ef8ad854d7b46b9dbfb83':
Fix warnings when BLE_INCLUDED is FALSE
bf9a8aa26988aedbc161d75f2688641ce59dc001 11-Feb-2014 Mike J. Chen <mjchen@google.com> Fix warnings when BLE_INCLUDED is FALSE

Change-Id: I27c8ac6d5410159ed6bbef6aca5bf3b9692b0467
Signed-off-by: Mike J. Chen <mjchen@google.com>
luetooth.c
85c1751ac78a4b9ae9f2250130000755081905fb 11-Feb-2014 Mike J. Chen <mjchen@google.com> am 3d4f5c71: am b83a8234: Merge changes Ifc373f95,I95eb887a,I1e6be2ab,Ia6ea939a,I147d0138, ... into klp-modular-dev

* commit '3d4f5c715204c3c5eeb21e351aff73072000f61e': (24 commits)
Make all warnings fatal compilation errors
Major warnings cleanup
Add macro UNUSED() to bt_utils.h
Fix unused parameter warning in static function
Add "static" to a static function
Fix a number of unused parameter warnings in static functions
Fix bug with wrong parameter passed to logu
Default send_ind_evt should be FALSE
Fix warning "implicit declaration of function 'GAP_BleReadPeerPrefConnParams'"
Fix unused parameter warnings in static functions by changing prototype
Fix some unused parameter warnings in static functions
Fix warnings about implicit declaration of bdcmp and bdcpy
Fix warning "comparison is always true due to limited range of data type"
Fix warning "suggest braces around empty body in an 'if' statement"
Fix warning "comparison is always true due to limited range of data type"
Add a function prototype for btm_ble_test_command_complete
Change argument to return ptr rather than assign to unused local
Fix warning "comparison is always true due to limited range of data type"
Fix warnings about implicit declarations
Fix warning "implicit declaration of function 'bdcmp'"
...
5cd8bff2dd0337cb52bf48f312e3d2d55a8882fb 01-Feb-2014 Mike J. Chen <mjchen@google.com> Major warnings cleanup

Mostly fixing unused parameter warnings.
A few other warnings also fixed like possible use of
unitialized variables (no real issue found, just compiler couldn't
follow the path), signed vs unsigned warning.

Also fixed some typos, indent issues, removal of dead code, etc.

Change-Id: I95eb887aefc4d559d7921f71a0af5f3bfb01ac01
Signed-off-by: Mike J. Chen <mjchen@google.com>
luetooth.c
tif_av.c
tif_config.c
tif_core.c
tif_dm.c
tif_gatt_test.c
tif_hf.c
tif_hh.c
tif_hl.c
tif_media_task.c
tif_pan.c
tif_rc.c
tif_sock_rfc.c
d8edb46866ca4f2d9ee61330db78d25352cfbf27 28-Jan-2014 Mike J. Chen <mjchen@google.com> am e372d9b5: Merge "Fix HID get_report callback support" into klp-modular-dev

* commit 'e372d9b58a288348782d01f534cf6dc81a7934c7':
Fix HID get_report callback support
b46d9b899f5e28929c8530cb99d023c93e5d5cb8 24-Jan-2014 Mike J. Chen <mjchen@google.com> Fix HID get_report callback support

There were multiple bugs in the code for get_report event
callback handling:

1) the p_dev lookup was using the wrong argument so was coming
up with NULL ptr and passing it through to the callback

2) the BT_HDR * was being passed to the callback instead of a
ptr to the payload

3) the size was being passed as a constant BT_HDR_SIZE.

It looked like this code was expecting the callback to parse
the BT_HDR, but that's an internal bluedroid structure.
The callback is defined as receiving the report data and the
report data size, which this change now provides.

Note that the payload might be NULL if the device returns
a HANDSHAKE error msg instead, and so it is valid to pass
the callback a NULL payload ptr and a 0 size.

Change-Id: I462b5cb5d4c460af085dc6e15f59c778a020a80e
Signed-off-by: Mike J. Chen <mjchen@google.com>
tif_hh.c
8a82348c04109cb85e3c0b676dd1c7c5cb461c24 27-Jan-2014 Adam Hampson <ahampson@google.com> bluetooth: hid: store ssr_max_latency and ssr_min_tout in bonding db

Store the ssr_max_latency and ssr_min_tout parameters in the
bonding database. Previously these parameters were not stored for HID
devices. This caused an inconsistency in sniff behavior between
when the HID device was paired and following a reboot of the host.

When the HID device is paired the SSR parameters are retrieved
from the HID device and are stored in the HID Host's device list.
If the host is rebooted then the HID Host's device list is
constructed from the bonding database.

If the SSR max latency is non-zero then the SSR parameters are
sent to the firmware and SSR is used. In the event that the SSR
max latency is 0, as it is if the parameters are not found, then
SSR is disabled.

Bug: 12764547

Change-Id: I63637575fdfcf4cb4ca0ce8dc2e4ccda9cccaf66
Signed-off-by: Adam Hampson <ahampson@google.com>
tif_hh.c
tif_storage.c
ddcf2f98fe6dbb6a130e77595caa67164185df50 16-Jan-2014 Zhihai Xu <zhihaixu@google.com> Merge "increase the bluetooth task priority when start a2dp."
4128e36cd8430dfbed16d364e6ab5265e1642db5 08-Jan-2014 Zhihai Xu <zhihaixu@google.com> increase the bluetooth task priority when start a2dp.

change the BT task priority based on audio play state.
increase the BT task priority to ANDROID_PRIORITY_URGENT_AUDIO
,when start ad2p audio playing.
to better prevent CPU premption by other process/task(UI).
restore the BT task priority when stop a2dp audio playing.

bug:12082841
Change-Id: I34e8344cffea87f68987149c820cd3e84a4196d1
tif_av.c
eeeac99328c23304ab24698331b6600f3b545700 08-Nov-2013 Andre Eisenbach <andre@broadcom.com> LE: Add service UUIDs and data to advertising data

Add support for UUIDs and custom service data in the advertising and
scan response records.

Change-Id: I6470427ad194871488cc90f3ab384b9ecf326b15
tif_gatt_client.c
2a2701cdddac0859a95e58aec542742c450145b9 16-Sep-2013 Kim Schulz <k.schulz@samsung.com> Fixes for problems found with coverity analyzer

- fixed UNINITIALIZED variable (hdl) in bta_hh_act.c :220
- fixed possible RESOURCE LEAK in btif_config_util.cpp in relation to open_file_map() if file is fd size=0
- fixed possible RESOURCE LEAK in create_socket_server() in uipc:196 (s not closed)
- fixed possible OVERRUN in l2c_csm.c, (l2c_csm_config), array "l2cb.fixed_reg" of 4 20-byte elements at element index 60 (byte offset 1200) using index "p_ccb->local_cid - 3" (which evaluates to 60)
- fixed possible OVERRUN in btm_pm.c, (btm_pm_reset) array "btm_cb.acl_db" of 7 288-byte elements at element index 7 (byte offset 2016) using index "btm_cb.pm_pend_link" (which evaluates to 7).
- fixed possible OVERRUN in btif_storage.c, (btif_storage_add_device_to_autopair_blacklist) array "input_value" of 20 bytes by passing it to a function which accesses it at byte offset 20 using argument "20U".
patch set 2:
- fixed {}
Patch set 3:
- fixed review commment in stack/btm/btm_pm.c:379

bug: 10777562
Change-Id: I2a6d57f93acaaf9b25c49a6a29cb60d0e1e3c5d8
tif_config_util.cpp
tif_storage.c
41b33913995e5baf53461fe50f836717c2a47db9 16-Dec-2013 Zhihai Xu <zhihaixu@google.com> Merge " the HID device state is out of sync after upair."
03c26931a463dd079bda26bfd19f323743f57f3e 16-Nov-2013 Zhihai Xu <zhihaixu@google.com> the HID device state is out of sync after upair.

the HID device state is out of sync between java layer and bluedroid stack after upair.
This will cause the HID device can't be connected after repair.
YOu can find the following error message
E/HidService( 1452): Hid Device not disconnected: 00:15:9E:20:29:41

bug:11718702
Change-Id: I271bb77a2cc205c5a0ef396db86b87902d29966b
tif_hh.c
491cc70bac4e6fddd9728a184a58e4907b3beab5 16-Dec-2013 Zhihai Xu <zhihaixu@google.com> Merge "fix a potential native crash during bluetooth sutdown"
6c65c2f3a372885a976c14b3ccacd0b5a5fbb8bd 26-Nov-2013 Zhihai Xu <zhihaixu@google.com> fix a potential native crash during bluetooth sutdown

When bluetooth is initialized which call gki_buffer_init,
the buffer pool is allocated by GKI_os_malloc which is
to call libc malloc function.
When bluetooth is cleanup which call GKI_shutdown,
the buffer pool will be freed by GKI_os_free
which is to call libc free function.
So if we access the buffer, after the whole buffer pool is freed,
we will get this native crash.
if we call cleanup during bluetooth disabling:
the state is still BTIF_CORE_STATE_DISABLING,
then GKI_shutdown will call before bte_main_disable
( bt_hc_if->cleanup();), which is before userial thread exit.
Then we may trigger this native crash.

bug:11793775
Change-Id: Ic8ced12848d25f918a28f4d5ba29b803d6ac5bd7
luetooth.c
tif_core.c
b3724709a0893d5abab42c459776d47f0ec17781 16-Dec-2013 Zhihai Xu <zhihaixu@google.com> Merge "implement flow control to avoid dropping packets in btif_media_task."
4aebca4662c280fdc32e0ad3705cae064bfa068d 19-Sep-2013 Zhihai Xu <zhihaixu@google.com> implement flow control to avoid dropping packets in btif_media_task.

implment flow conrol to save CPU usage and avoid dropping
packet in btif_media_task when overflow and cpu preemption happen.
when the packet count in the queue is above high watermark, we will
stopping adding packets, when the packet count in the queue is below
low watermark, we will start adding packets again.

bug:8252054
Change-Id: I3b7795dffbe5f2ae455e239a0234533f6cbb4403
tif_media_task.c
f507e5ea3fb41303af92b8491e9e925e1ade9326 16-Dec-2013 Zhihai Xu <zhihaixu@google.com> Merge "should return correct length and use shorter poll time for ad2p data"
01c686ce0051433d75605ff9ca4c3b7388ce3b6b 16-Sep-2013 Zhihai Xu <zhihaixu@google.com> should return correct length and use shorter poll time for ad2p data

the default poll timeout(100ms) is too long for a2dp data read,
because the a2dp timer pertiod to read data is 20ms. The poll timeout
should be far less than a2dp timer pertiod. also when poll timeout happen
for read, we should return the data length which we already read instead of 0.

bug:8252054
Change-Id: Ifa8587c6b7d127cbbbff76d9e20b630303b6379f
tif_media_task.c
f081595669be4242c7e23f850d83d9b876612bec 11-Dec-2013 Zhihai Xu <zhihaixu@google.com> Merge "BLE HID device connection failure due to security error."
7051db3a486aae771d9b5a81c3546790f86ede34 13-Nov-2013 Zhihai Xu <zhihaixu@google.com> BLE HID device connection failure due to security error.

When HID BLE device start encryption, if some other GATT application
already start encryption(but not finished yet) by calling
gatt_security_check_start. The HID BLE device will be failed to start
encryption, which will cause it to disconnect the BLE HID connection.
The solution is to check whether we already started the encryption
, If the encryption is already started, wait until the encryption
finished, then continue to start security check for BLE HID device.
add encrytion complete event to notify all GATT client encryption done.
filter the event just for BTA HH LE GATT client.

bug:11636246
Change-Id: If58e57c623cc8cfa05208587b010bec68c71306c
tif_gatt_test.c
0b93f5ce4df14aa3d3100a8f9609a1c7ea4cdbd9 06-Dec-2013 Zhihai Xu <zhihaixu@google.com> use bluetooth HID remote device name as input device name.

bug:12003067
Change-Id: I74e4921047a27ee79fa1e3cd58056fde2958e60f
tif_hh.c
d3f44782195519d97589f2362e5a8879ee7b62ff 04-Dec-2013 Zhihai Xu <zhihaixu@google.com> Merge "Pairing with dissapeard HID decive never times out (in UI)"
a9eb25c8c01e70613bace21b23a06bd9a10871b1 30-Sep-2013 Kim Schulz <k.schulz@samsung.com> Pairing with dissapeard HID decive never times out (in UI)

- added function to notify the UI about failed HID pairing

patch set2:
- added function header

patch set3:
- break long line

Bug: 10998578
Change-Id: I7314bf07da7ebac7252c6902d987fbca20da2abc
tif_dm.c
tif_hh.c
b0a43da3b412f53557125bf352dd9dddfd1a9991 24-Sep-2013 Kim Schulz <k.schulz@samsung.com> memset arguments wrongfully swapped

the arguments for one of the memset calls was wrong.

Bug: 10907215
Change-Id: Ie00a3a6b829b99fd94659a764b6f0309684d9303
tif_storage.c
767b2f98f168f8e4822598cb7b35f10bf586aa8a 07-Nov-2013 Matthew Xie <mattx@google.com> am 04e05e9a: Merge "LE: Add devices to the inquiry db before connecting" into klp-dev

* commit '04e05e9a39cbed22a099458c35207795a0039043':
LE: Add devices to the inquiry db before connecting
306bddadeec993013cfed6bf0e41a1a47a69367c 07-Nov-2013 Andre Eisenbach <andre@broadcom.com> LE: Add devices to the inquiry db before connecting

Ensure that the remote device type is set correctly by reading the
device information from non-volatile storage and (re-)adding it to
the inquiry database before connecting to a remote GATT device.
bug 11573208
Change-Id: Ifa69da3d5871aed5293ea5e611144874b67afe72
tif_gatt_client.c
tif_gatt_server.c
tif_gatt_util.c
43fb9ada63dc76542f25d9510ca5f60bd66ef8e4 07-Nov-2013 Matthew Xie <mattx@google.com> am 6088d83d: Merge "whitelist well tested devices for absolute volume feature" into klp-dev

* commit '6088d83d6ce30275b15fd0e5955a83f709f03172':
whitelist well tested devices for absolute volume feature
6088d83d6ce30275b15fd0e5955a83f709f03172 07-Nov-2013 Matthew Xie <mattx@google.com> Merge "whitelist well tested devices for absolute volume feature" into klp-dev
7850a939f3c33a0bada9b9e2cd335189614a5ef9 06-Nov-2013 Matthew Xie <mattx@google.com> whitelist well tested devices for absolute volume feature

We are blacklisting all the devices that are not in whitelist
instead of blacklisting known bad devices.
bug 11124170

Change-Id: I044970df611d2a800d7698d4a63331644ab107ce
tif_rc.c
7391a6fbda12f838f51ca7a4bd1cc44cb9e0a05c 06-Nov-2013 Zhihai Xu <zhihaixu@google.com> am 29fdb17a: Merge "need to save the BLE HID UUID to NVRAM" into klp-dev

* commit '29fdb17a232f45c5550e7fa8d773f87e06ac58f1':
need to save the BLE HID UUID to NVRAM
d7ee77bf8bb7f009b8088c15dcf5458b6f1fd05d 06-Nov-2013 Zhihai Xu <zhihaixu@google.com> need to save the BLE HID UUID to NVRAM

need to save the BLE HID UUID to NVRAM.
otherwise we will miss the HID profile setting
in device profile list of the BLE HID device after reboot.

bug:11541617
Change-Id: I11e1c871768e999ec1f48396018c3be379cc1b7d
tif_dm.c
f47598b9d6242435a96be1b6e7d3ffa31463ed88 25-Oct-2013 Matthew Xie <mattx@google.com> am 93449a36: Merge "Blacklist Devices that donot handle absolute volume well" into klp-dev

* commit '93449a36de3b17e95f442ebd49614fa30707cbbb':
Blacklist Devices that donot handle absolute volume well
a7ae4a15e954fe143326d4f869f8dac8e76ee8ce 24-Oct-2013 Matthew Xie <mattx@google.com> Blacklist Devices that donot handle absolute volume well

Use vendor prefix address, include hbs730 headset, passat carkit
bug 11124170

Change-Id: I80f634366ce332c55581d7b1e36641e5ce3ad346
tif_rc.c
52d0d8d67b41d81b494c8f3de0eb40bd7ee4e751 13-Oct-2013 zzy <zhenye@broadcom.com> am 031d239b: When rfcomm incoming queue is not empty, waiting for app ready to drain the data

* commit '031d239b408618294a5980cb3933e03e185f96cf':
When rfcomm incoming queue is not empty, waiting for app ready to drain the data
031d239b408618294a5980cb3933e03e185f96cf 09-Oct-2013 zzy <zhenye@broadcom.com> When rfcomm incoming queue is not empty, waiting for app ready to drain the data

Fixed the issue that rfcomm inbound packets could be out of order when host
flow control is activating.
bug 11031800

Change-Id: Idc1eb6633bb070f1ab2b33a9751fd7d714764d45
tif_sock_rfc.c
0b132028e5f16ca474a920f400dc8a87d49405d7 10-Oct-2013 Matthew Xie <mattx@google.com> am 65b8e0f3: Merge "Remove MMS support from MAP SDP" into klp-dev

* commit '65b8e0f360f7fe7be001087c899eebc507115f9d':
Remove MMS support from MAP SDP
65b8e0f360f7fe7be001087c899eebc507115f9d 10-Oct-2013 Matthew Xie <mattx@google.com> Merge "Remove MMS support from MAP SDP" into klp-dev
85f334eb26bb2d16741f61c2ea538f6c1f6bec4b 10-Oct-2013 Matthew Xie <mattx@google.com> am 6b728e41: Merge "Interleave br/edr device discovery with BLE device scan for some targets" into klp-dev

* commit '6b728e412c22549ef51c19315ccf9ab3b7e16885':
Interleave br/edr device discovery with BLE device scan for some targets
6b728e412c22549ef51c19315ccf9ab3b7e16885 10-Oct-2013 Matthew Xie <mattx@google.com> Merge "Interleave br/edr device discovery with BLE device scan for some targets" into klp-dev
7f3e42943b834ff0f556cd5c063a896f54d53167 30-Sep-2013 Matthew Xie <mattx@google.com> Interleave br/edr device discovery with BLE device scan for some targets

This change only applies to targets which do not support interleaved scan
in controller.
bug 8508849

Change-Id: Ia99faf92c942b4b33abfde2708eff25ec9cd5468
tif_dm.c
71c1c591dbe9f44e496ea2ff9d974d6ae7bce62f 10-Oct-2013 zzy <zhenye@broadcom.com> am 7939ed0c: added filter remove api to control the # of child node for bt_config.xml

* commit '7939ed0c9a50c769e9e648a2d7751e0894b485ed':
added filter remove api to control the # of child node for bt_config.xml
7939ed0c9a50c769e9e648a2d7751e0894b485ed 28-Sep-2013 zzy <zhenye@broadcom.com> added filter remove api to control the # of child node for bt_config.xml

Bug 10949832

Change-Id: I10589b9d0a0b4b8d7cbf66122c66bb2e99be04a1
tif_config.c
tif_storage.c
41d651a95ad63519e28f23f39a5c31c2dd0c8574 09-Oct-2013 Matthew Xie <mattx@google.com> Remove MMS support from MAP SDP

When we support MMS in the future. Revert this patch.
bug 10296324

Change-Id: I9d65895d6cb55b3967efcddc2c37b3f95ba3ce38
tif_sock_sdp.c
0819fa24e289d9f1cc3c4dd75e5dee2b1a8505bf 05-Oct-2013 Zhihai Xu <zhihaixu@google.com> am 379743be: Failure to start playback on A2DP sink after connection

* commit '379743beded881127703334e1dda2cd327ec651d':
Failure to start playback on A2DP sink after connection
379743beded881127703334e1dda2cd327ec651d 29-Sep-2013 Zhihai Xu <zhihaixu@google.com> Failure to start playback on A2DP sink after connection

This is what happen:
after Headset is connected, we call start_audio_datapath which will send AVDTP_Start command to Headset,
Headset reject it with bad state. Bluedroid stack will ack failure to start_audio_datapath.
The next time we write audio data to bluetooth, we will call start_audio_datapath again to send AVDTP_Start command to Headset
Headset reject it with bad state again. Bluedroid stack will ack failure to start_audio_datapath.
When the third time we call start_audio_datapath, right at that time we receive AVDTP_Start command from Headset.
Handle AVDTP_Start command and Handle start_audio_datapath are in two different threads.
Handle AVDTP_Start command is in btu_task thread.
Handle start_audio_datapath() is in btif_task thread.
We have race condition in this case
Because when btif_task processed BTIF_AV_START_STREAM_REQ_EVT(triggered by start_audio_datapath),
it don't know we receive AVDTP_Start command which is processed in btu_task.
btif_task will send a message BTA_AV_API_START_EVT to btu_task, which will be handled by bta_av_do_start.
AVDTP_start command from headset is handled by bta_av_start_ok.
bta_av_start_ok will send BTA_AV_START_EVT with suspending true to btif_task and send AVDTP_Suspend command
to headset to suspend the AVDTP for reconfiguration purpose.

in bta_av_do_start, we will check whether the AVDTP is already started, we will know the AVDTP is already start at this time because
bta_av_do_start is also running in btu_task. We will send BTA_AV_START_EVT with success to btif_task.

In the btif_task, BTA_AV_START_EVT will be processed by btif_av_state_opened_handler:
For the first BTA_AV_START_EVT with suspending true sent by bta_av_start_ok, it will ignore it:
if ((p_av->start.status == BTA_SUCCESS) && (p_av->start.suspending == TRUE))
return TRUE;
For the second BTA_AV_START_EVT with success sent by bta_av_do_start , it will ack success to start_audio_datapath, and change to
BTIF_AV_STATE_STARTED/BTAV_AUDIO_STATE_STARTED, after receive success ack from bluedroid stack, we will start send Audio data to bluetooth.

At last we received AVDTP_Suspend response accept from Headset, we will send BTA_AV_SUSPEND_EVT to btif_task, which will be
handled by btif_av_state_started_handler. It will call btif_a2dp_on_suspended and call audio_state_cb with new audio state
BTAV_AUDIO_STATE_STOPPED.
so The state between bluedroid stack and audio data path is out of sync.
The fix is to send failure message if we know we suspend AVDTP in bta_av_do_start,
also make sure we won't miss acknowledgement for pending start if we exit opened state,
to avoid audio data path dead lock.

bug:10953908
Change-Id: I1704839977324b7c4e234eb843cddf3719e10d2c
tif_av.c
tif_media_task.c
3975936fa35873ada869644d0903cb83d7d4a3b9 27-Sep-2013 Matthew Xie <mattx@android.com> am a3c389f3: Merge "Avoid potential buffer overrun in bd2str caused by signed char"

* commit 'a3c389f35287c9b1642c6f9a35fd22ff28f47919':
Avoid potential buffer overrun in bd2str caused by signed char
f2fc54d237a24dc4db307cb56a513a8720809f95 02-Jul-2013 Chris Dearman <chris.dearman@imgtec.com> Avoid potential buffer overrun in bd2str caused by signed char

Use uint8_t to avoid sign extension as char's may be signed.
As a further safeguard, use snprintf()

Change-Id: Icdd4dba9b270bde41547677fa2f98bf215401a23
tif_util.c
a30d95acf60f04531923e8ab06d976744697bf51 18-Sep-2013 Matthew Xie <mattx@google.com> Increase default bluetooth name from 15 to 31.

bug 7441329

Change-Id: I79d64e77f206268ace06ce0f7b16119f63655bec
tif_dm.c
b8ceaa484a09be14263d5f10d022a272f9602378 05-Apr-2013 Mattias Agren <magren@broadcom.com> Set default a2dp sbc encoding quality to high

* Increased bitpool to high quality setting (53). * Added rate quality
reduction to medium quality for basic rate connections * Enhanced
a2dp frame calculation ratio to smooth out frame distrubution * Removed
iop scaling patch.

Bug 8252054

Change-Id: I20725d0decfe5f820e1c03407889b6272e830aca
tif_av.c
tif_media_task.c
003284a0c70b60a7c959ea3bbc023e0fbda26be1 14-Sep-2013 Zhihai Xu <zhihaixu@google.com> Merge "fix wrong PBAP profile SDP record which may cause some carkit interop problem." into klp-dev
d0cbb2ed7abda2ca15e04c10dbf8de9bfc91369a 14-Sep-2013 Zhihai Xu <zhihaixu@google.com> fix wrong PBAP profile SDP record which may cause some carkit interop problem.

bug:10488422
Change-Id: I8fb4a73a631c84dc812f44593743905f2d2ad108
tif_sock_sdp.c
844682e302538e9ebf80c05c0dc37ea28961ff39 14-Sep-2013 Zhihai Xu <zhihaixu@google.com> Merge "Changed MAP version from 1.0 to 1.1, since this is what was actually implemented" into klp-dev
1e5109b5cbf49810abd0c94c413ce07db52caaca 10-Nov-2012 Matthew Xie <mattx@google.com> Use product model as default bluetooth name if not defined

bug 7441329

Change-Id: I6afe54a8a0c4d1120e96eb808cf9fc4bf5b37fdb
tif_dm.c
98139d9ecf9f42bffa26b6840659131b0b3258f0 22-Aug-2013 Kim Schulz <k.schulz@samsung.com> Changed MAP version from 1.0 to 1.1, since this is what was actually implemented

Change-Id: If391121ca92f1025bff3a99941afa12da69c3b69
Bug: 10434562
tif_sock_sdp.c
c8a9f438cd994a7e69aa7fa957e0b9139bfdb912 22-May-2013 Priti Aghera <paghera@broadcom.com> Incremented buffer size to accomodate default MTU

L2CAP Config request was not sent from Bluedroid as the MTU size was
higher than the max buffer size for default apdu tx/rx sizes.
Incremented the buffer size to accomodate this default MTU size. Also
included new datatypes and corresponding tx/rx apdus. This will set the
MTU size to that defined in datatype config rather than selecting
default value.
b/10565872
Change-Id: Id469c836581fb3d020bcb88c381421e0ef965073
tif_hl.c
247c68fe6eee3660cbdcf4509195fe735ae25573 01-Aug-2013 Satya Calloji <satyac@broadcom.com> Add support for AbsoluteVolume

Add support for AbsoluteVolume in BTIF
bug 9595622

Change-Id: I11b707f6ab50d31bd11e879b0ebe5ad5bac54ad9

Conflicts:
btif/src/btif_rc.c
tif_av.c
tif_rc.c
tif_util.c
607e3b79f1731de0d08a2c03d38ae17874bc282d 16-Aug-2013 Matthew Xie <mattx@google.com> Place handling of BTA_DM_DISC_BLE_RES_EVT in BLE feature ifdef

Without this fix, bluetooth fail to compile for non-BLE platform

Change-Id: Ida10c54ab841e0a2bcaeb389a9813dd846db8200
tif_dm.c
cb21f0434223a51d94eb4c6b5b62f77f9efa0a83 16-Aug-2013 Zhihai Xu <zhihaixu@google.com> Merge "LE: Add support for the HID-over-GATT profile (1/3)" into klp-dev
2e7fa68bfd9723b7ec7b6b0b128d89f31a2e06ee 09-Aug-2013 Andre Eisenbach <andre@broadcom.com> LE: Add support for the HID-over-GATT profile (1/3)

bug:8330048
Change-Id: I5727161b0a87700487bee96cdffa8fd169034204
tif_dm.c
98497a520010fc996a8ce490665cac6c1439dd2d 25-Jun-2013 John Du <johnldu@google.com> Add support for ff/rew

Change-Id: I017a7ddc9f7255d84ad8bf3284fefc1b7040900f
(cherry picked from commit 342bdf540d8c183d14ec5fb436b73cd979df3a8f)
tif_rc.c
5c44e45473e5fc2fa89411ab1add7dbfc979f1f8 07-Aug-2013 Andre Eisenbach <andre@broadcom.com> LE: Add peripheral role support (2/4)

Initial stack support for the LE peripheral role.

Change-Id: I261d751b43b7020760bff345b472b6f60caa60be
tif_dm.c
tif_gatt_client.c
ace8d679f68cfab4c022d00afc7e5daafc74a4fd 12-Jul-2013 Andre Eisenbach <andre@broadcom.com> LE: Check encryption state before starting encryption

Previously, the btif layer kept track of when a link was encrypted using
an internal list to track encryptino callbacks. This change switches to
querying the stack for the actual encryption state, since the btif layer
may not receive all encryption related callbacks.

Bug: BLTH02382147
Change-Id: I426b87d77e9a18531c2d42733a7e736a73bb116f
tif_gatt_client.c
tif_gatt_server.c
tif_gatt_util.c
5f9c140d094ebf4a269cdc6ae083900bf25f7fae 09-Jul-2013 Andre Eisenbach <andre@broadcom.com> LE: Add instance ID to descriptors (2/4)

If a remote devices offers multiple descriptors with the same UUID, the
instance ID is used to differentiate between them.

Change-Id: I1f3c284d714719fe9fb9cbb297c70a061c62a96d
tif_gatt_client.c
tif_gatt_util.c
6975b4d711142b885af479721cada448952c6b41 06-Aug-2013 Andre Eisenbach <andre@broadcom.com> LE: UPF 45 bug fixes

This change fixes the following issues:
- Second GATT-over-BR/EDR channel cannot be established when there
already is an existing GATT-over-BR/EDR channel
- If encryption fails for an LE connection due to a missing key,
the security state is not being cleared and blocks all further
security processing
- When DM discovery of an LE Peripheral device fails with a
connection timeout, no further discovery requests can be made
- GATT service discovery can get into endless loop when duplicate descriptor
definitions are found on the remote device
- When GATT over BR/EDR fails, BTA does not give a connection
callback to the application initiating the connection
- BR/EDR connection to remote platform does not generate API callbacks
- Stack crash discovered during UPF after remote disconnects
- The host is sending HCI disconnect to invalid HCI handle when
SMP fails because of a connection timeout
- Possible race condition:
If a disconnect is immediately followed by a connection complete,
the connection complete cannot be processed in the BTA GATT state
machine
- Write Complete event is not triggered for Prepare Write requests

Change-Id: I539cdedd68007818ff4f0d0213cee1c913f72d0f

Conflicts:
bta/gatt/bta_gatts_act.c
tif_gatt_client.c
tif_gatt_util.c
e1202caae4920139ea0cfed5c51f5f76b2dc8bc4 15-May-2013 Andre Eisenbach <andre@broadcom.com> LE: Add GATT disable functions

This patch adds required disable functions to the GATT sub-system to
properly unregister with the stack. Without the disable functions in
place, turning Bluetooth off with a GATT device connected may lead to
unexpected behaviour and cause GATT to fail on sub-sequent stack
restarts.

Change-Id: I7cb80e96109e2c09882991298d0487b506f5ffdd
tif_core.c
tif_gatt.c
f052217962d0c06392eb79687820c9469cd6a75a 29-May-2013 Andre Eisenbach <andre@broadcom.com> LE: Fix GKI exception for 0 length values

When a remote device responds to a read request with a 0 length value, a
GKI exception will occur. This patch checks for 0 length values to avoid
the exception and return the correct status to the application
requesting the read.

Change-Id: Idce61c3d2be7072dafe429ab978763b0ee61aed2
tif_gatt_client.c
e4020c28c8a9dc56f927b03a8ca3a17d9401bc1e 17-May-2013 Andre Eisenbach <andre@broadcom.com> LE: Add NULL pointer check in deep copy function

Adds a NULL pointer check for the GATT read event deep copy function.

Change-Id: Ia8d31e851589612009e1038c11b7b113e5367c6d
tif_gatt_client.c
tif_gatt_util.c
8444d1e649864c28b0c124bc2d16f7c153f01f14 17-Apr-2013 Andre Eisenbach <andre@broadcom.com> LE: Deep copy buffers when transfering client context

Certain BTA client event types require a deep copy of the request
data buffers when transfering context. Shallow copy of the pointers
involved may cause a crash when overlapping read and write requests
are received.

Change-Id: Id59b034d7fdd28087695a0688caff66b4cef4a4d
tif_gatt_client.c
181adbef76c194e257639daecb486bfc9a0ad037 10-Aug-2013 zzy <zhenye@broadcom.com> Fixed issue that failed to update rfc credit to peer when host can not handle the incoming packets fast enough

Bug 10233699: Bluetooth sockets block indefinitely on read(...)
tif_sock_rfc.c
153767ee55e16c45235e590305bdbc0ba952da63 19-Jul-2013 Matthew Xie <mattx@google.com> Bluetooth MAP profile - sms and mms support initial check-in

bug:10116530

Change-Id: I3bff487fdc0ee1256afa8d704a2cfa788081208c
tif_sock_sdp.c
4420e41159663c904fd55fbb7dd4816129467fb5 27-Jul-2013 Ajay Dudani <adudani@codeaurora.org> Fix check for BTIF_HL_CCH_OP_MDEP_FILTERING in btif_hl_upstreams_evt

Change-Id: If080fad6ba4b42944dc5ee8bf1d8f0586dbd05f8
tif_hl.c
292d9f5a84da312a13ce3e881cd3df09bc492882 26-Jul-2013 Zhihai Xu <zhihaixu@google.com> Merge "Add debug menu to enable btsnoop"
4c03040fa975cc23ea27b183908b1008bb3231f9 26-Jun-2013 Ganesh Ganapathi Batta <ganeshg@broadcom.com> am 29a69a11: am ec7e2c8e: Do not abort bonding if link disconnects during SDP after Auth cmplt

* commit '29a69a1144fc42d3742bacb9acee89a612cbf8b3':
Do not abort bonding if link disconnects during SDP after Auth cmplt
ec7e2c8e06396101c6b26187995db7c105ed3c3f 20-Jun-2013 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Do not abort bonding if link disconnects during SDP after Auth cmplt

If ACL link gets dropped during service search after bonding,
re-attempt service search instead of setting bond state to BOND_NONE
Bug 8611134

Change-Id: I77672d9f4feab634b3795a41e0d4e58903b5d275
tif_dm.c
390c94dc0f9deee917f52caaf3f8bb9f79aa98b4 16-May-2013 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Removed COD check for unbond and UNPAIRED_EVT

PC supporting HID Device would not have Peripheral as
its MAJOR COD. So COD check for major peripheral device was removed
in case of UNBOND and while receiving UNPAIRED_EVT. Additonal checking
is done when virtual unplug evt is received to remove bonding only for
HID Devic with MAJOR COD as Peripheral or if its a locally initiated
VUP.

Change-Id: I5343919463e48babc9cd03e05ff92a3f93f6d26d
tif_dm.c
tif_hh.c
bad70b1d0071ee9b16a029ff145e8e53038571ff 05-Jun-2013 Zhihai Xu <zhihaixu@google.com> Add debug menu to enable btsnoop

bug: 8059358
Change-Id: I232f6d47e7fb7e9c4d71c119394fce3e72cd02fc
luetooth.c
tif_core.c
194cdc31b949e2a72a53ab8fd4abed162ee00910 30-May-2013 Kausik Sinnaswamy <kausik@broadcom.com> am 67f5817f: am 77d1cb6f: Fix for AV lockup on local and remote start collision

* commit '67f5817f1526faa64d3720c2c3d471117c520de8':
Fix for AV lockup on local and remote start collision
77d1cb6ff904b48ee85c09a06c5e05dd0ed049b9 22-May-2013 Kausik Sinnaswamy <kausik@broadcom.com> Fix for AV lockup on local and remote start collision

Bug: 7002859

Change-Id: I6170be864b44011b98e08d7e2599021a3eec70a3
tif_av.c
02b14ec482d7eec54bf57f8f18d1f6487dc3df57 15-May-2013 YK Jeffrey Chao <jechao@broadcom.com> am 2fca6e54: am 48ebe2c6: Preload timeout and retry mechanism (1/3)

* commit '2fca6e548ff48988e63d3550d807b016192e0a77':
Preload timeout and retry mechanism (1/3)
48ebe2c6928d8fd4dc97c8adb138c3440714dc89 24-Apr-2013 YK Jeffrey Chao <jechao@broadcom.com> Preload timeout and retry mechanism (1/3)

If the Preload process was stuck due to unknown hardware init failure,
a 8-second ENABLE_TIMEOUT timeout would be eventually expired in Java layer
at AdapterState and attempted to set BT state back to STATE_OFF.
However BluetoothManagerService did not handle this case accordingly and led
to state mis-matching between Java layer and BTIF at the end.

Add a timeout and retry mechanism to manage Preload process.
Clean up native space resource and explicitly report STATE_OFF back to Java
space when Preload did not go through.

bug 7566317

Change-Id: I99a225e524f2b951249618990a2d0a8a39b43ff3
tif_core.c
da54571c77cf708d5196be153e8f9794f62a6da7 11-May-2013 Mattias Agren <magren@broadcom.com> am 83ecfd88: am 5fd74f06: Stability fixes for a2dp hal control path

* commit '83ecfd882bec4f5761c4114c571b170c5a9376db':
Stability fixes for a2dp hal control path
5fd74f06caab4324d0ba69df86ad5170c072ec64 05-Apr-2013 Mattias Agren <magren@broadcom.com> Stability fixes for a2dp hal control path

Ensure av statemachine is preventing a2dp hal to restart the stream
when not ready. This prevents ending up in a scenario where a2dp hal
locks up. Code cleanup.
bug 7002859

Change-Id: I3f3eeaab4ca185733b8b0042ed2cfa701f76a203
tif_av.c
tif_media_task.c
76d041f915e4c14b3fb11bae3c12fcb59f77bef5 10-May-2013 Matthew Xie <mattx@google.com> am e1405531: am e915116a: Merge "Solve compilation problem when BLE/GATT/SMP features are false" into jb-mr2-dev

* commit 'e1405531f637a3851371a2a2c624ff3db5e074fa':
Solve compilation problem when BLE/GATT/SMP features are false
e915116a24142955edbc40a0e380b4828957c762 09-May-2013 Matthew Xie <mattx@google.com> Merge "Solve compilation problem when BLE/GATT/SMP features are false" into jb-mr2-dev
fc4b2f1953dbe60464d0f5ef7daaa10001fbc62f 07-May-2013 Matthew Xie <mattx@google.com> Solve compilation problem when BLE/GATT/SMP features are false

bug 8664724
Change-Id: I582846ccf4b8995f298d8db533488fceb7993ae3
luetooth.c
tif_dm.c
tif_gatt_util.c
tif_storage.c
ec5f265762154e5f222e79ae132e58a5b7bc0cd6 07-May-2013 Kausik Sinnaswamy <kausik@broadcom.com> am 91409af5: am 95664a9a: Fix for SDP data structure leak during pairing

* commit '91409af50ebd2e7590b8e2463e1d06ac13f00e18':
Fix for SDP data structure leak during pairing
95664a9acc57b5e51365454f26d2fac0f2e1ecd4 03-May-2013 Kausik Sinnaswamy <kausik@broadcom.com> Fix for SDP data structure leak during pairing

During pairing, bluedroid initiates a SDP request to search services.
Upon SDP completion, some data structure buffers were not returned to
the pool resulting in leak.

Bug : 8797456
Change-Id: Ic512fd22ca6b8b748c5b92c02e24016fe785c0b1
tif_dm.c
6ded3e4bc35c9878771a59cb8cc75b702c2097fd 24-Apr-2013 Priti Aghera <paghera@broadcom.com> am f9020d0d: am f8f30c2c: HDP fix for Single SDP record

* commit 'f9020d0de5c8ade5fab86b26979620aac4f67dc9':
HDP fix for Single SDP record
f8f30c2cecf221b2c3983b72d5a849d799c39dd7 03-Apr-2013 Priti Aghera <paghera@broadcom.com> HDP fix for Single SDP record

Modified stack code to support single SDP record
for each register app call.
bug 8656462
Change-Id: I92570243306d5c1ca8339042eba5733e43fdb72c
tif_hl.c
tif_storage.c
8ec01b1006965a2966f116469f4f892382ab4d34 18-Apr-2013 Matthew Xie <mattx@google.com> am c11b7d75: am f5391070: Merge "LE (2/3): Add application ID to connection callback" into jb-mr2-dev

* commit 'c11b7d7598516783083970d17d52be0d1d75bcc4':
LE (2/3): Add application ID to connection callback
f5391070cbb1f3c66db34cef8501f2754cecc1e6 18-Apr-2013 Matthew Xie <mattx@google.com> Merge "LE (2/3): Add application ID to connection callback" into jb-mr2-dev
977b854e5121c0ea19ecab6eb2bdb3583f439568 10-Apr-2013 Andre Eisenbach <andre@broadcom.com> LE (2/3): Add application ID to connection callback

Bug: 8589393
Change-Id: Ib5c34ce1cddb0e32ad08ac3cbdeaa74cd8514f81
tif_gatt_server.c
ad7e70f3c8fa9db7c4a6cd4043597209a93b2ecb 16-Apr-2013 Ganesh Ganapathi Batta <ganeshg@broadcom.com> am 52eb4f3d: am 33af35c4: Fix for Nyko playpad

* commit '52eb4f3d971d59e8b5f015c870e92a15a591fd55':
Fix for Nyko playpad
33af35c49731bc8e305c862c8e9f3e42a1ab0dc9 10-Apr-2013 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Fix for Nyko playpad

Nyko playpad does not cmply with HID Device spec. NYKO gamepad
advertises as supporting virtual unplug but when virtual is sent
by host it responds with ERR_UNSUPPORTED_REQUEST. Modified BTIF
code to start a timer when VUP is issued and fire the timer if peer
does not respond.
Bug:8055549

Change-Id: I90db956fb243f1a518b00424b103ebf9f0a1b7f0
tif_hh.c
b763c76763b655db75bb2ec731f673460e3bdcec 08-Apr-2013 Ganesh Ganapathi Batta <ganeshg@broadcom.com> am 2f338f25: BT: JV rfcomm socket sniff support

* commit '2f338f25530d2aaab7acf45701c271d10b81d96d':
BT: JV rfcomm socket sniff support
2f338f25530d2aaab7acf45701c271d10b81d96d 24-Mar-2013 Ganesh Ganapathi Batta <ganeshg@broadcom.com> BT: JV rfcomm socket sniff support

Bug:8322094

Change-Id: Ib472f39488b685ac396289e65c1da21fdfd93c4c
tif_sock_rfc.c
7fe56f58c2a3cf0ac80177aaa890c143cd5fd950 29-Mar-2013 Priti Aghera <paghera@broadcom.com> Save the HID info into storage while adding device

Previously HID device info was not saved immediately to NVRAM, thus
when device was rebooted sometimes the hid information was missing
from NVRAM, thus host does not identify the HID Device
bug 8192743
Change-Id: I7ca8b607399e141fa851242e83c1c6d3854384f8
tif_storage.c
b88fc6cb5636c4af17077502fe3313ffb32d93ee 02-Apr-2013 Ravi Nagarajan <nravi@broadcom.com> Add support for PLAY_POS_CHANGED

Enable PLAY_POS_CHANGED support in get capabilities

Change-Id: I8f41209fe5be5345826136f14434488524e7b1bb
tif_rc.c
841e5b5092bcdbc1acffd6cf7255ec423fe15fdb 22-Mar-2013 Ravi Nagarajan <nravi@broadcom.com> Reject element attribute request if count is 0xff

Updates from review. BTRC_MAX_ELEM_ATTR_SIZE set back to 7 and handled
invalid attribute count (oxff) in BTIF

Change-Id: Id2610c7882c4bc8aca04491d81b9b2c35f0682d0
tif_rc.c
081d6e548bed5a91c0ba9abda518c06a1b0ba7f5 30-Mar-2013 Zhihai Xu <zhihaixu@google.com> need send reject response to unsupported Avrcp 1.3 command

Without this change, some carkit will stuch waiting for response and crash.

Change-Id: I710f69077e400830a9cedd540bef5d51dc468272
tif_rc.c
1f9a190b457f6a0e8effd47998014cb724fdb085 21-Mar-2013 Zhihai Xu <zhihaixu@google.com> Merge "Initial version of Stack for AVRCP 1.3" into jb-mr2-dev
9adddf4965e9ddb01e339b934c343fcbd842a977 06-Mar-2013 Ravi Nagarajan <nravi@broadcom.com> Initial version of Stack for AVRCP 1.3

BTIF and stack changes for supporting AVRCP 1.3

Change-Id: Id02eb7b6a385683cedc41c62b6f829f5d7620bd4
luetooth.c
tif_av.c
tif_rc.c
tif_util.c
ca22ac493ab777199084d87b3c7627e7f27555af 13-Feb-2013 Andre Eisenbach <andre@broadcom.com> LE fixes

- Null pointer exception check added.

An exception occurs at the memcpy in the bta_dm_gatt_disc_result.
User removed the battery on Ble device(Smart Nudge) during bonding
and connection. This exception occurs sometimes.
I used Broadcom LE Explorer to reproduce it.

- Fixed disconnect and encryption behaviour

Disconnect will now disconnect the physical link immediately when no
other application is interested in the device anymore. Also, the
connection to a remote device is now dropped if encryption fails.

- Deep copy buffers when transfering context

Certain BTA server event types require a deep copy of the request
data buffers when transfering context. Shallow copy of the pointers
involved may cause a crash when overlapping read and write requests
are received.

- 2nd encryption has not started

need to send encryption complete callback
when the encryption fail due to link drop without a complete event.
Otherwise BTA layer would not be able to clean up the status,
and no further encryption can be started.

Change-Id: If93e0a188e8779830c8991e4193b96dc95e23e5d
tif_dm.c
tif_gatt_server.c
tif_gatt_util.c
ead3cde4bac0c3e32cd31f149093f004eef8ceeb 06-Feb-2013 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Initial version of BLE support for Bluedroid

Change-Id: I9825a5cef9be2559c34c2a529b211b7d471147cf
luetooth.c
tif_core.c
tif_dm.c
tif_gatt.c
tif_gatt_client.c
tif_gatt_server.c
tif_gatt_test.c
tif_gatt_util.c
tif_hf.c
tif_hh.c
tif_hl.c
tif_storage.c
tif_util.c
e17bf003d4eefdc8525e55894210e9ee494972b8 16-Feb-2013 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Cancel device search before starting SDP

Also update bonding state when acl link goes down during bonding
b/8120036
Change-Id: I28e4cb6f35e4c524b7a67281e78a196ba1fce0cb
tif_dm.c
ebb1d755818704a662f7ea8ae3cc1b5593d582d8 28-Nov-2012 Priti Aghera <paghera@broadcom.com> Fixed unpair and reconnect issue with certain non-pointing hid devices

Hid info would not be removed from storage if COD is
NON_KEYBOARD_NON_POINTING. Due to this the device will
be added to stack even if it is unpaired and subsequent connections
will fail.
bug 8055549

Change-Id: Ib493fc165120de3c71398f5fe24b17f31fa5fc3e
tif_dm.c
tif_hh.c
45f5f9077c773b9d4533fef13045b5ff77e32e46 08-Feb-2013 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Resolved partial uipc channel read issue

When partial data is read the previously read size wasn't
compensated for. Ensure we don't transmit empty a2dp frames in case
of underrun
Bug 8026551

Change-Id: I4195ed798008378b93343bf7cd266c6e2f11b094
tif_media_task.c
d70b7a8ebce5a9646b8baf16a24a6eda88b1a4f6 31-Jan-2013 Nick Kralevich <nnk@google.com> fix too small buffer

property_get must be called with a buffer of at least
PROPERTY_VALUE_MAX len. The supplied buffer is too small.
Fixed.

Change-Id: I6c6b3050b30f6aa5ece69888263394e572551aff
tif_dm.c
9ac641d0a674333af57b85b367e64cf94dfae291 16-Jan-2013 Matthew Xie <mattx@google.com> fixed rfc resouce leaking and multi-session issue

also added more debug messages
bug 7486080

Change-Id: Ic21e9d2df5f651b51ea2126a3cac25811808dcfb
tif_sock_rfc.c
689d66b6559dcb3a0ad7f6cc33b6129e50910253 13-Dec-2012 The Android Open Source Project <initial-contribution@android.com> Snapshot 9fd57cbacd95e89602f430244c35bbc67f08b6d2

Change-Id: Ibc3a4bf4161d286c7cfab89a19c676eb5cc9224f
tif_config.c
tif_config_util.cpp
tif_hh.c
tif_pan.c
tif_sock.c
tif_sock_rfc.c
tif_sock_sdp.c
tif_sock_util.c
tif_storage.c
5738f83aeb59361a0a2eda2460113f6dc9194271 13-Dec-2012 The Android Open Source Project <initial-contribution@android.com> Snapshot cdeccf6fdd8c2d494ea2867cb37a025bf8879baf

Change-Id: Ia2de32ccb97a9641462c72363b0a8c4288f4f36d
luetooth.c
tif_av.c
tif_config.c
tif_config_util.cpp
tif_core.c
tif_dm.c
tif_hf.c
tif_hh.c
tif_hl.c
tif_media_task.c
tif_pan.c
tif_profile_queue.c
tif_rc.c
tif_sm.c
tif_sock.c
tif_sock_rfc.c
tif_sock_sdp.c
tif_sock_thread.c
tif_sock_util.c
tif_storage.c
tif_util.c