History log of /system/bt/bta/sys/bta_sys.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
ed424de5bfff3ba318af64828f291e6e9ff74b3a 30-Apr-2018 Pavlin Radoslavov <pavlin@google.com> Fix A2DP Suspend related multi-component deadlock

Apparently, the processing of A2DP Suspend from the Audio HAL
could result in a deadlock across multiple components:
A2dpService -> AudioService -> Audio-BT HAL -> BT Native Stack ->
BT JNI upcall -> A2dpService

1) A2dpService -> AudioService:
- Waiting inside setActiveDevice() -> synchronized (mStateMachines) ->
mAudioManager.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent()
- The mAudioManager call can be blocking: a followup call would wait
for the previous call to complete.
2) AudioService -> Audio-BT HAL
The AudioService is wating on the Audio-BT HAL to complete its request.
In this case the request is SUSPEND
3) Audio-BT HAL -> BT Native Stack
The Audio side of the Audio-BT HAL is waiting for the BT Native stack
to ACK the SUSPEND command.
More specifically, it is retrying few times with timeout of 250ms
each iteration.

4) BT Native Stack -> BT JNI upcall
- In the BT Native Stack the BtifAv FSM (see file btif/src/btif_av.cc)
is in state StateStarted and has received the
BTIF_AV_SUSPEND_STREAM_REQ_EVT because of the SUSPEND command from the
Audio HAL.
- As a result, the LocalSuspendPending flag has been set:
peer_.SetFlags(BtifAvPeer::kFlagLocalSuspendPending);
- Only after the above flag is reset, then the BT Native Stack will
ACK the SUSPEND command from the HAL
- The above flag will be reset when event BTA_AV_SUSPEND_EVT is received
from the underlying stack
- The BtifAv state machine has received the BTA_AV_SUSPEND_EVT event.
However, prior to clearing the pending status, the FSM tries to
report the audio state via JNI to the Java layer:
btif_report_audio_state();
...
peer_.ClearFlags(BtifAvPeer::kFlagLocalSuspendPending);
- Apparently, all the processing inside the BtifAv FSM is done on
the JNI thread, including the btif_report_audio_state() upcall.
5) BT JNI upcall -> A2dpService
- The btif_report_audio_state() upcall calls indirectly
A2dpNativeInterface.onAudioStateChanged() -> sendMessageToService() ->
A2dpService.messageFromNative()
- Within the A2dpService.messageFromNative() processing, there is
"synchronized (mStateMachines) {}" block, and the processing there
blocks because per (1) above A2dpService.setActiveDevice() is
already inside its own "synchronized (mStateMachines) {}" block

The above deadlock is fixed by the following:
- Modified the BTA_AV_SUSPEND_EVT processing such that
the clearing of the kFlagLocalSuspendPending flag is done BEFORE
the btif_report_audio_state()
- Modified the BtifAv FSM such that the internal processing of the FSM
events is done on the BTA thread instead of the JNI thread. Thus,
the FSM processing cannot be blocked by JNI upcalls.

Also:
- Updated the do_in_bta_thread() function to have a return value
so it is more aligned with the corresponding do_in_jni_thread()
implementation
- Updated the reordering of some other btif_report_*() upcalls inside
btif_av.cc so they are after the FSM internal processing in the
current state.
- Added few extra logs to the Audio-BT HAL (file audio_a2dp_hw.cc).

Bug: 72823323
Test: Disconnect/reconnect with Philips SBH7000 Headset
Change-Id: I7ccb558e458a8e90d0414f94463bda8d4b3fdc97
Merged-In: I7ccb558e458a8e90d0414f94463bda8d4b3fdc97
(cherry picked from commit 2a3b9b597ee07f8728bd9903b0bc104c4e24fd6c)
/system/bt/bta/sys/bta_sys.h
354a900914a6420d49992dc4f5442b0c857c1e0c 15-Feb-2018 Guang Xie <gregxie@google.com> Enable HCI Sniff mode and disable subrating for A2DP

Enabling the HCI Sniff mode could help headsets to save power.

Note that subrating is disabled implicitly by NOT sending the
"Sent Sniff Subrating" HCI command to the BT controller,
and effectively using the default Sniff Subrating parameters.
The Headset shouldn't go into Subrating Mode to prevent
potential stuttering if the Headset chooses to use subrating
with the wrong parameters.

NOTE: This should affect only Pixel Buds.

Also:
- Added some extra log messages
- Minor cleanup (argument/variable renaming)

