OSDN Git Service

android-x86/system-bt.git
7 years agoUse bt_bdaddr_t instead of BD_ADDR
Jakub Pawlowski [Fri, 9 Jun 2017 23:00:25 +0000 (16:00 -0700)]
Use bt_bdaddr_t instead of BD_ADDR

Test: compilation test, sl4a GattReadTest
Change-Id: I8d1bd6914aec55bb53495b1d0d5e3d37b86865e6

7 years agoMerge "Fix some includes"
Treehugger Robot [Tue, 13 Jun 2017 20:36:18 +0000 (20:36 +0000)]
Merge "Fix some includes"

7 years agoFix some includes
Bailey Forrest [Mon, 12 Jun 2017 23:48:02 +0000 (16:48 -0700)]
Fix some includes

- include fcntl.h for O_WRONLY,O_CREAT,O_TRUNC
- Change sys/stat.h, sys/types.h to use <>

Bug: None
Test: Build
Change-Id: I4ce1ceeba8ffdc6ff8b47ae43fcd8764d259f067

7 years agoMove bt_bdaddr_t operator to global header file
Jakub Pawlowski [Fri, 9 Jun 2017 21:02:03 +0000 (14:02 -0700)]
Move bt_bdaddr_t operator to global header file

This is to simplify bt_bdaddr_t handling

Test: compilation
Change-Id: I06ac6c2f0402ed13a2c04f86494d3c4fd0165963

7 years agoMerge "smp: Fix long SMP_Trace_* log messages"
Treehugger Robot [Fri, 9 Jun 2017 22:00:10 +0000 (22:00 +0000)]
Merge "smp: Fix long SMP_Trace_* log messages"

7 years agoMerge "bta: Update APPL_TRACE_* logs and call parameter"
Treehugger Robot [Fri, 9 Jun 2017 21:59:05 +0000 (21:59 +0000)]
Merge "bta: Update APPL_TRACE_* logs and call parameter"

7 years agobta: Update APPL_TRACE_* logs and call parameter
jruthe [Wed, 31 May 2017 20:55:42 +0000 (13:55 -0700)]
bta: Update APPL_TRACE_* logs and call parameter

Also update messages to use __func__ rather than hard-coding
function names in log messages.

Test: Pair two devices
Change-Id: I8d3a9e293c71775caee420b8da6bc3e4385a46dd

7 years agosmp: Fix long SMP_Trace_* log messages
johnshamoon [Wed, 31 May 2017 18:32:24 +0000 (11:32 -0700)]
smp: Fix long SMP_Trace_* log messages

Test: Manually pair two devices
Change-Id: Iebf43688220922563c0e1028d9e75a4cae2fc1bd

7 years agoGet rid of GATT_TRACE_* logs in favour of base/logging.h
Jakub Pawlowski [Fri, 9 Jun 2017 00:04:47 +0000 (17:04 -0700)]
Get rid of GATT_TRACE_* logs in favour of base/logging.h

Change-Id: Id77d313c5bff5e611441599da351a766d0ce5916

7 years agoMerge "Include used STL header files"
Treehugger Robot [Fri, 9 Jun 2017 04:06:00 +0000 (04:06 +0000)]
Merge "Include used STL header files"

7 years agoMerge "eSCO: Limit number of retries after mSBC connection failure"
Treehugger Robot [Fri, 9 Jun 2017 03:08:26 +0000 (03:08 +0000)]
Merge "eSCO: Limit number of retries after mSBC connection failure"

7 years agoMerge "GATT write improvements"
Jakub Pawlowski [Fri, 9 Jun 2017 02:01:29 +0000 (02:01 +0000)]
Merge "GATT write improvements"

7 years agoGATT write improvements
Jakub Pawlowski [Thu, 8 Jun 2017 19:27:30 +0000 (12:27 -0700)]
GATT write improvements

When doing GATT write, crash if p_clcb->p_attr_buf is null, or if
op_subtype is unknown. Both of this cases signal possible memory
corruption, and should be treated as fatal.
Properly handle GATT_CONGESTED error when doing long write.

Test: compilation test
Change-Id: Ia56f3bbd06cde2978b0ce2210ebe58042504938c

7 years agoeSCO: Limit number of retries after mSBC connection failure
Jack He [Wed, 7 Jun 2017 23:44:30 +0000 (16:44 -0700)]
eSCO: Limit number of retries after mSBC connection failure

* When peer device supports mSBC and codec negotiation, Fluoride stack
  will try to do the following when establishing a eSCO/SCO connection:
    1) Negotiate to mSBC by sending +BCS:2
    2) Try establishing eSCO/SCO connection using mSBC T2 settings
    3) If that failed, downgrade to mSBC T1 settings and retry
    4) If that failed, re-negotiate codec to CVSD, by sending +BCS:1
    5) Retry using CVSD S4 (HFP 1.7 and above) or S3 settings
    6) If this failed stop trying and report failure to upper stack
* Retry is achieved by:
    * Retry is only possible when inuse_codec = BTA_AG_CODEC_MSBC
    * Set codec_msbc_settings to BTA_AG_SCO_MSBC_SETTINGS_T1 when T2
       failed to connect in step 3 above
    * Set codec_fallback to true when T1 failed so that CVSD is used
       in step 4 above
* Retry stop is achieved by:
    * Set inuse_codec = BTA_AG_CODEC_CVSD
    * Set codec_msbc_settings back to BTA_AG_SCO_MSBC_SETTINGS_T2
    * Set codec_fallback to false and codec_updated to true so that
      the stack is ready for the next application triggerred SCO
      connection attempt
* Removed retry_with_sco_only as both Setup Synchronous Connection
  Command (0x0028) and Enhanced Setup Synchronous Connection Command
  (0x003D) fall back to SCO connection if eSCO is not supported.
  See page 858/2772 and 895/2772 of BT4.2 specification document
