Revert "Fix up for 4.3"

This reverts commit 7b88aad11af0931435ea319a9e738b908c6729eb.
HID: Establish Interrupt Channel when Control channel is configured

This patch starts establishment of Interrupt channel only when HID Control
channel has been properly configured.

Change-Id: I28f1100abeece9255fbdd5df312236c18baebe17
CRs-Fixed: 465491
(cherry picked from commit eab9bd1ed7231fb15c28dc5b1e7ed34ffaf0c142)
(cherry picked from commit 377c7d49c0d1b34116ff03b1922206dc73252cee)
(cherry picked from commit 31557f77a334c6138dcef9e7ca0398c218c05939)
Bluetooth: Send Interrupt req only when control is configured

This patch sends HID Interrupt Channel connect request to remote device
only when HID control channel has been fully configured, i.e. both sides
have sent and received configuration request/response for Control channel.
Without this patch it was seen that DUT was initiating Interrupt channel
request as soon as config request was received from remote side and before
sending config request to remote side.

Change-Id: I408f3a6f315c9a308717a138755e4d43a50a4b7a
CRs-Fixed: 532763
(cherry picked from commit b7d148ccd021a76215e7114a3ae3e2551b6fcf0d)
(cherry picked from commit 89ef67e0718a277107b53f2c08bd93eaaf13dbb3)
(cherry picked from commit b67998fcc09b50166e9ef266cd0ec2dfde8d3763)
Bluetooth: Reset Disconnect Reason on Connection Establishment

This patch resets the disconnect reason to successful on HID Interrupt
channel establishment. Without this change, wrong reason is propogated
to BTA layer on disconnection initiated either from DUT or Remote end.

Change-Id: I42641b511e44a761574faf8eafb7b0826e24aeb3
CRs-Fixed: 516328
(cherry picked from commit fb5fe418bc658253240c0fb1cfe62b17769f50f8)
(cherry picked from commit 24d95da9b43910267a1cba21433138af945df014)
(cherry picked from commit dd250c5787197ae80f51b19432d1e9cb86ddf59e)
Bluetooth: Store bonded HID device info into NVRAM.

Store ssr_max_latency and ssr_min_tout for bonded
HID device into NVRAM.

CRs-fixed: 476133
Change-Id: I87d8b6181981090df21ab746deac7053a1d0e938
(cherry picked from commit 301547a3985e02dc2402bad04f997566781ccd80)
(cherry picked from commit 6da0d6ee988cf275d8fc133fdd8372256c47dbbd)
(cherry picked from commit c6557d12068b972a04b2a8d1b0727d0e9d627080)
Bluetooth: Fix type of max latency and min timeout used in NVRAM

This patch fixes regression caused by commit
b6264c2464da28359291eb6785479b236bfc11e7 where Max latency and Min timeout
were being stored as 8 bit unsigned integers, instead of 16 bits unsigned
integers, resulting in loss of data. Max Latenency and Min timeout values
were not being copied properly resulting in wrong values being sent during
BTA_HH_ADD_DEV_EVT. Also some other side effects left from the commit that
entry was not being removed from NVRAM and duplicate entry additions have
also been fixed in this patch.

Change-Id: Ia316646ea85c874902a979637a7681dbf492bd2f
CRs-Fixed: 533988
(cherry picked from commit 9547e6c14750ea60a78216261c09d30864b4af76)
(cherry picked from commit ca0e412bf3c52c9b205b2f8fb2215a7e60ac7fd5)
(cherry picked from commit 2708868d27b3bc0fdaed033ff5f088a05a8b3b7f)
Bluetooth: Allow reconnection from Host on paired HID Device.

Host can send connection request when paired HID device
is in disconnected state. we are not checking the
NORMALLY_Connectible flags from sdp record, and anyways
sending this request from host, for subsequent user initiated
connection. If the remote HID is not in pagescan mode, we will
2 retries to connect, before giving up. If the remote HID is
in page scan mode, it will get connected.

CRs-fixed: 463916, 478811
Change-Id: I2b3c5c25dc7b08ab6ed0c3667897e5ea0f05f914
Conflicts:
	btif/src/btif_hh.c
(cherry picked from commit c43a6f0a4ce3f853631423bca01a48929b8d3469)
(cherry picked from commit d7b254774702a0921cc91ba8fec609d017f5dfaf)
(cherry picked from commit 0bd47cf763acbb5a9e874052febedbe38358ed87)
Bluetooth: Setting authentication req to Low for Pointing devices.

