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

Commit b03bf001 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "SM: Fix cert test" am: bad14dfd

Change-Id: Ica62c712beb442eb40feffa3056587f8c24a4d60
parents c41bad54 bad14dfd
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -187,7 +187,11 @@ class SimpleSecurityTest(GdFacadeOnlyBaseTestClass):
                security_facade.UiCallbackMsg(
                    message_type=security_facade.UiCallbackType.YES_NO,
                    boolean=True,
                    unique_id=ui_id))
                    unique_id=ui_id,
                    address=common.BluetoothAddressWithType(
                        address=common.BluetoothAddress(address=cert_address),
                        type=common.BluetoothAddressTypeEnum.
                        PUBLIC_DEVICE_ADDRESS)))

            dut_bond_asserts.assert_event_occurs(
                lambda bond_event: bond_event.message_type == security_facade.BondMsgType.DEVICE_BONDED
+10 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include "security/facade.grpc.pb.h"
#include "security/security_manager_listener.h"
#include "security/security_module.h"
#include "security/ui.h"

namespace bluetooth {
namespace security {
@@ -30,6 +31,7 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public
  SecurityModuleFacadeService(SecurityModule* security_module, ::bluetooth::os::Handler* security_handler)
      : security_module_(security_module), security_handler_(security_handler) {
    security_module_->GetSecurityManager()->RegisterCallbackListener(this, security_handler_);
    security_module_->GetSecurityManager()->SetUserInterfaceHandler(this, security_handler_);
  }

  ::grpc::Status CreateBond(::grpc::ServerContext* context, const facade::BluetoothAddressWithType* request,
@@ -66,12 +68,17 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public

  ::grpc::Status SendUiCallback(::grpc::ServerContext* context, const UiCallbackMsg* request,
                                ::google::protobuf::Empty* response) override {
    hci::Address peer;
    ASSERT(hci::Address::FromString(request->address().address().address(), peer));
    hci::AddressType remote_type = hci::AddressType::PUBLIC_DEVICE_ADDRESS;

    switch (request->message_type()) {
      case UiCallbackType::PASSKEY:
        // TODO: security_module_->GetSecurityManager()->OnPasskeyEntry();
        break;
      case UiCallbackType::YES_NO:
        // TODO: security_module_->GetSecurityManager()->OnConfirmYesNo(request->boolean());
        security_module_->GetSecurityManager()->OnConfirmYesNo(hci::AddressWithType(peer, remote_type),
                                                               request->boolean());
        break;
      default:
        LOG_ERROR("Unknown UiCallbackType %d", static_cast<int>(request->message_type()));
@@ -92,6 +99,7 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public
    display_yes_no.mutable_peer()->set_type(facade::BluetoothAddressTypeEnum::PUBLIC_DEVICE_ADDRESS);
    display_yes_no.set_message_type(UiMsgType::DISPLAY_YES_NO);
    display_yes_no.set_unique_id(unique_id++);
    ui_events_.OnIncomingEvent(display_yes_no);
  }

  virtual void DisplayConfirmValue(const bluetooth::hci::AddressWithType& peer, std::string name,
@@ -113,6 +121,7 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public
    display_yes_no.mutable_peer()->set_type(facade::BluetoothAddressTypeEnum::PUBLIC_DEVICE_ADDRESS);
    display_yes_no.set_message_type(UiMsgType::DISPLAY_YES_NO);
    display_yes_no.set_unique_id(unique_id++);
    ui_events_.OnIncomingEvent(display_yes_no);
  }

  void DisplayPasskey(const bluetooth::hci::AddressWithType& peer, std::string name, uint32_t passkey) override {
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ message UiCallbackMsg {
  bool boolean = 2;
  uint32 numeric_value = 3;
  uint32 unique_id = 4;
  facade.BluetoothAddressWithType address = 5;
}

enum BondMsgType {
+7 −3
Original line number Diff line number Diff line
@@ -100,9 +100,13 @@ void ClassicPairingHandler::OnPairingPromptAccepted(const bluetooth::hci::Addres
}

void ClassicPairingHandler::OnConfirmYesNo(const bluetooth::hci::AddressWithType& address, bool confirmed) {
  LOG_WARN("TODO Not Implemented!");
  if (confirmed) {
    GetChannel()->SendCommand(
        hci::UserConfirmationRequestReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress()));
  } else {
    GetChannel()->SendCommand(
        hci::UserConfirmationRequestNegativeReplyBuilder::Create(GetRecord()->GetPseudoAddress().GetAddress()));
  }
}

void ClassicPairingHandler::OnPasskeyEntry(const bluetooth::hci::AddressWithType& address, uint32_t passkey) {