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

Commit b22e055f authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "GD Security Shim: make required calls to shim"

parents 259646a8 16d7be5b
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -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()));
@@ -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()));
@@ -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()));
@@ -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()));
@@ -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()));
@@ -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()));
@@ -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()));
@@ -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()));
+14 −0
Original line number Diff line number Diff line
@@ -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)
@@ -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_,
@@ -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_;