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

Commit a9fcd500 authored by Archie Pusaka's avatar Archie Pusaka
Browse files

Put smp total_tx_unacked operations behind flag

Use the l2cap_tx_complete_cb_info flag to guard the smp operations.

Bug: 314819704
Bug: 301168932
Test: m -j

Change-Id: I8d2f547207cfa675e929a123850017e13dc463eb
parent 8247e188
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -305,6 +305,7 @@ cc_library_static {
        "libbt-platform-protos-lite",
        "libbt-platform-protos-lite",
        "libbt_shim_bridge",
        "libbt_shim_bridge",
        "libcom.android.sysprop.bluetooth.wrapped",
        "libcom.android.sysprop.bluetooth.wrapped",
        "server_configurable_flags",
    ],
    ],
    shared_libs: [
    shared_libs: [
        "libPlatformProperties",
        "libPlatformProperties",
@@ -493,7 +494,11 @@ cc_fuzz {
        "fuzzers/smp_fuzzer.cc",
        "fuzzers/smp_fuzzer.cc",
        "smp/*.cc", // add other sources files  (p256 related) under smp into this test
        "smp/*.cc", // add other sources files  (p256 related) under smp into this test
    ],
    ],
    shared_libs: [
        "server_configurable_flags",
    ],
    static_libs: [
    static_libs: [
        "bluetooth_flags_c_lib",
        "libbluetooth-types",
        "libbluetooth-types",
        "libbluetooth_crypto_toolbox",
        "libbluetooth_crypto_toolbox",
        "libbluetooth_hci_pdl",
        "libbluetooth_hci_pdl",
@@ -863,6 +868,7 @@ cc_test {
    shared_libs: [
    shared_libs: [
        "libcrypto",
        "libcrypto",
        "libcutils",
        "libcutils",
        "server_configurable_flags",
    ],
    ],
    static_libs: [
    static_libs: [
        "libbluetooth-types",
        "libbluetooth-types",
+9 −0
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@


#define LOG_TAG "smp"
#define LOG_TAG "smp"


#include "android_bluetooth_flags.h"
#include "internal_include/bt_target.h"
#include "internal_include/bt_target.h"
#include "os/log.h"
#include "os/log.h"
#include "osi/include/allocator.h"
#include "osi/include/allocator.h"
@@ -221,6 +222,14 @@ static void smp_data_received(uint16_t channel, const RawAddress& bd_addr,
static void smp_tx_complete_callback(uint16_t cid, uint16_t num_pkt) {
static void smp_tx_complete_callback(uint16_t cid, uint16_t num_pkt) {
  tSMP_CB* p_cb = &smp_cb;
  tSMP_CB* p_cb = &smp_cb;


#ifndef TARGET_FLOSS
  if (!IS_FLAG_ENABLED(l2cap_tx_complete_cb_info)) {
    LOG_VERBOSE("Exit since l2cap_tx_complete_cb_info is disabled");
    return;
  }
#endif

  LOG_VERBOSE("l2cap_tx_complete_cb_info is enabled, continue");
  if (p_cb->total_tx_unacked >= num_pkt) {
  if (p_cb->total_tx_unacked >= num_pkt) {
    p_cb->total_tx_unacked -= num_pkt;
    p_cb->total_tx_unacked -= num_pkt;
  } else {
  } else {
+24 −2
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@
#include <cstdint>
#include <cstdint>
#include <cstring>
#include <cstring>


#include "android_bluetooth_flags.h"
#include "crypto_toolbox/crypto_toolbox.h"
#include "crypto_toolbox/crypto_toolbox.h"
#include "device/include/controller.h"
#include "device/include/controller.h"
#include "internal_include/bt_target.h"
#include "internal_include/bt_target.h"
@@ -364,7 +365,6 @@ bool smp_send_msg_to_L2CAP(const RawAddress& rem_bda, BT_HDR* p_toL2CAP) {


  LOG_VERBOSE("rem_bda:%s, over_bredr:%d", ADDRESS_TO_LOGGABLE_CSTR(rem_bda),
  LOG_VERBOSE("rem_bda:%s, over_bredr:%d", ADDRESS_TO_LOGGABLE_CSTR(rem_bda),
              smp_cb.smp_over_br);
              smp_cb.smp_over_br);
  smp_cb.total_tx_unacked += 1;


  smp_log_metrics(rem_bda, true /* outgoing */,
  smp_log_metrics(rem_bda, true /* outgoing */,
                  p_toL2CAP->data + p_toL2CAP->offset, p_toL2CAP->len,
                  p_toL2CAP->data + p_toL2CAP->offset, p_toL2CAP->len,
@@ -373,9 +373,31 @@ bool smp_send_msg_to_L2CAP(const RawAddress& rem_bda, BT_HDR* p_toL2CAP) {
  l2cap_ret = L2CA_SendFixedChnlData(fixed_cid, rem_bda, p_toL2CAP);
  l2cap_ret = L2CA_SendFixedChnlData(fixed_cid, rem_bda, p_toL2CAP);
  if (l2cap_ret == L2CAP_DW_FAILED) {
  if (l2cap_ret == L2CAP_DW_FAILED) {
    LOG_ERROR("SMP failed to pass msg to L2CAP");
    LOG_ERROR("SMP failed to pass msg to L2CAP");
    smp_cb.total_tx_unacked -= 1;
    return false;
    return false;
  } else {
  } else {
#ifdef TARGET_FLOSS
    if (true)
#else
    if (IS_FLAG_ENABLED(l2cap_tx_complete_cb_info))
#endif
    {
      LOG_VERBOSE("l2cap_tx_complete_cb_info is enabled, exit here");
      smp_cb.total_tx_unacked += 1;
      return true;
    }

    tSMP_CB* p_cb = &smp_cb;

    LOG_VERBOSE("l2cap_tx_complete_cb_info is disabled");
    if (p_cb->wait_for_authorization_complete) {
      tSMP_INT_DATA smp_int_data;
      smp_int_data.status = SMP_SUCCESS;
      if (fixed_cid == L2CAP_SMP_CID) {
        smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
      } else {
        smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &smp_int_data);
      }
    }
    return true;
    return true;
  }
  }
}
}