OSDN Git Service

android-x86/system-bt.git
6 years agoAdd support for Multi-A2DP state machines per device am: d752229b61
Pavlin Radoslavov [Sat, 27 Jan 2018 00:02:40 +0000 (00:02 +0000)]
Add support for Multi-A2DP state machines per device am: d752229b61
am: bce489b8ae

Change-Id: I7348bf5fcf03eb039b260f8cf6209e5d3d4e492f

6 years agoAdd support for Multi-A2DP state machines per device
Pavlin Radoslavov [Fri, 26 Jan 2018 23:54:07 +0000 (23:54 +0000)]
Add support for Multi-A2DP state machines per device
am: d752229b61

Change-Id: Ie81f523d742a1fc57a8840915df5d7f11dc4e9d7

6 years agoMerge "btif: Name the unique_lock in initialize_transaction()" am: 625973a024
Tom Cherry [Fri, 26 Jan 2018 23:04:42 +0000 (23:04 +0000)]
Merge "btif: Name the unique_lock in initialize_transaction()" am: 625973a024
am: 4a71b2e39c

Change-Id: If449137110d6cdee4b6806020d02a9a370f28704

6 years agoMerge "btif: Name the unique_lock in initialize_transaction()"
Tom Cherry [Fri, 26 Jan 2018 23:01:35 +0000 (23:01 +0000)]
Merge "btif: Name the unique_lock in initialize_transaction()"
am: 625973a024

Change-Id: I794c19e52bf9613bb17e6d62fe614af262bc3b25

6 years agoAdd support for Multi-A2DP state machines per device
Pavlin Radoslavov [Sat, 25 Nov 2017 03:12:11 +0000 (19:12 -0800)]
Add support for Multi-A2DP state machines per device

* Reimplement most of the BTIF AV state machinery in C++
 - Separate the BTIF AV Source from BTIF AV Sink state:
   btif_av_source and btif_av_sink
 - Remove the single btif_av_cb control block instance
 - Add C++ based BtifStateMachine and remove the older C-based
   btif_sm state machine
 - Introduce C++ class BtifAvPeer to keep state per peer, and use
   a single state machine instance per peer
 - Update BTA_AvStart() and BTA_AvStop() to take tBTA_AV_HNDL handle
   argument
 - Register the BTA handles when enabling the Source/Sink service.
   This needs to be done in advance during service startup, otherwise
   a connection to a remote device will fail.
 - Move local event_handler functions inside C++ ProcessEvent methods,
   and pocess the BTIF, BTA AV and BTA AVRCP events per state machine
   instance
 - Cleanup callbacks and use do_in_jni_thread() to schedule the processing
 - Add BTIF AV API that needs to be called by the AVRCP module for certain
   AVRCP events: btif_av_avrcp_event_open(), btif_av_avrcp_event_close()
   btif_av_avrcp_event_remote_play()
 - Add a mechanism to set the active device
 - Add BluetoothDevice argument to the codec-related internal Binder
   APIs: getCodecStatus(), enableOptionalCodecs(),
   disableOptionalCodecs(), setCodecConfigPreference()
 - Rename btif_av_move_idle() to btif_av_acl_disconnected() and
   refactor the processing to happen within each state machine on the
   correct thread.
 - Process cleanup_src and cleanup_sink on the JNI thread
 - Add a mechanism to track the maximum number of connected devices.
 - Add unit tests for the new BtifStateMachine class

* Redesign some of the AVDTP internals so it can handle multiple connected
  devices
 - Change some of the AVDTP struct entries to C++ classes.
   This simplifies significantly the design fixes
 - Reorganize the AvdtpScb entries: for each connection the
   corresponding SEP entries are within the corresponding AvdtpCcb entry.
 - Pass peer address as argument to the API functions inside bta_av_co.cc,
   and update the peer address inside the corresponding peer entry in
   bta_av_co.cc
 - Add various log mesages
 - Store precomputed BTA AV SCB index in the AvdtpCcb entry and use it as
   appropriate.
 - Fix the TCID computation and handling for the AvdtpAdaptationLayer
 - Fix the computed value for AVDT_NUM_RT_TBL
 - Remove video-related code inside AVDTP
 - Refactor/cleanup hard-coded callbacks that depend on the BTA_AV_NUM_STRS
   value.
 - Update various #define values to support a larger number of connected
   devices:
   - Maximum number of streams:
     BTA_AV_NUM_STRS: 2 -> 6
   - BT_RC_NUM_APP: 1 -> 12 (AVRCP-related - 2 * MaxDevices)
   - MAX_L2CAP_LINKS: 7 -> 13
   - MAX_L2CAP_CHANNELS: 16 -> 32
   - AVDT_NUM_LINKS: 2 -> 6
   - AVDT_NUM_SEPS: (6 * AVDT_NUM_LINKS) -> 6
     Now the value is used for the maximum number of SEPs per device
   - AVDT_NUM_TC_TBL: 6 -> (AVDT_NUM_SEPS + AVDT_NUM_LINKS)
   - AVCT_NUM_LINKS: 2 -> 6
   - AVCT_NUM_CONN: 3 -> 14 (2 * MaxDevices + 2)

Also:
 - Update the JNI codec-related calls to use const reference
   instead of a pointer
 - Update the implementation of bta_av_chk_2nd_start() so it is aligned
   with bta_av_chk_start() and cleaned up both functions.
 - Rename btif_dispatch_sm_event() to btif_av_dispatch_sm_event() and
   btif_report_source_codec_state() to btif_av_report_source_codec_state()
   for consistency with the rest of the BTIF AV API.
 - Add new function btif_rc_is_connected_peer() and remove
   btif_rc_get_connected_peer()
 - Add new AVRCP header file btif/include/btif_rc.h
   and move the AVRCP "extern" declarations from btif_av.cc there.
 - Rename btif_av_execute_service() to btif_av_source_execute_service()
 - Cleanup the btif_av.h API descriptions
 - Print the BTIF AV state in the "dumpsys bluetooth_manager" output
 - Print the BTA AV state in the "dumpsys bluetooth_manager" output
 - Print the AVDTP state in the "dumpsys bluetooth_manager" output
 - Refactor btif_a2dp_source_cb into a class with internal state.
 - Refactor A2DP Source worker thread handling and replace it with
   libchrome message handler
 - Refactor BtaAvCo component (bta_av_co.cc)
   - C++ classes and state
   - Rename bta_av_co_audio_src_data_path to
     bta_av_co_audio_source_data_path
   - Remove most BTA_AV_CO_CP_SCMS_T checks
   - Replace mutex_global_lock() usage with local mutex
   - Keep codec-specific state per peer
   - Keep state about the active peer - the first connected peer is the
     default active peer
   - Report source codec state only for valid peers; i.e., don't report
     source codec state for empty RawAddress
   - Keep the contect_protect_active flag per peer
   - Print the BTA AV CO state in the dumpsys bluetooth_manager" output
 - Misc cleanup in BTA AV
 - Add ToString() method to struct btav_a2dp_codec_config_t
 - Additional cleanup

