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

Commit 0f346d57 authored by Pomai Ahlo's avatar Pomai Ahlo Committed by Gerrit Code Review
Browse files

Merge "Allow SCN 30 to be freed" into main

parents 589ec9a4 f4cbadec
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#define LOG_TAG "bta"

#include <bluetooth/log.h>
#include <com_android_bluetooth_flags.h>

#include <cstdint>

@@ -64,7 +65,7 @@ uint8_t BTA_AllocateSCN(void) {
      return i + 1;  // allocated scn is index + 1
    }
  }
  log::debug("Unable to allocate an scn");
  log::warn("Unable to allocate an scn");
  return 0; /* No free ports */
}

@@ -109,12 +110,21 @@ bool BTA_FreeSCN(uint8_t scn) {
  /* Since this isn't used by HFP, this function will only free valid SCNs
   * that aren't reserved for HFP, which is range [2, RFCOMM_MAX_SCN].
   */
  if (scn < RFCOMM_MAX_SCN && scn > 1) {

  if (com::android::bluetooth::flags::allow_free_last_scn()) {
    if (scn <= RFCOMM_MAX_SCN && scn > 1) {
      bta_jv_cb.scn_in_use[scn - 1] = false;
      log::debug("Freed SCN: {}", scn);
      return true;
    }
  } else {
    if (scn < RFCOMM_MAX_SCN && scn > 1) {
      bta_jv_cb.scn_in_use[scn - 1] = false;
      log::debug("Freed SCN: {}", scn);
      return true;
    }
  }

  log::warn("Invalid SCN: {}", scn);
  return false; /* Illegal SCN passed in */
}
}