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

Commit 69fe1730 authored by Chris Manton's avatar Chris Manton
Browse files

[1/24] Canonical form towards class enumification tBTM_STATUS

Prepare for class enum-ify tBTM_STATUS

Bug: 358402071
Test: m .
Flag: EXEMPT, Mechanical Refactor

Change-Id: Ia2b5b36c696476db8d4fefd59b83714e8d4b1d8b
parent 551dc422
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
#include "stack/btm/btm_sco_hfp_hal.h"
#include "stack/include/btm_api.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/btm_status.h"
#include "stack/include/main_thread.h"
#include "types/raw_address.h"

@@ -173,7 +174,7 @@ static void bta_ag_sco_conn_cback(uint16_t sco_idx) {
    /* no match found; disconnect sco, init sco variables */
    bta_ag_cb.sco.p_curr_scb = nullptr;
    bta_ag_cb.sco.state = BTA_AG_SCO_SHUTDOWN_ST;
    if (get_btm_client_interface().sco.BTM_RemoveSco(sco_idx) != BTM_SUCCESS) {
    if (get_btm_client_interface().sco.BTM_RemoveSco(sco_idx) != tBTM_STATUS::BTM_SUCCESS) {
      log::warn("Unable to remove SCO idx:{}", sco_idx);
    }
  }
@@ -324,7 +325,7 @@ static bool bta_ag_remove_sco(tBTA_AG_SCB* p_scb, bool only_active) {
        /* SCO is connected; set current control block */
        bta_ag_cb.sco.p_curr_scb = p_scb;
        return true;
      } else if ((status == BTM_SUCCESS) || (status == BTM_UNKNOWN_ADDR)) {
      } else if ((status == tBTM_STATUS::BTM_SUCCESS) || (status == BTM_UNKNOWN_ADDR)) {
        /* If no connection reset the SCO handle */
        p_scb->sco_idx = BTM_INVALID_SCO_INDEX;
      }
@@ -529,7 +530,7 @@ void bta_ag_create_sco(tBTA_AG_SCB* p_scb, bool is_orig) {
  if (is_orig) {
    bta_ag_cb.sco.is_local = true;
    /* Set eSCO Mode */
    if (get_btm_client_interface().sco.BTM_SetEScoMode(&params) != BTM_SUCCESS) {
    if (get_btm_client_interface().sco.BTM_SetEScoMode(&params) != tBTM_STATUS::BTM_SUCCESS) {
      log::warn("Unable to set ESCO mode");
    }
    bta_ag_cb.sco.p_curr_scb = p_scb;
@@ -571,7 +572,7 @@ void bta_ag_create_sco(tBTA_AG_SCB* p_scb, bool is_orig) {
            bta_ag_sco_disc_cback);
    if (btm_status == BTM_CMD_STARTED) {
      if (get_btm_client_interface().sco.BTM_RegForEScoEvts(
                  p_scb->sco_idx, bta_ag_esco_connreq_cback) != BTM_SUCCESS) {
                  p_scb->sco_idx, bta_ag_esco_connreq_cback) != tBTM_STATUS::BTM_SUCCESS) {
        log::warn("Unable to register for ESCO events");
      }
    }
+3 −2
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@
#include "stack/include/bt_uuid16.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/btm_log_history.h"
#include "stack/include/btm_status.h"
#include "stack/include/l2c_api.h"
#include "storage/config_keys.h"
#include "types/hci_role.h"
@@ -1867,7 +1868,7 @@ void bta_av_do_start(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
   * disable sniff mode unconditionally during streaming */
  tHCI_ROLE cur_role;
  if ((get_btm_client_interface().link_policy.BTM_GetRole(p_scb->PeerAddress(), &cur_role) ==
       BTM_SUCCESS) &&
       tBTM_STATUS::BTM_SUCCESS) &&
      (cur_role == HCI_ROLE_CENTRAL)) {
    BTM_block_role_switch_and_sniff_mode_for(p_scb->PeerAddress());
  } else {
@@ -2339,7 +2340,7 @@ void bta_av_start_ok(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
       * central.
       * disable sniff mode unconditionally during streaming */
      if ((get_btm_client_interface().link_policy.BTM_GetRole(p_scb->PeerAddress(), &cur_role) ==
           BTM_SUCCESS) &&
           tBTM_STATUS::BTM_SUCCESS) &&
          (cur_role == HCI_ROLE_CENTRAL)) {
        BTM_block_role_switch_and_sniff_mode_for(p_scb->PeerAddress());
      } else {
+4 −2
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_uuid16.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/btm_status.h"
#include "stack/include/hci_error_code.h"
#include "stack/include/sdp_api.h"
#include "storage/config_keys.h"
@@ -921,7 +922,8 @@ static void bta_av_sys_rs_cback(tBTA_SYS_CONN_STATUS /* status */, tHCI_ROLE new

  /* restore role switch policy, if role switch failed */
  if ((HCI_SUCCESS != hci_status) &&
      (get_btm_client_interface().link_policy.BTM_GetRole(peer_addr, &cur_role) == BTM_SUCCESS) &&
      (get_btm_client_interface().link_policy.BTM_GetRole(peer_addr, &cur_role) ==
       tBTM_STATUS::BTM_SUCCESS) &&
      (cur_role == HCI_ROLE_PERIPHERAL)) {
    get_btm_client_interface().link_policy.BTM_unblock_role_switch_for(peer_addr);
  }
@@ -1079,7 +1081,7 @@ bool bta_av_switch_if_needed(tBTA_AV_SCB* p_scb) {
bool bta_av_link_role_ok(tBTA_AV_SCB* p_scb, uint8_t bits) {
  tHCI_ROLE role;
  if (get_btm_client_interface().link_policy.BTM_GetRole(p_scb->PeerAddress(), &role) !=
      BTM_SUCCESS) {
      tBTM_STATUS::BTM_SUCCESS) {
    log::warn("Unable to find link role for device:{}", p_scb->PeerAddress());
    return true;
  }
+3 −2
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@
#include "stack/include/bt_types.h"
#include "stack/include/btm_ble_sec_api.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/btm_status.h"

using base::Closure;
using bluetooth::Uuid;
@@ -1845,7 +1846,7 @@ private:
      case BTA_GATTC_ENC_CMPL_CB_EVT: {
        tBTM_STATUS encryption_status;
        if (BTM_IsEncrypted(p_data->enc_cmpl.remote_bda, BT_TRANSPORT_LE)) {
          encryption_status = BTM_SUCCESS;
          encryption_status = tBTM_STATUS::BTM_SUCCESS;
        } else {
          encryption_status = BTM_FAILED_ON_SECURITY;
        }
@@ -2056,7 +2057,7 @@ private:
      return;
    }

    if (status != BTM_SUCCESS) {
    if (status != tBTM_STATUS::BTM_SUCCESS) {
      log::error("encryption failed. status: 0x{:02x}", status);

      BTA_GATTC_Close(device->conn_id);
+18 −16
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@
#include "stack/include/bt_uuid16.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/btm_inq.h"
#include "stack/include/btm_status.h"
#include "stack/include/gatt_api.h"
#include "stack/include/l2c_api.h"
#include "stack/include/main_thread.h"
@@ -235,7 +236,7 @@ void BTA_dm_on_hw_on() {
  log::info("Read default class of device [0x{:x}, 0x{:x}, 0x{:x}]", dev_class[0], dev_class[1],
            dev_class[2]);

  if (get_btm_client_interface().local.BTM_SetDeviceClass(dev_class) != BTM_SUCCESS) {
  if (get_btm_client_interface().local.BTM_SetDeviceClass(dev_class) != tBTM_STATUS::BTM_SUCCESS) {
    log::warn("Unable to set local device class:{}", dev_class_text(dev_class));
  }

@@ -314,10 +315,10 @@ void bta_dm_disable() {
  /* disable all active subsystems */
  bta_sys_disable();

  if (BTM_SetDiscoverability(BTM_NON_DISCOVERABLE) != BTM_SUCCESS) {
  if (BTM_SetDiscoverability(BTM_NON_DISCOVERABLE) != tBTM_STATUS::BTM_SUCCESS) {
    log::warn("Unable to disable classic BR/EDR discoverability");
  }
  if (BTM_SetConnectability(BTM_NON_CONNECTABLE) != BTM_SUCCESS) {
  if (BTM_SetConnectability(BTM_NON_CONNECTABLE) != tBTM_STATUS::BTM_SUCCESS) {
    log::warn("Unable to disable classic BR/EDR connectability");
  }

@@ -448,10 +449,10 @@ bool BTA_DmSetVisibility(bt_scan_mode_t mode) {
      return false;
  }

  if (BTM_SetDiscoverability(disc_mode_param) != BTM_SUCCESS) {
  if (BTM_SetDiscoverability(disc_mode_param) != tBTM_STATUS::BTM_SUCCESS) {
    log::warn("Unable to set classic BR/EDR discoverability 0x{:04x}", disc_mode_param);
  }
  if (BTM_SetConnectability(conn_mode_param) != BTM_SUCCESS) {
  if (BTM_SetConnectability(conn_mode_param) != tBTM_STATUS::BTM_SUCCESS) {
    log::warn("Unable to set classic BR/EDR connectability 0x{:04x}", conn_mode_param);
  }
  return true;
@@ -609,11 +610,11 @@ void bta_dm_remove_device(const RawAddress& target) {
  // Disconnect LE transport
  if (le_connected) {
    tBTM_STATUS status = btm_remove_acl(pseudo_addr, BT_TRANSPORT_LE);
    if (status != BTM_SUCCESS && identity_addr != pseudo_addr) {
    if (status != tBTM_STATUS::BTM_SUCCESS && identity_addr != pseudo_addr) {
      status = btm_remove_acl(identity_addr, BT_TRANSPORT_LE);
    }

    if (status != BTM_SUCCESS) {
    if (status != tBTM_STATUS::BTM_SUCCESS) {
      le_connected = false;
      log::error("Unable to disconnect LE connection {}", pseudo_addr);
    }
@@ -622,11 +623,11 @@ void bta_dm_remove_device(const RawAddress& target) {
  // Disconnect BR/EDR transport
  if (bredr_connected) {
    tBTM_STATUS status = btm_remove_acl(identity_addr, BT_TRANSPORT_BR_EDR);
    if (status != BTM_SUCCESS && identity_addr != pseudo_addr) {
    if (status != tBTM_STATUS::BTM_SUCCESS && identity_addr != pseudo_addr) {
      status = btm_remove_acl(pseudo_addr, BT_TRANSPORT_BR_EDR);
    }

    if (status != BTM_SUCCESS) {
    if (status != tBTM_STATUS::BTM_SUCCESS) {
      bredr_connected = false;
      log::error("Unable to disconnect BR/EDR connection {}", identity_addr);
    }
@@ -721,7 +722,7 @@ static void handle_role_change(const RawAddress& bd_addr, tHCI_ROLE new_role,
      const tBTM_STATUS status =
              get_btm_client_interface().link_policy.BTM_SwitchRoleToCentral(bd_addr);
      switch (status) {
        case BTM_SUCCESS:
        case tBTM_STATUS::BTM_SUCCESS:
          log::debug("Role policy already set to central peer:{}", bd_addr);
          break;
        case BTM_CMD_STARTED:
@@ -1022,7 +1023,7 @@ static void bta_dm_check_av() {
        const tBTM_STATUS status =
                get_btm_client_interface().link_policy.BTM_SwitchRoleToCentral(p_dev->peer_bdaddr);
        switch (status) {
          case BTM_SUCCESS:
          case tBTM_STATUS::BTM_SUCCESS:
            log::debug("Role policy already set to central peer:{}", p_dev->peer_bdaddr);
            break;
          case BTM_CMD_STARTED:
@@ -1175,7 +1176,7 @@ static void bta_dm_adjust_roles(bool delay_role_switch) {
                    get_btm_client_interface().link_policy.BTM_SwitchRoleToCentral(
                            bta_dm_cb.device_list.peer_device[i].peer_bdaddr);
            switch (status) {
              case BTM_SUCCESS:
              case tBTM_STATUS::BTM_SUCCESS:
                log::debug("Role policy already set to central peer:{}",
                           bta_dm_cb.device_list.peer_device[i].peer_bdaddr);
                break;
@@ -1257,7 +1258,7 @@ static void bta_dm_set_eir(char* local_name) {
  /* if local name is not provided, get it from controller */
  if (local_name == NULL) {
    if (get_btm_client_interface().local.BTM_ReadLocalDeviceName((const char**)&local_name) !=
        BTM_SUCCESS) {
        tBTM_STATUS::BTM_SUCCESS) {
      log::error("Fail to read local device name for EIR");
    }
  }
@@ -1441,7 +1442,7 @@ static void bta_dm_set_eir(char* local_name) {
    UINT8_TO_STREAM(p, 0); /* terminator of significant part */
  }

  if (get_btm_client_interface().eir.BTM_WriteEIR(p_buf) != BTM_SUCCESS) {
  if (get_btm_client_interface().eir.BTM_WriteEIR(p_buf) != tBTM_STATUS::BTM_SUCCESS) {
    log::warn("Unable to write EIR data");
  }
}
@@ -1603,7 +1604,8 @@ void bta_dm_ble_set_data_length(const RawAddress& bd_addr) {
  uint16_t max_len =
          bluetooth::shim::GetController()->GetLeMaximumDataLength().supported_max_tx_octets_;

  if (get_btm_client_interface().ble.BTM_SetBleDataLength(bd_addr, max_len) != BTM_SUCCESS) {
  if (get_btm_client_interface().ble.BTM_SetBleDataLength(bd_addr, max_len) !=
      tBTM_STATUS::BTM_SUCCESS) {
    log::info("Unable to set ble data length:{}", max_len);
  }
}
@@ -1795,7 +1797,7 @@ void bta_dm_allow_wake_by_hid(std::vector<RawAddress> classic_hid_devices,
  // If there are any entries in the classic hid list, we should also make
  // the adapter connectable for classic.
  if (classic_hid_devices.size() > 0) {
    if (BTM_SetConnectability(BTM_CONNECTABLE) != BTM_SUCCESS) {
    if (BTM_SetConnectability(BTM_CONNECTABLE) != tBTM_STATUS::BTM_SUCCESS) {
      log::warn("Unable to enable classic BR/EDR connectability");
    }
  }
Loading