OSDN Git Service

android-x86/system-bt.git
7 years agoBluetooth: GAP: Serialize the commands during Pairing process
Srinu Jella [Wed, 18 Dec 2013 06:27:33 +0000 (11:57 +0530)]
Bluetooth: GAP: Serialize the commands during Pairing process

Serialize the Remote version, Remote features, Authentication
requested commands.

This will make sure the above commands doesn't go simultaneously
to the remote device which can't handle the multiple comands
at a time.

Change-Id: I4448c291a60ee637dc5927806547e67f26571d86
CRs-Fixed: 896888

7 years agoBluetooth: SDP: Syncronize sdp callback functions
Venkata Jagadeesh [Tue, 21 Jun 2016 10:28:29 +0000 (15:58 +0530)]
Bluetooth: SDP: Syncronize sdp callback functions

Syncronize sdp callback functions in sdp server to
avoid race conditions in create/remove sdp records

CRs-Fixed: 1003295
Change-Id: Idb7a3e0a011c8ecd0d127d110e67e6a9a13a8ee9

7 years agoHID: Re-enable sniff with specific parameters to prevent LAGS
Hemant Gupta [Fri, 24 Jun 2016 14:25:52 +0000 (19:55 +0530)]
HID: Re-enable sniff with specific parameters to prevent LAGS

Usecase:
1. DUT Connected to BT Headset and MAgic Mouse
2. Make an outgoing call from DUT
3. Perform inquiry on DUT and check mouse movements.
4. Disconnect call from DUT/remote end.
5. Check Mouse Movements

Expected Result:
No lags should be seen with Mouse after call is disconnected.

Observed Results:
Lags are observed with Mouse after Call is disconnected.

Root Cause:
Remote BT Hid Mouse is not able to work with larger sniff parameters
so does not send Input reports leading to lags on DUT.

Fix:
Update sniff parameters to lower values (<15 ms interval) after call is
disconnected so that remote device works fine. Also as part
of SoC workaround, sniff should be disabled with blacklisted devices
only when DUT is slave on SCO link.

CRs-Fixed: 1039149
Change-Id: Ifa01abcae59b6f87842a763330b3a9f23511a675

7 years agoHF CLIENT: Change to disable sniff with specific Phones.
Satheesh Kumar Pallemoni [Fri, 24 Jun 2016 06:17:35 +0000 (11:47 +0530)]
HF CLIENT: Change to disable sniff with specific Phones.

When device is configured as hf client and connected to
AG, if AG goes into sniff, there may be disconnection
of hf connection with AG.We get information of AG's
manufacturer and model information using AT+CGMI
and AT+CGMM commands. We should disable sniff if AG's
model is known to have issues with sniff.

CRs-Fixed: 1021809
Change-Id: Iedfb8cbec7f716aadc83d511127834043eccfd57

7 years agoFixes for Issues reported by Static Analysis tool.
Satheesh Kumar Pallemoni [Fri, 1 Jul 2016 08:50:57 +0000 (14:20 +0530)]
Fixes for Issues reported by Static Analysis tool.

CRs-Fixed: 1036860
Change-Id: I0f4a69cbb4e47ecd333b14c2ff9fe0861166f858

7 years agoBluetooth: Kill the BT process immediately on detecting SSR
Ajay Kumar [Fri, 6 Nov 2015 07:43:42 +0000 (13:13 +0530)]
Bluetooth: Kill the BT process immediately on detecting SSR

Kill the BT process immediately on detecting SSR

CRs-Fixed: 801039
Change-Id: Id5007914140aa26c08579ca85f7622c79d73a00f

7 years agoaptX audio codec support
Umesh Vats [Tue, 21 Jun 2016 21:07:49 +0000 (14:07 -0700)]
aptX audio codec support

Support for a proprietary codec(aptX) based bluetooth audio
streaming   added.

CRs-Fixed: 962515
Change-Id: I821875227e168f9b74571c0ca814e577873b2f88

7 years agoBT: Fixed Static Analysis Issues
Matadeen Mishra [Tue, 7 Jun 2016 12:41:33 +0000 (18:11 +0530)]
BT: Fixed Static Analysis Issues

  - This fix avoids NULL pointer dereferences,
    Array Index Out of Bounds Exceptions
    and Banned funciton in the Fluedroid code
    space of Bluetooth.

Change-Id: If389820b427f39e1030013f14d5538d7c99ce9c6
CRs-Fixed: 1025718

7 years agoBluetooth: Introduced new interface for handling VS implementations
Manu Viswanadhan [Wed, 25 May 2016 06:47:20 +0000 (12:17 +0530)]
Bluetooth: Introduced new interface for handling VS implementations

Introduced new interface for handling vendor specific implementations

Created an API in the vendor interface that initiates SSR cleanup
that will be called in the case of enable and disable timeout.
SSR cleanup is called when the Bluetooth shuts down abruptly.
It sends vendor power OFF to the controller so that the next
startup occurs properly.

Created an API in the vendor interface that will be called while
transitioning from TURNING_OFF to BLE_ON, which cleanup the BREDR
profiles (from the btif layer). A callback is initiated from btif
layer which is redirected by the interface to the original implementation
of stopping the BREDR profiles. Also, since the cleanup for BREDR
profiles in the btif layer already happened during transition to
BLE_ON , the cleanup during BLE_TURNING_OFF to OFF is limited to
BLE profiles.

CRs-Fixed: 1027432

Change-Id: I4c0e8468aa71e1eeee7e81b39e71ad9f711c7a3e

7 years agoMisc AV changes in stack
Sumit Bajpai [Tue, 14 Jun 2016 09:55:37 +0000 (15:25 +0530)]
Misc AV changes in stack

1) Update UI on remote's browsing support.
2) Avoid sending get capability request if Avrcp TG.
3) Use Interop database for Abs vol.
4) Add 30msec uinput delay upon creation.
5) Role switch failure handling.
6) Misc A2dp/Avrcp handling.

CRs-Fixed: 1029888
Change-Id: I2e86285da9e9a0b7c5180fbefeb7665f62ac77cd

7 years agoAVRCP: Fix array index out of bound KW error.
AnubhavGupta [Fri, 3 Jun 2016 08:11:39 +0000 (13:41 +0530)]
AVRCP: Fix array index out of bound KW error.

 - fix array index out of bound KW error.

Change-Id: Id6531852141bcf53dc2132aa106a84179ec008e2

7 years agoFix issues reported by Static analysis tool
Satheesh Kumar Pallemoni [Tue, 7 Jun 2016 10:20:05 +0000 (15:50 +0530)]
Fix issues reported by Static analysis tool

CRs-Fixed: 1025718
Change-Id: Ie1f32028226f4f8e89e545bb75ef1a2a65a3b846

7 years agoEnable Sink with multicast
Venkateshwarlu Domakonda [Wed, 1 Jun 2016 13:28:05 +0000 (18:58 +0530)]
Enable Sink with multicast

Enable support for sink with multicast.

Change-Id: Ie9cb33ba102e585387a908fe821f93520ad8a860

7 years agoAVRCP(T): Add support for AVRCP 1.6
Hemant Gupta [Mon, 24 Aug 2015 11:21:38 +0000 (16:51 +0530)]
AVRCP(T): Add support for AVRCP 1.6

This patch adds supports for following AVRCP 1.6 target features:
    - Get Total Number of Items
    - Cover Art Feature

CRs-Fixed: 715683

AVRCP1.6: Reset Cover Art supported feature bit

Reset Cover Art supported feature bit in SDP record if
fallback to lower version.
Change-Id: I47bdc5dcbc777ba3afb90be1d52b0f6a152dde7b
CRs-Fixed: 956637

Update conf file only if Avrcp 1.5 or 1.6 is enabled

Update conf file only if Avrcp 1.5 or 1.6 is enabled.
CRs-Fixed: 963208

Change-Id: Ib8e81cc57a8060202dbfb2b90b5009f8d504529e

BT-AVRCP: Queue txn labels for same PDU.

If AVRCP CT sends same PDU request multiple times in
quick succession, TG ovewrites the txn label against
that PDU. This causes TG to respond with incorrect
txn labels

Change-Id: I0c9b10f0eb0e7cb695c224d8fe26f5c447ba7d93
CRs-Fixed: 995483

Change-Id: I58ec30ae039f78c59422b5612ebb9ef65a03e2dd

7 years agoCleanup L2CAP socket properly on close
Srinu Jella [Thu, 7 Apr 2016 13:35:44 +0000 (19:05 +0530)]
Cleanup L2CAP socket properly on close

Use case:
1. Sometimes pairing pop up occurs during Android beam
   transfer though it is not required.
2. No OPP Tx request over OBEX if we cancel during file transfer.

Steps:
1. Pair and connect from DUT to remote.
2. Go to gallery and send a file.
3. Accept same file and stop it from remote during transfer.
4. Repeat step 2-4 10 times.

Failure:
OPP Tx should not fail.

Root cause:
Close request was not properly handled from BTIF layer.

Fix:
1. Close the request properly from BTIF layer
   to close the socket variables and instruct the BTA layer
   close from there as well.

2. Clean up L2CAP socket properly on closure to free
   the entry registered with security manager to avoid
   leak in security manager records.

3. Close the socket for all valid handles including handle 0.

Change-Id: I4e37dcd858af258fbd64fbfb2fbf0083bd743e06

Check ccb state before executing channel state machine events

Use Case: When disconnect response is being executed, timeout
occurs and timeout event gets enqueued in BTU process. When
processing of disc event completes, timout event is received
at csm and is executed. However, by this time the Channel
Control Block is already released during previous event causing
errors.

Steps:
Various connection/disconnection scenario.

Failure: If ccb is already released while processing of
previous event, the occurance of new enqueued event causes
crash.

Root cause: Disconnection response event has already released
ccb and set lcb for this channel to null. The occurance of
timer event after this results in crash because lcb is
dereferenced while header creation to send disc response to
peer device.

Fix: Added check for ccb state for whether it is currently in
use or released before executing events in csm.

Change-Id: I9110e6dd5273fa162b51c8aa15bd0030567d664b

Handle L2CAP disconnection on incomplete connection

- Sometimes before even receiving the connection complete
  event from remote device, upper layer might send a
  disconnection on incomplete L2CAP connection, and expects
  notification of connection failure.

- This chnage notifies disconnection confirmation to upper
  layers with error incase L2CAP disconnection is received on
  incomplete L2CAP channel.

Change-Id: I4ab675329b3d791a3f68101495a6e6d90b13bde4

L2cap: Handle invalid HCI packets from Test tool

- Handled Buffer over flow for UINT16
- Handled full packet size more than gki buffer case.
- Discard invalid HCI packets from Codenomican test
  tool as data length and actual data not matching
  during reassembly

Use case: Execute L2CAP test suit from Defensics Codenomican

Steps:
1. Pair and connect DUT to Codenomican tool
2. Execute L2CAP test suit from Defensics Codenomican

Failure: Crash observed on DUT and Codenomican tool stuck in execution.

Root cause: Codenomican tool sending invalid HCI packets to DUT and
there are no checks to handle buffer over flow and other invalid data
from Codenomican tool.

Change-Id: I6f93c80244fc39d607ad285185136bbbca83d7ae

Increasing LE Properties to broadcast.

Use case: Remote BD_NAME is not broadcasted when BLE device
pairing is done by using NFC where we broadcasted only UUID.

steps:
Connect with BLE device by using NFC and check the remote name.

Failure: Remote device name is not available.

Root cause: BD_NAME is not broadcasted when BLE device pairing
is done.

Fix: Added property to broadcast remote BD_NAME also as part
BLE device pairing using NFC.

Change-Id: Ie6cda489aabff15a0ebbc692a16f9428729a7dba

Reset the pairing_cb for BREDR/cross key pairing address

