OSDN Git Service

android-x86/system-bt.git
6 years agoMerge "Improve A2DP codec run-time debug-abilitity"
Treehugger Robot [Wed, 11 Apr 2018 02:54:40 +0000 (02:54 +0000)]
Merge "Improve A2DP codec run-time debug-abilitity"

6 years agoImprove A2DP codec run-time debug-abilitity
Pavlin Radoslavov [Sat, 7 Apr 2018 00:05:47 +0000 (17:05 -0700)]
Improve A2DP codec run-time debug-abilitity

Rename A2DP_DumpCodecInfo() to A2DP_CodecInfoString() and change
the usage. Previously, A2DP_DumpCodecInfo() would print the
the codec information only if LOG_VERBOSE() was enabled in compile time.
The new A2DP_CodecInfoString() now returns human-readable std::string
with the codec information.
That string can be used in debug log messages that can be enabled
in run-time.

Bug: 77525584
Test: Manual - Examine log messages when A2DP streaming with and
      without debug log messages enabled.

Change-Id: Idd440d6c9e908520132feeeb5388d3e6aefa26db

6 years agoSet default AVRCP version to 1.4
Ajay Panicker [Tue, 10 Apr 2018 23:35:37 +0000 (16:35 -0700)]
Set default AVRCP version to 1.4

Bug: 77874113
Test: Check snoop logs to see that the broadcasted AVRCP version is 1.4
Change-Id: If36bccc58d04dffe46286ee8d18785b680b9de8a

6 years agoAllow platforms to override client connection sniff timeout
Zach Johnson [Fri, 30 Mar 2018 20:33:54 +0000 (13:33 -0700)]
Allow platforms to override client connection sniff timeout

It is already possible to set server connection sniff timeouts.

Bug: 70309445
Test: inspect timeouts via logs
Change-Id: Ibc19dd4f77aa28388169b2ce70d12200020e6a4d

6 years agoHFP: Report AT+BIA command to upper layer
Jack He [Thu, 5 Apr 2018 22:39:27 +0000 (15:39 -0700)]
HFP: Report AT+BIA command to upper layer

* Report AT+BIA command, AG indicator activation command, to upper layer
  so that upper layer can decide on whether or not to subscribe to these
  indicators

Bug: 77655992
Test: make

Change-Id: Ic330d6784c5edf20683cbfedda3fa54525878ce8

6 years agoMerge "Add hidden API to get current user of HID Device (2/3)"
Treehugger Robot [Fri, 6 Apr 2018 21:54:06 +0000 (21:54 +0000)]
Merge "Add hidden API to get current user of HID Device (2/3)"

6 years agoCheck if socket is closed before getting presentation position
Ajay Panicker [Thu, 5 Apr 2018 16:14:51 +0000 (09:14 -0700)]
Check if socket is closed before getting presentation position

Bug: 76456293
Test: Listen to music on a device that supports delay reporting
Change-Id: I4ca1c31819594750a7beb1d11ca5b8d64a7f836c

6 years agoMerge "Disable absolute volume if the remote device rejects registration"
Treehugger Robot [Thu, 5 Apr 2018 23:36:10 +0000 (23:36 +0000)]
Merge "Disable absolute volume if the remote device rejects registration"

6 years agoMerge "vendor_libs: Allow btlinux service to run from vendor or system/vendor"
Treehugger Robot [Thu, 5 Apr 2018 19:20:23 +0000 (19:20 +0000)]
Merge "vendor_libs: Allow btlinux service to run from vendor or system/vendor"

6 years agovendor_libs: Allow btlinux service to run from vendor or system/vendor
Dmitry Shmidt [Thu, 5 Apr 2018 17:35:37 +0000 (10:35 -0700)]
vendor_libs: Allow btlinux service to run from vendor or system/vendor

Bug: 75290651
Test: Manual

Change-Id: I30bda23667ac911bf21da5705d248833f919f8bf
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
6 years agoDisable absolute volume if the remote device rejects registration
Ajay Panicker [Wed, 4 Apr 2018 05:28:06 +0000 (22:28 -0700)]
Disable absolute volume if the remote device rejects registration

Instead of trying to re-register for a rejected volume changed
notification, disable absolute volume. This prevents spinning if a
remote device continuously rejects all attempts to register. A volume
level of -2 will be used to represent that the volume notification was
rejected.

Bug: 77238060
Test: Run host native test net_test_avrcp
Change-Id: I228524fb30348ca691d0792f0c7bcc4653d1fcef

