OSDN Git Service

android-x86/system-bt.git
7 years agoMerge "Generic Bluetooth HAL for standard Linux hci interface"
Treehugger Robot [Wed, 5 Jul 2017 23:27:33 +0000 (23:27 +0000)]
Merge "Generic Bluetooth HAL for standard Linux hci interface"

7 years agoGeneric Bluetooth HAL for standard Linux hci interface
Satish Patel [Wed, 28 Jun 2017 01:35:19 +0000 (18:35 -0700)]
Generic Bluetooth HAL for standard Linux hci interface

This acts as common interface for bluetooth devices (including
USB ones) using the standard Linux bluetooth hci interface.

Much of this code is pulled from hardware/interface/bluetooth
and system/bt/vendor_libs/linux.

Original code used from "system/bt/vendor_libs/linux" was from:
Samuel Ortiz <sameo@linux.intel.com>
Cristian Iorga <cristian.iorga@intel.com>
Pavlin Radoslavov <pavlin@google.com>
Jakub Pawlowski <jpawlowski@google.com>
Myles Watson <mylesgw@google.com>

Orginal code taken from hardware/interface/bluetooth was
contributed by:
Myles Watson <mylesgw@google.com>
Zach Johnson <zachoverflow@google.com>
Treehugger Robot <treehugger-gerrit@google.com>

Tested:
Hikey + on board bluetooth and Hikey + USB bluetooth dongle

Change-Id: I03da10cadfae6ffb298cfccc98e3337ab7db1967
Signed-off-by: Satish Patel <satish.patel@linaro.org>
[jstultz: Migrated code back to system/bt/vendor_libs/linux/.
 Included required sepolicy changes. Reworded and simplified
 commit message. ]
Signed-off-by: John Stultz <john.stultz@linaro.org>
7 years agoDynamic blacklist device for role switch
Srinu Jella [Thu, 8 Dec 2016 13:33:20 +0000 (19:03 +0530)]
Dynamic blacklist device for role switch

- Blacklist the device if it's rejected the role switch for
   max number of times. Same is added to the interop_database.

- Maximum number of failed (BTM_MAX_SW_ROLE_FAILED_ATTEMPTS)
  attempts set to 3 and it is configurable.

- Same blacklisted device is referred by the BTM module when
  any other module like profile is requesting for role switch
  and BTM module returns BTM_REPEATED_ATTEMPTS as the switch
  role status.

Test: Code compilation
Bug: 32999957
Change-Id: Ie999104a2c8ca507605ef3e1d454865cee98dcd2

7 years agoMerge "Add stdint.h for uint*_t types"
Treehugger Robot [Sun, 2 Jul 2017 03:38:39 +0000 (03:38 +0000)]
Merge "Add stdint.h for uint*_t types"

7 years agoRead the correct amount of attributes
Scott Bauer [Fri, 7 Apr 2017 00:35:40 +0000 (18:35 -0600)]
Read the correct amount of attributes

bta_gattc_cache_load currently attempts to read 0xFF attributes into an
allocation sized to num_attr attributes, which can be smaller than 0xFF.

There aren't more than num_attr bytes in correct data, but this breaks
with dynamic buffer overflow checking in CopperheadOS for the read
system call since fread ends up calling read, which obtains the size of
the allocation from the malloc implementation and then aborts due to the
(potential) overflow.

This would also fail with the default enabled _FORTIFY_SOURCE=2 feature
in the Android Open Source Project if osi_malloc was marked with the
alloc_size attribute. The way it wraps malloc loses that information so
fortify checks aren't done for calls like this.

Change-Id: I68bd170d5378c9d9d21cbda376083bc0b857e15c
Signed-off-by: Scott Bauer <sbauer@plzdonthack.me>
[migrated to C++ file, added 0xFFFF limit and wrote commit message]
Signed-off-by: Daniel Micay <danielmicay@gmail.com>
7 years agoMerge changes from topic 'refactor_register'
Treehugger Robot [Fri, 30 Jun 2017 21:09:12 +0000 (21:09 +0000)]
Merge changes from topic 'refactor_register'

