OSDN Git Service

android-x86/system-bt.git
6 years agoHOGP: Update status to OK, if link is already encrypted
Nitin Shivpure [Thu, 22 Mar 2018 10:46:32 +0000 (16:16 +0530)]
HOGP: Update status to OK, if link is already encrypted

Usecase:
1) Connect to HOGP device. (Because of some condition encryption fails with Connection
   Timeout, remote device turned off when connection was initiated)
2) Try to connect again to HoGP device

Expected Result:
Connection should be successful

Observed Result:
UI stuck in connecting state and connection never succeeds.

Root cause:
When encryption fails in previous iteration, encryption happens before HoGP Server starts
security procedure, leading to Encryption Complete event being received with wrong status.

Fix:
Update the status to success when sending encryption complete event if link is already
encrypted

Test: Issue is not seen after above steps

Fixes: 76133015
Change-Id: Ib404cf157289170ea300eae40f51393606c35105

6 years agobta_gattc_sdp_callback move null check above first usage
Jakub Pawlowski [Fri, 23 Mar 2018 19:34:37 +0000 (12:34 -0700)]
bta_gattc_sdp_callback move null check above first usage

Bug: 75311714
Test: Test scenario described in bug
Change-Id: Ib2da24134205277ae03cf28394db74758de17e5d

6 years agoLE Advertising Report parsing enhancements
Jakub Pawlowski [Thu, 22 Mar 2018 00:13:36 +0000 (17:13 -0700)]
LE Advertising Report parsing enhancements

Reject invalid data length for advertisement data.
Also, don't attempt to resolve anonymous advertising addresses.

Test: LE scanning tests
Bug: 73193883
Change-Id: I1cb330bc30fdcaebc86527cd2656c9dd7932b318

6 years agoRemove deinit_pending flag that is not needed/used
Pavlin Radoslavov [Fri, 23 Mar 2018 09:01:03 +0000 (02:01 -0700)]
Remove deinit_pending flag that is not needed/used

Test: Code compilation
Bug: 74952724
Change-Id: I022e16940c73181f991d528b9c96e2d26151369f

6 years agoAdd btm_free() to clean up btm properly
Fukai Wang [Wed, 26 Jul 2017 01:35:21 +0000 (09:35 +0800)]
Add btm_free() to clean up btm properly

Test: Run AdapterRepeatedEnableDisable in system/bt/test with
kTestRepeatCount set to 1000.

Merged-In: I3445a725d66e73e8bcffc7bfabe594f49a6fc863
Change-Id: I3445a725d66e73e8bcffc7bfabe594f49a6fc863

6 years agoGracefully recover on bad attempt to cancel LE connection
Jakub Pawlowski [Thu, 22 Mar 2018 01:46:14 +0000 (18:46 -0700)]
Gracefully recover on bad attempt to cancel LE connection

According to logs some devices are stuck when in BLE_CONN_CANCEL state.
That is they sent "LE Create Connection Cancel" request, and are
awaiting "LE Connection Complete" event with invalid handle forever.
But they wait and wait, and the event never arrive. That's because
"LE Create Connection Cancel" was sent, when connection attempt is not
pending. In such case, we should act upon command complete status, and
decide to leave BLE_CONN_CANCEL state.

To properly fix this issue, one would have to implement a proper queue
for managing LE connection attempt state, preferably for scratch. This
fix just give option of graceful recovery.

Test: sl4a GattConnectTest
Bug: 75290221
Change-Id: I7e7a377c789ac0a587390320fbf504267cca8727

6 years agoAdd Start/End Session for A2DP offload audio interface
Pavlin Radoslavov [Thu, 22 Mar 2018 09:55:58 +0000 (02:55 -0700)]
Add Start/End Session for A2DP offload audio interface

* Added explicit btif_a2dp_audio_interface_start_session() and
  btif_a2dp_audio_interface_end_session() and call them as appropriate.
* Removed unnecessary btif_a2dp_audio_interface_deinit() calls.

Bug: 74952724
Test: Manual: audio streaming without A2DP offload
Change-Id: I74b8c340ee258b09b9e1acbcb1cc75906ddc03fc

6 years agoAdded Start/End Session steps when A2DP codec is changed
Pavlin Radoslavov [Thu, 22 Mar 2018 09:09:18 +0000 (02:09 -0700)]
Added Start/End Session steps when A2DP codec is changed

If the A2DP codec is changed for the active device, then
the current session is restarted by calling End/Start Session.

Also:
 * Updated btav_a2dp_codec_config_t string representation to
   include the codec priority.
 * Fixed A2dpCodecConfig::setCodecPriority() and setDefaultCodecPriority()
   so the codec priority for the current codec_config_ is updated.
 * Fixed A2dpCodecs::setCodecUserConfig() so the restart_input flag
   is set as appropriate.
 * Use btav_a2dp_codec_config_t::ToString() as appropritate to print
   the codec config instead of explicitly printing each field.

Bug: 74988739
Test: Manual: Connect two headsets, change codecs, switch active device.
Change-Id: I6652168f3c48e5b431e00aa8f554929afbdcdbcf

6 years agoMerge "Write volume to Hearing Aid during connection setup"
Treehugger Robot [Thu, 22 Mar 2018 00:17:01 +0000 (00:17 +0000)]
Merge "Write volume to Hearing Aid during connection setup"

6 years agoMerge "Hearing Aid: Add API for active device"
Treehugger Robot [Wed, 21 Mar 2018 23:53:52 +0000 (23:53 +0000)]
Merge "Hearing Aid: Add API for active device"

6 years agoWrite volume to Hearing Aid during connection setup
Jakub Pawlowski [Tue, 20 Mar 2018 23:00:58 +0000 (16:00 -0700)]
Write volume to Hearing Aid during connection setup