* Besides both code paths are the same for retry_with_sco_only after
  eSCO changes went in

Bug: 62426841
Test: make, HFP regression, testplans/91406
Change-Id: I205311c55e8763c48b6eb43c27f242927384036e

7 years agoInclude used STL header files
Bailey Forrest [Thu, 8 Jun 2017 23:29:28 +0000 (16:29 -0700)]
Include used STL header files

Without these, cpplint's include-what-you-use fails.

Bug: None
Test: Build
Change-Id: I99954688b0041b10cfb7c18c8744cd889bf7a22e

7 years agoIgnore the Class Of Device if the value is invalid
Pavlin Radoslavov [Thu, 8 Jun 2017 22:22:52 +0000 (15:22 -0700)]
Ignore the Class Of Device if the value is invalid

If a Bluetooth Device is dual-mode and is discoverable as both
a Classic and a LE device, ignore unknown "zero" values
triggered by the LE advertisements. Otherwise, those could overwrite
a valid (previously discovered) Class Of Device.

Bug: 37615863
Test: Manual with LG HBS1100 headset
Change-Id: I5a0f6ef56248b41d973b850a5542475e45e0312d

7 years agoMerge "Add tracking of periodic_enable in adv_inst"
Jakub Pawlowski [Thu, 8 Jun 2017 22:58:56 +0000 (22:58 +0000)]
Merge "Add tracking of periodic_enable in adv_inst"

7 years agoMerge "gatt_api minor style fixes"
Jakub Pawlowski [Thu, 8 Jun 2017 22:43:23 +0000 (22:43 +0000)]
Merge "gatt_api minor style fixes"

7 years agoMerge "Don't handle server respons after it was deallocated"
Jakub Pawlowski [Thu, 8 Jun 2017 22:40:13 +0000 (22:40 +0000)]
Merge "Don't handle server respons after it was deallocated"

7 years agoMerge "Ensure we don't send more packets than firmware allows"
Treehugger Robot [Thu, 8 Jun 2017 19:41:33 +0000 (19:41 +0000)]
Merge "Ensure we don't send more packets than firmware allows"

7 years agoMerge "Fix transport quota exhaustion"
Treehugger Robot [Thu, 8 Jun 2017 19:39:00 +0000 (19:39 +0000)]
Merge "Fix transport quota exhaustion"

7 years agogatt_api minor style fixes
Jakub Pawlowski [Thu, 8 Jun 2017 19:27:30 +0000 (12:27 -0700)]
gatt_api minor style fixes

Test: compilation test
Change-Id: I7656513b2999cec5aefbb5b9f75e10e9436d0412

7 years agoAdd tracking of periodic_enable in adv_inst
Sunny Kapdi [Sat, 3 Jun 2017 01:11:05 +0000 (18:11 -0700)]
Add tracking of periodic_enable in adv_inst

Track state of periodic advertisement similar to
extended advertisement. Make sure periodic adv
is disabled prior to calling remove adv set

Test: net_test_stack_multi_adv
Bug: 62306759
Change-Id: I677211a0bca40e7151c8c7ee138bac623888291d

7 years agoAllow blocking AG SCO connects by policy
Zach Johnson [Wed, 19 Apr 2017 04:03:07 +0000 (21:03 -0700)]
Allow blocking AG SCO connects by policy

Needed for devices that support both HFP AG and HFP HF.

btsnoop logs show the sequence of events leading to failure:
(corroborated by bt logcat)

1. ACL connection with remote phone established on handle 0x01
2. ACL connection with remote headset established on handle 0x02
3. Incoming call in HF role from phone
4. Phone call locally published to telecom
5. Answer incoming call
6. SCO connection established with phone in HF role
7. AG role with headset picks up on call state change to answered
   via BTA_AG_IN_CALL_CONN_RES
8. Inside handler for BTA_AG_IN_CALL_CONN_RES, bta_ag_sco_open called
   to establish the SCO connection in the AG role with the headset,
   stomping on the previous (wanted) SCO connection with the phone.

Fix is to publish the SCO audio route policy to fluoride, so we can
stop 8 from happening.

Bug: 32958838
Test: manual:
      received incoming call in HF role, audio worked both ways;
      recieved incoming MT call, headset audio in AG role worked both ways
Change-Id: I12961598e8200bd1d5adb46ee8ec3a802114b80a

7 years agoEnsure we don't send more packets than firmware allows
Yamei Du [Wed, 18 Nov 2015 09:28:07 +0000 (17:28 +0800)]
Ensure we don't send more packets than firmware allows

Make TX complete callback after we've sent the packet
to the lower layers and adjusted our in flight packet
count.

Bug: 26763700
Test: manual
Change-Id: Iaba14a11c1583da2a72769ebd096e0baedf857c3

7 years agoFix transport quota exhaustion
Ruina Liu [Thu, 24 Sep 2015 02:04:16 +0000 (10:04 +0800)]
Fix transport quota exhaustion

BREDR and BLE use round-robin for link quota.

If you have exhausted one transport's quota,
the break will cause traffic for all transports
to cease.

Change to a continue to prevent this.

Change-Id: I7ca739dfbf02acd2e30527c16ca616a7bad70c51
Test: manual
CR-Id: ALPS02303646

7 years agoDon't handle server respons after it was deallocated
Jakub Pawlowski [Thu, 8 Jun 2017 17:22:51 +0000 (10:22 -0700)]
Don't handle server respons after it was deallocated

After a request is send to the GATT server, it might timeout, or get
cancelled, i.e. by client unregistering. If a response to such request
is later received, it should not be parsed. Currently such response is
parsed, and can call the response callback again, also on already
unregistered app.

Test: compilation test
Change-Id: Ia76770a693cd35d49973462c4d233d70f8a4e165