Bug: 70350399
Test: Manual and unit tests
Change-Id: Icecd7fd44a222d939b63a7473a2239ae0679f08c
Merged-In: Icecd7fd44a222d939b63a7473a2239ae0679f08c
(cherry picked from commit c7242818d4180dec4eae2e75f9fb91f7f6a160aa)

6 years agoMerge "btif: Name the unique_lock in initialize_transaction()"
Treehugger Robot [Fri, 26 Jan 2018 21:26:24 +0000 (21:26 +0000)]
Merge "btif: Name the unique_lock in initialize_transaction()"

6 years agoCancel LE Advertising related timers during shutdown am: c3049d6b6c
Hemant Gupta [Fri, 26 Jan 2018 19:48:09 +0000 (19:48 +0000)]
Cancel LE Advertising related timers during shutdown am: c3049d6b6c
am: 1f8152e0ba

Change-Id: I8169f61ec0cf8357195cdc5d2feb38fc7be9062a

6 years agoUse weak pointer when refering to AdvertisingManager am: ce0d65f4b9
Jakub Pawlowski [Fri, 26 Jan 2018 19:48:01 +0000 (19:48 +0000)]
Use weak pointer when refering to AdvertisingManager am: ce0d65f4b9
am: b380808af7

Change-Id: Ia8fd3c5b95483045bd86c1e93195e8ab5261ce6b

6 years agoCancel LE Advertising related timers during shutdown
Hemant Gupta [Fri, 26 Jan 2018 19:37:48 +0000 (19:37 +0000)]
Cancel LE Advertising related timers during shutdown
am: c3049d6b6c

Change-Id: I6d5d4200e16dc2aec4e50a459cd01e61640f3318

6 years agoUse weak pointer when refering to AdvertisingManager
Jakub Pawlowski [Fri, 26 Jan 2018 19:37:39 +0000 (19:37 +0000)]
Use weak pointer when refering to AdvertisingManager
am: ce0d65f4b9

Change-Id: Ic1ec6e485cf9f66f6dd134a3757a93c4a1ff1521

6 years agobtif: Name the unique_lock in initialize_transaction()
Tom Cherry [Fri, 26 Jan 2018 17:43:35 +0000 (09:43 -0800)]
btif: Name the unique_lock in initialize_transaction()

initialize_transaction()'s unique_lock is released immediately as a
temporary variable because it does not have a name.

Bug: 72525761
Test: None
Change-Id: Ic1b1a0bd3ab1e5f993ffe5e81b0cc390cb4e34ab

6 years agoCancel LE Advertising related timers during shutdown
Hemant Gupta [Tue, 23 Jan 2018 00:54:33 +0000 (16:54 -0800)]
Cancel LE Advertising related timers during shutdown

Failure to cancel advertising timers might lead to them being executed
after AdvertisingManager is destroyed.

Test: ran all advertising tests, no regression
Fixes: 71051865
Change-Id: I4431f5e0fe82501dbdbb9ca816eb092dde7c9436

6 years agoUse weak pointer when refering to AdvertisingManager
Jakub Pawlowski [Thu, 25 Jan 2018 18:53:57 +0000 (10:53 -0800)]
Use weak pointer when refering to AdvertisingManager

In btif layer, we schedule tasks for execution on
AdvertisingManager on bta thread. Before the scheduling we check if
AdvertisingManager is initialized. We don't check if AdvertisingManager
is still valid, when the command execution is starting on the bta thread.
This is a race condition, that can cause crashes.

To fix that, always post task for execution using weak reference, rather
than raw pointer. Thanks to it, the MessageLoop will check if the
weak_ptr is valid before attempt to execute the task. The check happens
on the target thread, right before the execution, eliminating all
possible race conditions.

Test: ran all advertising tests, no regression
Bug: 71051865
Change-Id: I7fd8255879d5272d47aa79974bb79bdaacb55800

6 years agoMerge "Fixed L2CAP Buffer Length when transmit packets" am: 935513cbab
Jakub Pawlowski [Thu, 25 Jan 2018 23:09:50 +0000 (23:09 +0000)]
Merge "Fixed L2CAP Buffer Length when transmit packets" am: 935513cbab
am: 3ba64555cc

Change-Id: I2c982afaefc31ccee49fd8326bde02f5af2b4d2a

6 years agoMerge "Fixed L2CAP Buffer Length when transmit packets"
Jakub Pawlowski [Thu, 25 Jan 2018 22:53:15 +0000 (22:53 +0000)]
Merge "Fixed L2CAP Buffer Length when transmit packets"
am: 935513cbab

Change-Id: I84dd547ead33d9099ea5265a8685f137781371fa

6 years agoMerge "Fixed L2CAP Buffer Length when transmit packets"
Jakub Pawlowski [Thu, 25 Jan 2018 22:37:16 +0000 (22:37 +0000)]
Merge "Fixed L2CAP Buffer Length when transmit packets"

6 years agoFixed L2CAP Buffer Length when transmit packets
Stanley Tng [Thu, 25 Jan 2018 19:40:35 +0000 (11:40 -0800)]
Fixed L2CAP Buffer Length when transmit packets

