OSDN Git Service

android-x86/system-bt.git
6 years agoHID: Refactor bta_dm_pm_ssr to be more readable
Jack He [Fri, 6 Oct 2017 00:54:49 +0000 (17:54 -0700)]
HID: Refactor bta_dm_pm_ssr to be more readable

* Reuse values obtained from tables
* Continue early when Bluetooth addresses do not match, so that the
  rest of the method can save some indentation

Test: make, HID host test
Change-Id: I7b2d4ec35a167c93da25a112e73c8d37531714a5

6 years agoBTA GATT cache cleanup bta_gattc_srvc_in_list
Jakub Pawlowski [Thu, 12 Oct 2017 22:00:35 +0000 (15:00 -0700)]
BTA GATT cache cleanup bta_gattc_srvc_in_list

Bug: 67057055
Test: compilation test
Change-Id: I22e752c1d270128ff0ae4f633d4f3eccf4cb725e

6 years agoBTA GATT cache cleanup add_*_to_list
Jakub Pawlowski [Thu, 12 Oct 2017 21:42:11 +0000 (14:42 -0700)]
BTA GATT cache cleanup add_*_to_list

Bug: 67057055
Test: compilation test
Change-Id: If70cfc4c024434ffe77e53410b5de8f70af6b33e

6 years agoBTA GATT cache cleanup bta_gattc_disc_res_cback
Jakub Pawlowski [Thu, 12 Oct 2017 18:18:03 +0000 (11:18 -0700)]
BTA GATT cache cleanup bta_gattc_disc_res_cback

Bug: 67057055
Test: compilation test
Change-Id: Iccfffe5de654070058ce3f4af3f48fa0975b7cf3

6 years agomake Uuid::kBase into local constexpr
Jakub Pawlowski [Thu, 12 Oct 2017 20:29:04 +0000 (13:29 -0700)]
make Uuid::kBase into local constexpr

This fixes a bug where From128BitBE is used before kBase is initialized

Bug: 67671467
Test: Share a picture using Bluetooth
Change-Id: Ifb5b5f90dbca9646f117b9ff5d01439407424597

6 years agoBTA GATT cache cleanup
Jakub Pawlowski [Wed, 11 Oct 2017 21:55:15 +0000 (14:55 -0700)]
BTA GATT cache cleanup

This patch splits bta_gattc_add_attr_to_cache into two functions:
bta_gattc_add_descr_to_cache and bta_gattc_add_incl_srvc_to_cache

Bug: 67057055
Test: compilation test
Change-Id: I92702495e8631197e56c2cb0ab126b59cf7e90e4

6 years agoFix logs in btif_hh
Hansong Zhang [Wed, 11 Oct 2017 23:43:53 +0000 (16:43 -0700)]
Fix logs in btif_hh

Fixed two logs which are incosistent with the actual error

Test: not needed.
Change-Id: I8937797148c8c71ef91f9fba5799192bf52692d8

6 years agoUse LOG() macros in BTA GATT logging
Jakub Pawlowski [Wed, 4 Oct 2017 19:22:10 +0000 (12:22 -0700)]
Use LOG() macros in BTA GATT logging

Test: compilation test
Change-Id: If7676af5bf915df57ab6e876d2f27500ebf5c07d

6 years agoMerge "Linux: silence gnu-variable-sized-type-not-at-end warnings"
Treehugger Robot [Tue, 10 Oct 2017 19:48:35 +0000 (19:48 +0000)]
Merge "Linux: silence gnu-variable-sized-type-not-at-end warnings"

6 years agoMerge "HCI: Restart 5 seconds after an HCI timeout"
Treehugger Robot [Tue, 10 Oct 2017 18:33:10 +0000 (18:33 +0000)]
Merge "HCI: Restart 5 seconds after an HCI timeout"

6 years agoLinux: silence gnu-variable-sized-type-not-at-end warnings
Jakub Pawlowski [Tue, 10 Oct 2017 17:12:30 +0000 (10:12 -0700)]
Linux: silence gnu-variable-sized-type-not-at-end warnings

Test: compile on linux using ninja
Change-Id: If3fed35017e4aa8cfc2740b49eb4ff547b4e7e5f

6 years agoChange DI record default company ID to Google
Andre Eisenbach [Tue, 10 Oct 2017 10:29:49 +0000 (03:29 -0700)]
Change DI record default company ID to Google

Test: manual
Change-Id: I181e9716dc2c9e48272dcc7f1a00841b4ed5c8dc

6 years agoLinux build fix - include what you use
Jakub Pawlowski [Tue, 10 Oct 2017 03:53:39 +0000 (20:53 -0700)]
Linux build fix - include what you use

sys/uio.h should be included for writev

Change-Id: I1f66391d15109366356af09c825afa1216fbbf34

6 years agoFix linking error during stack startup
Jakub Pawlowski [Mon, 9 Oct 2017 22:13:38 +0000 (15:13 -0700)]
Fix linking error during stack startup

Change-Id: I0ac207eada1ddf2181a4c2826ede74310ce119d1

6 years agoManually convert to unary where coccinelle could not
Myles Watson [Fri, 6 Oct 2017 23:51:21 +0000 (16:51 -0700)]
Manually convert to unary where coccinelle could not

Test: build
Change-Id: I7b5ea758b94bf225e8776f64256d644c3e96b198

