OSDN Git Service

android-x86/system-bt.git
6 years agoMerge "Add helper classes to auto indent newlines for ostreams"
Ajay Panicker [Thu, 10 May 2018 22:51:31 +0000 (15:51 -0700)]
Merge "Add helper classes to auto indent newlines for ostreams"
am: e3c041c4a4

Change-Id: Ifbcafaa32c70a3400b609772e0ec55bf1136abef

6 years agoMerge "Add helper classes to auto indent newlines for ostreams"
Treehugger Robot [Thu, 10 May 2018 22:35:02 +0000 (22:35 +0000)]
Merge "Add helper classes to auto indent newlines for ostreams"

6 years agoMerge "Hearing Aid: Add dumpsys log for audio packet"
Hansong Zhang [Thu, 10 May 2018 22:01:45 +0000 (15:01 -0700)]
Merge "Hearing Aid: Add dumpsys log for audio packet"
am: 5ac698c04e

Change-Id: Id4a1078b2197eb60b321dcffbe76095ad0aee4b7

6 years agoMerge "Hearing Aid: Add dumpsys log for audio packet"
Treehugger Robot [Thu, 10 May 2018 21:23:46 +0000 (21:23 +0000)]
Merge "Hearing Aid: Add dumpsys log for audio packet"

6 years agoHearingAid RemoveDevice - don't crash when profile not enabled
Jakub Pawlowski [Thu, 10 May 2018 20:20:25 +0000 (13:20 -0700)]
HearingAid RemoveDevice - don't crash when profile not enabled
am: f7c7cd2120

Change-Id: If3b9cbe1c96ac890c40726c034e71a4314138036

6 years agoHearingAid RemoveDevice - don't crash when profile not enabled
Jakub Pawlowski [Thu, 10 May 2018 13:42:43 +0000 (06:42 -0700)]
HearingAid RemoveDevice - don't crash when profile not enabled

Bug: 79468820
Test: Unbond non-hearing aid device when profile not enabled
Change-Id: I2a87f8725447045e7bc5b2a33facf1ce14b47c54

6 years agoHearing Aid: Add dumpsys log for audio packet
Hansong Zhang [Wed, 9 May 2018 21:39:56 +0000 (14:39 -0700)]
Hearing Aid: Add dumpsys log for audio packet

Add log for audio drops from audio HAL and buffer overflow
Add log for device capabilities and HiSyncId

Sample output:

Hearing Aid Manager:
  <device1> connected
    binaural right 0x...
    Packet counts (enqueued/flushed)                        : 73557 / 773
    Frame counts (enqueued/flushed)                         : 73557 / 773
  <device2> connected
    binaural left 0x...
    Packet counts (enqueued/flushed)                        : 74172 / 886
    Frame counts (enqueued/flushed)                         : 74172 / 886
  Hearing Aid Audio HAL:
    Counts (underflow)                                      : 0
    Bytes (underflow)                                       : 0
    Last update time ago in ms (underflow)                  : 0

Test: manual
Bug: 69623109
Change-Id: I5021b9214828b1846506638000f29af7343a3354

6 years agoMerge "A2DP: Add logging when A2DP fails to open"
Jack He [Thu, 10 May 2018 01:08:49 +0000 (18:08 -0700)]
Merge "A2DP: Add logging when A2DP fails to open"
am: 9f5ab2434e

Change-Id: I825570e840f65192e4746eef762e1f8c36f6c135

6 years agoMerge "A2DP: Add logging when A2DP fails to open"
Treehugger Robot [Thu, 10 May 2018 00:58:48 +0000 (00:58 +0000)]
Merge "A2DP: Add logging when A2DP fails to open"

6 years agoMerge "Fix LE cancel open when physical connection is established but not ready"
Vinit Deshpande [Thu, 10 May 2018 00:18:59 +0000 (17:18 -0700)]
Merge "Fix LE cancel open when physical connection is established but not ready"
am: cd40bfb8d7

Change-Id: I3e27ee66923fbc5eb6bd0357c6913ea82b904857

6 years agoMerge "Fix LE cancel open when physical connection is established but not ready"
Vinit Deshpande [Wed, 9 May 2018 23:58:48 +0000 (23:58 +0000)]
Merge "Fix LE cancel open when physical connection is established but not ready"

6 years agoA2DP: Add logging when A2DP fails to open
Jack He [Wed, 9 May 2018 22:44:09 +0000 (15:44 -0700)]
A2DP: Add logging when A2DP fails to open

* Make sure we output a log line whenever A2DP start request returns a
  failure state, namingly:
  - A2DP_CTRL_ACK_FAILURE
  - A2DP_CTRL_ACK_INCALL_FAILURE
  - A2DP_CTRL_ACK_DISCONNECT_IN_PROGRESS

Bug: 74988740
Test: make, logging only change
Change-Id: I63280d6280bf9c3d3ee6c578c1be332f8a9a3be0

6 years agoFix LE cancel open when physical connection is established but not ready
WENTAO WANG [Mon, 20 Nov 2017 21:10:07 +0000 (13:10 -0800)]
Fix LE cancel open when physical connection is established but not ready

Issue:
Cancel open does not work when the physical connection is established
but negotiation is not finished.

Fix:
Close the physical connection and release resources when fitting in this
situation.

Bug: 64230040
Test: test_cancel_open_ble_process
Change-Id: Ia23b5f3aab427b333d9d484b97e4cd4ff49f5319

6 years agoMerge "Fix PTS: TC_GATT_SR_UNS_BI_01_C sends unsupported opcode"
Stanley Tng [Wed, 9 May 2018 20:29:13 +0000 (13:29 -0700)]
Merge "Fix PTS: TC_GATT_SR_UNS_BI_01_C sends unsupported opcode"
am: 11e1274a05

Change-Id: I7e48817c7b29522b2912d48ef1282282e7e833a9

6 years agoMerge "Fix PTS: TC_GATT_SR_UNS_BI_01_C sends unsupported opcode"
Treehugger Robot [Wed, 9 May 2018 20:23:34 +0000 (20:23 +0000)]
Merge "Fix PTS: TC_GATT_SR_UNS_BI_01_C sends unsupported opcode"

