OSDN Git Service

Use MessageLoopThread in A2DP source, JNI, BTA, HCI and module bring-up
authorJack He <siyuanh@google.com>
Thu, 26 Jul 2018 04:43:01 +0000 (21:43 -0700)
committerJack He <siyuanh@google.com>
Thu, 2 Aug 2018 17:57:48 +0000 (10:57 -0700)
commit6d110527c8363f244530ee8e10f85c325f2bcb0e
treea272c16ea19a8505968263819a91085f6f944c7a
parentc27d25789bc0e59f421ad432d8ccca39a16b0a63
Use MessageLoopThread in A2DP source, JNI, BTA, HCI and module bring-up

* Replace OSI thread with MessageLoopThread in
  - btif_a2dp_source (A2DP encoding thread)
  - btif_core (JNI thread)
  - btu_init (BTA thread)
  - hci_layer (HCI thread)
  - module (module bring up thread)
  - various unit test threads
* Code that uses reactor from OSI thread is not replaced in this change
  because they need to move from using reactor to message loop first
* Main difference:
  - HCI layer no longer has access to mutex protecting message loop
    set up and tear down. Messages posted to thread after ShutDown()
    is called become no-op
  - In all cases QuitClosure() is used instead of QuitWhenIdleClosure().
    This means that we will never force kill a thread. An infinite loop
    will delay the shutdown of Bluetooth stack.
* do_in_hci_thread is actually do_in_bta_thread
* Move the definition of do_in_bta_thread from bta to btu since btu is
  where the thread actually lives
* Remove bta_closure_api.h and replace it with stack/include/btu.h
* Remove header inclusion in bta_sys.h and include stack/include/btu.h
  in individual compilation units
* Fixed a bug in btif_cleanup_bluetooth where btif_jni_disassociate()
  was not called on the JNI thread
* Make setting real time priority a requirement
* Crash during the following scenario:
  - When btif_profile_queue cleanup failed to be scheduled on JNI thread
  - When A2DP encoder thread failed to gain real time priority
  - When BTA thread failed to start up
  - When BTA thread failed to gain real time priority
  - When BTA thread failed to schedule its first callback
* Turn off Bluetooth in the following scenario:
  - When HCI thread failed to gain real time priority
  - When bt_workqueue thread failed to gain real time priority

Bug: 110303473
Test: make, native and Java unit tests,
      Connect to headset and listen to music through A2DP,
      testplans/details/184455/3975
Change-Id: Ib448992fc0ba5af82c2d117dd65f1abd45d2acb6
48 files changed:
bta/ag/bta_ag_api.cc
bta/ag/bta_ag_rfc.cc
bta/ag/bta_ag_sco.cc
bta/ag/bta_ag_sdp.cc
bta/dm/bta_dm_api.cc
bta/dm/bta_dm_ci.cc
bta/dm/bta_dm_pm.cc
bta/gatt/bta_gattc_act.cc
bta/gatt/bta_gattc_api.cc
bta/gatt/bta_gatts_api.cc
bta/include/bta_closure_api.h [deleted file]
bta/jv/bta_jv_api.cc
bta/sys/bta_sys.h
bta/sys/bta_sys_main.cc
btcore/include/module.h
btcore/src/module.cc
btif/Android.bp
btif/avrcp/avrcp_service.cc
btif/include/btif_common.h
btif/src/btif_a2dp_audio_interface.cc
btif/src/btif_a2dp_source.cc
btif/src/btif_av.cc
btif/src/btif_ble_advertiser.cc
btif/src/btif_ble_scanner.cc
btif/src/btif_core.cc
btif/src/btif_dm.cc
btif/src/btif_gatt_client.cc
btif/src/btif_gatt_server.cc
btif/src/btif_hearing_aid.cc
btif/src/btif_pan.cc
btif/src/btif_profile_queue.cc
btif/src/btif_storage.cc
btif/src/stack_manager.cc
btif/test/btif_profile_queue_test.cc
hci/src/hci_layer.cc
main/Android.bp
main/bte_main.cc
osi/Android.bp
osi/test/alarm_test.cc
osi/test/future_test.cc
osi/test/semaphore_test.cc
stack/Android.bp
stack/btm/btm_devctl.cc
stack/btu/btu_hcif.cc
stack/btu/btu_init.cc
stack/btu/btu_task.cc
stack/include/btu.h
stack/test/stack_btu_test.cc