6 years agoUse unary operator instead of == bool
Myles Watson [Fri, 6 Oct 2017 23:39:05 +0000 (16:39 -0700)]
Use unary operator instead of == bool

Automatically generated with coccinelle:

@@
expression e1;
@@

-e1 == false
+!e1

@@
expression e1;
@@

-false == e1
+!e1

@@
expression e1;
@@

-e1 == true
+e1

@@
expression e1;
@@

-true == e1
+e1

Test: build
Change-Id: Ic7df0dc43b550594855e457466b6bccd8f3443a3

6 years agoMerge "Remove the build team from OWNERS in system/bt"
Treehugger Robot [Fri, 6 Oct 2017 21:40:34 +0000 (21:40 +0000)]
Merge "Remove the build team from OWNERS in system/bt"

6 years agoMerge "Remove -Wno-typedef-redefinition"
Treehugger Robot [Fri, 6 Oct 2017 20:27:29 +0000 (20:27 +0000)]
Merge "Remove -Wno-typedef-redefinition"

6 years agoHCI: Restart 5 seconds after an HCI timeout
Myles Watson [Fri, 6 Oct 2017 18:22:51 +0000 (11:22 -0700)]
HCI: Restart 5 seconds after an HCI timeout

Bug: 67209266
Test: build
Change-Id: I69a4a17382742327268a80dbc5c5be49059ecb3c

6 years agoRemove the build team from OWNERS in system/bt
Myles Watson [Thu, 5 Oct 2017 23:21:51 +0000 (16:21 -0700)]
Remove the build team from OWNERS in system/bt

Test: build
Change-Id: I17f1fa9c0b5cdf4dc871c54f5731371f6828255c

6 years agoRemove -Wno-typedef-redefinition
Myles Watson [Thu, 5 Oct 2017 23:38:11 +0000 (16:38 -0700)]
Remove -Wno-typedef-redefinition

Test: build
Change-Id: I42cc5ad8f77061bdce8906f7e454c8120f4e71b2

6 years agoUse -Werror in system/bt/vendor_libs/linux/interface/
Chih-Hung Hsieh [Mon, 2 Oct 2017 22:48:17 +0000 (15:48 -0700)]
Use -Werror in system/bt/vendor_libs/linux/interface/

Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I2eca0a5fff52c83a86b060fd274c5a4cd1c53664

6 years agoMerge "Decrese the default verbosity for A2DP codec info logs"
Treehugger Robot [Thu, 5 Oct 2017 01:51:14 +0000 (01:51 +0000)]
Merge "Decrese the default verbosity for A2DP codec info logs"

6 years agoMerge "Added extra A2DP logging when there is an error"
Treehugger Robot [Thu, 5 Oct 2017 01:39:45 +0000 (01:39 +0000)]
Merge "Added extra A2DP logging when there is an error"

6 years agoMerge "Fix net_test_bluetooth"
Treehugger Robot [Thu, 5 Oct 2017 01:25:42 +0000 (01:25 +0000)]
Merge "Fix net_test_bluetooth"

6 years agoDecrese the default verbosity for A2DP codec info logs
Pavlin Radoslavov [Wed, 4 Oct 2017 18:26:04 +0000 (11:26 -0700)]
Decrese the default verbosity for A2DP codec info logs

Bug: 64159791
Test: Manual
Change-Id: Ida10f5d2aa6643df136a41891d7775e175c06570
(cherry picked from commit b4ae75f4524fd5bf55d015f860f1deaee0d81f43)

6 years agoAdded extra A2DP logging when there is an error
Pavlin Radoslavov [Wed, 4 Oct 2017 12:36:25 +0000 (05:36 -0700)]
Added extra A2DP logging when there is an error

Bug: 64159791
Test: Manual
Change-Id: Ic1001892b7abc9784a21a183d141df51b1b92fc0
(cherry picked from commit 6c6d2f6a14847ee75c72b1366449c45ab66feb00)

6 years agoFix net_test_bluetooth
Jakub Pawlowski [Wed, 4 Oct 2017 23:01:26 +0000 (16:01 -0700)]
Fix net_test_bluetooth

Test: net_test_bluetooth
Change-Id: I8c84f0db3ce0e4f6efbd6d7d3cdc794be8fb7faa

6 years agobtm: Return the result in btm_pm_compare_modes
Myles Watson [Tue, 3 Oct 2017 23:51:30 +0000 (16:51 -0700)]
btm: Return the result in btm_pm_compare_modes

Test: build
Bug: 67383347
Change-Id: Id4407c1a73592674f0d86b1be1152abc088908b5

6 years agoUse std::list in GATT related code
Jakub Pawlowski [Sat, 9 Sep 2017 19:50:38 +0000 (12:50 -0700)]
Use std::list in GATT related code

Bug: 67057055
Test: sl4a Gatt* tests
Change-Id: I8201ebdad5ba4c3d5d0a2fd3d0fe9dc900b51d60

6 years agoMerge "Run clang format on files touched by CL 488398"
Treehugger Robot [Wed, 4 Oct 2017 17:22:17 +0000 (17:22 +0000)]
Merge "Run clang format on files touched by CL 488398"

6 years agoA2DP: Advance btif profile queue on OPENING->other_state transition
Jack He [Mon, 2 Oct 2017 21:07:33 +0000 (14:07 -0700)]
A2DP: Advance btif profile queue on OPENING->other_state transition

