OSDN Git Service

SM: Fix event order logic for Classic Pairing
authorMartin Brabham <optedoblivion@google.com>
Wed, 18 Mar 2020 21:52:39 +0000 (14:52 -0700)
committerMartin Brabham <optedoblivion@google.com>
Fri, 20 Mar 2020 03:54:43 +0000 (03:54 +0000)
Bug: 145638034
Test: ./cert/run --host --test_filter=SimpleSecurityTest
Change-Id: I1d8c4cbfe847092f5defdd2761d8715b2f03b02b

gd/security/pairing/classic_pairing_handler.cc
gd/security/pairing/classic_pairing_handler_unittest.cc

index 5fbef88..c5ef608 100644 (file)
@@ -131,8 +131,6 @@ 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());
-  // We are done with the pairing flow
-  Cancel();
 }
 
 void ClassicPairingHandler::OnReceive(hci::IoCapabilityRequestView packet) {
@@ -164,8 +162,8 @@ void ClassicPairingHandler::OnReceive(hci::SimplePairingCompleteView packet) {
   if (last_status_ != hci::ErrorCode::SUCCESS) {
     LOG_INFO("Failed SimplePairingComplete: %s", hci::ErrorCodeText(last_status_).c_str());
     // Cancel here since we won't get LinkKeyNotification
-    Cancel();
   }
+  Cancel();
 }
 
 void ClassicPairingHandler::OnReceive(hci::ReturnLinkKeysView packet) {
index c300e5b..efa77f7 100644 (file)
@@ -182,8 +182,8 @@ class ClassicPairingHandlerTest : public ::testing::Test {
 //  <- IoCapabilityResponse
 //  <- UserConfirmationRequest
 //  -> UserConfirmationRequestReply (auto)
-//  <- SimplePairingComplete
 //  <- LinkKeyNotification
+//  <- SimplePairingComplete
 //  <- AuthenticationComplete
 //  -> SetConnectionEncryption
 //  <- EncryptionChange