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

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

Merge changes from topic "gd_sm_ui_wiring" am: 8e3df1a2 am: de5d439e

Change-Id: Ic15b6939955db7de2be1825657f327f32d4934aa
parents f2b54247 de5d439e
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -68,12 +68,10 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public
                                ::google::protobuf::Empty* response) override {
    switch (request->message_type()) {
      case UiCallbackType::PASSKEY:
        security_handler_->Post(
            common::BindOnce(std::move(user_passkey_callbacks_[request->unique_id()]), request->numeric_value()));
        // TODO: security_module_->GetSecurityManager()->OnPasskeyEntry();
        break;
      case UiCallbackType::YES_NO:
        security_handler_->Post(
            common::BindOnce(std::move(user_yes_no_callbacks_[request->unique_id()]), request->boolean()));
        // TODO: security_module_->GetSecurityManager()->OnConfirmYesNo(request->boolean());
        break;
      default:
        LOG_ERROR("Unknown UiCallbackType %d", static_cast<int>(request->message_type()));
+33 −2
Original line number Diff line number Diff line
@@ -172,8 +172,8 @@ void SecurityManagerImpl::HandleEvent(T packet) {

    const hci::EventCode code = event.GetEventCode();
    if (code != hci::EventCode::LINK_KEY_REQUEST) {
      LOG_ERROR("No classic pairing handler for device '%s' ready for command '%hhx' ", bd_addr.ToString().c_str(),
                event_code);
      LOG_ERROR("No classic pairing handler for device '%s' ready for command %s ", bd_addr.ToString().c_str(),
                hci::EventCodeText(event_code).c_str());
      return;
    }

@@ -254,6 +254,37 @@ void SecurityManagerImpl::OnHciLeEvent(hci::LeMetaEventView event) {
  LOG_ERROR("Unhandled HCI LE security event");
}

void SecurityManagerImpl::OnPairingPromptAccepted(const bluetooth::hci::AddressWithType& address, bool confirmed) {
  auto entry = pairing_handler_map_.find(address.GetAddress());
  if (entry != pairing_handler_map_.end()) {
    entry->second->OnPairingPromptAccepted(address, confirmed);
  } else {
    pending_le_pairing_.handler_->OnUiAction(PairingEvent::UI_ACTION_TYPE::PAIRING_ACCEPTED, confirmed);
  }
}

void SecurityManagerImpl::OnConfirmYesNo(const bluetooth::hci::AddressWithType& address, bool confirmed) {
  auto entry = pairing_handler_map_.find(address.GetAddress());
  if (entry != pairing_handler_map_.end()) {
    entry->second->OnConfirmYesNo(address, confirmed);
  } else {
    if (pending_le_pairing_.address_ == address) {
      pending_le_pairing_.handler_->OnUiAction(PairingEvent::UI_ACTION_TYPE::CONFIRM_YESNO, confirmed);
    }
  }
}

void SecurityManagerImpl::OnPasskeyEntry(const bluetooth::hci::AddressWithType& address, uint32_t passkey) {
  auto entry = pairing_handler_map_.find(address.GetAddress());
  if (entry != pairing_handler_map_.end()) {
    entry->second->OnPasskeyEntry(address, passkey);
  } else {
    if (pending_le_pairing_.address_ == address) {
      pending_le_pairing_.handler_->OnUiAction(PairingEvent::UI_ACTION_TYPE::PASSKEY, passkey);
    }
  }
}

void SecurityManagerImpl::OnPairingHandlerComplete(hci::Address address, PairingResultOrFailure status) {
  auto entry = pairing_handler_map_.find(address);
  if (entry != pairing_handler_map_.end()) {
+7 −2
Original line number Diff line number Diff line
@@ -37,12 +37,12 @@ class ISecurityManagerListener;

namespace internal {

class SecurityManagerImpl : public channel::ISecurityManagerChannelListener {
class SecurityManagerImpl : public channel::ISecurityManagerChannelListener, public UICallbacks {
 public:
  explicit SecurityManagerImpl(os::Handler* security_handler, l2cap::le::L2capLeModule* l2cap_le_module,
                               l2cap::classic::L2capClassicModule* l2cap_classic_module,
                               channel::SecurityManagerChannel* security_manager_channel, hci::HciLayer* hci_layer);
  virtual ~SecurityManagerImpl() = default;
  ~SecurityManagerImpl() = default;

  // All APIs must be invoked in SM layer handler

@@ -120,6 +120,11 @@ class SecurityManagerImpl : public channel::ISecurityManagerChannelListener {
   */
  void OnPairingHandlerComplete(hci::Address address, PairingResultOrFailure status);

  // UICallbacks implementation
  void OnPairingPromptAccepted(const bluetooth::hci::AddressWithType& address, bool confirmed) override;
  void OnConfirmYesNo(const bluetooth::hci::AddressWithType& address, bool confirmed) override;
  void OnPasskeyEntry(const bluetooth::hci::AddressWithType& address, uint32_t passkey) override;

 protected:
  std::vector<std::pair<ISecurityManagerListener*, os::Handler*>> listeners_;
  UI* user_interface_ = nullptr;
+14 −0
Original line number Diff line number Diff line
@@ -90,6 +90,20 @@ void ClassicPairingHandler::OnConnectionClose(hci::ErrorCode error_code) {
  Cancel();
}

void ClassicPairingHandler::OnPairingPromptAccepted(const bluetooth::hci::AddressWithType& address, bool confirmed) {
  LOG_WARN("TODO Not Implemented!");
}

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

void ClassicPairingHandler::OnPasskeyEntry(const bluetooth::hci::AddressWithType& address, uint32_t passkey) {
  LOG_WARN("TODO Not Implemented!");
}

void ClassicPairingHandler::Initiate(bool locally_initiated, hci::IoCapability io_capability,
                                     hci::OobDataPresent oob_present,
                                     hci::AuthenticationRequirements auth_requirements) {
+4 −0
Original line number Diff line number Diff line
@@ -76,6 +76,10 @@ class ClassicPairingHandler : public PairingHandler {
  void OnReceive(hci::UserConfirmationRequestView packet) override;
  void OnReceive(hci::UserPasskeyRequestView packet) override;

  void OnPairingPromptAccepted(const bluetooth::hci::AddressWithType& address, bool confirmed) override;
  void OnConfirmYesNo(const bluetooth::hci::AddressWithType& address, bool confirmed) override;
  void OnPasskeyEntry(const bluetooth::hci::AddressWithType& address, uint32_t passkey) override;

 private:
  void OnRegistrationComplete(l2cap::classic::FixedChannelManager::RegistrationResult result,
                              std::unique_ptr<l2cap::classic::FixedChannelService> fixed_channel_service);
Loading