OSDN Git Service

android-x86/system-bt.git
6 years agoMerge "btm_sec_disconnected Check if p_dev_rec is still in scope"
Treehugger Robot [Fri, 19 Jan 2018 20:25:28 +0000 (20:25 +0000)]
Merge "btm_sec_disconnected Check if p_dev_rec is still in scope"

6 years agoRemove casts for callbacks
Myles Watson [Thu, 18 Jan 2018 20:30:55 +0000 (12:30 -0800)]
Remove casts for callbacks

Casting callbacks can hide parameter mismatches from
the compiler, which makes it impossible to check
argument types.

Bug: 72005262
Test: Toggle Bluetooth, connect to a headset
Change-Id: I0c3e0653c77e829655377fbf170d1b03efa5ea32

6 years agobtm_sec_disconnected Check if p_dev_rec is still in scope
Bailey Forrest [Fri, 12 Jan 2018 23:52:14 +0000 (15:52 -0800)]
btm_sec_disconnected Check if p_dev_rec is still in scope

|btm_sec_disconnected| may call the callback
|btm_cb.api.p_auth_complete_callback| which can delete |p_dev_rec|.
After deletion, |btm_sec_disconnected| still atempts to use |p_dev_rec|.

Bug: 71913396
Test: Does not crash with a quickly terminated connection.
Change-Id: Ic28beb2888a51090283be04121d785495cf25a84

6 years agoMake GAP_ConnWriteData accept BT_HDR
Jakub Pawlowski [Thu, 18 Jan 2018 02:22:12 +0000 (18:22 -0800)]
Make GAP_ConnWriteData accept BT_HDR

This is next step towards making LE sockets work with zero copies.

Test: transfer file using OPP
Bug: 68359837
Change-Id: Iedcdd59acb223e2982f6cb96b8656f517008dee5

6 years agoRevert "HID: Update condition for checking LE HID handle validity"
Hemant Gupta [Fri, 12 Jan 2018 06:25:47 +0000 (11:55 +0530)]
Revert "HID: Update condition for checking LE HID handle validity"

This reverts commit af94891aa6e66b0d4b495d60aeac2aa8091c9d33 as changes to
fix same issue already merged via commit 2e3c3d782993c475e608291896db73b0960fa9dd
so this patch is not longer required.

Test: Code analysis for aosp master

Fixes: 71842479
Change-Id: Ifbc2375ad6df7231c85ef30c5e2c5b5d8dde16f0

6 years agoAdded support for new Android API for LE CoC
Stanley Tng [Wed, 20 Dec 2017 17:38:30 +0000 (09:38 -0800)]
Added support for new Android API for LE CoC

Added support for the new Android API including the management of the
LE_PSM values.
Also fixed a bug when de-registering the L2CAP CoC, the RCB is not
freed correctly.

Test: Ran the new ACTS Tests for LE CoC and existing ACTS for RfComm
Bug: 70683224
Change-Id: I5a545656bece667e7ba942d7b2334e3f5b49b283

6 years agoLimit data accepted by GAP_ConnWriteData to just one SDU
Jakub Pawlowski [Fri, 12 Jan 2018 11:19:33 +0000 (03:19 -0800)]
Limit data accepted by GAP_ConnWriteData to just one SDU

This limit is already enforced in BluetoothSocket.java, which is
dividing data into pieces no bigger than MTU.

This is first step towards making it accept BT_HDR with data, in order
to make LE sockets work with zero copies.

Test: transfer file using OPP
Bug: 68359837
Change-Id: I67bfd4ab5c2dc6aa8210058a742c57e1ccf845a0

6 years agoMerge "Make BTA_JvL2capWrite take ownership of the data buffer"
Treehugger Robot [Thu, 18 Jan 2018 01:49:54 +0000 (01:49 +0000)]
Merge "Make BTA_JvL2capWrite take ownership of the data buffer"

6 years agoMerge "Added internal API getMaxConnectedAudioDevices()"
Treehugger Robot [Thu, 18 Jan 2018 00:46:57 +0000 (00:46 +0000)]
Merge "Added internal API getMaxConnectedAudioDevices()"

6 years agoMake BTA_JvL2capWrite take ownership of the data buffer
Jakub Pawlowski [Thu, 11 Jan 2018 15:34:39 +0000 (07:34 -0800)]
Make BTA_JvL2capWrite take ownership of the data buffer

This is first step towards making it accept BT_HDR with data, in order
to make LE sockets work with zero copies.

Bug: 68359837
Test: transfer file using OPP
Change-Id: Ib202520554bbc83cb8587bf1c4caa4b0da6b266c

6 years agoFix buffer overflow in GAP_ConnWriteData
Jakub Pawlowski [Mon, 8 Jan 2018 21:06:45 +0000 (13:06 -0800)]
Fix buffer overflow in GAP_ConnWriteData

Bug: none
Test: exchange data with MPS>11000, sent file between devices using OPP
Change-Id: Ie456a35da4764bdac329135742634ce8f0a63469

6 years agoAdded internal API getMaxConnectedAudioDevices()
Pavlin Radoslavov [Wed, 17 Jan 2018 10:19:42 +0000 (02:19 -0800)]
Added internal API getMaxConnectedAudioDevices()

The API can be used to obtain the maximum number of connected
devices for A2DP or HFP.

Test: Manual
Bug: 64767509

Change-Id: Ide01ea91bc9708b20c78266d791d4775be3f943d

6 years agoMerge "Revert "Fix buffer overflow in GAP_ConnWriteData""
Treehugger Robot [Wed, 17 Jan 2018 01:33:46 +0000 (01:33 +0000)]
Merge "Revert "Fix buffer overflow in GAP_ConnWriteData""

6 years agoRevert "Fix buffer overflow in GAP_ConnWriteData"
Hansong Zhang [Tue, 16 Jan 2018 23:57:27 +0000 (23:57 +0000)]
Revert "Fix buffer overflow in GAP_ConnWriteData"

This reverts commit 9f9c47683e28a0cf99b308deeac04073a9528c59.

Reason for revert: Bluetooth OPP crashing.

