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

Commit 8d2e64ab authored by Henri Chataing's avatar Henri Chataing
Browse files

system/gd/l2cap: Migrate to libbluetooth_log

Test: m com.android.btservices
Bug: 305066880
Flag: EXEMPT, mechanical refactor
Change-Id: Ibc6530d234647076ff7a67e1bae04d460b970d99
parent 681ac3fd
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -609,6 +609,7 @@ cc_defaults {
        "libcrypto",
        "libgrpc++",
        "libgrpc_wrap",
        "liblog",
        "server_configurable_flags",
    ],
    cflags: [
@@ -680,9 +681,12 @@ cc_benchmark {
        "benchmark.cc",
    ],
    static_libs: [
        "libbase",
        "libbluetooth_gd",
        "libbluetooth_log",
        "libbt_shim_bridge",
        "libchrome",
        "liblog",
    ],
}

+10 −8
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

#include "l2cap/classic/facade.h"

#include <bluetooth/log.h>

#include <condition_variable>
#include <cstdint>
#include <unordered_map>
@@ -186,7 +188,7 @@ class L2capClassicModuleFacadeService : public L2capClassicModuleFacade::Service
    ASSERT(hci::Address::FromString(request->address(), peer));
    auto entry = security_link_map_.find(peer);
    if (entry == security_link_map_.end()) {
      LOG_WARN("Unknown address '%s'", ADDRESS_TO_LOGGABLE_CSTR(peer));
      log::warn("Unknown address '{}'", ADDRESS_TO_LOGGABLE_CSTR(peer));
    } else {
      entry->second->Hold();
    }
@@ -201,7 +203,7 @@ class L2capClassicModuleFacadeService : public L2capClassicModuleFacade::Service
    ASSERT(hci::Address::FromString(request->address(), peer));
    auto entry = security_link_map_.find(peer);
    if (entry == security_link_map_.end()) {
      LOG_WARN("Unknown address '%s'", ADDRESS_TO_LOGGABLE_CSTR(peer));
      log::warn("Unknown address '{}'", ADDRESS_TO_LOGGABLE_CSTR(peer));
    } else {
      entry->second->EnsureAuthenticated();
    }
@@ -217,7 +219,7 @@ class L2capClassicModuleFacadeService : public L2capClassicModuleFacade::Service
    outgoing_pairing_remote_devices_.erase(peer);
    auto entry = security_link_map_.find(peer);
    if (entry == security_link_map_.end()) {
      LOG_WARN("Unknown address '%s'", ADDRESS_TO_LOGGABLE_CSTR(peer));
      log::warn("Unknown address '{}'", ADDRESS_TO_LOGGABLE_CSTR(peer));
    } else {
      entry->second->Release();
    }
@@ -233,7 +235,7 @@ class L2capClassicModuleFacadeService : public L2capClassicModuleFacade::Service
    outgoing_pairing_remote_devices_.erase(peer);
    auto entry = security_link_map_.find(peer);
    if (entry == security_link_map_.end()) {
      LOG_WARN("Unknown address '%s'", ADDRESS_TO_LOGGABLE_CSTR(peer));
      log::warn("Unknown address '{}'", ADDRESS_TO_LOGGABLE_CSTR(peer));
    } else {
      entry->second->Disconnect();
    }
@@ -255,7 +257,7 @@ class L2capClassicModuleFacadeService : public L2capClassicModuleFacade::Service
  void OnLinkDisconnected(hci::Address remote) override {
    auto entry = security_link_map_.find(remote);
    if (entry == security_link_map_.end()) {
      LOG_WARN("Unknown address '%s'", ADDRESS_TO_LOGGABLE_CSTR(remote));
      log::warn("Unknown address '{}'", ADDRESS_TO_LOGGABLE_CSTR(remote));
      return;
    }
    entry->second.reset();
@@ -315,7 +317,7 @@ class L2capClassicModuleFacadeService : public L2capClassicModuleFacade::Service
          handler_->BindOnceOn(this, &L2capDynamicChannelHelper::on_connect_fail));
      std::unique_lock<std::mutex> lock(channel_open_cv_mutex_);
      if (!channel_open_cv_.wait_for(lock, std::chrono::seconds(2), [this] { return channel_ != nullptr; })) {
        LOG_WARN("Channel is not open for psm %d", psm_);
        log::warn("Channel is not open for psm {}", psm_);
      }
    }

