Loading system/gd/security/pairing/classic_pairing_handler.cc +10 −2 Original line number Diff line number Diff line Loading @@ -132,9 +132,13 @@ void ClassicPairingHandler::OnNameRequestComplete(hci::Address address, bool suc device_name_ = tmp_name; } has_gotten_name_response_ = true; // For SSP/Numeric comparison flow if (user_confirmation_request_) { this->OnReceive(*user_confirmation_request_); user_confirmation_request_ = std::nullopt; } // For OOB Flow; we go to link key notification and must wait for name if (link_key_notification_) { this->OnReceive(*link_key_notification_); } } Loading Loading @@ -192,6 +196,10 @@ void ClassicPairingHandler::OnReceive(hci::LinkKeyNotificationView packet) { LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); GetRecord()->SetLinkKey(packet.GetLinkKey(), packet.GetKeyType()); if (!has_gotten_name_response_) { link_key_notification_ = std::make_optional<hci::LinkKeyNotificationView>(packet); return; } Cancel(); } Loading Loading @@ -273,7 +281,6 @@ void ClassicPairingHandler::OnReceive(hci::IoCapabilityResponseView packet) { has_gotten_io_cap_response_ = true; if (user_confirmation_request_) { this->OnReceive(*user_confirmation_request_); user_confirmation_request_ = std::nullopt; } } Loading Loading @@ -393,6 +400,7 @@ void ClassicPairingHandler::OnReceive(hci::KeypressNotificationView packet) { void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // Ensure we have io cap response otherwise checks will be wrong if it comes late // Ensure we have the name response otherwise we cannot show a name for the device to the user if (!has_gotten_io_cap_response_ || !has_gotten_name_response_) { user_confirmation_request_ = std::make_optional<hci::UserConfirmationRequestView>(packet); return; Loading system/gd/security/pairing/classic_pairing_handler.h +1 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,7 @@ class ClassicPairingHandler : public PairingHandler { bool has_gotten_io_cap_response_ = false; bool has_gotten_name_response_ = false; std::optional<hci::UserConfirmationRequestView> user_confirmation_request_ = std::nullopt; std::optional<hci::LinkKeyNotificationView> link_key_notification_ = std::nullopt; hci::ErrorCode last_status_ = hci::ErrorCode::UNKNOWN_HCI_COMMAND; bool locally_initiated_ = false; Loading Loading
system/gd/security/pairing/classic_pairing_handler.cc +10 −2 Original line number Diff line number Diff line Loading @@ -132,9 +132,13 @@ void ClassicPairingHandler::OnNameRequestComplete(hci::Address address, bool suc device_name_ = tmp_name; } has_gotten_name_response_ = true; // For SSP/Numeric comparison flow if (user_confirmation_request_) { this->OnReceive(*user_confirmation_request_); user_confirmation_request_ = std::nullopt; } // For OOB Flow; we go to link key notification and must wait for name if (link_key_notification_) { this->OnReceive(*link_key_notification_); } } Loading Loading @@ -192,6 +196,10 @@ void ClassicPairingHandler::OnReceive(hci::LinkKeyNotificationView packet) { LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch"); GetRecord()->SetLinkKey(packet.GetLinkKey(), packet.GetKeyType()); if (!has_gotten_name_response_) { link_key_notification_ = std::make_optional<hci::LinkKeyNotificationView>(packet); return; } Cancel(); } Loading Loading @@ -273,7 +281,6 @@ void ClassicPairingHandler::OnReceive(hci::IoCapabilityResponseView packet) { has_gotten_io_cap_response_ = true; if (user_confirmation_request_) { this->OnReceive(*user_confirmation_request_); user_confirmation_request_ = std::nullopt; } } Loading Loading @@ -393,6 +400,7 @@ void ClassicPairingHandler::OnReceive(hci::KeypressNotificationView packet) { void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { // Ensure we have io cap response otherwise checks will be wrong if it comes late // Ensure we have the name response otherwise we cannot show a name for the device to the user if (!has_gotten_io_cap_response_ || !has_gotten_name_response_) { user_confirmation_request_ = std::make_optional<hci::UserConfirmationRequestView>(packet); return; Loading
system/gd/security/pairing/classic_pairing_handler.h +1 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,7 @@ class ClassicPairingHandler : public PairingHandler { bool has_gotten_io_cap_response_ = false; bool has_gotten_name_response_ = false; std::optional<hci::UserConfirmationRequestView> user_confirmation_request_ = std::nullopt; std::optional<hci::LinkKeyNotificationView> link_key_notification_ = std::nullopt; hci::ErrorCode last_status_ = hci::ErrorCode::UNKNOWN_HCI_COMMAND; bool locally_initiated_ = false; Loading