OSDN Git Service

android-x86/system-bt.git
6 years agoUnify logging in btif_sock_l2cap.cc
Jakub Pawlowski [Mon, 5 Feb 2018 18:37:50 +0000 (18:37 +0000)]
Unify logging in btif_sock_l2cap.cc
am: 35ee023655

Change-Id: If90184c2211b7b3ce1bd405611bb83f929b6274a

6 years agoUnify logging in btif_sock_l2cap.cc
Jakub Pawlowski [Fri, 2 Feb 2018 19:47:09 +0000 (11:47 -0800)]
Unify logging in btif_sock_l2cap.cc

Test: compilation
Bug: 68359837
Change-Id: I71edd3d04734471b6cd586c323aa6b335f903fae

6 years agoRemove Mac host libraries build depending on libchrome.
Hidehiko Abe [Mon, 5 Feb 2018 10:36:11 +0000 (10:36 +0000)]
Remove Mac host libraries build depending on libchrome.
am: 30aa9c9447

Change-Id: I6b5463133e13ff3ac05141cdd0a70227ce3bd8de

6 years agoRemove Mac host libraries build depending on libchrome.
Hidehiko Abe [Wed, 31 Jan 2018 07:59:18 +0000 (16:59 +0900)]
Remove Mac host libraries build depending on libchrome.

Libchrome will drop the support for Mac host.
This is the preparation.

Bug: 72618679
Test: Built on Mac.
Change-Id: I37982210a1da74d56c1da3227c5887685cd8b6cb

6 years agoMerge "Add function to update LE connection parameters"
Stanley Tng [Sat, 3 Feb 2018 04:10:54 +0000 (04:10 +0000)]
Merge "Add function to update LE connection parameters"
am: 2fc4777ff1

Change-Id: I323c50150dc691d12ffd80233238490d2d1346c9

6 years agoMerge "Add function to update LE connection parameters"
Stanley Tng [Sat, 3 Feb 2018 01:36:03 +0000 (01:36 +0000)]
Merge "Add function to update LE connection parameters"

6 years agoMaximize L2CAP socket MTU
Jakub Pawlowski [Sat, 3 Feb 2018 01:21:04 +0000 (01:21 +0000)]
Maximize L2CAP socket MTU
am: 622bd222e4

Change-Id: Ia1a74b45b0fdea696c17ff23b39503627aac262a

6 years agoBTA_JvL2capConnect simplification
Jakub Pawlowski [Fri, 2 Feb 2018 22:04:26 +0000 (22:04 +0000)]
BTA_JvL2capConnect simplification
am: 3538b64d97

Change-Id: I0ac5d16c8bab410f2fb6d2ca99811ae2d2768e31

6 years agoSimplify btSock_start_l2cap_server_l
Jakub Pawlowski [Fri, 2 Feb 2018 22:04:18 +0000 (22:04 +0000)]
Simplify btSock_start_l2cap_server_l
am: e5e2dd556b

Change-Id: I0e6757ebdfb4b85cfaa60285960c70b82f669044

6 years agoAdd function to update LE connection parameters
Stanley Tng [Thu, 4 Jan 2018 23:49:35 +0000 (15:49 -0800)]
Add function to update LE connection parameters

As part of new SL4A tests for LE CoC to measure data throughput
performance, this commit will add a function to enable the CoC Facade
to modify the LE Connection Parameters especially the Connection
Intervals. Also, add some debug logs.

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

6 years agoMaximize L2CAP socket MTU
Jakub Pawlowski [Tue, 30 Jan 2018 23:40:03 +0000 (15:40 -0800)]
Maximize L2CAP socket MTU

Introduce L2CAP_SDU_LENGTH_LE_MAX constant, and use it for LE CoC
sockets, while still keeping the old value for Classic sockets.

This also require change in how we send the rx_mtu up the stack - it
must be read from the socket property.

Additionally in this patch, l2cap_socket.mtu is renamed to tx_mtu to
distinguish it from rx_mtu. Assignment of this variable is also added
when we receive it from the remote.

Bug: 68359837
Test: tranfer file using OPP, do obex, run LE CoC tests. Run tests
between device with this patch, and older android phones.
Change-Id: Iffa20a6c6a93d5787bada7bf28655e9880d8c1a0

6 years agoBTA_JvL2capConnect simplification
Jakub Pawlowski [Wed, 31 Jan 2018 06:35:11 +0000 (22:35 -0800)]
BTA_JvL2capConnect simplification

Test: manual
Change-Id: I18ac5ac451490e0d3c0c9fc5daa9f8d64ff19bd5

