History log of /system/bt/bta/gatt/bta_gattc_act.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
26f8828cdb5f02b0b01bafaccd4ad0b0ba9d57ab 17-Mar-2016 Jakub Pawlowski <jpawlowski@google.com> Use handles to identify GATT attributes (1/4)

Bug: 27778668
Change-Id: Id7454450c1ce2164001a1f9ca0b91f18d84e3fd6
/system/bt/bta/gatt/bta_gattc_act.c
ac4ee3a4ecae72fbc992c17efd733e373ad56daf 04-Mar-2016 Jakub Pawlowski <jpawlowski@google.com> Remove bta_gattc_id2handle

Now that the instance id is equal to handle, we no longer need this
mapping function.

Bug: 27455533
Change-Id: I6760f8fc81460df8520d4ebf1899ed256ce5ad1e
/system/bt/bta/gatt/bta_gattc_act.c
56658ccb40957a296f6600bdfed529d3f6e264a7 06-Mar-2016 Jakub Pawlowski <jpawlowski@google.com> GATT cache storage refactoring

Currently when storing GATT cache into file, we save it piece
after piece, max 10 elements at once. This is not necessary,
we have enough space to just save all at once.
Also the logic doesn't need to be so complicated - no need
to state machine for such simple task.

Bug: 27455533
Change-Id: I82923dbedfb317835e45e13e0ea28151eb524d37
/system/bt/bta/gatt/bta_gattc_act.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
/system/bt/bta/gatt/bta_gattc_act.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
/system/bt/bta/gatt/bta_gattc_act.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
/system/bt/bta/gatt/bta_gattc_act.c
9df3192b94a186207976ecc579d390f3cfd547c6 05-Feb-2016 Jakub Pawlowski <jpawlowski@google.com> Use dynamic memory for keeping GATT cache

Change-Id: I60674c47246d8fe2094fe78ce31b752fa2acb89e
/system/bt/bta/gatt/bta_gattc_act.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
/system/bt/bta/gatt/bta_gattc_act.c
5919554fe8e03b87a7c7724238481b85e9cf6630 04-Feb-2016 Jakub Pawlowski <jpawlowski@google.com> Don't unregister notifications for unmodified services

Change-Id: Ie02dd72a2d4a423ab532ec84a4d588ab83f3e22b
/system/bt/bta/gatt/bta_gattc_act.c
20c68408686ba4fd4d17e21957616e1c60a913b3 29-Jan-2016 Pavlin Radoslavov <pavlin@google.com> Revert "Revert "Avoid double memory free and crash during LE discovery or disconnect""

The revert includes a compilation fix as well
(missing include of a header file).

This reverts commit 3a4082d7af5c5941769c700d774022a9b982d45c.

Change-Id: I5bb1f468d2c64839037afe5ed2d3ed5d1b21dca2
/system/bt/bta/gatt/bta_gattc_act.c
3a4082d7af5c5941769c700d774022a9b982d45c 29-Jan-2016 Ian Pedowitz <ijpedowitz@google.com> Revert "Avoid double memory free and crash during LE discovery or disconnect"

This reverts commit 12091a323ef84cad10d91fcf6588a6657e591ee0.

Change-Id: I01deaa5024bfef1782887fd8f8137f83916d8be0
/system/bt/bta/gatt/bta_gattc_act.c
12091a323ef84cad10d91fcf6588a6657e591ee0 28-Jan-2016 Nitin Arora <niarora@codeaurora.org> Avoid double memory free and crash during LE discovery or disconnect

1. Prevent GATT operations to proceed if queue is not empty

This change returns a FALSE from GATT enqueue operation, in case
there is already a GATT command enqueued. This simple change will
a. Prevent incorrect memory freeing of the currently queued command.
b. Prevent incorrect dequeing of the ongoing command and enqueing
another command which will never be executed.
c. Double free of memory causing segmentation fault

2. Prevent performing pending operations when link is down

This change prevents performing the execution of pending operations
when the link is disconnected. The pending operation in that case
is bound to fail thus freeing the memory pointed to by the p_q_cmd
which is cleaned up again by the discovery completion routine and
thus causing double free.

Bug:24178843
Change-Id: Ief2756f289a7db73d251ef7e247774dd3f7fc413
/system/bt/bta/gatt/bta_gattc_act.c
b83028d1422a097e57b829155d42882414c7a1ee 15-Jan-2016 Subramanian Srinivasan <subrsrin@codeaurora.org> Adds null check before freeing LE services list

Prevents the crash which happens when device is
disconnected during service discovery and the
services list is not yet properly allocated
memory and populated. This change frees up the
services list after discovery complete only when
it is not null.

