OSDN Git Service

Rework API btm_ble_select_adv_interval
authorChris Manton <cmanton@google.com>
Thu, 17 Sep 2020 18:00:47 +0000 (11:00 -0700)
committerChris Manton <cmanton@google.com>
Fri, 18 Sep 2020 17:50:47 +0000 (10:50 -0700)
Please Don't Pass Globals As Parameters

Towards readable code

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working
Test: act.py -tc BleCocTest

Change-Id: If1d5f80cf12250b063a2ebe525527b6ddf6bfabc

stack/btm/btm_ble_gap.cc

index f022425..99acc57 100644 (file)
@@ -830,9 +830,10 @@ uint16_t BTM_BleReadConnectability() {
  * Returns          void
  *
  ******************************************************************************/
-void btm_ble_select_adv_interval(tBTM_BLE_INQ_CB* p_cb, uint8_t evt_type,
-                                 uint16_t* p_adv_int_min,
-                                 uint16_t* p_adv_int_max) {
+static void btm_ble_select_adv_interval(uint8_t evt_type,
+                                        uint16_t* p_adv_int_min,
+                                        uint16_t* p_adv_int_max) {
+  tBTM_BLE_INQ_CB* p_cb = &btm_cb.ble_ctr_cb.inq_var;
   if (p_cb->adv_interval_min && p_cb->adv_interval_max) {
     *p_adv_int_min = p_cb->adv_interval_min;
     *p_adv_int_max = p_cb->adv_interval_max;
@@ -971,7 +972,7 @@ tBTM_STATUS btm_ble_set_discoverability(uint16_t combined_mode) {
       mode == BTM_BLE_NON_DISCOVERABLE)
     new_mode = BTM_BLE_ADV_DISABLE;
 
-  btm_ble_select_adv_interval(p_cb, evt_type, &adv_int_min, &adv_int_max);
+  btm_ble_select_adv_interval(evt_type, &adv_int_min, &adv_int_max);
 
   alarm_cancel(p_cb->fast_adv_timer);
 
@@ -1061,7 +1062,7 @@ tBTM_STATUS btm_ble_set_connectability(uint16_t combined_mode) {
       p_cb->discoverable_mode == BTM_BLE_NON_DISCOVERABLE)
     new_mode = BTM_BLE_ADV_DISABLE;
 
-  btm_ble_select_adv_interval(p_cb, evt_type, &adv_int_min, &adv_int_max);
+  btm_ble_select_adv_interval(evt_type, &adv_int_min, &adv_int_max);
 
   alarm_cancel(p_cb->fast_adv_timer);
   /* update adv params if needed */