6 years agoMerge "HID Device: remove "Cabled" flag when device is not used"
Treehugger Robot [Thu, 5 Apr 2018 01:39:23 +0000 (01:39 +0000)]
Merge "HID Device: remove "Cabled" flag when device is not used"

6 years agoHID Device: remove "Cabled" flag when device is not used
Hansong Zhang [Wed, 4 Apr 2018 01:17:43 +0000 (18:17 -0700)]
HID Device: remove "Cabled" flag when device is not used

Remove the "HidDeviceCabled" flag from the config when the remote device
is not currently being usec

Bug: 77549256
Test: manual
Change-Id: I2c88e972457608699c3f0344357828324a419b90

6 years agoMerge "Hearing Aid: change get/set active device (1/3)"
Treehugger Robot [Wed, 4 Apr 2018 21:42:17 +0000 (21:42 +0000)]
Merge "Hearing Aid: change get/set active device (1/3)"

6 years agoPersist VFS ID's between directory changes.
Ajay Panicker [Tue, 3 Apr 2018 01:21:04 +0000 (18:21 -0700)]
Persist VFS ID's between directory changes.

Some carkits don't honor the fact that VFS ID's only are consistent to
the folder they are currently browsing. Now a UID will remain valid
until the connection ends.

Bug: 68812037
Test: Run net_test_avrcp
Change-Id: I67898277327b54eaeca2121b9ff173b22bd4ba71

6 years agoAdd hidden API to get current user of HID Device (2/3)
Hansong Zhang [Mon, 8 Jan 2018 23:05:21 +0000 (15:05 -0800)]
Add hidden API to get current user of HID Device (2/3)

Bug: 69136526
Test: test with apps using HID Device profile
Change-Id: I6c6df052fac508499c42fc7ab493010e327d6003

6 years agoRefresh the now playing ID map when the now playing list changes
Ajay Panicker [Mon, 2 Apr 2018 22:36:35 +0000 (15:36 -0700)]
Refresh the now playing ID map when the now playing list changes

The Now Playing List ID's could be invalid if the now playing list
changes but there is not track change, like when adding a song to the
queue on the device.

Bug: 68812037
Test: Run host native test net_test_avrcp
Change-Id: I3c2c11aa87b64241f378819c38ae5cc21ffdb5ac

6 years agoAdd MTU Handling for AVRCP Packets
Ajay Panicker [Sat, 31 Mar 2018 21:38:53 +0000 (14:38 -0700)]
Add MTU Handling for AVRCP Packets

Bug: 77241554
Test: Run host native tests net_test_avrcp and net_test_btpacket
Change-Id: If32aa506dc8f99220ef35efeb4d77a1023767afe

6 years agoRFCOMM: Add more logging on failure cases
Jack He [Wed, 28 Mar 2018 20:02:37 +0000 (13:02 -0700)]
RFCOMM: Add more logging on failure cases

* Log every instance of RFCOMM unexpected disconnection
* Log every time when RFCOMM channel (DLCI) is changed
* Refactor some RFCOMM code to be more readable and easier for logging
* Remove excessive logging in power manager
* Assign HSP default version more appropriate location
* Replace some usage of NULL with nullptr

Bug: 77224743
Test: make, no functional changes
Change-Id: I5e62dd6d338f7e92a8b8d39c1fe155b71396034c

6 years agoMerge "Reduce the number of PCM data reads for aptX and aptX HD"
Treehugger Robot [Fri, 30 Mar 2018 20:58:11 +0000 (20:58 +0000)]
Merge "Reduce the number of PCM data reads for aptX and aptX HD"

6 years agoMerge changes from topic "AVRCP Controller Browsing"
Treehugger Robot [Fri, 30 Mar 2018 19:55:46 +0000 (19:55 +0000)]
Merge changes from topic "AVRCP Controller Browsing"

* changes:
  AVRCP play status change updates
  AVRCP register for addressed player changed

6 years agoReduce the number of PCM data reads for aptX and aptX HD
Pavlin Radoslavov [Fri, 30 Mar 2018 19:14:14 +0000 (12:14 -0700)]
Reduce the number of PCM data reads for aptX and aptX HD

For every periodic aptX / aptX HD data packet, use a single read
operation for all PCM data that needs to be encoded, instead of
using multiple reads of smaller blocks of data.

Bug: 70899260
Test: Manual: stream to aptX/aptX HD headset, change the sample rate
Change-Id: Ifcb8302589f24f5d7ab89c645c50d6905197fb7f

6 years agoHearing Aid: change get/set active device (1/3)
Hansong Zhang [Wed, 28 Mar 2018 23:43:21 +0000 (16:43 -0700)]
Hearing Aid: change get/set active device (1/3)

