OSDN Git Service

android-x86/system-bt.git
8 years agoAdd missing creation of timer tSMP_CB.smp_rsp_timer_ent
Pavlin Radoslavov [Fri, 22 Jan 2016 21:13:45 +0000 (13:13 -0800)]
Add missing creation of timer tSMP_CB.smp_rsp_timer_ent

Add missing creation of timer tSMP_CB.smp_rsp_timer_ent so
the timer is not NULL.

Bug: 26611369
Change-Id: I2882d40090599b628ecee777b244376168806776

8 years agoAdd extra log if timer_create(CLOCK_BOOTTIME_ALARM) fails
Pavlin Radoslavov [Fri, 22 Jan 2016 18:44:40 +0000 (10:44 -0800)]
Add extra log if timer_create(CLOCK_BOOTTIME_ALARM) fails

Add explicit log messages if timer_create(CLOCK_BOOTTIME_ALARM)
fails. The most likely reason is the kernel doesn't have
the appropriate patches.

Bug: 25739638
Change-Id: Icbeaa965d729ba11dfb7cfbb6185b1655b3c6de4

8 years agoA workaround for kernels missing CLOCK_BOOTTIME_ALARM
Pavlin Radoslavov [Fri, 22 Jan 2016 02:04:36 +0000 (18:04 -0800)]
A workaround for kernels missing CLOCK_BOOTTIME_ALARM

If the kernel doesn't have support for CLOCK_BOOTTIME_ALARM,
then timer_create(CLOCK_BOOTTIME_ALARM) will fail.

Added #ifdef KERNEL_MISSING_CLOCK_BOOTTIME_ALARM guard to get around
the issue. Platforms that don't have CLOCK_BOOTTIME_ALARM should have
the following lines in the device's "bdroid_buildcfg.h" file:

 /* Defined if the kernel does not have support for CLOCK_BOOTTIME_ALARM */
 #define KERNEL_MISSING_CLOCK_BOOTTIME_ALARM TRUE

Bug: 26611369
Change-Id: I455dbbc20f43b21a83998cd60cac8dea0a73080d

8 years agoMerge "service: Solve locking issues inside GATT interface"
Jakub Pawlowski [Fri, 22 Jan 2016 02:23:30 +0000 (02:23 +0000)]
Merge "service: Solve locking issues inside GATT interface"

8 years agoRefactor the Bluetooth timers
Pavlin Radoslavov [Sat, 5 Dec 2015 01:36:34 +0000 (17:36 -0800)]
Refactor the Bluetooth timers

* Updated the alarm API:
  - Existing API alarm_new() is modified to take an alarm name
    as an argument.
  - New API alarm_new_periodic() is used to create a periodic
    alarm.
  - Added new API alarm_is_scheduled() to test whether an alarm is
    scheduled.
  - Existing API alarm_set_periodic() is removed: a periodic
    alarm is created by alarm_new_periodic().
  - Added new API alarm_set_on_queue() to set an alarm whose
    callback is executed on a specific queue.
  - Added new API alarm_register_processing_queue() and
    alarm_unregister_processing_queue() to register/unregister
    a queue and the corresponding thread for alarm processing.
  - Added corresponding unit tests.

* Updated the alarm internals:
  - Added alarm_info_t for collecting alarm-related information
    and statistics.
  - Collect and store alarm-related statistics into alarm_info_t
    per alarm.
  - Include the alarm-related statistics and info into the native
    dumpsys output for Bluetooth.
  - Once an alarm expires, the alarm execution is scheduled for
    processing on another internal alarm-specific thread, not
    on the thread that is maintaining the alarms.
  - Implemented callback execution ordering guarantee among
    timers on the same thread with exactly same timeout values.

* Refactor some of the usage of alarm_set() and simplify the
  code by using alarm_set_on_queue() instead.

* Removed the non_repeating timers wrapper, and use directly
  the alarm mechanism / API.

* Refactored all timer_entry_t timers and replaced them with alarm_t
  timers:
  - Replaced the btu_start_timer() / btu_stop_timer() /
    btu_start_quick_timer() / btu_stop_quick_timer() /
    btu_oneshot_alarm() mechanism with alarm_set_on_queue() and
    alarm_cancel()
  - Removed the whole mechanism around the BTU_TTYPE_* timers.

* Fixed a bug when processing the GATT indication confirmation timer
  expiration (timer tGATT_TCB.conf_timer: b/26610829).

* Renamed and/or split misc. timeout functions, fields, and timers

* Renamed time-related constants and changed the values from seconds
  to milliseconds

* Replaced timer tAVDT_CCB.timer_entry with three mutually exclusive timers:
  idle_ccb_timer, ret_ccb_timer, rsp_ccb_timer
  The reason we are using three timers, is because in the original code
  function avdt_ccb_chk_timer() used the timer type in its logic: it
  would stop the timer only if the type is "idle".

* Removed btm_ble_timeout() and replaced it with multiple timeout
  callback functions (per timer)

* Fix the actual value of the global constant BT_1SEC_TIMEOUT and
  rename it to BT_1SEC_TIMEOUT_MS

* Removed btu_cb and associated timers and events, because they are
  never used.

* Removed unused timers, functions, struct and declarations that are
  not used / needed.

Bug: 26611369
Bug: 26610829

Change-Id: I812c8c31710a5daefc58b01fcf35c353768f390f

8 years agoAdd support for native kernel and callout wakelocks
Pavlin Radoslavov [Mon, 24 Aug 2015 23:29:21 +0000 (16:29 -0700)]
Add support for native kernel and callout wakelocks

 * Moved wakelock-related code to osi/src/wakelock.c
   The API is in osi/include/wakelock.h

 * Use wakelock_set_os_callouts() to specify native kernel
   or callout-based wakelock.
   On Android, wakelock_set_os_callouts() is called to
   set the bt_os_callouts_t callbacks into the Java layer.

 * Renamed alarm_set_wake_lock_paths() to wakelock_set_paths()