7 years agoMerge changes If7a360bf,Ibc20c110
Jakub Pawlowski [Thu, 8 Jun 2017 17:43:54 +0000 (17:43 +0000)]
Merge changes If7a360bf,Ibc20c110

* changes:
  gatt_cleanup_upon_disc refactor
  Simplify read/write start

7 years agoMerge "Misc native service changes"
Treehugger Robot [Thu, 8 Jun 2017 03:42:32 +0000 (03:42 +0000)]
Merge "Misc native service changes"

7 years agogatt_cleanup_upon_disc refactor
Jakub Pawlowski [Thu, 8 Jun 2017 00:29:26 +0000 (17:29 -0700)]
gatt_cleanup_upon_disc refactor

gatt_end_operation internally always call gatt_clcb_dealloc. Make sure
both those methods don't get called in gatt_cleanup_upon_disc. Also
minor style fixes.

Test: compilation test
Change-Id: If7a360bfd1ac2ccd7bb1565e8efe459333f8f025

7 years agoSimplify read/write start
Jakub Pawlowski [Sat, 3 Jun 2017 18:04:04 +0000 (11:04 -0700)]
Simplify read/write start

When read or write is started with insuficcient encryption, and the
encryption fails, it will either return immediate error
GATT_NO_RESOURCES, or the operation will be enqueued. In case the
enqueued operation fails again on the BTM_SetEncryption, no callback
will never be called, and no operation error will be returned. The
gatt_end_operation will never get called for the CLCB, and it will never
be freed, causing memory leak.

This patch fixes this by making sure that the call to
gatt_security_check_start always consumes the CLCB - either by executing
operation, queuing it, or returning error. This also ensures that if
BTM_SetEncryption fails, it will always be handled the same way - by
calling the callback.

Test: manual
Change-Id: Ibc20c1101cc7b5b6043e75df93b23a5b24b791e9

7 years agoMisc native service changes
Bailey Forrest [Wed, 7 Jun 2017 21:41:54 +0000 (14:41 -0700)]
Misc native service changes

Bug: None
Test: Build bluetoothtbd
Change-Id: Ie81e023735799a726a5fdd62c443795beaf3eeac

7 years agoAdd flag to bluetoothtbd to enable bluetooth on startup
Bailey Forrest [Wed, 7 Jun 2017 21:50:08 +0000 (14:50 -0700)]
Add flag to bluetoothtbd to enable bluetooth on startup

Bluetooth startup takes a few seconds and it can be done in parallel
during the boot up process.

Bug: None
Test: Test on device.
Change-Id: Ia23bdd6907b6f24d1e3eacb011173acf64a583ed

7 years agoFix GATT over BREDR not connecting
Jakub Pawlowski [Wed, 7 Jun 2017 18:26:36 +0000 (11:26 -0700)]
Fix GATT over BREDR not connecting

For BREDR connections, the upper stack always sends the request with
transport type DUMO, and this should be treated as BREDR if the device
is not known as LE only.

Bug: 62387078
Test: pts GattOverBrEdrTest
Change-Id: I726252e85e78bff2c9585332d2748a0d92a9f6d3

7 years agoFix loops iteration
Jakub Pawlowski [Wed, 7 Jun 2017 16:07:26 +0000 (09:07 -0700)]
Fix loops iteration

The erase() already increment the iterator. If the loop additionally do
"it++", it will skip some elements, and might iterate over the end.

Test: compilation test
Change-Id: Ibd9c993d8e80d807f5d7bc920da36ee538477438

7 years agoDisable 48.0kHz sampling rate for AAC
Pavlin Radoslavov [Fri, 2 Jun 2017 17:45:43 +0000 (10:45 -0700)]
Disable 48.0kHz sampling rate for AAC

Some carkits have issues playing A2DP audio using AAC with 48.0kHz
sampling rate, while playing AAC with 44.1kHz sampling rate is fine.

Bug: 38443632
Bug: 62301376
Test: manual
Change-Id: I50de2db1d5386d41bfe361fbac99fc7ebbbd3640

7 years agoUse std::unordered_set for keeping app_hold_link
Jakub Pawlowski [Mon, 5 Jun 2017 22:23:32 +0000 (15:23 -0700)]
Use std::unordered_set for keeping app_hold_link

Change-Id: Ia8a0c9a2264979c1ff89faa5ddf17a83fcb7c7ce

7 years agoGet rid of clcb_idx in favour of pointers
Jakub Pawlowski [Wed, 31 May 2017 16:44:00 +0000 (09:44 -0700)]
Get rid of clcb_idx in favour of pointers

Test: compilation test
Change-Id: Ib2c4b13b85343693e6cff4a94eed49382e3aec00

7 years agouse std::queue for keeping tGATT_CMD_Q
Jakub Pawlowski [Wed, 31 May 2017 00:19:46 +0000 (17:19 -0700)]
use std::queue for keeping tGATT_CMD_Q

Test: compilation
Change-Id: I4df9a075d27a306067c48c652f5da1fb156c4a9b

7 years agoRefactor tGATT_BG_CONN_DEV
Jakub Pawlowski [Tue, 6 Jun 2017 17:03:07 +0000 (10:03 -0700)]
Refactor tGATT_BG_CONN_DEV

* Use list for keeping the devices instead of fixes array, get rid of
  the in_use field.
* Use unordered_set instead of array to keep gatt_if of apps interested
  in specific device.
* the in_use flag was never cleared before, this had the potential to
  fill the whole array when multiple devices were addred/removed to the
  whitelist. This issue is fixed now.

Test: compilation test
Change-Id: Id87c2ae9c5b0ce0887a4fa9be50e34d646d22a13

7 years agoMerge "Suppress false compiler warnings"
Treehugger Robot [Wed, 7 Jun 2017 00:25:50 +0000 (00:25 +0000)]
Merge "Suppress false compiler warnings"