Use case: HID connection stuck during multi pairing.

Steps to reproduce:
precondition:
1 DUT
1 Headset HFP supported -- Pair and Unpair
1 HID mouse -- Pair and Unpair

Steps:
1. Pair and connect HFP remote device HM1700
2. Pair and connect HID remote device Sculpt Touch Mouse
3. Unpair both the remote devices and check them in the available
   devices list in settings app.
4. Initiate HFP connection from remote device HM1700 by
   resetting the headset.
5. Along with above step, initiate HID connection to the mouse from DUT.
   Along with step 5,Power down the HID mouse to avoid another connection.

Failure: At step 5, Observe that HID mouse shows ever connecting state in
the DUT UI.

Root cause: pairing_cb state is reseted for non pairing device and leading
to stuck in pairing to other device.

Fix: Reset the pairing_cb structure for BREDR or cross key pairing address
only. Without this check pairing_cb state can be reset by other non
pairing bd addresses which can lead to stuck in pairing.

Change-Id: I077bebffac9df7a0c7559af58656651467158c14

L2CAP: Allocate sufficient memory for FCS while cloning buffer

Use Case: OPP file transfer using OBEX over L2CAP.

Failure: Crash seen while sending the file using Obex over
L2CAP due to corruption in end canary.

Root Cause: Did not allocate sufficient memory for FCS
while cloning the PDU packet, eventually FCS bytes written
will corrupt the end canary.

Fix: Allocating sufficient memory for the PDU packet which
includes FCS also.

Change-Id: Ie47b9bc07732b02f774d1dce474d488fe063f50b

Don't process pair request when controller is not ready

Use case: when one application is trying to pair and
other application is turning off bluetooth.

Steps: when one application is trying to pair and
other application is turning off bluetooth.

Failure: Bluetooth process crashed.

Root Cause: Bluetooth process crashed due to assertion,
as controller module is not ready.

Fix: Made a checks for controller module is ready or not, If
it is ready then only go for pairing.

Change-Id: I72c72f6b5545c845e79874212359854023ffad98

Add null checks for L2CAP socket callback

Use Case: Bluetooth process crashed while sending the file
to remote device.

Steps: Send a file over L2CAP (OBEX over L2CAP) to remote device

Failure: BT process will crash and restarted automatically

Root Cause: L2CAP socket callback reset to null on error
condition, and when other function try to dereference it, this
leads to BT crash.

Fix: Added null checks for L2CAP socket callback

Change-Id: I2e4f20278fcc8a09bd4dbd507a6c4147e0de93c1

Handled pairing state change in collision scenario

Use case: DUT Stuck in pairing state forever with selfy stick
during repair.

Steps:
1. Pair and connect remote devices with DUT.
2. Now un pair selfy stick from DUT.
3. Keep remote in discoverable mode.
4. Start inquiry and try to pair with device.

Failure: Pairing with selfy stick always fails after collision.

Root Cause: As we return from btm_sec_dd_create_conn with out
moving pairing state in connection collision scenario. Pairing
state will remains idle and pairing won't proceed further.

Fix: Move the pairing state in collision scenario so that pairing
can proceed further.

Change-Id: Ic5c446ad3902b0ce16c7223ec2d8e4a625831446

Conflicts:
stack/l2cap/l2c_fcr.c
Change-Id: Ia83fbcf2477152005dd60cf8344ce1db708b1379

Conflicts:
hci/src/packet_fragmenter.c
Change-Id: I1ebcd267713ee4799cba4f9ab45a2db7300c60da

7 years agoBluetooth: Enable A2dp Multicast.
Ayan Ghosh [Mon, 25 Aug 2014 12:47:48 +0000 (18:17 +0530)]
Bluetooth: Enable A2dp Multicast.

This feature enables the multi
streaming support on BT HOST.

Change-Id: Ic3748c32b30036abd352c9322e30a704b2103fa7

Bluetooth: A2dp MultiCast/ Soft Hands-off.

 - Trigger suspend, when new ACL is up during active
   multicast
 - Initiate suspend on both links when it is initiated by
   either connected HS
 - Clear remote suspend flag when play is initiated by either
   connected HS
 - Allocate first free SCB when remote has initiated AVRCP connection
   and we are trying to connect to other HS
 - Update Encoder when HS2 is connected during
   active streaming on HS1
Change-Id: I7ccfb81637688c23c6a2b005f849ac76cc0dbd2a

Bluetooth: Initialize RC handle with proper value.

 - Initialize rc_handle with 0xFF
 - On disconnect re-set rc_handle to invalid value.

Change-Id: Id507114451701e998f9960aa5dc961ff16f2d1bf

Bluetooth: Do not register for Volume change.

 - When absolute volume is not supported by any
   of connected HS do not register for volume change
   notification on connected HS.

Change-Id: I3b29ac5929989bc7c45b1b0f8cbe75b3082e66d3

Bluetooth: Use SCB handle for Sniff.

 - Use scb handle for making entry for sniff instead
   of audio count.With Multi A2dp audio count denotes
   number of A2dp devices connected.Due to this stale
   entries were created for AV power entries, due to
   which links did not go to sniff after max entries
   in table is reached.

Change-Id: I051017991c7d3d7d42c4822efdad2b2aa1b0e2b2

Bluetooth: Use free SCB for Incoming connections.

  - In connection race conditions, check for
    first free SCB to allocate for incoming
    connection.
  - Initiate disconnect for incoming connection when
    no free SCB is available.
  - Check for max. possible connections before initiating
    suspend for new link up-event.
  - Clear all flag on AVRCP disconnect.
Change-Id: Ic605b0470ca88aac856cefe54bf6c9ec5320bd5a

A2DP Multicast: Allow outgoing connections for scatternet

    - As there is fallback to soft handoff incase of
      scatternet scenarios, allow the outgoing
      connections in case of role switch failure for
      existing slave connection.
    - Reject the incoming connection from BTA while
      processing another incoming connection.

Change-Id: Ib8a087eea5e9845a6e2ef758757f941c1bdf7b52

A2DP Multicast: Disable multicast if BR HS is connected

    - Disable multicast if BR headset is connected
    - Use scb index for AV Busy and Idle state updates

Change-Id: If7310be4f47cbe0775eb35c0b81122d524be25f5

Dual A2DP: Avoid blocking Play key event

    - Send play key event for PLAY sent from non playing device
      to be compliant with default behavior for single connection.

Change-Id: Ie07fc10d3a946ca4e3f9643b2ae5e556358fd0b8

A2DP Multicast: Update multicast state after AV state update

    - multicast state update checks the AV state for updating
      multicast condition. Need to make sure that AV state
      is updated in OPEN state before calling the API.

Change-Id: Ifa0fd1a90ff5d8a05c37dba1590f76176d9899e0

Dual A2DP: Disconnect AVRCP only connection.

    - AVRCP only connection should be disconnected to avoid
      confusion to end user in the Dual A2DP/Multicast scenarios.
    - Proper check for RC connections before closing uinput.

Change-Id: Id515c3f29499a3ada02b8e45cc2189276152a461

Conflicts:
btif/src/btif_av.c

Dual A2DP: Allocate free SCB for incoming connection

    - SCB allocated to incoming connection should be idle.
      If not, ongoing connection handling will be affected.

Change-Id: Ideaab85b928f08b37c7a284644fd3a62926b15ec

Dual A2DP: Initiate outgoing connection only if the state is Idle

    - A2DP connection also could be triggered from remote device
      before the AVRCP timer expires. Check the state before initiating
      connection for the device.

Change-Id: Id538de6ce829a388a4c052769177319cd5c217fc

Dual A2DP: Don't suspend if stream is started for other device

    - Avoid sending suspend for remote initiated START if
      stream is started for other device. IOT issues are seen with
      specific devices if gap between SUSPEND and START is less.

Change-Id: I64d768aa8246101687bbc98b4ae0be97645bb5b1

A2DP Multicast: Update multicast state during role change

    - Role change can be triggered at any point of time
      during the connection. Update the multicast state
      upon getting role change event.

Change-Id: I60a17e955b6fdc4379d571c59d8527ec023e9531

Revert "Bluetooth: Do not register for Volume change."

This reverts commit c87e747f40b870b9a540902595524b34a5436b43.

Change-Id: I4752486979366f67e9109bd61df54dc48786f564

Dual A2DP: Set the flush only when there is no play in progress

    - When connected to two devices update the flush state only
      if there is no play on any connected device.

Change-Id: Ic13b7285625c49350334c35eed878407b6e78821

Dual A2DP: Handle connection inconstencies during stress scenarios

    - Avoid removal of connect nodes in profile connect queue
    - Dual Handoff flag cleanup during START failure
    - Reject the A2DP connection from remote device if it is
      initiated on the same endpoint where outgoing connection
      is being attempted.

CRs-Fixed: 835641
Change-Id: I4cc0d680e5cabb003dd11c8ba232d1fc70f41780

Dual A2DP: Mark the AVDTP busy during outgoing connection

    - AVDTP incoming connection cannot be handled when there is
      outgoing connection in progress as per the base design.
      Reject the incoming AVDT connection so that other
      connection can happen and A2DP connection is always
      attempted from connectOtherProfile path.

CRs-Fixed: 839392

Change-Id: Iff801a7e4f170aa85cd06278c7d62dfc81464b5a

Dual A2DP: Acknowledge the SUSPEND after both streams stop

    - Avoid on_suspended call when other stream is not yet
      suspended as it unblocks the audio process to send
      further commands.
    - Handle RC close to cleanup the BTIF RC block even if
      the current AV connections are for different devices.
      This was seen because of not getting AVCT disconnection
      response and later this event is received after getting
      ACL disconnection complete.

CRs-Fixed: 842690
Change-Id: I7eb95a9ddfc7be06af4521af1567e4e166630317

Dual A2DP: Disconnect the AVRCP only connection

AVRCP only connection has to be disconnected when it is evaluated
for A2DP connection and no free AV blocks are available in BTIF.

Change-Id: I3f6b731ed6701c739defbfd8e011bbb6a1aeb3ba

Conflicts:
btif/src/btif_rc.c

A2DP Multicast: Check for both streams for stream ready

    - Stream ready should succeed only after both streams
      are suspended during multicast, otherwise audio data
      coming will trigger inconsistent behavior for stream
      starting.

Change-Id: Ia8794dbed7dbe5f55cf7139b200fcdf2eb5ee45f

A2DP Multicast: Handle suspend for both streams

In race conditions, it is seen that ACL is established while
stream is being started for both devices for multicast.
Since the multicast state is updated after stream start when
suspend is initiated we need to check if both streams are
started and suspend them accordingly.

Change-Id: I23f64174914350b476022f7bfbfb553a55d12902

Dual A2DP: Clear the RC priority information while disconnect

RC priority information has to be cleared during disconnection
to avoid improper usage during start even after initiating
disconnection.

Change-Id: Ia52c04ea2bfecbf390aae12400073adb0f327718

Dual A2DP: Interface to query active device for handoff

During Handoff case, check the playing device and device to
start playback to provide state for given device.

CRs-Fixed: 856063
Change-Id: I3a326d9f0c6221cfc4cdcc3fad037f22a29ff90e

Dual A2DP: Connection failure handling for proper cleanup

    - Cleanup BTA AV block for the outgoing connection if
      it fails because of no resources
    - Reject the incoming connection if there is outgoing
      connection in progress

Change-Id: I44d3dd6bbff93d38c1c22260056897e42d915ffa

Conflicts:
stack/avdt/avdt_msg.c
Change-Id: Ie74102d0254fa73061b6baea9811d834fae64358

7 years agoBluetooth: Add Dialog mouse & KB to blacklist for LE secure connections
Nitin Arora [Wed, 6 Apr 2016 00:10:37 +0000 (17:10 -0700)]
Bluetooth: Add Dialog mouse & KB to blacklist for LE secure connections