Also, added Bluetooth Wakelock Statistics to the bugreport.
Sample output:

$ adb shell dumpsys bluetooth_manager
...
Bluetooth Wakelock Statistics:
  Wakelock is acquired                    : false
  Wakelock acquired/released count        : 5 / 5
  Wakelock acquired/released errors       : 0 / 0
  Wakelock last acquired time (ms)        : 1524
  Wakelock acquired time min/max/avg (ms) : 1511 / 8104 / 3167
  Wakelock total acquired time (ms)       : 15836
  Bluetooth total run time (ms)           : 44123

Bug: 26645431
Change-Id: I42bfb7db5b016719faea39e47ebc77c3ad02467b

8 years agoMove btsnooz.py script from Android Wear to the BT stack project.
Sharvil Nanavati [Wed, 20 Jan 2016 17:14:47 +0000 (09:14 -0800)]
Move btsnooz.py script from Android Wear to the BT stack project.

Change-Id: I8368820b5ed9325d2c3b82885b9fe934c6bc87ca

8 years agoservice: Solve locking issues inside GATT interface
Jakub Pawlowski [Thu, 21 Jan 2016 00:24:03 +0000 (16:24 -0800)]
service: Solve locking issues inside GATT interface

ObserverList class handles adding/removing elements during iteration
by itself, therefore we don't need to do any locking.
Additionally, change lock type to shared for better performance, and
to avoid possible deadlocks that might be caused by calling HAL from
observers.

Change-Id: I4c372f1e03bd27a96bc6c036ab8ce34f5501c0a7

8 years agoUpdate btsnooz log file format to log ACL and SCO headers.
Sharvil Nanavati [Fri, 15 Jan 2016 21:41:56 +0000 (13:41 -0800)]
Update btsnooz log file format to log ACL and SCO headers.

Change-Id: I72db1769197150f34ebba6fcb9c0e3db2404f342

8 years agoFix build break in system/bt
Alex Vakulenko [Thu, 21 Jan 2016 03:04:32 +0000 (19:04 -0800)]
Fix build break in system/bt

This was due to libchrome uprev submitted earlier

Change-Id: Ic0f1bd80ff4563bd73754cd3b9fcd521e93616e7

8 years agoAdd socket tx/rx accounting
Adam Lesinski [Thu, 3 Dec 2015 06:15:08 +0000 (22:15 -0800)]
Add socket tx/rx accounting

Records network traffic going over bluetooth sockets. This patch adds support
for L2CAP and RFCOMM.

Bug: 26039657
Change-Id: Id30d69e4cd648f0e88ab23517e3b94f29b393995

8 years agoMerge "service/client: implement connect and disconnect methods"
Jakub Pawlowski [Thu, 21 Jan 2016 00:35:34 +0000 (00:35 +0000)]
Merge "service/client: implement connect and disconnect methods"

8 years agoservice/client: implement connect and disconnect methods
Jakub Pawlowski [Wed, 20 Jan 2016 01:07:53 +0000 (17:07 -0800)]
service/client: implement connect and disconnect methods

Change-Id: I141e8a1a917adfe7a2eb1c8adaf5e09fad9df5ac

8 years agoAdd missing field to fake Bluetooth interface
Ajay Panicker [Wed, 20 Jan 2016 22:42:20 +0000 (14:42 -0800)]
Add missing field to fake Bluetooth interface

Bug: 26686093
Change-Id: I09867ae073fb32165c64bf9d306b699c6bc843ee

8 years agobt: Update libchrome APIs to r369476
Alex Vakulenko [Wed, 20 Jan 2016 15:52:34 +0000 (07:52 -0800)]
bt: Update libchrome APIs to r369476

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

Change-Id: I988157d3a6e36ede6561c0fa6919bb756e8ed3dd

8 years agoservice: Expose Connect and Disconnect through IBluetothLowEnergy
Jakub Pawlowski [Wed, 20 Jan 2016 01:00:16 +0000 (17:00 -0800)]
service: Expose Connect and Disconnect through IBluetothLowEnergy

Change-Id: Idcfd3fac263e61bc1bb2be97017554d552511765

8 years agoMerge "Add Connect and Disconnect methods to LowEnergyClient"
Jakub Pawlowski [Wed, 20 Jan 2016 21:45:47 +0000 (21:45 +0000)]
Merge "Add Connect and Disconnect methods to LowEnergyClient"

8 years agoMerge "service: add HAL for connect/disconnect"
Jakub Pawlowski [Wed, 20 Jan 2016 21:45:40 +0000 (21:45 +0000)]
Merge "service: add HAL for connect/disconnect"

8 years agoAdd Connect and Disconnect methods to LowEnergyClient
Jakub Pawlowski [Wed, 20 Jan 2016 00:42:37 +0000 (16:42 -0800)]
Add Connect and Disconnect methods to LowEnergyClient

Change-Id: Ibabfd44575b7ab1c8fc7a57b844956038dd571c4

8 years agoSupport for A2DP Sink - Follow-up fix
Pavlin Radoslavov [Wed, 20 Jan 2016 18:41:01 +0000 (10:41 -0800)]
Support for A2DP Sink - Follow-up fix

Update the code so it matches the corresponding code in the internal tree.

Change-Id: I7cb143cde31e2cfca54b2172737cf262ae478186

8 years agoservice: add HAL for connect/disconnect
Jakub Pawlowski [Wed, 20 Jan 2016 00:35:20 +0000 (16:35 -0800)]
service: add HAL for connect/disconnect

Change-Id: I05b86af68e05433241d0206b0952d859483dee80