Bug: 69623109
Test: connect both hearing aid, change volume, reconnect, verify volume
level
Change-Id: Ia728ee25993f1bd7ecaae2aa0c1cb78926583a9b

6 years agoAdded Start/End Session steps to A2DP session setup
Pavlin Radoslavov [Tue, 20 Mar 2018 23:50:57 +0000 (16:50 -0700)]
Added Start/End Session steps to A2DP session setup

Start/End session is called when setting/changing the Active (remote)
device.

Also:
 * For A2DP Source, btif_a2dp_source_setup_codec() is called only for
   Start session. All other calls to btif_a2dp_source_setup_codec are
   removed.
 * Updated the btif_a2dp_source_setup_codec() implementation to
   call btif_a2dp_source_audio_tx_flush_req() and flush the incoming audio
   data. This removes 2 seconds hold-up delay when switching the active
   device and streaming audio.
 * Removed unnecessary lock inside btif/src/btif_a2dp_sink.cc

Bug: 74952724
Test: Manual - Connect two headsets, switch active device,
      connect/disconnect.
Change-Id: I43702e1ddc108628de93161905465647471f554c

6 years agoMerge "Add a property to enable the New AVRCP Profile (1/2)"
Treehugger Robot [Wed, 21 Mar 2018 00:39:04 +0000 (00:39 +0000)]
Merge "Add a property to enable the New AVRCP Profile (1/2)"

6 years agoHearing Aid: Add API for active device
Hansong Zhang [Fri, 16 Mar 2018 02:52:46 +0000 (19:52 -0700)]
Hearing Aid: Add API for active device

Add setActiveDevice() and isActiveDevice() as it will be used in
Settings

Bug: 69623109
Test: compilation and instrumentation
Change-Id: Ifc92bab2306ed78cb6d203c5e1b0a5887730d24f

6 years agoSet the default AVRCP Version to 1.5
Ajay Panicker [Tue, 20 Mar 2018 21:27:51 +0000 (14:27 -0700)]
Set the default AVRCP Version to 1.5

Bug: 76027180
Test: Compile and connect to remote device and see in SDP that the
      version reported is 1.5

Change-Id: I9ec88ca2127c3be055d7f64ccb8b3848cfed3fdf

6 years agoAdd a property to enable the New AVRCP Profile (1/2)
Ajay Panicker [Sat, 17 Mar 2018 00:13:50 +0000 (17:13 -0700)]
Add a property to enable the New AVRCP Profile (1/2)

You can now use the new AVRCP Profile by setting
persist.bluetooth.enablenewavrcp to true.

Also fix a misundestanding with connection_handler.cc. AVRCP Control
callbacks return a null address when disconnecting.

Bug: 68854188
Test: Check to see that the profile is used when property is true and is
      not used when property is false.

Change-Id: I4aa285c6bf009716cc80a80b813ba0acd3d8f9d8

6 years agoMerge "Don't skip SDP discovery prior to AVDTP connection"
Treehugger Robot [Mon, 19 Mar 2018 16:14:47 +0000 (16:14 +0000)]
Merge "Don't skip SDP discovery prior to AVDTP connection"

6 years agoAdd missing codec initialization for A2DP Sink
Pavlin Radoslavov [Fri, 16 Mar 2018 18:56:37 +0000 (11:56 -0700)]
Add missing codec initialization for A2DP Sink

Also:
 * Added missing assert to check when local codecs are not initialized
 * Removed unnecessary local copy: BtifAvSource::codec_priorities_

Bug: 74079615
Test: Manual: Enable A2DP Sink profile and initiate the connection from
      Remote A2DP Source
Change-Id: I40ea1aa2164612bbe108ac06be7f6cae8be30a72

6 years agoDon't skip SDP discovery prior to AVDTP connection
Pavlin Radoslavov [Sat, 17 Mar 2018 00:01:36 +0000 (17:01 -0700)]
Don't skip SDP discovery prior to AVDTP connection

This fixes an issue where the default AVDT_VERSION could be incorrectly
assigned to a remote device.

Bug: 74002223
Test: Manual: connect to Kinivo BTC450; power off/on the device to reconnect
Change-Id: I53817e942638d6e962aa5b8b87b7b31998270857

6 years agoFix sdk_mac builds for AVRCP Headers
Ajay Panicker [Fri, 16 Mar 2018 18:36:26 +0000 (11:36 -0700)]
Fix sdk_mac builds for AVRCP Headers

Disable sdk_mac for avrcp_headers since libchrome isn't compiled for sdk
mac.

Test: Compile
Change-Id: Ia5b67450e1beb82a78958eca25e6579496bf1ef6

6 years agoMerge "Utilize setting for AVRCP Target"
Joseph Pirozzo [Fri, 16 Mar 2018 18:56:51 +0000 (18:56 +0000)]
Merge "Utilize setting for AVRCP Target"

6 years agoMerge "Implement the JNI layer for the AVRCP Service (2/3)"
Treehugger Robot [Fri, 16 Mar 2018 08:30:19 +0000 (08:30 +0000)]
Merge "Implement the JNI layer for the AVRCP Service (2/3)"

6 years agoUtilize setting for AVRCP Target
Joseph Pirozzo [Wed, 14 Mar 2018 23:41:49 +0000 (16:41 -0700)]
Utilize setting for AVRCP Target

There is a setting that controls which AVRCP Target
version is enabled, use the same setting for both
source and sink devices.

Bug: 62397951
Test: Observe SDP record on sink device.
Change-Id: I65b307d011048ec88b3af8c542ce70601294cca8

6 years agoImplement the JNI layer for the AVRCP Service (2/3)
Ajay Panicker [Thu, 15 Mar 2018 06:45:54 +0000 (23:45 -0700)]
Implement the JNI layer for the AVRCP Service (2/3)