Bug: 72049058
Change-Id: Ic9ee9f28ce480453a9e01d3273595bff2264cd2b

6 years agoMerge "Refactor l2c_lcc_get_next_xmit_sdu_seg"
Treehugger Robot [Thu, 11 Jan 2018 23:28:37 +0000 (23:28 +0000)]
Merge "Refactor l2c_lcc_get_next_xmit_sdu_seg"

6 years agoMerge "L2CAP: Add parameter to indicate last piece of an SDU"
Treehugger Robot [Thu, 11 Jan 2018 23:21:44 +0000 (23:21 +0000)]
Merge "L2CAP: Add parameter to indicate last piece of an SDU"

6 years agoRefactor l2c_lcc_get_next_xmit_sdu_seg
Jakub Pawlowski [Wed, 10 Jan 2018 11:11:33 +0000 (03:11 -0800)]
Refactor l2c_lcc_get_next_xmit_sdu_seg

* use "PDU" instead of "segment" in variable names
* simplify computation of first_pdu, last_pdu, no_of_bytes_to_send
* remove unnecessary null checks

Test: manual
Bug: 68359837
Change-Id: Iecf511df2a51c2c103ecb3b524c6ed17910a7062

6 years agoL2CAP: Add parameter to indicate last piece of an SDU
Jakub Pawlowski [Wed, 10 Jan 2018 10:54:47 +0000 (02:54 -0800)]
L2CAP: Add parameter to indicate last piece of an SDU

This information will be used in future patches to notify packet
completition to upper layers.

Test: manual
Bug: 68359837
Change-Id: Ie4aa937b4da5aa83fa552a8603195a6933d64cc6

6 years agoHID: Update condition for checking LE HID handle validity
Hemant Gupta [Thu, 11 Jan 2018 09:52:49 +0000 (15:22 +0530)]
HID: Update condition for checking LE HID handle validity

1) Pair and connect with BR/EDR HID devices and LE devices
   such that the total number of connected paired devices
   becomes 7. It is not required that connection to all devices be
   maintained, they can be disconnected as well afterwards.
2) Pair and connect with a new LE device. Connection fails
3) Retry connecting to same LE device. Connection does not go through
4) Turn BT off

Observed Result:
1) LE device cannot be connected in step 2
2) Tombstone in BT while switching off BT with below signature

backtrace:
    #00 pc 0000000000092438  /system/lib64/libc.so (ifree+88)
    #01 pc 000000000009298c  /system/lib64/libc.so (je_free+120)
    #02 pc 00000000001b266c  /system/lib64/hw/bluetooth.default.so (_Z18osi_free_and_resetPPv+84)
    #03 pc 0000000000062f84  /system/lib64/hw/bluetooth.default.so
    (_Z17bta_hh_sm_executeP14tBTA_HH_DEV_CBtP12tBTA_HH_DATA+880)
    #04 pc 0000000000063120  /system/lib64/hw/bluetooth.default.so (_Z16bta_hh_hdl_eventP6BT_HDR+296)
    #05 pc 000000000007bbc4  /system/lib64/hw/bluetooth.default.so (_Z13bta_sys_eventP6BT_HDR+60)
    #06 pc 00000000001b4d88  /system/lib64/hw/bluetooth.default.so (_ZL22internal_dequeue_readyPv+80)
    #07 pc 00000000001b96f4  /system/lib64/hw/bluetooth.default.so (_ZL11run_reactorP9reactor_ti+312)
    #08 pc 00000000001b9590  /system/lib64/hw/bluetooth.default.so (_Z13reactor_startP9reactor_t+80)
    #09 pc 00000000001baf24  /system/lib64/hw/bluetooth.default.so (_ZL10run_threadPv+256)
    #10 pc 0000000000067bc4  /system/lib64/libc.so (_ZL15__pthread_startPv+36)
    #11 pc 000000000001f264  /system/lib64/libc.so (__start_thread+68)

Root Cause:
Wrong conditional check in macro BTA_HH_IS_LE_DEV_HDL_VALID which ignores the condition that max
14 HID devices can be connected and all of them can be LE as well.

Fix:
Update the condition in macro BTA_HH_IS_LE_DEV_HDL_VALID to compare with BTA_HH_MAX_DEVICE instead of
BTA_HH_LE_MAX_KNOWN

Test: Not yet performed, only code and log analysis

Fixes: 71842479
Change-Id: I2b56b6f109787608e25c340150be313f0f5397be

6 years agoFix buffer overflow in GAP_ConnWriteData
Jakub Pawlowski [Mon, 8 Jan 2018 21:06:45 +0000 (13:06 -0800)]
Fix buffer overflow in GAP_ConnWriteData

Bug: none
Test: exchange data with MPS>11000
Change-Id: I01c60d6f08529be051e921789c41f7065f45534f

6 years agoRemove duplicated code in l2cap_sock - on_l2cap_write_fixed_done
Jakub Pawlowski [Mon, 8 Jan 2018 09:23:52 +0000 (01:23 -0800)]
Remove duplicated code in l2cap_sock - on_l2cap_write_fixed_done

Test: none
Bug: 68359837
Change-Id: Ic3ebe0b7eebbd0122e7f7751ab3b48d6acf62da6

6 years agoMerge "Move repeated code from l2cu_check_channel_congestion into a separate function"
Treehugger Robot [Wed, 10 Jan 2018 13:04:58 +0000 (13:04 +0000)]
Merge "Move repeated code from l2cu_check_channel_congestion into a separate function"

6 years agoMerge "Make AdvertiseManager shutdown gracefully"
Treehugger Robot [Wed, 10 Jan 2018 10:48:27 +0000 (10:48 +0000)]
Merge "Make AdvertiseManager shutdown gracefully"

6 years agoMerge "HFP: Print human readable event and state name by default"
Treehugger Robot [Wed, 10 Jan 2018 03:47:04 +0000 (03:47 +0000)]
Merge "HFP: Print human readable event and state name by default"