This change allows the host to mask the Cross key bit in
the key distribution fields of the pairing request and
response while pairing with the Dialog keyboard and mouse
to prevent the remote from rejecting the DUT's pairing request.

CRs-Fixed: 1033619
Change-Id: I888b5ce8c12652ef5c393b304bed8948c4e6b444

7 years agoAVRCP 1.5 Implementation
Ayan Ghosh [Fri, 25 Jul 2014 12:21:32 +0000 (17:51 +0530)]
AVRCP 1.5 Implementation

AVRCP 1.5 Implementation

Change-Id: Ia35dc4344b05584cf5ab3b463815c9e6297d24ab

Proper check to ensure attributes are populated properly

Incorporated proper check to ensure if memory is allocated properly
then all requested attributes are populated in response from DUT

CRs-Fixed: 753309
Change-Id: Iead549635cd2059bc8cf33585a5d87ae023149d4

Reset Browsing Bit if carkit is blacklisted

    - Reset Browsing bit if carkit is blacklisted for avrcp 1.5.
    - Not to send 1.3+ specific supported events if carkit is blacklisted.

CRs-Fixed: 762470
Change-Id: I32ac80c0549b2b89dd2522dbb0dea89d255d33dc

Free Browse packet

Free Borwse packet in AVRC layer once the same is
copied to BTA for further processing.

CRs-Fixed: 785286
Change-Id: I8037a649cff5a1e527c28ba36999a1bed34d315a

BTIF-AV: Use valid memory for AVRCP message

After the context switch to BTIF for META message processing
the buffer allocated for tAVRC_MSG will be freed, hence allocate
the required memory and free that after handling the META
message

Crs-Fixed: 651506

Bluetooth: Change cleanup sequence.

 - Clear btif_rc_cb before setting callback to null.
 - do not initiate callback if rc address is null.

Change-Id: Ief15f21e40a36cf894b7c2e14e3236fc3ecf7701

Dynamic AVRC version change based on Remote's capability

 - Update DUT's adevertised AVRCP version as 1.4 or more if remote
   is capable of Avrcp File browsing with feature supported as 1.4 or more.
 - For other remote DUT always displays Avrcp version as 1.3.
 - For browsing capable remote, browsing feature works when remote does
   SDP after repair.

Change-Id: I00679397559cfb3b9efffeb92fc6b2755b851fea

Remove redundant entries from Browse structure

Remove redundant entries from Browse structure

Change-Id: Iff961f91693a2c7a32e9a22273c5e3c2b7ba4b96

Avrcp: Do not initialize transactions if cleanup done already.

In case of BT turn off, if avrcp cleanup happens earlier than
rc disconnection, then initialize_transaction gets blocked on
locking mutex which got destroyed during cleanup. Do not initialise
transaction and close uinput if done already during cleanup

Change-Id: Ib3fd61275bc918872a80a70b3d7ba66309b23ab6

BT-AVRCP: Cache set_addressed_player request while in active call.

When set addressed player is requested by avrcp controller while
in ongoing call, we fail to cache the request. Because of this
we do not send reject response to set addressed player request.
The change properly caches request and send reject response

Change-Id: I4cb02c8cb78c26fcbe22dda57cf9009e4b20be96
CRs-Fixed: 988856

Avoid updating conf file if Avrcp 1.5 is not enabled.

Avoid updating conf file if Avrcp 1.5 is not enabled.

Change-Id: I9088d0804f69a8a0a2369e97f07ce74bf750f966

Change-Id: Icbf61776a6fb63fac1555bf25d3700beccf2b67a

7 years agoA2DP Sink: Changes to support A2DP Sink in N MCL
AnubhavGupta [Thu, 28 Apr 2016 06:24:30 +0000 (11:54 +0530)]
A2DP Sink: Changes to support A2DP Sink in N MCL

- changes to enable A2DP Sink in N MCL.

Change-Id: I281f435ce5c55a2e2440f124e034cf478e7624e7

7 years agoBluetooth: IOP: Allow more time for AG connection to go through
Satheesh Kumar Pallemoni [Tue, 10 May 2016 12:00:06 +0000 (17:30 +0530)]
Bluetooth: IOP: Allow more time for AG connection to go through

Fix inter-operability issue by increasing connection timeout for
AG profile

Change-Id: I565d72fa23012c683f83a025b41c20e236864dc7

7 years agoHID: Fix following IOT issues
Hemant Gupta [Tue, 7 Jun 2016 09:22:11 +0000 (14:52 +0530)]
HID: Fix following IOT issues

  -  Add HID keyboard to sniff blacklist, to disable sniff when SCO
     is active and re-enable sniff when SCO is disconnected.
  -  Add Game Controller to sdp blacklist.

CRs-Fixed: 1025271
Change-Id: Idab33ca9326c7e0724113cb8db29691b2a65ea12

7 years agoHID: Disable sniff for some particluar remote devices
Hemant Gupta [Tue, 18 Aug 2015 10:52:06 +0000 (16:22 +0530)]
HID: Disable sniff for some particluar remote devices

This patch disables sniff on hid link for certain remote devices in
presence of SCO/esCO to prevent IOT issues of ACL disconnection on
HID link.

CRs-Fixed: 892083
Change-Id: Ia9fe1d8f5578b55c0e708e8791c5c37c3dbc48ff

7 years agoHID: Fix IOT issue with Motorolla KZ499 Keyboard
Hemant Gupta [Mon, 4 Apr 2016 06:56:41 +0000 (12:26 +0530)]
HID: Fix IOT issue with Motorolla KZ499 Keyboard

Fix IOT issue with Motorolla KZ500 Keyboard, which claims
support for multiouch functionality in SDP repord descriptor, but this
functionality doesn't work because of issues in usb hid kernel driver.
To handle this keyboard, digitizer record in report descriptor is removed
and the remaining descriptor is passed to kernel usb hid driver during
connection, which interprets the keyboard as generic keyboard instead of
multitouch keyboard and normal functioning of keyboard works fine thereafter.

Change-Id: I888b4a8997296ebbf3d9d23dd1c52ade230f984e
CRs-Fixed: 776647

7 years agoHID: Enhance blacklist logic for restricting SDP
Hemant Gupta [Sun, 26 Apr 2015 05:02:57 +0000 (10:32 +0530)]
HID: Enhance blacklist logic for restricting SDP

Enhance existing blacklist logic for restricting SDP
for HID devices, by adding BD address and name support in addition
to manufacturer id. Also blacklist logic is added for HID devices not
supporting authentication.
    - Targus mouse does not support authentication, so blacklist logic
      added to disable authentication for such HID devices.
    - Many HID mice return an out of resource error for incoming connections
      when more than 1 SDP connection is made to them. Current implementaion
      in BD stack performs SDP from 2 layers HID BTA layer to determine HID
      desritors for HID device and btif layer for determining uuid's supported.
      Blacklist logic is enhanced for such devices to not perform SDP from btif
      layer after authentication and directly inform upper layers that SDP is
      complete by adding support for BD address and name based addition to
      blacklist.

Change-Id: I4fe1e016549bb55ad176cd014bf1d5da85b38353
CRs-Fixed: 465421, 568114

7 years agoBluetooth: Fix to decrease power during OPP TX/RX
Matadeen Mishra [Thu, 30 Jun 2016 09:21:31 +0000 (14:51 +0530)]
Bluetooth: Fix to decrease power during OPP TX/RX

Refactor the original Fix.
Used 1000 milli second instead of 1 second, as API
changed to millisecond.

Change-Id: I0ecac707751f990eeabc63e56ad79e54b06e7a73
CRs-Fixed: 1036350

7 years agoBluetooth: Gap: Adding NULL check in HAL interface
Balraj Selvaraj [Wed, 21 Oct 2015 14:14:04 +0000 (19:44 +0530)]
Bluetooth: Gap: Adding NULL check in HAL interface

When the HCI_RAW_CMD support is included, adding
NULL check for bt_hal_cbacks and hci_event_recv_cb
in btif_hci_event_cback to avoid ASSERT message
continuosly which is consuming more power.

CRs-Fixed: 922611
Change-Id: I995e6411012fe515ca725267045a97076b692b7d

7 years agoBT: ACL and l2c out if sync after connection collision
Gurpreet Ghai [Tue, 8 Mar 2016 18:09:55 +0000 (23:39 +0530)]
BT: ACL and l2c out if sync after connection collision

Problem: Remote device can't be removed from paired list.
Cause: After connection collision, lcb is removed after
connection request is rejected by soc but acl entry is not
removed. So, for upper layer, acl connection always remains
up.
Fix: Removed acl connection and acl entry when connection
complete is received and lcb is not present.

CRs-Fixed: 987968
Change-Id: Ie2049217e436704262f06d0c0dc51611697cc29a

7 years agoBluetooth: GAP: Accept incoming connection in slave role
venkata Jagadeesh [Mon, 16 Nov 2015 09:22:02 +0000 (14:52 +0530)]
Bluetooth: GAP: Accept incoming connection in slave role

Accept incoming connection in slave role for blacklisted remotes

Change-Id: I7acda5f794fa53dd270b31c048f5e85a0ed7ce94
CRs-Fixed: 943689

7 years agoSDP: Restricted invalid attr len in sdp delete
venkata Jagadeesh [Tue, 16 Jun 2015 09:59:04 +0000 (15:29 +0530)]
SDP: Restricted invalid attr len in sdp delete

    Restricted invalid attr len in SDP_DeleteAttribute as
    pointer is trying to access invalid memory when attr_len
    is invalid

    Registering PNP record before PAN profile as PNP record
    should be registered before profiles.In some cases PAN and
    PNP SDP registration colliding and leading to memory
    corruption in SDP DB.

    Change-Id: Ib6d2120c7ef1d10633fa905d6b853281efaf0ecd

    Bluetooth: Cleanup ACL link during restarting pending ACL connection

    This fix removes the previously held ACL link with the BR_EDR
    device before trying to create a new pending connection with the
    same device.

    Change-Id: Iac941794e2fc86c48781edc86492146ab5c21eae

    Bluetooth: Cleanup the lcb variables properly on reuse

    - Cleanup all relevant link control block variables
      like send_not_acked, partial_segment_being_sent
      and stop the info response timer to reuse the same
      LCB.

    - L2cap layer will reuse the same lcb if the link is
      disconnected and wants to re-establish the link.

    Change-Id: I822b0ee350574bbeb5b3c86a349d1471fa45761a

Change-Id: I15f83b5c1a88d248d29080123ebbf4652f2cb340
CRs-Fixed: 885782

7 years agoBluetooth: Dont initiate rnr from pinreq if rnr in progress
venkata Jagadeesh [Tue, 27 Oct 2015 11:46:18 +0000 (17:16 +0530)]
Bluetooth: Dont initiate rnr from pinreq if rnr in progress

Dont initiate rnr from pinreq if rnr from security module is
in progress

Change-Id: I129044dca030bcf28495c30f4536bda5936e79a2
CRs-Fixed: 944764

7 years agoBluetooth: Use correct transport to check ACL connection
Nitin Arora [Mon, 25 Apr 2016 22:11:35 +0000 (15:11 -0700)]
Bluetooth: Use correct transport to check ACL connection

This change corrects the transport type used to verify if
the ACL connection for LE exists for a specific bda during
the cancel connection routine. This cancel connection routine
is triggered by advertiser connection complete, if the connection
to the same remote is pending as a scanner as well.
The process above leads to connection cancel and releasing the
link blocks. The correct check used in this change prevents the
release of link block due to the connection cancel.
Also, safety check has been added to the LE notification
routine to prevent the use of link blocks if it does not exist

CRs-Fixed: 1033641
Change-Id: If2f923e6a39974f01c62f1cbdbca6372a3082821