Change-Id: I0ced14d2ee133a332fa2fd7c456267438813a600
/system/bt/bta/gatt/bta_gattc_act.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
/system/bt/bta/gatt/bta_gattc_act.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
/system/bt/bta/gatt/bta_gattc_act.c
7b4fdb40e81a68d254f6bf7cefbc385d978fb9d0 05-Sep-2015 Pavlin Radoslavov <pavlin@google.com> Eliminate recursive calling when handling GATT related errors

If there are errors when processing GATT related events (e.g.,
configuring the MTU), don't use recursive calls into
bta_gattc_sm_execute(), because it breaks the free-ing of some
of the memory.

Bug: 23756301
Change-Id: I3c685170e868ffbf4e488d2bb5a31904e3f7b39d
/system/bt/bta/gatt/bta_gattc_act.c
08393054f0867d0f86a7f9c2eb156e67a86382c7 07-Aug-2015 Marie Janssen <jamuraa@google.com> resolved conflicts for merge of 49a86709 to mnc-dev-plus-aosp

Change-Id: Icd7ec2fd78ac4383da430708a88abaeba9009437
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
/system/bt/bta/gatt/bta_gattc_act.c
36b09da3bb730b75ce4e2aad705b1111b7edcee2 16-Jul-2015 Arman Uguray <armansito@google.com> am 50333a25: Properly disconnect GATT connection during noisy scans

* commit '50333a25ba3dac54033738d1e2a2688e2977ff2e':
Properly disconnect GATT connection during noisy scans
50333a25ba3dac54033738d1e2a2688e2977ff2e 16-Jul-2015 Arman Uguray <armansito@google.com> Properly disconnect GATT connection during noisy scans

This patch fixes an issue that is reproducible in highly noisy environments
(massive deployment of BLE beacons), through repeated connect/disconnect
attempts on a remote peripheral while scanning for beacons in the background.
The state machine in bta/gatt has a special control flow for handling disconnect
requests during discovery, which in this case failed to resolve the original
request by issuing an HCI_Disconnect command. This is now fixed by always
explicitly triggering the connection close sequence once the discovery state has
been cleaned up.

This patch also includes a fix for a crash that occurred as a side-effect of the
scenario described above.

Bug: 22350508
Change-Id: Ie9cbd3c8f54239b142bfb8dde80d9581ae70ed43
/system/bt/bta/gatt/bta_gattc_act.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
/system/bt/bta/gatt/bta_gattc_act.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
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
/system/bt/bta/gatt/bta_gattc_act.c
dd2021c65b8a1a14e67e4f23628b3e15faf9fdcc 19-Jun-2015 Tucker Sylvestro <tuckeris@google.com> Always ACK indications in the event of an error

This works around a race condition in which the just-connected remote
device sends the local device an indication before the appropriate
handle/device/etc. has been added to the cache. Previously we were
dropping that indication, which led to the remote device timing out
and disconnecting some time after the connection had been successfully
established.

Bug: 21026847

Change-Id: Iea43e7c93e48b5e7a7e78a1c3fb591d6fe972fc3
/system/bt/bta/gatt/bta_gattc_act.c
7557b67434226e4baeee87ba86a7b85d1687de9a 31-Jul-2014 Nitin Arora <niarora@codeaurora.org> Use correct structure to read LE connection handle

This patch corrects the retrieval of the connection handle
after the gatt write operation has succeeded successfully.

Change-Id: Iac79a64d6c626c2349b6f1a3744ea49a521a45f4
/system/bt/bta/gatt/bta_gattc_act.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
/system/bt/bta/gatt/bta_gattc_act.c
6e872cb5f5329d7f747091ba759f832bab4b45ec 31-Jul-2014 Nitin Arora <niarora@codeaurora.org> Use correct structure to read LE connection handle

This patch corrects the retrieval of the connection handle
after the gatt write operation has succeeded successfully.

Change-Id: Iac79a64d6c626c2349b6f1a3744ea49a521a45f4
/system/bt/bta/gatt/bta_gattc_act.c
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
/system/bt/bta/gatt/bta_gattc_act.c
b8b3e8070ad027e7a45ca5048ae807c4ec099b15 18-Apr-2015 Priti Aghera <paghera@broadcom.com> Initialize white list size after stack reset

The white list size is not currently set correctly, preventing devices
from being added to the LE whitelist, thus completely breaking
re-connects.

This fixes the white list management and propagates the correct reason
code for HID close events to make sure a device is re-added to the white
list if necessary.

Bug: 20290744
Change-Id: I46d7254ff3568c9964688cb192b9deb6b7d3062d
/system/bt/bta/gatt/bta_gattc_act.c
f8027005333c88a2f097cfd70d15c3d54c7764ae 12-Mar-2015 Chris Manton <cmanton@google.com> Demote, cleanup and extend observed logging
/system/bt/bta/gatt/bta_gattc_act.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.
/system/bt/bta/gatt/bta_gattc_act.c
794f3b5f126fffc3dd1129a710187591348bbf23 01-Oct-2014 Chris Manton <cmanton@google.com> Removal of bd.[c|h]