* Entering BTIF_AV_STATE_OPENING is only possible through
  BTIF_AV_CONNECT_REQ_EVT (initiated by us) OR
  BTA_AV_PENDING_EVT (initiated by remote)
  from BTIF_AV_STATE_IDLE
* If we go from BTIF_AV_CONNECT_REQ_EVT, we must have a pending
  connection request in btif_profile_queue that should be advanced when
  we quit BTIF_AV_STATE_OPENING state
* This CL adds a flag to indicate whether an AV connection is initiated
  by us and only advance queue when it is
* Also add queue advancement in BTA_AV_REJECT_EVT and BTA_AV_CLOSE_EVT

Bug: 67317954
Test: make
Change-Id: I16dc8ebf76c6edaacb1f7a4a44e604170ff9a8b0

6 years agoHandle Disconnect request in AV Opening State handler
c_sdamga [Mon, 20 Jul 2015 13:47:04 +0000 (19:17 +0530)]
Handle Disconnect request in AV Opening State handler

Usecase:
1. Uncheck media from settings UI
2. initiate A2dp connection from remote, send AVRCP play from remote

Failure:
A2dp connection stuck in opening state.

Rootcause:
When A2dp is unchecked from settings UI and remote initiated
a2dp connection and AVRCP play, music starts streaming on DUT
since A2dp connection disconnected. As A2dp connection was not
completed, btif state stuck in opening state.

Fix:
Handled the disconnection request in the opening state
so that AV state machine moves to proper state before
processing AVRCP Play.

Test: 1. Uncheck media from settings UI
2. initiate A2dp connection from remote, send AVRCP play

Bug: 35415160
Change-Id: If1cda5b78100419fdc60c97349efafdd4a18d40c

6 years agoRun clang format on files touched by CL 488398
Myles Watson [Tue, 19 Sep 2017 17:01:28 +0000 (10:01 -0700)]
Run clang format on files touched by CL 488398

https://android-review.googlesource.com/#/c/488398/

Test: build
Change-Id: Iefbd5b632087be00a12b1a0c851f9e3f3b514532

6 years agoFix adv instance validity check during suspend and resume of resolving list
Subramanian Srinivasan [Fri, 29 Sep 2017 01:41:03 +0000 (18:41 -0700)]
Fix adv instance validity check during suspend and resume of resolving list

When BT is shutdown, multi advertisement instance pointer is made
null by BleAdvertisingManager::CleanUp function.
Any subsequent BleAdvertisingManager::Get function call made at
this point(eg during suspension and resumption of resolving list
activity)leads to a crash as the instance pointer is null.
Hence, use BleAdvertisingManager::IsInitialized function instead
of BleAdvertisingManager::Get function to check the validity of
multi advertisement instance.

Bug: 67325491
Change-Id: Ibbae7fa546bb52494be78eaff6d4b7b15614ab15

6 years agoAdd comments to function arrays to indicate usage
Stanley Tng [Fri, 29 Sep 2017 16:01:25 +0000 (09:01 -0700)]
Add comments to function arrays to indicate usage

No logic change. More comments are added to function arrays to indicate
how each array entry are used.

Test: Manual
Change-Id: I59283cb9786da6f3a4b8a4b36e36e79a25ca6cb8

6 years agoMerge "Rename target.linux[_x86[_64]] to target.linux_glibc[_x86[_64]]"
Dan Willemsen [Tue, 3 Oct 2017 02:30:06 +0000 (02:30 +0000)]
Merge "Rename target.linux[_x86[_64]] to target.linux_glibc[_x86[_64]]"

6 years agoMerge "HID: Free process_repage_timer to prevent leak"
Treehugger Robot [Mon, 2 Oct 2017 23:02:56 +0000 (23:02 +0000)]
Merge "HID: Free process_repage_timer to prevent leak"

6 years agoHID: Free process_repage_timer to prevent leak
Hemant Gupta [Wed, 13 Sep 2017 12:05:03 +0000 (17:35 +0530)]
HID: Free process_repage_timer to prevent leak

Usecase:
1) Perform BT on/off stress test
2) Check for memory leakage in code in subsequent BT on/off usecase

Expectation
No memory leak during BT on/off stress test

Observed result
Memory leakage in hid code where alarm process_repage_timer is not freed
and only cancelled

Fix:
Free alarm process_repage_timer during HID Host deregstration

Test: Checked with BT on/off usecase, and alarm process_repage_timer is now
freed in every BT on/off usecase.

Bug: 65657207
Change-Id: Iccecd126716a5660f4c37ddc917bacee84342297

6 years agoRename target.linux[_x86[_64]] to target.linux_glibc[_x86[_64]]
Dan Willemsen [Mon, 2 Oct 2017 17:41:11 +0000 (10:41 -0700)]
Rename target.linux[_x86[_64]] to target.linux_glibc[_x86[_64]]

In the future, target.linux will apply to all targets running a linux kernel
(android, linux_glibc, linux_bionic). So move all current users to the specific
linux_glibc.

There will be another cleanup pass later that will move some instances back to
target.linux if the properties should be shared with target.android and
target.linux_bionic, but target.linux needs to be removed first.

Test: out/soong/build.ninja identical before/after
Change-Id: Iadc1ba324e03fd2b1b52bf471ffa2a71e0ec3e61
Exempt-From-Owner-Approval: build system cleanup

6 years agoAdd more logs for Bluetooth connection errors
Stanley Tng [Thu, 28 Sep 2017 19:55:41 +0000 (12:55 -0700)]
Add more logs for Bluetooth connection errors

