Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bcdc4fb8 authored by Martin Brabham's avatar Martin Brabham
Browse files

SM: Ensure we cannot cancel a pairing handler twice.

The callback for a ClassicPairingHandler is a OnceCallback,
so we only want Cancel to call it Once.

Bug:
Test: bluetooth_test_gd
Change-Id: I8c79b93fcce87d3f5197401ac25a5b96d1255dd7
parent 3e4963b6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -86,6 +86,8 @@ void ClassicPairingHandler::Initiate(bool locally_initiated, hci::IoCapability i
}

void ClassicPairingHandler::Cancel() {
  if (is_cancelled_) return;
  is_cancelled_ = true;
  PairingResultOrFailure result = PairingResult();
  if (last_status_ != hci::ErrorCode::SUCCESS) {
    result = PairingFailure(hci::ErrorCodeText(last_status_));
+1 −0
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ class ClassicPairingHandler : public PairingHandler {
  UI* user_interface_;
  os::Handler* user_interface_handler_;
  std::string device_name_;
  bool is_cancelled_ = false;

  hci::ErrorCode last_status_ = hci::ErrorCode::UNKNOWN_HCI_COMMAND;
  bool locally_initiated_ = false;