OSDN Git Service

android-x86/system-bt.git
7 years agoMerge "Various small warning/build fixes for Linux"
Treehugger Robot [Thu, 20 Oct 2016 22:16:03 +0000 (22:16 +0000)]
Merge "Various small warning/build fixes for Linux"

7 years agoReset device security flags when pairing fails
Andre Eisenbach [Tue, 18 Oct 2016 00:32:45 +0000 (17:32 -0700)]
Reset device security flags when pairing fails

Bug: 29998634
Test: manual
(cherry picked from commit 54ee9431e8bf0ec1c47d7306fd7a3d0975590733)

Change-Id: I8bd0ce5b797e30009260f7fe673f389d066db9ac

7 years agoVarious small warning/build fixes for Linux
Jakub Pawlowski [Thu, 20 Oct 2016 17:19:50 +0000 (10:19 -0700)]
Various small warning/build fixes for Linux

Test: build with ninja
Change-Id: Ic0f4d23e4a56a42be6e660f2afec83400ea6daa6

7 years agoVarious small fixes for Linux build
Jakub Pawlowski [Thu, 20 Oct 2016 06:31:13 +0000 (23:31 -0700)]
Various small fixes for Linux build

* add "-latomic" which was missing since we moved to clang
* empty LOG_EVENT_INT stub added for Linux
* add link libraries to fix stack_unittest
* add missing headers

Test: build with ninja
Change-Id: I1fe0b0b615db1da5ad083c162cb207b08979ce15

7 years agoMove libhardware dependency to third_party folder on Linux
Jakub Pawlowski [Thu, 20 Oct 2016 01:35:18 +0000 (18:35 -0700)]
Move libhardware dependency to third_party folder on Linux

Thanks to this change we no longer have to configure paths by hand

Test: build with ninja
Change-Id: I04dfaa8f16e52a25efcc241019bae40d4201fb8b

7 years agoosi: Apply clang-format
Myles Watson [Wed, 19 Oct 2016 20:15:34 +0000 (13:15 -0700)]
osi: Apply clang-format

