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

Commit f38308c5 authored by Chris Manton's avatar Chris Manton
Browse files

gd_shim: Use HACK_SetScoDisconnectCallback

Bug: 177382279
Tag: #refactor
Test: gd/cert/run

Change-Id: I9b5bead73332603a4f9024a8cd5c015008a1102b
parent 71de37e4
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include "gd/hci/controller.h"
#include "gd/os/handler.h"
#include "gd/os/queue.h"
#include "main/shim/btm.h"
#include "main/shim/dumpsys.h"
#include "main/shim/entry.h"
#include "main/shim/helpers.h"
@@ -792,6 +793,11 @@ bluetooth::shim::legacy::Acl::Acl(os::Handler* handler,
      handler->BindOn(this, &Acl::on_incoming_acl_credits));
  bluetooth::shim::RegisterDumpsysFunction(static_cast<void*>(this),
                                           [this](int fd) { Dump(fd); });
  Stack::GetInstance()->GetBtm()->Register_HACK_SetScoDisconnectCallback(
      [this](uint16_t handle, uint8_t reason) {
        TRY_POSTING_ON_MAIN(acl_interface_.connection.sco.on_disconnected,
                            handle, static_cast<tHCI_REASON>(reason));
      });
}

bluetooth::shim::legacy::Acl::~Acl() {
@@ -1133,6 +1139,12 @@ bool bluetooth::shim::legacy::Acl::SniffSubrating(
  return false;
}

void bluetooth::shim::legacy::Acl::HACK_OnScoDisconnected(uint16_t handle,
                                                          uint8_t reason) {
  TRY_POSTING_ON_MAIN(acl_interface_.connection.sco.on_disconnected, handle,
                      static_cast<tHCI_REASON>(reason));
}

void bluetooth::shim::legacy::Acl::DumpConnectionHistory(int fd) const {
  pimpl_->DumpConnectionHistory(fd);
}
+2 −0
Original line number Diff line number Diff line
@@ -74,6 +74,8 @@ class Acl : public hci::acl_manager::ConnectionCallbacks,
                      uint16_t minimum_remote_timeout,
                      uint16_t minimum_local_timeout) override;

  void HACK_OnScoDisconnected(uint16_t handle, uint8_t reason);

  void WriteData(uint16_t hci_handle,
                 std::unique_ptr<bluetooth::packet::RawBuilder> packet);

+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ const acl_interface_t GetAclInterface() {
      .connection.le.on_failed = acl_ble_connection_fail,
      .connection.le.on_disconnected = btm_acl_disconnected,

      .connection.sco.on_disconnected = nullptr,

      .link.classic.on_authentication_complete = btm_sec_auth_complete,
      .link.classic.on_central_link_key_complete = nullptr,
      .link.classic.on_change_connection_link_key_complete = nullptr,
+5 −0
Original line number Diff line number Diff line
@@ -47,6 +47,10 @@ typedef struct {
                          tHCI_STATUS reason);
} acl_le_connection_interface_t;

typedef struct {
  void (*on_disconnected)(uint16_t handle, tHCI_REASON reason);
} acl_sco_connection_interface_t;

typedef struct {
  void (*on_authentication_complete)(uint16_t handle, tHCI_STATUS status);
  void (*on_change_connection_link_key_complete)();
@@ -112,6 +116,7 @@ typedef struct {
typedef struct {
  acl_classic_connection_interface_t classic;
  acl_le_connection_interface_t le;
  acl_sco_connection_interface_t sco;
} acl_connection_interface_t;

typedef struct {