* setActiveDevice() returns false in error case, e.g. when the device is
not connected
* add getActiveDevices() instead of isActiveDevice(), which returns a list
that must have two elements: left and right, or empty list on error

Test: manual
Bug: 69623109
Change-Id: I6f872dd88422e9d7e5187603d3ad33628726e1ca

6 years agoUse RawAddress.ToString() instead of manual conversion
Jakub Pawlowski [Tue, 27 Mar 2018 23:02:02 +0000 (16:02 -0700)]
Use RawAddress.ToString() instead of manual conversion

Test: compilation
Change-Id: I66040a4f3d339ac0473052d916b9a0b4e3045e8e

6 years agoUnpair both transports of dual mode device, when LE address provided
Jakub Pawlowski [Wed, 28 Mar 2018 22:00:13 +0000 (15:00 -0700)]
Unpair both transports of dual mode device, when LE address provided

In bta_dm_remove_device, if the device is not connected, and we don't
know the transport for given address, we make two calls to
BTM_ReadConnectedTransportAddress, to determine the device address on
the other transport.
If the address provided is LE, first call will fill the other_address
variable with the Classic address, and the second call will fill it back
with LE addres. This mean we never try to remove Classic entry, instead
we remove LE entry twice.

Bug: 67907612
Test: establish LE connnection between two phones, trigger Bonding.
  After bonding complete, try to remove bond using LE address. Verify
  config file is cleaned of both LE and classic entry.

Change-Id: Ia5dd53f96b95478a07009cecc5b4a3c79f15c59b

6 years agoMerge changes I88d0862f,Ic9a2c8d8
Treehugger Robot [Thu, 29 Mar 2018 16:16:00 +0000 (16:16 +0000)]
Merge changes I88d0862f,Ic9a2c8d8

* changes:
  Use proper media ID when changing path
  Add missing AVRCP Set Addressed Player Response

6 years agoUse proper media ID when changing path
Ajay Panicker [Thu, 29 Mar 2018 00:04:39 +0000 (17:04 -0700)]
Use proper media ID when changing path

Use the current media ID on the path stack to retrieve folder contents.

Bug: 77237565
Test: run host native test net-test-avrcp
Change-Id: I88d0862f76d18a071a8530cd31954447b4e180fc

6 years agoAdd missing AVRCP Set Addressed Player Response
Ajay Panicker [Wed, 28 Mar 2018 23:02:36 +0000 (16:02 -0700)]
Add missing AVRCP Set Addressed Player Response

Bug: 77237301
Test: run host native tests net-test-btpackets and net-test-avrcp
Change-Id: Ic9a2c8d8cf5dd4c5be02a83975caa92e335ca2b9

6 years agoAVRCP play status change updates
Joseph Pirozzo [Wed, 28 Mar 2018 22:27:31 +0000 (15:27 -0700)]
AVRCP play status change updates

Process play status updates when seeking forward and backward.

Bug: 67568875
Test: seek forward and backward on paired phone and observe updates.
Change-Id: Id280f0e877cfea0a0da7603ab6d7bcfaf667d482

6 years agoMerge "Revert "HID: Fix the behavior of virtual_cable_unplug""
Treehugger Robot [Wed, 28 Mar 2018 21:50:01 +0000 (21:50 +0000)]
Merge "Revert "HID: Fix the behavior of virtual_cable_unplug""

6 years agoRevert "HID: Fix the behavior of virtual_cable_unplug"
Hansong Zhang [Wed, 28 Mar 2018 19:52:36 +0000 (19:52 +0000)]
Revert "HID: Fix the behavior of virtual_cable_unplug"

This reverts commit 65ce047e3feeba934015870254535882edf61743.

Reason for revert: Connected HID keyboard won't unpair
Bug: 76907578
Test: SL4A
Change-Id: I7d289183ac05b5f926c145799418461377228569

6 years agoChanged the default configured sample rate for aptX/aptX-HD to 48.0kHz
Pavlin Radoslavov [Wed, 28 Mar 2018 19:30:14 +0000 (12:30 -0700)]
Changed the default configured sample rate for aptX/aptX-HD to 48.0kHz

Previously, the default configured sample rate for aptX and aptX-HD
was 44.1kHz. However, during AVDTP codec setup, the initial codec
setup to 44.1kHz was followed immediately with automatic codec
reconfiguration to 48.0kHz (if supported by the remote device)
so the highest possible sample rate will be used.

Changing the default sample rate to 48.0kHz eliminates the
transient initial codec setup of 44.1kHz, because it is unnecessary
and error-prone.