8 years ago Support for A2DP Sink and Proper initialization of profiles
Anubhav Gupta [Tue, 5 May 2015 07:45:07 +0000 (13:15 +0530)]
 Support for A2DP Sink and Proper initialization of profiles

 - Register SDP and SEP (Stream End Point) for the profile
   whose init is called. We achieve this by making registration
   api aware of profile id being called.
 - Register A2DP Src + Avrcp Target + Avrcp Controller. We need
   to support Absolute Volume as well, so Avrcp Controller is
   required here.
 - Register A2DP Sink + Avrcp Controller. In this case we do not
   support absolute volume. Support would be added in AVRCP
   controller change
 - Adapter property is updated with profile ID for which init is
   called.This is required to make changes in btService for Profile
   initialization
 - Start listening for incoming AVRCP connection if we have
   only AVRCP Controller
 - Update default peer_features based on feature mask. In case
   of incoming AVRCP connection, SDP will be done later.
   In such a scenario default peer features sent to btif should
   be based on  features-set selected during initialization.
 - Drop Control, Meta and Browse commands when TG is not up.
 - Not to call AVRCP app callbacks when mentioned service is down.
 - Close audio socket on suspend

A2DP Sink: Support for AudioTrack

 - implemetation for audiotrack to take care of audio rendering
 - support for audio focus state in bluedroid

Bluetooth: Support for Avrcp 1.3  Controller

- support for SDP registration
- support for sending vendor dependant commands
- support for abs vol
- support for receiving vendor dependant response
- serialization of connection and rc_features callback

Avrcp_Ctrl: handling of commands and events for AVRCP Controller

- support of parsing cmd and event pdus
- timeout handling

Change-Id: I1e8d49b087eff6301373e1e90e8d868f15847c34

8 years agoMake list_foreach() more useful
Andre Eisenbach [Thu, 14 Jan 2016 05:20:59 +0000 (21:20 -0800)]
Make list_foreach() more useful

- Changed |callback| return type to bool to be able to interrupt
  iteration (to find specific elements for example).
- Added new |extra| parameter for |callback| so a pointer can be passed
  in to receive output values or to pass in criteria etc.
- Also added unit tests.

Change-Id: Id1ddcbabf55292f701d0277f2a1e9ec261b9fbde

8 years agoDo not send AT+CHLD=? if the 3-way call feature is not supported
Devin Kim [Thu, 14 Jan 2016 01:37:57 +0000 (10:37 +0900)]
Do not send AT+CHLD=? if the 3-way call feature is not supported

The HF shall not issue the AT+CHLD=? test command in case
either the HF or the AG does not support the Three-way calling feature.
Currently HF sends AT+CHLD=? to AG device when SLC sequence on going.
It affects to SCO statemachine so that after going out of range and
coming back in range while active call alives, SCO state goes bad and
never comes back. This is out of specification of HFP and it should be
fixed by checking peer and local 3way call capability check.

Bug: 25703926
Change-Id: I66adac2345c6fb0df6741fdbfa67d9483fc38a00

8 years agoservice: Implement IBinder.dump()
Marie Janssen [Mon, 14 Dec 2015 20:12:57 +0000 (12:12 -0800)]
service: Implement IBinder.dump()

Add dump() support to BluetoothBinderServer and change IBluetooth
implementation to allow the system to call it correctly.

Bug: 26095165
Change-Id: I32ca78e37484b5d748b8caf4c293aafcf01dfbff

8 years agoMerge "service: Add RegisterTestClient"
Jakub Pawlowski [Thu, 14 Jan 2016 20:51:24 +0000 (20:51 +0000)]
Merge "service: Add RegisterTestClient"

8 years agoservice: Add RegisterTestClient
Jakub Pawlowski [Wed, 13 Jan 2016 23:41:06 +0000 (15:41 -0800)]
service: Add RegisterTestClient

Extract registration code into separate helper, that'll be used in
tests that require more than one client.

Bug: 25744656
Change-Id: Ib3ceac8bba02cf1eb83f4265849ec423ad588e42

8 years agoservice: add scan support to bluetooth-cli
Jakub Pawlowski [Wed, 13 Jan 2016 19:28:08 +0000 (11:28 -0800)]
service: add scan support to bluetooth-cli

Adde the start-le-scan and stop-le-scan commands to
bluetooth-cli for testing.

Bug: 25744656
Change-Id: I02d42fcca071eebefd82f027cd9b89af27116a00

8 years agoservice: Add LE scan result support to Binder API
Arman Uguray [Thu, 3 Dec 2015 01:39:14 +0000 (17:39 -0800)]
service: Add LE scan result support to Binder API

Added Binder API documentation, bindings, and logic for BLE device
scan result.

Bug: 25744656
Change-Id: I5130a6b47438e266fab4a7b52b5372909824bc81

8 years agoservice: Add LE scan support to Binder API
Arman Uguray [Thu, 3 Dec 2015 01:39:14 +0000 (17:39 -0800)]
service: Add LE scan support to Binder API

Added Binder API documentation, bindings, and logic for BLE device
scans. Also added the start-le-scan and stop-le-scan commands to
bluetooth-cli for testing.

Bug: 25744656
Change-Id: I08c9d23ddd78cff1702495cf6d431cf5b9a7b894

8 years agoMerge "service: Add OnScanResult Delegate event."
Jakub Pawlowski [Wed, 13 Jan 2016 23:00:59 +0000 (23:00 +0000)]
Merge "service: Add OnScanResult Delegate event."

8 years agoMerge "service: Add Start|StopScan API to LowEnergyClient"
Jakub Pawlowski [Wed, 13 Jan 2016 23:00:35 +0000 (23:00 +0000)]
Merge "service: Add Start|StopScan API to LowEnergyClient"

8 years agoMerge "service: Parametrize LowEnergyClient with Adapter for tests"
Jakub Pawlowski [Wed, 13 Jan 2016 23:00:16 +0000 (23:00 +0000)]
Merge "service: Parametrize LowEnergyClient with Adapter for tests"

8 years agoOffload config save functionality to BTIF thread
Srinu Jella [Thu, 24 Dec 2015 12:10:52 +0000 (17:40 +0530)]
Offload config save functionality to BTIF thread

