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

Commit 7c7ef756 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Add host support for btif/

Move some dependencies to Android only.

Bug: 181590011
Tag: #refactor
Test: compile
Change-Id: I37812378210e822d1d36fcf24aaadbcf9f4a5084
parent 5cece708
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@ cc_library_static {
    srcs: [
    srcs: [
        "src/audio_a2dp_hw_utils.cc",
        "src/audio_a2dp_hw_utils.cc",
    ],
    ],
    host_supported: true,
}
}


// Audio A2DP library unit tests for target and host
// Audio A2DP library unit tests for target and host
+5 −1
Original line number Original line Diff line number Diff line
@@ -2549,7 +2549,11 @@ void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, uint8_t id, uint8_t app_id,
        if (((p_bta_dm_rm_cfg[j].app_id == app_id) ||
        if (((p_bta_dm_rm_cfg[j].app_id == app_id) ||
             (p_bta_dm_rm_cfg[j].app_id == BTA_ALL_APP_ID)) &&
             (p_bta_dm_rm_cfg[j].app_id == BTA_ALL_APP_ID)) &&
            (p_bta_dm_rm_cfg[j].id == id)) {
            (p_bta_dm_rm_cfg[j].id == id)) {
          role = toBTA_PREF_ROLES(p_bta_dm_rm_cfg[j].cfg);
          ASSERT_LOG(p_bta_dm_rm_cfg[j].cfg <= BTA_PERIPHERAL_ROLE_ONLY,
                     "Passing illegal preferred role:0x%02x [0x%02x<=>0x%02x]",
                     p_bta_dm_rm_cfg[j].cfg, BTA_ANY_ROLE,
                     BTA_PERIPHERAL_ROLE_ONLY);
          role = static_cast<tBTA_PREF_ROLES>(p_bta_dm_rm_cfg[j].cfg);
          if (role > p_dev->pref_role) p_dev->pref_role = role;
          if (role > p_dev->pref_role) p_dev->pref_role = role;
          break;
          break;
        }
        }
+0 −19
Original line number Original line Diff line number Diff line
@@ -30,7 +30,6 @@


#include "bt_target.h"  // Must be first to define build configuration
#include "bt_target.h"  // Must be first to define build configuration


#include "osi/include/log.h"
#include "stack/include/bt_types.h"
#include "stack/include/bt_types.h"
#include "stack/include/btm_api_types.h"
#include "stack/include/btm_api_types.h"
#include "stack/include/btm_ble_api_types.h"
#include "stack/include/btm_ble_api_types.h"
@@ -128,24 +127,6 @@ typedef enum : uint8_t {
  BTA_PERIPHERAL_ROLE_ONLY = 0x03,
  BTA_PERIPHERAL_ROLE_ONLY = 0x03,
} tBTA_PREF_ROLES;
} tBTA_PREF_ROLES;


inline tBTA_PREF_ROLES toBTA_PREF_ROLES(uint8_t role) {
  ASSERT_LOG(role <= BTA_PERIPHERAL_ROLE_ONLY,
             "Passing illegal preferred role:0x%02x [0x%02x<=>0x%02x]", role,
             BTA_ANY_ROLE, BTA_PERIPHERAL_ROLE_ONLY);
  return static_cast<tBTA_PREF_ROLES>(role);
}

inline std::string preferred_role_text(const tBTA_PREF_ROLES& role) {
  switch (role) {
    CASE_RETURN_TEXT(BTA_ANY_ROLE);
    CASE_RETURN_TEXT(BTA_CENTRAL_ROLE_PREF);
    CASE_RETURN_TEXT(BTA_CENTRAL_ROLE_ONLY);
    CASE_RETURN_TEXT(BTA_PERIPHERAL_ROLE_ONLY);
    default:
      return std::string("UNKNOWN:%hhu", role);
  }
}

enum {
enum {