7 years agoRevert "Fix bug where a bonded device could enter BONDING and BONDED states again."
Nitin Arora [Wed, 13 Apr 2016 00:09:37 +0000 (17:09 -0700)]
Revert "Fix bug where a bonded device could enter BONDING and BONDED states again."

This reverts commit 0b7fc589089ce4a96daa668b9d293ce01982424d.

Conflicts:
btif/src/btif_dm.c

CRs-Fixed: 1033628
Change-Id: I1b7ccf0ff4eaebe1c947ee81e50e4587a1bdbb47

7 years agoBluetooth: Prevent multiple register of service change indication
Nitin Arora [Thu, 16 Jun 2016 22:27:59 +0000 (15:27 -0700)]
Bluetooth: Prevent multiple register of service change indication

Use Case:
Pair DUT to a remote LE device. The host registers for the service
change indication twice, once when the connection callback is
received and another time, when the SMP process completes

Failure:
There are a few issues caused by this.
First, the duplicate action of service change indication registeration
is unnecessary.
The registeration that follows the SMP process adds a gatt_if to the
apps holding the current link. This gatt_if (=1) never disconnects
after registeration failure or success. And hence the host can never
physically disconnect the link.

Fix:
This change removes the service change registeration at SMP
process completion

CRs-Fixed: 1033611
Change-Id: I0d7566e2b4a9d01aa7926cdbe9f528c3941fcfeb

7 years agoBluetooth: Do not go for inquiry in BONDING State
Manu Viswanadhan [Tue, 25 Jun 2013 11:04:00 +0000 (16:34 +0530)]
Bluetooth: Do not go for inquiry in BONDING State

This patch fix a special case where DUT is paired & connected
with only one device, which has capbility to intiate paring as
soon as DUT unpair same remote device. As DUT is paired with
only one device, In this case Once DUT unpair remote device. DUT
goes for inquiry & at same time remote device initiates pairing
if Bludroid stack recieve pairing request before the inquiry
start then DUT should not go for inquiry, As DUT is already in
BONDING state.

CRs-Fixed: 481263

Change-Id: I0e1ec0fdb963921629e5c52f495ae2013e679a03

SDP: Fix for SDP query in certification test with Invalid PduSize

Bluedroid stack is only checking parameter length and input data length.
Added an extra logic to handle invalid data after getting last valid data.

Change-Id: I47eafb2c24e73b472c31a2fb47e02d48c5e04f6c

CRs-Fixed: 491693

Bluetooth: GAP: Update name as part of Discovery of services

Update the remote device name to upper layers as part of
discovery of remote device services.

CRs-Fixed: 593306

Change-Id: I24d899c1f5ccc81d8b0c4257abae16a7bf5d4682

Bluetooth: Handled delayed info rsp from remote during SDP

DUT initiates connection with out waiting for information response
from remote device during SDP.

Change-Id: Iee0251f8f81923b1291983b66b31c78e14d21af0

CRs-Fixed: 635697

Bluetooth: GAP: Changing the security to general bonding

Changing the security from non bonding to general bonding
in BTM_SEC_OUT_AUTHENTICATE condition.

Change-Id: I65d2ec4466e2bd81df2cc7e2936e05159a8645ed

CRs-Fixed: 676532

Bluetooth: Store local and remote io caps before RNR

Stores the loc_io_caps nad rmt_io_caps when the remote
name request is called, and these will be retrieved
in the function bta_dm_pinname_cback.

CRs-fixed: 535245

Change-Id: I4b2156d7101acabb1ded65bd21d49a9c4551f8db

Bluetooth: GAP: Handle security failure with invalid handle

Return NULL incase of invalid handle when finding a device
based on the handle. This will make sure to avoid giving
a invalid entry from the device list.

Also send authentication failure in case of invalid handle.

Change-Id: Ia95d10ae95cfa1750386233ee90f01899061294e

CRs-Fixed: 592545

Change-Id: I71b902ae201e32a0fb18fd3bce52fd86e8cbcdd5
CRs-Fixed: 902577

7 years agoFix for Compilation Issue
Satheesh Kumar Pallemoni [Mon, 20 Jun 2016 11:26:04 +0000 (16:56 +0530)]
Fix for Compilation Issue

We build our system/bt code by setting BLUETOOTH_QTI_SW macro always to TRUE.
But Customer wants to build by setting BLUETOOTH_QTI_SW macro to FALSE,
Which leads to compilation Issue.When SCO open was initiated by AG
and failed for mSBC,then Fallback to CVSD settings which has not done in
else condition.
So, we should add falling back to CVSD in else condition.

CRs-Fixed: 1031600
Change-Id: I7ed33cc20374dd899b21e3fa12abe622ddc84eff

7 years agoFixes for Static analysis tool reported.
Satheesh Kumar Pallemoni [Tue, 14 Jun 2016 12:51:33 +0000 (18:21 +0530)]
Fixes for Static analysis tool reported.

CRs-Fixed: 1028649
Change-Id: If86dc1766f225a097e4dcdcb68bf6ea6bec50a2a

7 years agoBluetooth: Modify logic to ignore HID notifications
Nitin Arora [Thu, 23 Jun 2016 01:04:08 +0000 (18:04 -0700)]
Bluetooth: Modify logic to ignore HID notifications

This change reverts the previous logic and delays the
ignoring of indications for HID devices, after the processing
of service change indications.
This is needed for keeping the update count equal to the
number of apps registered, so that service change indications
can be properly confirmed and followed by remote service
discovery.
This reverts commit a85bd580013944b321d88c3c5515a015c9f67f72.
CRs-Fixed: 982471

Change-Id: Iabba84aac1af6847bb44fd2169bd0870d8d14a55

7 years agoBluetooth: Increased the command buffer length to 128.
Matadeen Mishra [Sat, 6 Feb 2016 12:07:38 +0000 (17:37 +0530)]
Bluetooth: Increased the command buffer length to 128.

Increased the command buffer length to 128.
In align with the incoming buffer size.

Change-Id: I2dba02a4c5b40925b4d9ddcd2babd432859e93b6
CRs-Fixed: 973303

7 years agoAG: Accept '-' character in dial number string.
Satheesh Kumar Pallemoni [Tue, 21 Jun 2016 04:57:13 +0000 (10:27 +0530)]
AG: Accept '-' character in dial number string.

Some Headsets storing Number from CLCC response and sending
ATD<number with special Char '-'> for redial.We do not accept
special char '-' in number string and sending Error reponse.
We should add check for accept this special char '-' in
string for redial.

CRs-Fixed: 1031997
Change-Id: I7dfc6c98fdd902361e40752b10d0c41d7ca8fe7b

7 years agoBT: Rectify size passed to copy service name to secu records
Gurpreet Ghai [Thu, 9 Jun 2016 09:06:35 +0000 (14:36 +0530)]
BT: Rectify size passed to copy service name to secu records

Use case: Services having name length greater than max lenght
always take new slot in security records. So, after few enable
disable cycles in BLE ON scenario, the record gets completely
occupied making further connection impossible.

Steps:
1. Install a BLE App to create BLE always ON scenario.
2. Run a few cycles of Bluetooth(bredr) enable-disable.

Failure: Once security records are completely occupied, new
connections are not possible because of socket creation
failure due to unavailability of security id.

Root cause: Size passed to copy service name does not include
bit for null termination. So, for services having name size
greater than that size have their last bit truncated for null
termication. So, during next enable, the comparision with
same size always fails causing service to take new slot in
security records array.

Fix: Increased the size passed to copy service name by 1 after
considering null termination.

Change-Id: I3527df6610932f60fd85bcdd14d5b8a527c79722
CRs-Fixed: 1026359

7 years agoBluetooth: GAP: Reject incoming pairing if already in progress
Venkata Ramana Rao K [Tue, 21 Jun 2016 12:27:31 +0000 (17:57 +0530)]
Bluetooth: GAP: Reject incoming pairing if already in progress

  - This patch properly rejects incoming pairing request from remote device
    if already in pairing state. Without this patch it was observed that in
    some corner cases pairing was auto accepted for remote device while
    pairing was in progress with another remote device leading to inconsistent
    behaviour.

Change-Id: I19a2a98e4ceb51cabaef279a2e3f8224fbed9ea1
CRs-Fixed: 1032165

7 years agoBluetooth: Fix to decrease power during OPP TX/RX
Nitin Shivpure [Wed, 16 Dec 2015 11:17:42 +0000 (16:47 +0530)]
Bluetooth: Fix to decrease power during OPP TX/RX

Due to alarm timer implementation, bta_sys_idle OR bta_sys_busy call
was the overhead(eg. 7ms) on every OPP packet(TX/RX), which was causing
high power. Below optimization have been done in JV to decrease
power during OPP TX/RX
- If particular JV acl link is in sniff, only then use bta_sys_busy to
  trigger unsniff request.
- Start intermediate idle timer(1s) before starting actual idle sniff
  timer(bta_sys_idle).

CRs-fixed: 1028625
Change-Id: Ied1173776f9bf2dc89b8e84e68d6217932a01607

7 years agoBT: Checking for stack status before removing sdp
Gurpreet Ghai [Wed, 10 Feb 2016 14:51:39 +0000 (20:21 +0530)]
BT: Checking for stack status before removing sdp

Based on appliaction implementation, this api
can be called during undesirable state like
when stack is being cleared. This causes ANR
and tombstone in Bluetooth.
Checked for status of stack and returned without
processing if stack is already cleared.

Change-Id: Ib5447402f9c28e010a74700927be54db44f9ca65
CRs-Fixed: 975088

7 years agoUse Local ccb variable in loop to check GAP CCB pool
Venkata Ramana Rao [Wed, 15 Jun 2016 09:57:12 +0000 (15:27 +0530)]
Use Local ccb variable in loop to check GAP CCB pool

File Receiving fails on DUT after 3 file transfers using OOL from DUT.

steps:
Transfer the files between two devices which supports OOL after pairing.
After 3 files transfer from DUT, send a file from remote to DUT.
File transfer fails.

Failure: File transfer from remote to DUT fails always after 3 opp
client connections

Root cause: File transfer is failing always because no RCB's available.
RCB's were not cleaned up after use.

FIX: RCB's were not cleaned up because there is an extra check has been
added with transpo for the CCB.And wrong CCB is passed to check transport
to clean up.Using another local variable for the p_ccb will solve the issue.

Change-Id: I06a8f237047ffb212118b4239e9856fe5c89acb1

7 years agoHID:PAN: Fix issues reported by Static Analysis Tool
Hemant Gupta [Fri, 3 Jun 2016 12:31:44 +0000 (18:01 +0530)]
HID:PAN: Fix issues reported by Static Analysis Tool

Fix issues reported by Static Analysis Tool.

CRs-Fixed: 1025718
Change-Id: Ie0347307d7536f18bf8f32a2dfeda593a41933bf

7 years agoDelete GATT cache file from NVRAM when device is unpaired
Subramanian Srinivasan [Tue, 14 Jun 2016 01:15:31 +0000 (18:15 -0700)]
Delete GATT cache file from NVRAM when device is unpaired

GATT cache file is created for each remote device when
service discovery is performed. This file is not removed
when a device is unpaired. Hence even after performing a
fresh pairing, the subsequent service discoveries end up
retrieving the attribute list from the GATT cache instead
of fetching the results over the air.

The service discoveries for non paired devices also are
not performed over the air for the reconnection attempts.

This change deletes the GATT cache NVRAM file when a device
is unpaired and also resets the GATT cache structures
during disconnection of non paired devices.

Change-Id: I35ec4d0a53820c671fe94cb83927548b9be53d28

7 years agoBluetooth: Select bluetooth transport dynamically
Dibyendu Roy [Wed, 25 May 2016 09:24:43 +0000 (14:54 +0530)]
Bluetooth: Select bluetooth transport dynamically