6 years agoMerge "HFP: Remove used BTA call-in events and methods"
Treehugger Robot [Wed, 10 Jan 2018 03:46:48 +0000 (03:46 +0000)]
Merge "HFP: Remove used BTA call-in events and methods"

6 years agoMerge "Fix SIGSEGV during Hands-free client SDP"
Treehugger Robot [Wed, 10 Jan 2018 02:40:49 +0000 (02:40 +0000)]
Merge "Fix SIGSEGV during Hands-free client SDP"

6 years agoHFP: Print human readable event and state name by default
Jack He [Sun, 7 Jan 2018 01:00:37 +0000 (17:00 -0800)]
HFP: Print human readable event and state name by default

* Debug log in HFP's BTA code is gated by BTA_AG_SCO_DEBUG and
  BTA_AG_DEBUG flags. These are non-standard flags that must be
  configured at compile time. Instead, debug logs should be gated by
  flags in bt_stack.conf only
* This change enables human readable debug output by default by removing
  these flags, and refactor the string conversion functions

Bug: 70538124
Test: runtest bluetooth, native unit tests
Change-Id: I99fd00016020a9c6b14928906f07bca4f0ea482d

6 years agoHFP: Remove used BTA call-in events and methods
Jack He [Wed, 10 Jan 2018 00:25:46 +0000 (16:25 -0800)]
HFP: Remove used BTA call-in events and methods

* Since SCO over HCI is temporarily unsupported on the stack, SCO data
  call-in methods are no longer used by the stack and thus should be
  removed. For example, bta_ag_ci_sco_data() and BTA_AG_CI_SCO_DATA_EVT.
* Since raw RFCOMM access is disabled, various RFCOMM data call-in
  methods are no longer used by the stack and thus should be removed.
  For example, bta_ag_ci_rx_data() and BTA_AG_CI_RX_WRITE_EVT

Bug: 70538124
Test: runtest bluetooth, native unit test
Change-Id: Iacd60042e97b1be5f800319723836285eb68b2b9

6 years agoHFP: Remove AG RFCOMM data pass through mode
Jack He [Sat, 6 Jan 2018 23:53:29 +0000 (15:53 -0800)]
HFP: Remove AG RFCOMM data pass through mode

* In BTA_AG_PASS_THROUGH mode defined in bta_ag_api.h, RFCOMM data is
  passed directly to the upper layer. In this case, AT commands are
  parsed in the user application instead of being parsed within the fluoride
  stack.
* However, this mode is never used on the stack as btif_hf.cc only call
  BTA_AgEnable() with BTA_AG_PARSE parameter value. Currently, AT
  commands are only parsed within the fluoride stack
* This change removes this feature since the pass through mode is
  never used, tested, nor maintained

Bug: 70538124
Test: runtest bluetooth, native unit tests, no functional change
Change-Id: I921d5ee950e4abadea8433c5b2d5882a99923cb0

6 years agoHFP: Remove redundant AG data callout code
Jack He [Sat, 6 Jan 2018 23:31:42 +0000 (15:31 -0800)]
HFP: Remove redundant AG data callout code

* Methods in bta_ag_co.cc are almost empty and should be removed
* Only bta_ag_co_init() calls BTM_WriteVoiceSettings(). This can be
  called directly from BTA. The callout wrapper is unnecessary

Bug: 70538124
Test: runtest bluetooth, native unit tests, no functional change
Change-Id: I20ab1c033d18f3405e7efb8446b44153b24f3cb0

6 years agoHFP: Add isInbandRingingEnabled() API (3/4)
Jack He [Sat, 6 Jan 2018 01:18:29 +0000 (17:18 -0800)]
HFP: Add isInbandRingingEnabled() API (3/4)

* Use BluetoothHeadset.isInbandRingingEnabled() API to check whether
  in-band ringing is currently enabled in the system when deciding on
  audio routes for ringtone
* Use this value obtained in Java layer to initialize native HFP/HSP
  stack instead of checking it in native layer

Bug: 71646213
Test: make, toggle in-band ringing from Development Settings and observe
      whether Telecom service tries to open SCO when there is an
      incoming call

Change-Id: I917537b6d17681151639ff29a56ac9c0c7e0e7e8

6 years agoFix SIGSEGV during Hands-free client SDP
Lianchao Song [Fri, 22 Dec 2017 08:55:47 +0000 (16:55 +0800)]
Fix SIGSEGV during Hands-free client SDP

Fixes: 70367002
Change-Id: I2fd7a00551157a000b87c7bbdbc8a2c93cff21c4

6 years agoMove repeated code from l2cu_check_channel_congestion into a separate function
Jakub Pawlowski [Tue, 9 Jan 2018 11:45:09 +0000 (03:45 -0800)]
Move repeated code from l2cu_check_channel_congestion into a separate function

Test: compilation
Bug: 68359837
Change-Id: I69edf0d549633a2d9d0c73eae4efbaf47d302ab4

6 years agoRun by default the 64-bit unit tests on 64-bit devices
Pavlin Radoslavov [Tue, 9 Jan 2018 13:58:53 +0000 (05:58 -0800)]
Run by default the 64-bit unit tests on 64-bit devices

Bug: 71739588
Test: cd system/bt; mm -j 40; test/run_unit_tests.sh
Change-Id: Ie4206a8935456a0b62b7a4b90c7247f398a6a7ef

6 years agoDisable CFI verification for unit tests that are using gtest+gmock
Pavlin Radoslavov [Tue, 9 Jan 2018 13:36:20 +0000 (05:36 -0800)]
Disable CFI verification for unit tests that are using gtest+gmock

Apparently, the CFI verification crashes unit tests that
are using gtest+gmock. Interestingly, those tests succeed for 32-bit
binaries, and fail for 64-bit binaries.

Bug: 71739588
Test: Running the 64-bit version of the unit tests in test/run_unit_tests.sh
Change-Id: Id1f6b3667b3f9eabb0719e65aea18c6950de63a8

6 years agoMake AdvertiseManager shutdown gracefully
Jakub Pawlowski [Thu, 22 Jun 2017 16:46:18 +0000 (09:46 -0700)]
Make AdvertiseManager shutdown gracefully