7 years agoSuppress false compiler warnings
Ting-Yuan Huang [Tue, 9 May 2017 22:57:40 +0000 (15:57 -0700)]
Suppress false compiler warnings

In theory, static analyzer can't be 100% acurate for certain types of
analysis.

Bug: 38178471
Test: Built without seeing these warnings.
Change-Id: I63d2d02565cc040189ed70813eb42e06dd8c9f2a

7 years agoLinux build fix
Jakub Pawlowski [Tue, 6 Jun 2017 22:11:30 +0000 (15:11 -0700)]
Linux build fix

Change-Id: I2850577447a605877a8bc12f5ad852cacf4e0b3e

7 years agoGet rid of BTA_GATTC_API_REFRESH_EVT
Jakub Pawlowski [Mon, 5 Jun 2017 19:42:45 +0000 (12:42 -0700)]
Get rid of BTA_GATTC_API_REFRESH_EVT

Test: compilation test
Change-Id: I631962183ac63d2b168005060bb1f0d4964b0884

7 years agoGet rid of trivial BTA_GATTC_ events
Jakub Pawlowski [Mon, 5 Jun 2017 19:20:04 +0000 (12:20 -0700)]
Get rid of trivial BTA_GATTC_ events

Test: compilation test
Change-Id: I8c705d1bb0532cbe0dd69b1f3b0b5d1a63534a23

7 years agoInitial DBus transport support
Jakub Pawlowski [Mon, 31 Oct 2016 19:56:12 +0000 (12:56 -0700)]
Initial DBus transport support

This patch adds initial support for DBus transport on Linux. It exposes
initial implementation of Adapter that can be Enabled and Disabled. One
can also introspect the interface to find the exposed methods. Further
patches will extend it's functionality.

Test: ninja -C out/Default -j 40
Change-Id: I173cc752b8d8aaa8706ed36f75f5a043cc987b1a

7 years agoFix order of parameters to BTA_GATTC_Open
Jakub Pawlowski [Sat, 3 Jun 2017 23:39:04 +0000 (16:39 -0700)]
Fix order of parameters to BTA_GATTC_Open

Different order of parameters in different flavours of method caused
bug in btif_gatt_client.cc, where every client would be started as
opportunistic. This issue was introduced in commit
16bb48b320cde54a1a06a525f4d9be1421689649

Bug: 34951749
Test: sl4a GattReadTest was flaky without this patch
Change-Id: I243b11bd8e2c0da9f01cbd3eab95dc808bd54006

7 years agoPass GATT cb's by reference and other style fixes
Jakub Pawlowski [Tue, 30 May 2017 18:21:04 +0000 (11:21 -0700)]
Pass GATT cb's by reference and other style fixes

Test: compilation test
Change-Id: I410d0d0a0bf49b9f3ca5e034c66fe8e82661cee7

7 years agoUse std::queue for pending_enc_clcb
Jakub Pawlowski [Tue, 30 May 2017 16:59:54 +0000 (09:59 -0700)]
Use std::queue for pending_enc_clcb

Test: 62188929
Change-Id: Ide07f15c5e5b6bc8b93ac350081b7bef7c7b3938

7 years agoFix params of SetPeriodicAdvertisingParameters
Sunny Kapdi [Thu, 1 Jun 2017 21:34:03 +0000 (14:34 -0700)]
Fix params of SetPeriodicAdvertisingParameters

Fix the sequence of SetPeriodicAdvertisingParameters
in the hci_cmd

Bug: 62268713
Change-Id: Ibdcd362458e9d7ee2f95106a2aefa76e1c264103

7 years agoGATT: Fixed typo while notifying connection update
Avish Shah [Wed, 31 May 2017 05:13:57 +0000 (10:43 +0530)]
GATT: Fixed typo while notifying connection update

Current conditions checks whether the app registered for
PHY_UPDATE instead it should check for CONN_UPDATE.

Bug: 62206018
Test: Manual
Change-Id: Ie9d068a24d13ea0b186b0ca874531aa4ffd1121f

7 years agoHCI: Improve timeout handling
Myles Watson [Wed, 24 May 2017 20:16:40 +0000 (13:16 -0700)]
HCI: Improve timeout handling

Remove pending commands before enqueueing new ones and log all
pending commands when there is a timeout.

Bug: 37298084
Test: set the timeout to 20ms
Change-Id: I90a48db46a78f75dd78e468ee2d5c948afc1850e

7 years agoHCI: Get debug info from the firmware on timeout
Myles Watson [Tue, 9 May 2017 23:50:00 +0000 (16:50 -0700)]
HCI: Get debug info from the firmware on timeout

Bug: 37298084
Test: set the timeout to 20ms

Change-Id: I8b9815a03a15dcb6ce78c0692874b55cb4fc07bc

7 years agoGet rid of unused tGATT_SCCB
Jakub Pawlowski [Sat, 27 May 2017 01:51:27 +0000 (18:51 -0700)]
Get rid of unused tGATT_SCCB

Test: compilation test
Change-Id: I32fee6a93442c8415f7d855c1e4802bceb6fe5ff

7 years agoMerge "HSP: Use peer_version during SCO setup"
Treehugger Robot [Sat, 27 May 2017 01:58:34 +0000 (01:58 +0000)]
Merge "HSP: Use peer_version during SCO setup"

7 years agoMerge changes I0f43061b,I48c18401,I5073e800,I2c0926c7,I73120878
Treehugger Robot [Sat, 27 May 2017 00:50:22 +0000 (00:50 +0000)]
Merge changes I0f43061b,I48c18401,I5073e800,I2c0926c7,I73120878