6 years agoAdd helper classes to auto indent newlines for ostreams
Ajay Panicker [Thu, 3 May 2018 19:58:53 +0000 (12:58 -0700)]
Add helper classes to auto indent newlines for ostreams

Bug: 79167906
Test: adb shell dumpsys bluetooth_manager
Change-Id: I54484181abc438e90ade771fca6943c2b303e4db

6 years agoFix PTS: TC_GATT_SR_UNS_BI_01_C sends unsupported opcode
Stanley Tng [Wed, 9 May 2018 17:39:37 +0000 (10:39 -0700)]
Fix PTS: TC_GATT_SR_UNS_BI_01_C sends unsupported opcode

In this PTS test, add code to send back an unsupported error response
when an unsupported OpCode is received.

Bug: 79347869
Test: Rerun and pass PTS test
Change-Id: Ibf95dbc18dabbe201850da675c7a1b2739624de9

6 years agoMerge "Handle unbonding in Hearing Aid profile"
Jakub Pawlowski [Wed, 9 May 2018 08:12:24 +0000 (01:12 -0700)]
Merge "Handle unbonding in Hearing Aid profile"
am: ab22148a79

Change-Id: Icaee7201a4e47b471c60dcbc54eb2984d0cfa19f

6 years agoMerge "Handle unbonding in Hearing Aid profile"
Jakub Pawlowski [Wed, 9 May 2018 08:06:15 +0000 (08:06 +0000)]
Merge "Handle unbonding in Hearing Aid profile"

6 years agoMerge "Remove unused `tags` property from Android.bp files"
Dan Willemsen [Wed, 9 May 2018 06:06:07 +0000 (23:06 -0700)]
Merge "Remove unused `tags` property from Android.bp files"
am: 2b737b856d

Change-Id: Ie67b2d049583b8c9b25d4b0e8d1c26a25f700309

6 years agoMerge "Remove unused `tags` property from Android.bp files"
Dan Willemsen [Wed, 9 May 2018 05:59:03 +0000 (05:59 +0000)]
Merge "Remove unused `tags` property from Android.bp files"

6 years agoFetch the presentation position only if the audio state is STARTED
Pavlin Radoslavov [Wed, 9 May 2018 03:27:34 +0000 (20:27 -0700)]
Fetch the presentation position only if the audio state is STARTED
am: 61d1e86c5b

Change-Id: I693595f6bf4c5a95c08d5859887f9f5ef41242bd

6 years agoMerge "HFP: Remove parameter to start/stopScoUsingVirtualVoiceCall"
android-build-prod (mdb) [Wed, 9 May 2018 01:37:58 +0000 (18:37 -0700)]
Merge "HFP: Remove parameter to start/stopScoUsingVirtualVoiceCall"
am: 6e938867c3

Change-Id: I04318b2d604645b7aa566a4d3422df14ff0f50dc

6 years agoFetch the presentation position only if the audio state is STARTED
Pavlin Radoslavov [Wed, 9 May 2018 01:00:24 +0000 (18:00 -0700)]
Fetch the presentation position only if the audio state is STARTED

The audio HAL will fetch the audio presentation position (for the
purpose of delay reporting if the Headset supports it) only if the
audio state is STARTED.
Otherwise, it will use the default value (e.g., the one used
when the Headset does not support delay reporting).

This avoids unnecessary transient re-opening of the HAL control path
between the Audio framework and Bluetooth native stack (e.g., during
shutdown).

Bug: 78360113
Test: Manual - A2DP streaming with Headsets that support delay reporting
Change-Id: I56f7e9373ba27606913c74fa818da40305df85d4

6 years agoMerge "HFP: Remove parameter to start/stopScoUsingVirtualVoiceCall"
android-build-prod (mdb) [Wed, 9 May 2018 00:25:12 +0000 (00:25 +0000)]
Merge "HFP: Remove parameter to start/stopScoUsingVirtualVoiceCall"

6 years agoRemove unused `tags` property from Android.bp files
Dan Willemsen [Wed, 9 May 2018 00:08:54 +0000 (17:08 -0700)]
Remove unused `tags` property from Android.bp files

The tags property is (and has always been) unused by Soong. The property has
been defined as a list of strings, and the `androidmk` converted any
LOCAL_MODULE_TAGS entries over to it, but we've never done anything with it.

In preparation for removing the definition from Soong, I'm removing it from all
Android.bp files in the tree.

Since this has never done anything, this is a no-op, but if you really did want
the Android.mk behavior, the proper way to define a module to be installed in
userdebug / eng builds is to use PRODUCT_PACKAGES_DEBUG or PRODUCT_PACKAGES_ENG
in the appropriate product makefile.

Change-Id: I48cba711acbc030a98aea674016a0d53f8b5e4aa
Exempt-From-Owner-Approval: global no-op build change
Test: remove `tags` from Soong, see errors go away.

6 years agoHandle unbonding in Hearing Aid profile
Jakub Pawlowski [Tue, 8 May 2018 14:44:43 +0000 (07:44 -0700)]
Handle unbonding in Hearing Aid profile

Bug: 69623109
Change-Id: I3b1f778e414511a3748cebd2b0e233d638cd4d43
Fixes: 79207134
Test: unbond from Hearing Aid when connected or disconnected from it

6 years agoMerge "Return early if vendor-specific command fails"
android-build-prod (mdb) [Tue, 8 May 2018 17:46:03 +0000 (10:46 -0700)]
Merge "Return early if vendor-specific command fails"
am: c2e46139c9

Change-Id: I277503a4a8c5b86536a77c97c6dec3417b56fe9a

6 years agoMerge "Return early if vendor-specific command fails"
android-build-prod (mdb) [Tue, 8 May 2018 17:37:04 +0000 (17:37 +0000)]
Merge "Return early if vendor-specific command fails"

6 years agoMerge "Send correct key state and ignore keys from inactive device (1/2)"
Ajay Panicker [Tue, 8 May 2018 16:45:33 +0000 (09:45 -0700)]
Merge "Send correct key state and ignore keys from inactive device (1/2)"
am: a7b6d3a8e1

Change-Id: Ie47e3adbafaa6c7a15bd5fc241324a16f07b2aaf

6 years agoMerge "Send correct key state and ignore keys from inactive device (1/2)"
Ajay Panicker [Tue, 8 May 2018 16:37:15 +0000 (16:37 +0000)]
Merge "Send correct key state and ignore keys from inactive device (1/2)"

