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

Commit b76bbdce authored by Andre Eisenbach's avatar Andre Eisenbach Committed by Myles Watson
Browse files

Initial HIDL conversion

Test: Unit tests, VTS test, device sanity
Change-Id: Ia5b2b5fa762d240c0490666d50ea5c878631fcd1
parent 64c30931
Loading
Loading
Loading
Loading
+50 −41
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@
#include "osi/include/osi.h"
#include "osi/include/properties.h"
#include "utl.h"
#include "vendor.h"

#if (BTA_AR_INCLUDED == TRUE)
#include "bta_ar_api.h"
@@ -1031,12 +1030,15 @@ void bta_av_cleanup(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) {
  p_scb->num_disc_snks = 0;
  alarm_cancel(p_scb->avrc_ct_timer);

  /* TODO(eisenbach): RE-IMPLEMENT USING VSC OR HAL EXTENSION
    vendor_get_interface()->send_command(
        (vendor_opcode_t)BT_VND_OP_A2DP_OFFLOAD_STOP, (void*)&p_scb->l2c_cid);
    if (p_scb->offload_start_pending) {
      tBTA_AV_STATUS status = BTA_AV_FAIL_STREAM;
      (*bta_av_cb.p_cback)(BTA_AV_OFFLOAD_START_RSP_EVT, (tBTA_AV*)&status);
    }
  */

  p_scb->offload_start_pending = false;

  p_scb->skip_sdp = false;
@@ -1934,6 +1936,7 @@ void bta_av_str_stopped(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
  bta_sys_set_policy(BTA_ID_AV, policy, p_scb->peer_addr);

  if (p_scb->co_started) {
    /* TODO(eisenbach): RE-IMPLEMENT USING VSC OR HAL EXTENSION
    vendor_get_interface()->send_command(
        (vendor_opcode_t)BT_VND_OP_A2DP_OFFLOAD_STOP, (void*)&p_scb->l2c_cid);
    if (p_scb->offload_start_pending) {
@@ -1941,6 +1944,7 @@ void bta_av_str_stopped(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
      (*bta_av_cb.p_cback)(BTA_AV_OFFLOAD_START_RSP_EVT, (tBTA_AV*)&status);
    }
    p_scb->offload_start_pending = false;
    */

    bta_av_stream_chg(p_scb, false);
    p_scb->co_started = false;
@@ -2517,6 +2521,7 @@ void bta_av_suspend_cfm(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {

  /* in case that we received suspend_ind, we may need to call co_stop here */
  if (p_scb->co_started) {
    /* TODO(eisenbach): RE-IMPLEMENT USING VSC OR HAL EXTENSION
    vendor_get_interface()->send_command(
        (vendor_opcode_t)BT_VND_OP_A2DP_OFFLOAD_STOP, (void*)&p_scb->l2c_cid);
    if (p_scb->offload_start_pending) {
@@ -2524,6 +2529,7 @@ void bta_av_suspend_cfm(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
      (*bta_av_cb.p_cback)(BTA_AV_OFFLOAD_START_RSP_EVT, (tBTA_AV*)&status);
    }
    p_scb->offload_start_pending = false;
    */

    bta_av_stream_chg(p_scb, false);

@@ -2936,7 +2942,6 @@ void bta_av_open_at_inc(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
 ******************************************************************************/
void bta_av_offload_req(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
  tBTA_AV_STATUS status = BTA_AV_FAIL_RESOURCES;
  uint16_t mtu = bta_av_chk_mtu(p_scb, p_scb->stream_mtu);

  APPL_TRACE_DEBUG("%s: stream %s, audio channels open %d", __func__,
                   p_scb->started ? "STARTED" : "STOPPED",
@@ -2946,8 +2951,11 @@ void bta_av_offload_req(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
  /* Support offload if only one audio source stream is open. */
  if (p_scb->started != true) {
    status = BTA_AV_FAIL_STREAM;
  }

  } else if (bta_av_cb.audio_open_cnt == 1 &&
  /* TODO(eisenbach): RE-IMPLEMENT USING VSC OR HAL EXTENSION
   uint16_t mtu = bta_av_chk_mtu(p_scb, p_scb->stream_mtu);
   else if (bta_av_cb.audio_open_cnt == 1 &&
              p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC &&
              p_scb->chnl == BTA_AV_CHNL_AUDIO) {
     bt_vendor_op_a2dp_offload_t a2dp_offload_start;
@@ -2955,7 +2963,8 @@ void bta_av_offload_req(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
     if (L2CA_GetConnectionConfig(
             p_scb->l2c_cid, &a2dp_offload_start.acl_data_size,
             &a2dp_offload_start.remote_cid, &a2dp_offload_start.lm_handle)) {
      APPL_TRACE_DEBUG("%s: l2cmtu %d lcid 0x%02X rcid 0x%02X lm_handle 0x%02X",
       APPL_TRACE_DEBUG("%s: l2cmtu %d lcid 0x%02X rcid 0x%02X lm_handle
   0x%02X",
                        __func__, a2dp_offload_start.acl_data_size,
                        p_scb->l2c_cid, a2dp_offload_start.remote_cid,
                        a2dp_offload_start.lm_handle);
@@ -2980,7 +2989,7 @@ void bta_av_offload_req(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
       }
     }
   }

   */
  if (status != BTA_AV_SUCCESS)
    (*bta_av_cb.p_cback)(BTA_AV_OFFLOAD_START_RSP_EVT, (tBTA_AV*)&status);
}
+0 −1
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ This document lists all of the log tags used by the Bluetooth stack.
* BTIF_STORAGE
* BTIF_UTIL
* BTLD
* bt_low_power_manager
* bt_module
* bt_osi_alarm
* bt_osi_config
+15 −11
Original line number Diff line number Diff line
cc_defaults {
    name: "libbt-hci_defaults",
    defaults: ["fluoride_defaults"],
    shared_libs: [
        "android.hardware.bluetooth@1.0",
        "libhidlbase",
        "libhidltransport",
        "libhwbinder",
    ],
}

// HCI static library for target
// ========================================================
cc_library_static {
    name: "libbt-hci",
    defaults: ["fluoride_defaults"],
    defaults: ["libbt-hci_defaults"],
    srcs: [
        "src/btsnoop.cc",
        "src/btsnoop_mem.cc",
        "src/btsnoop_net.cc",
        "src/buffer_allocator.cc",
        "src/hci_audio.cc",
        "src/hci_hal.cc",
        "src/hci_hal_h4.cc",
        "src/hci_hal_mct.cc",
        "src/hci_inject.cc",
        "src/hci_layer.cc",
        "src/hci_packet_factory.cc",
        "src/hci_packet_parser.cc",
        "src/low_power_manager.cc",
        "src/packet_fragmenter.cc",
        "src/vendor.cc",
    ],
    local_include_dirs: [
        "include",
@@ -30,6 +36,7 @@ cc_library_static {
        "packages/modules/Bluetooth/system/stack/include",
        "packages/modules/Bluetooth/system/utils/include",
        "packages/modules/Bluetooth/system/bta/include",
        "system/libhwbinder/include",
    ],
}

@@ -37,7 +44,7 @@ cc_library_static {
// ========================================================
cc_test {
    name: "net_test_hci",
    defaults: ["fluoride_defaults"],
    defaults: ["libbt-hci_defaults"],
    local_include_dirs: [
        "include",
    ],
@@ -48,12 +55,9 @@ cc_test {
        "packages/modules/Bluetooth/system/osi/test",
        "packages/modules/Bluetooth/system/stack/include",
        "packages/modules/Bluetooth/system/utils/include",
        "system/libhwbinder/include",
    ],
    srcs: [
        "test/hci_hal_h4_test.cc",
        "test/hci_hal_mct_test.cc",
        "test/hci_layer_test.cc",
        "test/low_power_manager_test.cc",
        "test/packet_fragmenter_test.cc",
    ],
    shared_libs: [
+0 −4
Original line number Diff line number Diff line
@@ -52,10 +52,6 @@ executable("net_test_hci") {
  sources = [
    "//osi/test/AllocationTestHarness.cc",
    "//osi/test/AlarmTestHarness.cc",
    "test/hci_hal_h4_test.cc",
    "test/hci_hal_mct_test.cc",
    "test/hci_layer_test.cc",
    "test/low_power_manager_test.cc",
    "test/packet_fragmenter_test.cc",
  ]

+2 −20
Original line number Diff line number Diff line
@@ -58,30 +58,15 @@ typedef struct controller_t controller_t;
typedef struct hci_inject_t hci_inject_t;
typedef struct packet_fragmenter_t packet_fragmenter_t;
typedef struct vendor_t vendor_t;
typedef struct low_power_manager_t low_power_manager_t;

typedef unsigned char* bdaddr_t;
typedef uint16_t command_opcode_t;

typedef enum {
  LPM_DISABLE,
  LPM_ENABLE,
  LPM_WAKE_ASSERT,
  LPM_WAKE_DEASSERT
} low_power_command_t;

typedef void (*command_complete_cb)(BT_HDR* response, void* context);
typedef void (*command_status_cb)(uint8_t status, BT_HDR* command,
                                  void* context);

typedef struct hci_t {
  // Send a low power command, if supported and the low power manager is
  // enabled.
  void (*send_low_power_command)(low_power_command_t command);

  // Do the postload sequence (call after the rest of the BT stack initializes).
  void (*do_postload)(void);

  // Register with this data dispatcher to receive events flowing upward out of
  // the HCI layer
  data_dispatcher_t* event_dispatcher;
@@ -104,10 +89,7 @@ const hci_t* hci_layer_get_interface();

const hci_t* hci_layer_get_test_interface(
    const allocator_t* buffer_allocator_interface,
    const hci_hal_t* hal_interface, const btsnoop_t* btsnoop_interface,
    const hci_inject_t* hci_inject_interface,
    const packet_fragmenter_t* packet_fragmenter_interface,
    const vendor_t* vendor_interface,
    const low_power_manager_t* low_power_manager_interface);
    const btsnoop_t* btsnoop_interface,
    const packet_fragmenter_t* packet_fragmenter_interface);

void hci_layer_cleanup_interface();
Loading