6 years agoSimplify btSock_start_l2cap_server_l
Jakub Pawlowski [Wed, 31 Jan 2018 05:46:08 +0000 (21:46 -0800)]
Simplify btSock_start_l2cap_server_l

Test: run OPP, chekc LE CoC
Change-Id: I4091ea8065ba913966fcd14495b90b2c565fdba3

6 years agoMerge changes I00560443,I2e39bd31
Jakub Pawlowski [Fri, 2 Feb 2018 06:54:26 +0000 (06:54 +0000)]
Merge changes I00560443,I2e39bd31
am: 70a0c9e436

Change-Id: Ib9a6ab8b75066a0b73dc3d1f39312ca0ed3905b9

6 years agoMerge changes I00560443,I2e39bd31
Treehugger Robot [Fri, 2 Feb 2018 05:00:19 +0000 (05:00 +0000)]
Merge changes I00560443,I2e39bd31

* changes:
  Stricter check of the MTU size in the BTIF L2CAP socket
  Fix naming error in btif l2cap MPS -> MTU

6 years agoMerge "Add more checks to LE Connection Parameters"
Stanley Tng [Fri, 2 Feb 2018 04:00:16 +0000 (04:00 +0000)]
Merge "Add more checks to LE Connection Parameters"
am: 85807ed9b6

Change-Id: I4ac8135b166abc3d49c0ed4f224b6da79021bba0

6 years agoMerge "Metrics: Dump native metrics to Java as std:string"
Jack He [Fri, 2 Feb 2018 03:51:47 +0000 (03:51 +0000)]
Merge "Metrics: Dump native metrics to Java as std:string"
am: a53c929550

Change-Id: Iafc3fc2b7aa484539961210e6bbf094594cf5367

6 years agoMerge "Minimize amount of Flow Control packets for L2CAP CoC"
Jakub Pawlowski [Fri, 2 Feb 2018 03:51:07 +0000 (03:51 +0000)]
Merge "Minimize amount of Flow Control packets for L2CAP CoC"
am: f262cb9f93

Change-Id: I4a0d546d06a53e98977982a179e4687ab0a5e9aa

6 years agoMerge "PDU data lengty computation fix"
Jakub Pawlowski [Fri, 2 Feb 2018 03:50:51 +0000 (03:50 +0000)]
Merge "PDU data lengty computation fix"
am: edde455514

Change-Id: I620a686465baca6f0ef65ff211a459076bca1b3d

6 years agoMerge "Add more checks to LE Connection Parameters"
Treehugger Robot [Fri, 2 Feb 2018 01:41:53 +0000 (01:41 +0000)]
Merge "Add more checks to LE Connection Parameters"

6 years agoMerge "Metrics: Dump native metrics to Java as std:string"
Treehugger Robot [Fri, 2 Feb 2018 00:23:42 +0000 (00:23 +0000)]
Merge "Metrics: Dump native metrics to Java as std:string"

6 years agoStricter check of the MTU size in the BTIF L2CAP socket
Jakub Pawlowski [Wed, 31 Jan 2018 03:45:35 +0000 (19:45 -0800)]
Stricter check of the MTU size in the BTIF L2CAP socket

Test: manual
Bug: 68359837
Change-Id: I0056044388f8886f704a9ff2f30db09b3110d143

6 years agoFix naming error in btif l2cap MPS -> MTU
Jakub Pawlowski [Wed, 31 Jan 2018 03:39:52 +0000 (19:39 -0800)]
Fix naming error in btif l2cap MPS -> MTU

BTIF layer uses only MTU, maximum size of SDU, to do computations around
sizes. This error was introduced earlier during refactor.

Test: compilation
Bug: 68359837
Change-Id: I2e39bd31ce712d22f43e3059b6e1c73ef7b0fee7

6 years agoAdd more checks to LE Connection Parameters
Stanley Tng [Thu, 1 Feb 2018 21:21:24 +0000 (13:21 -0800)]
Add more checks to LE Connection Parameters

This part of code is missing the necessary LE Connection Parameters
checks.

Test: Tested on R.A.T. LE mouse
Bug: 70683224
Change-Id: I966a3dd4fd2fa9dc54109872df3d4c43d34f0156

6 years agoMerge "Minimize amount of Flow Control packets for L2CAP CoC"
Treehugger Robot [Thu, 1 Feb 2018 21:19:47 +0000 (21:19 +0000)]
Merge "Minimize amount of Flow Control packets for L2CAP CoC"