Offload config save functionality to btif thread from
timer thread as timer callback thread is critical in
a2dp playback case.

If the timer callback thread is busy in config save due
to IO operations, it may lead to a2dp audio choppy.

Fix to avoid the "bt_config.conf" file corruption from
the file system. This will avoid losing the paired
information in some corner case, such as abrupt power
off and on. This patch will ensure bt_config is saved to
NVRAM.

Bug: 24875861
CRs-Fixed: 953993
Change-Id: I893e9afefa89cbab6e7ddd8835ca77d3e316874c

8 years agoCorrectly verify return value of BTM_CancelInquiry
Yan Laijun [Wed, 13 Jan 2016 14:28:01 +0000 (22:28 +0800)]
Correctly verify return value of BTM_CancelInquiry

Change-Id: Iefb38023bc2b3e390eec14516f954e36f34ed5b4
Signed-off-by: Yan Laijun <yan.laijun@gmail.com>
8 years agoservice: Add OnScanResult Delegate event.
Arman Uguray [Thu, 3 Dec 2015 01:29:27 +0000 (17:29 -0800)]
service: Add OnScanResult Delegate event.

Added the LowEnergyClient::Delegate class and implemented scan result
reporting via the OnScanResult Delegate event.

Bug: 25744656
Change-Id: I050118c4f6761a7a32fa3ec8d9a1b41126a4c3ae

8 years agoservice: Add Start|StopScan API to LowEnergyClient
Arman Uguray [Mon, 30 Nov 2015 23:36:17 +0000 (15:36 -0800)]
service: Add Start|StopScan API to LowEnergyClient

Added the StartScan and StopScan methods to LowEnergyClient and basic unit
tests. This currently only supports regular scans with no batch scan or
hw/sw filters.

Bug: 25744656
Change-Id: Iddf6e897377f90a5eef81ef36696b1d7074a7dab

8 years agoservice: Parametrize LowEnergyClient with Adapter for tests
Jakub Pawlowski [Tue, 12 Jan 2016 21:51:35 +0000 (13:51 -0800)]
service: Parametrize LowEnergyClient with Adapter for tests

Bug: 25744656
Change-Id: I4eee8098c264c2135c2bb4f02a2319ba0dfec978

8 years agoservice/hal: Add per-client Scan interface
Arman Uguray [Mon, 30 Nov 2015 22:58:11 +0000 (14:58 -0800)]
service/hal: Add per-client Scan interface

Added a new per-client scan function to hal::BluetoothGattInterface.
The intention here is to push most of the per-client reference counting,
scan settings and filter coalescence below the HAL. This CL does this
first inside the Bluetooth daemon's HAL wrappers in a way that
represents what the future HAL scan API might look like.

This implements a basic reference counting scheme to share the global
controller scan session among different clients.

Bug: 25744656
Change-Id: I20c5cfc291be70d72576ebee014cc13544d5a299

8 years agoservice: use client_id instead of client_if
Jakub Pawlowski [Wed, 13 Jan 2016 18:19:34 +0000 (10:19 -0800)]
service: use client_id instead of client_if

Change-Id: Id045c81f748c99ab0525ce8869ef9cdd0207712e

8 years agoMerge "service: Rename variable holding advertisement settings"
Jakub Pawlowski [Tue, 12 Jan 2016 22:58:03 +0000 (22:58 +0000)]
Merge "service: Rename variable holding advertisement settings"

8 years agoservice: Rename variable holding advertisement settings
Jakub Pawlowski [Tue, 12 Jan 2016 21:43:33 +0000 (13:43 -0800)]
service: Rename variable holding advertisement settings

There will be more variables with settings. Make sure they
all have unique meaningful names.

Change-Id: I4b23fd3fa5a16f9132801b9141e4f8ed0be33be7

8 years agoMerge "Additional headsets blacklisted for absolute volume"
Andre Eisenbach [Tue, 12 Jan 2016 19:31:12 +0000 (19:31 +0000)]
Merge "Additional headsets blacklisted for absolute volume"

8 years agoservice: Make Adapter mockable.
Arman Uguray [Thu, 19 Nov 2015 23:57:57 +0000 (15:57 -0800)]
service: Make Adapter mockable.

Turned the Adapter class into an abstract interface so that we
can inject a mock Adapter in tests where there is an Adapter dependency
but where we don't care about side-effects/stack-calls created from the
Adapter.

Bug: 25744656

Change-Id: Ibf7dd9a4cc1008cbb36e60f7b87cfcb4ef2bd5d8

8 years agoAdditional headsets blacklisted for absolute volume
Andre Eisenbach [Tue, 12 Jan 2016 02:06:44 +0000 (18:06 -0800)]
Additional headsets blacklisted for absolute volume

Bug: 26070064
Change-Id: Ida1faec964982a4630f42ab378fe5b6dd6e21c16

8 years agoAssert on memory allocation failure
Andre Eisenbach [Mon, 11 Jan 2016 20:24:14 +0000 (12:24 -0800)]
Assert on memory allocation failure

This CL is a pre-cursor to cleaning up repeated memory allocation code
full of null-pointer checks. In the vast majority of cases in the
Bluetooth stack, a failed allocation is not recoverable and results in
undefined behaviour. By asserting, we can ensure we have a shot at
catching and fixing any issues not caused by OOM conditions.

Bug: 26494317
Change-Id: I53dff98c596068211934a1808f90de2d4484f952

8 years agoMerge "service: Add global scan support getters"
Jakub Pawlowski [Mon, 11 Jan 2016 22:15:47 +0000 (22:15 +0000)]
Merge "service: Add global scan support getters"

8 years agoImplement OOB pairing for LE devices using TK.
Jakub Pawlowski [Tue, 1 Dec 2015 20:14:22 +0000 (12:14 -0800)]
Implement OOB pairing for LE devices using TK.