6 years agoReturn early if vendor-specific command fails
Myles Watson [Thu, 3 May 2018 18:15:50 +0000 (11:15 -0700)]
Return early if vendor-specific command fails

Add CHECK() statements to crash if the callback is passed the incorrect
opcode or if there are no parameters.

Bug: 76192234
Bug: 77495521
Test: Start Bluetooth with a BT 3.0 chip (or a simulated one)
Change-Id: Iddd9a8503b2cfd52b16fb1c59f40e108b478e7b6

6 years agoMerge "Fixed PTS: TC_GATT_SR_GAR_BI_01_C failure"
android-build-prod (mdb) [Tue, 8 May 2018 01:16:19 +0000 (18:16 -0700)]
Merge "Fixed PTS: TC_GATT_SR_GAR_BI_01_C failure"
am: 2ff331f615

Change-Id: I0e6828ab55776941bd1e6315ebf83322b29b72f2

6 years agoMerge "Fixed PTS: TC_GATT_SR_GAR_BI_01_C failure"
android-build-prod (mdb) [Tue, 8 May 2018 01:03:03 +0000 (01:03 +0000)]
Merge "Fixed PTS: TC_GATT_SR_GAR_BI_01_C failure"

6 years agoFixed PTS: TC_GATT_SR_GAR_BI_01_C failure
Stanley Tng [Mon, 7 May 2018 21:58:36 +0000 (14:58 -0700)]
Fixed PTS: TC_GATT_SR_GAR_BI_01_C failure

When the GATT Read Request has bad handle parameters, returns the
GATT_INVALID_HANDLE error code instead of GATT_INVALID_PDU.

Bug: 79340029
Test: Rerun PTS
Change-Id: I9de576076d7f7aece0831ef57b01c07a24209010

6 years agoSend correct key state and ignore keys from inactive device (1/2)
Ajay Panicker [Fri, 4 May 2018 21:30:45 +0000 (14:30 -0700)]
Send correct key state and ignore keys from inactive device (1/2)

Also make it clearer whether the key state is pushed or released.

Bug: 79178216
Test: Run host native test net_test_avrcp
Change-Id: I8595ac97718bcb2af8f33643df4b9c8059a1b30b

6 years agoHFP: Remove parameter to start/stopScoUsingVirtualVoiceCall
Jack He [Thu, 3 May 2018 23:37:09 +0000 (16:37 -0700)]
HFP: Remove parameter to start/stopScoUsingVirtualVoiceCall

* Since HFP SCO routing is managed by setActiveDevice, there is no need
  for an input parameter to start/stopScoUsingVirtualVoiceCall

Bug: 76114959
Test: build
Change-Id: I2a3f9f7cb1191e2831d30630b2e0c3bee4a0acdb
(cherry picked from commit 426e87e3bada2116580e74815c4e03db78b8105a)

6 years agoMerge "BTM_BleClearBgConnDev: Return if there is no BLE"
android-build-prod (mdb) [Mon, 7 May 2018 06:52:14 +0000 (23:52 -0700)]
Merge "BTM_BleClearBgConnDev: Return if there is no BLE"
am: 1799f2fd0c

Change-Id: I59fd33764c7255fc5081ae7312764a36ea213dbe

6 years agoMerge "BTM_BleClearBgConnDev: Return if there is no BLE"
android-build-prod (mdb) [Mon, 7 May 2018 06:43:54 +0000 (06:43 +0000)]
Merge "BTM_BleClearBgConnDev: Return if there is no BLE"

6 years agoImplement GetTotalNumberOfItems response for AVRCP Browsing
Ajay Panicker [Sat, 5 May 2018 00:10:21 +0000 (17:10 -0700)]
Implement GetTotalNumberOfItems response for AVRCP Browsing
am: 0128c377b9

Change-Id: Ide66d983cb695d264c36229ff7f238e92e080d35

6 years agoImplement GetTotalNumberOfItems response for AVRCP Browsing
Ajay Panicker [Fri, 27 Apr 2018 13:59:22 +0000 (06:59 -0700)]
Implement GetTotalNumberOfItems response for AVRCP Browsing

Bug: 78636552
Test: run host test net_test_avrcp
Change-Id: Ie05d23874317978eb619d0e56a89f2c880166a52
Merged-In: Ie05d23874317978eb619d0e56a89f2c880166a52
(cherry picked from commit 16aa6a075e5cbb7c97bbc639b876221038212b62)

6 years agoIncrease the A2DP version from 1.2 to 1.3
Pavlin Radoslavov [Fri, 4 May 2018 18:39:43 +0000 (11:39 -0700)]
Increase the A2DP version from 1.2 to 1.3
am: c35f912d29

Change-Id: Ic022543294f5c46e129fcbc1b7d73daf56ac42fe

6 years agoBTM_BleClearBgConnDev: Return if there is no BLE
Myles Watson [Fri, 4 May 2018 17:15:46 +0000 (10:15 -0700)]
BTM_BleClearBgConnDev: Return if there is no BLE

Bug: 77495521
Bug: 76192234
Test: Start Bluetooth with a BT 3.0 chip (or a simulated one)
Change-Id: I718b7532bbba6100dd51c0677a44d41a2db0ce26

6 years agoIncrease the A2DP version from 1.2 to 1.3
Pavlin Radoslavov [Wed, 2 May 2018 22:09:42 +0000 (15:09 -0700)]
Increase the A2DP version from 1.2 to 1.3

Some headsets do not support properly the AVDTP 1.3 Delay Reporting
if the A2DP version is 1.2 .

Bug: 78409461
Test: Manual with Headsets that support AVDTP 1.3 Delay Reporting
      TestTracker/161070
Change-Id: Ia1e3afb3b5159101bc65b036ca5bd9f55ed4c431

6 years agobta: Only call get_acl_data_size_ble for LE
Myles Watson [Thu, 3 May 2018 22:43:44 +0000 (15:43 -0700)]
bta: Only call get_acl_data_size_ble for LE
am: a11bb2dcc2

Change-Id: I20aab54c5a82166c5497b0142819b3b8d143acec

6 years agobta: Only call get_acl_data_size_ble for LE
Myles Watson [Thu, 3 May 2018 18:13:55 +0000 (11:13 -0700)]
bta: Only call get_acl_data_size_ble for LE