Test: manual
Change-Id: I63402ee8ffa8f57a70a9c9aaa0370d8ca599bbea

6 years agoMerge "Remove unused events handler for BLE scan clients"
Treehugger Robot [Fri, 29 Sep 2017 23:17:41 +0000 (23:17 +0000)]
Merge "Remove unused events handler for BLE scan clients"

6 years agoRemove casts to (tBTA_GATTC*) unions to avoid unaligned accesses
Pavlin Radoslavov [Fri, 29 Sep 2017 01:11:06 +0000 (18:11 -0700)]
Remove casts to (tBTA_GATTC*) unions to avoid unaligned accesses

Bug: 65381426
Test: unit tests
Change-Id: I37e89ec7187ab1c61be4c736385a9fc5ec88d737

6 years agoMerge "Revert "Fix stack-buffer-overflow in bluetooth service GATT client""
Pavlin Radoslavov [Fri, 29 Sep 2017 21:44:59 +0000 (21:44 +0000)]
Merge "Revert "Fix stack-buffer-overflow in bluetooth service GATT client""

6 years agoMerge "UUID fix string parsing"
Treehugger Robot [Fri, 29 Sep 2017 21:07:57 +0000 (21:07 +0000)]
Merge "UUID fix string parsing"

6 years agoRemove unused events handler for BLE scan clients
Jakub Pawlowski [Fri, 29 Sep 2017 20:48:38 +0000 (13:48 -0700)]
Remove unused events handler for BLE scan clients

These events should be handled only for GATT clients, not for BLE
scanner.

Bug: 67058417
Test: compilation
Change-Id: I70744d3c6fd7eb40d839863f7413a7521ca0b2e9

6 years agoRevert "Fix stack-buffer-overflow in bluetooth service GATT client"
Pavlin Radoslavov [Fri, 29 Sep 2017 00:30:13 +0000 (17:30 -0700)]
Revert "Fix stack-buffer-overflow in bluetooth service GATT client"

Instead of a calling site fix, a fix will be added to the called
function instead.

This reverts commit 998f78519d4ca9aad5a7105c8064c6a08342e98c.

6 years agoUUID fix string parsing
Jakub Pawlowski [Fri, 29 Sep 2017 19:11:42 +0000 (12:11 -0700)]
UUID fix string parsing

Instead of making assumption about null termination to make sure proper
number of characters were consumed in sscanf, just ask it to provide the
total number of characters parsed

Test: unittest net_test_types net_test_storage
Change-Id: I2a71c6a15774f73e0ed294d2646884e768ff30d2

6 years agoRemove default libraries
Dan Willemsen [Fri, 29 Sep 2017 00:12:28 +0000 (17:12 -0700)]
Remove default libraries

libdl is part of system_shared_libs now. -ldl -lpthread -lm are now defaults
for host_ldlibs on Linux and Darwin. -lrt is a default for host_ldlibs on
Linux.

Test: m host
Change-Id: Ie87f6ff4290d18e099e1be92093b86f743296563
Exempt-From-Owner-Approval: build system cleanup

6 years agoFix condition of adding device to resloving list
Chao Quan [Thu, 28 Sep 2017 17:15:32 +0000 (10:15 -0700)]
Fix condition of adding device to resloving list

Initial conditions:
1. A phone with a bt controller which doesn't support LE
privacy feature.
2. A HOGP mouse which doesn't exchange identity informatin
(IRK & indentity address)to phone
Reproduce procedure:
1. phone pair with mouse.
2. Disconnect profile link to mouse.
3. re-initiate connect to mouse.
Result: Can't connect to mouse

After bond done, stack will try to add the bonded device
to resolving list. But in the condition that controller
doesn't support LE privacy, stack adds a record with a dummy
static address. When re-initiate connection to this device,
stack will use this dummy static address, and connection
fail.

Fix the related condition

Test: manual
Change-Id: I82621c57c54667294912d4270be10299e8029b4a

6 years agoRefactor btm_ble_resolving_list_load_dev
Chao Quan [Fri, 11 Aug 2017 03:30:59 +0000 (11:30 +0800)]
Refactor btm_ble_resolving_list_load_dev

Test: compilation
Change-Id: I69fd4d9df63801bcc8b529d95bee74fd06c86249

6 years agoMerge "HIDD: Auto-plug and accept incoming connections"
Treehugger Robot [Thu, 28 Sep 2017 04:16:02 +0000 (04:16 +0000)]
Merge "HIDD: Auto-plug and accept incoming connections"

6 years agoFix Linux build
Jack He [Thu, 28 Sep 2017 01:25:56 +0000 (18:25 -0700)]
Fix Linux build

* UUID source files
* L2CAP UCD source files

Test: build on linux
Change-Id: Iba6d8d082612c62e5a8d552140c86ed242da0e36

6 years agoMerge "Don't set CT2 bit when talking to pre-5.0 devices"
Treehugger Robot [Thu, 28 Sep 2017 01:01:30 +0000 (01:01 +0000)]
Merge "Don't set CT2 bit when talking to pre-5.0 devices"

6 years agoDon't set CT2 bit when talking to pre-5.0 devices
Jakub Pawlowski [Wed, 27 Sep 2017 22:41:13 +0000 (15:41 -0700)]
Don't set CT2 bit when talking to pre-5.0 devices

Prior to 5.0 spec, CT2 bit in AuthReq was reserved. Setting it cause
bonding failure with devices that handle it incorrectly.

