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

Commit 9fb7ecca authored by Henri Chataing's avatar Henri Chataing Committed by Gerrit Code Review
Browse files

Merge changes Ic100ac15,I2be3e576 into main

* changes:
  system/main: Migrate to libbluetooth_log
  system/osi: Migrate to libbluetooth_log
parents 66746818 991d6f59
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ cc_test {
        },
    },
    shared_libs: [
        "libbase",
        "libcrypto",
        "liblog",
    ],
@@ -104,6 +105,7 @@ cc_test {
        "libbluetooth-types",
        "libbluetooth_crypto_toolbox",
        "libbluetooth_log",
        "libbluetooth_log",
        "libbt-common",
        "libbt-platform-protos-lite",
        "libbt_shim_bridge",
@@ -135,9 +137,11 @@ cc_test {
        "test/thread_performance_test.cc",
    ],
    shared_libs: [
        "libbase",
        "liblog",
    ],
    static_libs: [
        "libbluetooth_log",
        "libbt-common",
        "libchrome",
        "libevent",
@@ -162,9 +166,11 @@ cc_benchmark {
        "benchmark/thread_performance_benchmark.cc",
    ],
    shared_libs: [
        "libbase",
        "liblog",
    ],
    static_libs: [
        "libbluetooth_log",
        "libbt-common",
        "libchrome",
        "libevent",
+18 −15
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@

#define LOG_TAG "bt_bte_conf"

#include <bluetooth/log.h>

#include <cstdint>
#include <cstdio>
#include <memory>
@@ -28,6 +30,8 @@
#include "osi/include/compat.h"  // strlcpy
#include "osi/include/config.h"

using namespace bluetooth;

// Parses the specified Device ID configuration file and registers the
// Device ID records with SDP.
void bte_load_did_conf(const char* p_path) {
@@ -35,7 +39,7 @@ void bte_load_did_conf(const char* p_path) {

  std::unique_ptr<config_t> config = config_new(p_path);
  if (!config) {
    LOG_ERROR("%s unable to load DID config '%s'.", __func__, p_path);
    log::error("unable to load DID config '{}'.", p_path);
    return;
  }

@@ -44,7 +48,7 @@ void bte_load_did_conf(const char* p_path) {
    snprintf(section_name, sizeof(section_name), "DID%d", i);

    if (!config_has_section(*config, section_name)) {
      LOG_INFO("%s no section named %s.", __func__, section_name);
      log::info("no section named {}.", section_name);
      break;
    }

@@ -75,26 +79,25 @@ void bte_load_did_conf(const char* p_path) {

    if (record.vendor_id_source != DI_VENDOR_ID_SOURCE_BTSIG &&
        record.vendor_id_source != DI_VENDOR_ID_SOURCE_USBIF) {
      LOG_ERROR("%s invalid vendor id source %d; ignoring DID record %d.",
                __func__, record.vendor_id_source, i);
      log::error("invalid vendor id source {}; ignoring DID record {}.",
                 record.vendor_id_source, i);
      continue;
    }

    LOG_INFO("Device ID record %d : %s", i,
    log::info("Device ID record {} : {}", i,
              (record.primary_record ? "primary" : "not primary"));
    LOG_INFO("  vendorId            = %04x", record.vendor);
    LOG_INFO("  vendorIdSource      = %04x", record.vendor_id_source);
    LOG_INFO("  product             = %04x", record.product);
    LOG_INFO("  version             = %04x", record.version);
    LOG_INFO("  clientExecutableURL = %s", record.client_executable_url);
    LOG_INFO("  serviceDescription  = %s", record.service_description);
    LOG_INFO("  documentationURL    = %s", record.documentation_url);
    log::info("vendorId            = {:04x}", record.vendor);
    log::info("vendorIdSource      = {:04x}", record.vendor_id_source);
    log::info("product             = {:04x}", record.product);
    log::info("version             = {:04x}", record.version);
    log::info("clientExecutableURL = {}", record.client_executable_url);
    log::info("serviceDescription  = {}", record.service_description);
    log::info("documentationURL    = {}", record.documentation_url);

    uint32_t record_handle;
    tBTA_STATUS status = BTA_DmSetLocalDiRecord(&record, &record_handle);
    if (status != BTA_SUCCESS) {
      LOG_ERROR("%s unable to set device ID record %d: error %d.", __func__, i,
                status);
      log::error("unable to set device ID record {}: error {}.", i, status);
    }
  }
}
+3 −1
Original line number Diff line number Diff line
@@ -18,12 +18,14 @@
#include <base/command_line.h>
#include <base/logging.h>
#include <base/strings/stringprintf.h>
#include <bluetooth/log.h>
#include <os/log.h>

#include "main_int.h"

#ifdef TARGET_FLOSS
#include <syslog.h>

static bool MessageHandler(int severity, const char* file, int line,
                           size_t message_start, const std::string& message) {
  ASSERT(message_start <= message.size());
@@ -91,7 +93,7 @@ void init_cpp_logging(config_t* config) {
  logging::LoggingSettings log_settings;

  if (!logging::InitLogging(log_settings)) {
    LOG_ERROR("Failed to set up logging");
    bluetooth::log::error("Failed to set up logging");
  }

  // Android already logs thread_id, proc_id, timestamp, so disable those.
+132 −128

File changed.

Preview size limit exceeded, changes collapsed.

+26 −31
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include "main/shim/btm.h"

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

#include <chrono>
#include <cstddef>
@@ -42,6 +43,8 @@
#include "types/bt_transport.h"
#include "types/raw_address.h"

using namespace bluetooth;

extern tBTM_CB btm_cb;

static constexpr bool kActiveScanning = true;
@@ -185,7 +188,7 @@ bool Btm::StartInquiry(
    LegacyInquiryCompleteCallback legacy_inquiry_complete_callback) {
  switch (mode) {
    case kInquiryModeOff:
      LOG_INFO("%s Stopping inquiry mode", __func__);
      log::info("Stopping inquiry mode");
      if (limited_inquiry_active_ || general_inquiry_active_) {
        GetInquiry()->StopInquiry();
        limited_inquiry_active_ = false;
@@ -197,18 +200,14 @@ bool Btm::StartInquiry(
    case kLimitedInquiryMode:
    case kGeneralInquiryMode: {
      if (mode == kLimitedInquiryMode) {
        LOG_INFO(

            "%s Starting limited inquiry mode duration:%hhd max responses:%hhd",
            __func__, duration, max_responses);
        log::info("Starting limited inquiry mode duration:{} max responses:{}",
                  duration, max_responses);
        limited_inquiry_active_ = true;
        GetInquiry()->StartLimitedInquiry(duration, max_responses);
        active_inquiry_mode_ = kLimitedInquiryMode;
      } else {
        LOG_INFO(

            "%s Starting general inquiry mode duration:%hhd max responses:%hhd",
            __func__, duration, max_responses);
        log::info("Starting general inquiry mode duration:{} max responses:{}",
                  duration, max_responses);
        general_inquiry_active_ = true;
        GetInquiry()->StartGeneralInquiry(duration, max_responses);
        legacy_inquiry_complete_callback_ = legacy_inquiry_complete_callback;
@@ -216,14 +215,14 @@ bool Btm::StartInquiry(
    } break;

    default:
      LOG_WARN("%s Unknown inquiry mode:%d", __func__, mode);
      log::warn("Unknown inquiry mode:{}", mode);
      return false;
  }
  return true;
}

void Btm::CancelInquiry() {
  LOG_INFO("%s", __func__);
  log::info("");
  if (limited_inquiry_active_ || general_inquiry_active_) {
    GetInquiry()->StopInquiry();
    limited_inquiry_active_ = false;
@@ -256,12 +255,12 @@ bool Btm::StartPeriodicInquiry(uint8_t mode, uint8_t duration,
    case kLimitedInquiryMode:
    case kGeneralInquiryMode: {
      if (mode == kLimitedInquiryMode) {
        LOG_INFO("%s Starting limited periodic inquiry mode", __func__);
        log::info("Starting limited periodic inquiry mode");
        limited_periodic_inquiry_active_ = true;
        GetInquiry()->StartLimitedPeriodicInquiry(duration, max_responses,
                                                  max_delay, min_delay);
      } else {
        LOG_INFO("%s Starting general periodic inquiry mode", __func__);
        log::info("Starting general periodic inquiry mode");
        general_periodic_inquiry_active_ = true;
        GetInquiry()->StartGeneralPeriodicInquiry(duration, max_responses,
                                                  max_delay, min_delay);
@@ -269,7 +268,7 @@ bool Btm::StartPeriodicInquiry(uint8_t mode, uint8_t duration,
    } break;

    default:
      LOG_WARN("%s Unknown inquiry mode:%d", __func__, mode);
      log::warn("Unknown inquiry mode:{}", mode);
      return false;
  }
  return true;
@@ -324,15 +323,11 @@ DiscoverabilityState Btm::GetClassicDiscoverabilityState() const {
  return state;
}

void Btm::SetLeGeneralDiscoverability() {
  LOG_WARN("UNIMPLEMENTED %s", __func__);
}
void Btm::SetLeGeneralDiscoverability() { log::warn("UNIMPLEMENTED"); }

void Btm::SetLeLimitedDiscoverability() {
  LOG_WARN("UNIMPLEMENTED %s", __func__);
}
void Btm::SetLeLimitedDiscoverability() { log::warn("UNIMPLEMENTED"); }

void Btm::SetLeDiscoverabilityOff() { LOG_WARN("UNIMPLEMENTED %s", __func__); }
void Btm::SetLeDiscoverabilityOff() { log::warn("UNIMPLEMENTED"); }

DiscoverabilityState Btm::GetLeDiscoverabilityState() const {
  DiscoverabilityState state{
@@ -340,7 +335,7 @@ DiscoverabilityState Btm::GetLeDiscoverabilityState() const {
      .interval = 0,
      .window = 0,
  };
  LOG_WARN("UNIMPLEMENTED %s", __func__);
  log::warn("UNIMPLEMENTED");
  return state;
}

@@ -371,9 +366,9 @@ void Btm::SetInterlacedPageScan() { GetPage()->SetInterlacedScan(); }

void Btm::SetStandardPageScan() { GetPage()->SetStandardScan(); }

void Btm::SetLeConnectibleOn() { LOG_WARN("UNIMPLEMENTED %s", __func__); }
void Btm::SetLeConnectibleOn() { log::warn("UNIMPLEMENTED"); }

void Btm::SetLeConnectibleOff() { LOG_WARN("UNIMPLEMENTED %s", __func__); }
void Btm::SetLeConnectibleOff() { log::warn("UNIMPLEMENTED"); }

ConnectabilityState Btm::GetLeConnectabilityState() const {
  ConnectabilityState state{
@@ -381,7 +376,7 @@ ConnectabilityState Btm::GetLeConnectabilityState() const {
      .interval = 0,
      .window = 0,
  };
  LOG_WARN("UNIMPLEMENTED %s", __func__);
  log::warn("UNIMPLEMENTED");
  return state;
}

@@ -399,25 +394,25 @@ bool Btm::UseLeLink(const RawAddress& raw_address) const {

BtmStatus Btm::ReadClassicRemoteDeviceName(const RawAddress& /* raw_address */,
                                           tBTM_NAME_CMPL_CB* /* callback */) {
  LOG_ALWAYS_FATAL("unreachable");
  log::fatal("unreachable");
  return BTM_UNDEFINED;
}

BtmStatus Btm::CancelAllReadRemoteDeviceName() {
  LOG_ALWAYS_FATAL("unreachable");
  log::fatal("unreachable");
  return BTM_UNDEFINED;
}

void Btm::StartAdvertising() { LOG_ALWAYS_FATAL("unreachable"); }
void Btm::StartAdvertising() { log::fatal("unreachable"); }

void Btm::StopAdvertising() {
  if (advertiser_id_ == hci::LeAdvertisingManager::kInvalidId) {
    LOG_WARN("%s No active advertising", __func__);
    log::warn("No active advertising");
    return;
  }
  GetAdvertising()->RemoveAdvertiser(advertiser_id_);
  advertiser_id_ = hci::LeAdvertisingManager::kInvalidId;
  LOG_INFO("%s Stopped advertising", __func__);
  log::info("Stopped advertising");
}

void Btm::StartConnectability() { StartAdvertising(); }
@@ -482,7 +477,7 @@ hci::AddressWithType Btm::GetAddressAndType(const RawAddress& bd_addr) {
                               p_dev_rec->ble.AddressType());
    }
  }
  LOG(ERROR) << "Unknown bd_addr. Use public address";
  log::error("Unknown bd_addr. Use public address");
  return ToAddressWithType(bd_addr, BLE_ADDR_PUBLIC);
}

Loading