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

Commit 40e05f49 authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

Encapsulate tBTM_PM_MCB::state am: 6fb2557d

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1534838

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I8cd51039e1181d2ffce87e873c1fd8652d327f45
parents eb883526 6fb2557d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -512,7 +512,7 @@ void DumpsysAcl(int fd) {
    LOG_DUMPSYS(fd, "    chg_ind:%s", (btm_pm_mcb.chg_ind) ? "true" : "false");
    LOG_DUMPSYS(fd, "    role:%s", RoleText(acl_conn.link_role).c_str());
    LOG_DUMPSYS(fd, "    power_mode_state:%s",
                power_mode_state_text(btm_pm_mcb.state).c_str());
                power_mode_state_text(btm_pm_mcb.State()).c_str());
  }
}
#undef DUMPSYS_TAG
+15 −0
Original line number Diff line number Diff line
@@ -126,7 +126,22 @@ typedef struct {
  bool chg_ind;
  tBTM_PM_PWR_MD req_mode[BTM_MAX_PM_RECORDS + 1];
  tBTM_PM_PWR_MD set_mode;

 private:
  friend tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id,
                                      const RawAddress& remote_bda,
                                      const tBTM_PM_PWR_MD* p_mode);
  friend tBTM_STATUS BTM_SetSsrParams(const RawAddress& remote_bda,
                                      uint16_t max_lat, uint16_t min_rmt_to,
                                      uint16_t min_loc_to);
  friend void btm_pm_proc_cmd_status(tHCI_STATUS status);
  friend void btm_pm_proc_mode_change(tHCI_STATUS hci_status,
                                      uint16_t hci_handle, tHCI_MODE mode,
                                      uint16_t interval);
  tBTM_PM_STATE state;

 public:
  tBTM_PM_STATE State() const { return state; }
  uint16_t interval;
  uint16_t max_lat;
  uint16_t min_loc_to;
+1 −1
Original line number Diff line number Diff line
@@ -350,7 +350,7 @@ void acl_initialize_power_mode(const tACL_CONN& p_acl) {
  tBTM_PM_MCB* p_db =
      &btm_cb.acl_cb_.pm_mode_db[btm_handle_to_acl_index(p_acl.hci_handle)];
  memset(p_db, 0, sizeof(tBTM_PM_MCB));
  p_db->state = BTM_PM_ST_ACTIVE;
  p_db->Init();
}

tACL_CONN* StackAclBtmAcl::acl_allocate_connection() {
+7 −6
Original line number Diff line number Diff line
@@ -265,7 +265,7 @@ bool BTM_ReadPowerMode(const RawAddress& remote_bda, tBTM_PM_MODE* p_mode) {
    LOG_WARN("Unknown device:%s", PRIVATE_ADDRESS(remote_bda));
    return false;
  }
  *p_mode = static_cast<tBTM_PM_MODE>(p_mcb->state);
  *p_mode = static_cast<tBTM_PM_MODE>(p_mcb->State());
  return true;
}

@@ -494,7 +494,7 @@ tBTM_STATUS StackAclBtmPm::btm_pm_snd_md_req(tACL_CONN& p_acl, uint8_t pm_id,
  mode = btm_pm_get_set_mode(pm_id, p_cb, p_mode, &md_res);
  md_res.mode = mode;

  if (p_cb->state == mode) {
  if (p_cb->State() == mode) {
    LOG_INFO("Link already in requested mode pm_id:%hhu link_ind:%d mode:%d",
             pm_id, link_ind, mode);

@@ -508,12 +508,13 @@ tBTM_STATUS StackAclBtmPm::btm_pm_snd_md_req(tACL_CONN& p_acl, uint8_t pm_id,
  p_cb->chg_ind = chg_ind;

  /* cannot go directly from current mode to resulting mode. */
  if (mode != BTM_PM_MD_ACTIVE && p_cb->state != BTM_PM_MD_ACTIVE)
  if (mode != BTM_PM_MD_ACTIVE && p_cb->State() != BTM_PM_MD_ACTIVE)
    p_cb->chg_ind = true; /* needs to wake, then sleep */

  if (p_cb->chg_ind) /* needs to wake first */
    md_res.mode = BTM_PM_MD_ACTIVE;
  else if (BTM_PM_MD_SNIFF == md_res.mode && p_cb->max_lat) {
    LOG_DEBUG("Sending sniff subrating to controller");
    send_sniff_subrating(btm_cb.acl_cb_.acl_db[link_ind], p_cb->max_lat,
                         p_cb->min_rmt_to, p_cb->min_loc_to);
    p_cb->max_lat = 0;
@@ -525,17 +526,17 @@ tBTM_STATUS StackAclBtmPm::btm_pm_snd_md_req(tACL_CONN& p_acl, uint8_t pm_id,
  btm_cb.acl_cb_.pm_pend_id = pm_id;

  LOG_INFO("switching from %s(0x%x) to %s(0x%x), link_ind: %d",
           power_mode_state_text(p_cb->state).c_str(), p_cb->state,
           power_mode_state_text(p_cb->State()).c_str(), p_cb->State(),
           power_mode_state_text(md_res.mode).c_str(), md_res.mode, link_ind);
  btm_cb.history_->Push(
      "%-32s: %s  %s(0x%02x) ==> %s(0x%02x)", "Power mode change",
      PRIVATE_ADDRESS(btm_cb.acl_cb_.acl_db[link_ind].remote_addr),
      power_mode_state_text(p_cb->state).c_str(), p_cb->state,
      power_mode_state_text(p_cb->State()).c_str(), p_cb->State(),
      power_mode_state_text(md_res.mode).c_str(), md_res.mode);

  switch (md_res.mode) {
    case BTM_PM_MD_ACTIVE:
      switch (p_cb->state) {
      switch (p_cb->State()) {
        case BTM_PM_MD_SNIFF:
          btsnd_hcic_exit_sniff_mode(
              btm_cb.acl_cb_.acl_db[link_ind].hci_handle);