6 years agoMerge "PDU data lengty computation fix"
Treehugger Robot [Thu, 1 Feb 2018 20:02:05 +0000 (20:02 +0000)]
Merge "PDU data lengty computation fix"

6 years agoMetrics: Dump native metrics to Java as std:string
Jack He [Thu, 1 Feb 2018 00:51:26 +0000 (16:51 -0800)]
Metrics: Dump native metrics to Java as std:string

* Dump metrics to Java layer as std::string instead of going through a
  file descriptor so that Java layer can process metrics data directly
* Add new method dumpMetrics(std::string*)

Bug: 33693818
Test: adb shell dumpsys bluetooth_manager --proto-bin
      SL4A metrics tests: BtMetricsTest, BtFunhausMetricsTest
Change-Id: I67883c1371862d7e4ff33cec01d710d2d8f274c9

6 years agoPDU data lengty computation fix
Jakub Pawlowski [Thu, 1 Feb 2018 18:03:37 +0000 (10:03 -0800)]
PDU data lengty computation fix

PDU data must also account for PDU length and Channel ID fields.
Otherwise each PDU is split into 2 BB packets, decreasing the link
speed.

Test: manual data transimssion test.
Change-Id: I026bf0e32c58eec620b5c55d748ecd81fa3ea67b

6 years agoMerge "Set pending_discovery when doing GATT over BR/EDR"
Jakub Pawlowski [Thu, 1 Feb 2018 03:36:46 +0000 (03:36 +0000)]
Merge "Set pending_discovery when doing GATT over BR/EDR"
am: 023f79e8ce

Change-Id: Ica7a4ed260edc7c8176ab7fccd5965bb2eea55a2

6 years agoMerge "Set pending_discovery when doing GATT over BR/EDR"
Treehugger Robot [Wed, 31 Jan 2018 22:49:28 +0000 (22:49 +0000)]
Merge "Set pending_discovery when doing GATT over BR/EDR"

6 years agoMinimize amount of Flow Control packets for L2CAP CoC
Jakub Pawlowski [Thu, 4 Jan 2018 13:06:21 +0000 (05:06 -0800)]
Minimize amount of Flow Control packets for L2CAP CoC

In order to not waste bandwidth on Flow Control packets with credits:
1. Set Initial Credits in the connect request/response to the maximum value
2. Send credits only when the remote has less than 64 of them left,
   increasing the value back to maximum.

Bug: 68359837
Test: observe data flow in btsnoop log
Change-Id: I34e1fecc55422b34df0b1e82bb2b402eb06620bd

6 years agoBUILD: Fix broken build for test-vendor_test_host
Jack He [Wed, 31 Jan 2018 21:33:53 +0000 (21:33 +0000)]
BUILD: Fix broken build for test-vendor_test_host
am: bc94521056

Change-Id: I9b4044f7b3faa54740b7cc089c26bb131c46543b

6 years agoBUILD: Fix broken build for test-vendor_test_host
Jack He [Wed, 31 Jan 2018 21:02:12 +0000 (13:02 -0800)]
BUILD: Fix broken build for test-vendor_test_host

* Disable darwin build for test-vendor_test_host explicitly as
  it does not use "fluoride_defaults" in its build configuration.

Bug: 72618679
Test: make
Change-Id: Ia81bf705ad248e129df69c14e385ced118c6df58

6 years agoMerge "BUILD: Disable build for mac-host target"
Jack He [Wed, 31 Jan 2018 20:06:53 +0000 (20:06 +0000)]
Merge "BUILD: Disable build for mac-host target"
am: 61f4003e52

Change-Id: I7fbad3751db03d69edeea6a4085cdedc58bb4002

6 years agoMerge "BUILD: Disable build for mac-host target"
Treehugger Robot [Wed, 31 Jan 2018 20:01:39 +0000 (20:01 +0000)]
Merge "BUILD: Disable build for mac-host target"

6 years agoBUILD: Disable build for mac-host target
Jack He [Tue, 30 Jan 2018 22:35:20 +0000 (14:35 -0800)]
BUILD: Disable build for mac-host target

* Move disable darwin (mac) options to "fluoride_defaults".
* mac-host target is disabled across fluoride, but developer can still
  build for non-mac targets on a mac host.
* Remove vendor_libs/Android.mk that is no longer used.

Bug: 72618679
Test: make
Change-Id: Ibad9fad3df169e9c4e418a4511c42066fcb10fdc

6 years agoSet pending_discovery when doing GATT over BR/EDR
Jakub Pawlowski [Wed, 31 Jan 2018 19:49:59 +0000 (11:49 -0800)]
Set pending_discovery when doing GATT over BR/EDR

