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

Commit 7cc771ac authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

Check shim bluetooth::shim::is_gd_link_policy_enabled am: 9a5883ad am: 9f70e9c1

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I7a79e799d43216f58c65b0c19f21c7c72733f903
parents a505f96e 9f70e9c1
Loading
Loading
Loading
Loading
+42 −5
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@
#include "device/include/controller.h"
#include "device/include/interop.h"
#include "main/shim/dumpsys.h"
#include "main/shim/link_policy.h"
#include "main/shim/shim.h"
#include "osi/include/log.h"
#include "stack/btm/btm_int_types.h"
#include "stack/include/acl_api.h"
@@ -110,6 +112,21 @@ tBTM_STATUS BTM_PmRegister(uint8_t mask, uint8_t* p_pm_id,
                           tBTM_PM_STATUS_CBACK* p_cb) {
  int xx;

  if (bluetooth::shim::is_gd_link_policy_enabled()) {
    ASSERT(p_pm_id != nullptr);
    ASSERT(p_cb != nullptr);
    if (mask & BTM_PM_DEREG) {
      return (bluetooth::shim::UnregisterLinkPolicyClient(p_cb))
                 ? (BTM_SUCCESS)
                 : (BTM_NO_RESOURCES);
    } else {
      *p_pm_id = 0;
      return (bluetooth::shim::RegisterLinkPolicyClient(p_cb))
                 ? (BTM_SUCCESS)
                 : (BTM_NO_RESOURCES);
    }
  }

  /* de-register */
  if (mask & BTM_PM_DEREG) {
    if (*p_pm_id >= BTM_MAX_PM_RECORDS) return BTM_ILLEGAL_VALUE;
@@ -176,6 +193,12 @@ tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id, const RawAddress& remote_bda,
    mode &= (~BTM_PM_MD_FORCE);
  }

  if (bluetooth::shim::is_gd_link_policy_enabled()) {
    tBTM_PM_PWR_MD power_mode_request = *p_mode;
    power_mode_request.mode &= (~BTM_PM_MD_FORCE);
    return bluetooth::shim::BTM_SetPowerMode(*p_acl, power_mode_request);
  }

  int acl_ind = btm_pm_find_acl_ind(remote_bda);
  if (acl_ind == MAX_L2CAP_LINKS) {
    if (btm_pm_is_le_link(remote_bda)) {
@@ -319,6 +342,11 @@ tBTM_STATUS BTM_SetSsrParams(const RawAddress& remote_bda, uint16_t max_lat,
    return BTM_UNKNOWN_ADDR;
  }

  if (bluetooth::shim::is_gd_link_policy_enabled()) {
    return bluetooth::shim::BTM_SetSsrParams(*p_acl, max_lat, min_rmt_to,
                                             min_loc_to);
  }

  if (p_cb->state == BTM_PM_ST_ACTIVE || p_cb->state == BTM_PM_ST_SNIFF) {
    LOG_INFO(
        "Set sniff subrating state:%s[%d] max_latency:0x%04x "
@@ -793,9 +821,8 @@ void btm_pm_proc_mode_change(tHCI_STATUS hci_status, uint16_t hci_handle,
 * Returns          none.
 *
 ******************************************************************************/
static void process_ssr_event(tHCI_STATUS status, uint16_t handle,
                              UNUSED_ATTR uint16_t max_tx_lat,
                              uint16_t max_rx_lat) {
void process_ssr_event(tHCI_STATUS status, uint16_t handle,
                       UNUSED_ATTR uint16_t max_tx_lat, uint16_t max_rx_lat) {
  const RawAddress bd_addr = acl_address_from_handle(handle);
  if (bd_addr == RawAddress::kEmpty) {
    LOG_WARN("Received sniff subrating event with no active ACL");
@@ -834,8 +861,13 @@ static void process_ssr_event(tHCI_STATUS status, uint16_t handle,
void btm_pm_on_sniff_subrating(tHCI_STATUS status, uint16_t handle,
                               uint16_t maximum_transmit_latency,
                               uint16_t maximum_receive_latency,
                               UNUSED_ATTR uint16_t minimum_remote_timeout,
                               UNUSED_ATTR uint16_t minimum_local_timeout) {
                               uint16_t minimum_remote_timeout,
                               uint16_t minimum_local_timeout) {
  if (bluetooth::shim::is_gd_link_policy_enabled()) {
    return bluetooth::shim::btm_pm_on_sniff_subrating(
        status, handle, maximum_transmit_latency, maximum_receive_latency,
        minimum_remote_timeout, minimum_local_timeout);
  }
  process_ssr_event(status, handle, maximum_transmit_latency,
                    maximum_receive_latency);
}
@@ -933,6 +965,11 @@ tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void) {

void btm_pm_on_mode_change(tHCI_STATUS status, uint16_t handle,
                           tHCI_MODE current_mode, uint16_t interval) {
  if (bluetooth::shim::is_gd_link_policy_enabled()) {
    return bluetooth::shim::btm_pm_on_mode_change(status, handle, current_mode,
                                                  interval);
  }

  btm_sco_chk_pend_unpark(status, handle);
  btm_pm_proc_mode_change(status, handle, current_mode, interval);
}
+4 −0
Original line number Diff line number Diff line
@@ -76,6 +76,10 @@ bool bluetooth::shim::is_gd_stack_started_up() {
  mock_function_count_map[__func__]++;
  return false;
}
bool bluetooth::shim::is_gd_link_policy_enabled() {
  mock_function_count_map[__func__]++;
  return false;
}
future_t* GeneralShutDown() {
  mock_function_count_map[__func__]++;
  return nullptr;