Allows the AVRCP Service Interface to be retrieved via bt_interface_t.

Bug: 68854188
Test: Compile
Change-Id: I0d9464ea19d3bd382d07134bff057a5515501b95

6 years agoRemove unnecessary CHECK in BleAdvertisingManager::Get()
Jakub Pawlowski [Thu, 15 Mar 2018 20:09:33 +0000 (13:09 -0700)]
Remove unnecessary CHECK in BleAdvertisingManager::Get()

It is causing race conditions. Weak pointer is already taking care of
making sure the instance is valid, even if it was not yet initialized.

Bug: 74863151
Test: compilation
Change-Id: Iddb69f8a38d80044d1bdd7699fad020f710914be

6 years agoMerge "Hearing Aid Manager implementation"
Treehugger Robot [Thu, 15 Mar 2018 04:41:57 +0000 (04:41 +0000)]
Merge "Hearing Aid Manager implementation"

6 years agoMerge "SMP: Update device type as BLE while deriving LTK from LK"
Treehugger Robot [Thu, 15 Mar 2018 02:43:40 +0000 (02:43 +0000)]
Merge "SMP: Update device type as BLE while deriving LTK from LK"

6 years agoHearing Aid Manager implementation
Jakub Pawlowski [Fri, 24 Nov 2017 23:20:37 +0000 (15:20 -0800)]
Hearing Aid Manager implementation

Test: connect to Hearing Aid, play some music, make phone call
Bug: 69623109
Change-Id: I924ce288f1aa28c0d59edffa7a00f90271a808ab

6 years agoSMP: Update device type as BLE while deriving LTK from LK
Nitin Shivpure [Tue, 13 Mar 2018 06:31:48 +0000 (12:01 +0530)]
SMP: Update device type as BLE while deriving LTK from LK

Usecase:
1) Install the same system version and CtsVerifier.apk on 2 DUT's
2) Pair both DUT's using BT Settings Menu.
3) On DUT execute  Bluetooth Test -> Bluetooth LE Secure Server Test ->
   Bluetooth LE Sever Test.
4) On remote device execute Bluetooth Test-> Bluetooth LE Secure Client
   Test -> Bluetooth LE Client Test

Expected Result:
All test cases can be passed.

Observed Result:
All test cases cannot be passed.

Root Cause:
DUT supports secure connection & LE privacy and during BR/EDR pairing LTK is
derived from LK, but device type is not updated and is still BR/EDR instead of LE.
Later when Gatt server starts advertisement with random address so while creating
LE connection from gatt client to gatt server, gatt client is not able to resolve
random address due to incorrect device type, It re-initiate LE paring with
gatt server.

Fix:
Updating device type as BLE while deriving LTK from LK.

Test: CTS test case can pass with above steps.

Fixes: 74728232
Change-Id: I1f2c5b54d17a58615f7c2ceb954e54619b165489

6 years agoEliminate error on quallcom debug logs from controller
Jakub Pawlowski [Wed, 14 Mar 2018 18:41:08 +0000 (11:41 -0700)]
Eliminate error on quallcom debug logs from controller

Change-Id: If975a5d76d42e6142534e87fd63b30f9ce8894d8

6 years agoSuppress AVDTP delay reporting logs per data packet
Pavlin Radoslavov [Wed, 14 Mar 2018 07:54:08 +0000 (00:54 -0700)]
Suppress AVDTP delay reporting logs per data packet

If AVDTP delay reporting is enabled, then several log messages
will be printed by default practically for each audio data packet.
Change the log level for those messages to DEBUG.

Also:
 * Add missing event decoding for A2DP_CTRL_GET_PRESENTATION_POSITION
 * Remove "default" switch statement inside audio_a2dp_hw_dump_ctrl_event()
   to catch missing "case" statements if a new tA2DP_CTRL_CMD event is
   added in the future.

Bug: 32755225
Test: Manual - A2DP streaming, check the logcat output
Change-Id: I3d1b1c2f6532c72af0e1e7aa5566572e13ed1684

6 years agoMerge "Fix strlcpy length passing in bta hl"
Treehugger Robot [Wed, 14 Mar 2018 01:27:36 +0000 (01:27 +0000)]
Merge "Fix strlcpy length passing in bta hl"

6 years agoMerge "btlinux: wait forever for a BT device"
Treehugger Robot [Wed, 14 Mar 2018 01:23:35 +0000 (01:23 +0000)]
Merge "btlinux: wait forever for a BT device"

6 years agoMerge "Update app use for link of BR/EDR over GATT"
Treehugger Robot [Wed, 14 Mar 2018 01:21:11 +0000 (01:21 +0000)]
Merge "Update app use for link of BR/EDR over GATT"

6 years agoMerge "Empty list check to stop Bluetooth stack crash in btif_rc"
Treehugger Robot [Wed, 14 Mar 2018 01:18:17 +0000 (01:18 +0000)]
Merge "Empty list check to stop Bluetooth stack crash in btif_rc"

6 years agoMerge "Fix gatt_is_bda_in_the_srv_chg_clt_list always return NULL"
Treehugger Robot [Wed, 14 Mar 2018 01:08:49 +0000 (01:08 +0000)]
Merge "Fix gatt_is_bda_in_the_srv_chg_clt_list always return NULL"

6 years agoEmpty list check to stop Bluetooth stack crash in btif_rc
Pulkit Bhuwalka [Sat, 20 Jan 2018 01:37:45 +0000 (17:37 -0800)]
Empty list check to stop Bluetooth stack crash in btif_rc

Remote devices sometimes poorly send 0 capabilities response when
connecting AVRCP. The stack currently crashes in response to this. We
should not crash and continue. Typically the remote device will send
proper packets in the future and continue to work properly.