* changes:
  Get rid of AMP_INCLUDED
  Get rid of GAP control block
  Get rid of GAP_TRACE_* logs
  Get rid of GAP_CONN_INCLUDED
  BLE GAP simplification

7 years agoGet rid of AMP_INCLUDED
Jakub Pawlowski [Fri, 26 May 2017 22:54:23 +0000 (15:54 -0700)]
Get rid of AMP_INCLUDED

Change-Id: I0f43061b150cfc61bb31cfc7a580592454cfbf9f

7 years agoGet rid of GAP control block
Jakub Pawlowski [Fri, 26 May 2017 22:49:07 +0000 (15:49 -0700)]
Get rid of GAP control block

Instead of global GAP control block, use separate block for gap_conn.cc
and gap_ble.cc

Change-Id: I48c18401390300f80285ba5491e8d91ee63d55ef

7 years agoGet rid of GAP_TRACE_* logs
Jakub Pawlowski [Fri, 26 May 2017 22:16:15 +0000 (15:16 -0700)]
Get rid of GAP_TRACE_* logs

This is a step required for making GAP testable, and not dependent on
any global log structures.

Change-Id: I5073e800cf842864021328308feb59a409927b2b

7 years agoGATT: Interop fix for service changed indications
Myles Watson [Fri, 26 May 2017 00:24:49 +0000 (17:24 -0700)]
GATT: Interop fix for service changed indications

The Pixel C Keyboard disconnects if it receives an indication
for which it hasn't registered.

Test: Add a GATT service with Pixel C connected
Bug: 34352677
Change-Id: I1f717db40b2ba9ec21feac5fd9e339c09f140d51

7 years agoGet rid of GAP_CONN_INCLUDED
Jakub Pawlowski [Fri, 26 May 2017 21:36:51 +0000 (14:36 -0700)]
Get rid of GAP_CONN_INCLUDED

Change-Id: I2c0926c7c935b6efe1f0ea35a86ed89edb746096

7 years agoBLE GAP simplification
Jakub Pawlowski [Thu, 25 May 2017 16:05:23 +0000 (09:05 -0700)]
BLE GAP simplification

Test: manual
Change-Id: I73120878aadf41e54f8eb1aae75e9f9bbb1df942

7 years agoHSP: Use peer_version during SCO setup
Jack He [Tue, 23 May 2017 02:23:04 +0000 (19:23 -0700)]
HSP: Use peer_version during SCO setup

* HSP profile should use peer_version obtained through SDP search to
  determine its behavior during SCO setup instead of a local version
  during initialization
* Added a WARNING message if SDP search failed to get remote HSP
  version, the default behavior is to use HSP 1.0
* Changed SDP search initialization to look for one UUID at a time
* See Bluetooth Erratum 3507

Test: make, HSP PTS test
Bug: 38210042
Change-Id: I67ce615a785b25a2e9304613a29d9be66a656c54

7 years agoRemove dead code from GAP
Jakub Pawlowski [Fri, 26 May 2017 17:25:02 +0000 (10:25 -0700)]
Remove dead code from GAP

Test: none
Change-Id: I23badbf73420e4af26e6d84f7b04fcd56100b122

7 years agoMerge "MCAP: Add a test tool for MCAP"
Treehugger Robot [Thu, 25 May 2017 22:32:19 +0000 (22:32 +0000)]
Merge "MCAP: Add a test tool for MCAP"

7 years agoFix GATT Server disconnecting for no reason
Jakub Pawlowski [Thu, 25 May 2017 16:09:12 +0000 (09:09 -0700)]
Fix GATT Server disconnecting for no reason

Connections created by GAP profile should be ephemeral, and not
interfere with the connection timeout.

When a device is bonded, listing services through DM would cause a
DM APP to create a connection, and later to disconnect. This causes
connection to timeout. In case a device was already connected, this
should not happen.

Bug: 34951749
Test: manual
Change-Id: Iad04fd9eed4c664f35131442e3f83a704497a067

7 years agoRevert "Fix GATT Server disconnecting for no reason"
Jakub Pawlowski [Thu, 25 May 2017 20:24:28 +0000 (13:24 -0700)]
Revert "Fix GATT Server disconnecting for no reason"

This reverts commit b69edd55ffe953d4f71f4a948e3feb2243223980.

7 years agoMCAP: Add a test tool for MCAP
Jack He [Thu, 18 May 2017 05:26:05 +0000 (22:26 -0700)]
MCAP: Add a test tool for MCAP

* Add a command line tool for MCAP related tests
* This tool can access the Bluetooth stack via a command line program
* Type "help" to obtain a list of available console commands in this
  Bluetooth
* Bluetooth must be disabled when this tool is running

Bug: 37867299
Test: make, PTS MCAP test
Change-Id: I106e6625ee8a29b7fdad88cdfeb99419054ef771

7 years agoFix crashes when GAP operation is interrupted by disconnection
Jakub Pawlowski [Thu, 25 May 2017 15:21:53 +0000 (08:21 -0700)]
Fix crashes when GAP operation is interrupted by disconnection

Also fixes potential issue while allocating control blocks.

Test: none
Bug: 38499153
Change-Id: I5101ac97476953cdfece45c3fa9b909e38b9d2dd

7 years agoFix GATT Server disconnecting for no reason
Jakub Pawlowski [Wed, 24 May 2017 23:15:21 +0000 (16:15 -0700)]
Fix GATT Server disconnecting for no reason

When two devices are bonded, even if the device is supposed to act just
as a GATT Server, service discovery is performed. Doing "read by type"
should not trigger connection timeout, or disconnection, as the server
should wait for the client to finish connection.

Please note that it does not GATT Client behaviour, as they manage the
connection timeout through L2CA_SendFixedChnlData called on each data
packet.

Bug: 34951749
Test: manual
Change-Id: If53cf63dc204238a60839497992c870b1b39aa60