Pass 0xFFFF (max uint16_t) to GAP_ConnOpen, which will call
get_acl_data_size_ble() to correct the value, but only when the
connection type is LE.

Bug: 77495521
Bug: 76192234
Test: Start Bluetooth with a BT 3.0 chip (or a simulated one)
Change-Id: If46ea249081fc058faf09bcb5149f21d8baf7aa7

6 years agoMerge "Add AVRCP native logging to dumpsys"
Ajay Panicker [Thu, 3 May 2018 20:16:22 +0000 (13:16 -0700)]
Merge "Add AVRCP native logging to dumpsys"
am: a0cebcac0a

Change-Id: I6f9493b23209f3f6bd0714f98d6a45d046205636

6 years agoMerge "Add AVRCP native logging to dumpsys"
Ajay Panicker [Thu, 3 May 2018 20:08:53 +0000 (20:08 +0000)]
Merge "Add AVRCP native logging to dumpsys"

6 years agoHID: Update state to disconnected in virtual unplug
Hemant Gupta [Thu, 3 May 2018 10:12:42 +0000 (03:12 -0700)]
HID: Update state to disconnected in virtual unplug
am: 126397bc6e

Change-Id: I822afa75804afceee13a7b6cf6ef00d57764b31b

6 years agoHID: Update state to disconnected in virtual unplug
Hemant Gupta [Fri, 2 Mar 2018 04:59:25 +0000 (10:29 +0530)]
HID: Update state to disconnected in virtual unplug

Usecase:
1.Pair and connect DUT with Remote device
2.Disconnect Remote device from DUT (Settings menu)
3.Connect to Remote device from settings menu when Remote will not be
  advertising.
4.With in 30 secs of connect command, delete the stored link key and then pair
  and connect again to Remote device from settings menu
  (when RD is advertising).

Expected Result:
Remote device should connect successfully.

Observed Result:
Remote device is shown in paired devices(settings menu)but not connected.

Root cause:
When virtual unplug happens device state is not cleared properly. So next
time when we are trying to connect its going to connected state.

Fix:
Update the current device state to BTHH_CONN_STATE_CONNECTING to
BTIF_HH_DEV_DISCONNECTED when virtual unplug happens.

Test: Issue is not seen after above steps

Fixes: 74082929
Change-Id: I8a325987ff5eb0a8e4f8708fc7c76b8a9ade6ccf

6 years agoUse weak pointers instead of base::Unretained to prevent use after free
Ajay Panicker [Thu, 3 May 2018 01:31:47 +0000 (18:31 -0700)]
Use weak pointers instead of base::Unretained to prevent use after free
am: 0d33f58fe7

Change-Id: Ifb282b1ed69dac0494e509eca5a837f50e5451bf

6 years agoUse weak pointers instead of base::Unretained to prevent use after free
Ajay Panicker [Wed, 2 May 2018 00:29:07 +0000 (17:29 -0700)]
Use weak pointers instead of base::Unretained to prevent use after free

Bug: 78517259
Test: Compile and switch users while AVRCP is connected
Change-Id: I9eb4482e4de52fed7750747afdc7cfb5402615a4

6 years agoAdd AVRCP native logging to dumpsys
Ajay Panicker [Wed, 2 May 2018 23:23:13 +0000 (16:23 -0700)]
Add AVRCP native logging to dumpsys

Example output
AVRCP Target Native Service: 2 devices
  d4:90:9c:0a:48:d0
    Current Volume: 42
    Current Browsed Player ID: -1
    Registered Notifications:
      Play Status
    Last Play State: 2
    Last Song Sent ID: ""
    Current Folder: ""
    MTU Sizes: CTRL=1020 BROWSE=332

Bug: 79167906
Test: adb shell dumpsys bluetooth_manager
Change-Id: I749dc3c568ac7793ac924ab1e46c3fc7ae42a260

6 years agoMerge "Ignore volume changed events from the non-active device"
android-build-prod (mdb) [Wed, 2 May 2018 20:14:57 +0000 (13:14 -0700)]
Merge "Ignore volume changed events from the non-active device"
am: f38c2335f1

Change-Id: I60ce1dc8c3abbc25629b56564086cfca2239946a

6 years agoMerge "Ignore volume changed events from the non-active device"
android-build-prod (mdb) [Wed, 2 May 2018 19:59:48 +0000 (19:59 +0000)]
Merge "Ignore volume changed events from the non-active device"

6 years agoMerge "Hearing Aid: leave some radio time for other devices"
android-build-prod (mdb) [Wed, 2 May 2018 18:26:27 +0000 (11:26 -0700)]
Merge "Hearing Aid: leave some radio time for other devices"
am: 792ef286f2

Change-Id: I4c46ec9ed8f3eb882dc8974a3448276a83fea250

6 years agoMerge "Hearing Aid: leave some radio time for other devices"
android-build-prod (mdb) [Wed, 2 May 2018 18:19:53 +0000 (18:19 +0000)]
Merge "Hearing Aid: leave some radio time for other devices"

6 years agoIgnore volume changed events from the non-active device
Ajay Panicker [Wed, 2 May 2018 17:05:24 +0000 (10:05 -0700)]
Ignore volume changed events from the non-active device

Bug: 78251684
Test: Run host native test net_test_avrcp
Change-Id: I164e9ded88c804da2ce8191c5f58cc053cfa6ecd

6 years agoMerge "Use weak pointers to prevent callbacks from executing after cleanup"
Ajay Panicker [Wed, 2 May 2018 18:01:53 +0000 (11:01 -0700)]
Merge "Use weak pointers to prevent callbacks from executing after cleanup"
am: 12f48d19e7

Change-Id: I9cad9114d2233330230fcc266b2015fbd8fe5d3a

6 years agoMerge "Use the wrapped volume interface with the AVRCP conneciton handler"
Ajay Panicker [Wed, 2 May 2018 18:01:33 +0000 (11:01 -0700)]
Merge "Use the wrapped volume interface with the AVRCP conneciton handler"
am: 6acb481634

Change-Id: I4016ab7a8121cf626f35a7ceda094258ecb01d61

