History log of /system/bt/btif/src/btif_hh.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
180b9725ee4f5d342b72d5f718762db64201e8b8 14-May-2016 Pavlin Radoslavov <pavlin@google.com> Add missing arguments to log messages

Bug: 28769522
Change-Id: I37c2b8400619646a8711099cf0bd369c3cf8eb51
/system/bt/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.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/btif/src/btif_hh.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/btif/src/btif_hh.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/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.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/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.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/btif/src/btif_hh.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/btif/src/btif_hh.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/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.c
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
/system/bt/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.c
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
/system/bt/btif/src/btif_hh.c
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
/system/bt/btif/src/btif_hh.c
e1a9e52ff59d36bd1bb5b7b3a02fafba6394edfe 31-Mar-2015 Etan Cohen <etancohen@google.com> Merge commit 'f7f839985b3931682363d2ef3b7c5cae55a842ee' into merge

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

Consolidate legacy types into bt_types.h
/system/bt/btif/src/btif_hh.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
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>
/system/bt/btif/src/btif_hh.c
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)
/system/bt/btif/src/btif_hh.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/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.c
afa6e1abbedaad8fe854b0f43999b8aeb801af91 28-Jun-2014 Matthew Xie <mattx@google.com> resolved conflicts for merge of e8c3d75b to master

Change-Id: I78ef69c4d54a36243620ae14296d3507e3339567
e8c3d75b75493911ebf0f99c83676359657178f7 04-May-2014 Sharvil Nanavati <sharvil@google.com> Logging cleanup: BTIF and APPL.

Change-Id: I5b1214642bbb4b9aecc0fd2c899a6ec2c9793286
/system/bt/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.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
/system/bt/btif/src/btif_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
/system/bt/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.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
/system/bt/btif/src/btif_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
/system/bt/btif/src/btif_hh.c
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>
/system/bt/btif/src/btif_hh.c
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>
/system/bt/btif/src/btif_hh.c
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>
/system/bt/btif/src/btif_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>
/system/bt/btif/src/btif_hh.c
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
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>
/system/bt/btif/src/btif_hh.c
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/btif/src/btif_hh.c
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>
/system/bt/btif/src/btif_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>
/system/bt/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.c
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
/system/bt/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.c
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
/system/bt/btif/src/btif_hh.c
ead3cde4bac0c3e32cd31f149093f004eef8ceeb 06-Feb-2013 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Initial version of BLE support for Bluedroid

Change-Id: I9825a5cef9be2559c34c2a529b211b7d471147cf
/system/bt/btif/src/btif_hh.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
/system/bt/btif/src/btif_hh.c
689d66b6559dcb3a0ad7f6cc33b6129e50910253 13-Dec-2012 The Android Open Source Project <initial-contribution@android.com> Snapshot 9fd57cbacd95e89602f430244c35bbc67f08b6d2

Change-Id: Ibc3a4bf4161d286c7cfab89a19c676eb5cc9224f
/system/bt/btif/src/btif_hh.c
5738f83aeb59361a0a2eda2460113f6dc9194271 13-Dec-2012 The Android Open Source Project <initial-contribution@android.com> Snapshot cdeccf6fdd8c2d494ea2867cb37a025bf8879baf

Change-Id: Ia2de32ccb97a9641462c72363b0a8c4288f4f36d
/system/bt/btif/src/btif_hh.c