Consolidate legacy types into bt_types.h
/system/bt/bta/gatt/bta_gattc_act.c
fe7216ca12f91baae733e7c93063db73121af308 06-May-2014 Chris Manton <cmanton@google.com> Enforce GKI API buffer usage

Also add another API GKI_queue_length(BUFFER_Q *)
/system/bt/bta/gatt/bta_gattc_act.c
f37767a17b2d80828f7ac4fa170859cb9e2f0bc6 05-Nov-2014 Andre Eisenbach <eisenbach@google.com> HOGP: Do not remove device from whitelist on encryption failure

If the encryption times out during the re-connect process for a HOGP
device, the device is removed from the whitelist and thus will not
reconnect until it is added back to the list. On platforms that do not
have a way to reconnect to a device manually, this means the device will
never reconnect again until the stack is restarted.

This patch checks the reason for the encryption failure and does not
remove the device from the whitelist if the encryption failed to a non
authentication/key related error.

Bug: 18233442
Change-Id: Ifaec4a9224ff9281956715b38d34c2d7c3fecb01
/system/bt/bta/gatt/bta_gattc_act.c
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
/system/bt/bta/gatt/bta_gattc_act.c
1f58d6ba111106df7db0c2c1b12d5895c6fd0bc3 16-Oct-2014 Andre Eisenbach <eisenbach@google.com> Implement GATT service cache

When trying to reconnect a previously paired device, notifications may
be sent by the remote device before the characteristic handles have been
discovered. Thus notifications will be lost.

This patch adds a non-volatile attribute cache that allows attribute
handles to be restored before notifications are received.

Bug: 17999991
Change-Id: I97faefbc6a2fed86cbce7f64d620ed03944d89b2
/system/bt/bta/gatt/bta_gattc_act.c
d2246b6ebdc1db60c2db8dd0e34a3121a71117e9 29-Aug-2014 Priti Aghera <paghera@broadcom.com> LE: Remove stored link key if encryption fails due to missing key (remote)

Remove the link key if encryption fails due to missing key or
authentication error. When a remote device loses the bond, all
HOGP services cached should be discarded and all client configuration
descriptors needs to be re-enabled. This will ensure successful
re-connection.

Bug: 15022622
Change-Id: Ie1730830c0cbbc294e2cd579d7dca69d16cf8218
/system/bt/bta/gatt/bta_gattc_act.c
32429188798b1f34fcf2cc609fd70ed85f20264b 26-Jul-2014 Andre Eisenbach <eisenbach@google.com> LE: Fix problem where pending command is not sent after pairing

If a read/write or other operation triggers SMP pairing with a remote
device, the operation should complete once pairing has finished. This
patch fixes a bug where the pending command was not sent after pairing.

Bug: 16405565
Change-Id: Idb2e54931c71b0a9e009cac318712eb9f5c7e15a
/system/bt/bta/gatt/bta_gattc_act.c
90715aad34cdead03fc22bc18891c04838e90e87 01-Jul-2014 Mike J. Chen <mjchen@google.com> Fix GKI buffer leak in GATT event handling

The GATT event handler was telling the BTA dispatcher that
it would always free the GKI msg buffers itself, but in fact
this wasn't true. There were some cases where the buffer is
queued and freed later (queued in p_clcb->p_q_cmd for later
access and freeing), but many times the event handlers
(like bta_gattc_ci_save()) don't queue the buffer and don't
free it, causing a GKI buffer leak.

Also, prevent a double free case (not certain it happens, but
in theory it could) if bta_gattc_sm_execute() queues a buffer
in bta_gattc_disc_cmpl().

Lastly, remove held flag since it's redundant with whether
p_q_cmd is null or not. Just go with one source of truth and
not have one shadow the other.

Change-Id: I1bd43919b8a2e125076e26cd6a3a08480b3e7e2d
Signed-off-by: Mike J. Chen <mjchen@google.com>
/system/bt/bta/gatt/bta_gattc_act.c
afa6e1abbedaad8fe854b0f43999b8aeb801af91 28-Jun-2014 Matthew Xie <mattx@google.com> resolved conflicts for merge of e8c3d75b to master

Change-Id: I78ef69c4d54a36243620ae14296d3507e3339567
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
/system/bt/bta/gatt/bta_gattc_act.c
e8c3d75b75493911ebf0f99c83676359657178f7 04-May-2014 Sharvil Nanavati <sharvil@google.com> Logging cleanup: BTIF and APPL.