7 years agoMCAP: Add test interface for PTS test (2/2)
Jack He [Sat, 13 May 2017 20:52:12 +0000 (13:52 -0700)]
MCAP: Add test interface for PTS test (2/2)

* PTS tests requires MCAP APIs to be called at protocol level
* This CL creates a test interface to enable the above functionality

Bug: 37867299
Test: make, no user visible effect
Change-Id: I15cc6cc613ce8f7c57564296e45077ab877c269b

7 years agoMCAP: Fix bugs in MCAP stack
Jack He [Thu, 18 May 2017 05:22:18 +0000 (22:22 -0700)]
MCAP: Fix bugs in MCAP stack

* Fix error response message for clock sync opcodes
* Fix error response message for CREATE_MDL opcode
* Fix logging in the MCAP stack

Bug: 37867299
Test: make, PTS MCAP test
Change-Id: I7a37ac04806bca20d732357f00b4761577b4be19

7 years agoMerge "Remove logspam when initializing logging for Bluetooth"
Treehugger Robot [Mon, 22 May 2017 21:55:19 +0000 (21:55 +0000)]
Merge "Remove logspam when initializing logging for Bluetooth"

7 years agoRemove logspam when adding GATT attributes
Ajay Panicker [Wed, 17 May 2017 01:46:22 +0000 (18:46 -0700)]
Remove logspam when adding GATT attributes

Bug: 37905488
Test: Code still compiles
Change-Id: I479fc82a15f977b7e3d50b07302241909efc8856

7 years agoRemove logspam when initializing logging for Bluetooth
Ajay Panicker [Wed, 17 May 2017 05:43:51 +0000 (22:43 -0700)]
Remove logspam when initializing logging for Bluetooth

Bug: 37803501
Test: Code still compiles
Change-Id: I9326e58aff0d80e441cb92c41e0e4a7d70e32b1b

7 years agoMerge "Protect the message loop from accesses after HCI shutdown"
Treehugger Robot [Thu, 18 May 2017 01:12:49 +0000 (01:12 +0000)]
Merge "Protect the message loop from accesses after HCI shutdown"

7 years agoProtect the message loop from accesses after HCI shutdown
Pavlin Radoslavov [Wed, 17 May 2017 01:50:43 +0000 (18:50 -0700)]
Protect the message loop from accesses after HCI shutdown

Bug: 38330724
Test: Manual: enable/disable Bluetooth
Change-Id: Iaece4cd608c67b28b436ded9fcc51c0bf28f4098

7 years agoProtect concurrent access to local state used during BLE scanning
Jakub Pawlowski [Wed, 17 May 2017 22:23:22 +0000 (15:23 -0700)]
Protect concurrent access to local state used during BLE scanning

Make sure that all access happens on jni thread

Bug: 38298938
Test: Code compilation
Change-Id: I38246626d2c6390586b314b27889dd9ba905f406

7 years agoBlacklist Kinivo BTC350 for Absolute Volume
Marie Janssen [Wed, 17 May 2017 01:40:45 +0000 (18:40 -0700)]
Blacklist Kinivo BTC350 for Absolute Volume

The volume is erratic on the speakers when the speaker is reporting
linear increase, with decreases for higher volumes.

Test: check that absolute volume not used for Kinivo Speakers
Bug: 37872586
Change-Id: Ic5f409e8631bece66a75372b916faa9c104e2024

7 years agoDisable MONO channel mode for LDAC
Pavlin Radoslavov [Tue, 16 May 2017 23:20:23 +0000 (16:20 -0700)]
Disable MONO channel mode for LDAC

Bug: 38351937
Test: A2DP streaming to LDAC headset and switching MONO/STEREO in Settings
Change-Id: I20c5069fd5d104b9ebe767ae2728af7d7b2ae1d9

7 years agoDiscover primary service by UUID for PTS tests (1/4)
Jakub Pawlowski [Tue, 16 May 2017 17:47:54 +0000 (10:47 -0700)]
Discover primary service by UUID for PTS tests (1/4)

Bug: 38123054
Test: manual
Change-Id: Ic97a964ca2a25a84c6abcf41acb0f3fb583488a2

7 years agoFix crash on GATT service unregistration
Jakub Pawlowski [Mon, 15 May 2017 07:58:07 +0000 (00:58 -0700)]
Fix crash on GATT service unregistration

When SDP_MAX_RECORDS were reached in SDP db, which usually happen by
registering big number of GATT services, unregistration of a service was
causing a crash. This was because we moved from memory after the array
into last element.

Bug: 38265174
Test: manual
Change-Id: I7b0235213fb07c85dcc1245f1c840b41267521d5

7 years agoFix BLE white list issues
Emil Lenngren [Mon, 19 Dec 2016 19:21:19 +0000 (19:21 +0000)]
Fix BLE white list issues

Since Bluetooth 4.2 and errata ESR08 there may not be more than one
connection between two LE device addresses. Also the stack assumes
there is at maximum one connection to the same address. This patch
makes sure there are no connected devices in the white list when a
connection attempt is started. Since some (even 4.2) controllers don't
handle this correctly, currently this method is used regardless of
controller in this patch.

When the maximum L2CAP connections were reached and a new connection
was established to a device using auto connect, the stack hung and
would no longer create new connections until Bluetooth was restarted,
since the state change to BLE_CONN_IDLE was forgotten. This patch
resets the state correctly, and also never initiates a connection
unless there is space to avoid connect-disconnect loop.

There were also bugs in the background_connections hash map; memory was
not freed when an element was erased and an incorrect hash function
which used the pointer to a bd addr instead of the bd addr itself which
basically meant that elements were never removed. This patch removes
the dynamic memory allocation and uses a correct hash function.

There was a bug that might lead to that the white list was filled
beyond its maximum, due to the counter was updated on the HCI command
complete event, which might run too late. Now the space is instead
calculated based on what commands have been sent to the controller.