If a HID Mouse is 2.0 device, it doesn't support bonding procedure.
If it is a 2.1 device, then authentication is mandatory and the
security level would be reset to HIGH. Since authentication is now
not performed for 2.0 HID mouse devices, SDP is triggerred before
L2CAP Control Channel creation which updates upper layer of pairing
being complete.

CRs-Fixed: 465421
Change-Id: I5947024e8817e9bacc05b7e5865d0aa78901f855
(cherry picked from commit fa65d4ac5d7b056e7750a2a1db0114ac8343b4da)
(cherry picked from commit 470f3349136522ce9dea363b431bf7d0145e89b1)
(cherry picked from commit 6d7703ebcbc1e986b98cf59fd54564c6f9469ed1)
Bluetooth: HID: Remove bond on connection failure

This patch sends bond state changed message to upper layers, when
bonding with HID devices fails due to connection timeout. Till now
upper layers were not informed of Bond state cahnged as None in
case when remote device is switched off or is not in page scan
mode.

Change-Id: Ib7920e4bd26f58bdc71503f2dffb4d59fdb6c5a7
CRs-Fixed: 514544
(cherry picked from commit 8977378244e2d89b868f96002ceb8b2e91074009)
(cherry picked from commit ed5f1a257c75a6ca449b115cc2c0fa11332a1c9c)
(cherry picked from commit 9c741e223d88b2f5bb7c33f51cabd3fede6067d5)
Bluetooth: Initiate RNR for HID Pointing Devices if no name.

This patch initiates Remote Name Request for HID Pointing devices in case
name is not known before initiating HID L2CAP Connection. Once remote name
is retrieved, name is stored in NVRAM and upper layers is informed
of name of remote device.

Change-Id: I6ecf07c222f804dcfcedd84fc1ff26ffe5bcbdc8
CRs-Fixed: 519771
(cherry picked from commit c9275e5e411009fae1369cb2e9d6d871d8af47e0)
(cherry picked from commit fcc4a0f5d64858278c3562ae1dc8a034c36fedc1)
(cherry picked from commit 601101f5526acec343636ad3a3ff69f1210c9ee2)
Bluetooth: Add support for disconnecting HID based on priority

This patch adds support for disconnecting the incoming HID connected based
on priority of remote HID Device. If user does not want to connect HID
profile for a particular remote device, priority of remote device would be
set to 0. Based on priority of remote device, incoming connection would be
disconnected if priority is 0.

Change-Id: I97002a46a16d386a6c178445ac825788d6bf40c9
CRs-Fixed: 532234
(cherry picked from commit 3cacb2a9b77f32ad8db6af6ae90b8a94707769c4)
(cherry picked from commit b83ce18a9b7bcc9bb70ffc08f8fb44a31390b48e)
(cherry picked from commit f692bf0af2a1383c0dab09fb865f564cfda7afcd)
Bluetooth: Save HID information into NVRAM immediately

This patch saves HID Device information into NVRAM immediately when storage
functions are being executed. Without this patch, HID info was only
buffered and was only written to NVRAM when some other API's like when
remote device version is retrieved or new device is paired.

Change-Id: I79098645fa35adf8ca39b91f140ad97a442f8f12
CRs-Fixed: 537522
(cherry picked from commit 2e33a1df09b0a1b610105d5ee45d07f26119cb21)
(cherry picked from commit f5ac0c6911d54fbc9c83726aa5aaea8cec9e6008)
(cherry picked from commit 6a62c686dbd0078cd7f6700844b70952d7cf9f06)
Bluetooth: Handle closing of UHID Poll thread from btif context

This patch handles closing of uhid driver from btif context instead of
bta context. since now uhid close would be handled in btif context, bta
thread would be unblocked for handling avdtp media packets.
Wihtout this change bta thread was getting blocked upto
max 500 ms when HID is disconnected, which caused delay in sending
of AVDTP Media packets during A2DP and HID concurrent test cases resulting
in audio break on BT headset dueing HID disconnection.

Change-Id: I4bc5bbcc07416752cdea08e896c86ec3457088f4
CRs-Fixed: 543015
(cherry picked from commit 7e9e9a9813a855cb8f3c6441f90a7c2e7f03709d)
(cherry picked from commit 66a0e71a60f614449b3fb561b3952b2375e10f74)
(cherry picked from commit 297b778ea0211a6f67be5a0671cd0cecafb849c7)
Bluetooth: Added HFP features bitmask function.

This function gets excuted when application
sets the value of HFP features support and
ignore the stack's default bitmask.