Change-Id: I5b1214642bbb4b9aecc0fd2c899a6ec2c9793286
/system/bt/bta/gatt/bta_gattc_act.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
/system/bt/bta/gatt/bta_gattc_act.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
/system/bt/bta/gatt/bta_gattc_act.c
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
/system/bt/bta/gatt/bta_gattc_act.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
/system/bt/bta/gatt/bta_gattc_act.c
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)
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
/system/bt/bta/gatt/bta_gattc_act.c
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
/system/bt/bta/gatt/bta_gattc_act.c
487f9e43faeab586967f035e115af8bd63034ace 06-Mar-2014 Andre Eisenbach <andre@broadcom.com> LE: Add status callback function for LE broadcasts

Change-Id: If4342050ce1141a9c2111286e7b3cccdc012a91e
/system/bt/bta/gatt/bta_gattc_act.c
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
/system/bt/bta/gatt/bta_gattc_act.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>
/system/bt/bta/gatt/bta_gattc_act.c
27166c68490139f7df282861b10127f85a20f393 16-Jan-2014 Zhihai Xu <zhihaixu@google.com> the status in the BLE disconnected callback is always success instead of the reason.

bug:12571469
Change-Id: I7b73aae672161cd50d5110daa51a8e04d6f6e841
/system/bt/bta/gatt/bta_gattc_act.c
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
/system/bt/bta/gatt/bta_gattc_act.c
36b686527892172cb44091d160b7d2806d49fc76 23-Oct-2013 Zhihai Xu <zhihaixu@google.com> Do not deregister HH GATT IF in bta_gattc_disable for hid over GATT

The root cause is bta_gattc_disable de-register the HH GATT IF
which cause bta_hh_cleanup_disable called
before we receive BTA_HH_INT_CLOSE_EVT.
The fix is "don't deregister HH GATT IF in bta_gattc_disable and
let HH module to de-register the HH GATT IF by bta_hh_le_deregister".
because HH GATT IF is a special GATT IF
which won't be exposed to uplayer and
HH GATT IF belong to BTA HH module, it should be managed by BTA HH.
bug:11284861

Change-Id: Ia14cd2be3f3548a4d1e2dcfbc89fa3a75d9651db
/system/bt/bta/gatt/bta_gattc_act.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
/system/bt/bta/gatt/bta_gattc_act.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
/system/bt/bta/gatt/bta_gattc_act.c
a16d6b07c1c3b08e8765f9d2b16ff1f22b0bdfc6 02-Jul-2013 Andre Eisenbach <andre@broadcom.com> LE: Add NULL check for GATT client callback

Change-Id: I1087102d8a740969fb0a98b409b58230a3236aeb
/system/bt/bta/gatt/bta_gattc_act.c
781b5adee20e222ef87b56b72bfcd3f64013e4a0 28-May-2013 Andre Eisenbach <andre@broadcom.com> LE: Integrate power table for GATT

No power table exists for GATT, causing the device to never enter sniff
mode while using GATT over BR/EDR.

Change-Id: I0db539c1814a61af620f3dba560da64481291beb
/system/bt/bta/gatt/bta_gattc_act.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
/system/bt/bta/gatt/bta_gattc_act.c
dda9a3e71119078181638cf3f5a51e38d173f6d4 24-May-2013 Andre Eisenbach <andre@broadcom.com> LE: Only copy UUID for callback on success

When a GATT client application registers with the stack, the UUID is
always copied into the callback buffer, even if the registration failed.
This patch adds a check to make sure an invalid UUID is not passed back
to the application.

Change-Id: I53ddc7939c096a33a64b00a8902bedba00b61e7d
/system/bt/bta/gatt/bta_gattc_act.c
5f63da7ae32d35c42281b999f63e544fec2b705e 14-May-2013 Andre Eisenbach <andre@broadcom.com> LE: Initialize return status when registering client

Initialize status to BTA_GATT_NO_RESOURCES. If cl_rcb is full, the
wrong status could be returned to the client.

Change-Id: I45d147242c9f24c7636671ffca2f9429c175b8cf
/system/bt/bta/gatt/bta_gattc_act.c
48db2d254997a69f8709e94c55607732e7772436 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
/system/bt/bta/gatt/bta_gattc_act.c
ead3cde4bac0c3e32cd31f149093f004eef8ceeb 06-Feb-2013 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Initial version of BLE support for Bluedroid

Change-Id: I9825a5cef9be2559c34c2a529b211b7d471147cf
/system/bt/bta/gatt/bta_gattc_act.c
5738f83aeb59361a0a2eda2460113f6dc9194271 13-Dec-2012 The Android Open Source Project <initial-contribution@android.com> Snapshot cdeccf6fdd8c2d494ea2867cb37a025bf8879baf

Change-Id: Ia2de32ccb97a9641462c72363b0a8c4288f4f36d
/system/bt/bta/gatt/bta_gattc_act.c