The address type of the address added to the white list must also be
tracked, otherwise it might be updated due to a BLE scan, and later the
wrong address is removed from the white list. This patch fixes this.
(Preferably 49-bit bd addrs should be used as identifier through the
whole stack but we're not there yet.)

There was a queue of size 10 with pending white list operations. That
queue got full if there was initially 10 devices in the white list,
then the 10 devices were removed and immediately after 10 other devices
were added. This patch removes the queue altogether by instead syncing
against the background_connections hash map.

Bug: https://code.google.com/p/android/issues/detail?id=219910
Test: stress-testing with a bunch of BLE devices and inspecting HCI log
Change-Id: I78de654ffbea5f4962a189caf984f7f2934e8fbe

7 years agoDon't ignore the A2DP Sink preferred SBC codec config
Pavlin Radoslavov [Fri, 12 May 2017 10:02:08 +0000 (03:02 -0700)]
Don't ignore the A2DP Sink preferred SBC codec config

If the A2DP Sink device sends "Set Configuration" with its preferred
SBC configuration, try using that configuration when selecting
the codec parameters instead of the A2DP Sink SBC capability.

Test: A2DP streaming, PTS AVDTP Tests: TC_ACP_SRC_SIG_SMG_BV_18_C,
      TC_ACP_SRC_SIG_SMG_BV_20_C, TC_ACP_SRC_SIG_SMG_BV_22_C
      PTS A2DP Tests: A2DP/SRC/SET/BV-04-I, A2DP/SRC/SET/BV-06-I
Bug: 37723311
Bug: 35664023
Change-Id: I48e2aa664b899c1cda5df4d1f86f9cfa3a9a67f6

7 years agoSet the RTP Header Marker bit selectively per A2DP codec
Pavlin Radoslavov [Fri, 12 May 2017 08:16:10 +0000 (01:16 -0700)]
Set the RTP Header Marker bit selectively per A2DP codec

Add a mechanism to set the RTP Header Marker bit per codec.
Currently, the Marker bit is set only for AAC.

Test: A2DP streaming, PTS AVDTP tests: TC_ACP_SRC_TRA_BTR_BV_01_C,
      TC_INT_SRC_SIG_SMG_BV_17_C, TC_INT_SRC_TRA_BTR_BV_01_C
Bug: 37723283
Change-Id: I9b8e77d44c750746c169df9628d5539ad2406b92

7 years agoImprove GATT Server database handling.
Jakub Pawlowski [Tue, 9 May 2017 12:02:38 +0000 (05:02 -0700)]
Improve GATT Server database handling.

- use references instead of pointers where possible. Thanks to it we can
  remove some reduntant null checks and simplify the code.
- use directly allocated memory instead of own buffers. Thanks to it the
  stack uses around 12kb less of memory after startup.
- use list and vector from std library, instead of some hand-written
  implementations.

This patch is a prerequisite for further server refactoring, that will
further reduce the space used, make unit-testing possible, and enable
proper handling of PTS GATT tests.

Test: sl4a GattReadTest
Bug: 38225928
Change-Id: I1620be682259ccb8f0c02754806e355e3f1ad0c1

7 years agoDisable output_sample.pcm
Joseph Pirozzo [Thu, 11 May 2017 16:36:47 +0000 (09:36 -0700)]
Disable output_sample.pcm

Update include files to include bt_target.h as it has the necessary
defines to correctly allow bdroid_buildcfg.h to enable and disable
dumping to output_sample.pcm.

Bug: 38180732
Test: Stream Bluetooth audio to device and observe that
output_sample.pcm does not get written or appended to.

Change-Id: Ia7926f93a47489686d315e3c9abd1618cb8adda3

7 years agoMerge "Removed A2DP_GetTrackBitsPerSample() API because it is not needed"
Treehugger Robot [Thu, 11 May 2017 02:10:07 +0000 (02:10 +0000)]
Merge "Removed A2DP_GetTrackBitsPerSample() API because it is not needed"

7 years agoMerge changes from topic 'eSCO'
Treehugger Robot [Thu, 11 May 2017 01:53:44 +0000 (01:53 +0000)]
Merge changes from topic 'eSCO'

* changes:
  eSCO: Format changes to original vendor patch (4/5)
  eSCO: Additional fix to get eSCO working for HFP and HSP (3/5)
  eSCO: Remove BTM_WBS_INCLUDED from the stack (2/5)
  eSCO: BT 4.1 Enhanced SCO command (1/5)

7 years agoMerge "HID: Add support for Set Idle and Get Idle commands (2/4)"
Andre Eisenbach [Thu, 11 May 2017 00:37:42 +0000 (00:37 +0000)]
Merge "HID: Add support for Set Idle and Get Idle commands (2/4)"

7 years agoRemoved A2DP_GetTrackBitsPerSample() API because it is not needed
Pavlin Radoslavov [Thu, 11 May 2017 00:09:00 +0000 (17:09 -0700)]
Removed A2DP_GetTrackBitsPerSample() API because it is not needed

The A2DP_GetTrackBitsPerSample() API was replaced in the past
by A2dpCodecConfig::getAudioBitsPerSample() .
 * Removed A2DP_GetTrackBitsPerSample() and related codec-specific APIs:
   - A2DP_GetTrackBitsPerSampleSbc
   - A2DP_GetTrackBitsPerSampleAac
   - A2DP_GetTrackBitsPerSampleAptx
   - A2DP_GetTrackBitsPerSampleAptxHd
   - A2DP_GetTrackBitsPerSampleLdac
     NOTE: The removed A2DP_GetTrackBitsPerSampleLdac implementation
     had a bug: a2dp_ldac_caps.bits_per_sample -> ldac_cie.bits_per_sample
     This bug itself was uncovered when switching to clang-3960126
   - A2DP_VendorGetTrackBitsPerSample()
 * Replaced few leftover usages of A2DP_GetTrackBitsPerSample()
   A2dpCodecConfig::getAudioBitsPerSample()
 * Updated the unit tests

Test: Code compilation, unit tests, A2DP streaming
Bug: 37752547
Change-Id: I7feeda0f32922b8ef888b157673e3e2ade98b179

7 years agoeSCO: Format changes to original vendor patch (4/5)
Jack He [Mon, 8 May 2017 00:27:47 +0000 (17:27 -0700)]
eSCO: Format changes to original vendor patch (4/5)

* Format changes to original vendor patch
* Re-order part of SCO creation code to improve readability
* Make log more concise and usefull

Bug: 19540029
Test: make, HFP PTS test, testplans/86884, testplans/87103
Change-Id: Ie0199519afb30f56568c04fef728fce44a172063

7 years agoeSCO: Additional fix to get eSCO working for HFP and HSP (3/5)
Jack He [Mon, 8 May 2017 00:26:02 +0000 (17:26 -0700)]
eSCO: Additional fix to get eSCO working for HFP and HSP (3/5)

* Removed vendor specific call after codec negotiation and before eSCO
  command is sent to Bluetooth chip
* Removed vendor specific call after a SCO connection is requested by
  the peer
* Removed vendor specific save audio state methods

Bug: 19540029
Test: make, HFP PTS test, testplans/86884, testplans/87103
Change-Id: I899405a8eaa2f38ee0de04949c5288f9eefa74df

7 years agoeSCO: Remove BTM_WBS_INCLUDED from the stack (2/5)
Myles Watson [Fri, 10 Feb 2017 00:26:34 +0000 (16:26 -0800)]
eSCO: Remove BTM_WBS_INCLUDED from the stack (2/5)

All of our platforms support WBS.

Bug: 19540029
Test: make, HFP PTS test, testplans/86884, testplans/87103
Change-Id: I384d49f73935ebb35b17132e71c85174797c435e

7 years agoeSCO: BT 4.1 Enhanced SCO command (1/5)
Mudumba Ananth [Thu, 9 Feb 2017 17:05:48 +0000 (09:05 -0800)]
eSCO: BT 4.1 Enhanced SCO command (1/5)

Added support for BT 4.1 enhanced SCO feature on the stack.
This feature allows the stack to create a SCO connection with
remote device by using Hci_Enhanced_Setup_Synchronous_Connection
command after checking the controller (4.1) support for
enhanced SCO command.
Added the command parameters to use the command in both wide band
speech(WBS) and narrow band speech(NBS) scenarios.

Number of Broadcom vendor specific commands(VSCs)that are needed
to be sent to Broadcom controllers along with this command have
also been updated accordingly

NOTE: This change would also need a firmware patch for
the feature to work on Broadcom contollers which will
be delivered to Google in a separate change set.

Bug: 19540029
Test: make, HFP PTS test, testplans/86884, testplans/87103
Change-Id: I1014d81be5cbe91078a4484dd072ac3957bfdfe4

7 years agobtif: GetItemAttributes can return no attributes
Marie Janssen [Fri, 14 Apr 2017 21:07:19 +0000 (14:07 -0700)]
btif: GetItemAttributes can return no attributes

If there are no attributes available, it's possible to return zero
attributes from a GetItemAttributes request.

This is triggered by some carkits who are unhappy when they only get
titles back (the only required item) and ask for the rest of the
attributes (which we don't have).

Test: connect to honda carkit and get snoop logs to confirm
Bug: 36055995
Bug: 35956792
Change-Id: I5a31e206565d212e456111d8c6b542c7a1569e5a

7 years agoGATT Server: check UUID
Jakub Pawlowski [Wed, 10 May 2017 11:39:26 +0000 (04:39 -0700)]
GATT Server: check UUID

Characteristic and descriptor can't use UUID equal to GATT Attribute
Types. Using such UUID would result in invalid GATT database, and
crashes during service discovery.

Test: manual
Bug: 38134693
Change-Id: Ide2c21109f885cbc79287452b1dabd3f532de385

7 years agoHID: Add support for Set Idle and Get Idle commands (2/4)
Hemant Gupta [Tue, 30 Jul 2013 10:41:33 +0000 (16:11 +0530)]
HID: Add support for Set Idle and Get Idle commands (2/4)

Provides an interface for application to send Set Idle
and Get Idle commands to remote HID Device. Support for these
two commands was missing from existing code, so existing code
design is reused to add support for these two commands.

Without this support following mandatory PTS test cases for HID 1.0
cannot be passed, TC_HOS_HID_BV_05/06.

Test: Executed PTS tests TC_HOS_HID_BV_05/06 and confirmed if they can
pass

Bug: 34344715
Change-Id: I14bc2dc349354fd87ef8aba25357514398532e87

7 years agoFix broken linux build
Jack He [Thu, 4 May 2017 20:27:25 +0000 (13:27 -0700)]
Fix broken linux build

* Generic linux does not have property_get_int32. Instead,
  osi_property_get_int32() is created to handle OS_GENERIC cases
* Some linux header have sigevent.sigev_notify_attributes typed as
  (pthread_attr_t *) whereas others typed it as (void *), as any pointer
  can be implicitly casted to (void *), the current casting to (void *)
  is unncessary and will break build on systems using (pthread_attr_t *)

Test: make, unit test, no user visible effect
Change-Id: I24b33da453dc9d40656168a3bcd900d9c99219ce

7 years agoMerge "Swap BTA and HCI queues with message loops"
Treehugger Robot [Mon, 8 May 2017 19:27:33 +0000 (19:27 +0000)]
Merge "Swap BTA and HCI queues with message loops"