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

Commit 0d58c323 authored by William Escande's avatar William Escande
Browse files

Revert^2 "InitFlags: Remove hci_adapter"

This reverts commit 75083ae2.

Reason for revert: relanding after addressing initial issue

InitFlags: Remove hci_adapter

Keep the workaround for floss as this is a floss only behavior

Bug: 290844854
Change-Id: If1d5b407d5484b6f166384b191c90c65092a2b35
Fix: 290844854
Test: m Bluetooth
Flag: EXEMPT, no logical change
parent 75083ae2
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -427,6 +427,15 @@ static bool is_profile(const char* p1, const char* p2) {
 *
 *
 ****************************************************************************/
 ****************************************************************************/


#ifdef TARGET_FLOSS
static int global_hci_adapter = 0;

static int set_adapter_index(int adapter) { global_hci_adapter = adapter; }
int GetAdapterIndex() { return global_hci_adapter; }
#else
int GetAdapterIndex() { return 0; } // Unsupported outside of FLOSS
#endif

static int init(bt_callbacks_t* callbacks, bool start_restricted, bool is_common_criteria_mode,
static int init(bt_callbacks_t* callbacks, bool start_restricted, bool is_common_criteria_mode,
                int config_compare_result, const char** init_flags, bool is_atv,
                int config_compare_result, const char** init_flags, bool is_atv,
                const char* user_data_directory) {
                const char* user_data_directory) {
@@ -1224,6 +1233,9 @@ static void interop_database_add_remove_name(bool do_add, const char* feature_na


EXPORT_SYMBOL bt_interface_t bluetoothInterface = {
EXPORT_SYMBOL bt_interface_t bluetoothInterface = {
        sizeof(bluetoothInterface),
        sizeof(bluetoothInterface),
#ifdef TARGET_FLOSS
        .set_adapter_index = set_adapter_index,
#endif
        .init = init,
        .init = init,
        .enable = enable,
        .enable = enable,
        .disable = disable,
        .disable = disable,
+0 −2
Original line number Original line Diff line number Diff line
@@ -31,8 +31,6 @@ public:
    }
    }
    init_flags::load(std::move(rusted_flags));
    init_flags::load(std::move(rusted_flags));
  }
  }

  inline static int GetAdapterIndex() { return init_flags::get_hci_adapter(); }
};
};


}  // namespace common
}  // namespace common
+3 −2
Original line number Original line Diff line number Diff line
@@ -31,7 +31,6 @@
#include <utility>
#include <utility>
#include <vector>
#include <vector>


#include "common/init_flags.h"
#include "hal/hci_hal.h"
#include "hal/hci_hal.h"
#include "hal/link_clocker.h"
#include "hal/link_clocker.h"
#include "hal/mgmt.h"
#include "hal/mgmt.h"
@@ -41,6 +40,8 @@
#include "os/reactor.h"
#include "os/reactor.h"
#include "os/thread.h"
#include "os/thread.h"


extern int GetAdapterIndex();

namespace {
namespace {
constexpr int INVALID_FD = -1;
constexpr int INVALID_FD = -1;


@@ -206,7 +207,7 @@ int ConnectToSocket() {
  }
  }


  // Determine which hci index we should connect to.
  // Determine which hci index we should connect to.
  int hci_interface = bluetooth::common::InitFlags::GetAdapterIndex();
  int hci_interface = GetAdapterIndex();


  if (waitHciDev(hci_interface) != 0) {
  if (waitHciDev(hci_interface) != 0) {
    ::close(socket_fd);
    ::close(socket_fd);
+3 −2
Original line number Original line Diff line number Diff line
@@ -30,9 +30,10 @@


#include <cerrno>
#include <cerrno>


#include "common/init_flags.h"
#include "os/log.h"
#include "os/log.h"


extern int GetAdapterIndex();

namespace bluetooth {
namespace bluetooth {
namespace hal {
namespace hal {


@@ -82,7 +83,7 @@ static int btsocket_open_mgmt(uint16_t hci) {
 * be HCI_OP_NOP (0x0000).
 * be HCI_OP_NOP (0x0000).
 */
 */
uint16_t Mgmt::get_vs_opcode(uint16_t vendor_specification) {
uint16_t Mgmt::get_vs_opcode(uint16_t vendor_specification) {
  int hci = bluetooth::common::InitFlags::GetAdapterIndex();
  int hci = GetAdapterIndex();
  int fd = btsocket_open_mgmt(hci);
  int fd = btsocket_open_mgmt(hci);
  uint16_t ret_opcode = HCI_OP_NOP;
  uint16_t ret_opcode = HCI_OP_NOP;


+4 −3
Original line number Original line Diff line number Diff line
@@ -25,7 +25,6 @@
#include <map>
#include <map>
#include <utility>
#include <utility>


#include "common/init_flags.h"
#include "hci/hci_packets.h"
#include "hci/hci_packets.h"
#include "include/hardware/bluetooth.h"
#include "include/hardware/bluetooth.h"
#include "include/hardware/bt_av.h"
#include "include/hardware/bt_av.h"
@@ -33,6 +32,8 @@
#include "include/hardware/bt_hh.h"
#include "include/hardware/bt_hh.h"
#include "stack/include/hci_error_code.h"
#include "stack/include/hci_error_code.h"


extern int GetAdapterIndex();

namespace bluetooth {
namespace bluetooth {
namespace metrics {
namespace metrics {


@@ -673,7 +674,7 @@ static int64_t GetChipsetInfoId(const char* path, const char* file) {


static std::string GetChipsetInfoModuleName() {
static std::string GetChipsetInfoModuleName() {
  std::string module;
  std::string module;
  int adapter_index = bluetooth::common::InitFlags::GetAdapterIndex();
  int adapter_index = GetAdapterIndex();
  std::string path = base::StringPrintf(kChipsetInfoModaliasPath, adapter_index);
  std::string path = base::StringPrintf(kChipsetInfoModaliasPath, adapter_index);


  if (base::ReadFileToString(base::FilePath(path), &module)) {
  if (base::ReadFileToString(base::FilePath(path), &module)) {
@@ -686,7 +687,7 @@ static MetricTransportType GetChipsetInfoTransport(void) {
  MetricTransportType transport = MetricTransportType::TRANSPORT_TYPE_UNKNOWN;
  MetricTransportType transport = MetricTransportType::TRANSPORT_TYPE_UNKNOWN;
  base::FilePath module_realpath;
  base::FilePath module_realpath;
  std::string module_name;
  std::string module_name;
  int adapter_index = bluetooth::common::InitFlags::GetAdapterIndex();
  int adapter_index = GetAdapterIndex();
  std::string path = base::StringPrintf(kChipInfoModuleDirPath, adapter_index);
  std::string path = base::StringPrintf(kChipInfoModuleDirPath, adapter_index);


  // examples of module_realpath: /sys/module/btusb and /sys/module/hci_uart
  // examples of module_realpath: /sys/module/btusb and /sys/module/hci_uart
Loading