This patch implements OOB pairing for LE devices using TK. Patches
for other pairing methods, and other transports will follow.

Bug: 22932952
Change-Id: Iad3c0c035de3b5a62ef24d3e3b655773fa03d5c1

8 years agoAdd script to change data types to native C types
Andre Eisenbach [Wed, 30 Dec 2015 01:49:01 +0000 (17:49 -0800)]
Add script to change data types to native C types

Please see source code for usage information and application.

Bug: 22948224
Change-Id: Ia2dbd618ddcdf13abf3c63d4649147f400e00cfe

8 years agoA2DP task media alarm non-null protection
Ajay Panicker [Wed, 6 Jan 2016 20:11:05 +0000 (12:11 -0800)]
A2DP task media alarm non-null protection

Prevent the alarm from being started multiple times.

Bug: 26277592
Change-Id: I764f93bab5490bf5f3942a1beb706457197d3ec1

8 years agonet_test_bluetooth: fix inconsistency in set/get name test
Ajay Panicker [Tue, 5 Jan 2016 23:03:19 +0000 (15:03 -0800)]
net_test_bluetooth: fix inconsistency in set/get name test

Fixed an issue where the set/get name test would fail every so often
due to the fact that the old name property would become invalid after
the properties array was freed.

Bug: 25793348
Change-Id: I4513219da2fb947b3b199f25a61c308b9fced8b6

8 years agoFix bug where a bonded device could enter BONDING and BONDED states again.
Sharvil Nanavati [Wed, 6 Jan 2016 00:23:02 +0000 (16:23 -0800)]
Fix bug where a bonded device could enter BONDING and BONDED states again.

The following sequence of events was observed:
- start bonding with device A
- bond state for A goes from 10 -> 11 -> 12
- everyone's happy
- start bonding with device B
- bond state for B goes from 10 -> 11
- bond state for A goes from 12 -> 11 -> 12

The bond state for A should not have been changed in the last step
since it was not participating in any bonding procedure at the time.

The above sequence can be reproduced if a device D bonds with
A and takes on the slave role and then D bonds with B and switches
to a master role. When D performs the role switch, it receives an
updated link key from A.

Since the link key update procedure is tied in with the pairing flow,
we see spurious bond state changes. This CL checks the pairing control
block to see if D is, in fact, pairing with A and if not, it skips the
bond state updates.

Bug: 25870383
Change-Id: Ic6ff548dbe4e960c965bdc9ef5c50a263b9b3b22

8 years agoBluetooth: Remove std=c++11
Andreas Gampe [Wed, 6 Jan 2016 00:29:05 +0000 (16:29 -0800)]
Bluetooth: Remove std=c++11

It's the default now.

Change-Id: Ice463e6e74d56bffd00a80824721dbe57241ea06

8 years agoMerge "Bluetooth: Silence unused-parameter warning"
Andreas Gampe [Tue, 5 Jan 2016 22:10:20 +0000 (22:10 +0000)]
Merge "Bluetooth: Silence unused-parameter warning"

8 years agoBluetooth: Silence unused-parameter warning
Andreas Gampe [Tue, 5 Jan 2016 21:52:00 +0000 (13:52 -0800)]
Bluetooth: Silence unused-parameter warning

Silence these for now. Reduce build noise.

Change-Id: I787c31f60c8d24e3dd2bae8d1acaa7592b7e29ba

8 years agoMerge "Fix absolute volume reporting if AVRC_ADV_CTRL_INCLUDED is false"
Sharvil Nanavati [Tue, 5 Jan 2016 18:01:59 +0000 (18:01 +0000)]
Merge "Fix absolute volume reporting if AVRC_ADV_CTRL_INCLUDED is false"

8 years agoMerge "Fix crash in HFP client's +COPS parsing code."
Sharvil Nanavati [Tue, 5 Jan 2016 16:58:05 +0000 (16:58 +0000)]
Merge "Fix crash in HFP client's +COPS parsing code."

8 years agoFix absolute volume reporting if AVRC_ADV_CTRL_INCLUDED is false
Sharvil Nanavati [Thu, 17 Dec 2015 14:23:19 +0000 (06:23 -0800)]
Fix absolute volume reporting if AVRC_ADV_CTRL_INCLUDED is false

Without this change, setting AVRC_ADV_CTRL_INCLUDED to false would
result in the native code reporting the remote device supports
absolute volume even though we don't.

Bug: 26070064
Change-Id: I5b88fa0adb89983de28a216898a1d8957fa454a1

8 years agoFix crash in HFP client's +COPS parsing code.
Sharvil Nanavati [Tue, 5 Jan 2016 01:21:05 +0000 (17:21 -0800)]
Fix crash in HFP client's +COPS parsing code.

If the Audio Gateway sends a malformed +COPS message (an operator
name > 16 characters) then the %n in sscanf format specifier is
ignored and sscanf will not assign a value to the appropriate
argument.

In such a case, the existing code will perform pointer arithmetic
using an uninitialized stack variable as an offset which may result
in pointing to an invalid memory address. When that memory is
subsequently dereferenced, we observe a crash.

This change ensures that the stack does not crash even if an invalid
+COPS message is sent from the Audio Gateway.

Bug: 24871011
Change-Id: I9bb42c75bcd90487831fc6950c571c87098559e7

8 years agoOnly send first 16 characters of operator name in +COPS.
Sharvil Nanavati [Tue, 5 Jan 2016 01:15:18 +0000 (17:15 -0800)]
Only send first 16 characters of operator name in +COPS.

According to the HFP spec, the operator name is required to be at
most 16 characters long.

Bug: 24871011
Change-Id: I9987de57a327348fc2203b9502e9df446a87793f

8 years agoFix RFCOMM Rx speed of transfer
Hemant Gupta [Thu, 27 Aug 2015 05:18:07 +0000 (10:48 +0530)]
Fix RFCOMM Rx speed of transfer