Bug: 70140873
Test: Faked 0 capabilities, made stack crash. Added fix, stack stopped
crashing. Verified Bluetooth streaming working.

Change-Id: Id51f0593bc0ddcd3c3085b0d1b1fae136baecceb

6 years agoUpdate app use for link of BR/EDR over GATT
Chao Quan [Mon, 23 Oct 2017 05:43:14 +0000 (13:43 +0800)]
Update app use for link of BR/EDR over GATT

Link of GATT over BR/EDR still exists when no app uses it.
To wait for the link down, closing bt takes more time.
This defect brought from change "Merge BT 4.1 features",
whose change-id is Ic6701da4cf6aaa390ff2c8816b43157f36b7fb42.

Give back link control using gatt_update_app_use_link_flag

Change-Id: Iee756f23651a32dcb7db1aed766e2c64dab6f6ea
Test: manual

6 years agoAdd the AVRCP Target Service to btif
Ajay Panicker [Mon, 12 Mar 2018 23:41:21 +0000 (16:41 -0700)]
Add the AVRCP Target Service to btif

This class provides a management interface for the AVRCP Target Service.

Bug: 68854188
Test: Compiles
Change-Id: Id639ca6530ea986b5d67203f448ae7a0eecc6f8a

6 years agoMerge "BLE: Don't access freed buffer in log message"
Treehugger Robot [Tue, 13 Mar 2018 18:16:22 +0000 (18:16 +0000)]
Merge "BLE: Don't access freed buffer in log message"

6 years agoBLE: Don't access freed buffer in log message
Nitin Shivpure [Tue, 6 Feb 2018 12:48:37 +0000 (18:18 +0530)]
BLE: Don't access freed buffer in log message

When GATT fail to write data on L2CAP, buffer is freed by L2CAP.
Accessing the buffer leads to fatal failure while printing the message info.

Test: BLE discover services and BT off test cases

Fixes: 73018520
Change-Id: I661398fd1321f6e68026b3720db4965fd6584d70

6 years agoA2DP Offload support
Sunny Kapdi [Tue, 13 Feb 2018 05:52:50 +0000 (21:52 -0800)]
A2DP Offload support

The encoding of the A2DP data packets if offloaded
to platform specific HAL. The communication with the
HAL is enabled by IBluetoothAudioOffload and
IBluetoothAudioHost interfaces. Bluetooth stack is
still responsible for A2DP control path.

Bug: 72242910
Test: Manual; TestTracker/148125
Change-Id: Ie6e9c233ca431d0ab8cf15d10c30836e41bbdcb7
(cherry picked from commit c013d10798f674fd4a73f03b9178952928294b1e)

6 years agoMerge "Get rid of BTM_IS_PUBLIC_BDA"
Treehugger Robot [Fri, 9 Mar 2018 23:29:05 +0000 (23:29 +0000)]
Merge "Get rid of BTM_IS_PUBLIC_BDA"

6 years agoMerge "Enable AVDTP Delay reports by default."
Treehugger Robot [Fri, 9 Mar 2018 20:56:50 +0000 (20:56 +0000)]
Merge "Enable AVDTP Delay reports by default."

6 years agoMerge "Add the AVRCP Connection Handler"
Treehugger Robot [Fri, 9 Mar 2018 05:12:32 +0000 (05:12 +0000)]
Merge "Add the AVRCP Connection Handler"

6 years agoGet rid of BTM_IS_PUBLIC_BDA
Jakub Pawlowski [Fri, 9 Mar 2018 04:11:41 +0000 (20:11 -0800)]
Get rid of BTM_IS_PUBLIC_BDA

One can't really guess address type based on last bits.
Instead, for new devices always assume public address.

Test: scan, toggle bluetooth, try connecting to device with public
      address
Bug: 74413120

Change-Id: Id558260798e717c214a5a817cea0c204c5f4858e

6 years agoAVRCP: Fix size for Register Notification Response packets
Ajay Panicker [Tue, 6 Mar 2018 19:16:23 +0000 (11:16 -0800)]
AVRCP: Fix size for Register Notification Response packets

Bug: 68854188
Test: ./run_host_unit_tests.py && ./run_unit_test.sh net_test_btpackets
Change-Id: I62d864e2c27d809944f160dc45906b90cbb84f3d

6 years agoAdd the AVRCP Connection Handler
Ajay Panicker [Wed, 28 Feb 2018 04:51:47 +0000 (20:51 -0800)]
Add the AVRCP Connection Handler

This class handles connecting and disconnecting AVRCP Devices as well as
SDP lookups and feature selection.

Bug: 68854188
Test: run_host_unit_tests.py && run_unit_tests.sh net_test_avrcp
Change-Id: I950587123d2875c4333b415c379c7c1fb0c29ca5

6 years agoEnable AVDTP Delay reports by default.
Ajay Panicker [Wed, 7 Mar 2018 23:22:29 +0000 (15:22 -0800)]
Enable AVDTP Delay reports by default.

Bug: 32755225
Test: See that delay reports are enabled when connecting to device
Change-Id: I03bd216eb1725ee3e2e5da4e0baae61007ba2dcf
Merged-In: I03bd216eb1725ee3e2e5da4e0baae61007ba2dcf

6 years agoAdd missing audio_hearing_aid_hw in Android.bp
Jakub Pawlowski [Wed, 7 Mar 2018 00:31:41 +0000 (16:31 -0800)]
Add missing audio_hearing_aid_hw in Android.bp

Bug: 69623109
Test: compile, verify audio.hearing_aid.default is built
Change-Id: Ia246a6b7b026d1e6d698e9a7832ead0e584b621d