Fixed the problem of the L2CAP buffer length is incorrect than blasting
multiple small data packets from java layer. The buffer length should be
what is actually read rather than what is possible to be read.

Test: Ran the new ACTS Tests for LE CoC
Bug: 70683224
Change-Id: I6cf4d465a41e4e936420f76b49ce2dbda20d41fb

6 years agoDon't pack and align GATT structs am: 1eda2929c9
Zach Johnson [Thu, 25 Jan 2018 16:49:35 +0000 (16:49 +0000)]
Don't pack and align GATT structs am: 1eda2929c9
am: e2e36999d1

Change-Id: Ia16fdda3dc1fa7bb8e0b6a93d0b619315cc5eb78

6 years agoDon't pack and align GATT structs
Zach Johnson [Thu, 25 Jan 2018 16:46:36 +0000 (16:46 +0000)]
Don't pack and align GATT structs
am: 1eda2929c9

Change-Id: Iffeb0f1a7c85d194dcefbcaa8353918fa6f09916

6 years agoDon't pack and align GATT structs
Zach Johnson [Thu, 25 Jan 2018 02:22:14 +0000 (18:22 -0800)]
Don't pack and align GATT structs

Causes BUS_ADRALEN on some architectures.

Change-Id: I50c2e1b4ef81fa8cd223cba09285099da8d7f67d
Fixes: 70571956
Test: 100% repro on bug before change, retest and 0% repro

6 years agoGet rid of BTA_SYS_DM - use do_in_bta_thread instead am: 0d4868040f
Jakub Pawlowski [Wed, 24 Jan 2018 20:58:49 +0000 (20:58 +0000)]
Get rid of BTA_SYS_DM - use do_in_bta_thread instead am: 0d4868040f
am: ccd75ed157

Change-Id: I5eccfce4aa6c27df33f51786ad4bf74032a68bfc

6 years agoGet rid of BTA_SYS_DM - use do_in_bta_thread instead
Jakub Pawlowski [Wed, 24 Jan 2018 20:55:22 +0000 (20:55 +0000)]
Get rid of BTA_SYS_DM - use do_in_bta_thread instead
am: 0d4868040f

Change-Id: I3ce30945bd3127204161d81d3a9bf3dafeb77a0a

6 years agoGet rid of BTA_SYS_DM - use do_in_bta_thread instead
Jakub Pawlowski [Tue, 23 Jan 2018 20:46:07 +0000 (12:46 -0800)]
Get rid of BTA_SYS_DM - use do_in_bta_thread instead

Test: Bond, change device name, scan for classic devices
Change-Id: If8d95976c4bb9ee6f346682590285cfc9d163ff5

6 years agoHFP: Add support for Multi-HFP (2/2) am: ca7d6f5912
Jack He [Wed, 24 Jan 2018 19:47:13 +0000 (19:47 +0000)]
HFP: Add support for Multi-HFP (2/2) am: ca7d6f5912
am: 35f2dae044

Change-Id: Ic13fa9eea73258ee5ec2797adc62dd5d2234762f

6 years agoHFP: Add support for Multi-HFP (2/2)
Jack He [Wed, 24 Jan 2018 19:42:43 +0000 (19:42 +0000)]
HFP: Add support for Multi-HFP (2/2)
am: ca7d6f5912

Change-Id: Ia80e37d828827b70cab4465b8d9044dd463ee8a3

6 years agoHFP: Add support for Multi-HFP (2/2)
Jack He [Wed, 10 Jan 2018 10:34:05 +0000 (02:34 -0800)]
HFP: Add support for Multi-HFP (2/2)

* Allocate at most 6 control blocks for btif_hf and bta_ag,
  this limit is defined by BTA_AG_MAX_NUM_CLIENTS
* Allow at most 6 RFCOMM connections to be managed by bta_ag
* Allow at most 6 SDP callbacks for each bta_ag
* Reject incoming SCO connection and do not start outgoing SCO
  connection if not coming from the current active device
* Reject incoming AT+BCC request if the remote device is not an active
  device
* Support only one device by default
* Fixed a bug in BTM_CreateSco where power mode was checked for old
  device and new power mode is set for new device and caused BTM SCO
  state machine to stuck in SCO_ST_PEND_UNPARK mode
* Added logs at failure conditions to be more verbose about connection
  errors and removed logs from non-error conditions to reduce verbosity
  in normal conditions

Bug: 68952570
Test: runtest -j40 bluetooth, native unit tests, HFP regression for 1
      device, simple tests for multiple devices
Change-Id: I97d20f6a126d77a4ef3a0cd1706b48130b4a6aae

6 years agoMinor improvements in LE Create Connection handling am: 659e34f343
Jakub Pawlowski [Wed, 24 Jan 2018 15:56:36 +0000 (15:56 +0000)]
Minor improvements in LE Create Connection handling am: 659e34f343
am: 418eed965e

Change-Id: I93d7415bc612de7c0679a15add60c26a55f7ec2c

6 years agoMinor improvements in LE Create Connection handling
Jakub Pawlowski [Wed, 24 Jan 2018 15:55:08 +0000 (15:55 +0000)]
Minor improvements in LE Create Connection handling
am: 659e34f343

Change-Id: I8153117afffb8b1fca50a33b3da9d23779558cbe

6 years agoMinor improvements in LE Create Connection handling
Jakub Pawlowski [Tue, 23 Jan 2018 17:07:59 +0000 (09:07 -0800)]
Minor improvements in LE Create Connection handling

1. According to spec, controller should never send "Command Complete" event
after "LE Create Connection" or "LE Extened Create Connection" command.
Add error message in such case.

2. Parse Comand Status for LE Enhanced Create Connection.

3. Fix NPE in btm_ble_update_mode_operation, when called from
btm_ble_create_ll_conn_complete.

Test: Bond/unbond with few LE devices while connected.
Change-Id: Ic135d9a8d096634afe33997afb42d054237598c2

6 years agoMerge "Allow L2CAP first packet with partial header" am: 8535edaade
Stanley Tng [Tue, 23 Jan 2018 20:09:56 +0000 (20:09 +0000)]
Merge "Allow L2CAP first packet with partial header" am: 8535edaade
am: ef83681de9

