OSDN Git Service

gd_shim: Use HACK_SetScoDisconnectCallback
authorChris Manton <cmanton@google.com>
Sat, 16 Jan 2021 02:43:39 +0000 (18:43 -0800)
committerChris Manton <cmanton@google.com>
Wed, 20 Jan 2021 07:12:58 +0000 (23:12 -0800)
Bug: 177382279
Tag: #refactor
Test: gd/cert/run

Change-Id: I9b5bead73332603a4f9024a8cd5c015008a1102b

main/shim/acl.cc
main/shim/acl.h
main/shim/acl_legacy_interface.cc
main/shim/acl_legacy_interface.h

index 382c187..b9f824e 100644 (file)
@@ -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);
 }
index 41fc397..127962a 100644 (file)
@@ -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);
 
index 02c6371..7fbeb2e 100644 (file)
@@ -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,
index 9747162..51196b7 100644 (file)
@@ -48,6 +48,10 @@ typedef struct {
 } 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)();
   void (*on_encryption_change)(bool enabled);
@@ -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 {