6 years agoPrecompute the RTP Header marker bit only for A2DP Source encoder
Pavlin Radoslavov [Tue, 6 Mar 2018 22:44:27 +0000 (14:44 -0800)]
Precompute the RTP Header marker bit only for A2DP Source encoder

The RTP Header marker bit is used only by the A2DP Source encoder,
and should be computed only when the local device is A2DP Source.

Test: Manual - disconnect, reconnect A2DP headset, play Audio
Bug: 74250013
Change-Id: I6510eeb9a34397e6623e5bc36675fc833b96ad7d

6 years agoMerge "Fix crash in l2c_rcv_acl_data during LE CoC SL4A Test"
Stanley Tng [Tue, 6 Mar 2018 22:02:21 +0000 (22:02 +0000)]
Merge "Fix crash in l2c_rcv_acl_data during LE CoC SL4A Test"

6 years agoFix crash in l2c_rcv_acl_data during LE CoC SL4A Test
Stanley Tng [Tue, 6 Mar 2018 18:56:12 +0000 (10:56 -0800)]
Fix crash in l2c_rcv_acl_data during LE CoC SL4A Test

When the incoming ACL messages is not setup yet, we should not further
processed it after we queue it. Otherwise, we will get be accessing the
null data structure for the connection.

Bug: 74240858
Test: Run SL4A test: act.py -c $MY_SL4A_CONFIG -tc BleCocTest:test_coc_secured_connection_throughput
Change-Id: I12e6d5dd30f05a74807afe6b4af1b9599c59886a

6 years agoMetrics: Move bluetooth.proto to one place
Jack He [Sat, 3 Mar 2018 08:03:25 +0000 (00:03 -0800)]
Metrics: Move bluetooth.proto to one place

* Move bluetooth.proto to proto/ and compile it for both Java LITE
  runtime and C++ LITE runtime so that it can be shared between Java
  and native code
* Remove redundant comments in bluetooth.proto

Bug: 33693818
Test: make, toggle Bluetooth, clearcut server-client E2E test
      adb shell dumpsys bluetooth_manager --proto-bin
      ACTS tests: BtMetricsTest, BtFunhausMetricsTest
Change-Id: I7cd5e1b4fb8fcc197272ef8161ff384e53022424

6 years agoMerge "Use proper sockets for A2DP and Hearing Aid HAL"
Treehugger Robot [Tue, 6 Mar 2018 02:17:56 +0000 (02:17 +0000)]
Merge "Use proper sockets for A2DP and Hearing Aid HAL"

6 years agoHearing Aid Audio Source 24000 sample rate support
Jakub Pawlowski [Mon, 5 Mar 2018 22:22:34 +0000 (14:22 -0800)]
Hearing Aid Audio Source 24000 sample rate support

Bug: 69623109
Test: compile, connect to hearing aid
Change-Id: I8751be8b92d2a902407726b6ec7fc1c8ecbcaebb

6 years agoUse proper sockets for A2DP and Hearing Aid HAL
Jakub Pawlowski [Fri, 2 Mar 2018 10:22:33 +0000 (02:22 -0800)]
Use proper sockets for A2DP and Hearing Aid HAL

Test: bond both Hearing Aid and Headset, try to stream to devices separately
Bug: 69623109
Change-Id: I81c9baa65d2ef114d4e964db29beb85def2629ae

6 years agoMerge "Add the AVRCP Device class for the AVRCP Refactor"
Treehugger Robot [Sat, 3 Mar 2018 02:32:56 +0000 (02:32 +0000)]
Merge "Add the AVRCP Device class for the AVRCP Refactor"

6 years agoHearingAidAudioSource implementation
Hansong Zhang [Fri, 19 Jan 2018 20:23:57 +0000 (12:23 -0800)]
HearingAidAudioSource implementation

Test: none
Bug: 69623109
Change-Id: Iaadd337ed5a8152db54b7515d55e0358f413f937

6 years agoMerge "Keep UIPC in local variable, rather than global struct."
Treehugger Robot [Fri, 2 Mar 2018 19:05:58 +0000 (19:05 +0000)]
Merge "Keep UIPC in local variable, rather than global struct."

6 years agoKeep UIPC in local variable, rather than global struct.
Jakub Pawlowski [Fri, 2 Mar 2018 00:23:58 +0000 (16:23 -0800)]
Keep UIPC in local variable, rather than global struct.

We will need multiple instances of UIPC.

Bug: 69623109
Test: play music using A2DP
Change-Id: Ie95f5272c92b5540034ebd166dbe10ea5b2b86a1

6 years agoAdd new sample rate BTAV_A2DP_CODEC_SAMPLE_RATE_24000
Jakub Pawlowski [Fri, 2 Mar 2018 09:56:09 +0000 (01:56 -0800)]
Add new sample rate BTAV_A2DP_CODEC_SAMPLE_RATE_24000

Test: compilation
Bug: 69623109
Change-Id: Ieffdd6e27ada8cbf221cfa7d1c0648aeb1c89be1

6 years agoHearing Aid BTIF interface implementation
Jakub Pawlowski [Thu, 1 Mar 2018 06:44:42 +0000 (22:44 -0800)]
Hearing Aid BTIF interface implementation

Boilerplate code - thread switching, logging and attaching to BTIF
infrastructure.

Test: manual with hearing aid
Bug: 69623109
Change-Id: I34a6542827a581a2fbe0b53e7220b7ff7ecbf540

6 years agoMerge "Multi-A2DP: stop or flush the A2DP queue only for Active peer"
Treehugger Robot [Thu, 1 Mar 2018 23:27:53 +0000 (23:27 +0000)]
Merge "Multi-A2DP: stop or flush the A2DP queue only for Active peer"

6 years agoMerge "Hearing Aid BTA interface"
Treehugger Robot [Thu, 1 Mar 2018 23:06:08 +0000 (23:06 +0000)]
Merge "Hearing Aid BTA interface"