Change-Id: I8b72178c34750ffa2c16af7676377e723d9556ad

6 years agoMerge "Allow L2CAP first packet with partial header"
Stanley Tng [Tue, 23 Jan 2018 19:42:38 +0000 (19:42 +0000)]
Merge "Allow L2CAP first packet with partial header"
am: 8535edaade

Change-Id: I6f2bbbe5a77bd393455b2af00f473e6473d0072e

6 years agoMerge "Allow L2CAP first packet with partial header"
Treehugger Robot [Tue, 23 Jan 2018 19:00:57 +0000 (19:00 +0000)]
Merge "Allow L2CAP first packet with partial header"

6 years agoRemove L2CAP_MASK_LE_COC_CHANNEL flag in channel number am: a34e9b4823
Stanley Tng [Tue, 23 Jan 2018 16:44:19 +0000 (16:44 +0000)]
Remove L2CAP_MASK_LE_COC_CHANNEL flag in channel number am: a34e9b4823
am: 928276cb5f

Change-Id: I1e796a1595b0a89203ce6fc766ee25180b537035

6 years agoRemove L2CAP_MASK_LE_COC_CHANNEL flag in channel number
Stanley Tng [Tue, 23 Jan 2018 16:39:10 +0000 (16:39 +0000)]
Remove L2CAP_MASK_LE_COC_CHANNEL flag in channel number
am: a34e9b4823

Change-Id: Ia922c148fcaa38206cb060cbba5b897b5744fed6

6 years agoRemove L2CAP_MASK_LE_COC_CHANNEL flag in channel number
Stanley Tng [Fri, 5 Jan 2018 17:25:11 +0000 (09:25 -0800)]
Remove L2CAP_MASK_LE_COC_CHANNEL flag in channel number

Cleanup the code by removing the use of L2CAP_MASK_LE_COC_CHANNEL flag
in the channel number. This flag will be passed in the proper "flags"
parameter.

Test: Ran the new ACTS Tests for LE CoC
Bug: 70683224
Change-Id: I6ed77b46e5434bca5f2501d853ae8181c7197b4c

6 years agoUse do_in_bta_thread in BTA DM layer am: 154be11f74
Jakub Pawlowski [Tue, 23 Jan 2018 16:07:50 +0000 (16:07 +0000)]
Use do_in_bta_thread in BTA DM layer am: 154be11f74
am: d33cd5ab03

Change-Id: Ic887a9aacd6e8dabd4ab83cb538e6ad5a77d3803

6 years agoUse do_in_bta_thread in BTA DM layer
Jakub Pawlowski [Tue, 23 Jan 2018 16:02:50 +0000 (16:02 +0000)]
Use do_in_bta_thread in BTA DM layer
am: 154be11f74

Change-Id: I7c7b578985b5094be304f964f371601343a70a58

6 years agoUse do_in_bta_thread in BTA DM layer
Jakub Pawlowski [Mon, 22 Jan 2018 18:22:43 +0000 (10:22 -0800)]
Use do_in_bta_thread in BTA DM layer

This patch is transforming all the trivial cases, where no variable
length data is included in the event struct. Further patches will
convert the non-trivial cases.

Bug: none
Test: scan, connect, set name, remove device
Change-Id: Ia216a8a7c3bb225aedac34375ce07b109398557c

6 years agoForward Hearing Aid UUID when discovered over LE am: 35bd37d395
Jakub Pawlowski [Tue, 23 Jan 2018 00:23:34 +0000 (00:23 +0000)]
Forward Hearing Aid UUID when discovered over LE am: 35bd37d395
am: 7167f129a5

Change-Id: Ie4ba93fa36d0bed27909a8046bc9e1be24f6a2ea

6 years agoForward Hearing Aid UUID when discovered over LE
Jakub Pawlowski [Tue, 23 Jan 2018 00:19:27 +0000 (00:19 +0000)]
Forward Hearing Aid UUID when discovered over LE
am: 35bd37d395

Change-Id: I39945939bc5e899f0000c2a8d05eedd0e61b6249

6 years agoBTE: Allocate LogMsg buffer on the stack am: 7a3819f092
Gurpreet Ghai [Mon, 22 Jan 2018 20:05:42 +0000 (20:05 +0000)]
BTE: Allocate LogMsg buffer on the stack am: 7a3819f092
am: a6474abbea

Change-Id: Ie6733b5643b0b6ceea1c976cce2288909308d1c1

6 years agoBTE: Allocate LogMsg buffer on the stack
Gurpreet Ghai [Mon, 22 Jan 2018 19:52:42 +0000 (19:52 +0000)]
BTE: Allocate LogMsg buffer on the stack
am: 7a3819f092

Change-Id: I54c0bf8dc64ad9c11a6d745aa64f16bbde3a9f6c

6 years agoForward Hearing Aid UUID when discovered over LE
Jakub Pawlowski [Tue, 21 Nov 2017 20:21:05 +0000 (12:21 -0800)]
Forward Hearing Aid UUID when discovered over LE

This way upper layers (Settings app) can make decision whether to connect
to the profile.

Test: none
Bug: 69623109
Change-Id: I98e93ebbf7ceadd1756e4dfd0e8c4f876544b39d

6 years agoDo SDP when HSP connection starts by remote am: ade654f3dc
Satish Kodishala [Mon, 22 Jan 2018 16:59:45 +0000 (16:59 +0000)]
Do SDP when HSP connection starts by remote am: ade654f3dc
am: 1bd52b3daf

Change-Id: Ia5e1d753ae4416a401781fd01f05585d1afb09bc

6 years agoBTE: Allocate LogMsg buffer on the stack
Gurpreet Ghai [Mon, 7 Aug 2017 06:05:22 +0000 (11:35 +0530)]
BTE: Allocate LogMsg buffer on the stack

Problem:
Due to static 1k buffer in LogMsg function is leading to a crash in
btapp as this function is called from multiple threads

Steps:
A2DP streaming or similar process that performs excessive logging

Failure: Crash occurs

Root Cause:
Static buffer being accessed and updated by different threads parallelly

