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

Commit f35cfe0b authored by Henri Chataing's avatar Henri Chataing
Browse files

system/common: Migrate to libbluetooth_log

Test: m com.android.btservices
Bug: 305066880
Flag: EXEMPT, mechanical refactor
Change-Id: I04bae75c77e7fd421884f5ff122c794cf229d44e
parent ea107cc4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ cc_library_static {
    ],
    shared_libs: [
        "libchrome",
        "liblog",
    ],
    static_libs: [
        "libbase",
@@ -64,6 +65,7 @@ cc_library_host_shared {
        "libbluetooth_headers",
    ],
    static_libs: [
        "libbase",
        "libbluetooth_hci_pdl",
        "libbluetooth_log",
        "libbt-common",
@@ -72,6 +74,7 @@ cc_library_host_shared {
        "libevent",
        "libflatbuffers-cpp",
        "libgmock",
        "liblog",
    ],
    stl: "libc++_static",
    generated_headers: [
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ if (use.test) {
      "//bt/system:external_gtest_main",
      "//bt/system:external_gmock_main",
      "//bt/system:target_defaults",
      "//bt/system/log:log_defaults",
    ]

    libs = [
+6 −5
Original line number Diff line number Diff line
@@ -15,16 +15,17 @@
 *  limitations under the License.
 *
 ******************************************************************************/
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "common/leaky_bonded_queue.h"

#include <base/logging.h>

#include "common/leaky_bonded_queue.h"
#include <bluetooth/log.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>

namespace testing {

using bluetooth::common::LeakyBondedQueue;
using namespace bluetooth;

#define ITEM_EQ(a, b)                  \
  do {                                 \
@@ -72,7 +73,7 @@ TEST(LeakyBondedQueueTest, TestEnqueueDequeue) {
  ITEM_EQ(item3_3, item3);
  EXPECT_THAT(item4_4, NotNull());
  ITEM_EQ(item4_4, item4);
  LOG(INFO) << "All done release items";
  log::info("All done release items");
  EXPECT_CALL(*item2_2, Destruct()).Times(1);
  delete item2_2;
  EXPECT_CALL(*item3_3, Destruct()).Times(1);
+4 −3
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@

#pragma once

#include <base/logging.h>
#include <bluetooth/log.h>

#include <functional>
#include <iterator>
#include <list>
@@ -26,8 +29,6 @@
#include <thread>
#include <unordered_map>

#include <base/logging.h>

#include "check.h"

namespace bluetooth {
@@ -48,7 +49,7 @@ class LegacyLruCache {
      : capacity_(capacity) {
    if (capacity_ == 0) {
      // don't allow invalid capacity
      LOG(FATAL) << log_tag << " unable to have 0 LRU Cache capacity";
      log::fatal("{} unable to have 0 LRU Cache capacity", log_tag);
    }
  }

+16 −18
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <base/logging.h>
#include <base/strings/stringprintf.h>
#include <base/time/time.h>
#include <bluetooth/log.h>
#include <sys/syscall.h>
#include <unistd.h>

@@ -62,7 +63,7 @@ void MessageLoopThread::StartUp() {
  {
    std::lock_guard<std::recursive_mutex> api_lock(api_mutex_);
    if (thread_ != nullptr) {
      LOG(WARNING) << __func__ << ": thread " << *this << " is already started";
      log::warn("thread {} is already started", *this);

      return;
    }
@@ -84,15 +85,14 @@ bool MessageLoopThread::DoInThreadDelayed(const base::Location& from_here,
  std::lock_guard<std::recursive_mutex> api_lock(api_mutex_);

  if (message_loop_ == nullptr) {
    LOG(ERROR) << __func__ << ": message loop is null for thread " << *this
               << ", from " << from_here.ToString();
    log::error("message loop is null for thread {}, from {}", *this,
               from_here.ToString());
    return false;
  }
  if (!message_loop_->task_runner()->PostDelayedTask(
          from_here, std::move(task), timeDeltaFromMicroseconds(delay))) {
    LOG(ERROR) << __func__
               << ": failed to post task to message loop for thread " << *this
               << ", from " << from_here.ToString();
    log::error("failed to post task to message loop for thread {}, from {}",
               *this, from_here.ToString());
    return false;
  }
  return true;
@@ -102,15 +102,15 @@ void MessageLoopThread::ShutDown() {
  {
    std::lock_guard<std::recursive_mutex> api_lock(api_mutex_);
    if (thread_ == nullptr) {
      LOG(INFO) << __func__ << ": thread " << *this << " is already stopped";
      log::info("thread {} is already stopped", *this);
      return;
    }
    if (message_loop_ == nullptr) {
      LOG(INFO) << __func__ << ": message_loop_ is null. Already stopping";
      log::info("message_loop_ is null. Already stopping");
      return;
    }
    if (shutting_down_) {
      LOG(INFO) << __func__ << ": waiting for thread to join";
      log::info("waiting for thread to join");
      return;
    }
    shutting_down_ = true;
@@ -161,7 +161,7 @@ bool MessageLoopThread::EnableRealTimeScheduling() {
  std::lock_guard<std::recursive_mutex> api_lock(api_mutex_);

  if (!IsRunning()) {
    LOG(ERROR) << __func__ << ": thread " << *this << " is not running";
    log::error("thread {} is not running", *this);
    return false;
  }

@@ -169,10 +169,10 @@ bool MessageLoopThread::EnableRealTimeScheduling() {
                                      kRealTimeFifoSchedulingPriority};
  int rc = sched_setscheduler(linux_tid_, SCHED_FIFO, &rt_params);
  if (rc != 0) {
    LOG(ERROR) << __func__ << ": unable to set SCHED_FIFO priority "
               << kRealTimeFifoSchedulingPriority << " for linux_tid "
               << std::to_string(linux_tid_) << ", thread " << *this
               << ", error: " << strerror(errno);
    log::error(
        "unable to set SCHED_FIFO priority {} for linux_tid {}, thread {}, "
        "error: {}",
        kRealTimeFifoSchedulingPriority, linux_tid_, *this, strerror(errno));
    return false;
  }
  return true;
@@ -187,8 +187,7 @@ void MessageLoopThread::Run(std::promise<void> start_up_promise) {
  {
    std::lock_guard<std::recursive_mutex> api_lock(api_mutex_);

    LOG(INFO) << __func__ << ": message loop starting for thread "
              << thread_name_;
    log::info("message loop starting for thread {}", thread_name_);
    base::PlatformThread::SetName(thread_name_);
    message_loop_ = new btbase::AbstractMessageLoop();
    run_loop_ = new base::RunLoop();
@@ -208,8 +207,7 @@ void MessageLoopThread::Run(std::promise<void> start_up_promise) {
    message_loop_ = nullptr;
    delete run_loop_;
    run_loop_ = nullptr;
    LOG(INFO) << __func__ << ": message loop finished for thread "
              << thread_name_;
    log::info("message loop finished for thread {}", thread_name_);
  }
}

Loading