6 years agoMerge "Call BTA_VendorCleanup on proper thread"
Treehugger Robot [Thu, 1 Mar 2018 22:21:29 +0000 (22:21 +0000)]
Merge "Call BTA_VendorCleanup on proper thread"

6 years agoMulti-A2DP: stop or flush the A2DP queue only for Active peer
Pavlin Radoslavov [Thu, 1 Mar 2018 16:26:43 +0000 (08:26 -0800)]
Multi-A2DP: stop or flush the A2DP queue only for Active peer

The A2DP queue should be flushed or the A2DP Tx/Rx operations
should be stopped only for the Active peer.
Otherwise, disconnecting a non-active A2DP Peer stops audio
output for the Active peer.

Bug: 73956686
Test: Manual: Connect two A2DP Sink devices, play music on the
      Active device, disconnect the non-Active device
Change-Id: I32a624c012ef2cd9ef0057f7289a6ed713f88039

6 years agoHearing Aid BTA interface
Jakub Pawlowski [Thu, 1 Mar 2018 06:59:32 +0000 (22:59 -0800)]
Hearing Aid BTA interface

This is the interface between the btif and bta layer, and also between
the profile implementation and audio source.
Submitting it in separate CL allows us to split the work on those
submodules.

Bug: 64038649
Test: compilation
Change-Id: I40663df4e3d8cfb401f9da6084b7212b7bdbcc8c

6 years agoCall BTA_VendorCleanup on proper thread
Jakub Pawlowski [Thu, 1 Mar 2018 19:54:16 +0000 (11:54 -0800)]
Call BTA_VendorCleanup on proper thread

Right now this function is running on any thread that call it, i.e. one
of Binder threads. This is introducing race condition during shutdown.

Test: restart bluetooth 10 times
Fix: 74075027
Change-Id: I426284792901e6a9540cb6420a7e27a340a3fe1d

6 years agoMerge "Pre-compute the RTP Header Marker Bit by using the correct peer address"
Treehugger Robot [Thu, 1 Mar 2018 20:01:02 +0000 (20:01 +0000)]
Merge "Pre-compute the RTP Header Marker Bit by using the correct peer address"

6 years agoRemove unused adjustAvrcpAbsoluteVolume
Ajay Panicker [Wed, 28 Feb 2018 19:38:26 +0000 (11:38 -0800)]
Remove unused adjustAvrcpAbsoluteVolume

The AudioManager now handles all calculations for volume stepping now
and no longer uses adjustAvrcpAbsoluteVolume.

Bug: 68812037
Test: Compile and test Absolute Volume on a device that supports it
Change-Id: I34f27d27b4c5c3959a84a6dc438edfed45a0b3e3

6 years agoHearing Aid Audio HAL
Jakub Pawlowski [Fri, 23 Feb 2018 21:55:48 +0000 (13:55 -0800)]
Hearing Aid Audio HAL

The code is cloned from the existing A2DP Audio HAL.
In the future it will expand to include hearing-aid specific
mechanism.

Test: code compilation
Bug: 64038649
Change-Id: I976aa189929c3051b83615d1536315a099f31a67

6 years agoMerge "Add new sample rate BTAV_A2DP_CODEC_SAMPLE_RATE_16000"
Treehugger Robot [Thu, 1 Mar 2018 10:25:39 +0000 (10:25 +0000)]
Merge "Add new sample rate BTAV_A2DP_CODEC_SAMPLE_RATE_16000"

6 years agoPre-compute the RTP Header Marker Bit by using the correct peer address
Pavlin Radoslavov [Thu, 1 Mar 2018 07:34:28 +0000 (23:34 -0800)]
Pre-compute the RTP Header Marker Bit by using the correct peer address

The RTP Header Marker Bit is computed by using the peer address
to lookup the corresponding codec instead of using the codec
for the current active peer.

Also, the pre-computed result is stored in the SCB for the peer instead
of storing a pointer to the current codec config.

Bug: 73897470
Test: Manual - disconnect, reconnect A2DP headsets
Change-Id: Id015de7be2a297b86ac945c7b7c64e6bc13ffc42

6 years agoAdd new sample rate BTAV_A2DP_CODEC_SAMPLE_RATE_16000
Jakub Pawlowski [Thu, 1 Mar 2018 02:40:33 +0000 (18:40 -0800)]
Add new sample rate BTAV_A2DP_CODEC_SAMPLE_RATE_16000

Test: compilation
Bug: 69623109
Change-Id: Ib7c94c538d8636719658814d2a73bc997ab6dddc

6 years agoAdd the AVRCP Device class for the AVRCP Refactor
Ajay Panicker [Thu, 22 Feb 2018 05:04:24 +0000 (21:04 -0800)]
Add the AVRCP Device class for the AVRCP Refactor

The AVRCP Device class handles all the state tracking for each connected
device as well as handling all the different message responses.

Bug: 68854188
Test: run_host_unit_tests.py && run_unit_tests.sh net_test_avrcp
Change-Id: Ic39337eff3e404ca3c2d96f48e79948fac83d7cb

6 years agoHearing Aid BTIF interface
Jakub Pawlowski [Wed, 22 Nov 2017 00:35:49 +0000 (16:35 -0800)]
Hearing Aid BTIF interface

This is first version of Hearing Aid interface.

Test: compilation
Bug: 69623109
Change-Id: I157dc8d1481c1f034c15aac7dd33a5103cf5ea14

6 years agoMerge changes from topics "bt-a2dp-remove-redundant-alarm-free", "bt-a2dp-codec-init...
Treehugger Robot [Tue, 27 Feb 2018 08:37:13 +0000 (08:37 +0000)]
Merge changes from topics "bt-a2dp-remove-redundant-alarm-free", "bt-a2dp-codec-init-same-thread"