* changes:
  Refactor module registration
  gofmt -w build/fluoride.go

7 years agoAdd stdint.h for uint*_t types
Jiyong Park [Tue, 27 Jun 2017 11:51:53 +0000 (20:51 +0900)]
Add stdint.h for uint*_t types

Mising stdint.h causes problem when building with BOARD_VNDK_VERSION,
where global include path is not provided.

Bug: 37342627
Test: BOARD_VNDK_VERSION=current m -j libbt-vendor
Change-Id: I55786baed229a3c9b4282816081a503d18a5a6f0

7 years agoAllow full dev consolidation after pairing
Nitin Arora [Sat, 13 Aug 2016 00:48:11 +0000 (17:48 -0700)]
Allow full dev consolidation after pairing

When BR/EDR and LE RPA device records are present
in the device records and the same remote device is
paired on a new RPA, the device consolidation happens
after the IRK is received. The current consolidation
breaks out of the loop after consolidating one device
record. In such cases, BR dev record is left and when
BR link key is derived, it gets updated in a separate
device record. Since two device records are present at
the same time for the same remote, the keys and static
addresses get picked up from incorrect node and issues
such as "remove device from resolving list seen with {0}
static address" are seen.

The fix includes allowing the host to complete
the consolidation for all device records rather than
breaking at the fist match.

Change-Id: Ic8ea4b831a7ba971eb6a0f54573934a6079b45d5

7 years agoBluetooth - Add tracing for TX queue and LDAC ABR
Philip Cuadra [Fri, 9 Jun 2017 21:36:06 +0000 (14:36 -0700)]
Bluetooth - Add tracing for TX queue and LDAC ABR

For debugging, add tracing to show the length of the TX queue and the
LDAC ABR level.

Test:  Ran bluetooth, took a systrace

Change-Id: Ia23764d68f27ae8209e37c4a0836852d73cf6cbc

7 years agoRename bt_bdaddr_t into RawAddress (3/3)
Jakub Pawlowski [Sun, 25 Jun 2017 00:30:18 +0000 (17:30 -0700)]
Rename bt_bdaddr_t into RawAddress (3/3)

Test: compilation test
Change-Id: I4571721a0c6165a66450ee157a53d8d15bfc45d0

7 years agoMerge "Get rid of BD_ADDR (again)"
Treehugger Robot [Wed, 28 Jun 2017 21:36:09 +0000 (21:36 +0000)]
Merge "Get rid of BD_ADDR (again)"

7 years agoGet rid of BD_ADDR (again)
Jakub Pawlowski [Wed, 28 Jun 2017 19:04:53 +0000 (12:04 -0700)]
Get rid of BD_ADDR (again)

BD_ADDR and BD_ADDR_LEN were defined multiple times. Get rid of the
redefiniton.

Test: compilation test
Change-Id: Ib6e922ce88132045c13ddc28d681a0f673d87407

7 years agoSet the A2DP media channel as a high priority L2CAP link
Ben YoungTae Kim [Tue, 20 Jun 2017 13:56:08 +0000 (19:26 +0530)]
Set the A2DP media channel as a high priority L2CAP link

Use dynamic ACL buffer allocation for high priority links:
1. Ensure dedicated ACL buffers for high priority links
2. Adjust buffer allocation if the priority of the link changes

Test: Manually tested with 4 HID devices and A2DP streaming scenario
Bug: 30787081
Change-Id: Id3c4a76e360aee322e9f8073bd399807e7987990

7 years agoLE State simplification
Jakub Pawlowski [Tue, 27 Jun 2017 00:22:35 +0000 (17:22 -0700)]
LE State simplification

Test: sl4a GattReadTest
Change-Id: I53d9b9a25f39b06e3593311ed9af5b1df10637ed

7 years agoMerge "Fix a inappropriate return of local var address"
Marie Janssen [Tue, 27 Jun 2017 22:51:08 +0000 (22:51 +0000)]
Merge "Fix a inappropriate return of local var address"