@@ -323,7 +325,7 @@ class L2capClassicModuleFacadeService : public L2capClassicModuleFacade::Service
      if (channel_ == nullptr) {
        std::unique_lock<std::mutex> lock(channel_open_cv_mutex_);
        if (!channel_open_cv_.wait_for(lock, std::chrono::seconds(2), [this] { return channel_ != nullptr; })) {
          LOG_WARN("Channel is not open for psm %d", psm_);
          log::warn("Channel is not open for psm {}", psm_);
          return;
        }
      }
@@ -397,7 +399,7 @@ class L2capClassicModuleFacadeService : public L2capClassicModuleFacade::Service
      if (channel_ == nullptr) {
        std::unique_lock<std::mutex> lock(channel_open_cv_mutex_);
        if (!channel_open_cv_.wait_for(lock, std::chrono::seconds(2), [this] { return channel_ != nullptr; })) {
          LOG_WARN("Channel is not open");
          log::warn("Channel is not open");
          return false;
        }
      }
+4 −1
Original line number Diff line number Diff line
@@ -15,6 +15,9 @@
 */

#include "l2cap/classic/internal/dynamic_channel_service_manager_impl.h"

#include <bluetooth/log.h>

#include "common/bind.h"
#include "l2cap/classic/internal/dynamic_channel_service_impl.h"
#include "l2cap/psm.h"
@@ -53,7 +56,7 @@ void DynamicChannelServiceManagerImpl::Unregister(Psm psm, DynamicChannelService
    service_map_.erase(psm);
    callback.Invoke();
  } else {
    LOG_ERROR("service not registered psm:%d", psm);
    log::error("service not registered psm:{}", psm);
  }
}

+8 −5
Original line number Diff line number Diff line
@@ -14,10 +14,13 @@
 * limitations under the License.
 */

#include "l2cap/classic/internal/fixed_channel_impl.h"

#include <bluetooth/log.h>

#include <unordered_map>

#include "l2cap/cid.h"
#include "l2cap/classic/internal/fixed_channel_impl.h"
#include "l2cap/classic/internal/link.h"
#include "os/handler.h"
#include "os/log.h"
@@ -71,12 +74,12 @@ void FixedChannelImpl::OnClosed(hci::ErrorCode status) {
void FixedChannelImpl::Acquire() {
  ASSERT_LOG(user_handler_ != nullptr, "Must register OnCloseCallback before calling any methods");
  if (closed_) {
    LOG_WARN("%s is already closed", ToLoggableStr(*this).c_str());
    log::warn("{} is already closed", ToLoggableStr(*this));
    ASSERT(!acquired_);
    return;
  }
  if (acquired_) {
    LOG_INFO("%s was already acquired", ToLoggableStr(*this).c_str());
    log::info("{} was already acquired", ToLoggableStr(*this));
    return;
  }
  acquired_ = true;
@@ -86,12 +89,12 @@ void FixedChannelImpl::Acquire() {
void FixedChannelImpl::Release() {
  ASSERT_LOG(user_handler_ != nullptr, "Must register OnCloseCallback before calling any methods");
  if (closed_) {
    LOG_WARN("%s is already closed", ToLoggableStr(*this).c_str());
    log::warn("{} is already closed", ToLoggableStr(*this));
    ASSERT(!acquired_);
    return;
  }
  if (!acquired_) {
    LOG_INFO("%s was already released", ToLoggableStr(*this).c_str());
    log::info("{} was already released", ToLoggableStr(*this));
    return;
  }
  acquired_ = false;
+4 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

#include "l2cap/classic/internal/fixed_channel_service_manager_impl.h"

#include <bluetooth/log.h>

#include "common/bind.h"
#include "l2cap/cid.h"
#include "l2cap/classic/internal/fixed_channel_service_impl.h"
@@ -55,7 +57,7 @@ void FixedChannelServiceManagerImpl::Unregister(Cid cid, FixedChannelService::On
    service_map_.erase(cid);
    handler->Post(std::move(callback));
  } else {
    LOG_ERROR("service not registered cid:%d", cid);
    log::error("service not registered cid:{}", cid);
  }
}

@@ -95,7 +97,7 @@ uint64_t FixedChannelServiceManagerImpl::GetSupportedFixedChannelMask() {
        result |= kBrEdrSecurityManager;
        continue;
      default:
        LOG_WARN("Unknown fixed channel is registered: 0x%x", cid);
        log::warn("Unknown fixed channel is registered: 0x{:x}", cid);
        continue;
    }
  }
Loading