If the Bluetooth stack is shutdown while AdvertiseManager has a pending HCI
operation being executed, the callback to that operation might be
executed after the manager was deleted. In order to fix any potential
issues, always use a weak pointer to the advertisement manager. This will
prevent the callbacks from getting executed.

In case of callbacks that are not executed on the AdvertiseManager
instance, one can check if the weak pointer is still valid, and properly
handle the stack shutdown.

Test: BleAdvertisingManagerTest:test_cleanup_during_execution
Change-Id: I8d33de4f64267a880880082c5498375c083addef

6 years agoPrevent LE CoC from dropping data when remote MPS>8087
Jakub Pawlowski [Fri, 5 Jan 2018 10:41:36 +0000 (02:41 -0800)]
Prevent LE CoC from dropping data when remote MPS>8087

When using LE Coc through Java socket, one can read MPS from
getMaxTransmitPacketSize(). If this value is bigger than
local device L2CAP_MAX_SDU_LENGTH, data sent to remote will be
truncated. This patch fixes that by using properly big buffer for
receiving data from socket on native side.

Test: connect with device with MPS bigger than MPS, alternatively set
L2CAP_MAX_SDU_LENGTH to i.e. 30 on device during test and try to write
"remote MPS" of bytes to remote device.
Bug: 68359837
Change-Id: I02bef80f0dd0f0d6850704ac7787c5f3f5b9b3ab

6 years agoHFP: Add APIs for set and get active device (3/3)
Jack He [Thu, 7 Dec 2017 02:35:11 +0000 (18:35 -0800)]
HFP: Add APIs for set and get active device (3/3)

* Add set active device APIs to set active device from Java layer
* Set active device to the first connected device if no one set it
  before
* Clear active device on RFCOMM disconnection if active device is the
  one getting disconnected
* Currently, the active device value is not used in any functional code

Bug: 68951996
Test: runtest -j40 bluetooth
Change-Id: Id0c00e89178b0f963ed8642e72c7010160dd1d68

6 years agoAdded internal API to get/set the A2DP Active Device
Pavlin Radoslavov [Tue, 19 Dec 2017 21:26:22 +0000 (13:26 -0800)]
Added internal API to get/set the A2DP Active Device

1. Call BluetoothA2dp.setActiveDevice(BluetoothDevice device) to set
   a connected A2DP device as active.
2. Listen for BluetoothA2dp.ACTION_ACTIVE_DEVICE_CHANGED intent
   that will contain the latest active device (in EXTRA_DEVICE field).
   If the active device could not be changed, the EXTRA_DEVICE
   field could be null.
3. If setActiveDevice() is NOT in-progress, BluetoothA2dp.getActiveDevice()
   can be used. If setActiveDevice() is in-progress, the result is undefined.
4. BluetoothA2dp.setActiveDevice() could be called by some other parts of
   the system, so interested parties should always listen for
   BluetoothA2dp.ACTION_ACTIVE_DEVICE_CHANGED intents and prepared
   for active device updates.

Bug: 71555243
Test: Manual
Change-Id: Ia25465e17a4539e940d09523cb621b230abd31e3

6 years agoHFP: Use disableinbandringing instead of enableinbandringing
Jack He [Thu, 7 Dec 2017 23:15:56 +0000 (15:15 -0800)]
HFP: Use disableinbandringing instead of enableinbandringing

* Use disableinbandringing system property as in-band ringing is enabled
  by default so an active user choice would disable it instead of
  enabling it

Bug: 65383086
Test: make, try toggling the preference and verify in-band ringing
      behavior

Change-Id: I9b10743960c933b223481d2efb68af538689c507
Merged-In: I9b10743960c933b223481d2efb68af538689c507
(cherry picked from commit 71de85091506eeeaab6e73cccf0ebd5bb06f2af1)

6 years agoRevert "Use vector instead of raw pointer in l2cap socket write handling"
Jakub Pawlowski [Fri, 5 Jan 2018 09:36:44 +0000 (09:36 +0000)]
Revert "Use vector instead of raw pointer in l2cap socket write handling"

This reverts commit 4da2ff53e694c5bee2973c55bb14eb40f74a9d3d.

Change-Id: Id8a399ec6f7474b92579c4647899e424feeb0d33

6 years agoUse vector instead of raw pointer in l2cap socket write handling
Jakub Pawlowski [Tue, 31 Oct 2017 06:15:43 +0000 (23:15 -0700)]
Use vector instead of raw pointer in l2cap socket write handling

Currently, when we receive data from upper layers for LE CoC socket,
we store it in memory and pass a raw pointer around, keeping memory
until the write is acknowledged by controller and event is sent back to
btif layer in on_l2cap_write*_done. If anything goes wrong, we might
loose the pointer to the data and have a memory leak.

From now on, we store the data in std::vector and pass its ownership
down the stack. The moment the data is copied into lower layer buffer,
vector is automatically freed. We no longer pass the data back to
on_l2cap_write*_done callback.

Bug: 68359837
Test: compilation test
Change-Id: If34c0fba8d4a040a242b8c655491b8967a03b96a

6 years agoAdd to receive BTHF_CALL_STATE_DISCONNECTED at HFP
Yasuyoshi Terui [Fri, 14 Feb 2014 06:07:35 +0000 (15:07 +0900)]
Add to receive BTHF_CALL_STATE_DISCONNECTED at HFP

When the call is disconnected, the BTHF state is changed to IDLE and
SCO connection is disconnected before playing disconnect tone. So the
disconnect tone can't be sound from BTHS.

Add DISCONNECTED state for HFP and keep the state until disconnect tone
sounds from BT.

Test: manual - Checked whether the disconnect tone is sound from the BTHS
Bug: 69645337

Change-Id: Id96385e4ce35cfe7d0d4e14b74a2fc1a63165f82

6 years agoHFP: Use objects for shared library interface and callbacks (1/2)
Jack He [Thu, 14 Dec 2017 23:00:39 +0000 (15:00 -0800)]
HFP: Use objects for shared library interface and callbacks (1/2)