Fix:
Used local buffer instead of static buffer from LogMsg function

Test: manual
Fixes: 69586278
Change-Id: I037d85c1ca0e134d1fa86308d0467f88d8ea159d

6 years agoDo SDP when HSP connection starts by remote
Satish Kodishala [Mon, 22 Jan 2018 16:57:03 +0000 (16:57 +0000)]
Do SDP when HSP connection starts by remote
am: ade654f3dc

Change-Id: If3a217646b08e2f2f184d646aa9a786851481328

6 years agoDo SDP when HSP connection starts by remote
Satish Kodishala [Thu, 11 Aug 2016 04:51:48 +0000 (10:21 +0530)]
Do SDP when HSP connection starts by remote

Test: 1. Enable only HSP profile on AG.
2. Connect to AG from BT headset supporting HSP profile only with VGS
3. VOIP call (eg. skype, hangout)
4. Control the volume using AG volume keys.

Failure:
Volume changes are not taking affect.

Rootcause:
When remote is doing SDP first, HSP AG is skipping SDP.
As a result, AG is not aware if remote supports remote
volume control feature.

Fix:
Don't skip SDP when remote does SDP first. Do SDP always
so that AG could find out if remote supports remote volume
control feature.

Fixes: 35657384

Change-Id: I73707f774dc4ec53cbd510ded15f28f87659eec3

6 years agoAllow L2CAP first packet with partial header
Stanley Tng [Wed, 10 Jan 2018 17:25:40 +0000 (09:25 -0800)]
Allow L2CAP first packet with partial header

This change will allow a fragmented and first L2CAP packet that has
partial L2CAP Header to be parsed. Only the first 2 bytes of L2CAP
header are necessary for the packet assembler to work and the subsequent
bytes of the header can be in later packets.

Test: Run RfComm and LE CoC SL4A Tests. Also verify on an OTA received packet
with the partial L2CAP CoC header.
Bug: 70683224

Change-Id: I659ebbe86eab57aa9d725f7b685525b445195e5e

6 years agoHFP: Do not use data in bta_ag_start_open if data is empty am: 26d45dc680
Jack He [Mon, 22 Jan 2018 09:35:23 +0000 (09:35 +0000)]
HFP: Do not use data in bta_ag_start_open if data is empty am: 26d45dc680
am: 6651130d44

Change-Id: I053042e0f35ff2f2bc4acedfc91bb6c773663980

6 years agoHFP: Do not use data in bta_ag_start_open if data is empty
Jack He [Mon, 22 Jan 2018 09:32:49 +0000 (09:32 +0000)]
HFP: Do not use data in bta_ag_start_open if data is empty
am: 26d45dc680

Change-Id: Ic3b3cc3edcc93d2d15b2058a61373e59f9425d6d

6 years agoHFP: Do not use data in bta_ag_start_open if data is empty
Jack He [Mon, 22 Jan 2018 07:18:05 +0000 (23:18 -0800)]
HFP: Do not use data in bta_ag_start_open if data is empty

* bta_ag_start_open() should not use data when data is empty

Change-Id: Id16d8c0ca90cbecb1b54900bd7f37a6c5c467ebd
Fixes: 72164296
Bug: 72164296
Test: make, pair and connect Bluetooth devices

6 years agoHFP: Use base::Bind instead of messages for bta_ag_api functions am: 8b699d1076
Jack He [Sun, 21 Jan 2018 22:59:31 +0000 (22:59 +0000)]
HFP: Use base::Bind instead of messages for bta_ag_api functions am: 8b699d1076
am: 24f7793da8

Change-Id: I83a4472d047aa6406b7807029aad1847f3693a52

6 years agoHFP: Use base::Bind instead of messages for bta_ag_api functions
Jack He [Sun, 21 Jan 2018 22:57:00 +0000 (22:57 +0000)]
HFP: Use base::Bind instead of messages for bta_ag_api functions
am: 8b699d1076

Change-Id: I8bd3327c91b9e755b95245bf3400698060164fe2

6 years agoHFP: Use base::Bind instead of messages for bta_ag_api functions
Jack He [Fri, 5 Jan 2018 23:11:39 +0000 (15:11 -0800)]
HFP: Use base::Bind instead of messages for bta_ag_api functions

Summary:
* Do not use bta_sys_sendmsg(BT_HDR) in bta/ag, use base::Bind instead
* Do not use BT_HDR in bta/ag
* Do not do memcpy during thread switch in bta/ag, instead, we use the
  default copy constructor

Details:
* Currently, bta_ag_api functions use explicit messages to cross from
  jni to bta thread. This adds unnecessary indirections that make it
  hard to figure out which methods in bta actually get called
* Instead, base::Bind can bind to methods in bta directly without
  putting parameters in an explicit struct. This greatly simplify our
  code without breaking the current threading model
* With base:Bind, we no longer rely on bta_sys_sendmsg(BT_HDR) to send
  event across threads. We can therefore get rid of BT_HDR in all
  sub-types of tBTA_AG_DATA. Instead of using BT_HDR->layer_specific
  flag to pass down handle IDs, we pass down handle ID directly,
  resulting in less confusion on the actual meaning of data

Bug: 70538124
Test: runtest bluetooth, native unit tests
Change-Id: Ic0b4498dd623d0ea31b4513d6b7861cae390bc72

6 years agoOne less copy when sending LE CoC data. am: 8451931236
Jakub Pawlowski [Sat, 20 Jan 2018 17:09:59 +0000 (17:09 +0000)]
One less copy when sending LE CoC data. am: 8451931236
am: 46cd2710db

Change-Id: I792c7373d035d8644a46e7831c87e439a4fc2506

6 years agoOne less copy when sending LE CoC data.
Jakub Pawlowski [Sat, 20 Jan 2018 17:07:27 +0000 (17:07 +0000)]
One less copy when sending LE CoC data.
am: 8451931236

Change-Id: Ie63ed4fa3ce9848c9285c25f037bb676370fa569

6 years agoOne less copy when sending LE CoC data.
Jakub Pawlowski [Fri, 12 Jan 2018 14:22:43 +0000 (06:22 -0800)]
One less copy when sending LE CoC data.