6 years agoMerge "Use weak pointers to prevent callbacks from executing after cleanup"
Ajay Panicker [Wed, 2 May 2018 17:55:48 +0000 (17:55 +0000)]
Merge "Use weak pointers to prevent callbacks from executing after cleanup"

6 years agoMerge "Use the wrapped volume interface with the AVRCP conneciton handler"
Ajay Panicker [Wed, 2 May 2018 17:52:37 +0000 (17:52 +0000)]
Merge "Use the wrapped volume interface with the AVRCP conneciton handler"

6 years agoHearing Aid: leave some radio time for other devices
Jakub Pawlowski [Thu, 15 Mar 2018 18:37:06 +0000 (11:37 -0700)]
Hearing Aid: leave some radio time for other devices

We should send maximum two packets in connection event, and they
should take less than 3.75ms with acknowledgements.
Leaving some radio time should make us able to keep third LE connection
to some less demanding devices.

Bug: 78364114
Bug: 69623109
Test: stream music through Hearing Aid and connect to some LE device
Change-Id: Ie97b9db456a957c11438208448c562435b1b0222

6 years agoMerge "Fix memory leak for BTRC_ITEM_MEDIA."
Joseph Pirozzo [Wed, 2 May 2018 15:42:06 +0000 (08:42 -0700)]
Merge "Fix memory leak for BTRC_ITEM_MEDIA."
am: 77bed94c2d

Change-Id: I53c846c4f6b772a03a6a1c97de82d0cbd9020fde

6 years agoMerge "Fix memory leak for BTRC_ITEM_MEDIA."
Joseph Pirozzo [Wed, 2 May 2018 15:34:17 +0000 (15:34 +0000)]
Merge "Fix memory leak for BTRC_ITEM_MEDIA."

6 years agoUse weak pointers to prevent callbacks from executing after cleanup
Ajay Panicker [Thu, 19 Apr 2018 22:17:16 +0000 (15:17 -0700)]
Use weak pointers to prevent callbacks from executing after cleanup

Switch from using the instance directly to using weak pointers to the
instance. This causes any base::Callback objects that are bound to that
weak instance to be cleaned up if the weak pointer becomes invalid.

Bug: 78134184
Test: valgrind ./net_test_avrcp
--gtest_filter=*disconnectAfterCleanupTest* and see that there is an
invalid read before the fix and it is gone after.

Change-Id: I46c3175e62b87be165e468d014155f8d8154c08a

6 years agoAdd a missing call to btif_av_stream_stop() for SetActivePeer(null)
Pavlin Radoslavov [Tue, 1 May 2018 18:23:47 +0000 (11:23 -0700)]
Add a missing call to btif_av_stream_stop() for SetActivePeer(null)
am: 361e2a46fb

Change-Id: I70b0293e294f51871a23d0387697bc9ffe80a353

6 years agoFix A2DP Suspend related multi-component deadlock
Pavlin Radoslavov [Tue, 1 May 2018 01:02:35 +0000 (18:02 -0700)]
Fix A2DP Suspend related multi-component deadlock
am: 2a3b9b597e

Change-Id: I4398d7b04c17b058e9c72599a0816719defd5159

6 years agoAdd a missing call to btif_av_stream_stop() for SetActivePeer(null)
Pavlin Radoslavov [Tue, 1 May 2018 00:57:34 +0000 (17:57 -0700)]
Add a missing call to btif_av_stream_stop() for SetActivePeer(null)

Without this call, the BtifAv state machine could be left in Started
state, while the A2DP media task timer is canceled.
This internal state inconsistency prevents the proper handling
of Audio HAL commands like SUSPEND - no ACK is returned and
the Audio HAL is blocked.

Bug: b/78901123
Test: Manual - play music to Headset, select "play media to" > This device
      resume music, select "play media to" > Bluetooth Headet

Change-Id: I11b280bea76de02f522e61ebb0a9d7eb5b50f993

6 years agoAdd ability to modify IO capability of Bluetooth device
Pulkit Bhuwalka [Mon, 30 Apr 2018 22:04:04 +0000 (15:04 -0700)]
Add ability to modify IO capability of Bluetooth device
am: 2bc59e5956

Change-Id: I908505b89e7db9040b1f3b515625e2c195b49640

6 years agoFix A2DP Suspend related multi-component deadlock
Pavlin Radoslavov [Mon, 30 Apr 2018 20:39:20 +0000 (13:39 -0700)]
Fix A2DP Suspend related multi-component deadlock

Apparently, the processing of A2DP Suspend from the Audio HAL
could result in a deadlock across multiple components:
  A2dpService -> AudioService  -> Audio-BT HAL -> BT Native Stack ->
  BT JNI upcall -> A2dpService

1) A2dpService -> AudioService:
   - Waiting inside setActiveDevice() -> synchronized (mStateMachines) ->
   mAudioManager.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent()
   - The mAudioManager call can be blocking: a followup call would wait
     for the previous call to complete.
2) AudioService -> Audio-BT HAL
   The AudioService is wating on the Audio-BT HAL to complete its request.
   In this case the request is SUSPEND
3) Audio-BT HAL -> BT Native Stack
   The Audio side of the Audio-BT HAL is waiting for the BT Native stack
   to ACK the SUSPEND command.
   More specifically, it is retrying few times with timeout of 250ms
   each iteration.

4) BT Native Stack -> BT JNI upcall
   - In the BT Native Stack the BtifAv FSM (see file btif/src/btif_av.cc)
     is in state StateStarted and has received the
     BTIF_AV_SUSPEND_STREAM_REQ_EVT because of the SUSPEND command from the
     Audio HAL.
   - As a result, the LocalSuspendPending flag has been set:
     peer_.SetFlags(BtifAvPeer::kFlagLocalSuspendPending);
   - Only after the above flag is reset, then the BT Native Stack will
     ACK the SUSPEND command from the HAL
   - The above flag will be reset when event BTA_AV_SUSPEND_EVT is received
     from the underlying stack
   - The BtifAv state machine has received the BTA_AV_SUSPEND_EVT event.
     However, prior to clearing the pending status, the FSM tries to
     report the audio state via JNI to the Java layer:
       btif_report_audio_state();
       ...
       peer_.ClearFlags(BtifAvPeer::kFlagLocalSuspendPending);
  - Apparently, all the processing inside the BtifAv FSM is done on
    the JNI thread, including the btif_report_audio_state() upcall.