Select bluetooth transport dynamically on the basis of
qcom.bluetooth.soc property. This patch removes the use of board
configuration option QCOM_BT_USE_SMD_TTY and uses dynamically
detected SOC type to choose required transport.

Change-Id: Iae1ee900362af95c42bffcc444b56267cbbae92d

7 years agoBluetooth: Select bluetooth HCI driver dynamically
Dibyendu Roy [Mon, 9 May 2016 09:24:25 +0000 (14:54 +0530)]
Bluetooth: Select bluetooth HCI driver dynamically

Select bluetooth HCI driver dynamically on the basis of
qcom.bluetooth.soc property. This patch removes the use of board
configuration option BLUETOOTH_HCI_USE_MCT and uses dynamically
detected SOC type to choose required HCI driver.

Change-Id: Idecb2fd74fbc9d361c2877e9b3a47606667e0229

7 years agoRevert "Revert "Initial commit for rfcomm test tool""
Matadeen Mishra [Thu, 12 May 2016 04:16:09 +0000 (21:16 -0700)]
Revert "Revert "Initial commit for rfcomm test tool""

Added strict_mode boolean parameter in enable function.

This reverts commit 007093f5aded6eb02501602996e2f2883b3923c7

Change-Id: I37a282e80fa6e884fbdf51de283d3e9c2761a7c4
CRs-Fixed: 1014526

7 years agoBtsnoop write from external process
Matadeen Mishra [Fri, 14 Nov 2014 14:16:19 +0000 (19:46 +0530)]
Btsnoop write from external process

- Write btsnoop from external process
  Introduced a new proces to dump snoop packets into file.
  Snoop packet can be send to the remote process using local
  socket as writing to file from BT process can cause A2DP
  choppyness.

- Avoid btsnoop file write if btsnoop client is connected
  Existing implementation writes it to file though the packet is
  sent over network socket. This chnage will make sure to avoid
  writing it to file if any of the network/local socket is
  connected.

- Generalized the mechanism to use same code irrespective of
  what type of socket it is. Otherwise having thread for each
  socket is not preferrable.

- Adjust the GMT offset to match with logcat logs.

- Limit the block of snoop write to 10ms and drop the packet.

- Memcpy issue single write to eliminate multiple I/O.

- Enable snoop by default on userdebug build.

- Option to override snoop config for userdebug build.

Change-Id: I13749dc348baf88af57e3ebec1ec7acd5e999c04

7 years agoHID: Add support for set report and get report
Hemant Gupta [Thu, 3 Sep 2015 09:19:18 +0000 (14:49 +0530)]
HID: Add support for set report and get report

Add support for set report and get report in HID user
space because of changes in uhid kernel driver with kernel changes
for kernel 3.18. Without these changes issues are seen with hid devices
that uses vendor usb hid drivers and send specific set and get report
to hid devices for their proper functioning.

Following are the new flags added in uhid driver of kernel, for which
support is required in hid user space.

UHID_GET_REPORT
UHID_GET_REPORT_REPLY
UHID_SET_REPORT
UHID_SET_REPORT_REPLY

Also update __FUNCTION__ to __func__ in API's where changes are made.

Change-Id: I90230b76d68e9275dcacd9f46f03e312ddf2fa30
CRs-Fixed: 963213

7 years agoBluetooth: Disable eager reader threads in RX path
Srinu Jella [Tue, 15 Dec 2015 14:22:32 +0000 (19:52 +0530)]
Bluetooth: Disable eager reader threads in RX path

- Disabled eager reader threads in RX path for both
  ROME and PRONTO targets.

- Exising machamisn is to poll for incoming data
  (event, ACL data) using dedicated thread called
  eager reader thread.

- Now the responsibility of polling for data moved
  to existing HCI worker thread.

- Enhanced the read mechanism from hci hal interface.

CRsFixed: 934414
Change-Id: Icfd27b7b93f83033b2230e61a23df69aa3c33bdf

Bluetooth: Optimize the L2cap FCR tx timer

- Optimize the L2cap Flow control tx timer
  to avoid frequent start and stop of same
  timer.

- it will restart the timer instead of stop
  and start.

- Changes made in btm timer functions also
  to avoid scheduling of next timer in queue
  though is not required as the same timer
  is supposed to start.

CRsFixed: 934414
Change-Id: Idd43a71617a27c6d70fafa4e31c16f735a1a9425

Bluetooth: Handle the SSR timeout case properly

- Kill the bluetooth process in case of SSR timeout,
  otherwise it will try to read the invalid data
  that might lead to crash.

- Also corrected the data type to check when error
  occurs on read call.

CRs-Fixed: 978009
Change-Id: I42f6c9f4a437f7b143fe1e1beb3b6ef39533f4d7

7 years agoBluetooth: Separated initialize and re-initialize of bta_dm_cb control block
Bandari Ramesh [Tue, 7 Jun 2016 13:46:52 +0000 (19:16 +0530)]
Bluetooth: Separated initialize and re-initialize of bta_dm_cb control block

 -Added bta_dm_deinit_cb function to re-initialize of
  bta_dm_cb control block

 -Modified the condition to set disable timer in case of any active
  ACL connections

Change-Id: I872944c39912bc8a534eba080a0ade7ced942bec
CRs-Fixed: 1025769

7 years agoSet DUT role as slave for outgoing connection
Venkateshwarlu Domakonda [Tue, 12 Jan 2016 07:04:45 +0000 (12:34 +0530)]
Set DUT role as slave for outgoing connection

Do not send role switch while accepting incoming connection
for Roman R9020 which delays responding to AVDTP_DISCOVER
and AVDTP_OPEN when in Slave role.

Change-Id: I1ba5bc0f1f88fe8ef7f4c186fbdfacd6726d3720

7 years agoAdd debug log to track Negative reply
Manu Viswanadhan [Fri, 29 Jan 2016 06:37:19 +0000 (12:07 +0530)]
Add debug log to track Negative reply

- Added logs to provide the negative reply
  information of
  - Pin code reply
  - Link key reply
  - Pass key reply
  - IO capability reply.

Change-Id: I7a25a53bf2dd7b69ecd9d0b30d49a163af731ee1
CRs-Fixed: 970954

7 years agoBT: Audio: Enhance default stack logging for AUDIO
rakesh reddy [Thu, 14 Aug 2014 06:28:45 +0000 (11:58 +0530)]
BT: Audio: Enhance default stack logging for AUDIO

Make default logging for upstream events,
statemachine state transitions, sco state
transitions, call state transitions etc.

Change-Id: Ia0dcb22e2efb99f186166ae4af2a8cb73f87616d

Bluetooth: A2DP Sink Logging.

 - logs for state transition.
 - Latency logs with sequence Number.

Change-Id: Iedabccd97d1118406f43b7ba494bdec5935b60b9

Print delay logs during A2dp streaming

    - Log systrace during A2dp streaming. This logging is not
      enabled by default.BT_AUDIO_SYSTRACE_LOG needs to be defined in
      applicable files to turn this logging on.
    - Properly name threads.
    - Log A2dp write delays.
    - Log pcm dump before writing to media socket to mediatask.
This logging is not enabled by default. BT_AUDIO_SAMPLE_LOG needs
to be dfined to enable this logging

Change-Id: If081480b29f02126a1d48b9d0d9f855a3a605cc5

Enable required AVRCP Logging by default

Enable required AVRCP Logging by default.
Introduce additional logging whereever required.

Change-Id: Ie2e88de06254257af3b77b4f8b06401273f29262

7 years agoRevert "Bluetooth: Proper gatt disconnection after ccc process"
Arusha Goyal [Wed, 1 Jun 2016 06:21:48 +0000 (23:21 -0700)]
Revert "Bluetooth: Proper gatt disconnection after ccc process"

This reverts commit 73d92fd3a7a40536add8d25f30a9c4eb8a6948b8

Change-Id: I38a8e8f8a96eb5e68598126117607543f181b29e

7 years agoA2dp logging enhancement for media task
Ayan Ghosh [Thu, 5 Nov 2015 13:25:26 +0000 (18:55 +0530)]
A2dp logging enhancement for media task

Enabling important mediatask logs to be printed
with TRC level set to default.

Change-Id: I4bf1eb2f130b136cc1b3987ba2c042a4bc268020

Conflicts:
btif/src/btif_media_task.c
Change-Id: I68b34253821a5a5f6ff9a87b6353e6bbbbfe718d

7 years agoRestart sniff timer on AVDTP signalling channel establishment
Ayan Ghosh [Fri, 6 Dec 2013 11:41:11 +0000 (17:11 +0530)]
Restart sniff timer on AVDTP signalling channel establishment

VolksWagan UHV Preminum takes time to initiate AVDTP media channel
after AVDTP signalling channel is up. If mentioned duration exceeds
7 seconds then ACL link goes into sniff due to which A2dp Connection
fails.

With this change we make sure that when AVDTP signalling channel
is up and media channel is not connected we do not go to sniff,
which is achieved by restarting sniff timer on signalling channel up
so that link does not go to sniff in between ongoing connection.

Change-Id: Ic3f268703067155ffd55a43f320ce199641c6b3f

7 years agoQLogKit: Enable FW Logging and Set Stack Trace Level
Sai Aitharaju [Fri, 19 Jun 2015 03:44:00 +0000 (09:14 +0530)]
QLogKit: Enable FW Logging and Set Stack Trace Level

   - Enables FW Logging during BT On and disables
     the FW Logging during BT Off in userdebug
     builds only.

   - Provides an interface to set trace level for
     all the stack layers of bluedroid.

CRs-Fixed: 866285
Change-Id: Ib12d220e0aa4845d04b05b7fbea079d30c308004

Bluetooth: Disable SOC logging for ROME targets

Disable SOC logging for ROME targets

Change-Id: Ifbb99900d8596932e514582619aaf775dacd3c33

7 years agoBluetooth: Add support to send/receive raw command/event
Srinu Jella [Fri, 6 Dec 2013 09:55:26 +0000 (15:25 +0530)]
Bluetooth: Add support to send/receive raw command/event

Bluetooth: Add support to send/receive raw command/event

Support added to send/Receive raw command/event.

Change-Id: I194e9ceed29d60de492427784ae340691e4254e7
CRsFixed: 598650

Bluetooth: Support to send HCI raw command to stack.

Provide an interface in stack to send
HCI raw commands to stack.

Change-Id: Id70d419c19a2b983450ebc113b8d0cca2b36ecf9
CRs-fixed: 751111

7 years agoBluetooth: Proper gatt disconnection after ccc process
Nitin Arora [Fri, 6 May 2016 22:26:13 +0000 (15:26 -0700)]
Bluetooth: Proper gatt disconnection after ccc process

This change allows for an operation complete of the client
configuration registeration process.
In the current code, the successful completion of the
process where host writes the client configuration
descriptor of the service changed characteristic of the
remote device, the connection id (1) is never disconnected.
Hence, for those remote devices with the service changed
characteristic that allows Indications, there will always
be a remaining connection which will prevent disconnection
of the remote device.

This change fixes that issue and also the issue related
to early notifications/registerations causing disconnects
of HOGP devices

CRs-Fixed: 1014919
Change-Id: I04273f6a1ab5e2d74f49687c9a70670e40db9d39

7 years agoDUN: Squashed commit of the following:
Ashwini Munigala [Tue, 10 May 2016 10:56:38 +0000 (16:26 +0530)]
DUN: Squashed commit of the following:

commit fc3b33bbee0f9e0ae62dc922baae5fd5e8c9e307
Author: Nitin Shivpure <nshivpur@codeaurora.org>
Date:   Tue Dec 8 18:38:20 2015 +0530

    Dun: Don't add Obex protocol descriptor in SDP

    Don't add Obex protocol descriptor in DUN SDP record.

    CRs-fixed: 949818
    Change-Id: Id108722eafdf146228636412d087220da24af91c

