OSDN Git Service

Refactor the Bluetooth timers
authorPavlin Radoslavov <pavlin@google.com>
Sat, 5 Dec 2015 01:36:34 +0000 (17:36 -0800)
committerPavlin Radoslavov <pavlin@google.com>
Fri, 22 Jan 2016 01:49:15 +0000 (17:49 -0800)
commit78bcff79e1b1f0efce436b33bdd6da88745bfc8a
treed6e4add2bd1c0322116052f0a719f1fd6e418917
parentd2e250824fca5c42b87b3b6f5fa19646ffa2d321
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
111 files changed:
bta/ag/bta_ag_act.c
bta/ag/bta_ag_cmd.c
bta/ag/bta_ag_int.h
bta/ag/bta_ag_main.c
bta/ag/bta_ag_sco.c
bta/av/bta_av_aact.c
bta/av/bta_av_act.c
bta/av/bta_av_int.h
bta/av/bta_av_main.c
bta/dm/bta_dm_act.c
bta/dm/bta_dm_api.c
bta/dm/bta_dm_int.h
bta/dm/bta_dm_pm.c
bta/hf_client/bta_hf_client_act.c
bta/hf_client/bta_hf_client_at.c
bta/hf_client/bta_hf_client_at.h
bta/hf_client/bta_hf_client_int.h
bta/hf_client/bta_hf_client_main.c
bta/include/bta_av_api.h
bta/sys/bta_sys.h
bta/sys/bta_sys_main.c
btif/include/btif_gatt_multi_adv_util.h
btif/include/btif_hh.h
btif/include/btif_hl.h
btif/src/bluetooth.c
btif/src/btif_av.c
btif/src/btif_config.c
btif/src/btif_gatt_client.c
btif/src/btif_gatt_multi_adv_util.c
btif/src/btif_hh.c
btif/src/btif_hl.c
btif/src/btif_media_task.c
btif/src/btif_rc.c
hci/src/hci_layer.c
hci/src/low_power_manager.c
include/bt_target.h
include/bt_trace.h
main/bte_logmsg.c
osi/Android.mk
osi/BUILD.gn
osi/include/alarm.h
osi/include/non_repeating_timer.h [deleted file]
osi/include/osi.h
osi/include/thread.h
osi/src/alarm.c
osi/src/non_repeating_timer.c [deleted file]
osi/test/alarm_test.cpp
stack/avdt/avdt_api.c
stack/avdt/avdt_ccb.c
stack/avdt/avdt_ccb_act.c
stack/avdt/avdt_int.h
stack/avdt/avdt_msg.c
stack/avdt/avdt_scb.c
stack/avdt/avdt_scb_act.c
stack/bnep/bnep_api.c
stack/bnep/bnep_int.h
stack/bnep/bnep_main.c
stack/bnep/bnep_utils.c
stack/btm/btm_acl.c
stack/btm/btm_ble_addr.c
stack/btm/btm_ble_gap.c
stack/btm/btm_ble_int.h
stack/btm/btm_ble_multi_adv.c
stack/btm/btm_devctl.c
stack/btm/btm_inq.c
stack/btm/btm_int.h
stack/btm/btm_main.c
stack/btm/btm_sec.c
stack/btu/btu_hcif.c
stack/btu/btu_init.c
stack/btu/btu_task.c
stack/gatt/gatt_api.c
stack/gatt/gatt_cl.c
stack/gatt/gatt_int.h
stack/gatt/gatt_main.c
stack/gatt/gatt_sr.c
stack/gatt/gatt_utils.c
stack/hid/hid_conn.h
stack/hid/hidh_api.c
stack/hid/hidh_conn.c
stack/hid/hidh_int.h
stack/include/bt_types.h
stack/include/btm_ble_api.h
stack/include/btu.h
stack/include/dyn_mem.h
stack/include/port_ext.h
stack/l2cap/l2c_api.c
stack/l2cap/l2c_ble.c
stack/l2cap/l2c_csm.c
stack/l2cap/l2c_fcr.c
stack/l2cap/l2c_int.h
stack/l2cap/l2c_link.c
stack/l2cap/l2c_main.c
stack/l2cap/l2c_ucd.c
stack/l2cap/l2c_utils.c
stack/mcap/mca_api.c
stack/mcap/mca_cact.c
stack/mcap/mca_csm.c
stack/mcap/mca_int.h
stack/rfcomm/port_int.h
stack/rfcomm/port_utils.c
stack/rfcomm/rfc_utils.c
stack/sdp/sdp_discovery.c
stack/sdp/sdp_main.c
stack/sdp/sdp_server.c
stack/sdp/sdp_utils.c
stack/sdp/sdpint.h
stack/smp/smp_api.c
stack/smp/smp_int.h
stack/smp/smp_l2c.c
stack/smp/smp_utils.c