Loading system/btif/src/btif_dm.cc +21 −13 Original line number Diff line number Diff line Loading @@ -293,18 +293,15 @@ static void btif_dm_data_free(uint16_t event, tBTA_DM_SEC* dm_sec) { void btif_dm_init(uid_set_t* set) { uid_set = set; if (bluetooth::shim::is_gd_shim_enabled()) { bluetooth::shim::BTIF_DM_SetUiCallback( [](RawAddress* bt_addr, bt_bdname_t* bd_name, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t pass_key) { bluetooth::shim::BTIF_DM_SetUiCallback([](RawAddress address, bt_bdname_t bd_name, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t pass_key) { do_in_jni_thread(FROM_HERE, base::BindOnce([](RawAddress address, bt_bdname_t bd_name, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t pass_key) { LOG(ERROR) << __func__ << ": UI Callback fired!"; // TODO(optedoblivion): Wire up HAL_CBACK // HAL_CBACK(bt_hal_cbacks, ssp_request_cb, &bd_addr, &bd_name, // cod, // (p_ssp_cfm_req->just_works ? BT_SSP_VARIANT_CONSENT // : // BT_SSP_VARIANT_PASSKEY_CONFIRMATION), // p_ssp_cfm_req->num_val); // //TODO: java BondStateMachine requires change into bonding state. If we ever send this event separately, consider removing this line HAL_CBACK(bt_hal_cbacks, bond_state_changed_cb, BT_STATUS_SUCCESS, &address, BT_BOND_STATE_BONDING); HAL_CBACK(bt_hal_cbacks, ssp_request_cb, &address, &bd_name, cod, pairing_variant, pass_key); }, address, bd_name, cod, pairing_variant, pass_key)); }); } } Loading Loading @@ -2424,6 +2421,17 @@ bt_status_t btif_dm_pin_reply(const RawAddress* bd_addr, uint8_t accept, bt_status_t btif_dm_ssp_reply(const RawAddress* bd_addr, bt_ssp_variant_t variant, uint8_t accept, UNUSED_ATTR uint32_t passkey) { if (bluetooth::shim::is_gd_shim_enabled()) { uint8_t tmp_dev_type = 0; uint8_t tmp_addr_type = 0; BTM_ReadDevInfo(*bd_addr, &tmp_dev_type, &tmp_addr_type); do_in_main_thread( FROM_HERE, base::Bind(&bluetooth::shim::BTIF_DM_ssp_reply, *bd_addr, tmp_addr_type, variant, accept)); } if (variant == BT_SSP_VARIANT_PASSKEY_ENTRY) { /* This is not implemented in the stack. * For devices with display, this is not needed Loading system/main/shim/btif_dm.cc +46 −35 Original line number Diff line number Diff line Loading @@ -15,10 +15,11 @@ */ #define LOG_TAG "bt_shim_btif_dm" #include "main/shim/btif_dm.h" #include "osi/include/log.h" #include "main/shim/btif_dm.h" #include "main/shim/entry.h" #include "osi/include/log.h" #include "main/shim/helpers.h" #include "security/security_module.h" #include "security/ui.h" Loading @@ -32,46 +33,44 @@ class ShimUi : public security::UI { ~ShimUi() {} void DisplayPairingPrompt(const bluetooth::hci::AddressWithType& address, std::string name) { LOG_WARN(LOG_TAG, "%s TODO Unimplemented", __func__); LOG_WARN(LOG_TAG, "%s ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ TODO Unimplemented", __func__); } void Cancel(const bluetooth::hci::AddressWithType& address) { LOG_WARN(LOG_TAG, "%s TODO Unimplemented", __func__); LOG_WARN(LOG_TAG, "%s ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ TODO Unimplemented", __func__); } void DisplayConfirmValue(const bluetooth::hci::AddressWithType& address, std::string name, uint32_t numeric_value) { LOG_WARN(LOG_TAG, "%s TODO Unimplemented", __func__); // TODO(optedoblivion): Remove and wire up to UI callback auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager(); security_manager->OnConfirmYesNo(address, true); // callback(address, name, 0, 0, 0); bt_bdname_t legacy_name{0}; memcpy(legacy_name.name, name.data(), name.length()); callback_(RawAddress(address.GetAddress().address), legacy_name, ((0x1F) << 8) /* COD_UNCLASSIFIED*/ , BT_SSP_VARIANT_PASSKEY_CONFIRMATION, numeric_value); } void DisplayYesNoDialog(const bluetooth::hci::AddressWithType& address, std::string name) { LOG_WARN(LOG_TAG, "%s TODO Unimplemented", __func__); // TODO(optedoblivion): Remove and wire up to UI callback auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager(); security_manager->OnConfirmYesNo(address, true); // callback(address, name, 0, 0, 0); bt_bdname_t legacy_name{0}; memcpy(legacy_name.name, name.data(), name.length()); callback_(RawAddress(address.GetAddress().address), legacy_name, ((0x1F) << 8) /* COD_UNCLASSIFIED*/ , BT_SSP_VARIANT_CONSENT, 0); } void DisplayEnterPasskeyDialog(const bluetooth::hci::AddressWithType& address, std::string name) { LOG_WARN(LOG_TAG, "%s TODO Unimplemented", __func__); void DisplayEnterPasskeyDialog(const bluetooth::hci::AddressWithType& address, std::string name) { bt_bdname_t legacy_name{0}; memcpy(legacy_name.name, name.data(), name.length()); callback_(RawAddress(address.GetAddress().address), legacy_name, ((0x1F) << 8) /* COD_UNCLASSIFIED*/ , BT_SSP_VARIANT_PASSKEY_ENTRY, 0); } void DisplayPasskey(const bluetooth::hci::AddressWithType& address, std::string name, uint32_t passkey) { LOG_WARN(LOG_TAG, "%s TODO Unimplemented", __func__); void DisplayPasskey(const bluetooth::hci::AddressWithType& address, std::string name, uint32_t passkey) { bt_bdname_t legacy_name{0}; memcpy(legacy_name.name, name.data(), name.length()); callback_(RawAddress(address.GetAddress().address), legacy_name, ((0x1F) << 8) /* COD_UNCLASSIFIED*/ , BT_SSP_VARIANT_PASSKEY_NOTIFICATION, passkey); } void SetLegacyCallback(std::function<void(RawAddress*, bt_bdname_t*, uint32_t, bt_ssp_variant_t, uint32_t)> callback) { void SetLegacyCallback(std::function<void(RawAddress, bt_bdname_t, uint32_t, bt_ssp_variant_t, uint32_t)> callback) { callback_ = callback; } private: std::function<void(RawAddress*, bt_bdname_t*, uint32_t, bt_ssp_variant_t, std::function<void(RawAddress, bt_bdname_t, uint32_t, bt_ssp_variant_t, uint32_t)> callback_; }; Loading @@ -81,16 +80,28 @@ ShimUi ui; /** * Sets handler to SecurityModule and provides callback to handler */ void BTIF_DM_SetUiCallback( std::function<void(RawAddress*, bt_bdname_t*, uint32_t, bt_ssp_variant_t, uint32_t)> callback) { LOG_WARN(LOG_TAG, "%s called", __func__); auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager(); void BTIF_DM_SetUiCallback(std::function<void(RawAddress, bt_bdname_t, uint32_t, bt_ssp_variant_t, uint32_t)> callback) { LOG_WARN(LOG_TAG, "%s", __func__); auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager(); ui.SetLegacyCallback(callback); security_manager->SetUserInterfaceHandler( &ui, bluetooth::shim::GetGdShimHandler()); security_manager->SetUserInterfaceHandler(&ui, bluetooth::shim::GetGdShimHandler()); } void BTIF_DM_ssp_reply(const RawAddress bd_addr, uint8_t addr_type, bt_ssp_variant_t variant, uint8_t accept) { LOG_WARN(LOG_TAG, "%s", __func__); hci::AddressWithType address = ToAddressWithType(bd_addr, addr_type); auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager(); if (variant == BT_SSP_VARIANT_PASSKEY_CONFIRMATION || variant == BT_SSP_VARIANT_CONSENT) { security_manager->OnConfirmYesNo(address, accept); } else { //TODO: // void OnPairingPromptAccepted(const bluetooth::hci::AddressWithType& address, bool confirmed) override; // void OnPasskeyEntry(const bluetooth::hci::AddressWithType& address, uint32_t passkey) override; LOG_WARN(LOG_TAG, "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ Variant not implemented yet %02x", variant); } } } // namespace shim Loading system/main/shim/btif_dm.h +2 −5 Original line number Diff line number Diff line Loading @@ -28,10 +28,7 @@ namespace shim { /** * Sets handler to SecurityModule and provides callback to handler */ void BTIF_DM_SetUiCallback( std::function<void(RawAddress*, bt_bdname_t*, uint32_t, bt_ssp_variant_t, uint32_t)> callback); void BTIF_DM_SetUiCallback(std::function<void(RawAddress, bt_bdname_t, uint32_t, bt_ssp_variant_t, uint32_t)> callback); void BTIF_DM_ssp_reply(const RawAddress bd_addr, uint8_t, bt_ssp_variant_t variant, uint8_t accept); } // namespace shim } // namespace bluetooth system/main/shim/btm.cc +1 −10 Original line number Diff line number Diff line Loading @@ -830,12 +830,3 @@ bool bluetooth::shim::Btm::RemoveBond(const RawAddress& bd_addr) { security_manager->RemoveBond(ToAddressWithType(bd_addr, BLE_ADDR_PUBLIC)); return true; } No newline at end of file void bluetooth::shim::Btm::SetSimplePairingCallback( tBTM_SP_CALLBACK* callback) { auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager(); // TODO(optedoblivion): security_manager->RegisterCallback(new // ExtendedCallback(simple_pairing_callback_)) simple_pairing_callback_ = callback; } system/main/shim/btm.h +0 −4 Original line number Diff line number Diff line Loading @@ -243,8 +243,6 @@ class Btm { bool CancelBond(const RawAddress& bd_addr); bool RemoveBond(const RawAddress& bd_addr); void SetSimplePairingCallback(tBTM_SP_CALLBACK* callback); private: ReadRemoteName le_read_remote_name_; ReadRemoteName classic_read_remote_name_; Loading @@ -256,8 +254,6 @@ class Btm { LegacyInquiryCompleteCallback legacy_inquiry_complete_callback_{}; tBTM_SP_CALLBACK* simple_pairing_callback_{nullptr}; uint8_t active_inquiry_mode_ = 0; // TODO(cmanton) abort if there is no classic acl link up Loading Loading
system/btif/src/btif_dm.cc +21 −13 Original line number Diff line number Diff line Loading @@ -293,18 +293,15 @@ static void btif_dm_data_free(uint16_t event, tBTA_DM_SEC* dm_sec) { void btif_dm_init(uid_set_t* set) { uid_set = set; if (bluetooth::shim::is_gd_shim_enabled()) { bluetooth::shim::BTIF_DM_SetUiCallback( [](RawAddress* bt_addr, bt_bdname_t* bd_name, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t pass_key) { bluetooth::shim::BTIF_DM_SetUiCallback([](RawAddress address, bt_bdname_t bd_name, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t pass_key) { do_in_jni_thread(FROM_HERE, base::BindOnce([](RawAddress address, bt_bdname_t bd_name, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t pass_key) { LOG(ERROR) << __func__ << ": UI Callback fired!"; // TODO(optedoblivion): Wire up HAL_CBACK // HAL_CBACK(bt_hal_cbacks, ssp_request_cb, &bd_addr, &bd_name, // cod, // (p_ssp_cfm_req->just_works ? BT_SSP_VARIANT_CONSENT // : // BT_SSP_VARIANT_PASSKEY_CONFIRMATION), // p_ssp_cfm_req->num_val); // //TODO: java BondStateMachine requires change into bonding state. If we ever send this event separately, consider removing this line HAL_CBACK(bt_hal_cbacks, bond_state_changed_cb, BT_STATUS_SUCCESS, &address, BT_BOND_STATE_BONDING); HAL_CBACK(bt_hal_cbacks, ssp_request_cb, &address, &bd_name, cod, pairing_variant, pass_key); }, address, bd_name, cod, pairing_variant, pass_key)); }); } } Loading Loading @@ -2424,6 +2421,17 @@ bt_status_t btif_dm_pin_reply(const RawAddress* bd_addr, uint8_t accept, bt_status_t btif_dm_ssp_reply(const RawAddress* bd_addr, bt_ssp_variant_t variant, uint8_t accept, UNUSED_ATTR uint32_t passkey) { if (bluetooth::shim::is_gd_shim_enabled()) { uint8_t tmp_dev_type = 0; uint8_t tmp_addr_type = 0; BTM_ReadDevInfo(*bd_addr, &tmp_dev_type, &tmp_addr_type); do_in_main_thread( FROM_HERE, base::Bind(&bluetooth::shim::BTIF_DM_ssp_reply, *bd_addr, tmp_addr_type, variant, accept)); } if (variant == BT_SSP_VARIANT_PASSKEY_ENTRY) { /* This is not implemented in the stack. * For devices with display, this is not needed Loading
system/main/shim/btif_dm.cc +46 −35 Original line number Diff line number Diff line Loading @@ -15,10 +15,11 @@ */ #define LOG_TAG "bt_shim_btif_dm" #include "main/shim/btif_dm.h" #include "osi/include/log.h" #include "main/shim/btif_dm.h" #include "main/shim/entry.h" #include "osi/include/log.h" #include "main/shim/helpers.h" #include "security/security_module.h" #include "security/ui.h" Loading @@ -32,46 +33,44 @@ class ShimUi : public security::UI { ~ShimUi() {} void DisplayPairingPrompt(const bluetooth::hci::AddressWithType& address, std::string name) { LOG_WARN(LOG_TAG, "%s TODO Unimplemented", __func__); LOG_WARN(LOG_TAG, "%s ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ TODO Unimplemented", __func__); } void Cancel(const bluetooth::hci::AddressWithType& address) { LOG_WARN(LOG_TAG, "%s TODO Unimplemented", __func__); LOG_WARN(LOG_TAG, "%s ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ TODO Unimplemented", __func__); } void DisplayConfirmValue(const bluetooth::hci::AddressWithType& address, std::string name, uint32_t numeric_value) { LOG_WARN(LOG_TAG, "%s TODO Unimplemented", __func__); // TODO(optedoblivion): Remove and wire up to UI callback auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager(); security_manager->OnConfirmYesNo(address, true); // callback(address, name, 0, 0, 0); bt_bdname_t legacy_name{0}; memcpy(legacy_name.name, name.data(), name.length()); callback_(RawAddress(address.GetAddress().address), legacy_name, ((0x1F) << 8) /* COD_UNCLASSIFIED*/ , BT_SSP_VARIANT_PASSKEY_CONFIRMATION, numeric_value); } void DisplayYesNoDialog(const bluetooth::hci::AddressWithType& address, std::string name) { LOG_WARN(LOG_TAG, "%s TODO Unimplemented", __func__); // TODO(optedoblivion): Remove and wire up to UI callback auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager(); security_manager->OnConfirmYesNo(address, true); // callback(address, name, 0, 0, 0); bt_bdname_t legacy_name{0}; memcpy(legacy_name.name, name.data(), name.length()); callback_(RawAddress(address.GetAddress().address), legacy_name, ((0x1F) << 8) /* COD_UNCLASSIFIED*/ , BT_SSP_VARIANT_CONSENT, 0); } void DisplayEnterPasskeyDialog(const bluetooth::hci::AddressWithType& address, std::string name) { LOG_WARN(LOG_TAG, "%s TODO Unimplemented", __func__); void DisplayEnterPasskeyDialog(const bluetooth::hci::AddressWithType& address, std::string name) { bt_bdname_t legacy_name{0}; memcpy(legacy_name.name, name.data(), name.length()); callback_(RawAddress(address.GetAddress().address), legacy_name, ((0x1F) << 8) /* COD_UNCLASSIFIED*/ , BT_SSP_VARIANT_PASSKEY_ENTRY, 0); } void DisplayPasskey(const bluetooth::hci::AddressWithType& address, std::string name, uint32_t passkey) { LOG_WARN(LOG_TAG, "%s TODO Unimplemented", __func__); void DisplayPasskey(const bluetooth::hci::AddressWithType& address, std::string name, uint32_t passkey) { bt_bdname_t legacy_name{0}; memcpy(legacy_name.name, name.data(), name.length()); callback_(RawAddress(address.GetAddress().address), legacy_name, ((0x1F) << 8) /* COD_UNCLASSIFIED*/ , BT_SSP_VARIANT_PASSKEY_NOTIFICATION, passkey); } void SetLegacyCallback(std::function<void(RawAddress*, bt_bdname_t*, uint32_t, bt_ssp_variant_t, uint32_t)> callback) { void SetLegacyCallback(std::function<void(RawAddress, bt_bdname_t, uint32_t, bt_ssp_variant_t, uint32_t)> callback) { callback_ = callback; } private: std::function<void(RawAddress*, bt_bdname_t*, uint32_t, bt_ssp_variant_t, std::function<void(RawAddress, bt_bdname_t, uint32_t, bt_ssp_variant_t, uint32_t)> callback_; }; Loading @@ -81,16 +80,28 @@ ShimUi ui; /** * Sets handler to SecurityModule and provides callback to handler */ void BTIF_DM_SetUiCallback( std::function<void(RawAddress*, bt_bdname_t*, uint32_t, bt_ssp_variant_t, uint32_t)> callback) { LOG_WARN(LOG_TAG, "%s called", __func__); auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager(); void BTIF_DM_SetUiCallback(std::function<void(RawAddress, bt_bdname_t, uint32_t, bt_ssp_variant_t, uint32_t)> callback) { LOG_WARN(LOG_TAG, "%s", __func__); auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager(); ui.SetLegacyCallback(callback); security_manager->SetUserInterfaceHandler( &ui, bluetooth::shim::GetGdShimHandler()); security_manager->SetUserInterfaceHandler(&ui, bluetooth::shim::GetGdShimHandler()); } void BTIF_DM_ssp_reply(const RawAddress bd_addr, uint8_t addr_type, bt_ssp_variant_t variant, uint8_t accept) { LOG_WARN(LOG_TAG, "%s", __func__); hci::AddressWithType address = ToAddressWithType(bd_addr, addr_type); auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager(); if (variant == BT_SSP_VARIANT_PASSKEY_CONFIRMATION || variant == BT_SSP_VARIANT_CONSENT) { security_manager->OnConfirmYesNo(address, accept); } else { //TODO: // void OnPairingPromptAccepted(const bluetooth::hci::AddressWithType& address, bool confirmed) override; // void OnPasskeyEntry(const bluetooth::hci::AddressWithType& address, uint32_t passkey) override; LOG_WARN(LOG_TAG, "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ Variant not implemented yet %02x", variant); } } } // namespace shim Loading
system/main/shim/btif_dm.h +2 −5 Original line number Diff line number Diff line Loading @@ -28,10 +28,7 @@ namespace shim { /** * Sets handler to SecurityModule and provides callback to handler */ void BTIF_DM_SetUiCallback( std::function<void(RawAddress*, bt_bdname_t*, uint32_t, bt_ssp_variant_t, uint32_t)> callback); void BTIF_DM_SetUiCallback(std::function<void(RawAddress, bt_bdname_t, uint32_t, bt_ssp_variant_t, uint32_t)> callback); void BTIF_DM_ssp_reply(const RawAddress bd_addr, uint8_t, bt_ssp_variant_t variant, uint8_t accept); } // namespace shim } // namespace bluetooth
system/main/shim/btm.cc +1 −10 Original line number Diff line number Diff line Loading @@ -830,12 +830,3 @@ bool bluetooth::shim::Btm::RemoveBond(const RawAddress& bd_addr) { security_manager->RemoveBond(ToAddressWithType(bd_addr, BLE_ADDR_PUBLIC)); return true; } No newline at end of file void bluetooth::shim::Btm::SetSimplePairingCallback( tBTM_SP_CALLBACK* callback) { auto security_manager = bluetooth::shim::GetSecurityModule()->GetSecurityManager(); // TODO(optedoblivion): security_manager->RegisterCallback(new // ExtendedCallback(simple_pairing_callback_)) simple_pairing_callback_ = callback; }
system/main/shim/btm.h +0 −4 Original line number Diff line number Diff line Loading @@ -243,8 +243,6 @@ class Btm { bool CancelBond(const RawAddress& bd_addr); bool RemoveBond(const RawAddress& bd_addr); void SetSimplePairingCallback(tBTM_SP_CALLBACK* callback); private: ReadRemoteName le_read_remote_name_; ReadRemoteName classic_read_remote_name_; Loading @@ -256,8 +254,6 @@ class Btm { LegacyInquiryCompleteCallback legacy_inquiry_complete_callback_{}; tBTM_SP_CALLBACK* simple_pairing_callback_{nullptr}; uint8_t active_inquiry_mode_ = 0; // TODO(cmanton) abort if there is no classic acl link up Loading