OSDN Git Service
Treehugger Robot [Thu, 1 Feb 2018 21:19:47 +0000 (21:19 +0000)]
Merge "Minimize amount of Flow Control packets for L2CAP CoC"
Treehugger Robot [Thu, 1 Feb 2018 20:02:05 +0000 (20:02 +0000)]
Merge "PDU 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
Treehugger Robot [Wed, 31 Jan 2018 22:49:28 +0000 (22:49 +0000)]
Merge "Set pending_discovery when doing GATT over BR/EDR"
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
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
Treehugger Robot [Wed, 31 Jan 2018 20:01:39 +0000 (20:01 +0000)]
Merge "BUILD: 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
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
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
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
Treehugger Robot [Tue, 30 Jan 2018 15:37:46 +0000 (15:37 +0000)]
Merge "Drops unittest build on Mac host."
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
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
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
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"
Treehugger Robot [Sat, 27 Jan 2018 03:44:34 +0000 (03:44 +0000)]
Merge "HFP: Fix NPE in error logging for voice recognition events"
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
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
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)
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)
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)
Treehugger Robot [Fri, 26 Jan 2018 21:26:24 +0000 (21:26 +0000)]
Merge "btif: 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
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
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
Jakub Pawlowski [Thu, 25 Jan 2018 22:37:16 +0000 (22:37 +0000)]
Merge "Fixed 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
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
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
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
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
Treehugger Robot [Tue, 23 Jan 2018 19:00:57 +0000 (19:00 +0000)]
Merge "Allow L2CAP first packet with partial header"
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
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
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
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
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
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
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
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
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
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
Treehugger Robot [Fri, 19 Jan 2018 21:41:24 +0000 (21:41 +0000)]
Merge "a2dp_source: Use SIZE_MAX queue size for worker_thread"
Treehugger Robot [Fri, 19 Jan 2018 20:27:47 +0000 (20:27 +0000)]
Merge "SDP: Increase heap buffer size used for A2DP/AVRC"
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"
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
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
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
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
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
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
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
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
Treehugger Robot [Thu, 18 Jan 2018 01:49:54 +0000 (01:49 +0000)]
Merge "Make BTA_JvL2capWrite take ownership of the data buffer"
Treehugger Robot [Thu, 18 Jan 2018 00:46:57 +0000 (00:46 +0000)]
Merge "Added internal API getMaxConnectedAudioDevices()"
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
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
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
Treehugger Robot [Wed, 17 Jan 2018 01:33:46 +0000 (01:33 +0000)]
Merge "Revert "Fix buffer overflow in GAP_ConnWriteData""
Hansong Zhang [Tue, 16 Jan 2018 23:57:27 +0000 (23:57 +0000)]
Revert "Fix buffer overflow in GAP_ConnWriteData"
This reverts commit
9f9c47683e28a0cf99b308deeac04073a9528c59.
Reason for revert: Bluetooth OPP crashing.
Bug:
72049058
Change-Id: Ic9ee9f28ce480453a9e01d3273595bff2264cd2b
Treehugger Robot [Thu, 11 Jan 2018 23:28:37 +0000 (23:28 +0000)]
Merge "Refactor l2c_lcc_get_next_xmit_sdu_seg"
Treehugger Robot [Thu, 11 Jan 2018 23:21:44 +0000 (23:21 +0000)]
Merge "L2CAP: Add parameter to indicate last piece of an SDU"
Jakub Pawlowski [Wed, 10 Jan 2018 11:11:33 +0000 (03:11 -0800)]
Refactor l2c_lcc_get_next_xmit_sdu_seg
* use "PDU" instead of "segment" in variable names
* simplify computation of first_pdu, last_pdu, no_of_bytes_to_send
* remove unnecessary null checks
Test: manual
Bug:
68359837
Change-Id: Iecf511df2a51c2c103ecb3b524c6ed17910a7062
Jakub Pawlowski [Wed, 10 Jan 2018 10:54:47 +0000 (02:54 -0800)]
L2CAP: Add parameter to indicate last piece of an SDU
This information will be used in future patches to notify packet
completition to upper layers.
Test: manual
Bug:
68359837
Change-Id: Ie4aa937b4da5aa83fa552a8603195a6933d64cc6
Hemant Gupta [Thu, 11 Jan 2018 09:52:49 +0000 (15:22 +0530)]
HID: Update condition for checking LE HID handle validity
1) Pair and connect with BR/EDR HID devices and LE devices
such that the total number of connected paired devices
becomes 7. It is not required that connection to all devices be
maintained, they can be disconnected as well afterwards.
2) Pair and connect with a new LE device. Connection fails
3) Retry connecting to same LE device. Connection does not go through
4) Turn BT off
Observed Result:
1) LE device cannot be connected in step 2
2) Tombstone in BT while switching off BT with below signature
backtrace:
#00 pc
0000000000092438 /system/lib64/libc.so (ifree+88)
#01 pc
000000000009298c /system/lib64/libc.so (je_free+120)
#02 pc
00000000001b266c /system/lib64/hw/bluetooth.default.so (_Z18osi_free_and_resetPPv+84)
#03 pc
0000000000062f84 /system/lib64/hw/bluetooth.default.so
(_Z17bta_hh_sm_executeP14tBTA_HH_DEV_CBtP12tBTA_HH_DATA+880)
#04 pc
0000000000063120 /system/lib64/hw/bluetooth.default.so (_Z16bta_hh_hdl_eventP6BT_HDR+296)
#05 pc
000000000007bbc4 /system/lib64/hw/bluetooth.default.so (_Z13bta_sys_eventP6BT_HDR+60)
#06 pc
00000000001b4d88 /system/lib64/hw/bluetooth.default.so (_ZL22internal_dequeue_readyPv+80)
#07 pc
00000000001b96f4 /system/lib64/hw/bluetooth.default.so (_ZL11run_reactorP9reactor_ti+312)
#08 pc
00000000001b9590 /system/lib64/hw/bluetooth.default.so (_Z13reactor_startP9reactor_t+80)
#09 pc
00000000001baf24 /system/lib64/hw/bluetooth.default.so (_ZL10run_threadPv+256)
#10 pc
0000000000067bc4 /system/lib64/libc.so (_ZL15__pthread_startPv+36)
#11 pc
000000000001f264 /system/lib64/libc.so (__start_thread+68)
Root Cause:
Wrong conditional check in macro BTA_HH_IS_LE_DEV_HDL_VALID which ignores the condition that max
14 HID devices can be connected and all of them can be LE as well.
Fix:
Update the condition in macro BTA_HH_IS_LE_DEV_HDL_VALID to compare with BTA_HH_MAX_DEVICE instead of
BTA_HH_LE_MAX_KNOWN
Test: Not yet performed, only code and log analysis
Fixes:
71842479
Change-Id: I2b56b6f109787608e25c340150be313f0f5397be
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
Change-Id: I01c60d6f08529be051e921789c41f7065f45534f
Jakub Pawlowski [Mon, 8 Jan 2018 09:23:52 +0000 (01:23 -0800)]
Remove duplicated code in l2cap_sock - on_l2cap_write_fixed_done
Test: none
Bug:
68359837
Change-Id: Ic3ebe0b7eebbd0122e7f7751ab3b48d6acf62da6
Treehugger Robot [Wed, 10 Jan 2018 13:04:58 +0000 (13:04 +0000)]
Merge "Move repeated code from l2cu_check_channel_congestion into a separate function"
Treehugger Robot [Wed, 10 Jan 2018 10:48:27 +0000 (10:48 +0000)]
Merge "Make AdvertiseManager shutdown gracefully"
Treehugger Robot [Wed, 10 Jan 2018 03:47:04 +0000 (03:47 +0000)]
Merge "HFP: Print human readable event and state name by default"
Treehugger Robot [Wed, 10 Jan 2018 03:46:48 +0000 (03:46 +0000)]
Merge "HFP: Remove used BTA call-in events and methods"
Treehugger Robot [Wed, 10 Jan 2018 02:40:49 +0000 (02:40 +0000)]
Merge "Fix SIGSEGV during Hands-free client SDP"
Jack He [Sun, 7 Jan 2018 01:00:37 +0000 (17:00 -0800)]
HFP: Print human readable event and state name by default
* Debug log in HFP's BTA code is gated by BTA_AG_SCO_DEBUG and
BTA_AG_DEBUG flags. These are non-standard flags that must be
configured at compile time. Instead, debug logs should be gated by
flags in bt_stack.conf only
* This change enables human readable debug output by default by removing
these flags, and refactor the string conversion functions
Bug:
70538124
Test: runtest bluetooth, native unit tests
Change-Id: I99fd00016020a9c6b14928906f07bca4f0ea482d
Jack He [Wed, 10 Jan 2018 00:25:46 +0000 (16:25 -0800)]
HFP: Remove used BTA call-in events and methods
* Since SCO over HCI is temporarily unsupported on the stack, SCO data
call-in methods are no longer used by the stack and thus should be
removed. For example, bta_ag_ci_sco_data() and BTA_AG_CI_SCO_DATA_EVT.
* Since raw RFCOMM access is disabled, various RFCOMM data call-in
methods are no longer used by the stack and thus should be removed.
For example, bta_ag_ci_rx_data() and BTA_AG_CI_RX_WRITE_EVT
Bug:
70538124
Test: runtest bluetooth, native unit test
Change-Id: Iacd60042e97b1be5f800319723836285eb68b2b9
Jack He [Sat, 6 Jan 2018 23:53:29 +0000 (15:53 -0800)]
HFP: Remove AG RFCOMM data pass through mode
* In BTA_AG_PASS_THROUGH mode defined in bta_ag_api.h, RFCOMM data is
passed directly to the upper layer. In this case, AT commands are
parsed in the user application instead of being parsed within the fluoride
stack.
* However, this mode is never used on the stack as btif_hf.cc only call
BTA_AgEnable() with BTA_AG_PARSE parameter value. Currently, AT
commands are only parsed within the fluoride stack
* This change removes this feature since the pass through mode is
never used, tested, nor maintained
Bug:
70538124
Test: runtest bluetooth, native unit tests, no functional change
Change-Id: I921d5ee950e4abadea8433c5b2d5882a99923cb0
Jack He [Sat, 6 Jan 2018 23:31:42 +0000 (15:31 -0800)]
HFP: Remove redundant AG data callout code
* Methods in bta_ag_co.cc are almost empty and should be removed
* Only bta_ag_co_init() calls BTM_WriteVoiceSettings(). This can be
called directly from BTA. The callout wrapper is unnecessary
Bug:
70538124
Test: runtest bluetooth, native unit tests, no functional change
Change-Id: I20ab1c033d18f3405e7efb8446b44153b24f3cb0
Jack He [Sat, 6 Jan 2018 01:18:29 +0000 (17:18 -0800)]
HFP: Add isInbandRingingEnabled() API (3/4)
* Use BluetoothHeadset.isInbandRingingEnabled() API to check whether
in-band ringing is currently enabled in the system when deciding on
audio routes for ringtone
* Use this value obtained in Java layer to initialize native HFP/HSP
stack instead of checking it in native layer
Bug:
71646213
Test: make, toggle in-band ringing from Development Settings and observe
whether Telecom service tries to open SCO when there is an
incoming call
Change-Id: I917537b6d17681151639ff29a56ac9c0c7e0e7e8
Lianchao Song [Fri, 22 Dec 2017 08:55:47 +0000 (16:55 +0800)]
Fix SIGSEGV during Hands-free client SDP
Fixes:
70367002
Change-Id: I2fd7a00551157a000b87c7bbdbc8a2c93cff21c4
Jakub Pawlowski [Tue, 9 Jan 2018 11:45:09 +0000 (03:45 -0800)]
Move repeated code from l2cu_check_channel_congestion into a separate function
Test: compilation
Bug:
68359837
Change-Id: I69edf0d549633a2d9d0c73eae4efbaf47d302ab4
Pavlin Radoslavov [Tue, 9 Jan 2018 13:58:53 +0000 (05:58 -0800)]
Run by default the 64-bit unit tests on 64-bit devices
Bug:
71739588
Test: cd system/bt; mm -j 40; test/run_unit_tests.sh
Change-Id: Ie4206a8935456a0b62b7a4b90c7247f398a6a7ef
Pavlin Radoslavov [Tue, 9 Jan 2018 13:36:20 +0000 (05:36 -0800)]
Disable CFI verification for unit tests that are using gtest+gmock
Apparently, the CFI verification crashes unit tests that
are using gtest+gmock. Interestingly, those tests succeed for 32-bit
binaries, and fail for 64-bit binaries.
Bug:
71739588
Test: Running the 64-bit version of the unit tests in test/run_unit_tests.sh
Change-Id: Id1f6b3667b3f9eabb0719e65aea18c6950de63a8
Jakub Pawlowski [Thu, 22 Jun 2017 16:46:18 +0000 (09:46 -0700)]
Make AdvertiseManager shutdown gracefully
If the Bluetooth stack is shutdown while AdvertiseManager has a pending HCI
operation being executed, the callback to that operation might be
executed after the manager was deleted. In order to fix any potential
issues, always use a weak pointer to the advertisement manager. This will
prevent the callbacks from getting executed.
In case of callbacks that are not executed on the AdvertiseManager
instance, one can check if the weak pointer is still valid, and properly
handle the stack shutdown.
Test: BleAdvertisingManagerTest:test_cleanup_during_execution
Change-Id: I8d33de4f64267a880880082c5498375c083addef
Jakub Pawlowski [Fri, 5 Jan 2018 10:41:36 +0000 (02:41 -0800)]
Prevent LE CoC from dropping data when remote MPS>8087
When using LE Coc through Java socket, one can read MPS from
getMaxTransmitPacketSize(). If this value is bigger than
local device L2CAP_MAX_SDU_LENGTH, data sent to remote will be
truncated. This patch fixes that by using properly big buffer for
receiving data from socket on native side.
Test: connect with device with MPS bigger than MPS, alternatively set
L2CAP_MAX_SDU_LENGTH to i.e. 30 on device during test and try to write
"remote MPS" of bytes to remote device.
Bug:
68359837
Change-Id: I02bef80f0dd0f0d6850704ac7787c5f3f5b9b3ab
Jack He [Thu, 7 Dec 2017 02:35:11 +0000 (18:35 -0800)]
HFP: Add APIs for set and get active device (3/3)
* Add set active device APIs to set active device from Java layer
* Set active device to the first connected device if no one set it
before
* Clear active device on RFCOMM disconnection if active device is the
one getting disconnected
* Currently, the active device value is not used in any functional code
Bug:
68951996
Test: runtest -j40 bluetooth
Change-Id: Id0c00e89178b0f963ed8642e72c7010160dd1d68
Pavlin Radoslavov [Tue, 19 Dec 2017 21:26:22 +0000 (13:26 -0800)]
Added internal API to get/set the A2DP Active Device
1. Call BluetoothA2dp.setActiveDevice(BluetoothDevice device) to set
a connected A2DP device as active.
2. Listen for BluetoothA2dp.ACTION_ACTIVE_DEVICE_CHANGED intent
that will contain the latest active device (in EXTRA_DEVICE field).
If the active device could not be changed, the EXTRA_DEVICE
field could be null.
3. If setActiveDevice() is NOT in-progress, BluetoothA2dp.getActiveDevice()
can be used. If setActiveDevice() is in-progress, the result is undefined.
4. BluetoothA2dp.setActiveDevice() could be called by some other parts of
the system, so interested parties should always listen for
BluetoothA2dp.ACTION_ACTIVE_DEVICE_CHANGED intents and prepared
for active device updates.
Bug:
71555243
Test: Manual
Change-Id: Ia25465e17a4539e940d09523cb621b230abd31e3
Jack He [Thu, 7 Dec 2017 23:15:56 +0000 (15:15 -0800)]
HFP: Use disableinbandringing instead of enableinbandringing
* Use disableinbandringing system property as in-band ringing is enabled
by default so an active user choice would disable it instead of
enabling it
Bug:
65383086
Test: make, try toggling the preference and verify in-band ringing
behavior
Change-Id: I9b10743960c933b223481d2efb68af538689c507
Merged-In: I9b10743960c933b223481d2efb68af538689c507
(cherry picked from commit
71de85091506eeeaab6e73cccf0ebd5bb06f2af1)
Jakub Pawlowski [Fri, 5 Jan 2018 09:36:44 +0000 (09:36 +0000)]
Revert "Use vector instead of raw pointer in l2cap socket write handling"
This reverts commit
4da2ff53e694c5bee2973c55bb14eb40f74a9d3d.
Change-Id: Id8a399ec6f7474b92579c4647899e424feeb0d33
Jakub Pawlowski [Tue, 31 Oct 2017 06:15:43 +0000 (23:15 -0700)]
Use vector instead of raw pointer in l2cap socket write handling
Currently, when we receive data from upper layers for LE CoC socket,
we store it in memory and pass a raw pointer around, keeping memory
until the write is acknowledged by controller and event is sent back to
btif layer in on_l2cap_write*_done. If anything goes wrong, we might
loose the pointer to the data and have a memory leak.
From now on, we store the data in std::vector and pass its ownership
down the stack. The moment the data is copied into lower layer buffer,
vector is automatically freed. We no longer pass the data back to
on_l2cap_write*_done callback.
Bug:
68359837
Test: compilation test
Change-Id: If34c0fba8d4a040a242b8c655491b8967a03b96a
Yasuyoshi Terui [Fri, 14 Feb 2014 06:07:35 +0000 (15:07 +0900)]
Add to receive BTHF_CALL_STATE_DISCONNECTED at HFP
When the call is disconnected, the BTHF state is changed to IDLE and
SCO connection is disconnected before playing disconnect tone. So the
disconnect tone can't be sound from BTHS.
Add DISCONNECTED state for HFP and keep the state until disconnect tone
sounds from BT.
Test: manual - Checked whether the disconnect tone is sound from the BTHS
Bug:
69645337
Change-Id: Id96385e4ce35cfe7d0d4e14b74a2fc1a63165f82
Jack He [Thu, 14 Dec 2017 23:00:39 +0000 (15:00 -0800)]
HFP: Use objects for shared library interface and callbacks (1/2)
* Declare bluetooth::headset::Interface and
bluetooth::headset::Callbacks instead of using structs
* Put HFP related methods and types into bluetooth::headset namespace
* Rename those methods into CamelStyle according to Google C++ style
guide
* Remove the usage of HAL_CBACK in HFP as we only need to check if the
callback object is null and all its methods must be implemented as
mandated by rules of the pure virtual function
* These classes can be mocked during test to isolate behaviors
* Improved effort handling in btif_hf.cc to log error messages during
failures
Bug:
70538124
Test: unit tests, testplans/135585
Change-Id: Iba120ef9d0a9701aececd300395b7b18d2d44e7d
Pavlin Radoslavov [Sun, 26 Nov 2017 04:51:36 +0000 (20:51 -0800)]
Added RawAddress::FromOctets method to copy address from uint8_t pointer
Also, added missing unit test for existing constructor
Test: Unit test added
Change-Id: Id642aaf2651c59b87af344c78aafc87aba2898d1
Jakub Pawlowski [Tue, 3 Oct 2017 19:31:48 +0000 (12:31 -0700)]
Advertising Filtering: send all filters in one batch (2/2)
Bug:
67371480
Test: sl4a FilteringTest
Change-Id: I93595b5ed4e7cf25cdb6a8b1f9413a7f05e61774
Treehugger Robot [Wed, 3 Jan 2018 18:35:35 +0000 (18:35 +0000)]
Merge "Temporarily remove broken SCO-over-HCI implementation"
Jakub Pawlowski [Wed, 3 Jan 2018 09:49:41 +0000 (01:49 -0800)]
Remove bytes after first zero length field in legacy advertisements
This is for compatibility with many existing old devices, that have
non-zero bytes after zero length field. This is currently causing
advertisements to be dropped, rendering those devices invisible.
Bug:
68907583
Test: AdvertiseDataParserTest.RemoveTrailingZerosMalformed
Change-Id: Ib51950f7e0c6a2771f56c6f69108fa10f2517f38
Hansong Zhang [Tue, 2 Jan 2018 21:48:42 +0000 (13:48 -0800)]
Temporarily remove broken SCO-over-HCI implementation
This is currently not used on known Android platforms and currently does
not compile. To be re-visited when SCO-over-HCI can be re-implemented
based on the new HAL.
Test: make
Bug:
70965527
Change-Id: Iefff5b3fb1599a0cdb2c7fb90b463f3643a2a47e
Jakub Pawlowski [Thu, 7 Dec 2017 09:21:48 +0000 (01:21 -0800)]
Minor style fixes in l2c_main.cc
Bug:
69623109
Test: compilation
Change-Id: Ie5d744bced1e392d9cfa57ae6c9b4a4664c021c8
Treehugger Robot [Thu, 21 Dec 2017 21:56:11 +0000 (21:56 +0000)]
Merge "BluetoothHidDevice: rename onIntrData to onInterruptData (2/5)"
Jakub Pawlowski [Tue, 19 Dec 2017 21:22:27 +0000 (13:22 -0800)]
Increase MPS for LE CoC to one LE Buffer Size
This should improve throughtput, and reduce number of LE-U PDUs needed
to send message over LE channel.
Test: compilation
Change-Id: Ic1e203eaec0b8012984f27d3c488ea6eb0945399
Treehugger Robot [Thu, 21 Dec 2017 15:11:56 +0000 (15:11 +0000)]
Merge "Increase default SDP_MTU_SIZE to 1024"