* Declare bluetooth::headset::Interface and
  bluetooth::headset::Callbacks instead of using structs
* Put HFP related methods and types into bluetooth::headset namespace
* Rename those methods into CamelStyle according to Google C++ style
  guide
* Remove the usage of HAL_CBACK in HFP as we only need to check if the
  callback object is null and all its methods must be implemented as
  mandated by rules of the pure virtual function
* These classes can be mocked during test to isolate behaviors
* Improved effort handling in btif_hf.cc to log error messages during
  failures

Bug: 70538124
Test: unit tests, testplans/135585
Change-Id: Iba120ef9d0a9701aececd300395b7b18d2d44e7d

6 years agoAdded RawAddress::FromOctets method to copy address from uint8_t pointer
Pavlin Radoslavov [Sun, 26 Nov 2017 04:51:36 +0000 (20:51 -0800)]
Added RawAddress::FromOctets method to copy address from uint8_t pointer

Also, added missing unit test for existing constructor

Test: Unit test added
Change-Id: Id642aaf2651c59b87af344c78aafc87aba2898d1

6 years agoAdvertising Filtering: send all filters in one batch (2/2)
Jakub Pawlowski [Tue, 3 Oct 2017 19:31:48 +0000 (12:31 -0700)]
Advertising Filtering: send all filters in one batch (2/2)

Bug: 67371480
Test: sl4a FilteringTest
Change-Id: I93595b5ed4e7cf25cdb6a8b1f9413a7f05e61774

6 years agoMerge "Temporarily remove broken SCO-over-HCI implementation"
Treehugger Robot [Wed, 3 Jan 2018 18:35:35 +0000 (18:35 +0000)]
Merge "Temporarily remove broken SCO-over-HCI implementation"

6 years agoRemove bytes after first zero length field in legacy advertisements
Jakub Pawlowski [Wed, 3 Jan 2018 09:49:41 +0000 (01:49 -0800)]
Remove bytes after first zero length field in legacy advertisements

This is for compatibility with many existing old devices, that have
non-zero bytes after zero length field. This is currently causing
advertisements to be dropped, rendering those devices invisible.

Bug: 68907583
Test: AdvertiseDataParserTest.RemoveTrailingZerosMalformed
Change-Id: Ib51950f7e0c6a2771f56c6f69108fa10f2517f38

6 years agoTemporarily remove broken SCO-over-HCI implementation
Hansong Zhang [Tue, 2 Jan 2018 21:48:42 +0000 (13:48 -0800)]
Temporarily remove broken SCO-over-HCI implementation

This is currently not used on known Android platforms and currently does
not compile. To be re-visited when SCO-over-HCI can be re-implemented
based on the new HAL.

Test: make
Bug: 70965527
Change-Id: Iefff5b3fb1599a0cdb2c7fb90b463f3643a2a47e

6 years agoMinor style fixes in l2c_main.cc
Jakub Pawlowski [Thu, 7 Dec 2017 09:21:48 +0000 (01:21 -0800)]
Minor style fixes in l2c_main.cc

Bug: 69623109
Test: compilation
Change-Id: Ie5d744bced1e392d9cfa57ae6c9b4a4664c021c8

6 years agoMerge "BluetoothHidDevice: rename onIntrData to onInterruptData (2/5)"
Treehugger Robot [Thu, 21 Dec 2017 21:56:11 +0000 (21:56 +0000)]
Merge "BluetoothHidDevice: rename onIntrData to onInterruptData (2/5)"

6 years agoIncrease MPS for LE CoC to one LE Buffer Size
Jakub Pawlowski [Tue, 19 Dec 2017 21:22:27 +0000 (13:22 -0800)]
Increase MPS for LE CoC to one LE Buffer Size

This should improve throughtput, and reduce number of LE-U PDUs needed
to send message over LE channel.

Test: compilation
Change-Id: Ic1e203eaec0b8012984f27d3c488ea6eb0945399

6 years agoMerge "Increase default SDP_MTU_SIZE to 1024"
Treehugger Robot [Thu, 21 Dec 2017 15:11:56 +0000 (15:11 +0000)]
Merge "Increase default SDP_MTU_SIZE to 1024"

6 years agoBluetoothHidDevice: rename onIntrData to onInterruptData (2/5)
Hansong Zhang [Mon, 18 Dec 2017 23:22:22 +0000 (15:22 -0800)]
BluetoothHidDevice: rename onIntrData to onInterruptData (2/5)

Bug: 63384609
Test: make
Merged-In: I76a149f1c7f30ac3eec31d57053231f7f6dac01d
Change-Id: I76a149f1c7f30ac3eec31d57053231f7f6dac01d
(cherry picked from commit 0fa9df6938dfe7dafa10601ea904cd6f1d2e95c2)

6 years agoIncrease default SDP_MTU_SIZE to 1024
Kim Low [Mon, 11 Dec 2017 22:38:01 +0000 (14:38 -0800)]
Increase default SDP_MTU_SIZE to 1024

This fixes a problem where older DualShock4 controllers would
not connect with SDP_MTU_SIZE < 1024.

Fixes: 70356237
Change-Id: I96a6ee0536547b93f2ae411eb1d8860292855c31

6 years agoMinor GATT logging fixes
Jakub Pawlowski [Wed, 13 Dec 2017 18:12:39 +0000 (10:12 -0800)]
Minor GATT logging fixes

Test: compilation
Bug: 70297056
Change-Id: If71bbb19a08abbbb30b5ce5027aed97e03b3baaa

6 years agoHFP: Add interface to disable in-band ringing through BSIR (1/2)
Jack He [Mon, 4 Dec 2017 22:13:01 +0000 (14:13 -0800)]
HFP: Add interface to disable in-band ringing through BSIR (1/2)

* Add send_bsir(bool, RawAddress*) to turn
  in-band ringtone feature ON and OFF dynamically during a service
  level connection with a headset

Bug: 70173881
Test: make
Change-Id: I358e39a9176d75dfb8682e77cf567f87eb417d1a