cd osi/
clang-format -i --style=file include/*.h include/socket_utils/* src/*.cc \
    src/socket_utils/* src/protos/* test/*

Test: mma -j32
Change-Id: I659e586076f1e2ec8f687cd33f441700b8d1f823

7 years agoGet rid of dependency on core from linux build (1/2)
Jakub Pawlowski [Wed, 19 Oct 2016 03:22:14 +0000 (20:22 -0700)]
Get rid of dependency on core from linux build (1/2)

When building bluetooth stack for linux, don't include dependencies from
core.

Test: build with ninja and mma
Change-Id: I02aeb178327c9f6c0414cc37624aecc58fb0876e

7 years agoMerge "Abstract the adjustment of A2DP codec parameters"
Treehugger Robot [Wed, 19 Oct 2016 07:11:14 +0000 (07:11 +0000)]
Merge "Abstract the adjustment of A2DP codec parameters"

7 years agoRemove Android a2dp bridge from generic build configuration
Jakub Pawlowski [Wed, 19 Oct 2016 01:45:21 +0000 (18:45 -0700)]
Remove Android a2dp bridge from generic build configuration

Code in audio_a2dp_hw folder contains Android-specific code for talking
to Android media libraries. It is not useful on other platforms, and
only adds unnecessary dependencies.

Test: compile with ninja
Change-Id: Ia0313332b4456ba0287587da66cdf2cce045f89c

7 years agoAbstract the adjustment of A2DP codec parameters
Pavlin Radoslavov [Wed, 19 Oct 2016 00:19:55 +0000 (17:19 -0700)]
Abstract the adjustment of A2DP codec parameters

Replaced hard-coded SBC-specific hack for updating some
of its parameters with an API abstraction: A2DP_AdjustCodec()
Also, added the corresponding unit tests.

Bug: 30958229
Test: manual A2DP testing, added new unit tests
Change-Id: I51a0a019d107362f9c24829408d426a5403b0a8e

7 years agoMerge "Use the default LE connection timeout if the remote device has no preference"
Treehugger Robot [Wed, 19 Oct 2016 00:50:29 +0000 (00:50 +0000)]
Merge "Use the default LE connection timeout if the remote device has no preference"

7 years agoMerge "Remove unused task IDs"
Treehugger Robot [Wed, 19 Oct 2016 00:30:01 +0000 (00:30 +0000)]
Merge "Remove unused task IDs"

7 years agoUse the default LE connection timeout if the remote device has no preference
Jakub Pawlowski [Tue, 18 Oct 2016 21:56:00 +0000 (14:56 -0700)]
Use the default LE connection timeout if the remote device has no preference

Change-Id: I03f022b6f18c7d1ec7f139a7d67fd60ec6f15ba2

7 years agoMerge "Add the appropriate statement to "case:" without "break""
Treehugger Robot [Tue, 18 Oct 2016 20:48:22 +0000 (20:48 +0000)]
Merge "Add the appropriate statement to "case:" without "break""

7 years agoMerge "Remove GAP_CONN_POST_EVT_INCLUDED"
Treehugger Robot [Tue, 18 Oct 2016 20:44:08 +0000 (20:44 +0000)]
Merge "Remove GAP_CONN_POST_EVT_INCLUDED"

7 years agoRemove unused task IDs
Andre Eisenbach [Tue, 18 Oct 2016 19:16:07 +0000 (12:16 -0700)]
Remove unused task IDs

Test: compiles
Change-Id: I0a16498d82d12e1b7597290e8b778efb5a7b3906

7 years agoRemove GAP_CONN_POST_EVT_INCLUDED
Andre Eisenbach [Tue, 18 Oct 2016 18:58:57 +0000 (11:58 -0700)]
Remove GAP_CONN_POST_EVT_INCLUDED

Also removed last usage of a GKI_* function.

Test: compiles
Change-Id: If9f8beca5d8485b363027fd64ac4005e9e499721

7 years agoLinux build fix
Jakub Pawlowski [Tue, 18 Oct 2016 16:56:29 +0000 (09:56 -0700)]
Linux build fix

Test: compile using ninja

7 years agoAdd the appropriate statement to "case:" without "break"
Pavlin Radoslavov [Tue, 18 Oct 2016 17:12:26 +0000 (10:12 -0700)]
Add the appropriate statement to "case:" without "break"

Test: code compilation
Change-Id: Ia43d7530a598a526764023c47bb20fdedda6fe64

7 years agoAdd clang configuration for ninja build scripts
Jakub Pawlowski [Tue, 18 Oct 2016 16:56:57 +0000 (09:56 -0700)]
Add clang configuration for ninja build scripts

Test: compile with ninja
Change-Id: I0f2ff28a03de05ea96bed5ba43eace9609d8deb0

7 years agobtif_rc: Don't memset STL mutex objects
Greg Kaiser [Tue, 18 Oct 2016 14:04:24 +0000 (07:04 -0700)]
btif_rc: Don't memset STL mutex objects

Switching to STL mutex/recursive_mutex objects left us with
code which memset these objects.  These are opaque, and need to
be initialized/destroyed via constructors/destructors, not
through directly setting their memory.

We change our memset calls to only zero out the parts of the
structs which don't have these objects.

Test: Recompile
Change-Id: Idf666e935f4094ad4cfca7cdafa523f777a7e769

7 years agoRenamed most C files to C++: *.c to *.cc
Pavlin Radoslavov [Sat, 15 Oct 2016 02:34:48 +0000 (19:34 -0700)]
Renamed most C files to C++: *.c to *.cc

Also:
 - Fixed C++ related compilation errors.
 - Added missing 'extern "C"' guards in some of the header files.
 - Added missing LOCAL_CPP_EXTENSION to Android.mk files.
 - Added-back btif/src/btif_mce.cc and bta/mce/bta_mce_* to
   btif/Android.mk and bta/Android.mk respectively.
 - Fixed the alphabetical ordering of the *.cc files in some
   of the Android.mk files.
 - Added missing Copyright header to "osi/include/list.h"
 - Updated "osi/src/wakelock.cc" to use C++ std::string
   instead of dynamic allocation of C-style strings.

Test: code compilation, unit tests, and A2DP streaming
Change-Id: Ia2f7215ed9df32775c701b68fc86b09875b942c7

7 years agoRemoved obsoleted define statements from bt_target.h
Pavlin Radoslavov [Tue, 18 Oct 2016 00:38:02 +0000 (17:38 -0700)]
Removed obsoleted define statements from bt_target.h

The removed statements were accidentally re-introduced
by an earlier CL that wasn't cherry-picked / rebased properly.

Test: code compilation.
Change-Id: I726a8df99c4a8e7af8130c0ca63306e67c4486c3

7 years agoMerge "Add various missing includes"
Treehugger Robot [Tue, 18 Oct 2016 01:38:08 +0000 (01:38 +0000)]
Merge "Add various missing includes"

7 years agoAdd various missing includes
Mark Salyzyn [Mon, 17 Oct 2016 16:43:39 +0000 (09:43 -0700)]
Add various missing includes

Test: Build errors
Bug: 30465923
Change-Id: Ib902d9d11d1f346d4dab0678d7f409f11a35c1b2

7 years agoMake advertising instance count part of the HCI interface
Jakub Pawlowski [Mon, 10 Oct 2016 21:25:52 +0000 (14:25 -0700)]
Make advertising instance count part of the HCI interface

The number of advertising instances will ultimately depend on the HCI
interface used. BleAdvertisingManagerImpl should not depend on a global
function for that.

Test: Covered by BleAdvertiseApiTest sl4a test
Bug: 30622771
Change-Id: I1399de3f4289708f7218eae9c00ac7372e4246db

7 years agoImplement AVRCP Controller (Client) Browsing.
Sanket Agarwal [Wed, 11 May 2016 19:30:49 +0000 (12:30 -0700)]
Implement AVRCP Controller (Client) Browsing.

Following is included as part of the features:
a) Browsing for all 4 scopes (Media, VFS, Player and Now Playing)
b) Player selection and song selection from browse list.

The change constructs the following (from lower to upper protocol
layers):
1. AVCTP Browse (bta/ & stack/)
                -- Connection Handling
                -- Constructing browse commands
                -- Parsing browse responses
2. AVRCP  (btif/)
                -- JNI interaction/API
                -- Connection handling to Java
                -- Delegating request and responses to Java

Bug: 28791287
Change-Id: Ibc97ded93cb9c469778ea1e37733390d561cd4cd
(cherry picked from commit 9ea8d07c9286a1f4d338dd64ee02266e324d28e5)

7 years agoFormat A2DP-related code with clang-format
Pavlin Radoslavov [Fri, 14 Oct 2016 23:13:54 +0000 (16:13 -0700)]
Format A2DP-related code with clang-format

clang-format -style=file -i stack/a2dp/a2dp_* stack/include/a2dp_* \
        btif/include/btif_a2dp* btif/src/btif_a2dp*

Test: top-level compilation and running A2DP
Change-Id: I66f0a047192b783ac0147def480754daf617dd8d

7 years agoRemoved unused *_DYNAMIC_MEMORY conditional statements
Pavlin Radoslavov [Fri, 14 Oct 2016 22:47:27 +0000 (15:47 -0700)]
Removed unused *_DYNAMIC_MEMORY conditional statements

Test: compilation from the top-level directory
Change-Id: I181e6ae2e71c232ca0dc733dabda5cb0fc2672d8

7 years agoMerge "Use proper types in SBC related code"
Treehugger Robot [Sat, 15 Oct 2016 04:51:06 +0000 (04:51 +0000)]
Merge "Use proper types in SBC related code"

7 years agoUse proper types in SBC related code
Jakub Pawlowski [Sat, 15 Oct 2016 00:14:16 +0000 (17:14 -0700)]
Use proper types in SBC related code

Use int32_t and int16_t instead of SINT32 and SINT16

Test: organoleptic assessment of audio quality from Android and Linux
Change-Id: Ia4d8a5f08163a90240382fd102082f5aab9611c5

7 years agoMerge "Add device record for BR/EDR devices with derived LE keys"
Treehugger Robot [Sat, 15 Oct 2016 00:34:00 +0000 (00:34 +0000)]
Merge "Add device record for BR/EDR devices with derived LE keys"

7 years agoMerge "A2DP-related renaming: a2d_* to a2dp_*"
Treehugger Robot [Sat, 15 Oct 2016 00:09:42 +0000 (00:09 +0000)]
Merge "A2DP-related renaming: a2d_* to a2dp_*"

7 years agoAdd device record for BR/EDR devices with derived LE keys
Subramanian Srinivasan [Fri, 14 Oct 2016 22:43:34 +0000 (15:43 -0700)]
Add device record for BR/EDR devices with derived LE keys

Loads BLE keys stored in NVRAM to btm_sec database for BR/EDR
devices with cross transport derived LE keys after BT reset.
This change also makes sure that after BT reset, while loading
the bonded devices from NVRAM, the bonded devices(with device
type BR/EDR and having derived BLE keys) are also added to the
resolving list after loading the IRK into btm_sec database.

Test: vendor
Change-Id: I1c9164a947526cf2ea36156458d148f5cbee778f

7 years agoA2DP-related renaming: a2d_* to a2dp_*
Pavlin Radoslavov [Fri, 14 Oct 2016 22:14:37 +0000 (15:14 -0700)]
A2DP-related renaming: a2d_* to a2dp_*

Test: top-level compilation and running A2DP

Change-Id: Ibbd3176b86667885666bfe29025ec2c120fafce6

7 years agoFixes setting of service uuid mask during BLE APCF scan
Subramanian Srinivasan [Mon, 24 Aug 2015 19:17:03 +0000 (12:17 -0700)]
Fixes setting of service uuid mask during BLE APCF scan

Fixes setting of incorrect service uuid mask bytes in vendor
specific command when service uuid mask length is less than
the length of service uuid APCF filter.
eg:ServiceUuid:12131215-0000-1000-8000-00805F9B34FB
SvcMaskUuid:0000FFFF-0000-1000-8000-00805F9B34FB
In the above eg, user is trying to apply 32 bit service uuid
mask on 32 bit service uuid. But the stack treats the
service uuid mask as 16 bits and inserts garbage values for
the first 16 bits of service uuid mask in the VS command
since the MSB bits of the mask are zeroes. This change fixes
the scenario where service uuid mask length is less than
service uuid length.

Change-Id: Ie1aece1162b1ba7f4b7a3e9eea7eb5a074f85d62

7 years agoHCI HAL: Retry writing HCI data on UART socket for EAGAIN errors
Lawrance Liu [Wed, 21 Sep 2016 15:01:13 +0000 (23:01 +0800)]
HCI HAL: Retry writing HCI data on UART socket for EAGAIN errors

If HCI HAL receives error code "EAGAIN" when transmitting data on UART
socket, retry transmit data again.

Purpose :
When doing system suspend/resume aging test, the HCI HAL may transmit
data during system resuming. In this case, there exist some timing which
BT controller does not allow HCI HAL to transmit data.

Change-Id: Ic1f13c76d8e735c941800a318a0388ca42b1fd72
Test: System suspend/resume aging test.

7 years agoMerge "Renamed files: *.c to *.cc in bta/av and stack/a2dp"
Treehugger Robot [Fri, 14 Oct 2016 20:21:15 +0000 (20:21 +0000)]
Merge "Renamed files: *.c to *.cc in bta/av and stack/a2dp"

7 years agoUpdate hf structure on phone state change only if SLC is up
Satish Kodishala [Thu, 4 Feb 2016 04:05:59 +0000 (09:35 +0530)]
Update hf structure on phone state change only if SLC is up

Usecase:
1. Enable multi-hf
2. Pair and connect A2DP to a headset(hs1).
3. Pair and connect HFP to another headset(hs2)
4. Accept call on AG
5. Disconnect hs2 by powering off headset
6. Disconnect the call
7. Power on the hs2

Failure:
No A2DP playback on hs1 though music player is playing.

Rootcause:
When there is a call on AG, we update both hf structures about
the call. However, when any headset gets disconnected, only its
hf structure is cleared. After the call is ended, we don't clear
hf structures since there is no hf connection. When A2DP queries
for active call, we return true incorrectly since the hs1's structures
are not updated when the call is ended.

Fix:
Update hf structures on phone state change only if SLC is connected
on it. Updating both hf structures regardless of the SLC state causes
hf state to indicate wrong status.

Test: manual
Change-Id: I487792038d97a2bac77639d7c699f49fc0b18f97

7 years agoUpdate GATT channel state to closing during disconnection
Nitin Arora [Thu, 14 May 2015 01:39:50 +0000 (18:39 -0700)]
Update GATT channel state to closing during disconnection

This change ensures that the GATT channel state is
moved to CLOSING state while GATT disconnect is
requested by the host, specifically when the GATT
state is OPEN.
This is needed to prevent any furthur GATT operations,
once GATT disconnect is issued.

Change-Id: I8511caa477881de4f4eaf18b84f23530e1958fe9

7 years agoSkip LE key derivation if BR key is temporary
Nitin Arora [Wed, 19 Aug 2015 22:47:23 +0000 (15:47 -0700)]
Skip LE key derivation if BR key is temporary

This change skips the LE LTK derivation in case the BR pairig
is not deticated bonding and neither side has requested MITM.
I.e. OPP file transfer require such bonds. This change resolve
the issue of residual IRK in the resolving list.

Change-Id: Ifc9dfc097564f603a466a5bd9b245c89f1bb82aa

7 years agoAdd null checks for L2CAP socket callback
Srinu Jella [Wed, 25 Mar 2015 07:36:38 +0000 (13:06 +0530)]
Add null checks for L2CAP socket callback

Use Case: Bluetooth process crashed while sending the file
to remote device.

Steps: Send a file over L2CAP (OBEX over L2CAP) to remote device

Failure: BT process will crash and restarted automatically

Root Cause: L2CAP socket callback reset to null on error
condition, and when other function try to dereference it, this
leads to BT crash.

Fix: Added null checks for L2CAP socket callback

Change-Id: I2e4f20278fcc8a09bd4dbd507a6c4147e0de93c1

7 years agoRenamed files: *.c to *.cc in bta/av and stack/a2dp
Pavlin Radoslavov [Fri, 14 Oct 2016 19:17:08 +0000 (12:17 -0700)]
Renamed files: *.c to *.cc in bta/av and stack/a2dp

Also, fixed C++ related compilation errors.

Test: code compilation from top-level directory
Change-Id: I60367ee7bc54b891cb05bb3f88dd11ebe5b2ca83

7 years agoMerge "Rectify size passed to copy service name to security records"
Treehugger Robot [Fri, 14 Oct 2016 19:49:05 +0000 (19:49 +0000)]
Merge "Rectify size passed to copy service name to security records"

7 years agoMerge "Remove bonded device information on pairing rejected"
Treehugger Robot [Fri, 14 Oct 2016 19:45:26 +0000 (19:45 +0000)]
Merge "Remove bonded device information on pairing rejected"

7 years agoMerge "Cleanup L2CAP socket properly on close"
Treehugger Robot [Fri, 14 Oct 2016 19:43:05 +0000 (19:43 +0000)]
Merge "Cleanup L2CAP socket properly on close"

7 years agoFix HFP AT command BIA failures
Devin Kim [Wed, 7 Sep 2016 04:47:47 +0000 (13:47 +0900)]
Fix HFP AT command BIA failures

Running the PTE test case TC_AG_IIA_BV_01_I, a failure occurs due to
missing initialization of tBTA_AG_VAL.

Bug: 31325270
Test: PTS
Change-Id: I683eccd53d40e79ec03545166b18ffa1922f0fb2

7 years agoRFCOMM: Prevent sending data in BTA_JV_ST_NONE state
Srinu Jella [Mon, 7 Sep 2015 08:10:07 +0000 (13:40 +0530)]
RFCOMM: Prevent sending data in BTA_JV_ST_NONE state

This patch adds state check in bta_jv_rfcomm_write, to prevent sending
data in BTA_JV_ST_NONE state. This would prevent an ASSERT in the code
due to a null handle. The handle might have already been set to null
during the closing of the RFCOMM connection.

Change-Id: Ibc6b1fb7aa6dce9a4acb52d724af3023fad9a9ae

7 years agoRectify size passed to copy service name to security records
Gurpreet Ghai [Thu, 9 Jun 2016 09:06:35 +0000 (14:36 +0530)]
Rectify size passed to copy service name to security records

Use case: Services having name length greater than max length
always take new slot in security records. After few enable
disable cycles in BLE ON scenario, the record gets completely
occupied making further connection impossible.

Steps:
1. Install a BLE App to create BLE always ON scenario.
2. Run a few cycles of Bluetooth(BREDR) enable-disable.

Failure: Once security records are completely occupied, new
connections are not possible because of socket creation
failure due to unavailability of security id.

Root cause: Size passed to copy service name does not include
bit for null termination. So, for services having name size
greater than that size have their last bit truncated for null
termination.
During next enable, the comparison with same size always fails
causing service to take new slot in security records array.

Fix: Increased the size passed to copy service name by 1 after
considering null termination.

Change-Id: I3527df6610932f60fd85bcdd14d5b8a527c79722

7 years agoRemove bonded device information on pairing rejected
Srinu Jella [Thu, 17 Mar 2016 11:53:48 +0000 (17:23 +0530)]
Remove bonded device information on pairing rejected

Use Case: Remove bonded device information from the BTIF layer storage
when authentication failed.

Failure: Remote device appeared in the paired list after authentication
failed.

Steps:
1. Create a connection from DUT to remote.
2. Remove linkkey in remote.
3. Create connection from DUT to remote, which is in paired list of
DUT, Remote rejected the connection and authentication failed.
But after BT OFF/ON, remote device appeared in the paired list

Root Cause: Not removing device if remoted rejected the pairing
request with reason pairing not allowed

Fix: Remove bonded device information from the BTIF layer storage
on rejected with pairing not allowed reason from remote

Change-Id: Ic9e5e1ed70d304edd3dbca82a73833753fa0093c

7 years agoCleanup L2CAP socket properly on close
Srinu Jella [Thu, 7 Apr 2016 13:35:44 +0000 (19:05 +0530)]
Cleanup L2CAP socket properly on close

Use case:
1. Sometimes pairing pop up occurs during Android beam
   transfer though it is not required.
2. No OPP Tx request over OBEX if we cancel during file transfer.

Steps:
1. Pair and connect from DUT to remote.
2. Go to gallery and send a file.
3. Accept same file and stop it from remote during transfer.
4. Repeat step 2-4 10 times.

Failure:
OPP Tx should not fail.

Root cause:
Close request was not properly handled from BTIF layer.

Fix:
1. Close the request properly from BTIF layer
   to close the socket variables and instruct the BTA layer
   close from there as well.

2. Clean up L2CAP socket properly on closure to free
   the entry registered with security manager to avoid
   leak in security manager records.

3. Close the socket for all valid handles including handle 0.

Change-Id: I4e37dcd858af258fbd64fbfb2fbf0083bd743e06

7 years agoAdd missing header files for ninja
Jakub Pawlowski [Fri, 14 Oct 2016 16:09:26 +0000 (09:09 -0700)]
Add missing header files for ninja

Ninja is complaining about unknown size_t and CHAR_BIT.

Test: compile with ninja
Change-Id: I5cf16dbeba964b8553b4e97d9ee21f68891956e3

7 years agoAdd a mechanism to dump A2DP codec stats
Pavlin Radoslavov [Wed, 12 Oct 2016 16:45:30 +0000 (09:45 -0700)]
Add a mechanism to dump A2DP codec stats

Also, added-back A2DP SBC frames related stats:
  - media_read_total_limited_frames
  - media_read_max_limited_frames
  - media_read_limited_count
  - media_read_total_expected_frames
  - media_read_max_expected_frames
  - media_read_expected_count

A2DP SBC State:
  Frames expected (total/max/ave)                         : 9131 / 8 / 6
  Frames limited (total/max/ave)                          : 0 / 0 / 0
  Counts (expected/limited)                               : 1322 / 0

Bug: 30958229
Test: manual
Change-Id: Id6ddea5eb9d39cf03cae84c79968081d56984e91

7 years agoAdd include for CHAR_BIT definition
Jakub Pawlowski [Thu, 13 Oct 2016 23:49:07 +0000 (16:49 -0700)]
Add include for CHAR_BIT definition

ninja is failing to compile due to missing limits.h include

Change-Id: I4c8eb0df7fb521c44358401ed1ce5cafe29384bb

7 years agoMerge "BTIF A2DP Source and Sink refactor and cleanup"
Treehugger Robot [Fri, 14 Oct 2016 01:55:33 +0000 (01:55 +0000)]
Merge "BTIF A2DP Source and Sink refactor and cleanup"

7 years agoBTIF A2DP Source and Sink refactor and cleanup
Pavlin Radoslavov [Mon, 3 Oct 2016 01:34:46 +0000 (18:34 -0700)]
BTIF A2DP Source and Sink refactor and cleanup

* Moved bta/av/bta_av_sbc.c to stack/a2dp/a2d_sbc_up_sample.c
  and renamed the corresponding bta_av_sbc_up_sample_* functions to
  a2d_sbc_up_sample_*
  Also, renamed bta_av_sbc_init_up_sample() to a2d_sbc_init_up_sample()
* Moved A2DP SBC Encoder-related tasks, state and constants from
  btif_a2dp_source.cc to a2d_sbc_encoder.c
* Introduced A2DP encoder callbacks interface tA2D_ENCODER_INTERFACE,
  and added A2D_GetEncoderInterface() to acccess the interface for a codec.
* Updated a2d_sbc_encoder_init() to specify callbacks:
  - a2d_source_read_callback_t - a callback to read audio data for encoding
  - a2d_source_enqueue_callback_t - a callback to enqueue A2DP source
    packets for transmission
* Removed BTIF_MEDIA_TRSCD_* - the encoding is always PCM
* Removed conditionally defined constants and replaced them by
  local definitions:
  - BTIF_MEDIA_BITRATE_STEP -> A2D_SBC_BITRATE_STEP
  - BTIF_A2DP_DEFAULT_BITRATE -> A2D_SBC_DEFAULT_BITRATE
  - BTIF_A2DP_NON_EDR_MAX_RATE -> A2D_SBC_NON_EDR_MAX_RATE
* Hard-coded the read data timeout period A2DP_DATA_READ_POLL_MS to 10ms
* Merged the UNDERRUN read errors into the UNDERFLOW errors.
* Removed the following statistics, because they are not very useful:
  - media_read_total_limited_frames
  - media_read_max_limited_frames
  - media_read_limited_count
  - media_read_total_expected_frames
  - media_read_max_expected_frames
  - media_read_expected_count
* Updated the implementation of buffer_overruns_max_count to
  use the (new) counter tx_queue_max_dropped_messages instead of
  media_read_max_expected_frames
* Replaced usage of LOG_DEBUG() in stack/a2d/ with LOG_VERBOSE():
  the former is enabled by default on some of the builds.
* Renamed:
  - btif_a2dp_sink_audio_focus_state_t -> btif_a2dp_sink_focus_state_t
  - btif_a2dp_sink_set_audio_focus_state_req() ->
    btif_a2dp_sink_set_focus_state_req()
  - tBTIF_A2DP_SINK_CB.RxSbcQ -> rx_audio_queue
  - btif_a2dp_source_start_aa_req() -> btif_a2dp_source_start_audio_req()
  - btif_a2dp_source_stop_aa_req() -> btif_a2dp_source_stop_audio_req()
  - btif_a2dp_source_aa_readbuf() -> btif_a2dp_source_audio_readbuf()
  - tBTIF_A2DP_SOURCE_CB.TxAaQ -> tx_audio_queue
  - BTIF_A2DP_SOURCE_MEDIA_TIMER_MS -> A2D_SBC_ENCODER_INTERVAL_MS
  - tA2D_AV_MEDIA_FEEDINGS -> tA2D_FEEDING_PARAMS
  - tBTIF_A2DP_SOURCE_INIT_AUDIO -> tA2D_ENCODER_INIT_PARAMS
  - tBTIF_A2DP_SOURCE_UPDATE_AUDIO -> tA2D_ENCODER_UPDATE_PARAMS
  - tBTIF_A2DP_SOURCE_INIT_AUDIO_FEEDING -> tBTIF_A2DP_SOURCE_INIT_FEEDING

Bug: 30958229
Test: TestTracker/65192
Change-Id: Iba0a9694bda3dba73f211f1bde25821497fa6a06

7 years agoUse proper socket type in uipc for non-android
Jakub Pawlowski [Thu, 13 Oct 2016 22:46:30 +0000 (15:46 -0700)]
Use proper socket type in uipc for non-android

Change-Id: I5e901ca381c816945146b508770a2aa54d9cdd79

7 years agoUpdate BUILD.gn files
Jakub Pawlowski [Thu, 13 Oct 2016 22:43:15 +0000 (15:43 -0700)]
Update BUILD.gn files

Test: compiled using ninja

7 years agoSplit btif_media_task into Source, Sink and Control
Pavlin Radoslavov [Fri, 23 Sep 2016 23:36:47 +0000 (16:36 -0700)]
Split btif_media_task into Source, Sink and Control

* btif/include/btif_a2dp.h and btif/src/btif_a2dp.cc implement
  the entry points for the BTIF A2DP module.

* btif/include/btif_a2dp_source.h and btif/src/btif_a2dp_source.cc implement
  the BTIF A2DP Source component.

* btif/include/btif_a2dp_sink.h and btif/src/btif_a2dp_sink.cc implement
  the BTIF A2DP Sink component.

* btif/include/btif_a2dp_control.h and btif/src/btif_a2dp_control.cc
  implement the A2DP control mechanism for the audio channel from the
  Media Framework.

Also:
* Removed BTA_AV_SBC_HDR_SIZE and used A2D_SBC_MPL_HDR_LEN instead.
* Removed BTIF_AV_SINK_FOCUS_REQ_EVT, because it is not used.
* Removed many of the "#if (BTA_AV_SINK_INCLUDED == TRUE)" guards.
* Removed "#ifdef USE_AUDIO_TRACK" guard, and always compile the
  corresponding code.
* Removed tBTIF_AV_MEDIA_FEEDINGS_PCM_STATE and moved its state
  to tBTIF_AV_MEDIA_FEEDINGS_STATE .

Bug: 30958229
Test: TestTracker/65192
Change-Id: I20bc52a1d7a7f03c92628a1562f14b7df3ebb445

7 years agoMerge "cleanup: Remove BT_USE_TRACES and BT_TRACE_APPL"
Treehugger Robot [Thu, 13 Oct 2016 00:22:49 +0000 (00:22 +0000)]
Merge "cleanup: Remove BT_USE_TRACES and BT_TRACE_APPL"

7 years agoFix file permissions for source code files
Pavlin Radoslavov [Wed, 12 Oct 2016 19:54:05 +0000 (12:54 -0700)]
Fix file permissions for source code files

Removed file execute permissions for:
 - bta/include/bta_hh_co.h
 - embdrv/sbc/decoder/Android.mk
 - embdrv/sbc/Android.mk
 - embdrv/Android.mk
 - btif/co/bta_ag_co.cc

Test: visual inspection of file permissions
Change-Id: I746debb1e8ceaa1cc14f867641b25cb42c04c7be

7 years agocleanup: Remove BT_USE_TRACES and BT_TRACE_APPL
Marie Janssen [Wed, 12 Oct 2016 19:40:57 +0000 (12:40 -0700)]
cleanup: Remove BT_USE_TRACES and BT_TRACE_APPL

Test: mma in system/bt

Change-Id: I357eb44a97f3935262252cf97c13cef078a95e4d

7 years agoMerge "btif: migrate from pthread locks to std::mutex"
Marie Janssen [Wed, 12 Oct 2016 16:17:42 +0000 (16:17 +0000)]
Merge "btif: migrate from pthread locks to std::mutex"

7 years agoMoved the typedef of period_ms_t from alarm.h to time.h
Pavlin Radoslavov [Wed, 12 Oct 2016 00:46:45 +0000 (17:46 -0700)]
Moved the typedef of period_ms_t from alarm.h to time.h

Test: code compilation
Change-Id: Ib61126d7921d088b045dca6c5b69a5379603fcc3

7 years agobtif: migrate from pthread locks to std::mutex
Marie Janssen [Mon, 10 Oct 2016 20:38:30 +0000 (13:38 -0700)]
btif: migrate from pthread locks to std::mutex

Test: run unit tests / sanity connection to devices
Change-Id: I293c3600affd229fea67cdd6624eba7f186cbcb7

7 years agoManually merge commit 'cc15f06acc3a1447318fefae00b3c10d9b7ae42a' to fix
Stephen Li [Tue, 11 Oct 2016 17:27:31 +0000 (10:27 -0700)]
Manually merge commit 'cc15f06acc3a1447318fefae00b3c10d9b7ae42a' to fix
automerger

BUG:32069275
Change-Id: I60cc50b21fe0d5a5464bd3acc5897ba7c4e05b73

7 years agostack: remove dead (#if 0'd) code
Marie Janssen [Mon, 10 Oct 2016 16:49:14 +0000 (09:49 -0700)]
stack: remove dead (#if 0'd) code

Test: compiles
Change-Id: I34f68c2b166a28622155358ff75478af8d18bed0

7 years agoFix improper connection check for absolute volume
Ajay Panicker [Tue, 11 Oct 2016 03:43:42 +0000 (20:43 -0700)]
Fix improper connection check for absolute volume

Test: Manually tested
Bug: 32060762
Change-Id: Ia6ca97c119d421aef1136f97afccb3f0c126334d

7 years agoReplace all uses of sprintf() with snprint()
George Burgess IV [Wed, 2 Mar 2016 22:00:19 +0000 (14:00 -0800)]
Replace all uses of sprintf() with snprint()

- sprintf() does not limit the length of the character string when writing
  to a buffer and may result in buffer overflow
- snprintf() requires the maximum write length as a parameter. When the
  maximum length supported is smaller than the reserved buffer length,
  the call will not result in buffer overflow

Bug: 31859081
Test: TestTracker/64195/3975
Change-Id: I519f8ef7b9b162fd79094f89148250d783c734c0

7 years agoMerge "Revert "Add dumpsys support for LE connection parameter updates""
Treehugger Robot [Mon, 10 Oct 2016 23:44:10 +0000 (23:44 +0000)]
Merge "Revert "Add dumpsys support for LE connection parameter updates""

7 years agoRemove Jabra headsets from absolute volume blacklist
Andre Eisenbach [Tue, 13 Sep 2016 16:57:51 +0000 (09:57 -0700)]
Remove Jabra headsets from absolute volume blacklist

Firmware fixes are available for affected headsets (Thanks, Jabra!!).

Change-Id: I60b42366d1e8155895cc58fff69f6404415a0406

7 years agoConvert advertising HAL from struct into class (3/3)
Jakub Pawlowski [Thu, 6 Oct 2016 23:52:30 +0000 (16:52 -0700)]
Convert advertising HAL from struct into class (3/3)

Bug: 30622771
Test: all related tests were updated
Change-Id: I9695284ae249fa427ae4b2f3e9649da951102c6c

7 years agoRemove return value of BTM_VendorSpecificCommand function
Jakub Pawlowski [Mon, 10 Oct 2016 19:36:49 +0000 (12:36 -0700)]
Remove return value of BTM_VendorSpecificCommand function

The return value of BTM_VendorSpecificCommand is currently just an
information wether the callback was passed to it or not, but many places
through stack use this value as error indication. Remove it.

Test: unit tests pass
Change-Id: Idf73fc49fb25e52c3aeb64f2305b4498ecacd9a4

7 years agoMerge "Remove return value of BTM_VendorSpecificCommand function"
Treehugger Robot [Mon, 10 Oct 2016 22:21:36 +0000 (22:21 +0000)]
Merge "Remove return value of BTM_VendorSpecificCommand function"

7 years agoRevert "Add dumpsys support for LE connection parameter updates"
Andre Eisenbach [Thu, 6 Oct 2016 22:42:22 +0000 (22:42 +0000)]
Revert "Add dumpsys support for LE connection parameter updates"

Reverting for now after talking to Jacky because this causes  circular dependencies as lower layer (stack/) functions are calling higher layer APIs (btif/) directly.

To restore a change like this, the data should be collected at a lower layer in the stack and reported through polling or a callback.

This reverts commit 8ec8ca4a875eed8b28e6714899f49781537411ae.

Change-Id: I748843864ae7198ea021fe70d2643a62097ab029

7 years agoMerge "L2CAP: Ensure handle is not null before attempting to close a socket"
Treehugger Robot [Mon, 10 Oct 2016 20:19:29 +0000 (20:19 +0000)]
Merge "L2CAP: Ensure handle is not null before attempting to close a socket"

7 years agoRemove return value of BTM_VendorSpecificCommand function
Jakub Pawlowski [Mon, 10 Oct 2016 19:36:49 +0000 (12:36 -0700)]
Remove return value of BTM_VendorSpecificCommand function

The return value of BTM_VendorSpecificCommand is currently just an
information wether the callback was passed to it or not, but many places
through stack use this value as error indication. Remove it.

Test: unit tests pass
Change-Id: Idf73fc49fb25e52c3aeb64f2305b4498ecacd9a4

7 years agoRemove return value from btsnd_hcic_* functions
Jakub Pawlowski [Mon, 10 Oct 2016 18:39:39 +0000 (11:39 -0700)]
Remove return value from btsnd_hcic_* functions

btsnd_hcic_* functions are always returning true, so this return value
is not really useful.

Test: unit tests pass
Change-Id: I06ced65392d180ceed565e45b7831de6aede283c

7 years agoIgnore return value of btsnd_hcic_* functions
Jakub Pawlowski [Mon, 10 Oct 2016 16:35:13 +0000 (09:35 -0700)]
Ignore return value of btsnd_hcic_* functions

btsnd_hcic_* functions return only true. This patch makes sure that no
logic is waiting for "false" value.
Few methods, that had their return value dependent on result of
btsnd_hcic_* were made void.

Test: unit tests pass
Change-Id: I43cff62f461ff35f4bd84e5338f1a587b6a05c58

7 years agoL2CAP: Ensure handle is not null before attempting to close a socket
Joseph Pirozzo [Mon, 10 Oct 2016 14:05:51 +0000 (07:05 -0700)]
L2CAP: Ensure handle is not null before attempting to close a socket

Bug: 32054308
Test: manual, UPF 55
Change-Id: Ib89f7557fa390d60691afe8399a768e8127e52cb
(cherry picked from commit a1fa1bb0d638d5f444bf959fb839e824d69de31d)

7 years agoMerge "Add null check to avoid exception after L2CAP psm assigned"
Treehugger Robot [Fri, 7 Oct 2016 19:51:54 +0000 (19:51 +0000)]
Merge "Add null check to avoid exception after L2CAP psm assigned"

7 years agoHID: Fix to handle UHID_OUTPUT_EV command from UHID driver
Ben YoungTae Kim [Wed, 10 Aug 2016 20:31:23 +0000 (13:31 -0700)]
HID: Fix to handle UHID_OUTPUT_EV command from UHID driver

Incorrect size check for UHID_OUTPUT_EV for incoming data from
UHID driver of kernel was leading to exiting of poll thread.
This was causing IOT issues with Apple Magic Mouse that require
output report to be sent for proper functioning of scroll functionality.

Bug: 28942565
Change-Id: I2eaba1f70b7cd51fb21933031d439543eb141fd2

7 years agoAdd null check to avoid exception after L2CAP psm assigned
Gurpreet Ghai [Wed, 3 Feb 2016 09:31:41 +0000 (15:01 +0530)]
Add null check to avoid exception after L2CAP psm assigned

Use case: BT will get crash in SNS testing.

steps: SNS testing BT ON/OFF.

Failure: Crash is observed.

Root Cause: If the number of supported services increased,
larger service record array is required. Smaller array is
resulting in out of record error causing L2CAP deregister.

Fix: Check added to avoid null pointer exception if null
is returned while fetching sock from id. Also cleanup of
SDP and security records done during BT turning Off.

Change-Id: I2e77127262119cabf2c372f894427dcdf3350e80

7 years agoRefactor advertising data types
Jakub Pawlowski [Wed, 5 Oct 2016 02:30:09 +0000 (19:30 -0700)]
Refactor advertising data types

Currently we have some unnecessary complicated code for handling
advertising data. Get rid of it.

Bug: 30622771
Test: Tests making sure flags and tx power are filled are added
Change-Id: I807cdf11577c357c116c54cab50bbf3261e1ee16

7 years agoUse the correct API to check whether a codec is valid
Pavlin Radoslavov [Wed, 5 Oct 2016 21:25:08 +0000 (14:25 -0700)]
Use the correct API to check whether a codec is valid

Use the (new) A2D_IsPeerSinkCodecValid() API call as appropriate
to check whether the codec information of a Sink peer is valid.
Previously, A2D_IsSourceCodecSupported() was used, and that didn't
match the original code (before the refactoring).
A2D_IsSourceCodecSupported() has extra checks, including min/max bitpool
oundaries, and those shouldn't be used for this initial check - the
bitpool boundaries can be adjusted later.

Similarly, use the new A2D_IsPeerSourceCodecValid() API call instead of
A2D_IsSinkCodecSupported().

Also:
 * Replaced A2D_IsValidCodec() with
   A2D_IsSourceCodecValid(), A2D_IsSinkCodecValid()
   A2D_IsPeerSourceCodecValid(), A2D_IsPeerSinkCodecValid()
   and added the appropriate unit tests.

 * Added extra debug messages to help identify similar issues in the future

Bug: 31749230
Test: manual test with a carkit, and unit tests
Change-Id: Iafaeb82744df9758e686194c91624992a0c55bdf

7 years agoRemove unnecessary checks of BTM_MAX_LOC_BD_NAME_LEN
Jakub Pawlowski [Tue, 4 Oct 2016 23:47:01 +0000 (16:47 -0700)]
Remove unnecessary checks of BTM_MAX_LOC_BD_NAME_LEN

Change-Id: I6e68f80d0d97081a4fc3879e6c11342923cfef7b

7 years agoMake Bluetooth LE multi-advertising testable
Jakub Pawlowski [Wed, 28 Sep 2016 14:36:54 +0000 (07:36 -0700)]
Make Bluetooth LE multi-advertising testable

This patch turns the code that manages LE multi-advertising into the
BleAdvertisingManager class. All HCI calls made by this code were
abstracted into BleAdvertiserHciInterface.

Thanks to those changes, we can mock BleAdvertiserHciInterface and test
the advertising manager.

The BleAdvertisingManagerTest, still has some dependencies on other
code from the "stack" module. These have to be implemented on top of the
test file. In the future, this dependencies should be replaced by mockable
classes.

Test: Tests covering the change are added in this patch.
Bug: 30622771
Change-Id: I4a363678815c235ee01255f462db2a671ef89610

7 years agovendor_lib: Apply clang-format with the new config
Myles Watson [Fri, 30 Sep 2016 15:45:15 +0000 (08:45 -0700)]
vendor_lib: Apply clang-format with the new config

cd vendor_libs/test_vendor_lib/
clang-format ../linux/bt_vendor_linux.c -style=file -i
clang-format include/* test/* src/* -style=file -i

Update the style guide since clang-format help uses the
-style=file option.

Test: mm -j32
Change-Id: I166adfb2bb9a87fefa1242c91e5f180011caa2ad

7 years agobt: replace cutils/log.h with android/log.h
Mark Salyzyn [Wed, 28 Sep 2016 22:31:49 +0000 (15:31 -0700)]
bt: replace cutils/log.h with android/log.h

Test: compile
Bug: 26552300
Bug: 31289077
Change-Id: I8fb392150441ca5b6bc43dc43a10a3009e22202b

7 years agoMerge "Fix bad GATT client state machine state after successfull cache load"
Jakub Pawlowski [Tue, 4 Oct 2016 00:38:14 +0000 (00:38 +0000)]
Merge "Fix bad GATT client state machine state after successfull cache load"

7 years agoReplace log/log.h with android/log.h
Mark Salyzyn [Thu, 29 Sep 2016 16:16:01 +0000 (09:16 -0700)]
Replace log/log.h with android/log.h

Actually, remove reference, android logging is not used here.

Test: compile
Bug: 26552300
Bug: 31289077
Change-Id: I37731dc37f61c129f3440e5d9ff1d0e71fe193d0

7 years agoFix bad GATT client state machine state after successfull cache load
Jakub Pawlowski [Mon, 3 Oct 2016 20:25:01 +0000 (13:25 -0700)]
Fix bad GATT client state machine state after successfull cache load

If the GATT service cache was successfully loaded from a file, the
state must be reset to idle.

Bug: 31175159
Change-Id: I92ebf1bec9d2e7467d7412b41923614ec5a13b6d

7 years agotest_vendor: Refactor scheduling of dual_mode_controller event handling
Jorge E. Moreira [Fri, 16 Sep 2016 23:50:41 +0000 (16:50 -0700)]
test_vendor: Refactor scheduling of dual_mode_controller event handling

Moved all controller actions out of read callbacks to task callbacks to
avoid race conditions when modifying internal controller state.

Change-Id: Ie8bb762992755db2dddb6b7bb6a4fe52ab2d0020

7 years agoRemove redundant logic from system/bt/bta
Jack He [Fri, 30 Sep 2016 19:57:44 +0000 (12:57 -0700)]
Remove redundant logic from system/bt/bta

Bug: 31274290
Test: Manual
Change-Id: I5a4bff5e25b08a32709cdc81bac86a641d80f113

7 years agoMerge "Do not request remote name from non-connectable dev"
Treehugger Robot [Fri, 30 Sep 2016 19:40:53 +0000 (19:40 +0000)]
Merge "Do not request remote name from non-connectable dev"

7 years agoMerge "Fix warnings of implicit function declaration in Linux vendor lib"
Treehugger Robot [Fri, 30 Sep 2016 19:33:46 +0000 (19:33 +0000)]
Merge "Fix warnings of implicit function declaration in Linux vendor lib"

7 years agoDo not request remote name from non-connectable dev
Kim Schulz [Fri, 29 Apr 2016 08:26:02 +0000 (10:26 +0200)]
Do not request remote name from non-connectable dev

if an LE device is found during an LE scan, the BT host will try to fetch its name (creating an LE
connection) even though the advertising report received indicates that it is a non-connectable
advertising.
This is pointless and should not happen.

Change-Id: I246e4795b4f4e33f3202908ebff3724e8e89523c

7 years agoFix warnings of implicit function declaration in Linux vendor lib
Patrick Tsai [Sat, 19 Mar 2016 04:12:34 +0000 (21:12 -0700)]
Fix warnings of implicit function declaration in Linux vendor lib

Change-Id: I482f1096e87966f33ba8584ea60188abab3bcc42

7 years agoFix NULL pointer crash in send_at_cmd
Sebastien Griffoul [Fri, 17 Oct 2014 10:14:19 +0000 (12:14 +0200)]
Fix NULL pointer crash in send_at_cmd

If the string argument of send_at_cmd is a null pointer,
then the function should not crash: indeed this is a valid
parameters which can be used to send an AT cmd which doesn't
require any extra parameter.

Test: trivial fix. Existing unit tests still pass.
Change-Id: I3d83eebed660d703cd5a93a19dc73f4f354ab7bf
Signed-off-by: Sebastien Griffoul <sebastien.griffoul@intel.com>
7 years agoEnable libbase logging for whole stack
Jakub Pawlowski [Wed, 28 Sep 2016 01:24:59 +0000 (18:24 -0700)]
Enable libbase logging for whole stack

Currently, only C++ code in the service/ folder can use libbase logging.
This patch makes sure that logging can be used and is properly
configured for usage when the stack is running as part of Bluetooth.apk.

Bug: 31806042
Change-Id: I1f8be79ba9999b53ece0b5217a893b4bd20ecafc