After this patch, data is read from socket directly into BT_HDR that is
passed down the stack, rather than copying the data later.

Test: manual
Bug: 68359837
Change-Id: I3f304e6c7e60ce64b44350678d0ba10324fc97bc

6 years agoAdd Connection Event Min/Max hint to Connection Update Request am: c194ec1e89
Jakub Pawlowski [Sat, 20 Jan 2018 03:50:16 +0000 (03:50 +0000)]
Add Connection Event Min/Max hint to Connection Update Request am: c194ec1e89
am: 235bbca2a4

Change-Id: Id4194e42c6b504aa83d0b000897a9ab85ed0e5f8

6 years agoAdd Connection Event Min/Max hint to Connection Update Request
Jakub Pawlowski [Sat, 20 Jan 2018 03:47:42 +0000 (03:47 +0000)]
Add Connection Event Min/Max hint to Connection Update Request
am: c194ec1e89

Change-Id: I6ccc959a08ecb6c25029ba9b8a03952f7066395b

6 years agoAdd Connection Event Min/Max hint to Connection Update Request
Jakub Pawlowski [Fri, 19 Jan 2018 19:29:21 +0000 (11:29 -0800)]
Add Connection Event Min/Max hint to Connection Update Request

Bug: 69623109
Test: manual on HA
Change-Id: Idc08d08029f287751fafb4a8e2379dcc118e5ac3

6 years agoMerge "a2dp_source: Use SIZE_MAX queue size for worker_thread" am: f82e7898bb
Bailey Forrest [Fri, 19 Jan 2018 21:49:41 +0000 (21:49 +0000)]
Merge "a2dp_source: Use SIZE_MAX queue size for worker_thread" am: f82e7898bb
am: 0c46edf7be

Change-Id: I19a2e485f55daf44f5c71bae953d02b1897162f0

6 years agoMerge "a2dp_source: Use SIZE_MAX queue size for worker_thread"
Bailey Forrest [Fri, 19 Jan 2018 21:47:41 +0000 (21:47 +0000)]
Merge "a2dp_source: Use SIZE_MAX queue size for worker_thread"
am: f82e7898bb

Change-Id: If74f098483a3cb8116351718f1d53ee8fdd9b157

6 years agoMerge "a2dp_source: Use SIZE_MAX queue size for worker_thread"
Treehugger Robot [Fri, 19 Jan 2018 21:41:24 +0000 (21:41 +0000)]
Merge "a2dp_source: Use SIZE_MAX queue size for worker_thread"

6 years agoMerge "SDP: Increase heap buffer size used for A2DP/AVRC" am: 434fc14ef4
minwoo2.kim [Fri, 19 Jan 2018 20:35:32 +0000 (20:35 +0000)]
Merge "SDP: Increase heap buffer size used for A2DP/AVRC" am: 434fc14ef4
am: 63f964bb64

Change-Id: I4bb1382e3c6ec1d1a9b0e6b0f097dc292eb45219

6 years agoMerge "btm_sec_disconnected Check if p_dev_rec is still in scope" am: d6dad56b4b
Bailey Forrest [Fri, 19 Jan 2018 20:32:57 +0000 (20:32 +0000)]
Merge "btm_sec_disconnected Check if p_dev_rec is still in scope" am: d6dad56b4b
am: 610e717c73

Change-Id: I660f363a7845a21d43afa4da827e1e3b8642119b

6 years agoMerge "SDP: Increase heap buffer size used for A2DP/AVRC"
minwoo2.kim [Fri, 19 Jan 2018 20:32:55 +0000 (20:32 +0000)]
Merge "SDP: Increase heap buffer size used for A2DP/AVRC"
am: 434fc14ef4

Change-Id: I634d2c18a062fc1518614114619827551ea2908c

6 years agoMerge "btm_sec_disconnected Check if p_dev_rec is still in scope"
Bailey Forrest [Fri, 19 Jan 2018 20:30:27 +0000 (20:30 +0000)]
Merge "btm_sec_disconnected Check if p_dev_rec is still in scope"
am: d6dad56b4b

Change-Id: Iae71e17f3bcf081758d1b9ea85a81a9d43c341c0

6 years agoMerge "SDP: Increase heap buffer size used for A2DP/AVRC"
Treehugger Robot [Fri, 19 Jan 2018 20:27:47 +0000 (20:27 +0000)]
Merge "SDP: Increase heap buffer size used for A2DP/AVRC"

6 years agoMerge "btm_sec_disconnected Check if p_dev_rec is still in scope"
Treehugger Robot [Fri, 19 Jan 2018 20:25:28 +0000 (20:25 +0000)]
Merge "btm_sec_disconnected Check if p_dev_rec is still in scope"

6 years agoRemove casts for callbacks am: fc9eced9bc
Myles Watson [Fri, 19 Jan 2018 19:31:03 +0000 (19:31 +0000)]
Remove casts for callbacks am: fc9eced9bc
am: 574924848f

Change-Id: I65b2112322cf6d82d0e4de3f94f1eafe0f5975c7

6 years agoMake GAP_ConnWriteData accept BT_HDR am: 42bdd07088
Jakub Pawlowski [Fri, 19 Jan 2018 19:30:46 +0000 (19:30 +0000)]
Make GAP_ConnWriteData accept BT_HDR am: 42bdd07088
am: c724643d39

Change-Id: Id85d40e7b51f415ab1119a2ea592d8249e6ca4b7

6 years agoRemove casts for callbacks
Myles Watson [Fri, 19 Jan 2018 19:29:03 +0000 (19:29 +0000)]
Remove casts for callbacks
am: fc9eced9bc

Change-Id: I4b512ee541e3a32f323cc29d10f51e9e1b8971d3

6 years agoMake GAP_ConnWriteData accept BT_HDR
Jakub Pawlowski [Fri, 19 Jan 2018 19:28:45 +0000 (19:28 +0000)]
Make GAP_ConnWriteData accept BT_HDR
am: 42bdd07088

Change-Id: If4572b3d43c1076feea8ac07032454fcb1b4f535