6 years agobt: Update libchrome APIS to r456626.
Hidehiko Abe [Wed, 13 Dec 2017 09:57:10 +0000 (18:57 +0900)]
bt: Update libchrome APIS to r456626.

The new libchrome has been ported from Chromium and some APIs
have changed. Make necessary changes at call sites.

Test: Build.
Change-Id: I4c904a9e8b76f1ee72e14d62740cb0d88963b270
Merged-In: I0cc2cf8521caf5f6f69346bb3ce3dc1c59b95cc6

6 years agoMerge "Add extra log message to print output codec config"
Treehugger Robot [Sat, 16 Dec 2017 00:09:34 +0000 (00:09 +0000)]
Merge "Add extra log message to print output codec config"

6 years agoMerge "HFP: Use do_in_jni_thread to avoid btif_transfer_context"
Treehugger Robot [Fri, 15 Dec 2017 19:09:36 +0000 (19:09 +0000)]
Merge "HFP: Use do_in_jni_thread to avoid btif_transfer_context"

6 years agoAdd extra log message to print output codec config
Pavlin Radoslavov [Fri, 15 Dec 2017 00:35:28 +0000 (16:35 -0800)]
Add extra log message to print output codec config

Test: Code compilation and log observation
Change-Id: Iee41fe0566b1d635431a9535099a3601c8de11b6

6 years agoHCI: Fix use after free in hci_transmit
Myles Watson [Thu, 14 Dec 2017 20:20:40 +0000 (12:20 -0800)]
HCI: Fix use after free in hci_transmit

Bug: 70626623
Test: Sanity Bluetooth on/off
Change-Id: Ie8c857f8bdf3897fd3776772a4198bab823c6115

6 years agoHFP: Use do_in_jni_thread to avoid btif_transfer_context
Jack He [Tue, 12 Dec 2017 04:21:36 +0000 (20:21 -0800)]
HFP: Use do_in_jni_thread to avoid btif_transfer_context

* Use do_in_jni_thread and base::Bind() to pass callbacks to JNI thread
* Remove unnecessary code after the refactoring

Bug: 70538124
Test: make, conntect to HFP-enabled car kits
Change-Id: Iea8f19732d40bf40b056fea760ee5cf785a5812b

6 years agoMerge "btif_sock_rfc: Use %u for uint32_t"
Treehugger Robot [Thu, 14 Dec 2017 21:27:12 +0000 (21:27 +0000)]
Merge "btif_sock_rfc: Use %u for uint32_t"

6 years agoMerge "Fix Bluetooth crash on user switching"
Treehugger Robot [Thu, 14 Dec 2017 19:36:56 +0000 (19:36 +0000)]
Merge "Fix Bluetooth crash on user switching"

6 years agoFix GATT discovery service fail over BR/EDR
Chao Quan [Mon, 23 Oct 2017 11:41:13 +0000 (19:41 +0800)]
Fix GATT discovery service fail over BR/EDR

According to the current gattc state machine, stack queues
discovery services request comes from framework when gattc
is in BTA_GATTC_DISCOVER_ST state. This request is re-scheduled
after discovery on server finished in bta_gattc_disc_cmpl
and return the discovery results to framemwork. But now, stack
assumed LE transport in code, which prevents discovery services
executing. This error can be detected by ACTS GATTOverBrEdrTest:
test_gatt_bredr_connect_trigger_on_services_discovered

Fix assumed transport to actual situantion

Test: ACTS GATTOverBrEdrTest:
test_gatt_bredr_connect_trigger_on_services_discovered
Change-Id: I110a0a3c19595fb76c3bb15b092ce18ebf7b11bf

6 years agoFix Bluetooth crash on user switching
Jakub Pawlowski [Thu, 14 Dec 2017 17:26:43 +0000 (09:26 -0800)]
Fix Bluetooth crash on user switching

Test: compilation
Fixes: 70634701
Change-Id: I571bb8dde1317b2a7e4a73a1316c4c26d0f19466

6 years agobtif_sock_rfc: Use %u for uint32_t
Yi Kong [Wed, 6 Dec 2017 00:25:56 +0000 (16:25 -0800)]
btif_sock_rfc: Use %u for uint32_t

Discovered by the upcoming compiler update.

Test: build
Change-Id: If1497232b8f74bfc95194126a398e62f6eda7672

6 years agoHFP: Fix static check errors
Jack He [Tue, 12 Dec 2017 03:49:30 +0000 (19:49 -0800)]
HFP: Fix static check errors

* In bta/ag and btif/btif_hf.cc
* Simplify boolean values
* Use nullptr intead of NULL
* Use C++ style include headers instead of C style ones
* Remove unused struct definitions
* Remove unused code from bta_ag_ci.h/cc
* Use range based for-loop when it can be converted automatically
* Use C++ style zero-initialization instead of memset so that non-POD
  members of structs can be initialized properly
* Use "" to initliaze char array since the rest of the array will be
  zero padded if the array is assigned to a shorter string than its
  length

Bug: 68340193
Test: make, connect to HFP enabled device
Change-Id: I25c1e48ca1cb40629b9b60243ec462f498d8fc24

6 years agoMerge "Bump GATT cache file version marker"
Treehugger Robot [Wed, 13 Dec 2017 21:54:02 +0000 (21:54 +0000)]
Merge "Bump GATT cache file version marker"

6 years agoBump GATT cache file version marker
Jakub Pawlowski [Wed, 13 Dec 2017 18:02:32 +0000 (10:02 -0800)]
Bump GATT cache file version marker

In commit 819e2ecb84, the type used for UUID in the GATT cache was changed
from tBT_UUID to bluetooth:Uuid. This changed the binary representation of
this field. 18 bytes were used previously, now only 16 bytes are used.
This change made GATT cache file format incompatible between Android
versions, and requires an increment of cache file format version.

Fixes: 70297056
Test: added GattCacheTest
Change-Id: I4bceada300dbe3aab10d14df2aa853e4573c536e

6 years agoMerge "Fix callback type mismatches in Bluetooth"
Vishwath Mohan [Wed, 13 Dec 2017 21:00:31 +0000 (21:00 +0000)]
Merge "Fix callback type mismatches in Bluetooth"

