From 28ba0135cad0471c3e71634cf2d4e1bf19788eec Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Tue, 5 Jan 2021 10:20:53 -0800 Subject: [PATCH] hci_legacy_interface: Add Start/Cancel Inquiry Towards testable code Bug: 163134718 Tag: #refactor Test: gd/cert/run --host Change-Id: Ieb9aa232ccc29de4aec15b722ff7a105859a1ca4 --- stack/btm/btm_inq.cc | 9 +++++---- stack/hcic/hcicmds.cc | 8 +++++--- stack/include/hcimsgs.h | 7 +++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/stack/btm/btm_inq.cc b/stack/btm/btm_inq.cc index 9f44be822..83e26f2af 100644 --- a/stack/btm/btm_inq.cc +++ b/stack/btm/btm_inq.cc @@ -44,10 +44,10 @@ #include "btm_int.h" #include "btu.h" #include "hcidefs.h" -#include "hcimsgs.h" #include "main/shim/btm_api.h" #include "main/shim/shim.h" #include "stack/include/acl_api.h" +#include "stack/include/hcimsgs.h" #include "stack/include/inq_hci_link_interface.h" extern void btm_inq_remote_name_timer_timeout(void* data); @@ -443,7 +443,7 @@ void BTM_CancelInquiry(void) { p_inq->p_inq_cmpl_cb = NULL; /* Do not notify caller anymore */ if ((p_inq->inqparms.mode & BTM_BR_INQUIRY_MASK) != 0) { - btsnd_hcic_inq_cancel(); + bluetooth::legacy::hci::GetInterface().InquiryCancel(); } if ((p_inq->inqparms.mode & BTM_BLE_INQUIRY_MASK) != 0) btm_ble_stop_inquiry(); @@ -546,7 +546,8 @@ tBTM_STATUS BTM_StartInquiry(tBTM_INQ_RESULTS_CB* p_results_cb, p_inq->max_bd_entries = (uint16_t)(BT_DEFAULT_BUFFER_SIZE / sizeof(tINQ_BDADDR)); - btsnd_hcic_inquiry(general_inq_lap, p_inq->inqparms.duration, 0); + bluetooth::legacy::hci::GetInterface().StartInquiry( + general_inq_lap, p_inq->inqparms.duration, 0); return BTM_CMD_STARTED; } @@ -842,7 +843,7 @@ void btm_inq_stop_on_ssp(void) { if (btm_cb.btm_inq_vars.inq_active & normal_active) { /* can not call BTM_CancelInquiry() here. We need to report inquiry * complete evt */ - btsnd_hcic_inq_cancel(); + bluetooth::legacy::hci::GetInterface().InquiryCancel(); } } /* do not allow inquiry to start */ diff --git a/stack/hcic/hcicmds.cc b/stack/hcic/hcicmds.cc index 89cc14848..e207700b3 100644 --- a/stack/hcic/hcicmds.cc +++ b/stack/hcic/hcicmds.cc @@ -35,8 +35,8 @@ #include "btm_int.h" /* Included for UIPC_* macro definitions */ #include "stack/include/acl_hci_link_interface.h" -void btsnd_hcic_inquiry(const LAP inq_lap, uint8_t duration, - uint8_t response_cnt) { +static void btsnd_hcic_inquiry(const LAP inq_lap, uint8_t duration, + uint8_t response_cnt) { BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); uint8_t* pp = (uint8_t*)(p + 1); @@ -53,7 +53,7 @@ void btsnd_hcic_inquiry(const LAP inq_lap, uint8_t duration, btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); } -void btsnd_hcic_inq_cancel(void) { +static void btsnd_hcic_inq_cancel(void) { BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); uint8_t* pp = (uint8_t*)(p + 1); @@ -1432,6 +1432,8 @@ void btsnd_hcic_vendor_spec_cmd(void* buffer, uint16_t opcode, uint8_t len, } bluetooth::legacy::hci::Interface interface_ = { + .StartInquiry = btsnd_hcic_inquiry, // OCF 0x0001 + .InquiryCancel = btsnd_hcic_inq_cancel, // OCF 0x0002 .Disconnect = btsnd_hcic_disconnect, .StartRoleSwitch = btsnd_hcic_switch_role, }; diff --git a/stack/include/hcimsgs.h b/stack/include/hcimsgs.h index ea126df4f..a13f3c408 100644 --- a/stack/include/hcimsgs.h +++ b/stack/include/hcimsgs.h @@ -30,9 +30,6 @@ void bte_main_hci_send(BT_HDR* p_msg, uint16_t event); /* Message by message.... */ -extern void btsnd_hcic_inquiry(const LAP inq_lap, uint8_t duration, - uint8_t response_cnt); - #define HCIC_PARAM_SIZE_INQUIRY 5 #define HCIC_INQ_INQ_LAP_OFF 0 @@ -41,7 +38,6 @@ extern void btsnd_hcic_inquiry(const LAP inq_lap, uint8_t duration, /* Inquiry */ /* Inquiry Cancel */ -extern void btsnd_hcic_inq_cancel(void); #define HCIC_PARAM_SIZE_INQ_CANCEL 0 @@ -85,6 +81,9 @@ namespace bluetooth { namespace legacy { namespace hci { struct Interface { + void (*StartInquiry)(const LAP inq_lap, uint8_t duration, + uint8_t response_cnt); + void (*InquiryCancel)(); void (*Disconnect)(uint16_t handle, uint8_t reason); void (*StartRoleSwitch)(const RawAddress& bd_addr, uint8_t role); }; -- 2.11.0