Bug: 66179701
Bug: 66931978
Test: Bond with device that have 4.2 chip
Change-Id: Idbbf2c39c499698844218059a35cb686996c136a

6 years agoFix out-of-bounds reading when copy SDP raw data
Yamei Du [Sat, 27 May 2017 02:41:42 +0000 (10:41 +0800)]
Fix out-of-bounds reading when copy SDP raw data

When no attribute is returned in the SDP response, the cpy_len will be
MAX_DISC_RAW_DATA_BUF, this will cause out-of-bonds reading of source
buffer when copy the response raw data.

Change-Id: I923d8ee7e08f935e13cec38b75a04beca6174452

6 years agoSMP: Use tSMP_INT_DATA instead of void
Myles Watson [Wed, 20 Sep 2017 23:41:19 +0000 (16:41 -0700)]
SMP: Use tSMP_INT_DATA instead of void

Test: pairing sanity
Change-Id: Ie3a2f94ddd718344219760cef7f1477bd4d09e00

6 years agoHIDD: Auto-plug and accept incoming connections
Ivan Podogov [Tue, 26 Sep 2017 10:42:41 +0000 (11:42 +0100)]
HIDD: Auto-plug and accept incoming connections

Linux, Windows, and OSX try to connect with HID devices during
pairing. We should auto-plug and accept incoming connections if
there is currently no device connected.

In case of Windows, if it fails to connect the first time right
after pairing, all future connections are guaranteed to fail:
hangs in the "response pending" state at L2CAP connection, right
after SECURITY_COMPLETE, looks like a bug in Windows stack.

Since we always have a plugged, "in_use" device in registered
state, we won't be able to accept a new incoming connection,
unless we don't have any other paired device at all. This check
should be removed to allow smoother pairing experience and fix
Windows compatibility.

Bug: 66940516
Test: manual, with a test app
Change-Id: Ie6ca639cb120b52f59880fadb4d3654a095664d6

6 years agoL2CAP: Remove UCD related flags
Jack He [Thu, 21 Sep 2017 00:06:42 +0000 (17:06 -0700)]
L2CAP: Remove UCD related flags

* L2CAP UCD (Unicast Connectionless Data) is no longer enabled on the
  stack
* L2CAP_UCD_INCLUDED is always FALSE, the TRUE case should be removed
* As result, L2CAP_UCD_MTU, L2CAP_UCD_IDLE_TIMEOUT, and
  L2CAP_UCD_CH_PRIORITY need to be removed as well

Bug: 66244184
Test: build
Change-Id: Ieee8b3a547653efa3a34a0810c415ba4c32f1be7

6 years agoMerge "Modify Bluetooth Class of Device from Android stack"
Treehugger Robot [Wed, 27 Sep 2017 19:43:18 +0000 (19:43 +0000)]
Merge "Modify Bluetooth Class of Device from Android stack"

6 years agoMerge "Fix GATT Characteristic discovery (server side)"
Treehugger Robot [Wed, 27 Sep 2017 18:55:30 +0000 (18:55 +0000)]
Merge "Fix GATT Characteristic discovery (server side)"

6 years agoFix GATT Characteristic discovery (server side)
Jakub Pawlowski [Wed, 27 Sep 2017 16:58:46 +0000 (09:58 -0700)]
Fix GATT Characteristic discovery (server side)

The pointer was not properly incremented, which resulted in trashes
being sent during GATT discovery.

This issue was introduced in commit
819e2ecb84a22d6e03ec9ed67b3260c0dd7e8aba (Use one type for UUID)

Bug: 66912853
Test: sl4a GATT read test
Change-Id: Ib57ad050ff17852f9b2fec9c51cad246235e3e80

6 years agoModify Bluetooth Class of Device from Android stack
Pulkit Bhuwalka [Thu, 14 Sep 2017 02:25:31 +0000 (19:25 -0700)]
Modify Bluetooth Class of Device from Android stack

Adds ability to modify Bluetooth Class of Device from Android stack by
hooking into existing functions to modify adapter properties. This
ensures the hardware HAL bluetooth.h interface does not have to change.

Bug: 36015415
Test: Modified Class of Device using sample app and verified device icon
change when discovering from a remote device.

Change-Id: Ib5f05741480a27431afea882d071ded4a6b1bdb8

6 years agoRemove casts to unions to avoid unaligned accesses
Myles Watson [Tue, 19 Sep 2017 17:01:28 +0000 (10:01 -0700)]
Remove casts to unions to avoid unaligned accesses

Bug: 65392204
Test: sanity
Change-Id: I2886cc02289b68710e83147ba4d7715a32a4fc55

6 years agoRemove unnecesary BTA redefinitions for GATT part 4
Jakub Pawlowski [Tue, 26 Sep 2017 15:45:20 +0000 (08:45 -0700)]
Remove unnecesary BTA redefinitions for GATT part 4

Test: compilation test
Change-Id: Ibe37a1c6506d567b68497e8c7074d90cd73ddf00

6 years agoRemove unnecesary BTA redefinitions for GATT part 3
Jakub Pawlowski [Tue, 26 Sep 2017 01:47:54 +0000 (18:47 -0700)]
Remove unnecesary BTA redefinitions for GATT part 3

Test: compilation test
Change-Id: I8d4b8cfd35fcb5ccd7067f1e02dedd1a58efa3ad