6 years agoAdded check to know the status of any ongoing pairing status.
Matadeen Mishra [Tue, 21 Jun 2016 12:27:31 +0000 (17:57 +0530)]
Added check to know the status of any ongoing pairing status.

Use Case: Host allows incoming pairing even though outgoing pairing
is in process.

Steps:
1. Initiate bonding from Mecapp and provide pin key at Mecapp pairing
pop-up.
2. Start pairing for Logitech mouse from DUT and click on accept
pairing at mecapp pairing pop-up.
3. Give the same pin key for mecapp pairing pop-up at DUT side and
observe the behavior.

Failure: Incoming request is getting from remote and got a pop-up
for PIN request.

Root Cause: Pairing was auto accepted for remote device while
pairing was in progress with another remote device leading to
inconsistent behavior.

Fix: Rejects incoming pairing request from remote device
if already in pairing state.

Test: Tested with HID Logitech Mouse

Fixes: 35417665

Change-Id: I19a2a98e4ceb51cabaef279a2e3f8224fbed9ea1

6 years agoFix callback type mismatches in Bluetooth
Vishwath Mohan [Mon, 4 Dec 2017 21:28:06 +0000 (13:28 -0800)]
Fix callback type mismatches in Bluetooth

This CL fixes some mismatches between defined callback signatures and
the signatures of the functions that are actually passed in as that
type.

Bug: 67507323
Test: lunch walleye_cfi && m -j50

Change-Id: Ia5c22ac614c34cc8bd8a370861d988bb9f8034a6

6 years agoMerge "BLE: Don't set SC bit in AuthReq for Legacy Devices"
Treehugger Robot [Wed, 13 Dec 2017 01:21:23 +0000 (01:21 +0000)]
Merge "BLE: Don't set SC bit in AuthReq for Legacy Devices"

6 years agoMerge "Check MT call setup state before starting ring timer"
Treehugger Robot [Wed, 13 Dec 2017 00:31:35 +0000 (00:31 +0000)]
Merge "Check MT call setup state before starting ring timer"

6 years agoBLE: Don't set SC bit in AuthReq for Legacy Devices
Hemant Gupta [Wed, 6 Dec 2017 10:05:20 +0000 (15:35 +0530)]
BLE: Don't set SC bit in AuthReq for Legacy Devices

Disable SC bit for legacy LE devices (< 4.2) since as per earlier
spec, this BIT should be 0 and ignored by remote device. Some remote
legacy devices which don't follow the approach of ignoring these bits
(if set) go in bad state and result in SMP pairing failure.

Test: Pairing succeeds with remote device after resettings SC bit.

Fixes: 70259025
Change-Id: I35838c60fb08916a141f764b3e1922d277b99f28

6 years agoAVRCP: Flush the command queue in AVRC_Close
Myles Watson [Tue, 12 Dec 2017 00:23:21 +0000 (16:23 -0800)]
AVRCP: Flush the command queue in AVRC_Close

Test: toggle BR/EDR, manually inspect open files using lsof
Change-Id: I7bdc3a3840e7cc31894a9050dd5b7c29f863bb30

6 years agoMerge "Make BluetoothPbap implement BluetoothProfile (3/3)"
Treehugger Robot [Tue, 12 Dec 2017 19:02:26 +0000 (19:02 +0000)]
Merge "Make BluetoothPbap implement BluetoothProfile (3/3)"

6 years agobinder: Call writeParcelFileDescriptor()
Myles Watson [Fri, 8 Dec 2017 23:50:49 +0000 (15:50 -0800)]
binder: Call writeParcelFileDescriptor()

Fixes: 69678755
Test: manual inspection using lsof
Change-Id: Ifcb5af2d5797e667c20d4c41ad836cf7626e9909

6 years agoMake BluetoothPbap implement BluetoothProfile (3/3)
Hansong Zhang [Sat, 9 Dec 2017 00:08:34 +0000 (16:08 -0800)]
Make BluetoothPbap implement BluetoothProfile (3/3)

Change AIDL method signatures:
* Removed connect()
* Add BluetoothDevice parameter for disconnect()
* Rename other method names to be consistent with BluetoothProfile
methods

Test: test with PBAP carkits
Bug: 69417672
Change-Id: Ide81254d71128b9d204b63aa60bc39752add6edd

6 years agoMerge "HFP: Remove dead code in native interface"
Treehugger Robot [Fri, 8 Dec 2017 01:14:59 +0000 (01:14 +0000)]
Merge "HFP: Remove dead code in native interface"

6 years agoMerge "Make LE CoC Maximum PDU Size configurable"
Treehugger Robot [Thu, 7 Dec 2017 22:20:51 +0000 (22:20 +0000)]
Merge "Make LE CoC Maximum PDU Size configurable"

6 years agoMake LE CoC Maximum PDU Size configurable
Jakub Pawlowski [Tue, 5 Dec 2017 07:17:49 +0000 (23:17 -0800)]
Make LE CoC Maximum PDU Size configurable

Hearing Aid will need to modify this value. For existing code keep the
value as is.

Test: none
Bug: 69623109
Change-Id: I8c97882b5dd08a049d3a958c51163bad41df4d6a

6 years agoMerge "BTIF: Fix return types of interface getters"
Treehugger Robot [Thu, 7 Dec 2017 20:21:54 +0000 (20:21 +0000)]
Merge "BTIF: Fix return types of interface getters"

6 years agoHFP: Remove dead code in native interface
Jack He [Thu, 7 Dec 2017 19:19:06 +0000 (11:19 -0800)]
HFP: Remove dead code in native interface

The following hidden API methods are not implemented by the stack and
should be removed:
  - getBatteryUsageHint()
  - acceptIncomingConnect()
  - rejectIncomingConnect()

The following hidden API methods are no longer needed due to lack of
usage and should be removed:
  - enableWBS()
  - disableWBS()
  - bindResponse()

Bug: 70336991
Test: make
Change-Id: Ifa0d3cbdf4487465782144b84a2bed5e4f7acc4e