7 years agoFix a inappropriate return of local var address
liuchao [Fri, 5 May 2017 03:04:33 +0000 (11:04 +0800)]
Fix a inappropriate return of local var address

Local variable address is returned through giving to
"p_db->p_attrs", which needs to be available after
returned from the function.

Test: mm -j8
Change-Id: I68744d0c925e3ea384a07ad6491fe831d59ee2fd

7 years agoHCI feature/command support check simplification
Jakub Pawlowski [Mon, 26 Jun 2017 20:06:17 +0000 (13:06 -0700)]
HCI feature/command support check simplification

Don't use one-time long constants
Test: compilation test

Change-Id: Iaab8039269215b44608193290de4d140e1399e66

7 years agoRefactor module registration
Colin Cross [Tue, 27 Jun 2017 18:05:21 +0000 (11:05 -0700)]
Refactor module registration

Refactor module registration so that it doesn't need to separately
track properties.

Test: builds, no change to out/soong/build.ninja
Change-Id: I4215b710a37f53ea1d5664bb0f7abbd42d25a3e9

7 years agogofmt -w build/fluoride.go
Colin Cross [Tue, 27 Jun 2017 18:15:25 +0000 (11:15 -0700)]
gofmt -w build/fluoride.go

Test: builds
Change-Id: I158eff9274c97eb59e4e3a63a39d0d5df501cee4

7 years agoDon't send the LE Set Privacy Mode command if it's not supported
Jakub Pawlowski [Mon, 26 Jun 2017 18:26:46 +0000 (11:26 -0700)]
Don't send the LE Set Privacy Mode command if it's not supported

LE Set Privacy Mode is currently guarded by LE Privacy feature, which is
enabled on some 4.x controllers, that don't support LE Set Privcay Mode
that was added in 5.0 spec.

Bug: 62809491
Test: Turn Bluetooth on/off with Angler (4.x) and check for
      Set Privacy Mode
Change-Id: Ie9a164d98558db2e1fe76d90eb6ab93e4cec89d0

7 years agobtif: Pass UIDs changed up to the Java layer
Marie Janssen [Fri, 23 Jun 2017 00:21:10 +0000 (17:21 -0700)]
btif: Pass UIDs changed up to the Java layer

Previously we were simply responding with an INTERIM response and
leaving it at that.

Test: connect to BMW kit and check that interim is sent from Java
Bug: 62775732
Change-Id: Idb7de4417438f0c9697ee5c838b511cdd2223e80

7 years agobluetoothtbd common library reconfiguration
Jakub Pawlowski [Sat, 24 Jun 2017 22:25:07 +0000 (15:25 -0700)]
bluetoothtbd common library reconfiguration

This patch change how code in service/common directory is compiled. Up
till now, .cc files were generated from .aidl, and the .cc files were
build for each target that used them. From now on, static lib is build
from .aidl and .cc files, and it is included into all targets that
require them.

This reduces build steps from around 1240 to 849.

Test: compilation test
Change-Id: Iebaf0c75497bc435dcc013be09a1f82e75547aa3

7 years agoFix crashes on stack shutdown
Jakub Pawlowski [Thu, 22 Jun 2017 19:45:30 +0000 (12:45 -0700)]
Fix crashes on stack shutdown

During stack shutdown, Unregister would sometimes get called after the
stack is already cleaned up, and the AdvertiseManager::Get would crash
on null check assertion. Ensure that stack is initialized before
Unregister call.

Bug: 37888261
Test: none
Change-Id: I7a4bbcd24ec7d24d21d04fe842985baaac899321

7 years agoFix BLE remote address resolution
Jacky Cheung [Wed, 21 Jun 2017 16:44:23 +0000 (09:44 -0700)]
Fix BLE remote address resolution

The hash segment of the resolvable device address needs to be extracted
for comparison.