6 years agoRemove unnecesary BTA redefinitions for GATT part 2
Jakub Pawlowski [Tue, 26 Sep 2017 00:41:21 +0000 (17:41 -0700)]
Remove unnecesary BTA redefinitions for GATT part 2

Test: compilation test
Change-Id: Iaf81188596c33b92f79f163dc95187ed5c6f52a4

6 years agoRemove unnecesary BTA redefinitions for GATT part 1
Jakub Pawlowski [Tue, 26 Sep 2017 00:24:46 +0000 (17:24 -0700)]
Remove unnecesary BTA redefinitions for GATT part 1

Test: compilation test
Change-Id: I98ab63a187684ae4ffbb0cb23e5c9e67994be468

6 years agoBuild fix after UUID refactor for stage branch
Jakub Pawlowski [Tue, 26 Sep 2017 05:19:01 +0000 (22:19 -0700)]
Build fix after UUID refactor for stage branch

Change-Id: Ia01fa17ba40d315a912c391211e101a951eab562

6 years agoUse one type for UUID (1/5)
Jakub Pawlowski [Mon, 10 Jul 2017 16:56:09 +0000 (09:56 -0700)]
Use one type for UUID (1/5)

Currently, we have few different representations for UUID in stack:
tBT_UUID, tSDP_UUID, bt_uuid_t, bluetooth:UUID, or uint8_t*.

Additionally, tBT_UUID and bt_uuid_t are used to hold UUID as 128bit
as Little Endian or Big Endian, depending on which part of stack (GATT
or SDP) is using it.

This patch is creating one type, bluetooth::Uuid, that will replace all
other types.

Bug: 66912853
Test: all sl4a tests for GATT and RFCOMM
Merged-In: Ia42d3233146db0488728ed6f878f99b368fe8838
Change-Id: Ia42d3233146db0488728ed6f878f99b368fe8838

6 years agoMerge "Get rid of unused _DYNAMIC_MEMORY"
Hansong Zhang [Fri, 22 Sep 2017 19:39:05 +0000 (19:39 +0000)]
Merge "Get rid of unused _DYNAMIC_MEMORY"

6 years agoMerge "btlinux: Fix sepolicy for split policy (Treble) builds"
Treehugger Robot [Fri, 22 Sep 2017 18:32:43 +0000 (18:32 +0000)]
Merge "btlinux: Fix sepolicy for split policy (Treble) builds"

6 years agoGet rid of unused _DYNAMIC_MEMORY
Hansong Zhang [Wed, 20 Sep 2017 16:31:32 +0000 (09:31 -0700)]
Get rid of unused _DYNAMIC_MEMORY

Removed the unused BTA_DYNAMIC_MEMORY and HID_DYNAMIC_LIBRARY

Bug: 27731905
Test: Manual
Change-Id: I6019584b165471c4058a2ec7ef8f278531153d18

6 years agoChange our AVRCP capabilities if the remote device only supports 1.3
Ajay Panicker [Wed, 6 Sep 2017 16:59:51 +0000 (09:59 -0700)]
Change our AVRCP capabilities if the remote device only supports 1.3

This prevents issues with devices that only support 1.3 but can not
handle forward compatability like some Alpine Carkits.

Bug: 37943083
Test: Connect to Alpine carkit that only supports 1.3 and see new features
      are used.

Change-Id: I6d041590dc51d7e8711b17fb1cb9c880b640052a
(cherry picked from commit f9f1c8b449efb9cb7894a64fe2977f875679ba52)

6 years agoBluetooth: Add AVRCP 1.3 as a developer option for AVRCP version (2/2)
Ajay Panicker [Fri, 1 Sep 2017 19:07:42 +0000 (12:07 -0700)]
Bluetooth: Add AVRCP 1.3 as a developer option for AVRCP version (2/2)

This is requied for the 2012 Mazda 3 carkit as the carkit refuses to send
AVRCP commands other than passthrough commands when the version is anything
else. AVRCP 1.3 is compatible with most carkits on the market and can be
used to get most carkits working at the cost of losing many features.

Bug: 37943083
Test: Set AVRCP 1.3 in developer options and see that SDP and the AVRCP
      capabilites have updated to reflect this.
      TestTracker: 105915/3975

Change-Id: Iffc7ed1dd91eecb699153125b25451de5826f202
(cherry picked from commit 2369a95e6ed0c16f61237fe9c1fc5a90d97129c1)

6 years agoDon't reject notifications and wait until new addressed player is ready (2/2)
Ajay Panicker [Wed, 30 Aug 2017 01:30:43 +0000 (18:30 -0700)]
Don't reject notifications and wait until new addressed player is ready (2/2)

There are some carkits like the ones found in the 2016 Honda CRZ and some
Audi's that do not follow the spec and do not honor reject pending notification
messages after switching players. This causes an issue whenever you switch
players, the metadata freezes due to the fact that the carkit never re-registers
for new track changed notifications. This patch removes the reject notification
and reorders the current notifications.

Bug: 64142363
Test: Test with Audi S7 and 2016 Honda CRZ and see that switching players works
      TestTracker: 105391/3975
Change-Id: Iaec70863594e13217916ab740d529f526d27c2d1
(cherry picked from commit dd535e70c767fe214c1634b46618d0fb5ed4385d)

6 years agoGet rid of libhardware dependency in native daemon
Jakub Pawlowski [Wed, 20 Sep 2017 20:52:11 +0000 (13:52 -0700)]
Get rid of libhardware dependency in native daemon

