Loading system/gd/security/pairing/classic_pairing_handler.cc +20 −0 Original line number Diff line number Diff line Loading @@ -341,6 +341,12 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // NOTE(optedoblivion) BTA needs a callback for when auto accepting JustWorks // If we auto accept from the ClassicPairingHandler in GD then we won't // get a callback to this shim function. // We will have to call it anyway until we eliminate the need // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading @@ -353,6 +359,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading @@ -374,6 +382,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading Loading @@ -444,6 +454,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading @@ -461,6 +473,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading @@ -474,6 +488,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading @@ -487,6 +503,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading @@ -500,6 +518,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading system/gd/security/pairing/classic_pairing_handler_unittest.cc +14 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,17 @@ class FakeSecurityManagerChannel : public channel::SecurityManagerChannel { } }; class TestUI : public UI { public: ~TestUI() override {} void DisplayPairingPrompt(const hci::AddressWithType& address, std::string name) override {} void Cancel(const hci::AddressWithType& address) override {} void DisplayConfirmValue(ConfirmationData data) override {} void DisplayYesNoDialog(ConfirmationData data) override {} void DisplayEnterPasskeyDialog(ConfirmationData data) override {} void DisplayPasskey(ConfirmationData data) override {} }; class SecurityManagerChannelCallback : public ISecurityManagerChannelListener { public: explicit SecurityManagerChannelCallback(pairing::ClassicPairingHandler* pairing_handler) Loading Loading @@ -143,6 +154,8 @@ class ClassicPairingHandlerTest : public ::testing::Test { handler_ = fake_registry_.GetTestModuleHandler(&FakeHciLayer::Factory); channel_ = new FakeSecurityManagerChannel(handler_, hci_layer_); security_record_ = std::make_shared<record::SecurityRecord>(device_); user_interface_ = new TestUI(); user_interface_handler_ = handler_; pairing_handler_ = new pairing::ClassicPairingHandler( channel_, security_record_, Loading @@ -162,6 +175,7 @@ class ClassicPairingHandlerTest : public ::testing::Test { channel_->SetChannelListener(nullptr); synchronize(); fake_registry_.StopAll(); delete user_interface_; delete pairing_handler_; delete channel_; delete channel_callback_; Loading Loading
system/gd/security/pairing/classic_pairing_handler.cc +20 −0 Original line number Diff line number Diff line Loading @@ -341,6 +341,12 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // NOTE(optedoblivion) BTA needs a callback for when auto accepting JustWorks // If we auto accept from the ClassicPairingHandler in GD then we won't // get a callback to this shim function. // We will have to call it anyway until we eliminate the need // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading @@ -353,6 +359,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading @@ -374,6 +382,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading Loading @@ -444,6 +454,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading @@ -461,6 +473,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading @@ -474,6 +488,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading @@ -487,6 +503,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading @@ -500,6 +518,8 @@ void ClassicPairingHandler::OnReceive(hci::UserConfirmationRequestView packet) { if (!GetRecord()->RequiresMitmProtection()) { GetChannel()->SendCommand( hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress()->GetAddress())); // TODO(optedoblivion): REMOVE WHEN SHIM LEAVES NotifyUiDisplayYesNo(); } else { GetChannel()->SendCommand(hci::UserConfirmationRequestNegativeReplyBuilder::Create( GetRecord()->GetPseudoAddress()->GetAddress())); Loading
system/gd/security/pairing/classic_pairing_handler_unittest.cc +14 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,17 @@ class FakeSecurityManagerChannel : public channel::SecurityManagerChannel { } }; class TestUI : public UI { public: ~TestUI() override {} void DisplayPairingPrompt(const hci::AddressWithType& address, std::string name) override {} void Cancel(const hci::AddressWithType& address) override {} void DisplayConfirmValue(ConfirmationData data) override {} void DisplayYesNoDialog(ConfirmationData data) override {} void DisplayEnterPasskeyDialog(ConfirmationData data) override {} void DisplayPasskey(ConfirmationData data) override {} }; class SecurityManagerChannelCallback : public ISecurityManagerChannelListener { public: explicit SecurityManagerChannelCallback(pairing::ClassicPairingHandler* pairing_handler) Loading Loading @@ -143,6 +154,8 @@ class ClassicPairingHandlerTest : public ::testing::Test { handler_ = fake_registry_.GetTestModuleHandler(&FakeHciLayer::Factory); channel_ = new FakeSecurityManagerChannel(handler_, hci_layer_); security_record_ = std::make_shared<record::SecurityRecord>(device_); user_interface_ = new TestUI(); user_interface_handler_ = handler_; pairing_handler_ = new pairing::ClassicPairingHandler( channel_, security_record_, Loading @@ -162,6 +175,7 @@ class ClassicPairingHandlerTest : public ::testing::Test { channel_->SetChannelListener(nullptr); synchronize(); fake_registry_.StopAll(); delete user_interface_; delete pairing_handler_; delete channel_; delete channel_callback_; Loading