Loading system/gd/security/pairing/classic_pairing_handler.cc +12 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,10 @@ namespace pairing { void ClassicPairingHandler::OnRegistrationComplete( l2cap::classic::FixedChannelManager::RegistrationResult result, std::unique_ptr<l2cap::classic::FixedChannelService> fixed_channel_service) { if (result != l2cap::classic::FixedChannelManager::RegistrationResult::SUCCESS) { LOG_ERROR("Failed service registration!"); return; } fixed_channel_service_ = std::move(fixed_channel_service); fixed_channel_manager_->ConnectServices( GetRecord()->GetPseudoAddress().GetAddress(), Loading @@ -31,12 +35,17 @@ void ClassicPairingHandler::OnRegistrationComplete( } void ClassicPairingHandler::OnUnregistered() { std::move(complete_callback_).Run(GetRecord()->GetPseudoAddress().GetAddress(), last_status_); PairingResultOrFailure result = PairingResult(); if (last_status_ != hci::ErrorCode::SUCCESS) { result = PairingFailure(hci::ErrorCodeText(last_status_)); } std::move(complete_callback_).Run(GetRecord()->GetPseudoAddress().GetAddress(), result); } void ClassicPairingHandler::OnConnectionOpen(std::unique_ptr<l2cap::classic::FixedChannel> fixed_channel) { ASSERT(fixed_channel_ == nullptr); fixed_channel_ = std::move(fixed_channel); ASSERT(fixed_channel_->GetDevice() == GetRecord()->GetPseudoAddress().GetAddress()); fixed_channel_->Acquire(); fixed_channel_->RegisterOnCloseCallback( security_handler_, common::BindOnce(&ClassicPairingHandler::OnConnectionClose, common::Unretained(this))); Loading Loading @@ -143,6 +152,7 @@ void ClassicPairingHandler::OnReceive(hci::SimplePairingCompleteView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); last_status_ = packet.GetStatus(); Cancel(); } Loading system/gd/security/pairing/classic_pairing_handler.h +1 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ class ClassicPairingHandler : public PairingHandler { hci::AuthenticationRequirements local_authentication_requirements_ __attribute__((unused)); std::unique_ptr<l2cap::classic::FixedChannel> fixed_channel_{nullptr}; common::OnceCallback<void(hci::Address, PairingResultOrFailure)> complete_callback_; PairingResultOrFailure last_status_; hci::ErrorCode last_status_; bool locally_initiated_ = false; }; Loading system/gd/security/pairing/classic_pairing_handler_unittest.cc +1 −1 Original line number Diff line number Diff line Loading @@ -120,7 +120,7 @@ class ClassicPairingHandlerTest : public ::testing::Test { security_record_ = std::make_shared<record::SecurityRecord>(device_); std::shared_ptr<l2cap::classic::testing::MockFixedChannelManager> sptr = std::shared_ptr<l2cap::classic::testing::MockFixedChannelManager>( new l2cap::classic::testing::MockFixedChannelManager); new l2cap::classic::testing::MockFixedChannelManager()); EXPECT_CALL(*sptr, RegisterService(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)) .Times(::testing::AnyNumber()); pairing_handler_ = new pairing::ClassicPairingHandler(sptr, channel_, security_record_, handler_, Loading Loading
system/gd/security/pairing/classic_pairing_handler.cc +12 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,10 @@ namespace pairing { void ClassicPairingHandler::OnRegistrationComplete( l2cap::classic::FixedChannelManager::RegistrationResult result, std::unique_ptr<l2cap::classic::FixedChannelService> fixed_channel_service) { if (result != l2cap::classic::FixedChannelManager::RegistrationResult::SUCCESS) { LOG_ERROR("Failed service registration!"); return; } fixed_channel_service_ = std::move(fixed_channel_service); fixed_channel_manager_->ConnectServices( GetRecord()->GetPseudoAddress().GetAddress(), Loading @@ -31,12 +35,17 @@ void ClassicPairingHandler::OnRegistrationComplete( } void ClassicPairingHandler::OnUnregistered() { std::move(complete_callback_).Run(GetRecord()->GetPseudoAddress().GetAddress(), last_status_); PairingResultOrFailure result = PairingResult(); if (last_status_ != hci::ErrorCode::SUCCESS) { result = PairingFailure(hci::ErrorCodeText(last_status_)); } std::move(complete_callback_).Run(GetRecord()->GetPseudoAddress().GetAddress(), result); } void ClassicPairingHandler::OnConnectionOpen(std::unique_ptr<l2cap::classic::FixedChannel> fixed_channel) { ASSERT(fixed_channel_ == nullptr); fixed_channel_ = std::move(fixed_channel); ASSERT(fixed_channel_->GetDevice() == GetRecord()->GetPseudoAddress().GetAddress()); fixed_channel_->Acquire(); fixed_channel_->RegisterOnCloseCallback( security_handler_, common::BindOnce(&ClassicPairingHandler::OnConnectionClose, common::Unretained(this))); Loading Loading @@ -143,6 +152,7 @@ void ClassicPairingHandler::OnReceive(hci::SimplePairingCompleteView packet) { ASSERT(packet.IsValid()); LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str()); ASSERT_LOG(GetRecord()->GetPseudoAddress().GetAddress() == packet.GetBdAddr(), "Address mismatch"); last_status_ = packet.GetStatus(); Cancel(); } Loading
system/gd/security/pairing/classic_pairing_handler.h +1 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ class ClassicPairingHandler : public PairingHandler { hci::AuthenticationRequirements local_authentication_requirements_ __attribute__((unused)); std::unique_ptr<l2cap::classic::FixedChannel> fixed_channel_{nullptr}; common::OnceCallback<void(hci::Address, PairingResultOrFailure)> complete_callback_; PairingResultOrFailure last_status_; hci::ErrorCode last_status_; bool locally_initiated_ = false; }; Loading
system/gd/security/pairing/classic_pairing_handler_unittest.cc +1 −1 Original line number Diff line number Diff line Loading @@ -120,7 +120,7 @@ class ClassicPairingHandlerTest : public ::testing::Test { security_record_ = std::make_shared<record::SecurityRecord>(device_); std::shared_ptr<l2cap::classic::testing::MockFixedChannelManager> sptr = std::shared_ptr<l2cap::classic::testing::MockFixedChannelManager>( new l2cap::classic::testing::MockFixedChannelManager); new l2cap::classic::testing::MockFixedChannelManager()); EXPECT_CALL(*sptr, RegisterService(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)) .Times(::testing::AnyNumber()); pairing_handler_ = new pairing::ClassicPairingHandler(sptr, channel_, security_record_, handler_, Loading