Bug: 74344711
Bug: 74361002
Test: Manual - audio streaming; examine btsnoop logs
Change-Id: Iec5086dba6f9003c21bcb41eddb3bc83ac7dddd1
Merged-In: Iec5086dba6f9003c21bcb41eddb3bc83ac7dddd1
(cherry picked from commit 1b548bb34a0bfc300b8aa03c271148141673922f)
/system/bt/bta/sys/bta_sys.h
0d4868040f8762476fa1b4c9b00ee6679479e7b2 23-Jan-2018 Jakub Pawlowski <jpawlowski@google.com> Get rid of BTA_SYS_DM - use do_in_bta_thread instead

Test: Bond, change device name, scan for classic devices
Change-Id: If8d95976c4bb9ee6f346682590285cfc9d163ff5
/system/bt/bta/sys/bta_sys.h
ca42b5faeefaaa3cf605bf4c57636612abbb7482 04-Dec-2017 Vishwath Mohan <vishwath@google.com> 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
/system/bt/bta/sys/bta_sys.h
5b790feeeb211c42bf78ca3ae9c26aa30e516765 18-Sep-2017 Jakub Pawlowski <jpawlowski@google.com> Make copyright headers consistent with Google template; remove "(C)"

Test: Comment changes only; still compiles...
Change-Id: Id699a8170112f06e4a2c9f2e0f0834d1817ace4e
/system/bt/bta/sys/bta_sys.h
7002c70525c66ca22cdc16e6bfeac90dc0ad2ff8 05-Jul-2017 Ajay Panicker <apanicke@google.com> Remove bta_closure in favor of posting messages to a message loop

Test: Sanity test with Bluetooth
Change-Id: Ifda27a3bd88d82f884c4d8af6383f1c692b69e85
/system/bt/bta/sys/bta_sys.h
a484a888196ddf8bcbf1ad3226d6451bc735a94b 25-Jun-2017 Jakub Pawlowski <jpawlowski@google.com> Rename bt_bdaddr_t into RawAddress (3/3)

Test: compilation test
Change-Id: I4571721a0c6165a66450ee157a53d8d15bfc45d0
/system/bt/bta/sys/bta_sys.h
c752e135d66f80c0b2efc35292ab8ddfd8227d61 16-Jun-2017 Jakub Pawlowski <jpawlowski@google.com> Replace BT_ADDR with bd_addr_t in bta_sys related code

Test: compilation test
Change-Id: Idab6e9c03621c5540b4a3a7fa537dff71a25ce3f
/system/bt/bta/sys/bta_sys.h
ad1e23d50e431fb82ff1b8d3ce02f64ca0c5a940 10-Dec-2016 Jack He <siyuanh@google.com> Remove extern "C" from header files

Since change 290046, most files in system/bt is compiled as C++ source.
Therefore, there is no longer a need for the extern "C" wrapper around
includes that export symbols from those sources.

The following python script is applied to each file in the directory:

front = '#ifdef\s+__cplusplus\s+extern\s+"C"\s+{\s+#endif\s+'
back = '#ifdef\s+__cplusplus\s+}\s+#endif'
with open(sys.argv[1], "r") as f:
data = f.read()
data = re.sub(front, "", data)
data = re.sub(back, "", data)
print data

through a shell script:

for file in $(find . -name "*.h"); do
python remove_cpp_extern_c.py $file > tmp
cat tmp > $file
rm tmp
done

with following files not edited:
* stack/include/a2dp_*
* include/bt_trace.h
* embdrv/sbc/*

Bug: 33492510
Test: Code compilation, BtFunhausMetricsTest, BtStressTest
Change-Id: Iac21cdfb1924b50478dd0b82326e092602cbc9d4
/system/bt/bta/sys/bta_sys.h
cd1fd07f1306e08fe048682dd5918987e579f937 09-Nov-2016 Myles Watson <mylesgw@google.com> bta: Apply clang-format

clang-format -i --style=file bta/*/*

(twice)

Test: mma -j32
Change-Id: Ib118b1dfb6a34f9a5bfe153d65841e9041165264
/system/bt/bta/sys/bta_sys.h
8af480e24549ba51a3f6858d9d9af504715e0bea 09-Nov-2016 Myles Watson <mylesgw@google.com> bta: Remove double asterisks in comments

