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

Commit 4163fb2b authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files
parents 692cce27 92ac86d2
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -129,9 +129,7 @@ static_library("bta") {

  deps = [
    "//bt/system:libbt-platform-protos-lite",
    "//bt/system/gd/rust/shim:shim_bridge_header",
    "//bt/system/gd/rust/shim:init_flags_bridge_header",
    "//bt/system/gd/rust/shim:message_loop_thread_bridge_header",
  ]
}

+0 −1
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ static_library("btcore") {
  deps = [
    "//bt/system/gd/rust/shim:init_flags_bridge_header",
    "//bt/system/gd/rust/shim:libbluetooth_rust_interop",
    "//bt/system/gd/rust/shim:message_loop_thread_bridge_header",
  ]
}

+0 −1
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ cc_defaults {
        "libbluetooth-types",
        "libbluetooth_rust_interop",
        "libbt-common",
        "libbt_callbacks_cxx",
        "libbt_shim_bridge",
        "libbt_shim_ffi",
        "libbtcore",
+1 −7
Original line number Diff line number Diff line
@@ -94,21 +94,15 @@ cc_defaults {
        },
    },
    defaults: ["fluoride_types_defaults_fuzzable"],
    header_libs: [
        "libbluetooth_headers",
        "libbt_callbacks_cxx_headers",
    ],
    header_libs: ["libbluetooth_headers"],
    generated_headers: [
        "cxx-bridge-header",
        "libbt_message_loop_thread_bridge_header",
        "libbt_shim_bridge_header",
    ],
    include_dirs: ["packages/modules/Bluetooth/system/gd/rust/shim"],
    static_libs: [
        "libbluetooth-types",
        "libbluetooth_rust_interop",
        "libbt-platform-protos-lite",
        "libbt_callbacks_cxx",
        "libbt_shim_bridge",
        "libbt_shim_ffi",
    ],
+5 −42
Original line number Diff line number Diff line
@@ -16,12 +16,12 @@

#include "message_loop_thread.h"

#include <base/logging.h>
#include <base/strings/stringprintf.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <thread>

#include <base/logging.h>
#include <base/strings/stringprintf.h>
#include <thread>

#include "gd/common/init_flags.h"
#include "osi/include/log.h"
@@ -45,22 +45,11 @@ MessageLoopThread::MessageLoopThread(const std::string& thread_name,
      linux_tid_(-1),
      weak_ptr_factory_(this),
      shutting_down_(false),
      is_main_(is_main),
      rust_thread_(nullptr) {}
      is_main_(is_main) {}

MessageLoopThread::~MessageLoopThread() { ShutDown(); }

void MessageLoopThread::StartUp() {
  if (is_main_ && init_flags::gd_rust_is_enabled()) {
    rust_thread_ = new ::rust::Box<shim::rust::MessageLoopThread>(
        shim::rust::main_message_loop_thread_create());
    auto rust_id =
        bluetooth::shim::rust::main_message_loop_thread_start(**rust_thread_);
    thread_id_ = rust_id;
    linux_tid_ = rust_id;
    return;
  }

  std::promise<void> start_up_promise;
  std::future<void> start_up_future = start_up_promise.get_future();
  {
@@ -85,19 +74,6 @@ bool MessageLoopThread::DoInThreadDelayed(const base::Location& from_here,
                                          base::OnceClosure task,
                                          const base::TimeDelta& delay) {
  std::lock_guard<std::recursive_mutex> api_lock(api_mutex_);
  if (is_main_ && init_flags::gd_rust_is_enabled()) {
    if (rust_thread_ == nullptr) {
      LOG(ERROR) << __func__ << ": rust thread is null for thread " << *this
                 << ", from " << from_here.ToString();
      return false;
    }

    shim::rust::main_message_loop_thread_do_delayed(
        **rust_thread_,
        std::make_unique<shim::rust::OnceClosure>(std::move(task)),
        delay.InMilliseconds());
    return true;
  }

  if (message_loop_ == nullptr) {
    LOG(ERROR) << __func__ << ": message loop is null for thread " << *this
@@ -116,14 +92,6 @@ bool MessageLoopThread::DoInThreadDelayed(const base::Location& from_here,

void MessageLoopThread::ShutDown() {
  {
    if (is_main_ && init_flags::gd_rust_is_enabled()) {
      delete rust_thread_;
      rust_thread_ = nullptr;
      thread_id_ = -1;
      linux_tid_ = -1;
      return;
    }

    std::lock_guard<std::recursive_mutex> api_lock(api_mutex_);
    if (thread_ == nullptr) {
      LOG(INFO) << __func__ << ": thread " << *this << " is already stopped";
@@ -157,9 +125,7 @@ base::PlatformThreadId MessageLoopThread::GetThreadId() const {
  return thread_id_;
}

std::string MessageLoopThread::GetName() const {
  return thread_name_;
}
std::string MessageLoopThread::GetName() const { return thread_name_; }

std::string MessageLoopThread::ToString() const {
  std::lock_guard<std::recursive_mutex> api_lock(api_mutex_);
@@ -214,9 +180,6 @@ base::WeakPtr<MessageLoopThread> MessageLoopThread::GetWeakPtr() {
void MessageLoopThread::Run(std::promise<void> start_up_promise) {
  {
    std::lock_guard<std::recursive_mutex> api_lock(api_mutex_);
    if (is_main_ && init_flags::gd_rust_is_enabled()) {
      return;
    }

    LOG(INFO) << __func__ << ": message loop starting for thread "
              << thread_name_;
Loading