Bluetooth: GAP: Add NULL check before accessing the Node

NULL check added before accessing the Bluedroid interface
layer configuration node variables.

Change-Id: Iedf1e3550037d2ce5c422ace25c07c05da7329a7
Bluetooth: Clear remote suspend flag on play state change.

Remote device may initiate AVDTP Suspend within 3s of AVRCP pause,
in that case flag is set which prevents further a2dp data.
In case DUT initiates play before standby, remote suspend flag
won't be cleared and start fails.
Change made to ensure on Avrcp play state change event, flag
is cleared.

Change-Id: I1a0f96086030cf06bbebe3de0f2bead7846c19e3
Bluetooth:DUT to initiate Sniff after A2DP Pause.

Host does not initiate Sniff after A2DP pause.
Change is done in HF Power Manager table such
that Sniff timer starts once HF is in idle and
A2DP is paused.

Change-Id: I25608db3e2b8cfe8f44b10894d5d3a7388b54ed5
CRs-Fixed: 545681
Bluetooth:check vendor data pointer while parsing AVRCP command

Changes made in avrcp_pars_vendor_cmd to have NULL check for
vendor data.

CRs-Fixed: 574911

Change-Id: I6faf9ab30fa836087bb1b3c79151f7d0f347015d
Bluetooth: modifies write Client Conf characteristics api

This changes api to use write_request to enable notifications
for hid reports. it ensures notifications enables by
receiving successful  write response for request.

CRs-Fixed: 576382

Change-Id: I4c18f2cb727a7aabddaa5c965b29eca78843fc7a
Bluetooth: Avoid overlapping Disconn commands from Host

In case the host doesnt reply to the pairing request,
and waits for the timeout, the timout causes a "disconnection"
and is folllowed by another one by SMP state machine,
at the pairing complete event. This changed adds a check,
to ignore the disconnect command, in case another one is in progress
to the same link

Change-Id: Ib71740bed80375fb44487e89600f05519cd58b10
CRs-Fixed: 546854
Bluetooth: Handle getCapability failure for Incoming Connection

This change takes care of handling GetCapability failure event for
Incoming Connection. DUT will initiate disconnect if GetCapability
response is failed.

Change-Id: Icc121739cc3da6f999a09f2e576cbfaec3007155
CRs-fixed: 506864
Bluetooth: Allow connection update after conn update request is enabled

This change maintains the PENDING state for connection update
requests sent by the remote. This allows the central to update
the connection parameters requested by the peripheral after the
conn update requests are enabled (after SMP pairing and service
discovery completes).

Change-Id: Ib17730ee011e2457de5d8b1a2c2eba9a88f71bc7
CRs-Fixed: 562319
Bluetooth: Check A2dp state inside mutex lock.

In race conditions A2dp state was updated to suspended
after checking and before acquiring mutex lock.A2dp State
should be checked inside mutex lock to avoid checking against
inconsistent state.Prevent overwriting of state
from AUDIO_A2DP_STATE_SUSPENDED to AUDIO_A2DP_STATE_STOPPED
which would again start the data path.With this change we make
sure to check state inside mutex lock and also avoid overwrite
of state in case of write failure.

Change-Id: I1d74490057fea06113dcf4e0666387f4d5224157
CRs-Fixed: 572205
Bluetooth: Introduce open/close interfaces for ANT

Introduce Open/Close interfaces for ANT so that ANT module
can retrieve the ANT channel for send/receive of ANT data

Also Enables Bluetooth clean turn on flag so that there will be
no unnececessary turn off happens before Bluetooth turn-on
is dispatched

Change-Id: I8583ca529d7aae0b6a18813e200a8a2643b31fb1
Bluetooth: HID: Properly check if SDP is required on HID device

This patch clean up HID Outgoing connection for pointing devices
by preventing multiple SDP to HID Pointing device by checking if
outgoing connection is already in progress or device already
connected. Without this patch, connection state was getting stuck
with pointing device that required authentication when another
HID conenction was disconnected in between.

Change-Id: I552fece5de8d361695f0ca3fb7e58d500e3a1e33
CRs-Fixed: 576827
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.

CRs-Fixed: 568382,579638,569034
Change-Id: I9699c8225a77d9272420334b4c76b3c1df87e459
Bluetooth: Add MMS in sdp record attribute

MMS was not listing in sdp record attribute, hence add change
to set the same because we support both sms/mms in map.

Change-Id: Ia3410e6027500856af1472ef9da4c3e7f09bfe4e
CRs-fixed: 574281
Bluetooth: HID: Delay disabling HID until active connections

This patch delays GATT layer from disabling HID Host layer when BT is
switched off when DUT is still connected to remote HID Devices.
Once disconnection is complete, disabling is reinitiated.

Change-Id: I0cd484b0e983b39f5989c92463f67e2e4e84503a
CRs-Fixed: 575023
Bluetooth: HID: Add support for HID Device Role

This patch adds support for HID Device role in bluedroid stack allowing
phone to be used as Keyboard or Mouse.

Change-Id: I45b581a54f6c7bbc1f25226715a7ea23e34255c0
CRs-Fixed: 573086
Bluetooth: Avoid  a BD stack crash due to NULL pointer

While accepting PBAP connection request. Power manager
Callback is NULL on JV layer. Which leads crash in BTU
task While accessing power manager state for PBAP profile.
This Patch will avoid crash.

Change-Id: I2f65971c78b63202d9f9e4ca46981b52d33fa2a0
CRs-Fixed: 580154
Bluetooth: Notify BT APP about alias as the name if present

While scanning notify the Bluetooth APP about the alias name
as the actual device name of snanned device if alias name is
present.

CRs-Fixed: 539420
Change-Id: Id8a093b1503eb3f308f466f30c1a4a6f4c250594
Bluetooth: GAP: Update Security SM state properly on collision

Change the security SM's state to BTM_PAIR_STATE_WAIT_PIN_REQ
on transaction collision.

Change the desired role to master when accepting a connection.
Also avoid sending the disconnect incase of HCI_ERR_PEER_USER.

Change-Id: I1d5dfee237d8b2813f234ba7ee69facd7e78112a
CRs-Fixed: 579612
Limit number of sbc frames to fit into single MTU

Calculate number of sbc frames to fit into single MTU
for EDR capable remote. This makes sure the maximum
utilization of available bandwidth keeping the bitrate
as high quality one.

CRs-Fixed: 573451

Change-Id: Ibe917a303284f3eba9f845309083cd08b78680d0
Bluetooth: Retain the old COD if already present

Retain the old COD as the initial value if the device
entry already present in the list and entry is not in use.

CRs-Fixed: 546135
Change-Id: I99b7269b1976ef7458c6568441e6e3c1e015a75f