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

Commit 2f00e4cf authored by Chris Manton's avatar Chris Manton
Browse files

Check BTM_ReadPowerMode and BTM_SetPowerMode return values

Towards readable code

Bug: 163134718
Tag: #refactor
Test: gd/cert/run --host

Change-Id: I03a4a0005967957a56051d181965d7634f27073e
parent ba73e66a
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include "bta_sys.h"
#include "btm_api.h"
#include "device/include/controller.h"
#include "main/shim/dumpsys.h"
#include "osi/include/log.h"
#include "stack/include/acl_api.h"
#include "stack/include/btu.h"
@@ -667,11 +668,18 @@ static bool bta_dm_pm_park(const RawAddress& peer_addr) {
  tBTM_PM_MODE mode = BTM_PM_STS_ACTIVE;

  /* if not in park mode, switch to park */
  BTM_ReadPowerMode(peer_addr, &mode);
  if (!BTM_ReadPowerMode(peer_addr, &mode)) {
    LOG_WARN("Unable to read power mode for peer:%s",
             PRIVATE_ADDRESS(peer_addr));
  }

  if (mode != BTM_PM_MD_PARK) {
    BTM_SetPowerMode(bta_dm_cb.pm_id, peer_addr,
    tBTM_STATUS status = BTM_SetPowerMode(bta_dm_cb.pm_id, peer_addr,
                                          &p_bta_dm_pm_md[BTA_DM_PM_PARK_IDX]);
    if (status == BTM_CMD_STORED || status == BTM_CMD_STARTED) {
      return true;
    }
    LOG_WARN("Unable to set park power mode");
  }
  return true;
}
@@ -691,7 +699,11 @@ static void bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE* p_peer_dev, uint8_t index) {
  tBTM_PM_PWR_MD pwr_md;
  tBTM_STATUS status;

  BTM_ReadPowerMode(p_peer_dev->peer_bdaddr, &mode);
  if (!BTM_ReadPowerMode(p_peer_dev->peer_bdaddr, &mode)) {
    LOG_WARN("Unable to read power mode for peer:%s",
             PRIVATE_ADDRESS(p_peer_dev->peer_bdaddr));
  }

  uint8_t* p_rem_feat = BTM_ReadRemoteFeatures(p_peer_dev->peer_bdaddr);
  APPL_TRACE_DEBUG("bta_dm_pm_sniff cur:%d, idx:%d, info:x%x", mode, index,
                   p_peer_dev->info);
@@ -819,7 +831,11 @@ void bta_dm_pm_active(const RawAddress& peer_addr) {

  /* switch to active mode */
  pm.mode = BTM_PM_MD_ACTIVE;
  BTM_SetPowerMode(bta_dm_cb.pm_id, peer_addr, &pm);
  tBTM_STATUS status = BTM_SetPowerMode(bta_dm_cb.pm_id, peer_addr, &pm);
  if (status != BTM_CMD_STORED && status != BTM_CMD_STARTED) {
    LOG_WARN("Unable to set active mode for device:%s",
             PRIVATE_ADDRESS(peer_addr));
  }
}

/** BTM power manager callback */