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

Commit 3e89475f authored by Chris Manton's avatar Chris Manton
Browse files

legacy: Use bta::dm::act::get_btm_client_interface

Bug: 193716447
Test: m .

Change-Id: I392f3b9fb0a80cad54d0a5d14aed28d9aa441221
parent 75e790e6
Loading
Loading
Loading
Loading
+35 −22
Original line number Diff line number Diff line
@@ -261,7 +261,7 @@ void BTA_dm_on_hw_on() {
  LOG_INFO("%s: Read default class of device {0x%x, 0x%x, 0x%x}", __func__,
      dev_class[0], dev_class[1], dev_class[2]);

  BTM_SetDeviceClass(dev_class);
  get_btm_client_interface().local.BTM_SetDeviceClass(dev_class);

  /* load BLE local information: ID keys, ER if available */
  Octet16 er;
@@ -280,11 +280,13 @@ void BTA_dm_on_hw_on() {
  btm_dm_sec_init();
  btm_sec_on_hw_on();

  BTM_WritePageTimeout(osi_property_get_int32(PROPERTY_PAGE_TIMEOUT,
  get_btm_client_interface().link_policy.BTM_WritePageTimeout(
      osi_property_get_int32(PROPERTY_PAGE_TIMEOUT,
                             p_bta_dm_cfg->page_timeout));

  if (ble_vnd_is_included()) {
    BTM_BleReadControllerFeatures(bta_dm_ctrl_features_rd_cmpl_cback);
    get_btm_client_interface().ble.BTM_BleReadControllerFeatures(
        bta_dm_ctrl_features_rd_cmpl_cback);
  } else {
    /* Set controller features even if vendor support is not included */
    if (bta_dm_acl_cb.p_acl_cback)
@@ -405,7 +407,8 @@ static void bta_dm_wait_for_acl_to_drain_cback(void* data) {

/** Sets local device name */
void bta_dm_set_dev_name(const std::vector<uint8_t>& name) {
  BTM_SetLocalDeviceName((const char*)name.data());
  get_btm_client_interface().local.BTM_SetLocalDeviceName(
      (const char*)name.data());
  bta_dm_set_eir((char*)name.data());
}

@@ -447,7 +450,7 @@ void bta_dm_process_remove_device_no_callback(const RawAddress& bd_addr) {
  /* need to remove all pending background connection before unpair */
  bta_dm_disc_gatt_cancel_open(bd_addr);

  BTM_SecDeleteDevice(bd_addr);
  get_btm_client_interface().security.BTM_SecDeleteDevice(bd_addr);

  /* remove all cached GATT information */
  bta_dm_disc_gatt_refresh(bd_addr);
@@ -470,8 +473,10 @@ void bta_dm_process_remove_device(const RawAddress& bd_addr) {
void bta_dm_remove_device(const RawAddress& bd_addr) {
  /* If ACL exists for the device in the remove_bond message*/
  bool is_bd_addr_connected =
      BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE) ||
      BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_BR_EDR);
      get_btm_client_interface().peer.BTM_IsAclConnectionUp(bd_addr,
                                                            BT_TRANSPORT_LE) ||
      get_btm_client_interface().peer.BTM_IsAclConnectionUp(
          bd_addr, BT_TRANSPORT_BR_EDR);

  tBT_TRANSPORT other_transport = BT_TRANSPORT_AUTO;
  if (is_bd_addr_connected) {
@@ -509,18 +514,20 @@ void bta_dm_remove_device(const RawAddress& bd_addr) {
  // device
  bool other_address_connected =
      (other_transport)
          ? BTM_ReadConnectedTransportAddress(&other_address, other_transport)
          : (BTM_ReadConnectedTransportAddress(&other_address,
                                               BT_TRANSPORT_BR_EDR) ||
             BTM_ReadConnectedTransportAddress(&other_address2,
                                               BT_TRANSPORT_LE));
          ? get_btm_client_interface().peer.BTM_ReadConnectedTransportAddress(
                &other_address, other_transport)
          : (get_btm_client_interface().peer.BTM_ReadConnectedTransportAddress(
                 &other_address, BT_TRANSPORT_BR_EDR) ||
             get_btm_client_interface().peer.BTM_ReadConnectedTransportAddress(
                 &other_address2, BT_TRANSPORT_LE));
  if (other_address == bd_addr) other_address = other_address2;

  if (other_address_connected) {
    // Get real transport
    if (other_transport == BT_TRANSPORT_AUTO) {
      bool connected_with_br_edr =
          BTM_IsAclConnectionUp(other_address, BT_TRANSPORT_BR_EDR);
          get_btm_client_interface().peer.BTM_IsAclConnectionUp(
              other_address, BT_TRANSPORT_BR_EDR);
      other_transport =
          connected_with_br_edr ? BT_TRANSPORT_BR_EDR : BT_TRANSPORT_LE;
    }
@@ -633,7 +640,7 @@ static void handle_role_change(const RawAddress& bd_addr, tHCI_ROLE new_role,
      /* more than one connections and the AV connection is role switched
       * to peripheral
       * switch it back to central and remove the switch policy */
      BTM_SwitchRoleToCentral(bd_addr);
      get_btm_client_interface().link_policy.BTM_SwitchRoleToCentral(bd_addr);
      need_policy_change = true;
    } else if (p_bta_dm_cfg->avoid_scatter && (new_role == HCI_ROLE_CENTRAL)) {
      /* if the link updated to be central include AV activities, remove
@@ -642,7 +649,8 @@ static void handle_role_change(const RawAddress& bd_addr, tHCI_ROLE new_role,
    }

    if (need_policy_change) {
      BTM_block_role_switch_for(p_dev->peer_bdaddr);
      get_btm_client_interface().link_policy.BTM_block_role_switch_for(
          p_dev->peer_bdaddr);
    }
  } else {
    /* there's AV no activity on this link and role switch happened
@@ -776,7 +784,8 @@ static void bta_dm_acl_down(const RawAddress& bd_addr,
      continue;

    if (device->conn_state == BTA_DM_UNPAIRING) {
      issue_unpair_cb = BTM_SecDeleteDevice(device->peer_bdaddr);
      issue_unpair_cb = get_btm_client_interface().security.BTM_SecDeleteDevice(
          device->peer_bdaddr);

      /* remove all cached GATT information */
      get_gatt_interface().BTA_GATTC_Refresh(bd_addr);
@@ -880,9 +889,11 @@ static void bta_dm_check_av() {
               p_dev->info_text().c_str());
      if ((p_dev->conn_state == BTA_DM_CONNECTED) && p_dev->is_av_active()) {
        /* make central and take away the role switch policy */
        BTM_SwitchRoleToCentral(p_dev->peer_bdaddr);
        get_btm_client_interface().link_policy.BTM_SwitchRoleToCentral(
            p_dev->peer_bdaddr);
        /* else either already central or can not switch for some reasons */
        BTM_block_role_switch_for(p_dev->peer_bdaddr);
        get_btm_client_interface().link_policy.BTM_block_role_switch_for(
            p_dev->peer_bdaddr);
        break;
      }
    }
@@ -1023,7 +1034,7 @@ static void bta_dm_adjust_roles(bool delay_role_switch) {
          if (bta_dm_cb.device_list.peer_device[i].pref_role !=
                  BTA_PERIPHERAL_ROLE_ONLY &&
              !delay_role_switch) {
            BTM_SwitchRoleToCentral(
            get_btm_client_interface().link_policy.BTM_SwitchRoleToCentral(
                bta_dm_cb.device_list.peer_device[i].peer_bdaddr);
          } else {
            alarm_set_on_mloop(bta_dm_cb.switch_delay_timer,
@@ -1412,7 +1423,8 @@ void bta_dm_eir_update_uuid(uint16_t uuid16, bool adding) {
  if (adding) {
    LOG_INFO("EIR Adding UUID=0x%04X into extended inquiry response", uuid16);

    BTM_AddEirService(bta_dm_cb.eir_uuid, uuid16);
    get_btm_client_interface().eir.BTM_AddEirService(bta_dm_cb.eir_uuid,
                                                     uuid16);
  } else {
    LOG_INFO("EIR Removing UUID=0x%04X from extended inquiry response", uuid16);

@@ -1515,7 +1527,8 @@ static void bta_ble_energy_info_cmpl(tBTM_BLE_TX_TIME_MS tx_time,
void bta_dm_ble_get_energy_info(
    tBTA_BLE_ENERGY_INFO_CBACK* p_energy_info_cback) {
  bta_dm_cb.p_energy_info_cback = p_energy_info_cback;
  tBTM_STATUS btm_status = BTM_BleGetEnergyInfo(bta_ble_energy_info_cmpl);
  tBTM_STATUS btm_status = get_btm_client_interface().ble.BTM_BleGetEnergyInfo(
      bta_ble_energy_info_cmpl);
  if (btm_status != BTM_CMD_STARTED)
    bta_ble_energy_info_cmpl(0, 0, 0, 0, HCI_ERR_UNSPECIFIED);
}