OSDN Git Service

GD-Controller: Do not register NumberOfCompletedPacket without ACL layer
authorJack He <siyuanh@google.com>
Fri, 16 Oct 2020 22:22:22 +0000 (15:22 -0700)
committerJack He <siyuanh@google.com>
Fri, 16 Oct 2020 22:24:09 +0000 (15:24 -0700)
* Only register it when ACL layer is enabled
* Also hci layer event is only registered by HCI lyaer when HCI layer
  is enabled

Test: make, pair and connect Bluetooth devices
Bug: 170603745
Tag: #gd-refactor
Change-Id: Icc94d239c28ba58ceffebee1061b4f8042afecc5

gd/hci/controller.cc
main/shim/hci_layer.cc

index b511641..23e9349 100644 (file)
@@ -35,8 +35,10 @@ struct Controller::impl {
   void Start(hci::HciLayer* hci) {
     hci_ = hci;
     Handler* handler = module_.GetHandler();
-    hci_->RegisterEventHandler(
-        EventCode::NUMBER_OF_COMPLETED_PACKETS, handler->BindOn(this, &Controller::impl::NumberOfCompletedPackets));
+    if (common::InitFlags::GdAclEnabled()) {
+      hci_->RegisterEventHandler(
+          EventCode::NUMBER_OF_COMPLETED_PACKETS, handler->BindOn(this, &Controller::impl::NumberOfCompletedPackets));
+    }
 
     le_set_event_mask(kDefaultLeEventMask);
     set_event_mask(kDefaultEventMask);
index 93c89a3..6ad79f6 100644 (file)
@@ -223,7 +223,7 @@ static bool event_already_registered_in_hci_layer(
     case bluetooth::hci::EventCode::PAGE_SCAN_REPETITION_MODE_CHANGE:
     case bluetooth::hci::EventCode::MAX_SLOTS_CHANGE:
     case bluetooth::hci::EventCode::VENDOR_SPECIFIC:
-      return true;
+      return bluetooth::shim::is_gd_hci_enabled();
     case bluetooth::hci::EventCode::LE_META_EVENT:
     case bluetooth::hci::EventCode::DISCONNECTION_COMPLETE:
       return bluetooth::shim::is_gd_shim_enabled();
@@ -236,7 +236,7 @@ static bool event_already_registered_in_controller_layer(
     bluetooth::hci::EventCode event_code) {
   switch (event_code) {
     case bluetooth::hci::EventCode::NUMBER_OF_COMPLETED_PACKETS:
-      return bluetooth::shim::is_gd_controller_enabled();
+      return bluetooth::shim::is_gd_acl_enabled();
     default:
       return false;
   }