commit 5f726cef997ee8400e0761f60e6a72f74f999ad6
Author: Srinu Jella <sjella@codeaurora.org>
Date:   Mon Oct 21 11:19:44 2013 +0530

    DUN: Add DUN SDP record to the Bluedroid stack.

    Add DUN server SDP record in Bluedroid stack.

    CRs-Fixed: 557180
    Change-Id: I432496079ae0d7325805b1b1cf684629bbf51035

Change-Id: I21ca2b1396de77611b55e34ce3d875b960f9b6d7

7 years agoFix for issues reported by Static analysis tool.
Satheesh Kumar Pallemoni [Mon, 9 May 2016 12:43:05 +0000 (18:13 +0530)]
Fix for issues reported by Static analysis tool.

Fixed issues in reported by static analysis tool.

Change-Id: I5a3ca9070ef21d2d86060b25f4282acf113a0987

7 years agoSocket: Add Get/Set socket option to the Rfcomm socket.(2/4)
Srinu Jella [Mon, 21 Oct 2013 06:11:15 +0000 (11:41 +0530)]
Socket: Add Get/Set socket option to the Rfcomm socket.(2/4)

Introduced Get/Set socket option support to the Rfcomm socket.
Currently Rfcomm socket supports get/set modem bits socket
options.For other sockets it will return error.

CRs-Fixed: 557180
Change-Id: Ia1779293b643c22d3f754c7f405646d42eb94963

7 years agoAdd support for FM vendor operations such as ON/OFF
Satish kumar sugasi [Thu, 17 Dec 2015 20:26:03 +0000 (12:26 -0800)]
Add support for FM vendor operations such as ON/OFF

This adds FM ON/OFF and HCI init operations

Change-Id: I476a8017343f9bc8dd8f30cc5ce14c8d05515caf

7 years agoBluetooth: GAP: Don't update short name if the device paired
Matadeen Mishra [Fri, 29 Apr 2016 15:15:34 +0000 (20:45 +0530)]
Bluetooth: GAP: Don't update short name if the device paired

Don't notify the BT APP about the shortened device name which
will be part of EIR response,incase of device is already
paired.
Incase if the alias name present for that device, it
will notify th BT APP alias name as the actual device name.

CRs-Fixed: 576911
Change-Id: Ia64e1e90aae8c4e0cc52643ce3bbbb1332fe5b66

7 years agoAG: Disable HSP profile durning BT turn off.
Satish Kodishala [Wed, 9 Mar 2016 13:27:01 +0000 (18:57 +0530)]
AG: Disable HSP profile durning BT turn off.

When BT Turns ON we are enabling HSP and HFP profile.
When BT Turns OFF we are disabling only HFP profile.
So,When BT Turns ON unable to connect HSP profile.
So,Add Disable for HSP profile also once BT Turn OFF.

CRs-Fixed: 987527
Change-Id: Ied8bef7eee8a20530ceedea636fcc1000ee7bb3a

7 years agoBluetooth:CoreStack: DUT Stack Logging.
Matadeen Mishra [Sat, 30 Apr 2016 11:46:12 +0000 (17:16 +0530)]
Bluetooth:CoreStack: DUT Stack Logging.

   DUT stack information logging:
   -L2CAP configuration parameter,
   -Device role information
   -L2CAP flow control and congestion information
   -L2CAP State machine and events
   -RFCOMM credits count
change-id: I6e74bdb1cda4455c50314f67bbcd19accd3c31e4

CRs-Fixed:602294
Bluetooth:CoreStack: DUT Stack Logging set2
   DUT stack information logging:
   -L2CAP CIDs, PSM and MTU
   -removed RFCOMM credits count from default logs
change-id: I7a25d751b200e8ece87f9e5fd79ab48d736087cb

CRs-Fixed: 602294
Bluetooth: Add debug logs for the remote device information
change-id: I857016c056635907586d8a9d0d577edde4efc34a

Add logs to provide the below remote device information
- Remote device features
- Service class
- LMP version, subversion, manufacturer
- Role changed event
CRs-Fixed: 602291
Change-Id: I99f51841716e27ef7170b7566379b975c99a65e0

7 years agoRevert "Initial commit for rfcomm test tool"
Arusha Goyal [Mon, 9 May 2016 11:06:09 +0000 (16:36 +0530)]
Revert "Initial commit for rfcomm test tool"

This reverts commit 3d4f014eb0595ff41393c0c1e259b8941737cb0c.

Change-Id: I21701af4cea0cfdcd23819a400e9c09f1f50008b

7 years agoBluetooth: Fix module cleanup.
Ajay Kumar [Wed, 25 Nov 2015 06:52:46 +0000 (12:22 +0530)]
Bluetooth: Fix module cleanup.

if module does not start fully its state will either NONE
OR INITIALIZED. While module_shut_down if module state is
not STARTED, it will exit without shutting underlying
layers which will give issues or ASSERT in next cleanup.

In this specific issue hci module stucks in USERIAL_OPEN
and startup timer expires and module exits with the error.
Since there is no error check on hci module fail it goes
ahead and enables BT(that might give issues later) but
fails to cleanup and does not call USERIAL_CLOSE while
hci module_shut_down as part of disable.Now this will
ASSERT in next enable as USERIAL lib handle is not NULL.

even if we call module_shut_down that is not going to
help as it will exit without calling lifecycle function
:shutdown. Adding module error state will solve the issue

CRs-Fixed: 939575
Change-Id: I0f448eb438881a9df46d07eab44d809bae740ab5

7 years agoAVRCP: Update sdp record correctly for CT or TG
Anubhav Gupta [Tue, 22 Mar 2016 18:03:33 +0000 (23:33 +0530)]
AVRCP: Update sdp record correctly for CT or TG

 - pass sdp version as parameter
 - update sdp records for avrcp controller in case of client
   profiles being enabled
 - BTA_AV_FEAT_BROWSE flag was incorrecly set during AV registration
   causing AVRCP TG version to upgrade to 1.4 even though browsing
   feature is not supported.
 - Use AVRC_CTLR_INCLUDED feature flag instead of AVRC_ADV_CTRL_INCLUDED
   for guarding Avrcp controller code in build/parse apis for
   command/response

Change-Id: I3ff4082453a2624a72d8f152d75af83a8efb4937

7 years agoHID: Return error when hid host is disabled
Hemant Gupta [Tue, 19 Jan 2016 15:48:15 +0000 (21:18 +0530)]
HID: Return error when hid host is disabled

This patch returns error when hid host service is disabled.
Without this patch thre could be potential UI synchronization
errors when hid host service is disabled.

Change-Id: Ida9e4c91015c8b0e4d36db5f58c0a65b7630a259
CRs-Fixed: 964404

7 years agoHID: Fix issues in stack reported by static analysis tool
Hemant Gupta [Fri, 22 Apr 2016 07:23:02 +0000 (12:53 +0530)]
HID: Fix issues in stack reported by static analysis tool

This patch fixes issues for hid profile in BD stack reported
by static analysis tool.

Change-Id: I8d765e8e7662781266b73344dee3dd1766930799
CRs-Fixed: 740857

7 years agoHID: Fix corner case state machine handling for HID Host
Hemant Gupta [Tue, 4 Nov 2014 14:49:01 +0000 (20:19 +0530)]
HID: Fix corner case state machine handling for HID Host

This patch fixes the following issues for HID Host state machine handling
  - Retry timer was never stopped in stack in case l2cap channel was refused
    by remote device, and l2cap connection was made before timer could expire.
    This was leading to some variable corruption in collision cases.
  - UHID driver is also closed in case open failed to fix some corner case
    issues of uhid driver not closed in some cases.
  - Handling of virtual cable unplug in waiting for connection state. Without
    this some IOT issues were seen with some hid mouse which used to send
    VC unplug while connection setup was still ongoing for hid host because of
    SDP.
  - Fix corner case race condition when remote device closes the l2cap while
    DUT is about to send Virtual cable unplug control command. Without this change,
    it was seen that in above scenario state machine of hid host moved to idle on
    reception of close event from remote device, and was unable to handle device
    unpairing on successful completion of virtual unpulg event which never came
    in above scenarios.
  - Some extra debug logs are added in code flow.

Change-Id: I851b73068a801f637eac94533a60150946d257f6
CRs-Fixed: 750415

7 years agoHID: Set sniff subrate with optimize latency value on HID Link.
Hemant Gupta [Fri, 21 Feb 2014 13:20:41 +0000 (18:50 +0530)]
HID: Set sniff subrate with optimize latency value on HID Link.

Current HID design disables sniff on HID Link in presence of SCO/eSCO, which
was leading to many IOT issues, as HID links work in sniff mode, and disabling
sniff on hid leads to issues of connection timeout if anchor points are missed
during sco/esco concurrent usecases. This design is changed as below:

- If HID is connected & SCO is active, then disabling Sniff subrate
  to fix connection timeout on HID link.

- If HID is connected & SCO is not active. Setting sniff subrate with
  optimize value based on the remote parameter to fix connection
  timeout on HID link to avoid HID IOT issues.

- Adds behaviour of host disabling SSR for JW MT002 and prevents
  Host from sending Sniff subrating command to SoC for BORND mouse
  so as to avoid IOT issues of disconnection and slow mouse movements
  respectively with these device.

- Updates SSR parameters for HID Link to have a minimum
  Max latency value for SSR, to have better trade off between power
  consumption as well as performance of HID.

Change-Id: I6d60df88ea33e00b0fb173447351da4874dc97e5
CRs-Fixed: 635632

7 years agoHID: Add support for Set Idle and Get Idle commands (2/4)
Hemant Gupta [Tue, 30 Jul 2013 10:41:33 +0000 (16:11 +0530)]
HID: Add support for Set Idle and Get Idle commands (2/4)

This patch adds support for sending set idle and get idle commands to
remote HID device, on receiving the function call from upper layers.
Also on reception of get idle time from remote device, upper layers
are infrmed using registered callback.
Without this support TC_HOS_HID_BV_05/06 PTS test cases for HID 1.0
cannot be passed.

Change-Id: I14bc2dc349354fd87ef8aba25357514398532e87
CRs-Fixed: 522511

7 years agoInitial commit for rfcomm test tool
Srinu Jella [Fri, 29 May 2015 11:33:08 +0000 (17:03 +0530)]
Initial commit for rfcomm test tool

- Initial commit for rfcomm test tool.

Change-Id: I2c00ea88030d6494acb368da08f81be87ef411d7

Rfcomm test tool for rfcomm protocol certification

- Interface provided from BT-If layer to interact
  with rfcomm.

- This tool covers all rfcomm PTS test cases.

Change-Id: I129fbabdbdd80c87f0867c90e472e65bd1611af2

Initial commit for mcap test tool

- Initial commit for mcap test tool

Change-Id: I8657c941603728f6681000a904d96368c6f1f2cc

Initial commit for l2cap test tool

- Initial commit for l2cap test tool

Change-Id: Ia989c59f16d3cb2f314083e4436249f38dc93e7e

Mcap test tool for mcap protocol certification

- Interface provided from BT-If layer to interact
  with mcap

- This tool covers all mcap PTS test cases.

Change-Id: I07f1eb8dc3d98c95b82ee67554c1a846e71c4bfc

L2CAP test tool for L2cap layer certification

- Interface provided from BT-If layer to interact
  with l2cap

- This tool covers all l2cap 4.0 PTS test cases
  whcih includes basic, ertm and streaming mode
  test cases.

Change-Id: Ifacd0b99974c28788926e0f901c37ee2c12ff97b

Bluetooth : Cert tool compilation

Change-Id: I7eaf1ce9ccd2872ba614152ee34f53e6a6fc897b