5) BT JNI upcall -> A2dpService
  - The btif_report_audio_state() upcall calls indirectly
    A2dpNativeInterface.onAudioStateChanged() -> sendMessageToService() ->
    A2dpService.messageFromNative()
  - Within the A2dpService.messageFromNative() processing, there is
    "synchronized (mStateMachines) {}" block, and the processing there
    blocks because per (1) above A2dpService.setActiveDevice() is
    already inside its own "synchronized (mStateMachines) {}" block

The above deadlock is fixed by the following:
 - Modified the BTA_AV_SUSPEND_EVT processing such that
   the clearing of the kFlagLocalSuspendPending flag is done BEFORE
   the btif_report_audio_state()
 - Modified the BtifAv FSM such that the internal processing of the FSM
   events is done on the BTA thread instead of the JNI thread. Thus,
   the FSM processing cannot be blocked by JNI upcalls.

Also:
 - Updated the do_in_bta_thread() function to have a return value
   so it is more aligned with the corresponding do_in_jni_thread()
   implementation
 - Updated the reordering of some other btif_report_*() upcalls inside
   btif_av.cc so they are after the FSM internal processing in the
   current state.
 - Added few extra logs to the Audio-BT HAL (file audio_a2dp_hw.cc).

Bug: 72823323
Test: Disconnect/reconnect with Philips SBH7000 Headset
Change-Id: I7ccb558e458a8e90d0414f94463bda8d4b3fdc97

6 years agoFix memory leak for BTRC_ITEM_MEDIA.
Joseph Pirozzo [Mon, 30 Apr 2018 19:23:18 +0000 (12:23 -0700)]
Fix memory leak for BTRC_ITEM_MEDIA.

Memory is allocated for each media item received from a remote phone for
AVRCP media browsing.  Although the media item itself was freed, the
memory for each attribute was not freed.  Move the allocation up to
the parent function such that it can be allocated and freed in the same
location.

Bug: 78222934
Test: dumpsys meminfo com.android.bluetooth
Change-Id: I217830441949642cd6ef0f96ac5fde9251452095

6 years agoAdd ability to modify IO capability of Bluetooth device
Pulkit Bhuwalka [Thu, 22 Mar 2018 21:34:33 +0000 (14:34 -0700)]
Add ability to modify IO capability of Bluetooth device

Redirects all access to Bluetooth IO capability from
macros. This allows it to be config determined but fall back to #define
values to maintain backward compatibility.

There is also the addition of methods to set IO capability properties.
Since these are done at the adapter level, it reuses
set_adapter_property from the bluetooth interface by adding new
property configs.

Bug: 36015413
Test: Created a test activity to modify values using the API and pair
with different settings. Default value is picked up from macro.

Change-Id: I7b80ea70cef4eacab91d20a58e745281aed273cd
(cherry picked from commit 7a5281f7ffe6860f15fcc088c63b1109f98c0e0e)

6 years agoMerge "RFCOMM: Crash on null MCB and PORT in state machine"
android-build-prod (mdb) [Sat, 28 Apr 2018 00:18:09 +0000 (17:18 -0700)]
Merge "RFCOMM: Crash on null MCB and PORT in state machine"
am: 41b84de18c

Change-Id: Ie90697adeed2c34298b15fc5be587032848c714e

6 years agoMerge "RFCOMM: Crash on null MCB and PORT in state machine"
android-build-prod (mdb) [Fri, 27 Apr 2018 23:58:07 +0000 (23:58 +0000)]
Merge "RFCOMM: Crash on null MCB and PORT in state machine"

6 years agoEnable HCI Sniff mode and disable subrating for A2DP
Guang Xie [Fri, 27 Apr 2018 21:20:18 +0000 (14:20 -0700)]
Enable HCI Sniff mode and disable subrating for A2DP
am: 1b548bb34a

Change-Id: I3bef5fa5e44f2ee10b0c1d8a09c839823f0a0343

6 years agoEnable HCI Sniff mode and disable subrating for A2DP
Guang Xie [Thu, 15 Feb 2018 20:42:15 +0000 (12:42 -0800)]
Enable HCI Sniff mode and disable subrating for A2DP

Enabling the HCI Sniff mode could help headsets to save power.

Note that subrating is disabled implicitly by NOT sending the
"Sent Sniff Subrating" HCI command to the BT controller,
and effectively using the default Sniff Subrating parameters.
The Headset shouldn't go into Subrating Mode to prevent
potential stuttering if the Headset chooses to use subrating
with the wrong parameters.

NOTE: This should affect only Pixel Buds.

Also:
 - Added some extra log messages
 - Minor cleanup (argument/variable renaming)

Bug: 74344711
Bug: 74361002
Test: Manual - audio streaming; examine btsnoop logs
Change-Id: Iec5086dba6f9003c21bcb41eddb3bc83ac7dddd1

6 years agoRFCOMM: Crash on null MCB and PORT in state machine
Jack He [Fri, 27 Apr 2018 19:00:50 +0000 (12:00 -0700)]
RFCOMM: Crash on null MCB and PORT in state machine

* rfc_mx_sm_execute should never receive a NULL mcb
* rfc_port_sm_execute should never receive a NULL port
* If the above happens, we should crash since otherwise we might miss a
  state machine event and not knowing that we missed it if we just do a
  simple NULL check

Bug: 77224743
Test: StackRfcommTest
Change-Id: I7114e46ae706927cc839c7201c97362710e7a874

6 years agoUse the wrapped volume interface with the AVRCP conneciton handler
Ajay Panicker [Fri, 27 Apr 2018 13:50:42 +0000 (06:50 -0700)]
Use the wrapped volume interface with the AVRCP conneciton handler

Use the wrapped volume interface in connection handler so that JNI calls
are automatically executed on the correct thread when called from the
connection handler.

Bug: 30602783
Test: Connect a device that doesn't support absolute volume and see that
the JNI call doesn't throw an exception.

Change-Id: Ife768c715022e70dd4055270c1d6cf76ba26aea3

6 years agoSave the AVDTP version after SDP discovery and read it on reconnect
Pavlin Radoslavov [Thu, 26 Apr 2018 01:15:45 +0000 (18:15 -0700)]
Save the AVDTP version after SDP discovery and read it on reconnect
am: a634f4e30a

