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

Commit 39043c65 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "RootCanal: Use gd/os/log.h logging"

parents 1c1dcc69 e2545fb7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ cc_binary {
    ],
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/gd",
        "packages/modules/Bluetooth/system/hci/include",
        "packages/modules/Bluetooth/system/internal_include",
        "packages/modules/Bluetooth/system/stack/include",
@@ -86,6 +87,7 @@ cc_library_shared {
    ],
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/gd",
        "packages/modules/Bluetooth/system/hci/include",
        "packages/modules/Bluetooth/system/internal_include",
        "packages/modules/Bluetooth/system/stack/include",
+30 −26
Original line number Diff line number Diff line
@@ -18,14 +18,13 @@

#include "bluetooth_hci.h"

#include <base/logging.h>
#include <cutils/properties.h>
#include <netdb.h>
#include <netinet/in.h>
#include <string.h>
#include <utils/Log.h>

#include "hci_internals.h"
#include "os/log.h"

namespace android {
namespace hardware {
@@ -54,7 +53,7 @@ class BluetoothDeathRecipient : public hidl_death_recipient {
  void serviceDied(
      uint64_t /* cookie */,
      const wp<::android::hidl::base::V1_0::IBase>& /* who */) override {
    ALOGE("BluetoothDeathRecipient::serviceDied - Bluetooth service died");
    LOG_ERROR("BluetoothDeathRecipient::serviceDied - Bluetooth service died");
    has_died_ = true;
    mHci->close();
  }
@@ -73,10 +72,10 @@ class BluetoothDeathRecipient : public hidl_death_recipient {
BluetoothHci::BluetoothHci() : death_recipient_(new BluetoothDeathRecipient(this)) {}

Return<void> BluetoothHci::initialize(const sp<IBluetoothHciCallbacks>& cb) {
  ALOGI("%s", __func__);
  LOG_INFO("%s", __func__);

  if (cb == nullptr) {
    ALOGE("cb == nullptr! -> Unable to call initializationComplete(ERR)");
    LOG_ERROR("cb == nullptr! -> Unable to call initializationComplete(ERR)");
    return Void();
  }

@@ -145,7 +144,7 @@ Return<void> BluetoothHci::initialize(const sp<IBluetoothHciCallbacks>& cb) {

  // Send responses to logcat if the test channel is not configured.
  test_channel_.RegisterSendResponse([](const std::string& response) {
    ALOGI("No test channel yet: %s", response.c_str());
    LOG_INFO("No test channel yet: %s", response.c_str());
  });

  if (BtTestConsoleEnabled()) {
@@ -160,7 +159,7 @@ Return<void> BluetoothHci::initialize(const sp<IBluetoothHciCallbacks>& cb) {
  test_channel_.AddDefaults();

  // This should be configurable in the future.
  ALOGI("Adding Beacons so the scan list is not empty.");
  LOG_INFO("Adding Beacons so the scan list is not empty.");
  test_channel_.Add({"beacon", "be:ac:10:00:00:01", "1000"});
  test_channel_.AddDeviceToPhy({"2", "1"});
  test_channel_.Add({"beacon", "be:ac:10:00:00:02", "1000"});
@@ -168,7 +167,7 @@ Return<void> BluetoothHci::initialize(const sp<IBluetoothHciCallbacks>& cb) {

  unlink_cb_ = [this, cb](sp<BluetoothDeathRecipient>& death_recipient) {
    if (death_recipient->getHasDied())
      ALOGI("Skipping unlink call, service died.");
      LOG_INFO("Skipping unlink call, service died.");
    else {
      auto ret = cb->unlinkToDeath(death_recipient);
      if (!ret.isOk()) {
@@ -187,7 +186,7 @@ Return<void> BluetoothHci::initialize(const sp<IBluetoothHciCallbacks>& cb) {
}

Return<void> BluetoothHci::close() {
  ALOGI("%s", __func__);
  LOG_INFO("%s", __func__);
  return Void();
}

@@ -221,18 +220,19 @@ Return<void> BluetoothHci::sendScoData(const hidl_vec<uint8_t>& packet) {
void BluetoothHci::SetUpHciServer(int port, const std::function<void(int)>& connection_callback) {
  int socket_fd = remote_hci_transport_.SetUp(port);

  test_channel_.RegisterSendResponse(
      [](const std::string& response) { ALOGI("No HCI Response channel: %s", response.c_str()); });
  test_channel_.RegisterSendResponse([](const std::string& response) {
    LOG_INFO("No HCI Response channel: %s", response.c_str());
  });

  if (socket_fd == -1) {
    ALOGE("Remote HCI channel SetUp(%d) failed.", port);
    LOG_ERROR("Remote HCI channel SetUp(%d) failed.", port);
    return;
  }

  async_manager_.WatchFdForNonBlockingReads(socket_fd, [this, connection_callback](int socket_fd) {
    int conn_fd = remote_hci_transport_.Accept(socket_fd);
    if (conn_fd < 0) {
      ALOGE("Error watching remote HCI channel fd.");
      LOG_ERROR("Error watching remote HCI channel fd.");
      return;
    }
    int flags = fcntl(conn_fd, F_GETFL, NULL);
@@ -247,18 +247,19 @@ void BluetoothHci::SetUpHciServer(int port, const std::function<void(int)>& conn
void BluetoothHci::SetUpLinkLayerServer(int port, const std::function<void(int)>& connection_callback) {
  int socket_fd = remote_link_layer_transport_.SetUp(port);

  test_channel_.RegisterSendResponse(
      [](const std::string& response) { ALOGI("No LinkLayer Response channel: %s", response.c_str()); });
  test_channel_.RegisterSendResponse([](const std::string& response) {
    LOG_INFO("No LinkLayer Response channel: %s", response.c_str());
  });

  if (socket_fd == -1) {
    ALOGE("Remote LinkLayer channel SetUp(%d) failed.", port);
    LOG_ERROR("Remote LinkLayer channel SetUp(%d) failed.", port);
    return;
  }

  async_manager_.WatchFdForNonBlockingReads(socket_fd, [this, connection_callback](int socket_fd) {
    int conn_fd = remote_link_layer_transport_.Accept(socket_fd);
    if (conn_fd < 0) {
      ALOGE("Error watching remote LinkLayer channel fd.");
      LOG_ERROR("Error watching remote LinkLayer channel fd.");
      return;
    }
    int flags = fcntl(conn_fd, F_GETFL, NULL);
@@ -272,14 +273,15 @@ void BluetoothHci::SetUpLinkLayerServer(int port, const std::function<void(int)>
int BluetoothHci::ConnectToRemoteServer(const std::string& server, int port) {
  int socket_fd = socket(AF_INET, SOCK_STREAM, 0);
  if (socket_fd < 1) {
    ALOGI("socket() call failed: %s", strerror(errno));
    LOG_INFO("socket() call failed: %s", strerror(errno));
    return -1;
  }

  struct hostent* host;
  host = gethostbyname(server.c_str());
  if (host == NULL) {
    ALOGI("gethostbyname() failed for %s: %s", server.c_str(), strerror(errno));
    LOG_INFO("gethostbyname() failed for %s: %s", server.c_str(),
             strerror(errno));
    return -1;
  }

@@ -291,7 +293,8 @@ int BluetoothHci::ConnectToRemoteServer(const std::string& server, int port) {

  int result = connect(socket_fd, (struct sockaddr*)&serv_addr, sizeof(serv_addr));
  if (result < 0) {
    ALOGI("connect() failed for %s@%d: %s", server.c_str(), port, strerror(errno));
    LOG_INFO("connect() failed for %s@%d: %s", server.c_str(), port,
             strerror(errno));
    return -1;
  }

@@ -305,22 +308,23 @@ int BluetoothHci::ConnectToRemoteServer(const std::string& server, int port) {
void BluetoothHci::SetUpTestChannel(int port) {
  int socket_fd = test_channel_transport_.SetUp(port);

  test_channel_.RegisterSendResponse(
      [](const std::string& response) { ALOGI("No test channel: %s", response.c_str()); });
  test_channel_.RegisterSendResponse([](const std::string& response) {
    LOG_INFO("No test channel: %s", response.c_str());
  });

  if (socket_fd == -1) {
    ALOGE("Test channel SetUp(%d) failed.", port);
    LOG_ERROR("Test channel SetUp(%d) failed.", port);
    return;
  }

  ALOGI("Test channel SetUp() successful");
  LOG_INFO("Test channel SetUp() successful");
  async_manager_.WatchFdForNonBlockingReads(socket_fd, [this](int socket_fd) {
    int conn_fd = test_channel_transport_.Accept(socket_fd);
    if (conn_fd < 0) {
      ALOGE("Error watching test channel fd.");
      LOG_ERROR("Error watching test channel fd.");
      return;
    }
    ALOGI("Test channel connection accepted.");
    LOG_INFO("Test channel connection accepted.");
    test_channel_.RegisterSendResponse(
        [this, conn_fd](const std::string& response) { test_channel_transport_.SendResponse(conn_fd, response); });

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

#pragma once

#include "os/log.h"

#include <android/hardware/bluetooth/1.0/IBluetoothHci.h>

#include <hidl/MQDescriptor.h>
+3 −2
Original line number Diff line number Diff line
@@ -16,10 +16,11 @@

#define LOG_TAG "android.hardware.bluetooth@1.0-service.sim"

#include "os/log.h"

#include <android/hardware/bluetooth/1.0/IBluetoothHci.h>
#include <hidl/HidlSupport.h>
#include <hidl/HidlTransportSupport.h>
#include <utils/Log.h>

#include "bluetooth_hci.h"

@@ -36,5 +37,5 @@ int main(int /* argc */, char** /* argv */) {
  if (status == android::OK)
    joinRpcThreadpool();
  else
    ALOGE("Could not register as a service!");
    LOG_ERROR("Could not register as a service!");
}
+3 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ cc_library_static {
    ],
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/gd",
    ],
    shared_libs: [
        "libbase",
@@ -83,6 +84,7 @@ cc_test_host {
    ],
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/gd",
    ],
    shared_libs: [
        "liblog",
@@ -116,6 +118,7 @@ cc_test_host {
    ],
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/gd",
    ],
    shared_libs: [
        "liblog",
Loading