* changes:
  Removed redundant alarm_free() call on the wrong thread
  Perform all codec-related init operations on the same thread

6 years agoRemoved redundant alarm_free() call on the wrong thread
Pavlin Radoslavov [Tue, 27 Feb 2018 07:16:43 +0000 (23:16 -0800)]
Removed redundant alarm_free() call on the wrong thread

Bug: 73741079
Bug: 73892830
Test: Manual - A2DP connect/disconnect; audio streaming
Change-Id: I3e553245ef5ac10835d08b78e52a3fbd945914ee

6 years agoPerform all codec-related init operations on the same thread
Pavlin Radoslavov [Tue, 27 Feb 2018 06:44:30 +0000 (22:44 -0800)]
Perform all codec-related init operations on the same thread

Renamed btif_a2dp_source_encoder_init_event() to
btif_a2dp_source_setup_codec_delayed() and moved the
peer parameter fetching from btif_a2dp_source_setup_codec()
to btif_a2dp_source_setup_codec_delayed()

Test: Manual - A2DP connect/disconnect; audio streaming
Change-Id: Ib29dd6b2bef3045be3727122e1f8608780921d98

6 years agoClear the A2DP active device within the native stack during cleanup
Pavlin Radoslavov [Tue, 27 Feb 2018 06:53:05 +0000 (22:53 -0800)]
Clear the A2DP active device within the native stack during cleanup

Use explicit SetActivePeer(RawAddress::kEmpty) for BtifAvSource and
BtifAvSink during Cleanup()

Also, replaced incorrectly classified BTIF_TRACE_WARNING() log messages
with LOG_INFO().

Bug: 73832547
Test: Manual - A2DP streaming, enable Location -> Bluetooth scanning,
      restart Bluetooth in Quick Settings
Change-Id: Ieeae8915a45dc0c98cd68bd4bb113424c2de74d9

6 years agoInitialize max number of connected A2DP devices in the native stack via JNI
Pavlin Radoslavov [Tue, 27 Feb 2018 03:16:05 +0000 (19:16 -0800)]
Initialize max number of connected A2DP devices in the native stack via JNI

Pass the maximum number of connected A2DP devices from Java to the
native stack as a parameter to the init() call.

Bug: 72351654
Test: Manual: Connect to multiple A2DP devices, check the log messages
Change-Id: I0647c36fe7c6a2df2c42a60b53b5cf505160b1e6

6 years agoMerge "Add/update the BTIF A2DP log messages"
Treehugger Robot [Tue, 27 Feb 2018 01:02:21 +0000 (01:02 +0000)]
Merge "Add/update the BTIF A2DP log messages"

6 years agoHCI: Set a timer to abort after a timeout
Myles Watson [Sat, 24 Feb 2018 01:28:23 +0000 (17:28 -0800)]
HCI: Set a timer to abort after a timeout

Add code to clean up the timer and close the file whether
abort gets called or not.

Bug: 72719600
Bug: 72474659
Test: Cause an HCI timeout and wait for the firmware dump
Change-Id: I713f440d77bfad4c9f17dfc57f98ba5bada37fff

6 years agoAdd/update the BTIF A2DP log messages
Pavlin Radoslavov [Mon, 26 Feb 2018 20:08:22 +0000 (12:08 -0800)]
Add/update the BTIF A2DP log messages

 * Added new log messages where needed
 * Updated existing log messages so the message format is more aligned
   with the rest of the messages

Test: Manual: A2DP streaming
Change-Id: I9f953c43df1ff415379bb7d7fb61f0d33760df30

6 years agoUse assigned UUID for Hearing Aid Service
Jakub Pawlowski [Thu, 22 Feb 2018 23:02:25 +0000 (15:02 -0800)]
Use assigned UUID for Hearing Aid Service

Test: manual
Bug: 64038649
Change-Id: Ie5b39d74d245373142be31027cccb5f51f8586bf

6 years agoMerge "Add explicit init/cleanup steps for A2DP Source and Sink"
Treehugger Robot [Sat, 24 Feb 2018 04:49:57 +0000 (04:49 +0000)]
Merge "Add explicit init/cleanup steps for A2DP Source and Sink"

6 years agoAdd explicit init/cleanup steps for A2DP Source and Sink
Pavlin Radoslavov [Fri, 23 Feb 2018 17:04:57 +0000 (09:04 -0800)]
Add explicit init/cleanup steps for A2DP Source and Sink

The startup/shutdown steps for A2DP Source and Sink
are done when setting/resetting the Active device, and this
implies the device has been connected.

The operations that must be done before the remote device
is connected are moved to init (and cleanup for the reverse operations)

Bug: 73832547
Test: Manual - Connect/disconnect/play A2DP to Headset
Change-Id: Iaa55c2d27443646111f07a53d2c5163bca9e256d

6 years agoL2CAP: Discard pending requests on link disconnect
Manoj Babulal [Thu, 13 Jul 2017 07:04:09 +0000 (12:34 +0530)]
L2CAP: Discard pending requests on link disconnect

Scenario: A connection request packet is admitted to link tx queue in
L2CAP but before it could be transmitted (host busy), ACL link can get
disconnected (idle timeout) and the link tx queue is not flushed during
link disconnect handling. In such scenario, subsequent connection
attempt by host is seen to fail. This is because host is found to send
multiple connection requests (one connect request packet from the queue
and a new connection request packet per new request). Remote accepts old
connection request packet and waits for connection response from host.
For next connection request seen by remote, remote responds with 'No
PSM' resource error (as it already admitted one connection request and
it is in progress). Here when the connection response arrives from
remote, host ignores it because it sees packet id mismatch (host had
sent old connection request first and later information request/response
packets were exchanged. Remote had sent connection response copying
stale packet id picked from old connection request).