CRs-Fixed: 482189
Change-Id: I2e355c4e3aed35ca4d1f65001d4641f94e1f2b46
(cherry picked from commit 8b5fca8e0a01a695e1cb9150dd84fa24f8218e00)
(cherry picked from commit 2739781e3c4d0808f64677cbdd7a27851d9cce14)
(cherry picked from commit 698deaa4fc25a7a03f1954ec5f2995cc1091051e)
Bluetooth: Getbuf returning invalid buffer pointer

Getbuff is checking for the pool which can accommodate
requested size, but it changing the pool with a restricted
check and not checking for the free memory size in that pool.

Added a check to avoid returng the wrong pool free buf pointer.

Change-Id: Id66d460c5a40d8c3208438d7cfaf729e9b355184
CRs-fixed: 513060
(cherry picked from commit ff78451da086271527883a20081ef57d56285c0c)
(cherry picked from commit 1afebc80fce8d239be4e792594f57c7f0e74919d)
(cherry picked from commit d7cebd4f532f8e6e43fbc77d3c8a8eb293e7646a)
Bluetooth: Enabled the WBS in BT stack.

This change enables compile time flag
BTM_WBS_INCLUDED in the stack.Enabling
this flag enables the WBS codec negotiation
code in the stack. Along with this
it allows BTIF layer to notify
the BT app about the codec negotiated and
changed.
All changes in stack is gaurded
using BLUETOOTH_QCOM_SW feature flag.

Change-Id: I1c08e33b39a51a23822530ebfc925a9b9e96712f
(cherry picked from commit c98e680303d10866d41319f46e14081838d8fc29)
(cherry picked from commit 0ea6d93c0d5d0e572af8e2c06f4ad7bd733c9d00)
(cherry picked from commit 7e091b0066a7e4d00f0bfa05dd788818f696731e)
Bluetooth: Avoid to advertise PANU service records.

This is special case where remote device(PC) acts as PANU
& is trying to connect PANU on DUT instead of NAP. Because
DUT had advertised PANU service records on SDP. As DUT does
not support PANU-PANU connection, So connection is dropped
every time. As per spec, It's not mandatory to advertise PANU
service records, So PANU service record should not be advertised
on SDP to solve this issue.

Change-Id: I1f733467335b5e0ca00899cf4380860d233aab33
CRs-Fixed: 520804
(cherry picked from commit 0e0811014cc1dc222de0f18b93023b0ff182cc2c)
(cherry picked from commit 1332c3c8cfbeaf0bae076383aa3be17daac9a1e5)
(cherry picked from commit 54e0ef1180640b3333330579657737adb15bdb75)
Bluetooth: Adding support for 5th PANU connection

DUT(NAP role) can be connected up to maximum 4 remote devices
(PANU role) as per the current implementation. Adding support
for 5th PANU connection, So DUT(NAP role) can be connected up
to maximum 5 Remote devices(PANU role).

Change-Id: Ic687c56bded40e5e79099ef3c31d40e10b8531c8
CRs-Fixed: 463828
(cherry picked from commit 2ff000c8fb06168e9b440834b2a62c1a6d2f8b0f)
(cherry picked from commit 6641fb84039a1ef3c438712908f5d8895265538d)
(cherry picked from commit 99547011cdacdb2294cdcc7ff919dc55d8c089d0)
Bluetooth: Adding Sniff feature for PAN Profile

Sniff feature for PAN profile was not implemented in power
manager module of Bluedroid stack, which was causing this
issue. Adding sniff feature for PANU role & NAP role to solve
this issue.

Conflicts:
        bta/dm/bta_dm_cfg.c

Change-Id: Idf568f53a317abd536edf34fbdf1733fdf53b7d0
CRs-Fixed: 525517
(cherry picked from commit 70041241d84b837110fb97187ac91d65856e9301)
(cherry picked from commit a8b9eea2abe08e0dfc7ce60a8712a1f010b60171)
(cherry picked from commit 79a028230de35c2c65683676642846ce6ed65b57)
Bluetooth: Update held call state.

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

CRs-Fixed: 538599
Change-Id: I936c6563dfb429ff977ac993ac994d59fc58528b
(cherry picked from commit b31955e99c4258501f53301aac1e635169f9d1a5)
(cherry picked from commit 0bc840ebc516e5fd74f5d5dde58241d6fd5f9148)
(cherry picked from commit 86194d195eb7ae8700c00f0d3cbc941a11a3d4b6)