Bug: 62589903
Test: manual
Change-Id: I979a8ad3074b692503b0c882bd90041ba4fbfb4d

7 years agoUse references in GATT client/server API (2/3)
Jakub Pawlowski [Wed, 21 Jun 2017 07:00:18 +0000 (00:00 -0700)]
Use references in GATT client/server API (2/3)

This allows to get rid of some unnecessary null checks, and guarantee
proper values are passed.

Test: compilation test
Change-Id: I1b790dba0cfc3ab02984c3911d83a6f413a1e7e6

7 years agoFix peer address type in LE extended create connection command
Subramanian Srinivasan [Fri, 9 Jun 2017 00:19:05 +0000 (17:19 -0700)]
Fix peer address type in LE extended create connection command

As per BT Spec 5.0, peer address type in LE extended create
connection command can have only either 0x00 or 0x01 as valid
values. This change fixes setting of incorrect peer address
type values in extended create connection command.

Bug: 62578331
Bug: 62358300
Change-Id: I792d48be7637fc571727e7e51de1fc397158b4d5

7 years agoMerge "Make GATT client and server assumption about addres type in open identical"
Jakub Pawlowski [Wed, 21 Jun 2017 14:24:54 +0000 (14:24 +0000)]
Merge "Make GATT client and server assumption about addres type in open identical"

7 years agoMake GATT client and server assumption about addres type in open identical
Jakub Pawlowski [Tue, 20 Jun 2017 18:40:36 +0000 (11:40 -0700)]
Make GATT client and server assumption about addres type in open identical

When attempting to open GATT server to device of unknown type, it should
make same assumption about the type as GATT client, which is LE device.

Test: compilation test
Bug: 62827460
Change-Id: Ic96de97445a843ef3c482fd5b54098b325fb0f9c

7 years agoUnify the empty and any address usage
Jakub Pawlowski [Mon, 19 Jun 2017 18:35:07 +0000 (11:35 -0700)]
Unify the empty and any address usage

Test: compilation test
Change-Id: Ic7fae4aa6c6c32e08fbca257dd3629f4f8df92f0

7 years agoMerge "Disable 48.0kHz sampling rate for AAC - update the unit test"
Treehugger Robot [Tue, 20 Jun 2017 16:19:38 +0000 (16:19 +0000)]
Merge "Disable 48.0kHz sampling rate for AAC - update the unit test"

7 years agoDisable 48.0kHz sampling rate for AAC - update the unit test
Pavlin Radoslavov [Tue, 20 Jun 2017 04:12:37 +0000 (21:12 -0700)]
Disable 48.0kHz sampling rate for AAC - update the unit test

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: I5a8b72e86fb1a2cbf92f85e7a6c340cee58dadb5

7 years agoGet rid of BD_ADDR
Jakub Pawlowski [Fri, 16 Jun 2017 22:16:15 +0000 (15:16 -0700)]
Get rid of BD_ADDR

Test: compilation test
Change-Id: I8493485873a81f897fbaef1504076ef18274a8a5

7 years agoGet rid of bdcpy, bdcmp and other BD_ADDR helpers
Jakub Pawlowski [Fri, 16 Jun 2017 20:55:52 +0000 (13:55 -0700)]
Get rid of bdcpy, bdcmp and other BD_ADDR helpers

Test: compilation test
Change-Id: I37f17bfb3826b59797373645691c61bfbaefdbfd

7 years agoReplace BT_ADDR with bd_addr_t in bta_sys related code
Jakub Pawlowski [Fri, 16 Jun 2017 19:52:23 +0000 (12:52 -0700)]
Replace BT_ADDR with bd_addr_t in bta_sys related code

Test: compilation test
Change-Id: Idab6e9c03621c5540b4a3a7fa537dff71a25ce3f

7 years agoReplace BD_ADDR with bt_addr_t in MCE related code
Jakub Pawlowski [Fri, 16 Jun 2017 17:54:34 +0000 (10:54 -0700)]
Replace BD_ADDR with bt_addr_t in MCE related code

