diff --git a/system/stack/btm/btm_inq.cc b/system/stack/btm/btm_inq.cc index 55c52d6c07b1233a980d3d7e1bf1480cd1c82039..c0d4181fe48c73e46b8683bf0437c9ffe29daedc 100644 --- a/system/stack/btm/btm_inq.cc +++ b/system/stack/btm/btm_inq.cc @@ -42,6 +42,7 @@ #include "common/time_util.h" #include "device/include/controller.h" #include "hci/controller_interface.h" +#include "hci/event_checkers.h" #include "hci/hci_layer.h" #include "include/check.h" #include "internal_include/bt_target.h" @@ -251,6 +252,7 @@ void SendRemoteNameRequest(const RawAddress& raw_address) { btsnd_hcic_rmt_name_req(raw_address, HCI_PAGE_SCAN_REP_MODE_R1, HCI_MANDATARY_PAGE_SCAN_MODE, 0); } +static void btm_process_cancel_complete(tHCI_STATUS status, uint8_t mode); /******************************************************************************* * * Function BTM_SetDiscoverability @@ -554,7 +556,14 @@ void BTM_CancelInquiry(void) { btm_cb.btm_inq_vars.p_inq_cmpl_cb = NULL; /* Do not notify caller anymore */ if ((btm_cb.btm_inq_vars.inqparms.mode & BTM_BR_INQUIRY_MASK) != 0) { - bluetooth::legacy::hci::GetInterface().InquiryCancel(); + bluetooth::shim::GetHciLayer()->EnqueueCommand( + bluetooth::hci::InquiryCancelBuilder::Create(), + get_main_thread()->BindOnce( + [](bluetooth::hci::CommandCompleteView complete_view) { + bluetooth::hci::check_complete< + bluetooth::hci::InquiryCancelCompleteView>(complete_view); + btm_process_cancel_complete(HCI_SUCCESS, BTM_BR_INQUIRY_MASK); + })); } if (!bluetooth::shim::is_classic_discovery_only_enabled()) { @@ -1040,7 +1049,14 @@ 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 */ - bluetooth::legacy::hci::GetInterface().InquiryCancel(); + bluetooth::shim::GetHciLayer()->EnqueueCommand( + bluetooth::hci::InquiryCancelBuilder::Create(), + get_main_thread()->BindOnce( + [](bluetooth::hci::CommandCompleteView complete_view) { + bluetooth::hci::check_complete< + bluetooth::hci::InquiryCancelCompleteView>(complete_view); + btm_process_cancel_complete(HCI_SUCCESS, BTM_BR_INQUIRY_MASK); + })); } } /* do not allow inquiry to start */ @@ -1593,7 +1609,7 @@ void btm_process_inq_complete(tHCI_STATUS status, uint8_t mode) { * Returns void * ******************************************************************************/ -void btm_process_cancel_complete(tHCI_STATUS status, uint8_t mode) { +static void btm_process_cancel_complete(tHCI_STATUS status, uint8_t mode) { BTIF_dm_report_inquiry_status_change( tBTM_INQUIRY_STATE::BTM_INQUIRY_CANCELLED); btm_process_inq_complete(status, mode); diff --git a/system/stack/btu/btu_hcif.cc b/system/stack/btu/btu_hcif.cc index c411914e3edf315329109ffc01ebfea44a80082a..4d6a238ece64e6687ed2284d328b5005cf31b34e 100644 --- a/system/stack/btu/btu_hcif.cc +++ b/system/stack/btu/btu_hcif.cc @@ -970,10 +970,6 @@ static void btu_hcif_esco_connection_chg_evt(uint8_t* p) { static void btu_hcif_hdl_command_complete(uint16_t opcode, uint8_t* p, uint16_t evt_len) { switch (opcode) { - case HCI_INQUIRY_CANCEL: - /* Tell inquiry processing that we are done */ - btm_process_cancel_complete(HCI_SUCCESS, BTM_BR_INQUIRY_MASK); - break; case HCI_SET_EVENT_FILTER: break; diff --git a/system/stack/hcic/hcicmds.cc b/system/stack/hcic/hcicmds.cc index 74b1c1a520526000ab4b42ad55c9dab5252e363e..21c819dd59dfdf12e67609eff03478608cdcb7c5 100644 --- a/system/stack/hcic/hcicmds.cc +++ b/system/stack/hcic/hcicmds.cc @@ -48,10 +48,6 @@ #define HCIC_INQ_INQ_LAP_OFF 0 #define HCIC_INQ_DUR_OFF 3 #define HCIC_INQ_RSP_CNT_OFF 4 -/* Inquiry */ - -/* Inquiry Cancel */ -#define HCIC_PARAM_SIZE_INQ_CANCEL 0 /* Periodic Inquiry Mode */ #define HCIC_PARAM_SIZE_PER_INQ_MODE 9 @@ -482,18 +478,6 @@ #define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY 14 #define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY 3 -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); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_INQ_CANCEL; - p->offset = 0; - UINT16_TO_STREAM(pp, HCI_INQUIRY_CANCEL); - UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_INQ_CANCEL); - - btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); -} - static void btsnd_hcic_disconnect(uint16_t handle, uint8_t reason) { BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); uint8_t* pp = (uint8_t*)(p + 1); @@ -1672,7 +1656,6 @@ void btsnd_hcic_configure_data_path(hci_data_direction_t data_path_direction, namespace bluetooth::legacy::hci { class InterfaceImpl : public Interface { - void InquiryCancel() const override { btsnd_hcic_inq_cancel(); } void Disconnect(uint16_t handle, uint8_t reason) const override { btsnd_hcic_disconnect(handle, reason); } diff --git a/system/stack/include/acl_api.h b/system/stack/include/acl_api.h index 95d41a8adb1afdb9ea92c9a731ef67e8830c90d3..34d2d504a3736f6b411c2c48a0a6e1ef15429999 100644 --- a/system/stack/include/acl_api.h +++ b/system/stack/include/acl_api.h @@ -302,8 +302,6 @@ bool acl_peer_supports_ble_connection_subrating(const RawAddress& remote_bda); bool acl_peer_supports_ble_connection_subrating_host( const RawAddress& remote_bda); -void btm_process_cancel_complete(uint8_t status, uint8_t mode); - uint8_t btm_handle_to_acl_index(uint16_t hci_handle); tHCI_REASON btm_get_acl_disc_reason_code(void); diff --git a/system/stack/include/hcimsgs.h b/system/stack/include/hcimsgs.h index cbaabe8f38fb5bd5845896482218f8fa6945cf98..8713ccce985f82a8c6f768d70f5c4a4eb3069a95 100644 --- a/system/stack/include/hcimsgs.h +++ b/system/stack/include/hcimsgs.h @@ -43,7 +43,6 @@ enum hci_data_direction_t { namespace bluetooth::legacy::hci { class Interface { public: - virtual void InquiryCancel() const = 0; virtual void Disconnect(uint16_t handle, uint8_t reason) const = 0; virtual void ChangeConnectionPacketType(uint16_t handle, uint16_t packet_types) const = 0; diff --git a/system/stack/include/inq_hci_link_interface.h b/system/stack/include/inq_hci_link_interface.h index 5f712c399bba91672a98540e55ec9c96016c45a5..38638893b28d1d485d4b750001796f3b59b13de8 100644 --- a/system/stack/include/inq_hci_link_interface.h +++ b/system/stack/include/inq_hci_link_interface.h @@ -30,7 +30,6 @@ void btm_process_inq_results(const uint8_t* p, uint8_t hci_evt_len, uint8_t inq_res_mode); void btm_process_inq_complete(tHCI_STATUS status, uint8_t mode); -void btm_process_cancel_complete(tHCI_STATUS status, uint8_t mode); void btm_acl_process_sca_cmpl_pkt(uint8_t len, uint8_t* data); tINQ_DB_ENT* btm_inq_db_new(const RawAddress& p_bda, bool is_ble); diff --git a/system/stack/test/common/mock_hcic_layer.cc b/system/stack/test/common/mock_hcic_layer.cc index bb670a9107b7ceb6a166cb18c841619deeb1ab12..d885b9daa4c7e6b8d6c56a8036a680dacfeb0657 100644 --- a/system/stack/test/common/mock_hcic_layer.cc +++ b/system/stack/test/common/mock_hcic_layer.cc @@ -108,7 +108,6 @@ namespace bluetooth::legacy::hci { class MockInterface : public Interface { public: - virtual void InquiryCancel() const override { FAIL(); } virtual void Disconnect(uint16_t handle, uint8_t reason) const override { btsnd_hcic_disconnect(handle, reason); } diff --git a/system/test/mock/mock_legacy_hci_interface.h b/system/test/mock/mock_legacy_hci_interface.h index 2260d41f5319f8d6f214ed3e8685acbeb6620022..3ae95fa4291bd94d9225680bfe8b14aeb27426fe 100644 --- a/system/test/mock/mock_legacy_hci_interface.h +++ b/system/test/mock/mock_legacy_hci_interface.h @@ -23,7 +23,6 @@ namespace bluetooth::legacy::hci::testing { class MockInterface : public Interface { public: - MOCK_METHOD(void, InquiryCancel, (), (const)); MOCK_METHOD(void, Disconnect, (uint16_t handle, uint8_t reason), (const)); MOCK_METHOD(void, ChangeConnectionPacketType, (uint16_t handle, uint16_t packet_types), (const)); diff --git a/system/test/mock/mock_stack_btm_inq.cc b/system/test/mock/mock_stack_btm_inq.cc index 8ff677f2abd0a5e4e9c5b6e0e3f59faf9a3d216b..9fc34e8e542b92bf4b03e3dbdea1d6bca07c2965 100644 --- a/system/test/mock/mock_stack_btm_inq.cc +++ b/system/test/mock/mock_stack_btm_inq.cc @@ -69,7 +69,6 @@ struct btm_inq_find_bdaddr btm_inq_find_bdaddr; struct btm_inq_remote_name_timer_timeout btm_inq_remote_name_timer_timeout; struct btm_inq_rmt_name_failed_cancelled btm_inq_rmt_name_failed_cancelled; struct btm_inq_stop_on_ssp btm_inq_stop_on_ssp; -struct btm_process_cancel_complete btm_process_cancel_complete; struct btm_process_inq_complete btm_process_inq_complete; struct btm_process_inq_results btm_process_inq_results; struct btm_process_remote_name btm_process_remote_name; @@ -256,10 +255,6 @@ void btm_inq_stop_on_ssp(void) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_inq_stop_on_ssp(); } -void btm_process_cancel_complete(tHCI_STATUS status, uint8_t mode) { - inc_func_call_count(__func__); - test::mock::stack_btm_inq::btm_process_cancel_complete(status, mode); -} void btm_process_inq_complete(tHCI_STATUS status, uint8_t mode) { inc_func_call_count(__func__); test::mock::stack_btm_inq::btm_process_inq_complete(status, mode); diff --git a/system/test/mock/mock_stack_btm_inq.h b/system/test/mock/mock_stack_btm_inq.h index 7ac6d12b2030e988c16bb60f0b189211bdfb6968..ab805ab9751eab5fad11b50332d0bb0373f15a56 100644 --- a/system/test/mock/mock_stack_btm_inq.h +++ b/system/test/mock/mock_stack_btm_inq.h @@ -429,16 +429,6 @@ struct btm_inq_stop_on_ssp { }; extern struct btm_inq_stop_on_ssp btm_inq_stop_on_ssp; -// Name: btm_process_cancel_complete -// Params: tHCI_STATUS status, uint8_t mode -// Return: void -struct btm_process_cancel_complete { - std::function<void(tHCI_STATUS status, uint8_t mode)> body{ - [](tHCI_STATUS /* status */, uint8_t /* mode */) {}}; - void operator()(tHCI_STATUS status, uint8_t mode) { body(status, mode); }; -}; -extern struct btm_process_cancel_complete btm_process_cancel_complete; - // Name: btm_process_inq_complete // Params: tHCI_STATUS status, uint8_t mode // Return: void