Bug: 69276823
Test: Manual: connect to aptX / aptX-HD headsets and examine the AVDTP codec
      configuration in the btsnoop logs.
Change-Id: I9e22365e0f07690c87503ea52fd9bb4d1ad4d5ff

6 years agoAVRCP register for addressed player changed
Joseph Pirozzo [Wed, 28 Mar 2018 16:20:48 +0000 (09:20 -0700)]
AVRCP register for addressed player changed

Register to be notified when the addressed media player changes so we
can update the AVRCP controller.

Bug: 72495854
Test: Change media player on phone, verify media source is updated.
Change-Id: I932a25b9861734ecc6e1fdcf40f02cdde1fd049a

6 years agoFix crash in Log
Joseph Pirozzo [Tue, 27 Mar 2018 20:41:11 +0000 (13:41 -0700)]
Fix crash in Log

Correct parameter order.

Bug: 77009945
Test: observe log message
Change-Id: I69d4bc04936c322707111c825864007b7f257cc4

6 years agoMerge "Open acceptor channel for RC on cleanup"
Treehugger Robot [Wed, 28 Mar 2018 00:14:08 +0000 (00:14 +0000)]
Merge "Open acceptor channel for RC on cleanup"

6 years agoMerge "Serialize the commands during Pairing process"
Treehugger Robot [Wed, 28 Mar 2018 00:02:00 +0000 (00:02 +0000)]
Merge "Serialize the commands during Pairing process"

6 years agoOpen acceptor channel for RC on cleanup
AnubhavGupta [Tue, 11 Jul 2017 07:32:56 +0000 (13:02 +0530)]
Open acceptor channel for RC on cleanup

Usecase:
1. Install Fitbit app
2. Pair and connect with RD1
3. Start streaming
4. Pair and connect Fitbit watch

Failure:
No Stable Avctp connection with Fitbit Watch after pairing

Rootcause:
If there will be no listening acceptor
then some Remotes unable to connect AVRC
connection upon remote restart.

Fix:
Open acceptor channel for RC on cleanup
as if there will be no listening acceptor
then some Remotes unable to connect AVRC
connection upon remote restart.

Test: 1. Install Fitbit app
2. Pair and connect with RD1
3. Start streaming
4. Pair and connect Fitbit watch

Fixes: 63605621
Change-Id: Ia6cefc29ca64b00f2f5fe2f9816d71604c511415

6 years agoMerge "Suppress unnecessary A2DP codec reconfiguration"
Treehugger Robot [Tue, 27 Mar 2018 22:22:34 +0000 (22:22 +0000)]
Merge "Suppress unnecessary A2DP codec reconfiguration"

6 years agoMerge "A2DP Sink: add a mechanism for selecting the codec"
Treehugger Robot [Tue, 27 Mar 2018 22:22:19 +0000 (22:22 +0000)]
Merge "A2DP Sink: add a mechanism for selecting the codec"

6 years agoSerialize the commands during Pairing process
Srinu Jella [Wed, 18 Dec 2013 06:27:33 +0000 (11:57 +0530)]
Serialize the commands during Pairing process

Steps:
1. Pair and connect with HID mouse.
2. Once the settings UI shows paired and connected
3. Try to unpair the device, but UI still shows connected.

Failure: Unable to unpair HID mouse due to LMP
response timeout occurred for  remote version and remote
feature request.

Root Cause: Remote version, Remote features, Authentication
requested commands go simultaneously to the remote device
which can't handle the multiple commands at a time.

Fix: Serialize the Remote version, Remote features, Authentication
requested commands.

Test: Tested manually with apple magic mouse.
Bug: 35125883

Change-Id: I4448c291a60ee637dc5927806547e67f26571d86

6 years agoSuppress unnecessary A2DP codec reconfiguration
Pavlin Radoslavov [Tue, 27 Mar 2018 07:17:29 +0000 (00:17 -0700)]
Suppress unnecessary A2DP codec reconfiguration

If OTA A2DP codec configuration is accepted from the remote
device, then don't trigger codec reconfiguration.

Bug: 74521894
Test: Manual: accept connection and codec config from A2DP Sink
Change-Id: Ic2f6ff08d130adf85cad68a54ab9fbc0a711534c

6 years agoA2DP Sink: add a mechanism for selecting the codec
Pavlin Radoslavov [Tue, 27 Mar 2018 06:30:46 +0000 (23:30 -0700)]
A2DP Sink: add a mechanism for selecting the codec

Use the existing mechanism for selecting the A2DP Source codec to
select the A2DP Sink codec when the local device is A2DP Sink.