Test: compilation test
Bug: 66187274
Change-Id: I97ee33a55315f44dc03083d1a8da9a38d5619725

6 years agoLoosen libhardware dependency
Jakub Pawlowski [Wed, 20 Sep 2017 20:16:11 +0000 (13:16 -0700)]
Loosen libhardware dependency

In most places we don't really need the libhardware library, just the
headers.

Bug: 66187274
Test: compilation test
Change-Id: Ifa2f547165fcf8b34bc29ab80d2bd12ce02f4ae1

6 years agoEnable extra A2DP control log messages
Pavlin Radoslavov [Wed, 20 Sep 2017 03:29:33 +0000 (20:29 -0700)]
Enable extra A2DP control log messages

Also, fixed a log message when failed to accept the
corresponding socket socket.

Test: manual
Bug: 63949429
Change-Id: I6d9af32f61974a739d179c37da36c360aefcca79

6 years agoBLE Adv RPA is not updated on first timeout
Sunny Kapdi [Tue, 19 Sep 2017 01:14:13 +0000 (18:14 -0700)]
BLE Adv RPA is not updated on first timeout

BLE Advertisement RPA is getting updated with the
same RPA instead of the newly generated RPA on the
first timeout. Make sure to send the newly generated
RPA to the Controller.

CRs-Fixed: 2111232
Bug: 65857055
Change-Id: I4d8e95c26fe8e5944fdee32089b8fcaffa238367

6 years agobtlinux: Fix sepolicy for split policy (Treble) builds
Rob Herring [Mon, 18 Sep 2017 14:25:58 +0000 (09:25 -0500)]
btlinux: Fix sepolicy for split policy (Treble) builds

In full Treble builds, the btlinux HAL fails to build the sepolicy:

neverallow check failed at out/target/product/linaro_x86_64/obj/ETC/plat_sepolicy.cil_intermediates/plat_sepolicy.cil:4518
from system/sepolicy/public/domain.te:673
  (neverallow base_typeattr_55 base_typeattr_56 (file (execute execute_no_trans entrypoint)))
    <root>
    allow at out/target/product/linaro_x86_64/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:6054
      (allow hal_bluetooth_btlinux hal_bluetooth_btlinux_exec (file (read getattr map execute entrypoint open)))

Test: Build completes successfully
Change-Id: Ibb8dbe7f2ca823c87ae4404c40cdc35656c8e0af
Signed-off-by: Rob Herring <robh@kernel.org>
6 years agoMerge "Clean-up BTIF profile queue on profile shutdown"
Treehugger Robot [Sat, 16 Sep 2017 06:24:09 +0000 (06:24 +0000)]
Merge "Clean-up BTIF profile queue on profile shutdown"

6 years agoClean-up BTIF profile queue on profile shutdown
Jack He [Fri, 15 Sep 2017 00:13:19 +0000 (17:13 -0700)]
Clean-up BTIF profile queue on profile shutdown

* Add btif_profile_cleanup(uuid) method to remove pending connection
  requests for individual UUIDs
* Call the above method in each profile's clean-up method
* Add unit tests for btif_profile_queue

Bug: 63790458
Test: make, unit tests, pair and connect car kits
Change-Id: I28288c295b7ca0259b2112c11b4e5a81d6f2e33c

6 years agoSetPreferredPhy/ReadPhy callback fix
Jakub Pawlowski [Fri, 15 Sep 2017 20:43:40 +0000 (13:43 -0700)]
SetPreferredPhy/ReadPhy callback fix

Bug: 65746728
Test: manual
Change-Id: Ifdd8e7051c953aa1c006abecd62d1af196619d98

6 years agoMerge "GAP: Set service_id before calling gap_release_ccb"
Treehugger Robot [Thu, 14 Sep 2017 23:45:01 +0000 (23:45 +0000)]
Merge "GAP: Set service_id before calling gap_release_ccb"

6 years agoGAP: Set service_id before calling gap_release_ccb
Myles Watson [Thu, 14 Sep 2017 21:13:44 +0000 (14:13 -0700)]
GAP: Set service_id before calling gap_release_ccb

Calling gap_release_ccb with a service_id == 0, which in turn
calls BTM_SecClrService with an ID of 0.

From the documentation for BTM_SecClrService:

  Service ID - Id of the service to remove. '0' removes all
               service records (except SDP).

Test: BLE connection and characteristic read
Change-Id: Icf309807f02e1faa273cf9bad9c09d9221a8bbfd

6 years agoFix included service parsing (1/3)
Jakub Pawlowski [Thu, 14 Sep 2017 18:40:32 +0000 (11:40 -0700)]
Fix included service parsing (1/3)

Bug: 65637368
Test: sl4a GattIncludedServiceTest
Change-Id: Icb882d411a75a91e3fea050f00c40e76de3539de

6 years agoAdd Suspend/Resume for advertising
Jakub Pawlowski [Mon, 28 Aug 2017 16:56:13 +0000 (09:56 -0700)]
Add Suspend/Resume for advertising

This is needed for resolving list handling.

Bug: 64846264
Test: updated unit tests
Change-Id: I3d9c7b90d3b69d459d33c4ca7a9849ca3a7abc40

6 years agoMerge "btm: Clear LINK_KEY_KNOWN flag for temporary connections"
Treehugger Robot [Tue, 12 Sep 2017 21:50:08 +0000 (21:50 +0000)]
Merge "btm: Clear LINK_KEY_KNOWN flag for temporary connections"

