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

Commit 9bc05f77 authored by Pomai Ahlo's avatar Pomai Ahlo
Browse files

Move SCN from BTM to BTA

Move SCN allocation logic to BTA, renaming accordingly.

Bug: 299158235
Test: atest BtaRfcommScnTest
Change-Id: Iab1a4e0d9617489ecd21f2dfe83d1ce67427545f
parent db1cf430
Loading
Loading
Loading
Loading
+67 −1
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ filegroup {
    srcs: [
        "dm/bta_dm_act.cc",
        "dm/bta_dm_api.cc",
        "dm/bta_dm_sec_api.cc",
        "dm/bta_dm_cfg.cc",
        "dm/bta_dm_ci.cc",
        "dm/bta_dm_disc.cc",
@@ -48,6 +47,7 @@ filegroup {
        "dm/bta_dm_main.cc",
        "dm/bta_dm_pm.cc",
        "dm/bta_dm_sec.cc",
        "dm/bta_dm_sec_api.cc",
    ],
}

@@ -184,6 +184,7 @@ cc_library_static {
        "jv/bta_jv_act.cc",
        "jv/bta_jv_api.cc",
        "jv/bta_jv_cfg.cc",
        "rfcomm/bta_rfcomm_scn.cc",
        "sdp/bta_sdp.cc",
        "sdp/bta_sdp_act.cc",
        "sdp/bta_sdp_api.cc",
@@ -340,6 +341,7 @@ cc_test {
        ":TestCommonMainHandler",
        ":TestCommonMockFunctions",
        ":TestFakeOsi",
        ":TestMockBtaScn",
        ":TestMockBtaSdp",
        ":TestMockBtif",
        ":TestMockDevice",
@@ -452,6 +454,70 @@ cc_test {
    cflags: ["-Wno-unused-parameter"],
}

cc_test {
    name: "bt_host_test_bta_scn",
    defaults: [
        "bluetooth_gtest_x86_asan_workaround",
        "fluoride_bta_defaults",
        "mts_defaults",
    ],
    test_suites: ["device-tests"],
    host_supported: true,
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/gd",
    ],
    generated_headers: [
        "BluetoothGeneratedDumpsysDataSchema_h",
    ],
    srcs: [
        ":TestCommonMockFunctions",
        ":TestFakeOsi",
        ":TestMockBtaSys",
        ":TestMockBtif",
        ":TestMockStackBtm",
        ":TestMockStackGap",
        ":TestMockStackL2cap",
        ":TestMockStackRfcomm",
        ":TestMockStackSdp",
        "jv/bta_jv_act.cc",
        "rfcomm/bta_rfcomm_scn.cc",
        "test/bta_rfcomm_scn_test.cc",
    ],
    shared_libs: [
        "libbase",
        "libcrypto",
        "libcutils",
        "liblog",
    ],
    static_libs: [
        "libbluetooth-types",
        "libbt-common",
        "libbt-platform-protos-lite",
        "libbt_shim_bridge",
        "libbt_shim_ffi",
        "libbtcore",
        "libbtdevice",
        "libchrome",
        "libcom.android.sysprop.bluetooth",
        "libevent",
        "libgmock",
    ],
    sanitize: {
        address: true,
        cfi: true,
        misc_undefined: ["bounds"],
    },
    target: {
        android: {
            whole_static_libs: [
                "libPlatformProperties",
            ],
        },
    },
    cflags: ["-Wno-unused-parameter"],
}

// csis unit tests for host
cc_test {
    name: "bluetooth_csis_test",
+1 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ static_library("bta") {
    "pan/bta_pan_api.cc",
    "pan/bta_pan_ci.cc",
    "pan/bta_pan_main.cc",
    "rfcomm/bta_rfcomm_scn.cc",
    "sdp/bta_sdp.cc",
    "sdp/bta_sdp_act.cc",
    "sdp/bta_sdp_api.cc",
+3 −2
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include "bt_target.h"  // Legacy stack config
#include "bt_trace.h"   // Legacy trace logging
#include "bta/ag/bta_ag_int.h"
#include "bta/include/bta_rfcomm_scn.h"
#include "btif/include/btif_config.h"
#include "device/include/interop.h"
#include "device/include/interop_config.h"
@@ -257,7 +258,7 @@ void bta_ag_create_records(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) {
      if (bta_ag_cb.profile[i].sdp_handle == 0) {
        bta_ag_cb.profile[i].sdp_handle =
            get_legacy_stack_sdp_api()->handle.SDP_CreateRecord();
        bta_ag_cb.profile[i].scn = BTM_AllocateSCN();
        bta_ag_cb.profile[i].scn = BTA_AllocateSCN();
        bta_ag_add_record(bta_ag_uuid[i], data.api_register.p_name[i],
                          bta_ag_cb.profile[i].scn, data.api_register.features,
                          bta_ag_cb.profile[i].sdp_handle);
@@ -307,7 +308,7 @@ void bta_ag_del_records(tBTA_AG_SCB* p_scb) {
            bta_ag_cb.profile[i].sdp_handle);
        bta_ag_cb.profile[i].sdp_handle = 0;
      }
      BTM_FreeSCN(bta_ag_cb.profile[i].scn);
      BTA_FreeSCN(bta_ag_cb.profile[i].scn);
      bta_sys_remove_uuid(bta_ag_uuid[i]);
    }
  }
+3 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@

#include "bta/hf_client/bta_hf_client_int.h"
#include "bta/include/bta_hf_client_api.h"
#include "bta/include/bta_rfcomm_scn.h"
#include "bta/sys/bta_sys.h"
#include "osi/include/allocator.h"
#include "osi/include/osi.h"  // UNUSED_ATTR
@@ -182,7 +183,7 @@ void bta_hf_client_create_record(tBTA_HF_CLIENT_CB_ARR* client_cb_arr,
  if (client_cb_arr->sdp_handle == 0) {
    client_cb_arr->sdp_handle =
        get_legacy_stack_sdp_api()->handle.SDP_CreateRecord();
    client_cb_arr->scn = BTM_AllocateSCN();
    client_cb_arr->scn = BTA_AllocateSCN();
    bta_hf_client_add_record(p_service_name, client_cb_arr->scn,
                             client_cb_arr->features,
                             client_cb_arr->sdp_handle);
@@ -207,7 +208,7 @@ void bta_hf_client_del_record(tBTA_HF_CLIENT_CB_ARR* client_cb) {
  if (client_cb->sdp_handle != 0) {
    get_legacy_stack_sdp_api()->handle.SDP_DeleteRecord(client_cb->sdp_handle);
    client_cb->sdp_handle = 0;
    BTM_FreeSCN(client_cb->scn);
    BTA_FreeSCN(client_cb->scn);
    bta_sys_remove_uuid(UUID_SERVCLASS_HF_HANDSFREE);
  }
}
+3 −3
Original line number Diff line number Diff line
@@ -18,6 +18,6 @@

#include <cstdint>

uint8_t BTM_AllocateSCN(void);
bool BTM_FreeSCN(uint8_t scn);
bool BTM_TryAllocateSCN(uint8_t scn);
uint8_t BTA_AllocateSCN(void);
bool BTA_FreeSCN(uint8_t scn);
bool BTA_TryAllocateSCN(uint8_t scn);
Loading