OSDN Git Service

android-x86/system-bt.git
5 years agoMerge "Enable 2-EV3 packets for Wide Band HFP client"
Joseph Pirozzo [Wed, 25 Jul 2018 00:38:12 +0000 (00:38 +0000)]
Merge "Enable 2-EV3 packets for Wide Band HFP client"

5 years agoMerge "Use appropriate Tx time in BLE Set Data length command"
Treehugger Robot [Wed, 25 Jul 2018 00:33:00 +0000 (00:33 +0000)]
Merge "Use appropriate Tx time in BLE Set Data length command"

5 years agoUse appropriate Tx time in BLE Set Data length command
Subramanian Srinivasan [Thu, 15 Mar 2018 22:58:20 +0000 (15:58 -0700)]
Use appropriate Tx time in BLE Set Data length command

Fixes Tx time parameter in HCI LE set data length command
depending on HCI versions supported by controller.

Bug: 110373079
Change-Id: I83cc4c41ca4c2b6470ec30057717946b1d7fe329

5 years agoMake PROPERTY_PRODUCT_MODEL device configurable
Fen Wang [Tue, 10 Apr 2018 03:41:34 +0000 (12:41 +0900)]
Make PROPERTY_PRODUCT_MODEL device configurable

Make it possible to set PROPERTY_PRODUCT_MODEL in device configuration.

Bug:
Change-Id: I4d34d4ec368f7eb8bd50e2d5431bb120a284f4e3

5 years agoMerge "Ignore SDP failure while bonding if SDP was not attempted"
Treehugger Robot [Tue, 24 Jul 2018 04:21:40 +0000 (04:21 +0000)]
Merge "Ignore SDP failure while bonding if SDP was not attempted"

6 years agoClean up style in BLE White List code
Hansong Zhang [Tue, 17 Jul 2018 00:57:17 +0000 (17:57 -0700)]
Clean up style in BLE White List code

* Remove unused code
* Update BgConnHash to return size_t for hashcode
* Change BLE scan_int and scan_win to uint16_t according to spec

Bug: 111562702
Test: SL4A BLE test and manual with BLE mouse
Change-Id: Ieff3acbfaa95b7d804e57021d562218d9fbe42cc

6 years agoIgnore SDP failure while bonding if SDP was not attempted
Cheney Ni [Tue, 17 Jul 2018 11:27:59 +0000 (19:27 +0800)]
Ignore SDP failure while bonding if SDP was not attempted

When bonding, there is an ACL_UP event to the upper layers and some apps
may want to fetch SDP in return. This can break pairing. In cases SDP fails,
it causes the procedure to be finished before the LinkKey is generated.
And thus the LinkKey is not committed to NVRAM and the device is not paired.

Bug: 111189110
Test: : Pair / Unpair BT accessories manually
Change-Id: Iaefbe8b6c1fc3e78f0f120220992df84699a2eb8

6 years agoMerge "Metrics: Add python script to dump metrics into ASCII format"
Treehugger Robot [Tue, 17 Jul 2018 23:50:34 +0000 (23:50 +0000)]
Merge "Metrics: Add python script to dump metrics into ASCII format"

6 years agoMetrics: Add python script to dump metrics into ASCII format
Jack He [Fri, 13 Jul 2018 21:54:38 +0000 (14:54 -0700)]
Metrics: Add python script to dump metrics into ASCII format

Test: make,
      ./dump_metrics_ascii.py proto/bluetooth/metrics/bluetooth.proto
Change-Id: Ie671fa2c2ceb9f93ed62495b592a2cf9d69ff41b

6 years agoIncrease DM connection size for multiple links
Ben YoungTae Kim [Tue, 10 Jul 2018 00:58:12 +0000 (17:58 -0700)]
Increase DM connection size for multiple links

For multiple headset connections, it will be increased to support
multiple services(HFP/AV/CT) for each links.

Test: Connect to 4 or more headsets and play music
Bug: 110972513
Change-Id: I56f69e12fb1a4a614c69fa383e9c53675a189fc9

6 years agoMerge "HFP: Reset BTA SCO control block when bta_ag_create_sco failed"
Treehugger Robot [Fri, 13 Jul 2018 19:59:10 +0000 (19:59 +0000)]
Merge "HFP: Reset BTA SCO control block when bta_ag_create_sco failed"

6 years agoMerge "SCO: Allocate 6 BTM SCO control blocks for Multi-HFP support"
Treehugger Robot [Fri, 13 Jul 2018 19:58:46 +0000 (19:58 +0000)]
Merge "SCO: Allocate 6 BTM SCO control blocks for Multi-HFP support"

6 years agoHFP: Reset BTA SCO control block when bta_ag_create_sco failed
Benson Li [Wed, 4 Jul 2018 12:41:58 +0000 (20:41 +0800)]
HFP: Reset BTA SCO control block when bta_ag_create_sco failed

* When trying to connect SCO to non-active and active device back to
  back, the first connection to non-active device must fail gracefully
* Otherwise, BTA SCO state machine may stuck in a irrecoverable state
* Schedule to send AUDIO_CONNECTING state before starting SCO connection
  to avoid race condition between connecting state and connection
  failure

Bug: 111101075
Test: Manual test, make a call and switch path A->speaker->B on phone UI
Change-Id: I9bfa389e04863944d88f2bca49d27f1247fa072b

6 years agoSCO: Allocate 6 BTM SCO control blocks for Multi-HFP support
Jack He [Fri, 13 Jul 2018 00:48:36 +0000 (17:48 -0700)]
SCO: Allocate 6 BTM SCO control blocks for Multi-HFP support

Bug: 110818719
Test: connect 5 devices, switch to speaker using dialer, switch to
      Bluetooth device using settings, repeat for all devices

Change-Id: I68d8a892c99e106250245c4f56327555a13543ae

6 years agoMerge "AVRCP: Reject when CT sends invalid RegisterNotification"
Treehugger Robot [Thu, 12 Jul 2018 01:45:05 +0000 (01:45 +0000)]
Merge "AVRCP: Reject when CT sends invalid RegisterNotification"