Change-Id: I3ea83f1ce66acdc932c54e5df968d0acd05b22e7

6 years agoSave the AVDTP version after SDP discovery and read it on reconnect
Pavlin Radoslavov [Mon, 23 Apr 2018 20:36:33 +0000 (13:36 -0700)]
Save the AVDTP version after SDP discovery and read it on reconnect

* Save the AVDTP version discovered by SDP to the device's local
  configuration section with key string of "AvdtpVersion"
* Refactor tBTA_AV_SCB and hide the AVDTP version and peer address
  behind get/set methods:
  AvdtpVersion() / SetAvdtpVersion() / PeerAddress().
* Added new methods tBTA_AV_SCB::OnConnected() and OnDisconnected().
  The former is used to setup some of the internal state when
  connected to a peer: the peer address and read the stored AVDTP
  version from local configuration section.
  The latter is used to reset that state when disconnected
  from that peer.
* Removed field tBTA_AV_SDP_RES.avdt_version because it is never
  set / used.
* Removed duplicate re-definition of AVDT_VERSION inside avdt_api.h

Bug: 78142165
Test: Manual: connect/reconnect with Sennheiser MOMENTUM M2 AEBT headset
Change-Id: Ib9dcd95dc9899fa81f3cd927f127e5cb0f21ef60

6 years agoMerge changes from topics "bt-hfp-fix-connection-collision-handling", "bt-rfcomm...
android-build-prod (mdb) [Wed, 25 Apr 2018 21:36:12 +0000 (14:36 -0700)]
Merge changes from topics "bt-hfp-fix-connection-collision-handling", "bt-rfcomm-improve-logging-and-readability", "bt-rfcomm-add-end-to-end-unit-tests"
am: abcc72862f

Change-Id: Ic0db1e0cbc993f37d92bb9e13c9515bb268cf5b4

6 years agoMerge changes from topics "bt-hfp-fix-connection-collision-handling", "bt-rfcomm...
android-build-prod (mdb) [Wed, 25 Apr 2018 21:24:55 +0000 (21:24 +0000)]
Merge changes from topics "bt-hfp-fix-connection-collision-handling", "bt-rfcomm-improve-logging-and-readability", "bt-rfcomm-add-end-to-end-unit-tests"

* changes:
  HFP: Fix connection colision handling
  RFCOMM: Improve logging and readability
  RFCOMM: Add unit tests for connection scenarios

6 years agoHFP: Fix connection colision handling
Jack He [Mon, 23 Apr 2018 00:30:14 +0000 (17:30 -0700)]
HFP: Fix connection colision handling

* When there is a connection collison, and remote device is trying to
  connect to HFP server channel while we try to connect to remote's
  server channel as a client. If the remote device succssfully connect
  to us, we should drop our connection request to remote device and
  accept remote device's connection request. As result, we will observe
  1. Our connection request fails, this propagate up to Java layer and
  also clean up any states in these layers
  2. Remote connection request succeeds, this propagate up to Java layer
     as well as a new incoming connection
* Added BTA_AG_COLLISION_EVT to formally handle AG collision in state
  machine
* Modified bta_ag_resume_open to re-send BTA_AG_API_OPEN_EVT instead of
  modifying the state machine state directly. State machine states
  should only be modified by state machine handler
* Ignore RFCOMM open event if PORT_CheckConnection fails
* Added StackRfcommTest.TestConnectionCollision to reproduce this
  scenario with 100% certainty
* Add static checks to HFP BTA state machine to make sure action and
  event indices match enum sizes

Bug: 77224743
Test: connect to multiple remote devices with HFP, MAP and PBAP
      StackRfcommTest.TestConnectionCollision
      btestplans/details/158641/3975
Change-Id: Ib3652784b123abe195e7bd30421ef5f4345b1d4d

6 years agoMerge "Hearing Aid: Keep configuration after disconnect()"
android-build-prod (mdb) [Wed, 25 Apr 2018 10:29:30 +0000 (03:29 -0700)]
Merge "Hearing Aid: Keep configuration after disconnect()"
am: 0056fc3dd1

Change-Id: I3f1009f29782514e3d69ae088745bb367abd2ffe

6 years agoMerge "Hearing Aid: Keep configuration after disconnect()"
android-build-prod (mdb) [Wed, 25 Apr 2018 10:12:25 +0000 (10:12 +0000)]
Merge "Hearing Aid: Keep configuration after disconnect()"

6 years agoRFCOMM: Improve logging and readability
Jack He [Sat, 21 Apr 2018 05:06:11 +0000 (22:06 -0700)]
RFCOMM: Improve logging and readability

Debug Improvements:
* Add more error logging in the following methods:
 - rfc_mx_sm_state_idle for L2CA_ConnectReq failure
 - rfc_mx_sm_state_configure for RFC_EVENT_TIMEOUT
 - rfc_mx_conf_cnf for L2CAP configuration failures
 - RFCOMM_RemoveServer

Readability Improvements:
* Refactored logic in the following methods to be more readable
 - L2CA_ErtmConnectReq
 - RFCOMM_CreateConnection
 - port_open_continue
 - PORT_StartCnf
 - port_allocate_port
 - rfc_send_buf_uih
 - bta_ag_get_other_idle_scb
* Rename RFCOMM_ParNegReq to RFCOMM_ParameterNegotiationRequest
* Rename RFCOMM_ParNegRsp to RFCOMM_ParameterNegotiationResponse
* Rename RFCOMM_PortNegReq to RFCOMM_PortParameterNegotiationRequest
* Rename RFCOMM_PortNegRsp to RFCOMM_PortParameterNegotiationResponse

Rename using IDE:
* Rename tRFCOMM_CB.last_port to tRFCOMM_CB.last_port_index
* Rename tPORT.inx to tPORT.handle as inx is ready the port handle
  indexed from 1
* Rename tRFC_MCB.port_inx to tRFC_MCB.port_handles

NPE Prevention:
* Add error checking in rfc_save_lcid_mcb to avoid accessing beyond
  array boundary

Bug: 77224743
Test: StackRfcommTest, connect and disconnect to multiple devices
      with PBAP, MAP, PAN, PTS HFP tests
      testplans/details/158641/3975