Drop queued packets as part of link disconnection handling.
This was already done in BLE transport case and is now being done
unconditionally.

Fixes: 73050475
Test: back-to-back PAN connect-disconnect iterations amidst ongoing
      OPP file transfer and AV streaming
Change-Id: I42cc7ae90cc1152f1781282698529fe50f0ebf89

6 years agoUprev to AVDTP 1.3 and Implement AVDTP delay reports
Ajay Panicker [Wed, 21 Dec 2016 23:37:34 +0000 (15:37 -0800)]
Uprev to AVDTP 1.3 and Implement AVDTP delay reports

Implement receiving the delay report message which requires AVDTP 1.3.
Also start keeping track of total number of audio bytes sent over the
air. We now will report both of these values to the audio HAL so that
they can adjust audio playback using these values.

Bug: 32755225
Test: Manual test with a device that supports delay reporting
      Testtracker: 145280
Change-Id: I22c1c6401e4912efab06fa56fb582faae4b38eaf

6 years agoMerge "Remove unreachable code"
Treehugger Robot [Fri, 23 Feb 2018 18:32:54 +0000 (18:32 +0000)]
Merge "Remove unreachable code"

6 years agoFree the A2DP Source media alarm on the A2DP Source worker thread
Pavlin Radoslavov [Fri, 23 Feb 2018 11:35:37 +0000 (03:35 -0800)]
Free the A2DP Source media alarm on the A2DP Source worker thread

Move the alarm_free() for the A2DP Source media alarm from
btif_a2dp_source_shutdown() to btif_a2dp_source_shutdown_delayed().
The latter is executed on the btif_a2dp_source_thread.
This avoids a race condition with btif_a2dp_source_audio_tx_stop_event()
that also might attempt to free the same alarm.

Test: Manual - unpair A2DP device while A2DP streaming.
Bug: 73741079
Change-Id: Ia871fcbeaae7c351878228e7605e65307a3d1583

6 years agoCorrect the value for BT_RC_NUM_APP for Multi-A2DP / Multi-AVRCP
Pavlin Radoslavov [Sat, 10 Feb 2018 23:23:49 +0000 (15:23 -0800)]
Correct the value for BT_RC_NUM_APP for Multi-A2DP / Multi-AVRCP

The original value of BT_RC_NUM_APP was incorrectly increased from
1 to 12 for the purpose of supporting up to 6 AVRCP connected devices.

The new BT_RC_NUM_APP value is corrected to 6:
  BT_RC_NUM_APP -> 1 -> 12 -> 6 (AVRCP-related - MaxDevices)

Test: Manual - connected to multiple headsets and selected each
      headset to play audio.
Bug: 70350399
Change-Id: I53e350c2bf1717b1f031a7a265adf3417cf3c513

6 years agoReplace AVRC callback function pointers with base::Callback
Ajay Panicker [Sun, 26 Nov 2017 00:27:33 +0000 (16:27 -0800)]
Replace AVRC callback function pointers with base::Callback

Replace function pointers with base::Callback for AVRCP to make
interfacing with the new AVRCP service easier.

Bug: 68812037
Test: Connect headset and see that Absolute volume and passthrough
commands still work.

Change-Id: I2ab20b7b59186aea413a736f43e926e17915a139

6 years agoRevert "Remove A2DP Source/Sink startup calls during A2DP initialization"
Andre Eisenbach [Wed, 21 Feb 2018 02:38:52 +0000 (02:38 +0000)]
Revert "Remove A2DP Source/Sink startup calls during A2DP initialization"

This reverts commit 83255478b0457f291d6a78795444ff3b895d4a90.

Reason for revert:
Prevents audio routing due to stale active device record if
Bluetooth is toggled without the process stopping completely
(ex. LE-only mode).

Bug: 72701090
Change-Id: Ifa798e63df14855b5bf0bd45e1557315cd51034d
Fixes: 73601288

6 years agoAdd packet classes needed for AVRCP Absolute Volume
Ajay Panicker [Sat, 17 Feb 2018 19:22:48 +0000 (11:22 -0800)]
Add packet classes needed for AVRCP Absolute Volume

Add the Register Notification Request packet as well as the
packets Set Absolute Volume packet.

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

6 years agoRemove unreachable code
Yi Kong [Tue, 20 Feb 2018 17:48:09 +0000 (12:48 -0500)]
Remove unreachable code

The conditionals can never be true, as they are outside of the bounds of
their data types. Fixes tautological-constant-compare warning.

Bug: 72331526
Test: m
Change-Id: I74063fe19b319ee32e4c1c8b3a5fc7ed612586e3

6 years agoOSI: Protect cutils/properties.h from direct calls
Myles Watson [Fri, 16 Feb 2018 21:11:04 +0000 (13:11 -0800)]
OSI: Protect cutils/properties.h from direct calls

Bug: None
Test: compile, no calls to property_get outside of libosi
      change PROPERTY_VALUE_MAX in osi/include/properties.h
      -> doesn't compile
Change-Id: I18c7b861782b1df4878da032ae3f0340dffdecab

6 years agoGet rid of BTA_HOST_INTERLEAVE_SEARCH
Jakub Pawlowski [Fri, 16 Feb 2018 21:21:58 +0000 (13:21 -0800)]
Get rid of BTA_HOST_INTERLEAVE_SEARCH

Test: compilation
Change-Id: I6f91cd783fc1dd46cda55d3456a67eb78ba4c7ae

6 years agoMerge "Make STREAM_TO_UINT64 globally available"
Treehugger Robot [Fri, 16 Feb 2018 05:49:15 +0000 (05:49 +0000)]
Merge "Make STREAM_TO_UINT64 globally available"