Bluetooth losing HF connection to car-kit after 5 seconds

This patch adresses a change in bluetooth which causes a possible
loss of connection within 5 seconds after connecting.  This new
behavior appeared with android 4.2 (4.1.2 worked fine in this regard).

I traced down the disconnects to an BTA_AG_SVC_TOUT_EVT via a timer
that checks if a service connection was made within a few seconds.
Essentially bta_ag_svc_conn_open() was not called on AT+CMER because
android thought the car kit supported 3WAY but the car kit did not
set the 3WAY flag via AT commands and did not send AT+CHLD either.
Android otoh used the flag obtained by SDP and expected 3WAY behavior
and eventually disconnected when AT+CHLD did not arrive.

This may be a bordeline case, because in the Bluetooth Specification
(page 20), assuming service level initialization via SDP is only
mentioned on the HF side while there is no such mention (but could
probably be implied) on page 21 for the AG.

Fact is however, that the use of SDP features value for peer_features
is new since Android 4.2 and breaks existing good behavior on a BMW
2005/E46 car kit (navi professional). This kit never asks for AT+CHLD
and never via AT commands suggests it supports 3WAY (although it seems
to have the flag set via SDP).

Also, having essential behavior (like making the connection or not)
depend on circumstances that may be prone to race conditions, may be
a good reason to not use the SDP flag also (or at least masking out
the 3WAY bit when using it).

(An alternative approach could be to hook into bta_ag_timer_cback() and
when the timer exipres, but when also AT+CMER has been seen meanwhile,
to continue and assume a service level connection without 3WAY,
i.e. clearing the 3-way flags but calling bta_ag_svc_conn_open() anyway.)

Change-Id: I95dcdc5f46e7af723a655afd3d707764603c96c3
Signed-off-by: Markus Schmidt <shimodax@gmail.com>
fixed compiler warning on memset (2nd parameter should be 0 instead of NULL)

This is a fix for a warning when compiling bluetooth with debug.  Someone wrote memset(..., NULL, ...) rather than memset(..., 0, ...) which triggers a gcc warning (ubuntu 12.04)

Change-Id: I9ff2ef62f728a61afd0cceac6a1e65f0765c4c01
Signed-off-by: Markus Schmidt <shimodax@gmail.com>
Fix for BT HID devices using CoD other than COD_HID_KEYBOARD, COD_HID_COMBO and COD_HID_POINTING

For BT HID devices not using the CoDs mentioned above cached info such as HID descriptor etc is not deleted when the device is unpaired.
Bluetooth.org clearly states: "No assumptions should be made about specific functionality or characteristics of any application based solely on the assignment of the Major or Minor device class"

Change-Id: Icc387d4a5a742af5f374533997e0560dfb45c18a
Signed-off-by: Andreas Nielsen <fructel@gmail.com>
bta: dm: Don't use memcpy on areas that may overlap.

Change-Id: I52ba6a663732420db952a93779576f8988d26d2f
Fix tuna bluetooth with no strict

Change-Id: Iee30b20a49b343e03de31f275996a804254fc464
Fixed i2s call for headsets

Credits: maxell

Change-Id: I1bdf2ff5e8c475907aa8450af85116bafadd739d
libbt-hci: include bdroid_buildcfg.h from device repo

This lets device repos override some constants with their bdroid_buildcfg.h if
necessary.

This fixes Bluetooth issues (namely tethering) on endeavoru where
BTHC_USERIAL_READ_MEM_SIZE needs to be set to a higher value.

Change-Id: I8955963cdb2b34f1ba63f8160861699f7284814f
a2dp hw: adding a2dp tuning through bdroid_buildcfg.h

This adds possibility to configure a2dp tuning on an
arbitrary sysfs path and arbitrary ON/OFF values.
It's activated when a2dp is being used, and
deactivates when a2dp is stopped.
This way a device can either use an a2dp_tuning sysfs file
or cpu scaling min freq sysfs path with a target
min_freq value for elevation.

Here are two example of the two strategies of usage for
this:
bdroid_buildcfg.h - sysfs tuning file
 #define A2DP_HW_SYSFS_TUNER "/sys/devices/platform/tegra_uart.2/a2dp_tuning"
 #define A2DP_HW_SYSFS_TUNER_OFF "0"
 #define A2DP_HW_SYSFS_TUNER_ON "1"

bdroid_buildcfg.h - scaling min freq file
 #define A2DP_HW_SYSFS_TUNER "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"
 #define A2DP_HW_SYSFS_TUNER_OFF "0"
 #define A2DP_HW_SYSFS_TUNER_ON "204000"

Change-Id: I2cd94e626eb2a6d04a6e52ddac94fa5773eb09d8