SDP discovery can return services before LE discovery, or after LE
discovery is already done. In both cases, pending_discover is not a
valid pointer, and must be set before call to bta_gattc_explore_srvc

Test: sl4a GattOverBrEdr
Change-Id: I2b43d2348edfa641c56a8085a92b6367b146030d

6 years agoGet rid of L2CAP_MAX_BUF_SIZE, use variable-size buffers instead
Jakub Pawlowski [Tue, 30 Jan 2018 23:05:43 +0000 (23:05 +0000)]
Get rid of L2CAP_MAX_BUF_SIZE, use variable-size buffers instead
am: f47bfde2ed

Change-Id: Icb7dc81a1a476705984e33c171d8d1b577bd03e6

6 years agoGet rid of L2CAP_MAX_BUF_SIZE, use variable-size buffers instead
Jakub Pawlowski [Mon, 29 Jan 2018 21:54:24 +0000 (13:54 -0800)]
Get rid of L2CAP_MAX_BUF_SIZE, use variable-size buffers instead

This is step towards increasing L2CAP_MAX_SDU_LENGTH value.

Test: transfer file using OPP, send data using CoC
Bug: 68359837
Change-Id: Ia4fb6b2325cb92db9c90c6a4d2ab17f271640ea8

6 years agoPacket: Disable host tests for Mac
Myles Watson [Tue, 30 Jan 2018 19:45:45 +0000 (19:45 +0000)]
Packet: Disable host tests for Mac
am: bf101fa2c5

Change-Id: I7cbd2e2b811cf95e813428029b1c00a440852b08

6 years agoPacket: Disable host tests for Mac
Myles Watson [Tue, 30 Jan 2018 17:15:16 +0000 (09:15 -0800)]
Packet: Disable host tests for Mac

Bug: 72618679
Test: Build on Mac
Change-Id: I85c1412b86a1fbbab01491a755be9bc2b8241d50

6 years agoMerge "Drops unittest build on Mac host."
Hidehiko Abe [Tue, 30 Jan 2018 15:46:32 +0000 (15:46 +0000)]
Merge "Drops unittest build on Mac host."
am: 2706fc2cd5

Change-Id: I62ee4f02dd8b3481420582e15f7048597b2271f6

6 years agoMerge "Drops unittest build on Mac host."
Treehugger Robot [Tue, 30 Jan 2018 15:37:46 +0000 (15:37 +0000)]
Merge "Drops unittest build on Mac host."

6 years agoAdd Packet class as alternative to BT_HDR
Ajay Panicker [Tue, 30 Jan 2018 03:49:34 +0000 (03:49 +0000)]
Add Packet class as alternative to BT_HDR
am: 341ab2befa

Change-Id: If25a3b85486b871b99919429d37efc265a0b601c

6 years agoAdd Packet class as alternative to BT_HDR
Ajay Panicker [Wed, 3 Jan 2018 22:23:44 +0000 (14:23 -0800)]
Add Packet class as alternative to BT_HDR

Adds Packets, Iterators, and Packet Builders to Bluetooth to be used as
an alternative to BT_HDR.

 - Packet is a base class used to pass around data. It is intended to be
   immutable after creation and subclasses will implement all required
   functions and their own accessor methods to retrieve data.

 - Iterator provides a convienent way to traverse packet data.

 - PacketBuilder is used to construct Packets. This class is should be
   the only way to mutate packet objects.

Also add class representations for the following packet types:
  AVRCP (Base Packet)
    AVRCP Vendor Packet
      AVRCP Get Capabilities Packet
      AVRCP Get Element Attributes Packet
      AVRCP Register Notification Packet
      AVRCP Get Play Status Packet
      AVRCP Reject Packet
    AVRCP Pass Through Packet

Adds net_test_btpackets to run_host_unit_tests.py for pre-submit

Bug: 68854188
Test: run host native test net_test_packets
Change-Id: I0d385710178e5feb2d5089847580754ad6308709

6 years agoDrops unittest build on Mac host.
Hidehiko Abe [Mon, 29 Jan 2018 06:43:47 +0000 (15:43 +0900)]
Drops unittest build on Mac host.

Bug: 72618679
Test: Built on Mac.
Change-Id: If6e2f8cf39cd80e80a419fbbed0ce34931ede915

6 years agoReport LE CoC credits to GAP clients
Jakub Pawlowski [Sat, 27 Jan 2018 16:07:34 +0000 (16:07 +0000)]
Report LE CoC credits to GAP clients
am: b9c95d5a61

Change-Id: I28db97500b79b8e4d90ab31334310deb2779c158