Qual tools: L2CAP Add support for window size
            MCAP  Delay MDP Handling

Change-Id: Ic7a99e89a956a95a882caa829925cda08d642232

7 years agoBluetooth: Check for NULL String.
Gaurav Asati [Mon, 9 Jun 2014 12:34:10 +0000 (18:04 +0530)]
Bluetooth: Check for NULL String.

When JNI checks are enabled it checks for
NULL, so check for empty string for ATD.

CRs-Fixed: 676866
Change-Id: I8b0cdafeb34737b95041ed6a6ec117fa32effa36

7 years agoDon't unset the HF indicators and S4 Settings for PTS
Satish Kodishala [Thu, 7 Apr 2016 10:26:34 +0000 (15:56 +0530)]
Don't unset the HF indicators and S4 Settings for PTS

PTS Test Case HFP_AG_SLC_BV_10_I failed due to PTS HFP version is 1.5.
If there is HFP Version less than 1.7 we are unsetting the HF indicators
and S4 settings in BRSF.So,regardless of PTS HFP version we should not
unset the HF indicators and S4 settings in BRSF.
Also for HSP Profile some PTS Test cases failed because when there is
HSP connection we are checking for callsetup indicator which were not
present for HSP profile. So,we should check for HFP connection as well
with the call setup Indicator.

CRs-Fixed: 1000512
Change-Id: I61239a187c2f85b759eb3029c47e6c2fe341c16e

7 years agoDynamic HF version change based on remote hf version
Satish Kodishala [Thu, 5 Nov 2015 06:46:12 +0000 (12:16 +0530)]
Dynamic HF version change based on remote hf version

For remote devices supporting HF specification 1.6 or lower,
advertize phone's HF version as 1.6. For remote devices supporting
HF version 1.7, add them to data base and advertize phone's HF
version as 1.7. User need to re-pair HFP version 1.7 devices

CRs-fixed: 934912
Change-Id: Icd6eeea738b19a9ca74214cb33b0bcaebc5f4b9e

7 years agoBluetooth: Implement dynamic blacklist method for role switch
Srinu Jella [Thu, 8 Oct 2015 11:44:16 +0000 (17:14 +0530)]
Bluetooth: Implement dynamic blacklist method for role switch

 - Blacklist the device if it's rejected the role switch for
   max number of times.Same is added to the iot_devlist.conf
   file.

-  Maximum number of failed (BTM_MAX_SW_ROLE_FAILED_ATTEMPTS)
   attempts set to 3 and it is configurable.

-  Same blacklisted device is referred by the BTM module when
   any other module like profile is requesting for role switch
   and BTM module returns BTM_REPEATED_ATTEMPTS as the switch
   role status.

-  There is option to retry for role switch even though the
   device is blacklisted and it can be controlled by feature
   flag BTM_SAFE_REATTEMPT_ROLE_SWITCH. And by default it is
   enabled

CRs-Fixed: 831542
Change-Id: I570e1539578e60901794941ca46f0722e368a954

7 years agoFTP: Add FTP SDP record in Bluedroid stack.
Hemant Gupta [Wed, 8 Jul 2015 18:23:15 +0000 (23:53 +0530)]
FTP: Add FTP SDP record in Bluedroid stack.

Add FTP SDP record registeration in Bluedroid Stack.

Change-Id: I7b3c3d85c5c6a7ac20a0a9361a646d2d494f8fec
CRs-Fixed: 504049

7 years agoHF Client: Handle errors for CGMI, CGMM in the stack
Satish Kodishala [Tue, 6 Oct 2015 15:42:14 +0000 (21:12 +0530)]
HF Client: Handle errors for CGMI, CGMM in the stack

AT+CGMI=? and AT+CGMM=? commands are sent from stack to
the AG in post SLC sequence. We are upstreaming errors
returned from AG for these commands to
HeadsetClientStateMachine. This leads to state mismatch
in state machine.

CRs-fixed: 919514
Change-Id: I4acb32d3c1dd78ba3de3b60fb029268b307199f7

7 years agoHID: Prevent incoming and outgoing SDP collision
Hemant Gupta [Wed, 7 Oct 2015 06:38:10 +0000 (12:08 +0530)]
HID: Prevent incoming and outgoing SDP collision

SDP is performed 2 times as part of HID connection in BD stack,
one after successful authentication, and one in hid stack layer
as sdp data is not stored currently in stack. When there is outgoing and
incoming connections, SDP failed message was posted which was resulting
in SDP failure for hid host resulting in improper disconnection of
hid interrupt channel.

Change-Id: I5b4813dc916696e2c0f76be27a85c1a89c2d8be0
CRs-Fixed: 683139

7 years agoGet AG manufacturer information
Satish Kodishala [Fri, 1 May 2015 14:23:35 +0000 (19:53 +0530)]
Get AG manufacturer information

Added support for AT+CGMI and AT+CGMM commands.
The commands get manufacturer identification and model
information respectively. Commands are sent post SLC
procedure.

CRs-fixed: 844824
Change-Id: Ie556281eebc7b8511d28b2d56f3519cca312e3c6

7 years agoBluetooth: Avoid crash while releasing CCB
Ajay Kumar [Wed, 9 Mar 2016 05:03:33 +0000 (10:33 +0530)]
Bluetooth: Avoid crash while releasing CCB

There are chances that LCB values are not
filled while releasing CCB, putting check
for this ensuring no crash while LCB is NULL.

Change-Id: Iac2fa78d3599431308a030861158efa095bbdbf5
CRs-Fixed: 984983

7 years agoIgnore RFCOMM close event in case of collision
Satish Kodishala [Fri, 10 Jul 2015 09:36:07 +0000 (15:06 +0530)]
Ignore RFCOMM close event in case of collision

When Multi-hf is enabled, if outgoing and incoming to/from
HF collide, ignore RFCOMM close event if HF is already connected.

CRs-fixed: 869792
Change-Id: I1ed5b17de13ed66c2add4c2377949cdffe968c48

Handle unknown codecs sent by HF

Use case:
1. Connect to headset supporting CVSD, mSBC and other codecs.
2. Verify if headset sending AT+BAC with supported codecs.
3. Check if SCO is established with mSBC codec.

Failure:
SCO is established with CVSD codec.

Root cause:
When parsing AT+BAC command, if unknown codec is received,
we are falling back to CVSD although mSBC is supported in HF.

Fix:
AT+BAC parsing function modified to return correct codecs
supported by HF when it encounters unknown codecs in arguments
of AT+BAC.

CRs-fixed: 861222
Change-Id: Ibc6a72b749280dc70a355270f37f4316468c1a4f

Clear remote BD address if SDP search fails

Use case:
1. Enable multi hf.
2. Pair and connect to a headset.
3. Turn off headset and try connecting to headset from AG.
4. After the connection fails, turn on headset.
5. Make sure headset initiates HF connection to AG.
6. Make MO/MT call, switch from headset to AG, vice versa using headset.

Failure:
When call is transferred from AG to headset, headset initiated
SCO connection request is rejected by AG.

Root cause:
For outgoing connection in step 3, SDP search fails. BD address of
remote headset is stored in scb[0]. BD address of headset with which
we tried to connect is not cleared in scb[0].

When incoming HF connection request is accepted in step 5, BD address
of headset is stored in scb[1]. Now, BD address of the same headset is
stored in both scb[0], scb[1].

When SCO connection request is received from headset, we get scb
information using BD address. However, since BD address in scb[0]
is not cleared, we end up selecting scb[0] for which there is no
headset connected. This makes us think that remote is initiating
SCO connection without SLC and we reject the SCO connection.

Fix:
Clear the BD address of remote when SDP search fails.

CRs-fixed: 861209
Change-Id: Iff3e1f2a25988c3eb55d6914cae6ac8427a7e211

BT: HFP1.7: Do not upstream invalid BIND set event.

Incase remote HS sends incorrect BIND set command during
SLC, do not upstream the event to BT apps to avoid disconnection.

Change-Id: Ie2d52a97ab179174e219ebe0c17f9d1f66545367
CRs-Fixed: 809572

Do not reset SSR parameters on SCO link.

When Headset is connected during active call, HFP is connected
first. Due to active call SCO is also established, when SCO is
established we disable SSR. When a2dp is connected after SCO
connection it enables SSR. This enabling of SSR is causing ACL
disconnect.

When there is new profile connection on same device which has SCO
we should not enable SSR. It should be enabled only when there
is no SCO.

Change-Id: I25263a148a13136174a67867a822ba3497a11f8e

7 years agoGAP: Accept incoming connection with slave role
venkata Jagadeesh [Thu, 26 Jun 2014 06:25:41 +0000 (11:55 +0530)]
GAP: Accept incoming connection with slave role

-Define DUT Default desired role as master

-Accept incoming connection with DUT role as slave for
list of carkits and headsets which are blacklisted.

Change-Id: Ie6af63b50debd417ce2d54b28b83d95ef4f695a6
CRs-Fixed: 892194

Bluetooth: GAP: Disallow roleswitch for blacklisted devices

Set link policy to disallow role switch for blacklisted devices
as some devices not starting encryption after role switch
and a2dp connection getting delayed for some devices due to role switch

Change-Id: I75a20b5cda9c4b46d118b12de373c99a25f72012
CRs-Fixed: 892242

Bluetooth : GAP : Dont initiate role switch for blacklisted remotes

Don't initiate role switch for blacklisted remotes from DUT
as some remotes always rejects role switch and role swicth retrails from
DUT may lead to a2dp glitches

Change-Id: I41bd78f1d25f1fc2985f1cf226a54d6819be968b

7 years agoBluetooth: Add support to send h/w error event
Srinu Jella [Mon, 21 Sep 2015 13:59:50 +0000 (19:29 +0530)]
Bluetooth: Add support to send h/w error event

- Bluedroid stack needs to be reset whenever H/w
  chip restarts like Subsytem restart.

- Emulates the hardware error event on detecting
  SSR event from PR controller.

CRs-Fixed: 914079
Change-Id: I9248a4e6ad689fc590fd4fd0f7a067cd33bf314f

Bluetooth: Reset bluetooth status to download NVM tags

- Reset bluetooth status to download the NVM tags once
  the SSR is detected.

- NVM tags downloaded only once for the first BT on and
  downloaded again in case of SSR or command timeout.

- Without this change, there would be diffrence in
  BD addr which would lead to pair/connection issues.

CRs-Fixed: 932195
Change-Id: I75a44e7ae7d301ff1c9be8349c1b51d4c80cbf36

BT: Adding check for packet size before allocating buffer

During controller reset, corrupted packet might reach
to host. This packet might indicate length value more
than maximum allowed packet length. This causes crash
during buffer allocation.
Added the correct length check before allocating the
memory.

CRs-Fixed: 978009
Change-Id: I462b9b18e4c9db67d4860509376b0cb38830e56d

BT: Rectify the method to reset host after controller crash

Use case: When controller is forcefully crashed for testing,
the host process should reset itself.

Steps: Testing envolving forceful crashing of controller
to observe recovery and behavior of host in such events.

Failure: Once controller crash was enforced, the host
process was not resetting itself.

Root cause: The packet created to send hw reset event to
stack was getting truncated.

Fix: Changed the logic to first create an empty packet and
later set its type and data to make hw reset event.

CRs-Fixed: 1000446

Change-Id: Ied4e62db0be5bb8e16fac05787b9a071fd86b1e7

7 years agoAdd few logs for phone state change updates
Satish Kodishala [Tue, 18 Aug 2015 13:57:39 +0000 (19:27 +0530)]
Add few logs for phone state change updates

Added few logs to get the phone state updates from Telephony.

CRs-fixed: 751733
Change-Id: Ic5553e08f0584fef0705386ba96e0fa852676ba3

