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

Commit 5c03a6e6 authored by Henri Chataing's avatar Henri Chataing Committed by Gerrit Code Review
Browse files

Merge "system/btif: Migrate to libbluetooth_log" into main

parents 0b4c0bb6 39203e70
Loading
Loading
Loading
Loading
+17 −23
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <base/logging.h>
#include <base/task/cancelable_task_tracker.h>
#include <base/threading/thread.h>
#include <bluetooth/log.h>

#include <mutex>
#include <sstream>
@@ -374,7 +375,7 @@ class PlayerSettingsInterfaceWrapper : public PlayerSettingsInterface {
void AvrcpService::Init(MediaInterface* media_interface,
                        VolumeInterface* volume_interface,
                        PlayerSettingsInterface* player_settings_interface) {
  LOG(INFO) << "AVRCP Target Service started";
  log::info("AVRCP Target Service started");

  profile_version = avrcp_interface_.GetAvrcpVersion();

@@ -435,7 +436,7 @@ uint16_t AvrcpService::GetSupportedFeatures(uint16_t profile_version) {
}

void AvrcpService::Cleanup() {
  LOG(INFO) << "AVRCP Target Service stopped";
  log::info("AVRCP Target Service stopped");

  avrcp_interface_.RemoveRecord(sdp_record_handle);
  bta_sys_remove_uuid(UUID_SERVCLASS_AV_REM_CTRL_TARGET);
@@ -456,8 +457,8 @@ void AvrcpService::Cleanup() {
}

void AvrcpService::RegisterBipServer(int psm) {
  LOG(INFO) << "AVRCP Target Service has registered a BIP OBEX server, psm="
            << psm;
  log::info("AVRCP Target Service has registered a BIP OBEX server, psm={}",
            psm);
  avrcp_interface_.RemoveRecord(sdp_record_handle);
  uint16_t supported_features
      = GetSupportedFeatures(profile_version) | AVRC_SUPF_TG_PLAYER_COVER_ART;
@@ -469,7 +470,7 @@ void AvrcpService::RegisterBipServer(int psm) {
}

void AvrcpService::UnregisterBipServer() {
  LOG(INFO) << "AVRCP Target Service has unregistered a BIP OBEX server";
  log::info("AVRCP Target Service has unregistered a BIP OBEX server");
  avrcp_interface_.RemoveRecord(sdp_record_handle);
  uint16_t supported_features = GetSupportedFeatures(profile_version);
  sdp_record_handle = get_legacy_stack_sdp_api()->handle.SDP_CreateRecord();
@@ -493,32 +494,27 @@ ServiceInterface* AvrcpService::GetServiceInterface() {
}

void AvrcpService::ConnectDevice(const RawAddress& bdaddr) {
  LOG(INFO) << __PRETTY_FUNCTION__
            << ": address=" << ADDRESS_TO_LOGGABLE_STR(bdaddr);
  log::info("address={}", ADDRESS_TO_LOGGABLE_STR(bdaddr));

  connection_handler_->ConnectDevice(bdaddr);
}

void AvrcpService::DisconnectDevice(const RawAddress& bdaddr) {
  LOG(INFO) << __PRETTY_FUNCTION__
            << ": address=" << ADDRESS_TO_LOGGABLE_STR(bdaddr);
  log::info("address={}", ADDRESS_TO_LOGGABLE_STR(bdaddr));
  connection_handler_->DisconnectDevice(bdaddr);
}

void AvrcpService::SetBipClientStatus(const RawAddress& bdaddr,
                                      bool connected) {
  LOG(INFO) << __PRETTY_FUNCTION__
            << ": address=" << ADDRESS_TO_LOGGABLE_STR(bdaddr)
            << ", connected=" << connected;
  log::info("address={}, connected={}", ADDRESS_TO_LOGGABLE_STR(bdaddr),
            connected);
  connection_handler_->SetBipClientStatus(bdaddr, connected);
}

void AvrcpService::SendMediaUpdate(bool track_changed, bool play_state,
                                   bool queue) {
  LOG(INFO) << __PRETTY_FUNCTION__ << " track_changed=" << track_changed
            << " : "
            << " play_state=" << play_state << " : "
            << " queue=" << queue;
  log::info("track_changed={} :  play_state={} :  queue={}", track_changed,
            play_state, queue);

  // This function may be called on any thread, we need to make sure that the
  // device update happens on the main thread.
@@ -532,10 +528,8 @@ void AvrcpService::SendMediaUpdate(bool track_changed, bool play_state,

void AvrcpService::SendFolderUpdate(bool available_players,
                                    bool addressed_players, bool uids) {
  LOG(INFO) << __PRETTY_FUNCTION__ << " available_players=" << available_players
            << " : "
            << " addressed_players=" << addressed_players << " : "
            << " uids=" << uids;
  log::info("available_players={} :  addressed_players={} :  uids={}",
            available_players, addressed_players, uids);

  // Ensure that the update is posted to the correct thread
  for (const auto& device :
@@ -554,7 +548,7 @@ void AvrcpService::SendActiveDeviceChanged(const RawAddress& address) {

void AvrcpService::SendPlayerSettingsChanged(
    std::vector<PlayerAttribute> attributes, std::vector<uint8_t> values) {
  LOG(INFO) << __PRETTY_FUNCTION__;
  log::info("");
  std::stringstream ss;
  for (size_t i = 0; i < attributes.size(); i++) {
    ss << "attribute=" << attributes.at(i) << " : ";
@@ -568,7 +562,7 @@ void AvrcpService::SendPlayerSettingsChanged(
    ss << std::endl;
  }

  LOG(INFO) << ss.str();
  log::info("{}", ss.str());

  // Ensure that the update is posted to the correct thread
  for (const auto& device :
@@ -694,7 +688,7 @@ void AvrcpService::DebugDump(int fd) {
/** when a2dp connected, btif will start register vol changed, so we need a
 * interface for it. */
void AvrcpService::RegisterVolChanged(const RawAddress& bdaddr) {
  LOG(INFO) << ": address=" << ADDRESS_TO_LOGGABLE_STR(bdaddr);
  log::info(": address={}", ADDRESS_TO_LOGGABLE_STR(bdaddr));

  connection_handler_->RegisterVolChanged(bdaddr);
}
+14 −14
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@

#include <base/functional/bind.h>
#include <base/location.h>
#include <bluetooth/log.h>
#include <hardware/bluetooth.h>
#include <stdlib.h>

@@ -41,8 +42,7 @@
#define ASSERTC(cond, msg, val)                                        \
  do {                                                                 \
    if (!(cond)) {                                                     \
      LOG_ERROR("### ASSERT : %s %s line %d %s (%d) ###", __FILE__, __func__, \
                __LINE__, (msg), (val));                                      \
      bluetooth::log::error("### ASSERT : {} ({}) ###", (msg), (val)); \
    }                                                                  \
  } while (0)

@@ -66,7 +66,7 @@
#define HAL_CBACK(P_CB, P_CBACK, ...)                         \
  do {                                                        \
    if ((P_CB) && (P_CB)->P_CBACK) {                          \
      LOG_VERBOSE("%s: HAL %s->%s", __func__, #P_CB, #P_CBACK);    \
      bluetooth::log::verbose("HAL {}->{}", #P_CB, #P_CBACK); \
      (P_CB)->P_CBACK(__VA_ARGS__);                           \
    } else {                                                  \
      ASSERTC(0, "Callback is NULL", 0);                      \
+3 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#undef LOG_TAG  // Undefine the LOG_TAG by this compilation unit
#include "btif/src/btif_rc.cc"

#include <bluetooth/log.h>
#include <gtest/gtest.h>

#include <cstdint>
@@ -107,7 +108,7 @@ static bluetooth::common::MessageLoopThread jni_thread("bt_jni_thread");
bt_status_t do_in_jni_thread(const base::Location& from_here,
                             base::OnceClosure task) {
  if (!jni_thread.DoInThread(from_here, std::move(task))) {
    LOG(ERROR) << __func__ << ": Post task to task runner failed!";
    log::error("Post task to task runner failed!");
    return BT_STATUS_FAIL;
  }
  return BT_STATUS_SUCCESS;
@@ -264,7 +265,7 @@ TEST_F(BtifRcWithCallbacksTest, handle_rc_ctrl_features) {

  CHECK(std::future_status::ready == future.wait_for(std::chrono::seconds(2)));
  auto res = future.get();
  LOG_INFO("FEATURES:%d", res.feature);
  log::info("FEATURES:{}", res.feature);
  CHECK(res.feature == (BTRC_FEAT_ABSOLUTE_VOLUME | BTRC_FEAT_METADATA |
                        BTRC_FEAT_BROWSE | BTRC_FEAT_COVER_ARTWORK));
}