6 years agoRemove casts for callbacks
Myles Watson [Thu, 18 Jan 2018 20:30:55 +0000 (12:30 -0800)]
Remove casts for callbacks

Casting callbacks can hide parameter mismatches from
the compiler, which makes it impossible to check
argument types.

Bug: 72005262
Test: Toggle Bluetooth, connect to a headset
Change-Id: I0c3e0653c77e829655377fbf170d1b03efa5ea32

6 years agobtm_sec_disconnected Check if p_dev_rec is still in scope
Bailey Forrest [Fri, 12 Jan 2018 23:52:14 +0000 (15:52 -0800)]
btm_sec_disconnected Check if p_dev_rec is still in scope

|btm_sec_disconnected| may call the callback
|btm_cb.api.p_auth_complete_callback| which can delete |p_dev_rec|.
After deletion, |btm_sec_disconnected| still atempts to use |p_dev_rec|.

Bug: 71913396
Test: Does not crash with a quickly terminated connection.
Change-Id: Ic28beb2888a51090283be04121d785495cf25a84

6 years agoMake GAP_ConnWriteData accept BT_HDR
Jakub Pawlowski [Thu, 18 Jan 2018 02:22:12 +0000 (18:22 -0800)]
Make GAP_ConnWriteData accept BT_HDR

This is next step towards making LE sockets work with zero copies.

Test: transfer file using OPP
Bug: 68359837
Change-Id: Iedcdd59acb223e2982f6cb96b8656f517008dee5

6 years agoRevert "HID: Update condition for checking LE HID handle validity" am: 812d20dfd8
Hemant Gupta [Fri, 19 Jan 2018 01:16:47 +0000 (01:16 +0000)]
Revert "HID: Update condition for checking LE HID handle validity" am: 812d20dfd8
am: f1cc3e6164

Change-Id: I2eddb42f1e585e4c87d61713a81cb94a3cc03a1c

6 years agoRevert "HID: Update condition for checking LE HID handle validity"
Hemant Gupta [Fri, 19 Jan 2018 01:07:38 +0000 (01:07 +0000)]
Revert "HID: Update condition for checking LE HID handle validity"
am: 812d20dfd8

Change-Id: Ia541465ba62f3a0c7bb890290f1b2a03925f2756

6 years agoAdded support for new Android API for LE CoC am: 49dd53cb3d
Stanley Tng [Thu, 18 Jan 2018 18:04:09 +0000 (18:04 +0000)]
Added support for new Android API for LE CoC am: 49dd53cb3d
am: a1eb49a78f

Change-Id: Ie510183ecaa7bb2bbf6b0cdf6b973c8b7f92d9ef

6 years agoAdded support for new Android API for LE CoC
Stanley Tng [Thu, 18 Jan 2018 17:59:28 +0000 (17:59 +0000)]
Added support for new Android API for LE CoC
am: 49dd53cb3d

Change-Id: If4aa43d5571db2f4c41d1851a486a42804a9efca

6 years agoSDP: Increase heap buffer size used for A2DP/AVRC
minwoo2.kim [Fri, 12 Jan 2018 09:09:04 +0000 (18:09 +0900)]
SDP: Increase heap buffer size used for A2DP/AVRC

This buffer is used to save the attributes parsed from the SDP response
transferred from a peer device.

In Android O, SDP fails sometimes due to full memory from SDP DB.

The reason of this shortage seems to be the increasing of allocated
memory for tSDP_DISC_ATTR.

Android N uses a 32-bit bluetooth lib and 4 bytes of memory for
pointers.

In total, 12 bytes are used for tSDP_DISC_ATTR

Android O uses a 64-bit bluetooth lib and 8 bytes of memory for
pointers.

Now, 24 bytes are used for tSDP_DISC_ATTR.

To match this increase of memory consumption, We need to double the heap
buffer size. (from 1000 to 2000)

bug: 71005276
Test: passed the connection test performed with more than 50 BT devices
launched in the market

Signed-off-by: minwoo kim <minwoo2.kim@lge.com>
Change-Id: I24bb50810e224aa1e23141493b5b2fa3b706c495

6 years agoRevert "HID: Update condition for checking LE HID handle validity"
Hemant Gupta [Fri, 12 Jan 2018 06:25:47 +0000 (11:55 +0530)]
Revert "HID: Update condition for checking LE HID handle validity"

This reverts commit af94891aa6e66b0d4b495d60aeac2aa8091c9d33 as changes to
fix same issue already merged via commit 2e3c3d782993c475e608291896db73b0960fa9dd
so this patch is not longer required.

Test: Code analysis for aosp master

Fixes: 71842479
Change-Id: Ifbc2375ad6df7231c85ef30c5e2c5b5d8dde16f0

6 years agoa2dp_source: Use SIZE_MAX queue size for worker_thread
Bailey Forrest [Thu, 18 Jan 2018 01:57:48 +0000 (17:57 -0800)]
a2dp_source: Use SIZE_MAX queue size for worker_thread

If the queue runs out of space, we can run into a deadlock.
Explanation of the deadlock is in the bug.

If I connect and disconnect ~20 times in quick succession I would
usually run into this issue

Bug: 72121764
Test: Connect/disconnect 170 times with script, issue does not occur.
Change-Id: I0a76e51aa99481f9fe4885b879209b3d215ae5b0

6 years agoAdded support for new Android API for LE CoC
Stanley Tng [Wed, 20 Dec 2017 17:38:30 +0000 (09:38 -0800)]
Added support for new Android API for LE CoC

Added support for the new Android API including the management of the
LE_PSM values.
Also fixed a bug when de-registering the L2CAP CoC, the RCB is not
freed correctly.

Test: Ran the new ACTS Tests for LE CoC and existing ACTS for RfComm
Bug: 70683224
Change-Id: I5a545656bece667e7ba942d7b2334e3f5b49b283

6 years agoLimit data accepted by GAP_ConnWriteData to just one SDU am: ce5f485e67
Jakub Pawlowski [Thu, 18 Jan 2018 13:34:04 +0000 (13:34 +0000)]
Limit data accepted by GAP_ConnWriteData to just one SDU am: ce5f485e67
am: bfa287eb85