Test: compilation test
Change-Id: Icfb69cafa55bcd0f4e0146577deb05bb881672cd

7 years agoBuild fix for AOSP
Jakub Pawlowski [Tue, 20 Jun 2017 02:41:06 +0000 (19:41 -0700)]
Build fix for AOSP

Test: compilation test
Change-Id: I66a4854834f0528fad2cf76b5b1d0a48a9038948

7 years agoReplace BD_ADDR with bt_bdaddr_t in RFCOMM related code
Jakub Pawlowski [Fri, 16 Jun 2017 17:46:47 +0000 (10:46 -0700)]
Replace BD_ADDR with bt_bdaddr_t in RFCOMM related code

Test: compilation test
Change-Id: I591049f0f4ea9fa60b1b9f0271e1a906a2a06f30

7 years agoReplace BD_ADDR with bt_bdaddr_t in SDP and A2DP related code
Jakub Pawlowski [Fri, 16 Jun 2017 17:00:46 +0000 (10:00 -0700)]
Replace BD_ADDR with bt_bdaddr_t in SDP and A2DP related code

Test: compilation test
Change-Id: I59a69d56377d38f349def6b24aa5c7d5a3d4f859

7 years agoReplace BD_ADDR with bt_bdaddr_t in hf client related code
Jakub Pawlowski [Fri, 16 Jun 2017 16:35:52 +0000 (09:35 -0700)]
Replace BD_ADDR with bt_bdaddr_t in hf client related code

Test: compilation test
Change-Id: Iee6b07b6a919e5d061a04cb3d919166661e673e8

7 years agoReplace BD_ADDR with bt_bdaddr_t in JV related code
Jakub Pawlowski [Fri, 16 Jun 2017 15:42:05 +0000 (08:42 -0700)]
Replace BD_ADDR with bt_bdaddr_t in JV related code

Test: compilation test
Change-Id: Ie0cf491506ebb898ba968586048d2b58248ba112

7 years agouse bt_bdaddr_t instead of BD_ADDR in PAN related code
Jakub Pawlowski [Thu, 15 Jun 2017 18:53:33 +0000 (11:53 -0700)]
use bt_bdaddr_t instead of BD_ADDR in PAN related code

Test: compilation test
Change-Id: I1fced7529f3d91bf429c179cf4eba5157b35c8fd

7 years agoReplace BD_ADDR with bt_bdaddr_t in HL related code
Jakub Pawlowski [Thu, 15 Jun 2017 18:10:08 +0000 (11:10 -0700)]
Replace BD_ADDR with bt_bdaddr_t in HL related code

Test: compilation test
Change-Id: Ife04e0839a4a6f61b77a60f49bf44ab5bdacc874

7 years agoUse bt_bdaddr_t instead of BD_ADDR in AVDT related code
Jakub Pawlowski [Wed, 14 Jun 2017 00:53:54 +0000 (17:53 -0700)]
Use bt_bdaddr_t instead of BD_ADDR in AVDT related code

Test: compilation test
Change-Id: Ibdfd79972d2270303cf1d2e0da26b23d8d5d62d5

7 years agoGet rid of no longer necessary bt_bdaddr_t helpers
Jakub Pawlowski [Thu, 15 Jun 2017 14:16:16 +0000 (07:16 -0700)]
Get rid of no longer necessary bt_bdaddr_t helpers

This are now implemented by the "==" and copy operator

Test: compilation test

Change-Id: I4438c54a9238ad9f3083f7f8a8159d1b7f0f9b32

7 years agoAdd a mechanism to avoid using AVDTP RECONFIGURE for blacklisted devices
Pavlin Radoslavov [Mon, 19 Jun 2017 19:44:11 +0000 (12:44 -0700)]
Add a mechanism to avoid using AVDTP RECONFIGURE for blacklisted devices

Some carkits report SUCCESS for AVDTP RECONFIGURE commands when
changing A2DP codec configuration. However, there is no audio coming
from the carkit.