7 years agoBluetooth: Add support to read BD address from bt_nv.bin
Srinu Jella [Wed, 7 Oct 2015 12:31:53 +0000 (18:01 +0530)]
Bluetooth: Add support to read BD address from bt_nv.bin

- Add support to read BD address from bt_nv.bin if no
  other BD address is available from other mechanism.

- If the ro.boot.btmacaddr property is set, it will
  prioritize this property over bt_nv.bin.

CRs-Fixed: 921979
Change-Id: I8a0d38be7adb93db95eb3618a8f6af4030adf373

7 years agoHandling Authentication Failure From the lower layer
Matadeen Mishra [Wed, 23 Sep 2015 16:56:46 +0000 (22:26 +0530)]
Handling Authentication Failure From the lower layer

Use case: DUT unable to do connect with all devices in
Multipairing case.

Steps:
1. pair with HS
2. disconnect HS.
3. reconnect HS from DUT.

Failure: Authentication failure occurred due to LMP
transaction collision DUT not deleting link key which
lead to unable to connect to device.

Root Cause: Not posting the Authentication failure
event to application layer, while removing the link-key.

Fix: Post the Authentication failure event to application
and removing the link-key.

Change-Id: I079d8ce89c1fea66f0624127514cec8405bfdd3d

Add null check to avoid exception after L2CAP psm assigned

Use case: BT will get crash in SNS testing.

steps: SNS testing BT ON/OFF.

Failure: Crash is observed.

Root Cause: If the number of supported services increased,
larger service record array is required. Smaller array is
resulting in out of record error causing L2CAP deregister.

Fix: Check added to avoid null pointer exception if null
is returned while fetching sock from id. Also cleanup of
SDP and security records done during BT turning Off.

Change-Id: I2e77127262119cabf2c372f894427dcdf3350e80

Prevent crash due to second attempt to clean up eager_reader

Null out the eager readers once they are cleaned up, so we
don't try to clean them up later if an error occurs opening
the HAL again later.

Change-Id: I07df1010a1a619cb67b306d64e274d450234a002

Remove bonded device information on pairing rejected

Use Case: Remove bonded device information from the BTIF layer storage
when authentication failed.

Failure: Remote device appeared in the paired list after authentication
failed.

Steps:
1. Create a connection from DUT to remote.
2. Remove linkkey in remote.
3. Create connection from DUT to remote, which is in paired list of
DUT, Remote rejected the connection and authentication failed.
But after BT OFF/ON, remote device appeared in the paired list

Root Cause: Not removing device if remoted rejected the pairing
request with reason pairing not allowed

Fix: Remove bonded device information from the BTIF layer storage
on rejected with pairing not allowed reason from remote

Change-Id: Ic9e5e1ed70d304edd3dbca82a73833753fa0093c

GAP: Save pin code length for incoming legacy SAP connection

Use case: Carkit cannot reconnect to DUT in Sim Access Profile mode

Steps:
1. Pair with a car-kit (Agree all SAP, MAP, PBAP requests)
2. Initiate disconnection on DUT
3. Initiate re-connection on the car-kit.

Failure: SAP profile reconnection failing as dut gives negetive
linkkey reply.

Root Cause: sec_flags not getting updated without pin len and stack
triggering negative link key reply even linkkey is proper for 16 digit
authentication of SAP.

Fix: Save pin length during BTM_PINCodeReply.

Change-Id: I8300dd3ff497058291143313b169190910e0a7c5

Ignore pairing not allowed error when pairing in progress

Use case: Pairing with both devices fails, when there is
clash of pairing from 2 devices

1. Create a link from Test tool to DUT. Remove bonding info in Test tool.
2. Create a link from DUT to magic mouse. Unpair the link from DUT.
3. Click on magic mouse, it creates a link, and we get a pairing
   pop-up in DUT.
4. Try to pair from Test tool to DUT.

Failure: Pairing with mouse should success and other pairing
should fail. But both pairing fails

Root cause: Stack sending pairing not allowed error to upper layers
for the second device when already pairing is in progress with
some other device, which is impacting the existing pairing.

Fix: Issue fixed by Ignore pairing not allowed error for the
second device when already pairing is in progress with some
other device.

Change-Id: I20dbd70e7429505a580c9a20d40a8d92318f6c3e

Handled delayed info response from remote during SDP

Use case: DUT is not connecting to windows-7 tablet

Failure: Connection is not successful with windows-7 tablet.

Steps:
1. Turn on BT on DUT
2. Pair and connect from remote device.

Root Cause: DUT initiates connection with out waiting for
information response from remote device during SDP.

Fix: DUT will not wait for information response from the
remote during SDP.

Change-Id: Iee0251f8f81923b1291983b66b31c78e14d21af0

GAP: Update Paging and inquiry busy level seperately

Use case:  Bluetooth Search Fail while ACL disconnection.

Steps:
1. Headset(HBS 760) connect
2. Put Headset off
3. BT Search Fail.

Failure: BT search fail after disconnected Headset.

Root cause: While updating the busy level of Paging or inquiry '10'
was used as BL for paging and inquiry,this leads to
1. Ignore the one of them when both of them are active.
2. During ACL disconnection, unexpected inquiry busy level update.

Fix: Sending unique busy level for paging related events and inquiry
related events, so that each event will be notified.

Change-Id: I7bddcb4901061c450555235717b7d49bab922ae8

GAP Write 248 char name length to the chip while BT ON/OFF

Use case: Remote device cannot see local name with 248 chars.

steps:
1. Turn on BT (Default name will come)
2. Change local name to 248 chars
   make sure DUT can be successfully searched from remote device.
3. Turn off BT (or phone reboot)
4. Turn on BT

After step.4, the 248 chars name comes to GUI on MTP. However
device search from remote device having DUT "Default name".

Failure: Remote device cannot see local name with 248 chars.

Root cause: DUT not supporting for the 248 char local name

Fix: Writing the exact 248 character local name to the chip

Change-Id: I702af8fa8d0affda509de7a9f17af8922e410286

Failed to re-register APK Configuration for HDP

Use case: register/unregister HDP from third party APK

Test Steps:

1.Install Any Test APK which internally registers/unregister the HDP.
2.Run Test APK.
3.Do initialization of Test APK which internally registers the HDP.
4.Force stop the Test APK.
5.And rerun the APK by going back test APK menu.
6.Now it never perform the re-register the HDP as part of initialization.

Root Cause: HDP registration related counter write operations are done
in JNI main thread, and it's been referenced in BTIF thread.Sometimes,
if the context switch to BTIF thread doesn't happen immediately after
counter increment/decrement, it may not un-register the app if the
counter becomes 0.

Fix: Fixed it by making all operations related to counter in BTIF
thread, so that de-registration happens for all HDP APPs.

Change-Id: I71ace68a5f3d39d81b646f5f40c02ce56b9e93f0

Added check for hci_layer status before processing function calls

Use case: BT will get crash in SNS testing.

Steps: SNS testing BT ON/OFF.

Failure: Crash is observed.

Root Cause: When hci_layer functions for transmit command and cleanup
are called during hci_layer shutdown, they might try to access
lists that are already cleared as part of shutdown process.

Fix: Added check within functions to check for hci_layer state
before processing.

Change-Id: I8dbca9893e03dfc500886c5033a79976dc5d23e1

Group BR-EDR related SDP variables under transport

Use Case: Random RNR initiated after HOGP Keyboard disconnection.

steps:
1. keep madcatz in advertisement mode and scan, pair from DUT.
2. keep dailog Keyboard in advertisement mode and scan, pair from DUT.
3. Take Keyboard out of range to initiate disconnection from remote
or initiate disconnection from remote.

Failure: DUT trying to do RNR to random device.

Root Cause: when the disconnection happened for LE device, it sets
the wait_disc to true, that is causing random RNR to go for BR-EDR
device.

Fix: Group all BR-EDR related SDP variables under transport check
so that if some other operation on LE will not corrupt these BR-EDR
variables to mislead.

Change-Id: Ic9003f2b85bbaaa30b201b8a639a9d9b52055ac5

7 years agoEnable AVRCP TG feature only when A2dp source is enabled
Anubhav Gupta [Tue, 5 May 2015 12:18:24 +0000 (17:48 +0530)]
Enable AVRCP TG feature only when A2dp source is enabled

  - Drop Control, Meta and Browse commands when TG is not up.
  - Not to call AVRCP app callbacks when mentioned service is down.
  - Advertise AVRC CT category 2 support in CT SDP record.

Change-Id: Ib54c104e87c735b55d6c6ec07c08d2149acc1a6d

7 years agoReject Metadata command with invalid length
Anubhav Gupta [Wed, 21 May 2014 14:33:00 +0000 (20:03 +0530)]
Reject Metadata command with invalid length

This change ensures that DUT rejects AVRCP Meta command
having invalid data length to avoid crash while processing
the invalid command further.
This crash was seen while running codenomicon test suit.

Change-Id: I8a591d601636a0fce268b5b965f2bd691c24c319

7 years agoEnable incoming connection for AVRCP Controller
Anubhav Gupta [Tue, 5 May 2015 14:54:47 +0000 (20:24 +0530)]
Enable incoming connection for AVRCP Controller

 - Start listening for incoming AVRCP connection if we have
   only AVRCP Controller
 - Update default peer_features based on feature mask. In case
   of incoming AVRCP connection, SDP will be done later.
   In such a scenario default peer features sent to btif should
   be based on  features-set selected during initialization.

Change-Id: Ied8ac0673288a4423bd41500985366ddc2c567a8

7 years agoInitiate Sniff on A2DP/HFP links
Anubhav Gupta [Tue, 24 Sep 2013 06:01:16 +0000 (11:31 +0530)]
Initiate Sniff on A2DP/HFP links

With Plantronics headsets it has been seen that sometime
it takes upto 30s to initiate SNIFF. With these devices
ACL is in active mode for that duration. Though there is
no user observable impact but power consumption will
be more as link does not go to SNIFF.

Changes are done in Handsfree Power Manager table such that
once Handsfree PM state Machine goes to idle state, SNIFF
timer is started. In addition to that extra power mode entry
for AV is avoided by passing correct app_id to sys methods.
This avoids sending app_open from SDP for A2DP. Instead uses
conn_open while starting SDP and conn_close on SDP complete.

Change-Id: I25608db3e2b8cfe8f44b10894d5d3a7388b54ed5

7 years agoHandle Disconnect request in Opening State.
c_sdamga [Mon, 20 Jul 2015 13:47:04 +0000 (19:17 +0530)]
Handle Disconnect request in Opening State.

When A2dp is unchecked from settings UI and remote has
initiated a2dp connection and initiated AVRCP play music
gets started on DUT. Since A2dp connection is disconnected
music continues to play on DUT.

As A2dp connection was not completed, btif state was still
in opening state.Hence handle disconnect in opening state
so that we disconnect A2dp before AVRCP cmd is processed

Change-Id: If1cda5b78100419fdc60c97349efafdd4a18d40c

7 years agoBT:[1/3]Send VSC to SOC for VOIP connectivity network type.
Sumit Bajpai [Tue, 9 Jun 2015 12:55:20 +0000 (18:25 +0530)]
BT:[1/3]Send VSC to SOC for VOIP connectivity network type.

- Handle voip network type wifi command from BT app.
- Prepare VSC in BTIF.
- Handle command complete for VSC.

CRs-Fixed: 821566
Change-Id: Ia74e1f0f1e0fb37f952b736b1546ed2de5aee5af

7 years agoBluetooth: update both connected HS.
Gaurav Asati [Tue, 18 Aug 2015 13:39:57 +0000 (19:09 +0530)]
Bluetooth: update both connected HS.

 - When VR is launched/closed from connected HS, update other
   HS for VR state change.
 - When VR is launched/closed from UI, update both connected
   HS for VR state change.

Change-Id: I652557abe6983e60b7d2ace305b5418f4fba3c70