Double asterisks at the beginning of the line
sed -i s,"^[*][*]"," *", bta/*/*

Double asterisks after a space
sed -i s,"^ [*][*]\([^*]\)"," *\1", bta/*/*
sed -i s,"^ [*][*]$"," *", bta/*/*

Test: mma -j32
Change-Id: Ib83b802c7000176683b4e7f24d1255b3c2c6c01c
/system/bt/bta/sys/bta_sys.h
b2a292b5d8df2f359c38b0787bc01181225a9bc9 15-Oct-2016 Pavlin Radoslavov <pavlin@google.com> 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
/system/bt/bta/sys/bta_sys.h
e5c78954fb37f7e9a1d66387ebdb3848f04b1082 10-Aug-2016 Jakub Pawlowski <jpawlowski@google.com> Make it possible to post closures to BTA message queue

Currently, every task executed on bta thread needs a separate event id,
structure holding its parameters, API method, and method that will be
executed in bta thread, which must accept generic tBTA_DM_MSG.

Because of that we end up with lots of boilerplate code, and possibility
to misinterpret bytes in tBTA_DM_MSG struct.

After this patch, we can post closures onto bta thread. Thanks to it we
don't need a struct to hold parameters, and the executed method can have
a meaningful parameters.

First experiments showed over 50% reduction in code size when rewriting
advertising code to new style, not to mention much better readability.

Bug: 30622771
Change-Id: I400839b920c04c67c893899969d07a02d9c1b2e6
/system/bt/bta/sys/bta_sys.h
e9e58ced195ec2c983c7723c9cbdabd45eb0f2fd 17-Jun-2016 Marie Janssen <jamuraa@google.com> bta: use standard types

Use standard types everywhere.
Use standard style for #if statements:
- #if (VAR_NAME == TRUE)
- #if (VAR_NAME1 == TRUE && VAR_NAME2 == TRUE)
Use __func__ instead of __FUNCTION__
Fix some debug statements to use __func__

Change-Id: Ib86de4de9f14529ecaa4f71597260e3b5785360b
/system/bt/bta/sys/bta_sys.h
3d6accfcc0bdc5c7a8713320c9bb069cbf253348 11-May-2016 Bryce Lee <brycelee@google.com> Move extern "C" to top of headers and remove tBTA_HF_CLIENT_HDR.

Previously, extern "C" was placed in various locations within the header
files, sometimes below actual struct declarations. Doing so would lead to
alignment issues between C and C++ code.

tBTA_HF_CLIENT_HDR was removed from bta_hf_client_api since it was
extraneous and empty - leading to alignment issues.

Change-Id: Icdd338f1affe4c3a70c7bbd716249be6a16443d2
/system/bt/bta/sys/bta_sys.h
bea31308930f20aac1f7422f262e509e9f51f084 14-Mar-2016 Pavlin Radoslavov <pavlin@google.com> Removed unused function bta_sys_vs_hdl()

Change-Id: Iaf199d418aafc0b518df2f7febfa1c9e29f1fa42
/system/bt/bta/sys/bta_sys.h
78bcff79e1b1f0efce436b33bdd6da88745bfc8a 05-Dec-2015 Pavlin Radoslavov <pavlin@google.com> 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
/system/bt/bta/sys/bta_sys.h
258c2538e3b62a8cdb403f2730c45d721e5292b4 28-Sep-2015 Pavlin Radoslavov <pavlin@google.com> GKI cleanup - moved GKI buffer allocation wrappers to OSI

* Moved the following GKI buffer allocation functions to OSI:
- GKI_getbuf() -> osi_getbuf()
- GKI_freebuf() -> osi_freebuf()
- GKI_get_buf_size() -> osi_get_buf_size()

For now we need the osi_getbuf() / osi_freebuf() allocation wrapper,
because we need to be able to call osi_get_buf_size() on the allocated
buffer.
In the future those should be replaced with osi_malloc() / osi_free().
Currently, the osi_malloc() buffer size internal allocation tracker
does not always track the size, hence we need the osi_getbuf() wrapper.

* Replaced GKI_MAX_BUF_SIZE with BT_DEFAULT_BUFFER_SIZE

* Added new file include/bt_common.h that can be usee to include
few files that should be included alost everywhere (e.g. bt_target.h"
NOTE: This file might be removed in the future and we should include
everywhere the right set of header files.

* Removed some of the GKI-related references

* Removed file include/gki_target.h

Change-Id: Ie87830e73143de200746d54235aa99f228a95024
/system/bt/bta/sys/bta_sys.h
9f1c9ad85759c7663e3bbc494f8e75b2f107da67 28-Sep-2015 Pavlin Radoslavov <pavlin@google.com> GKI cleanup - Moved struct TIMER_LIST_ENT to OSI

* Moved struct TIMER_LIST_ENT to file osi/include/non_repeating_timer.h
and renamed it to timer_entry_t
NOTE: This is a short-term solution. timer_entry_t should be
removed, and its usage everywhere should be replaced by
struct non_repeating_timer_t .
* Renamed TIMER_CBACK to timer_callback_t
* Renamed TIMER_PARAM_TYPE to timer_param_t

Change-Id: I9ca830718bf900195f9c0a513a97f6995322693b
/system/bt/bta/sys/bta_sys.h
76356aee883af67898ddc1aa3b628195f396d42a 21-Apr-2015 VenkatRaghavan VijayaRaghavan <venkatrv@broadcom.com> Bug fix PM changes and LE connectivity mode fixes

Allow PM to support multiple delay timer for different profiles and
power mode requests. And set correct connectivity mode.

Bug: 22040710
Change-Id: Idabd9ea944f0c5a89ce542d85db9f103fa7d1816
/system/bt/bta/sys/bta_sys.h
8372aa5fa535ee4f09c09981b6125b54ace31fe2 25-Mar-2015 Kim Schulz <k.schulz@samsung.com> L2CAP and SDP Search API for BT profiles (2/2)

Added support for exposing L2CAP to Java such that OBEX over L2CAP
is made possible.

Added support to create SDP records as a seperate step.(as opposed to
creating a SDP record when a BluetoothSocket is created).
This allows both a RFCOMM channel and a L2CAP PSM to be included in a
SDP record. (Additionally the content of the SDP record is set by the
profile in Java, in stead of beeing hardcoded in the socket layer.)
This completes the L2CAP channel exposure to Java.

Change-Id: Iaf68a07d910145cdd33e940d73cd680f79164100
/system/bt/bta/sys/bta_sys.h
e13fbfafe2105d264357ac41133f0ac0e054429c 28-Dec-2014 Sharvil Nanavati <sharvil@google.com> Remove more GKI code.

This change removes all remaining GKI task remnants as well as
a few timer and buffer bits.
/system/bt/bta/sys/bta_sys.h
c0a87fe60f79ddf41595a30e75a77f43c19cd323 02-Mar-2015 Sharvil Nanavati <sharvil@google.com> Remove GKI timers
/system/bt/bta/sys/bta_sys.h
62d1538689b3594a150c84808642b3c7aef06046 02-Nov-2014 Zach Johnson <zachoverflow@google.com> Remove ptim and associated GKI timer functions
/system/bt/bta/sys/bta_sys.h
1e61ce1ae3fe8ef72443b30907f1cf8acae39674 24-Oct-2014 Chris Manton <cmanton@google.com> Remove always true definition BTM_EIR_SERVER_INCLUDED
/system/bt/bta/sys/bta_sys.h
24933b5b1a06274c47133debac5251a97128a267 25-Sep-2014 June R. Tate-Gans <jtgans@google.com> Removing unnecessary BTAPI #defines.
/system/bt/bta/sys/bta_sys.h
3ca27de478059136506cce747a17856f6470425a 18-Sep-2014 Sharvil Nanavati <sharvil@google.com> Fix timeout values for BTA system timers.

bta_sys_start_timer assumes a timeout value in GKI ticks but the
callers are passing in a timeout value in milliseconds. This change
updates the implementation to use units of milliseconds.
/system/bt/bta/sys/bta_sys.h
18023290406f076c5c76cdffdbf8ee081450a42f 29-Aug-2014 Chris Manton <cmanton@google.com> Replace timers and btu_task

Replace GKI timers with alarms.
/system/bt/bta/sys/bta_sys.h
19e25c91229b442dce1710a8b9bb91457bbf86dd 04-Sep-2014 Zach Johnson <zachoverflow@google.com> Remove FM/GPS/NFC related definitions
/system/bt/bta/sys/bta_sys.h
245876929944e9958d80db9f087008ce35f5f133 26-Aug-2014 Chris Manton <cmanton@google.com> Remove unnecessary layer of indirection
/system/bt/bta/sys/bta_sys.h
1a9247a1229aa65b3d1dce16426177bc5828e54d 05-Jun-2014 Satya Calloji <satyac@broadcom.com> LE ADV Filter changes

BTIF and stack layer changes for ADV filter feature

Change-Id: I865e57c41802751e172248547b8510598261ec94
/system/bt/bta/sys/bta_sys.h
b203d478f4835f5e35217874a1787e1914328f7c 21-Nov-2013 Andre Eisenbach <andre@broadcom.com> LE: Add controller based advertising filter API (2/2)

Change-Id: I444654bf19a048d5fcef33f79edbf1cdda3d3b62
/system/bt/bta/sys/bta_sys.h
5738f83aeb59361a0a2eda2460113f6dc9194271 13-Dec-2012 The Android Open Source Project <initial-contribution@android.com> Snapshot cdeccf6fdd8c2d494ea2867cb37a025bf8879baf

Change-Id: Ia2de32ccb97a9641462c72363b0a8c4288f4f36d
/system/bt/bta/sys/bta_sys.h