Use Case:
1. OPP Rx use case on the DUT Side
2. Transfer 10Mb+ of file from remote to DUT
3. Observe speeds over RFCOMM (expected 1.5Mbps+)

Failure:
Actual speeds lesser than 1.5Mbps

Root Cause:
Rx bottlenecks seen due to frequent timer operation
during incoming data on RFCOMM

Fix:
BUSY and IDLE states of BT Power manager are already
handled inside the stack and no need to explicitly set
IDLE and BUSY states from JV layer anymore.

Bug: 22487461
Change-Id: Icdc25c52103d6a849cc6e12656d9c69f5e152b05

8 years agoFix flaky AlarmTest.test_set_long_*
Marie Janssen [Tue, 29 Dec 2015 23:34:55 +0000 (15:34 -0800)]
Fix flaky AlarmTest.test_set_long_*

The "long" tests need some leeway for the timer to be checked because
sometimes it takes ~1-2ms to check timers for wakelock scheduling.

Bug: 26140385
Change-Id: I362166f1d93a811f3933776294775b594226ab30

8 years agoUse GID "wakelock" to control access to kernel wakelock
Pavlin Radoslavov [Tue, 24 Nov 2015 01:16:29 +0000 (17:16 -0800)]
Use GID "wakelock" to control access to kernel wakelock

Bug: 25864142
Change-Id: I5103471b0ec28c26c18b891fc3be07c000067b4e

8 years agoMerge "net_test_bluetooth: Improve set/get name logic"
Andre Eisenbach [Wed, 23 Dec 2015 03:22:45 +0000 (03:22 +0000)]
Merge "net_test_bluetooth: Improve set/get name logic"

8 years agoFix BT connection failures
Devin Kim [Thu, 3 Dec 2015 21:19:20 +0000 (13:19 -0800)]
Fix BT connection failures

When HFP connection failed establishing between phone and watch, it can't
recover RFCOMM status which causes that HFP connection will not be made
unless BT radio goes off and comes back on. RFCOMM and HFP both trying to
open RFCOMM control channel at nearly same time, at some point, there's
a possibility that SABM packet didn't reach out to BT controller to connect
to phone from watch with HFP while phone tries to connect to watch with
AW RFCOMM.

This will take care of pending SABM packet to reach out to controller
properly so that RFCOMM status will not be messed.

Bug: 24285000
Bug: 25579482
Bug: 25579423
Bug: 25578997
Change-Id: Icc26b86c644ebd8d1c12a2fb4e94d04ba16cc2dd

8 years agoRemove "block" parameter from eager_reader_read()
Andre Eisenbach [Fri, 20 Nov 2015 22:07:24 +0000 (14:07 -0800)]
Remove "block" parameter from eager_reader_read()

Setting this parameter to true did not work and did not behave as
expected. The functionality provided by this parameter is also not
necessary, thus removing code.

Change-Id: I29e60da4adf1d1fc84d8ec9a590de89e94bb7900

8 years agoProperly reset NONBLOCK flag in semaphore_try_wait()
Andre Eisenbach [Wed, 23 Dec 2015 01:50:24 +0000 (17:50 -0800)]
Properly reset NONBLOCK flag in semaphore_try_wait()

Without this fix, calling semaphore_try_wait() on a semaphore that
wasn't currently set, would leave the NONBLOCK flag on the file
descriptor as a side-effect.

Also added a unit test for semaphores, including a test specifically for
this condition.

Change-Id: I0ea37bb68b14c76febaab25b3aee1bb4f5acee8c

8 years agonet_test_bluetooth: Improve set/get name logic
Ajay Panicker [Tue, 22 Dec 2015 21:09:48 +0000 (13:09 -0800)]
net_test_bluetooth: Improve set/get name logic

Without this CL semaphore_wait would instantly return due to the fact
that enabling the adapter would cause the properties callback to post
immediatly. Also prevented the test from returning a false positive if the
original device name was the same as the test name.

Change-Id: I987efcb9a5ef58209d37d2fc21f3c149fb3e556c

8 years agoBlacklist devices for absolute volume control
Andre Eisenbach [Fri, 11 Dec 2015 20:32:21 +0000 (12:32 -0800)]
Blacklist devices for absolute volume control

Some devices do not play well with absolute volume control. They either
play back music at unacceptably loud volume levels or provide
insufficiently granular volume control where a single "step" of volume
change results in unexpectedly large jumps in volume.

Bug: 2607006426060431
Change-Id: I5a336fba87119325b47a5ad385e9c48a631f2121

8 years agonet_test_bluetooth: fix set and get name tests
Ajay Panicker [Mon, 21 Dec 2015 23:05:10 +0000 (15:05 -0800)]
net_test_bluetooth: fix set and get name tests

Fixed the get and set name tests so that they are more consistent and robust.

Change-Id: I4b76357eff05531c4e52cd6de03eb3b8b969062b

8 years agoMerge "Remove dependency on base::Hash"
Christopher Wiley [Mon, 21 Dec 2015 15:50:16 +0000 (15:50 +0000)]
Merge "Remove dependency on base::Hash"

8 years agoRemove dependency on base::Hash
Christopher Wiley [Fri, 18 Dec 2015 23:57:36 +0000 (15:57 -0800)]
Remove dependency on base::Hash

This function is changing to just use std::hash anyway.  This is
slightly less efficient because of the copies, but doing it inline
makes the cost more explicit to bluetooth authors.

Bug: 26253162
Change-Id: I940ea8ce8aa27808cef8a8b9398a7756db3b5ca3
Test: Compiles

8 years agoFix memory leak in vendor layer
Marie Janssen [Fri, 18 Dec 2015 19:07:08 +0000 (11:07 -0800)]
Fix memory leak in vendor layer

When the vendor library transmits without giving a callback, the vendor
translation receives a buffer it's in charge of deallocating.