* Added new method BtaAvCo::SelectSinkCodec() similar to
  SelectSourceCodec() and use the new method to select the actual
  codec based on the AVDTP Codec capability discovery.
* Renamed method BtaAvCo::UpdateSelectableCodec() to
  UpdateSelectableSourceCodec() and added similar
  UpdateSelectableSinkCodec()
* Renamed method BtaAvCo::AttemptCodecSelection() to
  AttemptSourceCodecSelection() and added similar
  AttemptSinkCodecSelection
* Renamed AudioSinkHasContentProtection() to AudioSepHasContentProtection()
  because it can be used for either A2DP Source or Sink
* Removed method BtaAvCo::FindPeerSourceSepForCurrentCodec() because it
  is not needed anymore.
* Added new method A2dpCodecs::findSinkCodecConfig() similar to
  findSourceCodecConfig()
* Added new function A2DP_SinkCodecIndex() similar to
  A2DP_SourceCodecIndex()
* Added new method A2dpCodecs::setSinkCodecConfig()
* Reorganize the SBC and AAC Source/Sink codec config classes:
  - Virtual method A2dpCodecConfig::setCodecConfig() is now implemented
    for Sink codecs as well: SBC Sink, AAC Sink
  - Renamed A2dpCodecConfigSbc to A2dpCodecConfigSbcSource
  - Renamed A2dpCodecConfigAac to A2dpCodecConfigAacSource
  - Added base class A2dpCodecConfigSbcBase. That class implements
    method setCodecConfig() for both A2dpCodecConfigSbcSource and
    A2dpCodecConfigSbcSink
  - Added base class A2dpCodecConfigAacBase. That class implements
    method setCodecConfig() for both A2dpCodecConfigAacSource and
    A2dpCodecConfigAacSink
  - Updated the A2dpCodecConfigAacBase::setCodecConfig() so it computes
    correctly the AAC Variable Bit Rate Support flag in the result codec
    config: The Variable Bit Rate Support is disabled if either side
    disables it.
* Removed A2DP_BuildSrc2SinkConfig() because it is not needed anymore.
  The correspinding A2DP_BuildSrc2SinkConfigSbc() and
  A2DP_BuildSrc2SinkConfigAac() are removed as well.
* Renamed a2dp_sbc_caps inside a2dp_sbc.cc to a2dp_sbc_source_caps
* Renamed a2dp_aac_caps inside a2dp_aac.cc to a2dp_aac_source_caps
* Added corresponding unit tests

Bug: 74521894
Test: Manual: initiate connection from A2DP Sink.
      Unit tests in system/bt: test/run_unit_tests.sh net_test_stack

Change-Id: I3fc541a068993c123e8d61c209896bb758fd3764

6 years agoHFP: Save discovered HFP version to config file
Jack He [Sat, 21 Oct 2017 08:35:57 +0000 (01:35 -0700)]
HFP: Save discovered HFP version to config file

* Store discovered HFP version to btif config file so that a
  reconnection session knows the HFP version before SDP
* Check stored HFP version when RFCOMM channel is open before any AT
  command is processed
* Set peer HFP version to 0 on control block allocation

Bug: 67938255
Test: Connect with HFP 1.7 headsets
Change-Id: I43e7aa04dee17ea7ba9e7d3992ec0860c11d23bc

6 years agoFix potential NULL dereference in set_volume
Jakub Pawlowski [Mon, 26 Mar 2018 16:08:07 +0000 (09:08 -0700)]
Fix potential NULL dereference in set_volume

Bug: 76217773
Change-Id: I50188e9c69dbcd42286097cb6fbc1aa715877c80

6 years agoUse proper HCI_ERR_* constants in advertisement termination handling
Jakub Pawlowski [Sat, 24 Mar 2018 00:48:26 +0000 (17:48 -0700)]
Use proper HCI_ERR_* constants in advertisement termination handling

There is no functional change, just making the code pretty, and updating
names to match 5.0 specification.

Test: sl4a AdvertisingSetTest:test_reenabling
Bug: 74198564
Change-Id: I1811e19bd18470adda55f7af7cfee23bcc4d1871

6 years agoGuard ACPF with proper checks
Jakub Pawlowski [Fri, 23 Mar 2018 17:29:14 +0000 (10:29 -0700)]
Guard ACPF with proper checks

Fail on calls to  ACPF when it's not supported in controller.
Right now we sent such commands when starting/stopping the regular scan.

Bug: 69116550
Test: Enable bluetooth on platform without ACPF, start/stop scan
Change-Id: I334114d36a8af8c8f58d230f75ab3a00f009c4c5

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