Change-Id: I8de89dfc0cee48fed6ad4e1d4a8cdcde2f960aab

6 years agoRFCOMM: Add unit tests for connection scenarios
Jack He [Sat, 21 Apr 2018 05:04:21 +0000 (22:04 -0700)]
RFCOMM: Add unit tests for connection scenarios

Unit tests:
* Add net_test_stack_rfcomm
* Use a compiler trick to compile production RFCOMM code against L2CAP
  and BTM header, but fake L2CAP and BTM source code so that we can stub
  statically defined L2CAP and BTM code using mocks
* Rename net_test_rfcomm to net_test_rfcomm_suite
* Add mocked L2CAP and BTM layer to allow packet replay from L2CAP layer
  to RFCOMM layer in order to reproduce time dependent issues such as
  connection collision
* Add a number of utility methods that generates RFCOMM packet bytes
  using supported parameters
* Add unit test for above utility methods
* Add suite of unit tests named StackRfcommTest, including:
 - SingleServerConnectionHelloWorld
 - MultiServerPortSameDeviceHelloWorld
 - SameServerPortMultiDeviceHelloWorld
 - SingleClientConnectionHelloWorld
 - SameClientPortMultiDeviceHelloWorld
* These tests supply L2CAP packets and API calls to trigger RFCOMM
  connection setup in various scenarios
* Added logging method to output debug log via VLOG(1) logging level and
  allow compile time configuration of these logs through a constant flag

Bug: 77224743
Test: ./test/run_unit_tests.sh net_test_stack_rfcomm
      testplans/details/158641/3975
Change-Id: I9d59843603cd36394c3736670bcf3c39dea26674

6 years agoHSP: Keep sending RING message
Chenyang Zhang [Wed, 25 Apr 2018 00:32:43 +0000 (17:32 -0700)]
HSP: Keep sending RING message
am: 039c2bd30b

Change-Id: Ib5a9221ae8d41f794c69b691afd24b8d7fe662cb

6 years agoHSP: Keep sending RING message
Chenyang Zhang [Mon, 26 Mar 2018 03:21:59 +0000 (11:21 +0800)]
HSP: Keep sending RING message

Two PTS Test failed:
- HSP/AG/IAC/BV-01-I
- HSP/AG/ACR/BV-02-I

Reason:
AG didn't send the "RING" unsolicited result code to HS(PTS),
then HS can't send the "AT+CKPD=200" command to received the call.
After a while, the "FATAL ERROR (MTC): Call establishment timed out"
triggered by PTS.

Solution:
Keep sending RING message for HSP.

Bug: 77507028
Change-Id: If1288a5f7b1b7da8ecba34ed90a85a0af8a91e9a

6 years agoHearing Aid: Keep configuration after disconnect()
Hansong Zhang [Mon, 23 Apr 2018 19:26:52 +0000 (12:26 -0700)]
Hearing Aid: Keep configuration after disconnect()

After disconnect(), the Hearing Aid service removes the device from the
white list, but retains the configuration. The Java Hearing Aid service
still knows the hiSyncId and capabilities, so it can connect() to
multiple devices at the same time

Bug: 69623109
Test: manual and unit test for Java service
Change-Id: Ic17b9be7e6a0577baecd520680abffbaf0a0dc47

6 years agoRename <cutils/log.h> to <log/log.h>
Logan Chien [Mon, 23 Apr 2018 10:23:30 +0000 (03:23 -0700)]
Rename <cutils/log.h> to <log/log.h>
am: 93011f0038

Change-Id: Ibe1561c78d52fd2d4ca6f523a92aeb9e5b72b15c

6 years agoRename <cutils/log.h> to <log/log.h>
Logan Chien [Mon, 23 Apr 2018 06:46:28 +0000 (14:46 +0800)]
Rename <cutils/log.h> to <log/log.h>

Bug: 78370064
Test: lunch aosp_walleye-userdebug && cd system/bt && mma

Change-Id: I43448e88c236b72d86206bd652075f35eccca6f6

6 years agoA2DP offload: switch to new properties
Petri Gynther [Fri, 20 Apr 2018 07:51:29 +0000 (00:51 -0700)]
A2DP offload: switch to new properties
am: e0e6ed8485

Change-Id: I555c4e9b84a20cb7b959ba41d1bd9b56f986817b

6 years agoA2DP offload: switch to new properties
Petri Gynther [Wed, 18 Apr 2018 01:29:09 +0000 (18:29 -0700)]
A2DP offload: switch to new properties

Bug: 63932139
Bug: 76201991
Test: Manual A2DP testing (A2DP offload enabled and disabled)
Change-Id: Idcc2af40bde09758e060861ac518c06b7551212a

6 years agoMerge "Don't start the authentication when peer device already started it"
ilbeom.kim [Thu, 19 Apr 2018 23:41:08 +0000 (16:41 -0700)]
Merge "Don't start the authentication when peer device already started it"
am: 0c37b39f4b

Change-Id: Ic72dace481aee0ce8fe6b16ad69066daa10a1574

6 years agoMerge "Don't start the authentication when peer device already started it"
Treehugger Robot [Thu, 19 Apr 2018 23:23:21 +0000 (23:23 +0000)]
Merge "Don't start the authentication when peer device already started it"

6 years agoReset the A2DP coding parameters when switching codecs
Pavlin Radoslavov [Wed, 18 Apr 2018 20:28:23 +0000 (13:28 -0700)]
Reset the A2DP coding parameters when switching codecs
am: fe240f2e82

Change-Id: Iebadc2f4a69306b815065d1e8fe55db62da65843

6 years agoReset the A2DP coding parameters when switching codecs
Pavlin Radoslavov [Wed, 18 Apr 2018 17:57:22 +0000 (10:57 -0700)]
Reset the A2DP coding parameters when switching codecs

Bug: 77281039
Test: Manual - connect Headset and switch codecs while playing audio
Change-Id: Icb89b0d78195fd654d66bc1334b121cf62c55be1

6 years agoGATT: fix 32 bit UUID handling
Jakub Pawlowski [Wed, 18 Apr 2018 08:52:49 +0000 (01:52 -0700)]
GATT: fix 32 bit UUID handling
am: f107e4f9e8

Change-Id: Icdf3f41a3588e781b0d2029d5cec315ea33b4632