6 years agoReport LE CoC credits to GAP clients
Jakub Pawlowski [Sat, 27 Jan 2018 01:18:52 +0000 (17:18 -0800)]
Report LE CoC credits to GAP clients

Test: manual with HA
Change-Id: Ic4552b05b6e6c7dad5311e0b893da3166bf1895c

6 years agoMerge "Report credit count change, when credits are received for LE CoC"
Jakub Pawlowski [Sat, 27 Jan 2018 04:13:08 +0000 (04:13 +0000)]
Merge "Report credit count change, when credits are received for LE CoC"
am: f6f158713a

Change-Id: I6bc20a0b10414c9e73333bce9e550e8b32390d74

6 years agoMerge "Report credit count change, when credits are received for LE CoC"
Treehugger Robot [Sat, 27 Jan 2018 04:08:05 +0000 (04:08 +0000)]
Merge "Report credit count change, when credits are received for LE CoC"

6 years agoMerge "HFP: Fix NPE in error logging for voice recognition events"
Jack He [Sat, 27 Jan 2018 03:50:17 +0000 (03:50 +0000)]
Merge "HFP: Fix NPE in error logging for voice recognition events"
am: 7676c7df90

Change-Id: I03f15ceda56a53616ec514fc46419288a624cdf3

6 years agoMerge "HFP: Fix NPE in error logging for voice recognition events"
Treehugger Robot [Sat, 27 Jan 2018 03:44:34 +0000 (03:44 +0000)]
Merge "HFP: Fix NPE in error logging for voice recognition events"

6 years agoDisable host compilation on Darwin for net_test_btif_state_machine
Pavlin Radoslavov [Sat, 27 Jan 2018 02:42:26 +0000 (02:42 +0000)]
Disable host compilation on Darwin for net_test_btif_state_machine
am: 7b593eb9c9

Change-Id: Ia8f39cc6fa9abac85c0aab07e37651fcfc45f44b

6 years agoAdd a workaround for A2DP devices that request Role Change
Pavlin Radoslavov [Sat, 27 Jan 2018 01:59:58 +0000 (01:59 +0000)]
Add a workaround for A2DP devices that request Role Change
am: 829a8f8f53

Change-Id: Ia8348c9aca0e2eb8986c3f89e104801d3828855c

6 years agoReport credit count change, when credits are received for LE CoC
Jakub Pawlowski [Sun, 21 Jan 2018 00:07:10 +0000 (16:07 -0800)]
Report credit count change, when credits are received for LE CoC

Test: manual with HA
Bug: 69623109
Change-Id: I1c6f240eaf08d876bb285f3ffa737365f392925e

6 years agoHFP: Fix NPE in error logging for voice recognition events
Jack He [Sat, 27 Jan 2018 01:39:23 +0000 (17:39 -0800)]
HFP: Fix NPE in error logging for voice recognition events

Bug: 72506800
Test: make and test with VREC events
Change-Id: I126b75d9e991b312e795ed38672b0153ca03dcea

6 years agoDisable host compilation on Darwin for net_test_btif_state_machine
Pavlin Radoslavov [Thu, 25 Jan 2018 13:15:38 +0000 (05:15 -0800)]
Disable host compilation on Darwin for net_test_btif_state_machine

The net_test_btif_state_machine unit test depends on libosi,
and that library itself is disabled for Darwin.

Test: Code compilation on Linux
Change-Id: I143015370988657e2903f86175244308c01d5162
(cherry picked from commit 8fb98a5350f8b5893b9fc160fa030fd7dbae06a9)

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()"
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 a workaround for A2DP devices that request Role Change
Pavlin Radoslavov [Tue, 16 Jan 2018 18:48:13 +0000 (10:48 -0800)]
Add a workaround for A2DP devices that request Role Change

Certain A2DP devices request Role Change after connection,
and typically the Phone grants it - as a result the Phone is the Slave.

However, with Multi-A2DP, follow-up A2DP connections require that the
Phone becomes the Master: within the existing stack we have function
bta_av_switch_if_needed() that checks whether the Phone needs to request
Role Change and become again the Master.
Some A2DP devices will refuse the Phone to become the Master again, and
this prevents/blocks the Phone from having multiple A2DP connections
that are open.

Test: Manual
Bug: 72122792
Bug: 70350399
Change-Id: I749c73a38e3fb10262143ba6b41a7d65309ddf49
(cherry picked from commit 0f82fe7b83dc765d245a8996ed758359643d5b0b)

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
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"
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
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
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)
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
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"
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
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
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
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
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 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
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
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.
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
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"
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