  BTA_DM_NO_SCATTERNET,      /* Device doesn't support scatternet, it might
  BTA_DM_NO_SCATTERNET,      /* Device doesn't support scatternet, it might
+16 −7
Original line number Original line Diff line number Diff line
@@ -60,7 +60,6 @@ cc_library_static {
        "src/btif_a2dp_source.cc",
        "src/btif_a2dp_source.cc",
        "src/btif_activity_attribution.cc",
        "src/btif_activity_attribution.cc",
        "src/btif_av.cc",
        "src/btif_av.cc",
        "src/btif_avrcp_audio_track.cc",
        "src/btif_ble_advertiser.cc",
        "src/btif_ble_advertiser.cc",
        "src/btif_ble_scanner.cc",
        "src/btif_ble_scanner.cc",
        "src/btif_bqr.cc",
        "src/btif_bqr.cc",
@@ -101,32 +100,42 @@ cc_library_static {
        "src/btif_keystore.cc",
        "src/btif_keystore.cc",
        "src/stack_manager.cc",
        "src/stack_manager.cc",
    ],
    ],
    header_libs: [
        "libmedia_headers",
    ],
    shared_libs: [
    shared_libs: [
        "android.hardware.bluetooth.a2dp@1.0",
        "android.hardware.bluetooth.a2dp@1.0",
        "android.hardware.bluetooth.audio@2.0",
        "android.hardware.bluetooth.audio@2.0",
        "android.hardware.bluetooth.audio@2.1",
        "android.hardware.bluetooth.audio@2.1",
        "libaaudio",
        "libcrypto",
        "libcrypto",
        "libcutils",
        "libcutils",
        "libfmq",
        "libhidlbase",
        "libhidlbase",
        "liblog",
        "liblog",
        "libtinyxml2",
        "libtinyxml2",
        "libutils",
        "libutils",
        "libz",
        "libz",
    ],
    ],
    target: {
        android: {
            shared_libs: [
                "libaaudio",
                "libfmq",
            ],
            whole_static_libs: [
                "libbt-audio-hal-interface",
            ],
            srcs: ["src/btif_avrcp_audio_track.cc"],
        },
        host: {
            srcs: ["src/btif_avrcp_audio_track_linux.cc"],
        },
    },
    whole_static_libs: [
    whole_static_libs: [
        "avrcp-target-service",
        "avrcp-target-service",
        "lib-bt-packets",
        "lib-bt-packets",
        "libaudio-a2dp-hw-utils",
        "libaudio-a2dp-hw-utils",
        "libbt-audio-hal-interface",
    ],
    ],
    cflags: [
    cflags: [
        "-DBUILDCFG",
        "-DBUILDCFG",
    ],
    ],
    host_supported: true,
}
}


// btif unit tests for target
// btif unit tests for target
+2 −0
Original line number Original line Diff line number Diff line
@@ -161,6 +161,7 @@ static int uhid_read_event(btif_hh_device_t* p_dev) {
        APPL_TRACE_ERROR("%s: UHID_FEATURE: Invalid report type = %d", __func__,
        APPL_TRACE_ERROR("%s: UHID_FEATURE: Invalid report type = %d", __func__,
                         ev.u.feature.rtype);
                         ev.u.feature.rtype);
      break;
      break;
#ifdef OS_ANDROID  // Host kernel does not support UHID_SET_REPORT
    case UHID_SET_REPORT:
    case UHID_SET_REPORT:
      if (ret < (ssize_t)(sizeof(ev.type) + sizeof(ev.u.set_report))) {
      if (ret < (ssize_t)(sizeof(ev.type) + sizeof(ev.u.set_report))) {
          APPL_TRACE_ERROR("%s: Invalid size read from uhid-dev: %zd < %zu",
          APPL_TRACE_ERROR("%s: Invalid size read from uhid-dev: %zd < %zu",
@@ -184,6 +185,7 @@ static int uhid_read_event(btif_hh_device_t* p_dev) {
            APPL_TRACE_ERROR("%s:UHID_SET_REPORT: Invalid Report type = %d"
            APPL_TRACE_ERROR("%s:UHID_SET_REPORT: Invalid Report type = %d"
                          , __func__, ev.u.set_report.rtype);
                          , __func__, ev.u.set_report.rtype);
        break;
        break;
#endif  // ifdef OS_ANDROID
    default:
    default:
      APPL_TRACE_DEBUG("Invalid event from uhid-dev: %u\n", ev.type);
      APPL_TRACE_DEBUG("Invalid event from uhid-dev: %u\n", ev.type);
  }
  }
Loading