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

Commit 2e1ff556 authored by Jack He's avatar Jack He
Browse files

GD-Shim: Create a seaparate GD_IDL_MODULE to support and IDLE stack

* There is a transient state where Bluetooth stack is loaded but not
  enabled. Theoritically, we should be able to load stored Bluetooth
  adapter name and address and report it to the Java layer.
* Correspondingly, some GD modules also need to present there

Bug: 160101414
Test: enable GD and scan for devices
Tag: #gd-refactor
Change-Id: I637320c6796c31ccf43c9ae3a6d8c779db87ebf0
parent e389270c
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "btif_common.h"
#include "common/message_loop_thread.h"
#include "device/include/controller.h"
#include "main/shim/shim.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "osi/include/semaphore.h"
@@ -112,6 +113,9 @@ static void event_init_stack(void* context) {

    module_init(get_module(OSI_MODULE));
    module_init(get_module(BT_UTILS_MODULE));
    if (bluetooth::shim::is_gd_shim_enabled()) {
      module_start_up(get_module(GD_IDLE_MODULE));
    }
    module_init(get_module(BTIF_CONFIG_MODULE));
    btif_init_bluetooth();

@@ -147,7 +151,6 @@ static void event_start_up_stack(UNUSED_ATTR void* context) {
  hack_future = local_hack_future;

  // Include this for now to put btif config into a shutdown-able state
  module_start_up(get_module(BTIF_CONFIG_MODULE));
  bte_main_enable();

  if (future_await(local_hack_future) != FUTURE_SUCCESS) {
@@ -212,6 +215,7 @@ static void event_clean_up_stack(void* context) {
  module_clean_up(get_module(BTIF_CONFIG_MODULE));
  module_clean_up(get_module(BT_UTILS_MODULE));
  module_clean_up(get_module(OSI_MODULE));
  module_shut_down(get_module(GD_IDLE_MODULE));
  module_management_stop();
  LOG_INFO("%s finished", __func__);

+5 −16
Original line number Diff line number Diff line
@@ -27,30 +27,17 @@
#define LOG_TAG "bt_main"

#include <base/logging.h>
#include <base/threading/thread.h>
#include <fcntl.h>
#include <pthread.h>
#include <signal.h>
#include <stdlib.h>
#include <time.h>

#include <hardware/bluetooth.h>

#include "bt_common.h"
#include "bt_hci_bdroid.h"
#include "bt_utils.h"
#include "bta_api.h"
#include "btcore/include/module.h"
#include "bte.h"
#include "btif_common.h"
#include "btif/include/btif_config.h"
#include "btsnoop.h"
#include "btu.h"
#include "device/include/interop.h"
#include "hci_layer.h"
#include "hcimsgs.h"
#include "osi/include/alarm.h"
#include "osi/include/fixed_queue.h"
#include "osi/include/future.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "shim/hci_layer.h"
@@ -159,9 +146,11 @@ void bte_main_enable() {

  if (bluetooth::shim::is_gd_shim_enabled()) {
    LOG_INFO("%s Gd shim module enabled", __func__);
    module_shut_down(get_module(GD_IDLE_MODULE));
    module_start_up(get_module(GD_SHIM_MODULE));
    module_start_up(get_module(GD_HCI_MODULE));
    module_start_up(get_module(BTIF_CONFIG_MODULE));
  } else {
    module_start_up(get_module(BTIF_CONFIG_MODULE));
    module_start_up(get_module(BTSNOOP_MODULE));
    module_start_up(get_module(HCI_MODULE));
  }
@@ -184,8 +173,8 @@ void bte_main_disable(void) {

  if (bluetooth::shim::is_gd_shim_enabled()) {
    LOG_INFO("%s Gd shim module enabled", __func__);
    module_shut_down(get_module(GD_HCI_MODULE));
    module_shut_down(get_module(GD_SHIM_MODULE));
    module_start_up(get_module(GD_IDLE_MODULE));
  } else {
    module_shut_down(get_module(HCI_MODULE));
    module_shut_down(get_module(BTSNOOP_MODULE));
+1 −1
Original line number Diff line number Diff line
@@ -680,7 +680,7 @@ void Btm::StartAdvertising() {
    return;
  }

  hci::AdvertisingConfig config;
  hci::AdvertisingConfig config = {};
  advertiser_id_ = GetAdvertising()->CreateAdvertiser(
      config, common::Bind([](hci::Address, hci::AddressType) { /*OnScan*/ }),
      common::Bind([](hci::ErrorCode, uint8_t, uint8_t) { /*OnTerminated*/ }),
+0 −19
Original line number Diff line number Diff line
@@ -101,25 +101,6 @@ std::unique_ptr<bluetooth::packet::RawBuilder> MakeUniquePacket(
}
}  // namespace

static future_t* hci_module_shut_down(void);
static future_t* hci_module_start_up(void);

EXPORT_SYMBOL extern const module_t gd_hci_module = {
    .name = GD_HCI_MODULE,
    .init = nullptr,
    .start_up = hci_module_start_up,
    .shut_down = hci_module_shut_down,
    .clean_up = nullptr,
    .dependencies = {GD_SHIM_MODULE, nullptr}};

static future_t* hci_module_start_up(void) {
  return nullptr;
}

static future_t* hci_module_shut_down(void) {
  return nullptr;
}

static void set_data_cb(
    base::Callback<void(const base::Location&, BT_HDR*)> send_data_cb) {
  send_data_upwards = std::move(send_data_cb);
+0 −2
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@

#include "hci/include/hci_layer.h"

static const char GD_HCI_MODULE[] = "gd_hci_module";

namespace bluetooth {
namespace shim {

Loading