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

Commit 077c8e82 authored by Hieu Dang's avatar Hieu Dang Committed by Automerger Merge Worker
Browse files

Merge "Separate default role logic and acl paging logic" am: e3b3b845 am:...

Merge "Separate default role logic and acl paging logic" am: e3b3b845 am: f870aea3 am: 00247886

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2114675



Change-Id: I777e09ac48a3c7773af90afc889dc56e6f41dac3
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents d4a67190 00247886
Loading
Loading
Loading
Loading
+25 −15
Original line number Diff line number Diff line
@@ -1334,6 +1334,30 @@ void btm_rejectlist_role_change_device(const RawAddress& bd_addr,
  }
}

/*******************************************************************************
 *
 * Function         acl_cache_role
 *
 * Description      This function caches the role of the device associated
 *                  with the given address. This happens if we get a role change
 *                  before connection complete. The cached role is propagated
 *                  when ACL Link is created.
 *
 * Returns          void
 *
 ******************************************************************************/

void acl_cache_role(const RawAddress& bd_addr, tHCI_ROLE new_role,
                    bool overwrite_cache) {
  if (overwrite_cache || delayed_role_change_ == nullptr) {
    RoleChangeView role_change;
    role_change.new_role = new_role;
    role_change.bd_addr = bd_addr;
    delayed_role_change_ =
        std::make_unique<RoleChangeView>(std::move(role_change));
  }
}

/*******************************************************************************
 *
 * Function         btm_acl_role_changed
@@ -1353,11 +1377,7 @@ void StackAclBtmAcl::btm_acl_role_changed(tHCI_STATUS hci_status,
  if (p_acl == nullptr) {
    // If we get a role change before connection complete, we cache the new
    // role here and then propagate it when ACL Link is created.
    RoleChangeView role_change;
    role_change.new_role = new_role;
    role_change.bd_addr = bd_addr;
    delayed_role_change_ =
        std::make_unique<RoleChangeView>(std::move(role_change));
    acl_cache_role(bd_addr, new_role, /*overwrite_cache=*/true);
    LOG_WARN("Unable to find active acl");
    return;
  }
@@ -2163,16 +2183,6 @@ void btm_acl_reset_paging(void) {
 *
 ******************************************************************************/
void btm_acl_paging(BT_HDR* p, const RawAddress& bda) {
  // This function is called by the device initiating the connection.
  // If no role change is requested from the remote device, we want
  // to classify the connection initiator as the central device.
  if (delayed_role_change_ == nullptr) {
    RoleChangeView role_change;
    role_change.bd_addr = bda;
    role_change.new_role = HCI_ROLE_CENTRAL;
    delayed_role_change_ =
        std::make_unique<RoleChangeView>(std::move(role_change));
  }
  if (!BTM_IsAclConnectionUp(bda, BT_TRANSPORT_BR_EDR)) {
    VLOG(1) << "connecting_bda: " << btm_cb.connecting_bda;
    if (btm_cb.paging && bda == btm_cb.connecting_bda) {
+5 −0
Original line number Diff line number Diff line
@@ -561,6 +561,11 @@ void btsnd_hcic_create_conn(const RawAddress& dest, uint16_t packet_types,
  UINT8_TO_STREAM(pp, page_scan_mode);
  UINT16_TO_STREAM(pp, clock_offset);
  UINT8_TO_STREAM(pp, allow_switch);

  // If no role change is requested from the remote device, we want
  // to classify the connection initiator as the central device.
  acl_cache_role(dest, HCI_ROLE_CENTRAL, /*overwrite_cache=*/false);

  btm_acl_paging(p, dest);
}

+3 −0
Original line number Diff line number Diff line
@@ -79,3 +79,6 @@ void btm_pm_on_sniff_subrating(tHCI_STATUS status, uint16_t handle,
                               uint16_t maximum_receive_latency,
                               uint16_t minimum_remote_timeout,
                               uint16_t minimum_local_timeout);

void acl_cache_role(const RawAddress& bd_addr, tHCI_ROLE new_role,
                    bool overwrite_cache);
 No newline at end of file