6 years agoAVRCP: Reject when CT sends invalid RegisterNotification
Hansong Zhang [Tue, 10 Jul 2018 19:37:58 +0000 (12:37 -0700)]
AVRCP: Reject when CT sends invalid RegisterNotification

Check whether the RegisterNotification request from CT is valid, and
safely reject invalid request

Bug: 111260441
Test: manually test with RIVA WAND speaker
Change-Id: Ia2edd94e50fa7cb5b61be54f297adf971060a924

6 years agoMerge "Fix stack not acking status to audio when A2DP start failed"
Treehugger Robot [Tue, 10 Jul 2018 10:03:07 +0000 (10:03 +0000)]
Merge "Fix stack not acking status to audio when A2DP start failed"

6 years agoRegister for Service Changed notification after encryption
Jakub Pawlowski [Wed, 4 Jul 2018 14:11:52 +0000 (07:11 -0700)]
Register for Service Changed notification after encryption

This fixes issue introduced in commit 645ee14ce2327fff61f54d208763eca1c143063e
Registration for Service Changed notifications was
disabled, because there was no good way back then to have
"opportunistic" app. Since opportunistic apps were introduced, and the
code in GATT_ConfigServiceChangeCCC is already marking connection as
opportunistic, reenable notification registration.

Test: manual verification, that Service Changed descriptor is set
Change-Id: Iefaec3914829fa4a4a60dc3c3790c3daa9f4f4d8

6 years agoGet rid of warning when connecting LE device
Jakub Pawlowski [Wed, 4 Jul 2018 16:26:05 +0000 (09:26 -0700)]
Get rid of warning when connecting LE device

We are sending LE fixed channel notification to classic callback. Stop
doing that. This triggers following warning in log output on every
LE connection:
W bt_smp  : smp_br_connect_callback is called on unexpected transport 2

Test: manual with phone, verify warning is gone when connecting over LE
Change-Id: I47597fa03744fb1bff03d287f790ea32fa033cc7

6 years agoFix stack not acking status to audio when A2DP start failed
Ugo Yu [Mon, 9 Jul 2018 05:49:44 +0000 (13:49 +0800)]
Fix stack not acking status to audio when A2DP start failed

Add a missing ack in A2DP start failed case when A2DP offload is
enabled.

Bug: 111207927
Test: Manual

Change-Id: I96a7ad322ea7ce6da5084a48fdd3dec980ce57b8

6 years agoDon't trigger AVDTP Suspend in response to AVDTP Suspend+Start from remote
Pavlin Radoslavov [Fri, 29 Jun 2018 03:10:36 +0000 (20:10 -0700)]
Don't trigger AVDTP Suspend in response to AVDTP Suspend+Start from remote

If the remote device sent us AVDTP Suspend, and then AVDTP Start, don't
trigger AVDTP Suspend from the local device in response to the AVDTP Start.

Also:
 * Add a call btif_av_stream_start_offload() inside btif_a2dp_on_started()
   if we were started remotely.
 * Fix the order of calling btif_a2dp_on_started() and triggering
   an internal BTIF_AV_SUSPEND_STREAM_REQ_EVT event. Otherwise,
   BTA Suspend might be called before btif_av_stream_start_offload()

Bug: 110015851
Bug: 110186160
Test: Manual
Change-Id: I908d19f8caf5130b96a64153ff39bd4b52879713

6 years agoMerge "Fix double close in btif.cc's dump."
Treehugger Robot [Fri, 29 Jun 2018 18:55:56 +0000 (18:55 +0000)]
Merge "Fix double close in btif.cc's dump."

6 years agoEnable 2-EV3 packets for Wide Band HFP client
Joseph Pirozzo [Fri, 29 Jun 2018 12:57:47 +0000 (05:57 -0700)]
Enable 2-EV3 packets for Wide Band HFP client

The previous code defaulted to the failsafe settings rather than the
prefered settings when accepting an eSCO connection for Wide Band
Speech, this change will enable the T2 (2-EV3) packets.

Bug: 110227849
Test: Connect to phone, place call, verify 2-EV3 packets via HCI logs.
Change-Id: I0c215249b16cfcd4d79137fa80b0d9cc1992c9da

6 years agoAVRCP: Reject SetAddressedPlayer command only if remote set invalid player ID
Benson Li [Mon, 25 Jun 2018 06:11:20 +0000 (14:11 +0800)]
AVRCP: Reject SetAddressedPlayer command only if remote set invalid player ID

Implement HandleSetAddressedPlayer() to check if remote set valid
player ID and properly respond to remote.

Bug: 110632860
Test: PTS Test AVRCP/TG/MPS/BI-01-C AVRCP/TG/MPS/BV-02-C
Change-Id: Ice13e7ea97cdac369c4d021171a24bf9d96c9da8

6 years agoMerge "Move sepolicy files to system/sepolicy"
Treehugger Robot [Thu, 28 Jun 2018 00:31:05 +0000 (00:31 +0000)]
Merge "Move sepolicy files to system/sepolicy"

6 years agoMove sepolicy files to system/sepolicy
Myles Watson [Tue, 26 Jun 2018 00:09:27 +0000 (17:09 -0700)]
Move sepolicy files to system/sepolicy