When there is a callback, it's the vendor library's job to deallocate
it.

Change-Id: I65b0a037b28103ba46a33a1baea942f7e724eb7c

8 years agoRemove repeated code in HF BTIF init function.
yanlaijun [Thu, 17 Dec 2015 01:53:54 +0000 (09:53 +0800)]
Remove repeated code in HF BTIF init function.

Change-Id: I25a07e9cdb29ef31696a156c6f7ff5b57f4f5cfb
Signed-off-by: yanlaijun <yan.laijun@gmail.com>
8 years agoBluetooth: Silence warnings
Andreas Gampe [Wed, 16 Dec 2015 18:53:07 +0000 (10:53 -0800)]
Bluetooth: Silence warnings

Silence unused-parameters warnings coming from libchrome.

Bug: 26228533
Change-Id: I08bc474c905cd2cf7b1c0492ee37187c499ddf52

8 years agonet_test_bluetooth: GATT test refactor
Ajay Panicker [Mon, 7 Dec 2015 22:15:33 +0000 (14:15 -0800)]
net_test_bluetooth: GATT test refactor

Properly integrating the GATT tests in net_test_bluetooth to utilize GUnit
correctly. Contains all the GATT tests and the base class the GATT tests use.
Also reorganized the files.

Bug: 25793348
Change-Id: I5a547a2528c20d6baa9b1fb6d0b956f718d736cc

8 years agotest: Add bluetoothtbd_test and net_test_bluetooth to runner
Scott James Remnant [Wed, 11 Nov 2015 20:41:08 +0000 (12:41 -0800)]
test: Add bluetoothtbd_test and net_test_bluetooth to runner

Change-Id: Iee7365cc366793d3f88cd8b9a6be454c5b853863

8 years agoservice: Add global scan support getters
Arman Uguray [Tue, 17 Nov 2015 21:29:55 +0000 (13:29 -0800)]
service: Add global scan support getters

Added a mutex that protects the local_le_features structure inside
Adapter. Added the following functions related to scan support:

  - Adapter::GetTotalNumberOfTrackableAdvertisements
  - Adapter::IsOffloadedFilteringSupported
  - Adapter::IsOffloadedScanBatchingSupported

Bug: 25744656
Change-Id: Id4d63486d1c51f2eddbd095a0a3ef6e6bb80c529

8 years agoservice: Add scan structures
Arman Uguray [Tue, 17 Nov 2015 21:11:03 +0000 (13:11 -0800)]
service: Add scan structures

Added the ScanFilter, ScanSettings, ScanResult structures that are
used in the BLE scan API.

Bug: 25744656
Change-Id: Id1bb28e7ebe85fd40013876aa097e1d0f0a4e471

8 years agoservice: Add connection state tracking to Adapter
Arman Uguray [Fri, 13 Nov 2015 23:05:48 +0000 (15:05 -0800)]
service: Add connection state tracking to Adapter

Added the IsDeviceConnected method to Adapter and also an
Observer method that other components can use to track the ACL
state between the local adapter and a remote device.

Bug: 25157450
Change-Id: If9bc25ab58b4a9b5430753405fb64834c0946050

8 years agoMerge "Rename libchrome-host to libchrome."
Alex Deymo [Thu, 10 Dec 2015 22:18:34 +0000 (22:18 +0000)]
Merge "Rename libchrome-host to libchrome."

8 years agoClean up A2D_ParsSbcInfo indentation
Ian Coolidge [Fri, 4 Dec 2015 22:15:03 +0000 (14:15 -0800)]
Clean up A2D_ParsSbcInfo indentation

This should introduce no change in behavior.

Change-Id: I14faa73d898f69bd15aff7c3857c671ebe1628c9

8 years agoMerge "Fix p_info increment in A2D_ParsSbcInfo"
Pavlin Radoslavov [Thu, 10 Dec 2015 19:34:26 +0000 (19:34 +0000)]
Merge "Fix p_info increment in A2D_ParsSbcInfo"

8 years agoAdd default implementations for observer callbacks
Ajay Panicker [Thu, 10 Dec 2015 01:44:59 +0000 (17:44 -0800)]
Add default implementations for observer callbacks

Added defaults functions that do nothing for the bluetooth observers. Also
removed empty definition of the discovery callback in adapter. A little cleanup
was done too.

Change-Id: I93b6134f25e30e30cc2072cb4c99ce06aa781849

8 years agoFix the fixed_queue_try_remove_from_queue() internals
Pavlin Radoslavov [Sat, 14 Nov 2015 02:36:56 +0000 (18:36 -0800)]
Fix the fixed_queue_try_remove_from_queue() internals

Calling fixed_queue_try_remove_from_queue() should update
queue->dequeue_sem and queue->enqueue_sem as appropriate.

Also:
 * Removed function fixed_queue_init() because it is not used
 * Added fixed_queue_test.cpp unit tests for fixed_queue
 * Updated some of the fixed_queue API description

Bug: 25973053

Change-Id: I3a0931f34fed34a2d60f82904601ef4157ee8ff9

8 years agoRename libchrome-host to libchrome.
Alex Deymo [Thu, 10 Dec 2015 02:08:33 +0000 (18:08 -0800)]
Rename libchrome-host to libchrome.

Update the name of the libchrome-host library to the match the one used
in the target.

Bug: 24619596
TEST=make dist

Change-Id: I73e906a0683142cc7e43237d4c5fa20c27acc6cc

8 years agoFix crashes with lots of discovered LE devices
Marie Janssen [Wed, 9 Dec 2015 18:08:25 +0000 (10:08 -0800)]
Fix crashes with lots of discovered LE devices

When loads of devices are discovered a config file which is too large
can be written out, which causes the BT daemon to crash on startup.

This limits the number of config entries for unpaired devices which
are initialized, and prevents a large number from being saved to the
filesystem.

Bug: 26071376
Change-Id: I4a74094f57a82b17f94e99a819974b8bc8082184

