From: Chris Manton Date: Wed, 14 Oct 2020 15:32:33 +0000 (-0700) Subject: Use tHCI_STATUS throughout shim interface X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=9fa03e8e5f;p=android-x86%2Fsystem-bt.git Use tHCI_STATUS throughout shim interface Bug: 166280067 Tag: #refactor Test: act.py -tc BleCocTest Test: ble paired 2 phones Test: classic paired Bose SoundLink Change-Id: Ia6b600dbe0a8dbf99b1e97d6776a5dfe7f48248f --- diff --git a/main/shim/acl.cc b/main/shim/acl.cc index 4732676a5..c8d3e4049 100644 --- a/main/shim/acl.cc +++ b/main/shim/acl.cc @@ -180,7 +180,7 @@ class ClassicShimAclConnection void OnDisconnection(hci::ErrorCode reason) override { btm_sec_disconnected(connection_->GetHandle(), - static_cast(reason)); + static_cast(reason)); } void OnReadRemoteVersionInformationComplete(uint8_t lmp_version, @@ -351,7 +351,7 @@ void bluetooth::shim::legacy::Acl::OnLeConnectFail( uint16_t handle{0}; /* TODO Unneeded */ bool enhanced{true}; /* TODO logging metrics only */ - uint8_t status = ToLegacyHciErrorCode(reason); + tHCI_STATUS status = ToLegacyHciErrorCode(reason); acl_ble_connection_fail(legacy_address_with_type, handle, enhanced, status); } diff --git a/main/shim/acl_legacy_interface.h b/main/shim/acl_legacy_interface.h index f288e08b7..bb3eda7d7 100644 --- a/main/shim/acl_legacy_interface.h +++ b/main/shim/acl_legacy_interface.h @@ -18,6 +18,7 @@ #include #include "stack/include/bt_types.h" +#include "stack/include/hci_error_code.h" #include "types/raw_address.h" namespace bluetooth { @@ -25,11 +26,11 @@ namespace shim { namespace legacy { typedef struct { - void (*on_connected)(const RawAddress& bda, uint16_t handle, uint8_t status, - uint8_t enc_mode); - void (*on_failed)(const RawAddress& bda, uint16_t handle, uint8_t status, + void (*on_connected)(const RawAddress& bda, uint16_t handle, + tHCI_STATUS status, uint8_t enc_mode); + void (*on_failed)(const RawAddress& bda, uint16_t handle, tHCI_STATUS status, uint8_t enc_mode); - void (*on_disconnected)(uint16_t handle, uint8_t reason); + void (*on_disconnected)(uint16_t handle, tHCI_STATUS reason); } acl_classic_connection_interface_t; typedef struct { @@ -39,8 +40,8 @@ typedef struct { const RawAddress& local_rpa, const RawAddress& peer_rpa, uint8_t peer_addr_type); void (*on_failed)(const tBLE_BD_ADDR& address_with_type, uint16_t handle, - bool enhanced, uint8_t status); - void (*on_disconnected)(uint16_t handle, uint8_t reason); + bool enhanced, tHCI_STATUS status); + void (*on_disconnected)(uint16_t handle, tHCI_STATUS reason); } acl_le_connection_interface_t; typedef struct { @@ -77,7 +78,6 @@ typedef struct { void (*on_role_change)(uint8_t new_role); void (*on_role_discovery_complete)(uint8_t current_role); } acl_classic_link_interface_t; -; typedef struct { void (*on_connection_update)(uint16_t connection_interval, diff --git a/main/shim/helpers.h b/main/shim/helpers.h index 0f18073d2..e7601eb33 100644 --- a/main/shim/helpers.h +++ b/main/shim/helpers.h @@ -101,7 +101,7 @@ inline std::unique_ptr MakeUniquePacket( return payload; } -inline uint8_t ToLegacyHciErrorCode(hci::ErrorCode reason) { +inline tHCI_STATUS ToLegacyHciErrorCode(hci::ErrorCode reason) { switch (reason) { case hci::ErrorCode::SUCCESS: return HCI_SUCCESS; @@ -138,17 +138,17 @@ inline uint8_t ToLegacyHciErrorCode(hci::ErrorCode reason) { case hci::ErrorCode::CONNECTION_ACCEPT_TIMEOUT: return HCI_ERR_HOST_TIMEOUT; case hci::ErrorCode::UNSUPORTED_FEATURE_OR_PARAMETER_VALUE: - return static_cast( + return static_cast( hci::ErrorCode::UNSUPORTED_FEATURE_OR_PARAMETER_VALUE); case hci::ErrorCode::INVALID_HCI_COMMAND_PARAMETERS: return HCI_ERR_ILLEGAL_PARAMETER_FMT; case hci::ErrorCode::REMOTE_USER_TERMINATED_CONNECTION: return HCI_ERR_PEER_USER; case hci::ErrorCode::REMOTE_DEVICE_TERMINATED_CONNECTION_LOW_RESOURCES: - return static_cast( + return static_cast( hci::ErrorCode::REMOTE_DEVICE_TERMINATED_CONNECTION_LOW_RESOURCES); case hci::ErrorCode::REMOTE_DEVICE_TERMINATED_CONNECTION_POWER_OFF: - return static_cast( + return static_cast( hci::ErrorCode::REMOTE_DEVICE_TERMINATED_CONNECTION_POWER_OFF); case hci::ErrorCode::CONNECTION_TERMINATED_BY_LOCAL_HOST: return HCI_ERR_CONN_CAUSE_LOCAL_HOST; @@ -157,30 +157,31 @@ inline uint8_t ToLegacyHciErrorCode(hci::ErrorCode reason) { case hci::ErrorCode::PAIRING_NOT_ALLOWED: return HCI_ERR_PAIRING_NOT_ALLOWED; case hci::ErrorCode::UNKNOWN_LMP_PDU: - return static_cast(hci::ErrorCode::UNKNOWN_LMP_PDU); + return static_cast(hci::ErrorCode::UNKNOWN_LMP_PDU); case hci::ErrorCode::UNSUPPORTED_REMOTE_OR_LMP_FEATURE: return HCI_ERR_UNSUPPORTED_REM_FEATURE; case hci::ErrorCode::SCO_OFFSET_REJECTED: - return static_cast(hci::ErrorCode::SCO_OFFSET_REJECTED); + return static_cast(hci::ErrorCode::SCO_OFFSET_REJECTED); case hci::ErrorCode::SCO_INTERVAL_REJECTED: - return static_cast(hci::ErrorCode::SCO_INTERVAL_REJECTED); + return static_cast(hci::ErrorCode::SCO_INTERVAL_REJECTED); case hci::ErrorCode::SCO_AIR_MODE_REJECTED: - return static_cast(hci::ErrorCode::SCO_AIR_MODE_REJECTED); + return static_cast(hci::ErrorCode::SCO_AIR_MODE_REJECTED); case hci::ErrorCode::INVALID_LMP_OR_LL_PARAMETERS: - return static_cast(hci::ErrorCode::INVALID_LMP_OR_LL_PARAMETERS); + return static_cast( + hci::ErrorCode::INVALID_LMP_OR_LL_PARAMETERS); case hci::ErrorCode::UNSPECIFIED_ERROR: return HCI_ERR_UNSPECIFIED; case hci::ErrorCode::UNSUPPORTED_LMP_OR_LL_PARAMETER: - return static_cast( + return static_cast( hci::ErrorCode::UNSUPPORTED_LMP_OR_LL_PARAMETER); case hci::ErrorCode::ROLE_CHANGE_NOT_ALLOWED: - return static_cast(hci::ErrorCode::ROLE_CHANGE_NOT_ALLOWED); + return static_cast(hci::ErrorCode::ROLE_CHANGE_NOT_ALLOWED); case hci::ErrorCode::LINK_LAYER_COLLISION: return HCI_ERR_LMP_ERR_TRANS_COLLISION; case hci::ErrorCode::ENCRYPTION_MODE_NOT_ACCEPTABLE: return HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE; case hci::ErrorCode::CONTROLLER_BUSY: - return static_cast(hci::ErrorCode::CONTROLLER_BUSY); + return static_cast(hci::ErrorCode::CONTROLLER_BUSY); } } diff --git a/stack/acl/ble_acl.cc b/stack/acl/ble_acl.cc index a19e92aee..0ed840edb 100644 --- a/stack/acl/ble_acl.cc +++ b/stack/acl/ble_acl.cc @@ -107,7 +107,8 @@ void acl_ble_enhanced_connection_complete( } void acl_ble_connection_fail(const tBLE_BD_ADDR& address_with_type, - uint16_t handle, bool enhanced, uint8_t status) { + uint16_t handle, bool enhanced, + tHCI_STATUS status) { if (status != HCI_ERR_ADVERTISING_TIMEOUT) { btm_cb.ble_ctr_cb.set_connection_state_idle(); btm_ble_clear_topology_mask(BTM_BLE_STATE_INIT_BIT); diff --git a/stack/acl/btm_acl.cc b/stack/acl/btm_acl.cc index b730bab62..32972ed43 100644 --- a/stack/acl/btm_acl.cc +++ b/stack/acl/btm_acl.cc @@ -2761,8 +2761,8 @@ bool acl_set_peer_le_features_from_handle(uint16_t hci_handle, return true; } -void btm_acl_connected(const RawAddress& bda, uint16_t handle, uint8_t status, - uint8_t enc_mode) { +void btm_acl_connected(const RawAddress& bda, uint16_t handle, + tHCI_STATUS status, uint8_t enc_mode) { btm_sec_connected(bda, handle, status, enc_mode); btm_acl_set_paging(false); l2c_link_hci_conn_comp(status, handle, bda); diff --git a/stack/acl/btm_ble_connection_establishment.cc b/stack/acl/btm_ble_connection_establishment.cc index b08cb5e99..152ba1db9 100644 --- a/stack/acl/btm_ble_connection_establishment.cc +++ b/stack/acl/btm_ble_connection_establishment.cc @@ -190,7 +190,8 @@ void btm_ble_conn_complete(uint8_t* p, UNUSED_ATTR uint16_t evt_len, android::bluetooth::hci::STATUS_UNKNOWN); tBLE_BD_ADDR address_with_type{.bda = bda, .type = bda_type}; - acl_ble_connection_fail(address_with_type, handle, enhanced, status); + acl_ble_connection_fail(address_with_type, handle, enhanced, + static_cast(status)); } } diff --git a/stack/btm/btm_sec.cc b/stack/btm/btm_sec.cc index e0b829686..807179cb4 100644 --- a/stack/btm/btm_sec.cc +++ b/stack/btm/btm_sec.cc @@ -3683,17 +3683,7 @@ tBTM_STATUS btm_sec_disconnect(uint16_t handle, uint8_t reason) { return (btm_sec_send_hci_disconnect(p_dev_rec, reason, handle)); } -/******************************************************************************* - * - * Function btm_sec_disconnected - * - * Description This function is when a connection to the peer device is - * dropped - * - * Returns void - * - ******************************************************************************/ -void btm_sec_disconnected(uint16_t handle, uint8_t reason) { +void btm_sec_disconnected(uint16_t handle, tHCI_STATUS reason) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev_by_handle(handle); uint8_t old_pairing_flags = btm_cb.pairing_flags; int result = HCI_ERR_AUTH_FAILURE; diff --git a/stack/btm/btm_sec.h b/stack/btm/btm_sec.h index 790649d33..3464d5d84 100644 --- a/stack/btm/btm_sec.h +++ b/stack/btm/btm_sec.h @@ -25,6 +25,7 @@ #include #include "stack/btm/security_device_record.h" #include "stack/include/btm_api_types.h" +#include "stack/include/hci_error_code.h" #define BTM_SEC_MAX_COLLISION_DELAY (5000) @@ -645,7 +646,7 @@ tBTM_STATUS btm_sec_disconnect(uint16_t handle, uint8_t reason); * Returns void * ******************************************************************************/ -void btm_sec_disconnected(uint16_t handle, uint8_t reason); +void btm_sec_disconnected(uint16_t handle, tHCI_STATUS reason); /** This function is called when a new connection link key is generated */ void btm_sec_link_key_notification(const RawAddress& p_bda, diff --git a/stack/btu/btu_hcif.cc b/stack/btu/btu_hcif.cc index beac8d376..5feb3f057 100644 --- a/stack/btu/btu_hcif.cc +++ b/stack/btu/btu_hcif.cc @@ -961,7 +961,7 @@ static void btu_hcif_connection_comp_evt(uint8_t* p, uint8_t evt_len) { } if (link_type == HCI_LINK_TYPE_ACL) { - btm_acl_connected(bda, handle, status, enc_mode); + btm_acl_connected(bda, handle, static_cast(status), enc_mode); } else { memset(&esco_data, 0, sizeof(tBTM_ESCO_DATA)); /* esco_data.link_type = HCI_LINK_TYPE_SCO; already zero */ @@ -1022,7 +1022,7 @@ static void btu_hcif_disconnection_comp_evt(uint8_t* p) { } /* Notify security manager */ - btm_sec_disconnected(handle, reason); + btm_sec_disconnected(handle, static_cast(reason)); } /******************************************************************************* @@ -1400,7 +1400,8 @@ static void btu_hcif_hdl_command_status(uint16_t opcode, uint8_t status, case HCI_CREATE_CONNECTION: if (status != HCI_SUCCESS) { STREAM_TO_BDADDR(bd_addr, p_cmd); - btm_acl_connected(bd_addr, HCI_INVALID_HANDLE, status, 0); + btm_acl_connected(bd_addr, HCI_INVALID_HANDLE, + static_cast(status), 0); } break; case HCI_AUTHENTICATION_REQUESTED: diff --git a/stack/include/acl_hci_link_interface.h b/stack/include/acl_hci_link_interface.h index 39d233679..76a986112 100644 --- a/stack/include/acl_hci_link_interface.h +++ b/stack/include/acl_hci_link_interface.h @@ -25,8 +25,8 @@ // This header contains functions for HCIF-Acl Management to invoke // void btm_acl_connection_request(const RawAddress& bda, uint8_t* dc); -void btm_acl_connected(const RawAddress& bda, uint16_t handle, uint8_t status, - uint8_t enc_mode); +void btm_acl_connected(const RawAddress& bda, uint16_t handle, + tHCI_STATUS status, uint8_t enc_mode); void btm_acl_encrypt_change(uint16_t handle, uint8_t status, uint8_t encr_enable); void btm_acl_paging(BT_HDR* p, const RawAddress& dest); diff --git a/stack/include/ble_acl_interface.h b/stack/include/ble_acl_interface.h index 948c6b89a..5c56c326a 100644 --- a/stack/include/ble_acl_interface.h +++ b/stack/include/ble_acl_interface.h @@ -29,4 +29,5 @@ void acl_ble_enhanced_connection_complete( uint16_t conn_timeout, const RawAddress& local_rpa, const RawAddress& peer_rpa, uint8_t peer_addr_type); void acl_ble_connection_fail(const tBLE_BD_ADDR& address_with_type, - uint16_t handle, bool enhanced, uint8_t status); + uint16_t handle, bool enhanced, + tHCI_STATUS status); diff --git a/stack/include/sec_hci_link_interface.h b/stack/include/sec_hci_link_interface.h index f2392fd6c..786abc25f 100644 --- a/stack/include/sec_hci_link_interface.h +++ b/stack/include/sec_hci_link_interface.h @@ -35,7 +35,7 @@ void btm_read_inq_tx_power_complete(uint8_t* p); void btm_read_local_oob_complete(uint8_t* p); void btm_rem_oob_req(uint8_t* p); void btm_sec_auth_complete(uint16_t handle, uint8_t status); -void btm_sec_disconnected(uint16_t handle, uint8_t reason); +void btm_sec_disconnected(uint16_t handle, tHCI_STATUS reason); void btm_sec_encrypt_change(uint16_t handle, uint8_t status, uint8_t encr_enable); void btm_sec_link_key_notification(const RawAddress& p_bda,