Test: Toggle Bluetooth, ls -alZ /vendor/bin/hw/*blue*
Change-Id: Ibf72f8bacc2f4975d06f4892e3b33ef6fb08aab7
Merged-In: Ibf72f8bacc2f4975d06f4892e3b33ef6fb08aab7

6 years agoFix double close in btif.cc's dump.
Josh Gao [Tue, 26 Jun 2018 21:01:06 +0000 (14:01 -0700)]
Fix double close in btif.cc's dump.

dump closes a file descriptor that is still owned by a
ParcelFileDescriptor which leads eventually to a double close.

Test: treehugger
Change-Id: Id351b5429cb17b48e37313850a363d739d78c4a1

6 years agoIf command_timed_out() is triggered don't get blocked by a deadlock
Pavlin Radoslavov [Thu, 21 Jun 2018 01:28:33 +0000 (18:28 -0700)]
If command_timed_out() is triggered don't get blocked by a deadlock

If command_timed_out() is triggered and we cannot acquire the
commands_pending_response_mutex to print the debug info, then proceed
with the rest of the operations until the process aborts.

Similarly, if startup_timer_expired() is triggered and we are blocked
by a deadlock, just abort() because there is no way to recover.

Bug: 110441099
Test: Code compilation
Change-Id: I367332bbbd9c1d887bd2bc829b9f617114fc96fc

6 years agoMove crypto related functions into crypto_toolbox
Jakub Pawlowski [Thu, 21 Jun 2018 12:23:47 +0000 (14:23 +0200)]
Move crypto related functions into  crypto_toolbox

Also clean up the code:
* remove spurious logging, or replace with DVLOG
* use std::copy and std::reverse_copy instead of ARRAY_TO_STREAM and
  REVERSE_ARRAY_TO_STREAM

Test: CryptoToolboxTest already cover all those functions
Change-Id: I3221d0966d2dd6ca229adf441ceb75dd37a54d7c
Merged-In: I3221d0966d2dd6ca229adf441ceb75dd37a54d7c

6 years agoMerge "Reset a2dp_cmd_pending as appropriate for A2DP HW offload HAL commands"
Treehugger Robot [Tue, 26 Jun 2018 03:02:47 +0000 (03:02 +0000)]
Merge "Reset a2dp_cmd_pending as appropriate for A2DP HW offload HAL commands"

6 years agoMerge "Add missing btif_a2dp_audio_interface_end_session() call during disconnect"
Treehugger Robot [Tue, 26 Jun 2018 02:50:44 +0000 (02:50 +0000)]
Merge "Add missing btif_a2dp_audio_interface_end_session() call during disconnect"

6 years agoMerge "a2dp_vendor_ldac: add missing break"
Treehugger Robot [Tue, 26 Jun 2018 02:07:46 +0000 (02:07 +0000)]
Merge "a2dp_vendor_ldac: add missing break"

6 years agoReset a2dp_cmd_pending as appropriate for A2DP HW offload HAL commands
Pavlin Radoslavov [Mon, 25 Jun 2018 22:22:13 +0000 (15:22 -0700)]
Reset a2dp_cmd_pending as appropriate for A2DP HW offload HAL commands

Previously, the a2dp_cmd_pending was set to the last pending command,
but was never reset to A2DP_CTRL_CMD_NONE after the command processing
was completed.

Bug: 110712574
Test: Manual: Pair with two headsets, start/suspend/stop/switch active
      device
Change-Id: I464e6e9d41a221df44eba21e538b499a9ac1dcfb

6 years agoAdd missing btif_a2dp_audio_interface_end_session() call during disconnect
Pavlin Radoslavov [Mon, 25 Jun 2018 23:34:17 +0000 (16:34 -0700)]
Add missing btif_a2dp_audio_interface_end_session() call during disconnect

Update the logic inside btif_a2dp_source_end_session_delayed() to make
sure that btif_a2dp_audio_interface_end_session() is called when device
is disconnected.

Also, update existing log messages to make it easier to identify similar
issues in the future.

Bug: 110176990
Test: Manual: Pair with two headsets, start/suspend/stop/switch active
      device
Change-Id: I248e5c3e2c4cf0ad820cef34ba859e9adc8dec8e

6 years agoa2dp_vendor_ldac: add missing break
Tom Yan [Wed, 20 Jun 2018 04:10:45 +0000 (12:10 +0800)]
a2dp_vendor_ldac: add missing break

Bug: 110800823
Test: Code compilation
Change-Id: I9b40f63d176031087cb2ab2f2b5400b4d326cf8f
Signed-off-by: Tom Yan <tom.ty89@gmail.com>
6 years agoLinux build fix
Jakub Pawlowski [Thu, 21 Jun 2018 07:03:45 +0000 (09:03 +0200)]
Linux build fix

Add empty android_errorWriteLog implementation for Linux
Add missing license headers
Fix BUILD.gn files

Test: compile using ninja
Change-Id: I9be297d5847b4c0856786738eac2c30424593919

6 years agoMerge "HFP: Don't use mSBC for HF devices not supporting Codec Negotiation"
Treehugger Robot [Fri, 22 Jun 2018 05:26:17 +0000 (05:26 +0000)]
Merge "HFP: Don't use mSBC for HF devices not supporting Codec Negotiation"

6 years agoMove crypto toolbox functions into separate file
Jakub Pawlowski [Tue, 19 Jun 2018 21:48:07 +0000 (14:48 -0700)]
Move crypto toolbox functions into separate file

Test: already covered by CryptoToolboxTest
Change-Id: I9ba12616d51744fe46648a00a73065cf66f54297

6 years agoAdd more crypto toolbox tests, plus minor fix in smp_keys.cc
Jakub Pawlowski [Mon, 18 Jun 2018 20:33:26 +0000 (13:33 -0700)]
Add more crypto toolbox tests, plus minor fix in smp_keys.cc

This code extracts two new functions, smp_calculate_ltk_to_link_key
and smp_calculate_link_key_to_ltk, in order to test them.
Also use modulo operator to compute modulo in smp_calculate_g2.
Plus remove unused function definitions in smp_int.h, that were probably
previously used for testing.

Test: added and updated CryptoToolboxTest
Change-Id: Ia84f72af666fc8e34f887b65b07208bc786bf2e0

6 years agoHFP: Don't use mSBC for HF devices not supporting Codec Negotiation
weichinweng [Thu, 21 Jun 2018 06:28:25 +0000 (14:28 +0800)]
HFP: Don't use mSBC for HF devices not supporting Codec Negotiation

* Some misbehaving HF devices (e.g. Sony XAV AX100 carkit, Sony MW600)
  indicate their support on WBS but not support on Codec Negotiation.
  In this condition, if Fluoride chooses mSBC will result in big noise or SCO
  no sound.
* This CL adds a workaround for checking if HF device indicate codec negotiation is
  not supported, Fluoride will assume CVSD codec by default.

Bug: 101592600
Test: make, connect SCO and check voice on carkit and headset.
Change-Id: If0d8779bcfd55b87852f56f0448fd1b585ee45ad

6 years agoRemove unused MIP events, calbacks and structs
Jakub Pawlowski [Wed, 20 Jun 2018 21:09:21 +0000 (14:09 -0700)]
Remove unused MIP events, calbacks and structs

Test: compilation
Change-Id: I00e0fcfdea129f0f7eee16d69c5fc09451ad6746

6 years agoGracefully handle A2DP hardware offload Audio HAL service death
Pavlin Radoslavov [Wed, 20 Jun 2018 02:10:43 +0000 (19:10 -0700)]
Gracefully handle A2DP hardware offload Audio HAL service death

Register for Audio HAL service death, and restart the Audio HAL session
if necessary.

Bug: 77926419
Test: Manual: stream Bluetooth audio and kill -9 the audioserver
Change-Id: I45e83aea0fb95301e6ceadee74661dd55f8c0f66

6 years agoReplace BT_OCTET16 with Octet16
Jakub Pawlowski [Fri, 15 Jun 2018 00:40:34 +0000 (17:40 -0700)]
Replace BT_OCTET16 with Octet16

BT_OCTET16 was a uint8_t[16], that is a pointer.
This means that it was not copyable, and one had to be always aware of
what this type really means when passing it to function.

Octet16 is std::array<uint8_t, 16> and is copyable. It can also be
copied using "=" operator, instead of memcpy, or ARRAY_TO_STREAM.

Octet16 can also be returned from function by value. Thanks to it, some
smp functions can be simplified, by returning value instead of accepting
pointer to output.

Test: net_stack_smp_test
Change-Id: I0687a948e5807f76ec3d1b5d1d4d2ad2b50b87dd

6 years agoFix SMP_Encrypt for data shorter than 16 bytes
Jakub Pawlowski [Mon, 18 Jun 2018 20:29:24 +0000 (13:29 -0700)]
Fix SMP_Encrypt for data shorter than 16 bytes

This bug was introduced in commit c3e7c878fe8495590f059547153bd77cdea322a6
osi_calloc was replaced with raw array, that is not wiped clean.

Change-Id: I57a4e7a26108ad4672d2dd2ff25028653c96ca1b

6 years agoMerge "SMP_Encrypt - convert p_out into raw array"
Treehugger Robot [Mon, 18 Jun 2018 19:24:25 +0000 (19:24 +0000)]
Merge "SMP_Encrypt - convert p_out into raw array"

6 years agogatt: Avoid using erased iterator
Greg Kaiser [Fri, 15 Jun 2018 21:30:50 +0000 (14:30 -0700)]
gatt: Avoid using erased iterator

After we've called erase() on an iterator, we can't safely use
it anymore.  We avoid this, to assure consistent behavior from
this code.

Test: None
Change-Id: I4c9aecadc768d57f942669b7e68ee3a302e67e9c

6 years agoSMP_Encrypt - convert p_out into raw array
Jakub Pawlowski [Thu, 14 Jun 2018 23:46:29 +0000 (16:46 -0700)]
SMP_Encrypt - convert p_out into raw array

SMP_Encrypt output is really 128bit value. No need for status or any
other additional fields.

Test: net_test_stack_smp.AesCmacTest covers that
Change-Id: Iabfaa85d6f4bd5715e0bdab9d3eaf22bb5c39239

6 years agoMerge "Add support for AVRCP addressed player changed."
Joseph Pirozzo [Fri, 15 Jun 2018 18:54:57 +0000 (18:54 +0000)]
Merge "Add support for AVRCP addressed player changed."

6 years agoMerge "A2DP Offload: Log audio duration and codec metrics"
Treehugger Robot [Fri, 15 Jun 2018 17:40:32 +0000 (17:40 +0000)]
Merge "A2DP Offload: Log audio duration and codec metrics"

6 years agoClear local suspending flag when the BTA_AV_STOP_EVT event received
cheneyni [Mon, 11 Jun 2018 13:19:26 +0000 (21:19 +0800)]
Clear local suspending flag when the BTA_AV_STOP_EVT event received

The Stack would set the pending flag when received the Stop request but
did not clear it even state became Opened.  This would cuase Stack
replied Suspended immediately to Audio HAL but kept peer at Started
state and failed to handle Start request again.

This change clears the local suspending flag when BTA_AV_STOP_EVT
received and also reset all pending status when becomes Opened so it
will take effect only when Stack is changing state from Started.

Bug: 110022304
Test: Manual: (1) Play A2DP music and switch codec
              (2) Play A2DP music and change active device

Change-Id: I4b9aca33eb7eb6c40038e2082d23eb22e5830714

6 years agoMerge "Fix the reconnect issue in hfp client"
Treehugger Robot [Fri, 15 Jun 2018 06:22:30 +0000 (06:22 +0000)]
Merge "Fix the reconnect issue in hfp client"

6 years agoA2DP Offload: Log audio duration and codec metrics
Jack He [Fri, 15 Jun 2018 01:04:12 +0000 (18:04 -0700)]
A2DP Offload: Log audio duration and codec metrics

* Add A2dpOffloadAudioStats class to store metrics for A2DP offload
* Add logging statements to log A2DP start/suspend/stop events when A2DP
  offload is enabled
* Separate software encoding logging from hardware encoding logging

Bug: 109953464
Test: make, run A2DP in offload mode and dump metrics
Change-Id: I1a19c64c6b1ee530e5927dd3d13e31b00729850b

6 years agoMerge "Correctly initialize A2DP Sink codecs if A2DP Source HW offload is enabled"
Treehugger Robot [Fri, 15 Jun 2018 01:39:43 +0000 (01:39 +0000)]
Merge "Correctly initialize A2DP Sink codecs if A2DP Source HW offload is enabled"

6 years agoHearing Aid: codec and connection interval switching
Stanley Tng [Sat, 9 Jun 2018 00:09:00 +0000 (17:09 -0700)]
Hearing Aid: codec and connection interval switching

Added support to switch the LE Connection Interval between 10 msec and
20 msec. Uses the "persist.bluetooth.hearingaid.interval" to configure.

Test: Manually use hearing aid devices and switches between 10 msec and
20 msec connection interval
Bug: 79579786

Change-Id: Iec15a0c9f76afe265368fd90662ffe60a29fb27b

6 years agoCorrectly initialize A2DP Sink codecs if A2DP Source HW offload is enabled
Pavlin Radoslavov [Thu, 14 Jun 2018 23:27:54 +0000 (16:27 -0700)]
Correctly initialize A2DP Sink codecs if A2DP Source HW offload is enabled

This also fixes unit test failures if A2DP Source HW offload is enabled.

Bug: 110228602
Test: Failing unit tests now succeed
Change-Id: I36678738bfcfcce0f2e8a055f10c86cc6b3e682a

6 years agoMerge "Multi-A2DP: Fix timing and codec measurement in metrics"
Treehugger Robot [Thu, 14 Jun 2018 23:10:13 +0000 (23:10 +0000)]
Merge "Multi-A2DP: Fix timing and codec measurement in metrics"

6 years agoMulti-A2DP: Fix timing and codec measurement in metrics
Jack He [Sat, 9 Jun 2018 03:13:23 +0000 (20:13 -0700)]
Multi-A2DP: Fix timing and codec measurement in metrics

* Copy BtifMediaStats and SchedulingStats when updating metrics
  to avoid race conditions
* Do not log audio_duration_ms if session_end_us <= session_start_us
* Clear cached A2DP metrics when LogBluetoothSessionEnd() is called
* Log codec information along-side A2DP metrics
* Log whether A2DP offload is enabled along-side A2DP metrics

Multi-A2DP:
* Log LogBluetoothSessionStart at btif_a2dp_source_start_session_delayed
* Log LogBluetoothSessionEnd at btif_a2dp_source_end_session_delayed

Unit Test:
* Wrote A2DPSessionTwoUpdatesSeparatedbyEndTest that will fail if A2DP
  metrics are not cleared when LogBluetoothSessionEnd is called

Bug: 109953464
Test: make, net_test_osi::BluetoothMetricsLoggerTest,
      net_test_osi::BluetoothA2DPSessionMetricsTest
Change-Id: I6a311dce8035ce2e3f39773c260ea9eaef73e45b

6 years agoSMP_Encrypt refactor
Jakub Pawlowski [Thu, 14 Jun 2018 16:03:47 +0000 (09:03 -0700)]
SMP_Encrypt refactor

* key must be 16bit, so no need to pass it's length, and check it's
  value
* p_out being null is a bad call that should crash to be catched, not an
  error we should handle
* hash computation always succeed, don't return any errors

Test: existing unit tests cover it, i.e. AesCmacTest
Change-Id: Ifba8902f3f1a7be3c54dd7a33d9ff1e52ffd237b

6 years agoAdd tests for AES_CMAC
Jakub Pawlowski [Thu, 14 Jun 2018 07:20:13 +0000 (00:20 -0700)]
Add tests for AES_CMAC

Test: added AesCmacTest
Change-Id: I66615e581ee64debc2c25ae03e18decd2f8c8fa8

6 years agoGATTC_Discover: pass parameters directly instead of through pointer
Jakub Pawlowski [Fri, 8 Jun 2018 16:32:57 +0000 (09:32 -0700)]
GATTC_Discover: pass parameters directly instead of through pointer

Bug: 67057055
Test: manual
Change-Id: I7be853241595b336e2d4b67bc57170ee01ce6e72

6 years agoGATT database refactor
Jakub Pawlowski [Wed, 18 Apr 2018 14:31:30 +0000 (07:31 -0700)]
GATT database refactor

Move logic and data responsible for GATT Discovery into separate class.
Create clean representation of GATT database, and attributes for
storage.
Minor service discovery improvements:
* don't send requests to explore services with start handle equal to end handle.
* don't try to discover characteristic if only one handle is left at end
  of service - it uses two handles, one for definition, one for value
* if secondary service is defined before service that includes it, it
  should now be properly discovered.

Test: Added DatabaseBuilderTest, manual tests with LE HID devices, Daydream
      Controller and Clips camera.
Bug: 67057055
Change-Id: I511f4ee7c56c8fa65f012de0b6d1291321840d11

6 years agoAdd storage API to get number of bonded devices
Jacky Cheung [Thu, 29 Jun 2017 22:27:35 +0000 (15:27 -0700)]
Add storage API to get number of bonded devices

Test: manual
Change-Id: Iaded8031bf706d84cff68f78dff8feb887a159a4

6 years agoFix the reconnect issue in hfp client
Jinguang Dong [Tue, 12 Jun 2018 11:56:24 +0000 (19:56 +0800)]
Fix the reconnect issue in hfp client

The HFP client would not reconnect any more on collision scenario
as upper layer calls the connect API per 30s. which related with
CL of 5eccd90936d606e0070872b247fd3462e9c9c19b

Bug: 74518379

Test: Manual test for multiple incoming/outgoing HF connections
      between Android Wear and Handset

Signed-off-by: Kai Huang <huangkai1@huawei.com>
Change-Id: I445f3633165d8ec12f91bc5fe5a8217505318cff

6 years agoMerge "Hearing Aid - codec switching"
Treehugger Robot [Mon, 11 Jun 2018 20:06:20 +0000 (20:06 +0000)]
Merge "Hearing Aid - codec switching"

6 years agoHearing Aid - codec switching
Jakub Pawlowski [Tue, 10 Apr 2018 07:16:53 +0000 (00:16 -0700)]
Hearing Aid - codec switching

StartSendingAudio internally sets the codec to the HearingAidAudioSource.
OnDeviceAvailable callback triggers audio framework to  grab codec
configuration from HearingAidAudioSource. Those calls must be made in proper
order, otherwise audio framework will grab bad codec configuration.

This patch also remove default codec configuration, and crash if codec
configuration is not done correctly.

Test: use hearing aid supporting 24kHz codec
Change-Id: I9419d58fa8728fc8e0f0c2d2ed8d8d741309a9a3

6 years agoMerge "Add documentation for enabling PTS mode"
Treehugger Robot [Mon, 11 Jun 2018 07:42:18 +0000 (07:42 +0000)]
Merge "Add documentation for enabling PTS mode"

6 years agoMerge "Use ParcelFileDescriptor implementation in libbinder"
Treehugger Robot [Mon, 11 Jun 2018 07:27:41 +0000 (07:27 +0000)]
Merge "Use ParcelFileDescriptor implementation in libbinder"

6 years agoMerge "Send ACK for A2DP_CTRL_CMD_SUSPEND even if audio was no streaming"
Treehugger Robot [Fri, 8 Jun 2018 05:39:40 +0000 (05:39 +0000)]
Merge "Send ACK for A2DP_CTRL_CMD_SUSPEND even if audio was no streaming"

6 years agoRun the AVRCP Service interface functions on the BTA thread
Ajay Panicker [Thu, 31 May 2018 00:50:39 +0000 (17:50 -0700)]
Run the AVRCP Service interface functions on the BTA thread

Bug: 80416347
Test: Turn off Bluetooth while connected to a device we initiated the
connection to.

Change-Id: I8f10409c495213ef3117aedf66919de7c0b3d164
(cherry picked from commit 95e1a9e65f2d61523753f19d8855144672413506)

6 years agoAVRCP: Narrow the scope of the lock in Init and Cleanup
Ajay Panicker [Thu, 24 May 2018 18:26:15 +0000 (11:26 -0700)]
AVRCP: Narrow the scope of the lock in Init and Cleanup

Bug: 80227904
Test: Disable Bluetooth while connected to a device
Change-Id: I6c77e38ebaa84e4a075ef4636d6b519d4ccfb8c5
(cherry picked from commit 4369f6f7607c17ef0ab77bb52d23f20dbc54e424)

6 years agoAVRCP: Cancel all pending messages and prevent future messages after cleanup
Ajay Panicker [Tue, 22 May 2018 21:42:16 +0000 (14:42 -0700)]
AVRCP: Cancel all pending messages and prevent future messages after cleanup

Bug: 79859133
Test: Regression test and repeatedly turn Bluetooth off and on
Change-Id: I1aa05cc5430dbda1d4bae6aa9543f655baed77b4
(cherry picked from commit 85624a8015128ec0bb846e539030d11b85952323)

6 years agoSend ACK for A2DP_CTRL_CMD_SUSPEND even if audio was no streaming
Pavlin Radoslavov [Tue, 5 Jun 2018 05:18:32 +0000 (22:18 -0700)]
Send ACK for A2DP_CTRL_CMD_SUSPEND even if audio was no streaming

The A2DP_CTRL_CMD_SUSPEND command from the Audio HAL could be received
even if audio wasn't streaming before. Therefore, we should always
respond with an ACK once the command processing has been completed.

Bug: 109712592
Test: Manual: (1) Play music to Headset; (2) Select "This device" as output;
      (3) Stop playing music; (4) Select Headset as output

Change-Id: I0f5d52d14b50882931b9d19de1a2f25204fce19e
Merged-In: I0f5d52d14b50882931b9d19de1a2f25204fce19e
(cherry picked from commit 3008cfbeb15605adb0c925d394d9e9934f74d6f6)

6 years agoRevert "Don't start the authentication when peer device already started it"
Jakub Pawlowski [Sat, 2 Jun 2018 06:34:40 +0000 (06:34 +0000)]
Revert "Don't start the authentication when peer device already started it"

This reverts commit e75bd3aa3588a5616dfad6fe9f253cb58e65e3ed.

Reason for revert: It breaks pairing of Classic HID devices with Phones

Change-Id: I5dd703934c56387d279d350a36c135245a669b29
Test: Pair with Bluetooth Classic HID keyboard
Bug: 79941483

6 years agoDo completion callback during failed security authenication
Stanley Tng [Mon, 4 Jun 2018 17:34:45 +0000 (10:34 -0700)]
Do completion callback during failed security authenication

This CL fixes a regression caused by the earlier commit SHA 6269f02 where the
completion callback for this failed security authenication attempt is
rejected incorrectly. The corner case is when the authenication failed
but the bonding address matches the current address.

Test: Run SL4A "BleCocTest:test_coc_secured_connection_throughput"
Change-Id: I68b75b0e96d2762dcd2862787d51aeb90d7b90a0

6 years agoAdd documentation for enabling PTS mode
Hansong Zhang [Wed, 30 May 2018 23:08:28 +0000 (16:08 -0700)]
Add documentation for enabling PTS mode

Test: not needed
Change-Id: I8a65e3a4bac4de72ec20c73e6b553f2565c9e1de

6 years agoRevert "GATT: Fix GATT error response for execute write"
Jakub Pawlowski [Thu, 24 May 2018 21:14:18 +0000 (21:14 +0000)]
Revert "GATT: Fix GATT error response for execute write"

This reverts commit b8a5b213a63def7c0a0d09d322603ae5a9abd435.

Reason for revert: This patch does not make Fluoride comply with BT Spec,
it just make a false assumption to pass a test case.

Change-Id: I023b7673c52522e7c1a318f5b9596ebb4fbc99ec

6 years agoAdd support for AVRCP addressed player changed.
Joseph Pirozzo [Thu, 31 May 2018 17:26:08 +0000 (10:26 -0700)]
Add support for AVRCP addressed player changed.

When the addressed player notification comes in decode it and provide
the status up to the java layer correctly.

Bug: 72495707
Test: change media player on paired phone and observe callback.
Change-Id: Iebaae524c06f5c4b7bc962d1f55d539910510e1f

6 years agoAVRCP: Reject invalid PlayItem and SetAddressedPlayer command
Hansong Zhang [Wed, 30 May 2018 21:16:23 +0000 (14:16 -0700)]
AVRCP: Reject invalid PlayItem and SetAddressedPlayer command

* Use CType REJECT to reject invalid PlayItem command
* Reject SetAddressPlayer command as it is not implemented

Bug: 80481276
Bug: 80483247
Test: PTS AVRCP/TG/MCN/NP/BI-01-C
Change-Id: I837f6d2661e94e09afaa72a9c0c77d5c1ffe9e98
(cherry picked from commit fe5d973670cc6f95d7431f5a0699a326032e8b06)

6 years agoMerge changes from topic "avrcp-addressed-player-changed"
Treehugger Robot [Wed, 30 May 2018 16:42:33 +0000 (16:42 +0000)]
Merge changes from topic "avrcp-addressed-player-changed"

* changes:
  Send addressed and available player change for PTS test
  Add respond track not selected interim when register notification
  Send UID 0 for track changed if there is no media ID

6 years agoUse ParcelFileDescriptor implementation in libbinder
Ryo Hashimoto [Wed, 30 May 2018 07:34:19 +0000 (16:34 +0900)]
Use ParcelFileDescriptor implementation in libbinder

Bug: 80377815
Test: build
Change-Id: I0a415181827d6c4dc2243cf14b9fb120effce982

6 years agoSend addressed and available player change for PTS test
tedwang [Fri, 18 May 2018 10:16:40 +0000 (18:16 +0800)]
Send addressed and available player change for PTS test

Implement HandleAddressPlayerUpdate() and HandAvailablePlayerUpdate()
for PTS test.

Bug: 79375787 79376305
Test: PTS Test AVRCPTG/MPS/BV-05-C AVRCP/TG/MPS/BV-07-C
Change-Id: I6b976af8bdd1afcc9799c50c8e558939cf7be187
Merged-In: I6b976af8bdd1afcc9799c50c8e558939cf7be187
(cherry picked from commit 7a3f78eaa6294d5079312dc9f0e5c7d5c6b5e059)

6 years agoAdd respond track not selected interim when register notification
tedwang [Wed, 16 May 2018 11:51:26 +0000 (19:51 +0800)]
Add respond track not selected interim when register notification

Respond interim with Identifier 0xFFFFFFFFFFFFFFFF register
notification for EVENT_TRACK_CHANGE for pts test

Bug: 79378129
Test: PTS AVRCP/TG/NFY/BV-04-C
Change-Id: Ia861bf4682e9daf9c7c3842df9f95381171da574
Merged-In: Ia861bf4682e9daf9c7c3842df9f95381171da574
(cherry picked from commit a25fca2acb30aafab9cedc521888b794b703eff3)

6 years agoSend UID 0 for track changed if there is no media ID
Ajay Panicker [Tue, 8 May 2018 23:34:04 +0000 (16:34 -0700)]
Send UID 0 for track changed if there is no media ID

Some carkits need the track changed UID to change even though we
explicitly report that UID's are refreshed on any now playing list
change. UID 0 is special since it represents that the song has changed
and forces an update.

Bug: 72824896
Test: Tested with Audi carkit where Spotify wasn't updating past the
first song previously.

Change-Id: I033f9a2f96acfde25922d6912a4927b95fb89596
Merged-In: I033f9a2f96acfde25922d6912a4927b95fb89596
(cherry picked from commit 2789ae2b57085aad446d7e062f66f5d83cf26e0b)

6 years agoLE Create Connection Complete - crash on Command Disallowed
Jakub Pawlowski [Tue, 29 May 2018 22:28:15 +0000 (15:28 -0700)]
LE Create Connection Complete - crash on Command Disallowed

When LE Create Connection Complete is received with status "Command
Disallowed", we can't tell which state we should transition to. This
can be triggered only in case of rare race condition. Crash to recover.

This was introduced in 24adb37e4106bf8544c7729d34451fdf2777c4dc, when
generic handling of all errors to this event was added.

Bug: 77429706
Test: sl4a GattConnectTest
Change-Id: I888861461da296876d97e8784a3dc7c53130fb51

6 years agoMerge "Fix race condition in LE Create Connection Cancel handling"
Jakub Pawlowski [Wed, 30 May 2018 02:43:52 +0000 (02:43 +0000)]
Merge "Fix race condition in LE Create Connection Cancel handling"

6 years agoBluetooth HFP: Use WBS by default (1/5)
Hansong Zhang [Tue, 17 Apr 2018 23:00:30 +0000 (16:00 -0700)]
Bluetooth HFP: Use WBS by default (1/5)

Bug: 72624793
Test: compilation
Change-Id: Ia64c49210769581bba5be7354b67fa50d89cfdaa

6 years agoExplicitly stop streaming when switching streaming to another device
Pavlin Radoslavov [Mon, 28 May 2018 03:06:20 +0000 (20:06 -0700)]
Explicitly stop streaming when switching streaming to another device

* Explicitly call btif_av_stream_stop() inside
  btif_a2dp_source_end_session_delayed() when ending the session.
  It should be called regardless whether we are using software
  or hardware based encoding.
* Removed extra btif_av_stream_stop() call inside
  BtifAvSource::SetActivePeer(), because it is not needed anymore.
  It is replaced by the call inside btif_a2dp_source_end_session_delayed()
* Added "peer_address" argument to btif_av_stream_stop()
  so it can be used to stop the stream to a specific peer.
* Fix an issue inside bta_av_chk_2nd_start() that was triggering
  extra start request to some headsets - the extra start request
  was blocking follow-up legitimate requests.
* Simplify the logic inside bta_av_do_start() so it is easier to
  identify issues when start streaming. The actual processing logic
  itself is not changed.
* Add extra log messages or update existing ones to help debug
  similar issues in the future.

Bug: 79909084
Test: Manual: streaming A2DP, connect a new device, change active device
Change-Id: Id583aa44aec7082dc5f94532e6b41a7ea33813a1
Merged-In: Id583aa44aec7082dc5f94532e6b41a7ea33813a1
(cherry picked from commit 7b97d4d4a45d25a4ac80f3b59a40c115f0a03af4)

6 years agoFix race condition in LE Create Connection Cancel handling
Jakub Pawlowski [Tue, 29 May 2018 19:52:17 +0000 (12:52 -0700)]
Fix race condition in LE Create Connection Cancel handling

Message with description of the issue being fixed:
https://android-review.googlesource.com/c/platform/system/bt/+/646600#message-4781dd6e3e74d8b11ef716bbf58edbc64645f18c

Bug: 77429706
Change-Id: I1c076c7f033fc3d1aaf47887ce691b6325721d85

6 years agoLinux build and linking fix
Jakub Pawlowski [Sat, 26 May 2018 04:07:38 +0000 (21:07 -0700)]
Linux build and linking fix

Test: run bluetoothtbd on Linux
Change-Id: Id9d913f8766b71c77696df25f74a8e33ba57523e

6 years agoMerge "Don't refresh GATT database after bonding"
Jakub Pawlowski [Tue, 29 May 2018 15:03:54 +0000 (15:03 +0000)]
Merge "Don't refresh GATT database after bonding"

6 years agoA2DP Offload: Avoid Offload_start/stop from remote
Sunny Kapdi [Fri, 25 May 2018 16:29:16 +0000 (09:29 -0700)]
A2DP Offload: Avoid Offload_start/stop from remote

When DUT is A2DP Source, and remote initiates start
we suspend it immediately. There is no need to do
Offload_start/stop in this case. Also, the offload
start/stop was coming out of sync here.

Bug: 80284000
Test: Manual
Change-Id: If54c28188e7432ebcba639cd2fbfe81536c2f2e6

6 years agoInform AVRCP Controller before cleaning up.
Joseph Pirozzo [Fri, 25 May 2018 19:31:06 +0000 (12:31 -0700)]
Inform AVRCP Controller before cleaning up.

Move the JNI callback earlier in the procedure before the device info is
zeroed out such that the higher levels know which device disconnected.

Bug: 80265765
Test: Disconnect AVRCP and verify bluetooth_manager reports it is
disconnected.

Change-Id: I1c69341227f4c1c1662022a4a77e1752f6306d2e

6 years agoHFP: Only advance BTIF queue for outgoing connections
Jack He [Thu, 24 May 2018 22:53:27 +0000 (15:53 -0700)]
HFP: Only advance BTIF queue for outgoing connections

* Modify HFP btif layer to only advance queue when there is a
  connection outcome for outgoing connections
* During an ACL collision, incoming connection may preempt outgoing
  connection and come back to the upper layer in a separate control
  block. In this case, we should not advance the btif queue until the
  outgoing connection sends callback to the btif layer
* When RFCOMM connection is successful, but SLC connection failed, we
  should also send callback to Java layer and advance the queue. We
  should only do this when transition from RFCOMM connected to
  Disconnected, not from SLC connected to Disconnected
* We should only advance the queue after sending connection state update
  to Java layer
* This prevents the crash in connect_int() where we check for any
  control block that is left in connecting state

Bug: 80251999
Test: connect HFP devices rapidly to trigger ACL collision
      testplans/details/166812/3975
Change-Id: Iba3736c77d8ef4a4701896461042466c26bc4820

6 years agoHFP: Fix ACL collision handling and WBS update
Jack He [Fri, 25 May 2018 01:59:13 +0000 (18:59 -0700)]
HFP: Fix ACL collision handling and WBS update

* Correctly set control block handle when passing WBS event data to
  upstream
* Correctly reject local outgoing connection when a colliding incoming
  connection is connected to RFCOMM
* Add more logging to help with future debugging

Bug: 80251999
Test: connect HFP devices rapidly and toggle Bluetooth rapidly
      testplans/details/166812/3975
Change-Id: I90616d70335ca68c40251fb722146924c4801cbe

6 years agoDon't refresh GATT database after bonding
Jakub Pawlowski [Wed, 16 May 2018 21:46:40 +0000 (14:46 -0700)]
Don't refresh GATT database after bonding

According to the Bluetooth spec: "For a given client, the server shall have
one set of attributes.".

If we discover services before bonding, we should be fine using them
afterwards, without need to refresh whole GATT database.

This change should speed up bonding HOGP devces by around one second.

Refreshment of GATT database was tied to connection parameter
reenabling. Make sure bonding does not disable connection parameter
change.

Bug: 67057055
Test: Bond with HOGP device, verify profile is connected properly
Change-Id: I1e738c56e211cf3d9234b424f354bf3e468227aa

6 years agoMerge "Linux build fix"
Treehugger Robot [Fri, 25 May 2018 21:09:38 +0000 (21:09 +0000)]
Merge "Linux build fix"

6 years agoFix log level - requesting MTU is not error
Jakub Pawlowski [Thu, 24 May 2018 19:27:10 +0000 (12:27 -0700)]
Fix log level - requesting MTU is not error

Test: compilation
Change-Id: Idf99af22cf4d29f6fb3da08e86e36b3394617c4f

6 years agoLinux build fix
Jakub Pawlowski [Fri, 25 May 2018 16:31:26 +0000 (09:31 -0700)]
Linux build fix

Test: compile on linux
Change-Id: I831df72da8bdec17c4d9c87ebdfb333024eb964c

6 years agoMerge "Add separate sniff mode settings for gamepads"
Treehugger Robot [Thu, 24 May 2018 22:52:05 +0000 (22:52 +0000)]
Merge "Add separate sniff mode settings for gamepads"

6 years agoMerge changes from topic "ds4-support"
Treehugger Robot [Thu, 24 May 2018 22:52:05 +0000 (22:52 +0000)]
Merge changes from topic "ds4-support"

* changes:
  Add UHID GET_REPORT functionality
  Option to send data report through BTA_HhSetReport