8 years agoAdd discovery state callback to adapter
Ajay Panicker [Thu, 10 Dec 2015 01:05:11 +0000 (17:05 -0800)]
Add discovery state callback to adapter

Change-Id: Icb3afacc5a23603762f2b0c42244dc408b245dcc

8 years agoDisable bdtool compilation
Andre Eisenbach [Thu, 10 Dec 2015 01:03:27 +0000 (17:03 -0800)]
Disable bdtool compilation

For re-factoring purposes, the dependencies are broken. Need to
re-evaluate tool usage and port to new bluetoothtbd HAL layer if
necessary.

Change-Id: I27b2ad3d78c67a12c67d8db9f506f94888bea70f

8 years agonet_test_bluetooth: adapter test refactor
Ajay Panicker [Mon, 7 Dec 2015 22:12:13 +0000 (14:12 -0800)]
net_test_bluetooth: adapter test refactor

Properly integrating net_test_bluetooth to utilize GUnit correctly.
Contains all the adapter tests and base class that all the other tests
utilize. Also removed all the old test code.

Bug: 25793348
Change-Id: Ie05d54e9d21f01e2d717bb79d187d7f0ff8a83f1

8 years agoosi: Remove error_fclose goto and redundant fflush.
Alain Vongsouvanh [Wed, 9 Dec 2015 16:57:38 +0000 (08:57 -0800)]
osi: Remove error_fclose goto and redundant fflush.

Change-Id: I327f9ce696bb68eb3b89b4a8b15dba189e027970

8 years agoFix the calculation of bta_sys_get_remaining_ticks
VenkatRaghavan V [Wed, 9 Dec 2015 11:47:13 +0000 (17:17 +0530)]
Fix the calculation of bta_sys_get_remaining_ticks

Previously, bta_sys_get_remaining_ticks() calculated the remaining
ticks for all the items in the hash map, which is incorrect.
Instead, we need to calculate the remaining ticks only for the queried
item.

Bug: 26110234

Change-Id: Ia867c1d0da15809a643b946f7d8b9143e3882935

8 years agoAdded visibility to the UIPC_Read() errors
Pavlin Radoslavov [Tue, 8 Dec 2015 01:47:08 +0000 (17:47 -0800)]
Added visibility to the UIPC_Read() errors

Changed some of the BTIF_TRACE_EVENT() log messages
to BTIF_TRACE_WARNING() so we can get better visibility into the
UIPC_Read() errors.

Also, removed UIPC_ReadBuf() and UIPC_SendBuf(), because they are
not implemented / used.

Change-Id: Iccc6a4d73dfe3c3e57f21c538891d7cb429f11ac

8 years agoFix net_test_hci unit tests
Pavlin Radoslavov [Mon, 7 Dec 2015 23:33:46 +0000 (23:33 +0000)]
Fix net_test_hci unit tests
am: c3caf784c7

* commit 'c3caf784c788af45fd6b657a09f4034b9d3387ba':
  Fix net_test_hci unit tests

8 years agoOnly initiate codec negotiation if feature is supported
Chenjie Luo [Mon, 7 Dec 2015 23:14:11 +0000 (23:14 +0000)]
Only initiate codec negotiation if feature is supported
am: 1cb11bb9af

* commit '1cb11bb9af8c72437eaf364bd422715015e4534b':
  Only initiate codec negotiation if feature is supported

8 years agoUpdate features pages after LE Host Support change
Frédéric Dalleau [Mon, 7 Dec 2015 23:14:05 +0000 (23:14 +0000)]
Update features pages after LE Host Support change
am: ebc367a5a8

* commit 'ebc367a5a8c90f70fd39096a2e658826d17e94a0':
  Update features pages after LE Host Support change

8 years agoFix p_info increment in A2D_ParsSbcInfo
Ian Coolidge [Fri, 4 Dec 2015 22:11:22 +0000 (14:11 -0800)]
Fix p_info increment in A2D_ParsSbcInfo

This is supposed to adjust position in the passed buffer,
not adjust a value of the buffer.

It fixes A2DP sink pairing by not corrupting the codec mask.

Also add const qualification to the input buffer.

Change-Id: Ic83ba73e0ea90897c131b4c1417cb976903862ac

8 years agoFix net_test_hci unit tests
Pavlin Radoslavov [Fri, 4 Dec 2015 01:11:55 +0000 (17:11 -0800)]
Fix net_test_hci unit tests

* Added new function API to hci_layer: hci_layer_cleanup_interface()
  It can be used to cleanup after hci_layer_get_interface()
  or hci_layer_get_test_interface()
* Fixed the unit tests inside HciLayerTest by removing usage of
  allocation_tracker_reset() and adding hci_layer_cleanup_interface() .
  The former was used as a hack to bypass the internal memory allocation
  of hci_layer_get_test_interface(). The latter is used to properly
  cleanup such allocation.

Bug: 26014740
Change-Id: I498b996a931c59dd3b4258f1a5741cfa6d302e42

8 years agoOnly initiate codec negotiation if feature is supported
Chenjie Luo [Fri, 20 Nov 2015 19:18:42 +0000 (11:18 -0800)]
Only initiate codec negotiation if feature is supported

Bug: 25634250
Change-Id: I97330c853f6cf90673b4ff28c72645f9d1c8ff9d

8 years agoUpdate features pages after LE Host Support change
Frédéric Dalleau [Tue, 18 Aug 2015 10:23:12 +0000 (12:23 +0200)]
Update features pages after LE Host Support change

After "Write LE Host Support" command is sent, the number of supported features
pages increases. Make sure we have the correct number of pages because it will
be read later.

Change-Id: I23d57b2cc9e773e14b2ce30ccfa624ba433b191c
Signed-off-by: Frédéric Dalleau <frederic.dalleau@linux.intel.com>
Signed-off-by: Zhiquan Liu <zhiquan.liu@intel.com>