6 years agobtm: Clear LINK_KEY_KNOWN flag for temporary connections
Myles Watson [Tue, 12 Sep 2017 15:23:23 +0000 (08:23 -0700)]
btm: Clear LINK_KEY_KNOWN flag for temporary connections

Bug: 62561154
Test: Smart Setup, erase target, Smart Setup
Change-Id: Icba672a38772dc99a74f351301c81d66f37ee929

6 years agoFix ASAN crash inside btif_av_event_deep_copy()
Pavlin Radoslavov [Tue, 12 Sep 2017 19:08:49 +0000 (12:08 -0700)]
Fix ASAN crash inside btif_av_event_deep_copy()

Allocate sufficient data on the stack that can be safely copied inside
btif_av_event_deep_copy()

Bug: 65524264
Test: Run Bluetooth on ASAN enabled build
Change-Id: Ie6d4a28933302131c58eb4aee34161e435634377

6 years agoReturn the correct status when BTA_AV Open failed because of role switch
Pavlin Radoslavov [Tue, 12 Sep 2017 18:51:21 +0000 (11:51 -0700)]
Return the correct status when BTA_AV Open failed because of role switch

Bug: 65588660
Test: Code compilation
Change-Id: I705ec28c76f2342e18bece193005c962b9febac8

6 years agoFix MAC address byte ordering in the uniq field
Kim Low [Thu, 6 Apr 2017 01:01:34 +0000 (18:01 -0700)]
Fix MAC address byte ordering in the uniq field

The UNIQ field can be used in the driver to detect duplicate devices.
For example, if a controller is connected via both Bluetooth and USB,
the driver can use the UNIQ field, which typically contains the unique
MAC address to identify that it's the same device.

Test: Connect a Bluetooth device and check its MAC address using
      ioctl(EVIOCGUNIQ) call.
Change-Id: I458608e845fcb24c0d615f6aef8d92ccb08d08ec

6 years agostack: Fix btm_send_link_key_notif comment
Myles Watson [Tue, 12 Sep 2017 14:08:13 +0000 (07:08 -0700)]
stack: Fix btm_send_link_key_notif comment

Test: build
Change-Id: I212ac76af9fab7b11d02120cae5f6eeec14baf69

6 years agoFix alarms being posted on wrong thread
Jakub Pawlowski [Fri, 8 Sep 2017 18:26:25 +0000 (11:26 -0700)]
Fix alarms being posted on wrong thread

Alarms from btu_bta_alarm_queue and btu_generic_alarm_queue should be
processed on the main MessageLoop thread.
Replaced obsoleted alarm_set_on_queue() alarm API with the new
alarm_set_on_mloop() API

Test: manual
Bug: 65078753
Change-Id: I54b472b39b44a6c541dbdcdad7414056d0dd4163

6 years agoFix crash during derigister GATT server
Chao Quan [Mon, 24 Jul 2017 11:46:53 +0000 (19:46 +0800)]
Fix crash during derigister GATT server

When deregister a gatt server, GATT_deregister
will use a loop to stop service one by one and
call std::list::erase in GATTS_StopService to
remove service info. But erase makes iterator lose
efficacy. If the iterator is operated after that,
Bluetooth will crash.

Add the iterator before erase.

Test: manual
Change-Id: I10f9351a95ab4922553d8a77663a0212407607aa

6 years agoEnsure that services are cleaned from the GattServer HandleMap.
Jeremy Klein [Fri, 8 Sep 2017 21:04:39 +0000 (14:04 -0700)]
Ensure that services are cleaned from the GattServer HandleMap.

The incorrect service handle was being plumbed up to onServiceDeleted.
This was causing stale entries to stick around forever in the HandleMap,
which could later cause failures to find callback references in
ContextMap if the connection ID changed for a given device.

Bug: 65463237
Test: unit tests modified and run
Change-Id: I2e22858b447f4e6b5a4fbceee4c406191c84a67d

6 years agoUse strlcpy() instead of strncpy() to copy string property
Pavlin Radoslavov [Thu, 7 Sep 2017 23:22:53 +0000 (16:22 -0700)]
Use strlcpy() instead of strncpy() to copy string property

Also, allocate property with extra space for the null-termination string.

Test: Unit tests passing
Change-Id: I67452cb640cda752c3094c2b1a47eaa13c24e5c6

6 years agoRead the Tx Power level when flushing the A2DP Tx queue
Pavlin Radoslavov [Fri, 1 Sep 2017 23:40:59 +0000 (16:40 -0700)]
Read the Tx Power level when flushing the A2DP Tx queue

Also, minor renaming and cleanup (for consistency).

Test: Streaming A2DP headset and trigger audio stutter
Bug: 64038257
Change-Id: Id722342b596e0bf3c9c7664272b6d3e311bb82e9

6 years agoImplement HCI_Read_Automatic_Flush_Timeout mechanism
Pavlin Radoslavov [Fri, 1 Sep 2017 23:09:27 +0000 (16:09 -0700)]
Implement HCI_Read_Automatic_Flush_Timeout mechanism

Also, read the Automatic Flush Timeout when flushing the A2DP Tx queue

Test: Streaming A2DP headset and trigger audio stutter
Bug: 64038257
Change-Id: Ic49b5236328ddacde1d7f2aee131e35e317a14ef