Bug: 37625892
Test: Manual - A2DP Codec reconfiguration while streaming audio
Change-Id: I01f37a2514e490986a20e96ace78c92463403396

7 years agoGet rid of last mentions of BD_ADDR from btif.
Jakub Pawlowski [Thu, 15 Jun 2017 21:48:35 +0000 (14:48 -0700)]
Get rid of last mentions of BD_ADDR from btif.

Test: compilation test
Change-Id: I22f6b01b1a69eca96b05319692a2eb82ecc186a8

7 years agoMerge "Bluetooth 5: Update LE2M implementation through DM (3/3)"
Treehugger Robot [Thu, 15 Jun 2017 17:50:28 +0000 (17:50 +0000)]
Merge "Bluetooth 5: Update LE2M implementation through DM (3/3)"

7 years agoBluetooth 5: Update LE2M implementation through DM (3/3)
Avish Shah [Thu, 13 Apr 2017 11:45:20 +0000 (17:15 +0530)]
Bluetooth 5: Update LE2M implementation through DM (3/3)

This patch moves LE2M implementation to the DM instead of tied to GATT.

Below are the reasons to make this change:
1) Per link setting usually be done under DM, such as link policy etc.
2) In the future, if LECOC is coming to use in more profile/apps,
   we can not rely on GATT API for these. Separate API should be required.
3) we could have multiple logical GATT user on top of the same link.
4) Also this will avoid duplicating all the APIs on GATTC and GATTS.

Bug: 37586939
Test: sl4a PhyTest passed
Change-Id: I7330be85d1bb98a4cc66b69462b01c23c9375362

7 years agoFix btm_ble_get_acl_remote_addr
Jakub Pawlowski [Thu, 15 Jun 2017 15:32:56 +0000 (08:32 -0700)]
Fix btm_ble_get_acl_remote_addr

Second parameter, conn_addr, should be assigned the value. Right now we
only modify the place in memory where the pointer points to.
This bug was introduced in commit
c2276b06572ab6fc1f900fbb1f41087e77d47e2a

Test: compilation test
Change-Id: If52a6b02f4ad0d88a6461a4d76e4f8317dcaac9f

7 years agoFix bad comparison in btm_ble_refresh_local_resolvable_private_addr
Jakub Pawlowski [Thu, 15 Jun 2017 15:22:24 +0000 (08:22 -0700)]
Fix bad comparison in btm_ble_refresh_local_resolvable_private_addr

This issue was introduced while switching from BD_ADDR to bt_bdaddr_t

Test: Pairing with BLE mouse
Change-Id: I6f6e2386cbd8449bd38d65d1d9c1c5a0032f2156

7 years agoFix build breakage from change I8d1bd6914aec55bb53495b1d0d5e3d37b86865e6
Ivan Podogov [Wed, 14 Jun 2017 10:40:36 +0000 (11:40 +0100)]
Fix build breakage from change I8d1bd6914aec55bb53495b1d0d5e3d37b86865e6

Test: manual build
Change-Id: I7d37ee188d2258e3a52c700c7748b53804cb1c0a

7 years agoUse bt_bdaddr_t instead of BD_ADDR in HID related code
Jakub Pawlowski [Fri, 9 Jun 2017 23:00:25 +0000 (16:00 -0700)]
Use bt_bdaddr_t instead of BD_ADDR in HID related code

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

7 years agoFix HID crashing on no descriptor
Jakub Pawlowski [Tue, 13 Jun 2017 21:16:57 +0000 (14:16 -0700)]
Fix HID crashing on no descriptor

Bug: 62461796
Test: compilation test
Change-Id: Ic7b1fcc4b6f3c8680f1810679ed609f2691fa4aa

7 years agoFix for fugu build
Jakub Pawlowski [Tue, 13 Jun 2017 23:41:45 +0000 (16:41 -0700)]
Fix for fugu build

Test: compilation with BLE_PRIVACY_SPT=TRUE
Change-Id: I1765ad009368077bb4c0be9673a27a9df428f41f

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