Loading system/gd/security/initial_informations.h +2 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,8 @@ struct InitialInformations { std::optional<MyOobData> my_oob_data; /* Used by Pairing Handler to present user with requests*/ UI* ui_handler; UI* user_interface; os::Handler* user_interface_handler; /* HCI interface to use */ hci::LeSecurityInterface* le_security_interface; Loading system/gd/security/internal/security_manager_impl.cc +12 −15 Original line number Diff line number Diff line Loading @@ -33,19 +33,6 @@ namespace bluetooth { namespace security { namespace internal { namespace { // TOOD: implement properly, have it passed form other module? class UIHandler : public ::bluetooth::security::UI { public: void DisplayPairingPrompt(const hci::AddressWithType& address, std::string& name) {} void CancelPairingPrompt(const hci::AddressWithType& address) {} void DisplayConfirmValue(uint32_t numeric_value) {} void DisplayEnterPasskeyDialog() {} void DisplayPasskey(uint32_t passkey) {} }; UIHandler static_ui_handler; } // namespace void SecurityManagerImpl::DispatchPairingHandler(record::SecurityRecord& record, bool locally_initiated) { common::OnceCallback<void(hci::Address, PairingResultOrFailure)> callback = common::BindOnce(&SecurityManagerImpl::OnPairingHandlerComplete, common::Unretained(this)); Loading Loading @@ -122,6 +109,14 @@ void SecurityManagerImpl::RemoveBond(hci::AddressWithType device) { // Signal Remove from database } void SecurityManagerImpl::SetUserInterfaceHandler(UI* user_interface, os::Handler* handler) { if (user_interface_ != nullptr || user_interface_handler_ != nullptr) { LOG_ALWAYS_FATAL("Listener has already been registered!"); } user_interface_ = user_interface; user_interface_handler_ = handler; } void SecurityManagerImpl::RegisterCallbackListener(ISecurityManagerListener* listener, os::Handler* handler) { for (auto it = listeners_.begin(); it != listeners_.end(); ++it) { if (it->first == listener) { Loading Loading @@ -320,8 +315,10 @@ void SecurityManagerImpl::OnConnectionOpenLe(std::unique_ptr<l2cap::le::FixedCha .pairing_request = std::nullopt, // TODO: handle remotely initiated pairing in SecurityManager properly .remote_oob_data = std::nullopt, // TODO: .my_oob_data = std::nullopt, // TODO: // /* Used by Pairing Handler to present user with requests*/ .ui_handler = &static_ui_handler, /* Used by Pairing Handler to present user with requests*/ .user_interface = user_interface_, .user_interface_handler = user_interface_handler_, /* HCI interface to use */ .le_security_interface = hci_security_interface_le_, .proper_l2cap_interface = pending_le_pairing_.enqueue_buffer_.get(), Loading system/gd/security/internal/security_manager_impl.h +8 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,11 @@ class SecurityManagerImpl : public channel::ISecurityManagerChannelListener { /* void RemoveBond(std::shared_ptr<hci::LeDevice> device); */ /** * Register Security UI handler, for handling prompts around the Pairing process. */ void SetUserInterfaceHandler(UI* user_interface, os::Handler* handler); /** * Register to listen for callback events from SecurityManager * Loading Loading @@ -117,6 +122,9 @@ class SecurityManagerImpl : public channel::ISecurityManagerChannelListener { protected: std::vector<std::pair<ISecurityManagerListener*, os::Handler*>> listeners_; UI* user_interface_ = nullptr; os::Handler* user_interface_handler_ = nullptr; void NotifyDeviceBonded(hci::AddressWithType device); void NotifyDeviceBondFailed(hci::AddressWithType device, PairingResultOrFailure status); void NotifyDeviceUnbonded(hci::AddressWithType device); Loading system/gd/security/pairing_handler_le.cc +2 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,8 @@ void PairingHandlerLe::PairingMain(InitialInformations i) { if (i.remotely_initiated) { LOG_INFO("Was remotely initiated, presenting user with the accept prompt"); i.ui_handler->DisplayPairingPrompt(i.remote_connection_address, i.remote_name); i.user_interface_handler->Post(common::BindOnce(&UI::DisplayPairingPrompt, common::Unretained(i.user_interface), i.remote_connection_address, i.remote_name)); // If pairing was initiated by remote device, wait for the user to accept // the request from the UI. Loading system/gd/security/pairing_handler_le_legacy.cc +4 −2 Original line number Diff line number Diff line Loading @@ -89,9 +89,11 @@ LegacyStage1ResultOrFailure PairingHandlerLe::LegacyPasskeyEntry(const InitialIn constexpr uint32_t PASSKEY_MAX = 999999; if (passkey > PASSKEY_MAX) passkey >>= 1; i.ui_handler->DisplayConfirmValue(passkey); i.user_interface_handler->Post( common::BindOnce(&UI::DisplayConfirmValue, common::Unretained(i.user_interface), passkey)); } else { i.ui_handler->DisplayEnterPasskeyDialog(); i.user_interface_handler->Post( common::BindOnce(&UI::DisplayEnterPasskeyDialog, common::Unretained(i.user_interface))); std::optional<PairingEvent> response = WaitUiPasskey(); if (!response) return PairingFailure("Passkey did not arrive!"); Loading Loading
system/gd/security/initial_informations.h +2 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,8 @@ struct InitialInformations { std::optional<MyOobData> my_oob_data; /* Used by Pairing Handler to present user with requests*/ UI* ui_handler; UI* user_interface; os::Handler* user_interface_handler; /* HCI interface to use */ hci::LeSecurityInterface* le_security_interface; Loading
system/gd/security/internal/security_manager_impl.cc +12 −15 Original line number Diff line number Diff line Loading @@ -33,19 +33,6 @@ namespace bluetooth { namespace security { namespace internal { namespace { // TOOD: implement properly, have it passed form other module? class UIHandler : public ::bluetooth::security::UI { public: void DisplayPairingPrompt(const hci::AddressWithType& address, std::string& name) {} void CancelPairingPrompt(const hci::AddressWithType& address) {} void DisplayConfirmValue(uint32_t numeric_value) {} void DisplayEnterPasskeyDialog() {} void DisplayPasskey(uint32_t passkey) {} }; UIHandler static_ui_handler; } // namespace void SecurityManagerImpl::DispatchPairingHandler(record::SecurityRecord& record, bool locally_initiated) { common::OnceCallback<void(hci::Address, PairingResultOrFailure)> callback = common::BindOnce(&SecurityManagerImpl::OnPairingHandlerComplete, common::Unretained(this)); Loading Loading @@ -122,6 +109,14 @@ void SecurityManagerImpl::RemoveBond(hci::AddressWithType device) { // Signal Remove from database } void SecurityManagerImpl::SetUserInterfaceHandler(UI* user_interface, os::Handler* handler) { if (user_interface_ != nullptr || user_interface_handler_ != nullptr) { LOG_ALWAYS_FATAL("Listener has already been registered!"); } user_interface_ = user_interface; user_interface_handler_ = handler; } void SecurityManagerImpl::RegisterCallbackListener(ISecurityManagerListener* listener, os::Handler* handler) { for (auto it = listeners_.begin(); it != listeners_.end(); ++it) { if (it->first == listener) { Loading Loading @@ -320,8 +315,10 @@ void SecurityManagerImpl::OnConnectionOpenLe(std::unique_ptr<l2cap::le::FixedCha .pairing_request = std::nullopt, // TODO: handle remotely initiated pairing in SecurityManager properly .remote_oob_data = std::nullopt, // TODO: .my_oob_data = std::nullopt, // TODO: // /* Used by Pairing Handler to present user with requests*/ .ui_handler = &static_ui_handler, /* Used by Pairing Handler to present user with requests*/ .user_interface = user_interface_, .user_interface_handler = user_interface_handler_, /* HCI interface to use */ .le_security_interface = hci_security_interface_le_, .proper_l2cap_interface = pending_le_pairing_.enqueue_buffer_.get(), Loading
system/gd/security/internal/security_manager_impl.h +8 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,11 @@ class SecurityManagerImpl : public channel::ISecurityManagerChannelListener { /* void RemoveBond(std::shared_ptr<hci::LeDevice> device); */ /** * Register Security UI handler, for handling prompts around the Pairing process. */ void SetUserInterfaceHandler(UI* user_interface, os::Handler* handler); /** * Register to listen for callback events from SecurityManager * Loading Loading @@ -117,6 +122,9 @@ class SecurityManagerImpl : public channel::ISecurityManagerChannelListener { protected: std::vector<std::pair<ISecurityManagerListener*, os::Handler*>> listeners_; UI* user_interface_ = nullptr; os::Handler* user_interface_handler_ = nullptr; void NotifyDeviceBonded(hci::AddressWithType device); void NotifyDeviceBondFailed(hci::AddressWithType device, PairingResultOrFailure status); void NotifyDeviceUnbonded(hci::AddressWithType device); Loading
system/gd/security/pairing_handler_le.cc +2 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,8 @@ void PairingHandlerLe::PairingMain(InitialInformations i) { if (i.remotely_initiated) { LOG_INFO("Was remotely initiated, presenting user with the accept prompt"); i.ui_handler->DisplayPairingPrompt(i.remote_connection_address, i.remote_name); i.user_interface_handler->Post(common::BindOnce(&UI::DisplayPairingPrompt, common::Unretained(i.user_interface), i.remote_connection_address, i.remote_name)); // If pairing was initiated by remote device, wait for the user to accept // the request from the UI. Loading
system/gd/security/pairing_handler_le_legacy.cc +4 −2 Original line number Diff line number Diff line Loading @@ -89,9 +89,11 @@ LegacyStage1ResultOrFailure PairingHandlerLe::LegacyPasskeyEntry(const InitialIn constexpr uint32_t PASSKEY_MAX = 999999; if (passkey > PASSKEY_MAX) passkey >>= 1; i.ui_handler->DisplayConfirmValue(passkey); i.user_interface_handler->Post( common::BindOnce(&UI::DisplayConfirmValue, common::Unretained(i.user_interface), passkey)); } else { i.ui_handler->DisplayEnterPasskeyDialog(); i.user_interface_handler->Post( common::BindOnce(&UI::DisplayEnterPasskeyDialog, common::Unretained(i.user_interface))); std::optional<PairingEvent> response = WaitUiPasskey(); if (!response) return PairingFailure("Passkey did not arrive!"); Loading