6 years agoGATT cache memory corruption fix
Jakub Pawlowski [Tue, 5 Dec 2017 12:05:46 +0000 (04:05 -0800)]
GATT cache memory corruption fix

When doing GATT discovery, we interleave adding elements to vector,
and storing pointers to them. This can cause memory corruption, because
vector can reallocate the memory when adding element, leaving the pointers
invalid. To fix that, never store pointers to mutable vector elements.

Bug: 70041392
Test: manual, connected to HID device
Change-Id: I6bb3fec61afa742f446b66e3291c5f326738ee17

6 years agoBTA GATT operation queue
Jakub Pawlowski [Thu, 30 Nov 2017 05:49:32 +0000 (21:49 -0800)]
BTA GATT operation queue

Currently, HID BTA app have own GATT queue for scheduling reads/writes
during device setup. Such queue will also be needed for Hearing Aid.
This patch makes the GATT queue code generic and clean it up.

Test: manual, bond HID device
Bug: 69623109
Change-Id: Ic893d630ab5154f7c1875748f3e275cbad02a7b2

6 years agoBTIF: Fix return types of interface getters
Jack He [Mon, 4 Dec 2017 22:30:42 +0000 (14:30 -0800)]
BTIF: Fix return types of interface getters

* They should return const pointer to interface structs
* Fixed return type for btif_rc_ctrl_get_interface, it should be
  "const btrc_ctrl_interface_t*" but was "btrc_interface_t*". Later
  casting masked this error, but it may hurt us in the future if not
  fixed

Test: make
Change-Id: I41b2366cce68b1338761d84cef9ab986fd3334df

6 years agoMerge "Log BT Trace levels per profile"
Treehugger Robot [Wed, 6 Dec 2017 20:51:42 +0000 (20:51 +0000)]
Merge "Log BT Trace levels per profile"

6 years agoMerge "Remove BluetoothHidDeviceAppConfiguration (1/4)"
Treehugger Robot [Wed, 6 Dec 2017 19:34:22 +0000 (19:34 +0000)]
Merge "Remove BluetoothHidDeviceAppConfiguration (1/4)"

6 years agoRemove the remote from paired list when auth fails
Venkata Jagadeesh Garaga [Wed, 6 Dec 2017 19:06:40 +0000 (19:06 +0000)]
Remove the remote from paired list when auth fails
am: dae4076bcb

Change-Id: I5c0d47a55b13e2b4bf13678edcb45e01584d8cad

6 years agoRemove the remote from paired list when auth fails
Venkata Jagadeesh Garaga [Sun, 30 Jul 2017 11:05:54 +0000 (16:35 +0530)]
Remove the remote from paired list when auth fails

Problem:
Remote stuck in connecting state during reconnection.

Steps:
1.Pair and connect the remote.
2.disconnect the remote and try to connect again from the DUT. In few trial authentication failure observed.

Root Cause:
During profile re connection scenario stack not posting
bond state change call back with bond none state if any
authentication failure. Any profile connection triggered
after this can stuck in security procedure and
never recovers.

Fix:
Hence remove the remote from paired list when auth fails

Test: manual
Bug:69028610
Change-Id: I6ac627e733f8b0b191c600153542acbb07f8c7a8

6 years agoCheck MT call setup state before starting ring timer
Satish Kodishala [Wed, 13 Jan 2016 13:53:04 +0000 (19:23 +0530)]
Check MT call setup state before starting ring timer

Test: 1. Pair and connect to Bluetooth Headset.
2. Make an incoming call and accept it from phone or BT headset.

Failure:
User may hear ring although incoming call accepted.

Root cause:
There is a ring timer to send RING every 5 secs to connected
headset until the MT call is accepted. When the call is
accepted, we stop the ring timer and send call indicators.
In case, just at the same time the ring timer stopped and
call indicators sent, if ring timer expired, it will be started
again.

Fix:
Start the ring timer only if the call is not accepted yet.

Bug: 35415875
Change-Id: Ifbde9ac45ac406f46e418a8d20abff0fefe6d414

6 years agoLog BT Trace levels per profile
Eagle Kang [Thu, 13 Apr 2017 06:50:53 +0000 (14:50 +0800)]
Log BT Trace levels per profile

BT stack trace level load from bt_stack.conf.
This change help developer to know BT stack log level
when analyze main logs.

Test: manual
Change-Id: I00037ac7d3a4bf88ea027ded77f22bef212a5874

6 years agoMerge "Add missing space in GATT_Register log"
Jakub Pawlowski [Tue, 5 Dec 2017 18:28:42 +0000 (18:28 +0000)]
Merge "Add missing space in GATT_Register log"
am: 563d7af58d

Change-Id: Ic74998a761cfaedf42e18fceea0006c386a93a66

6 years agoMerge "Add missing space in GATT_Register log"
Treehugger Robot [Tue, 5 Dec 2017 18:07:27 +0000 (18:07 +0000)]
Merge "Add missing space in GATT_Register log"

6 years agoFind connection ID on BR/EDR
Chao Quan [Tue, 5 Dec 2017 14:34:24 +0000 (14:34 +0000)]
Find connection ID on BR/EDR
am: 72b64d5302

Change-Id: I8a51ce2405720b000ce52c01855540ae45b33e3d

6 years agoFind connection ID on BR/EDR
Chao Quan [Mon, 23 Oct 2017 11:56:16 +0000 (19:56 +0800)]
Find connection ID on BR/EDR

GATT profile may send service change indication to its
connected client and gatt_profile_find_conn_id_by_bd_addr
function helps gatt profile to find its connected client.
Gatt profile may use a BR/EDR link. So need to check it
also to avoid missing.

Test: manual
Change-Id: Ieb64cf6eab9d94352440c876be69990a7a4eb57f

6 years agoAdd missing space in GATT_Register log
Jakub Pawlowski [Tue, 5 Dec 2017 08:19:44 +0000 (00:19 -0800)]
Add missing space in GATT_Register log

Test: none
Change-Id: Idab3083daa68a958f33b264db1ff5e2f0c211ba5