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

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

Add message loop post for shim layer

Bug: 142501664
Test: Compiles
Change-Id: Ia25f5ad4147bcd7206203bcb69bfcd0e901711f6
parent 0083002b
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -16,23 +16,47 @@

#include <cstdint>

#define LOG_TAG "bt_shim"

#include "common/message_loop_thread.h"
#include "main/shim/entry.h"
#include "main/shim/shim.h"
#include "osi/include/log.h"
#include "osi/include/properties.h"

static const char* kPropertyKey = "bluetooth.gd.enabled";

static bluetooth::common::MessageLoopThread bt_shim_thread("bt_shim_thread");

static bool gd_shim_enabled_ = false;
static bool gd_shim_property_checked_ = false;

future_t* ShimModuleStartUp() {
  bt_shim_thread.StartUp();
  CHECK(bt_shim_thread.IsRunning())
      << "Unable to start bt shim message loop thread.";
  bluetooth::shim::StartGabeldorscheStack();
  return nullptr;
}

future_t* ShimModuleShutDown() {
  bluetooth::shim::StopGabeldorscheStack();
  bt_shim_thread.ShutDown();
  return nullptr;
}

EXPORT_SYMBOL extern const module_t gd_shim_module = {
    .name = GD_SHIM_MODULE,
    .init = nullptr,
    .start_up = bluetooth::shim::StartGabeldorscheStack,
    .shut_down = bluetooth::shim::StopGabeldorscheStack,
    .start_up = ShimModuleStartUp,
    .shut_down = ShimModuleShutDown,
    .clean_up = NULL,
    .dependencies = {NULL}};

void bluetooth::shim::Post(base::OnceClosure task) {
  bt_shim_thread.DoInThread(FROM_HERE, std::move(task));
}

bool bluetooth::shim::is_gd_shim_enabled() {
  if (!gd_shim_property_checked_) {
    gd_shim_property_checked_ = true;
+20 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
/**
 * Gabeldorsche related legacy-only-stack-side expansion and support code.
 */
#include "base/bind.h"
#include "btcore/include/module.h"
#include "main/shim/entry.h"

@@ -27,7 +28,26 @@ static const char GD_SHIM_MODULE[] = "gd_shim_module";
namespace bluetooth {
namespace shim {

/**
 * Checks if the bluetooth stack is running in legacy or gd mode.
 *
 * This check is used throughout the legacy stack to determine which
 * methods, classes or functions to invoke.  The default (false) mode
 * is the legacy mode which runs the original legacy bluetooth stack.
 * When enabled (true) the core portion of the gd stack is invoked
 * at key points to execute equivalent functionality using the
 * gd core components.
 *
 * @return true if using gd shim core, false if using legacy.
 */
bool is_gd_shim_enabled();

/**
 * Posts a task on the shim message queue.
 *
 * @param task Task to be posted onto the message queue.
 */
void Post(base::OnceClosure task);

}  // namespace shim
}  // namespace bluetooth