Change-Id: Idc19aa5e5a2fe8d742d4b9d8166667ef4cb833d0

6 years agoLimit data accepted by GAP_ConnWriteData to just one SDU
Jakub Pawlowski [Thu, 18 Jan 2018 13:31:31 +0000 (13:31 +0000)]
Limit data accepted by GAP_ConnWriteData to just one SDU
am: ce5f485e67

Change-Id: I6d91324e7b8347d745a358394403258d02456bae

6 years agoMerge "Make BTA_JvL2capWrite take ownership of the data buffer" am: 00fa787f83
Jakub Pawlowski [Thu, 18 Jan 2018 02:23:30 +0000 (02:23 +0000)]
Merge "Make BTA_JvL2capWrite take ownership of the data buffer" am: 00fa787f83
am: e13fcb8cda

Change-Id: I589bd2296c1374e81c76cc2b9006d6c61ccf74ea

6 years agoMerge "Added internal API getMaxConnectedAudioDevices()" am: 94b769b9f3
Pavlin Radoslavov [Thu, 18 Jan 2018 02:18:33 +0000 (02:18 +0000)]
Merge "Added internal API getMaxConnectedAudioDevices()" am: 94b769b9f3
am: b652c61044

Change-Id: Ifa92e6e4ee011012b7e17910686e668f1b65e8d2

6 years agoMerge "Make BTA_JvL2capWrite take ownership of the data buffer"
Jakub Pawlowski [Thu, 18 Jan 2018 02:16:04 +0000 (02:16 +0000)]
Merge "Make BTA_JvL2capWrite take ownership of the data buffer"
am: 00fa787f83

Change-Id: I139a9c76519330023825464558ee47e62f10ace0

6 years agoMerge "Added internal API getMaxConnectedAudioDevices()"
Pavlin Radoslavov [Thu, 18 Jan 2018 02:10:42 +0000 (02:10 +0000)]
Merge "Added internal API getMaxConnectedAudioDevices()"
am: 94b769b9f3

Change-Id: I67191c51f005479e8fc16ee24789da1bba8db4ce

6 years agoLimit data accepted by GAP_ConnWriteData to just one SDU
Jakub Pawlowski [Fri, 12 Jan 2018 11:19:33 +0000 (03:19 -0800)]
Limit data accepted by GAP_ConnWriteData to just one SDU

This limit is already enforced in BluetoothSocket.java, which is
dividing data into pieces no bigger than MTU.

This is first step towards making it accept BT_HDR with data, in order
to make LE sockets work with zero copies.

Test: transfer file using OPP
Bug: 68359837
Change-Id: I67bfd4ab5c2dc6aa8210058a742c57e1ccf845a0

6 years agoMerge "Make BTA_JvL2capWrite take ownership of the data buffer"
Treehugger Robot [Thu, 18 Jan 2018 01:49:54 +0000 (01:49 +0000)]
Merge "Make BTA_JvL2capWrite take ownership of the data buffer"

6 years agoFix buffer overflow in GAP_ConnWriteData am: 00c922a091
Jakub Pawlowski [Thu, 18 Jan 2018 01:26:51 +0000 (01:26 +0000)]
Fix buffer overflow in GAP_ConnWriteData am: 00c922a091
am: 60b02a72a2

Change-Id: I5257934b9b05492f06de2b17d9cc9597da80e71c

6 years agoFix buffer overflow in GAP_ConnWriteData
Jakub Pawlowski [Thu, 18 Jan 2018 01:18:45 +0000 (01:18 +0000)]
Fix buffer overflow in GAP_ConnWriteData
am: 00c922a091

Change-Id: Ice8b45329a9351542d1cecc1cb4b5e3429f45a79

6 years agoMerge "Added internal API getMaxConnectedAudioDevices()"
Treehugger Robot [Thu, 18 Jan 2018 00:46:57 +0000 (00:46 +0000)]
Merge "Added internal API getMaxConnectedAudioDevices()"

6 years agoMake BTA_JvL2capWrite take ownership of the data buffer
Jakub Pawlowski [Thu, 11 Jan 2018 15:34:39 +0000 (07:34 -0800)]
Make BTA_JvL2capWrite take ownership of the data buffer

This is first step towards making it accept BT_HDR with data, in order
to make LE sockets work with zero copies.

Bug: 68359837
Test: transfer file using OPP
Change-Id: Ib202520554bbc83cb8587bf1c4caa4b0da6b266c

6 years agoFix buffer overflow in GAP_ConnWriteData
Jakub Pawlowski [Mon, 8 Jan 2018 21:06:45 +0000 (13:06 -0800)]
Fix buffer overflow in GAP_ConnWriteData

Bug: none
Test: exchange data with MPS>11000, sent file between devices using OPP
Change-Id: Ie456a35da4764bdac329135742634ce8f0a63469

6 years agoAdded internal API getMaxConnectedAudioDevices()
Pavlin Radoslavov [Wed, 17 Jan 2018 10:19:42 +0000 (02:19 -0800)]
Added internal API getMaxConnectedAudioDevices()

The API can be used to obtain the maximum number of connected
devices for A2DP or HFP.

Test: Manual
Bug: 64767509

Change-Id: Ide01ea91bc9708b20c78266d791d4775be3f943d

6 years agoMerge "Revert "Fix buffer overflow in GAP_ConnWriteData"" am: 115a92883d
Hansong Zhang [Wed, 17 Jan 2018 01:43:43 +0000 (01:43 +0000)]
Merge "Revert "Fix buffer overflow in GAP_ConnWriteData"" am: 115a92883d
am: 3f37df9c4d

Change-Id: I6a118850c76ef27a076e2ce3d59661596e4689f2

6 years agoMerge "Revert "Fix buffer overflow in GAP_ConnWriteData""
Hansong Zhang [Wed, 17 Jan 2018 01:40:04 +0000 (01:40 +0000)]
Merge "Revert "Fix buffer overflow in GAP_ConnWriteData""
am: 115a92883d

Change-Id: I27c3e98dce3a2f3eb4ce44c2b7f4c0726f8fb76d