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

Commit f23edfa7 authored by Arman Uguray's avatar Arman Uguray Committed by Miao Chou
Browse files

gn-build: Get btif to compile as its own module

This CL adds support to build //btif:btif as its own target as a static library
by introducing a new module-level BUILD.gn file, adding missing includes, and
conditionally compiling code that is Android-specific (depends on libcutils).
This removes/breaks some functionality on non-Android builds since the
corresponding features are missing until we have a more unified replacement.

BUG=21339022

Change-Id: Ibb0372da45f256c55fa894fdda3d70319ea008c9
parent 319860a9
Loading
Loading
Loading
Loading

system/btif/BUILD.gn

0 → 100644
+99 −0
Original line number Diff line number Diff line
#
#  Copyright (C) 2015 Google, Inc.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at:
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#

static_library("btif") {
  sources = [
    "src/btif_av.c",
    "src/btif_config.c",
    "src/btif_config_transcode.cpp",
    "src/btif_core.c",
    "src/btif_dm.c",
    "src/btif_gatt.c",
    "src/btif_gatt_client.c",
    "src/btif_gatt_multi_adv_util.c",
    "src/btif_gatt_server.c",
    "src/btif_gatt_test.c",
    "src/btif_gatt_util.c",
    "src/btif_hf.c",
    "src/btif_hf_client.c",
    "src/btif_hh.c",
    "src/btif_hl.c",
    "src/btif_mce.c",
    "src/btif_media_task.c",
    "src/btif_pan.c",
    "src/btif_profile_queue.c",
    "src/btif_rc.c",
    "src/btif_sdp.c",
    "src/btif_sdp_server.c",
    "src/btif_sm.c",
    "src/btif_sock.c",
    "src/btif_sock_l2cap.c",
    "src/btif_sock_rfc.c",
    "src/btif_sock_sco.c",
    "src/btif_sock_sdp.c",
    "src/btif_sock_thread.c",
    "src/btif_sock_util.c",
    "src/btif_storage.c",
    "src/btif_util.c",
    "src/stack_manager.c",
  ]

  # BTIF callouts
  sources += [
    "co/bta_ag_co.c",
    "co/bta_dm_co.c",
    "co/bta_av_co.c",
    "co/bta_hh_co.c",
    "co/bta_hl_co.c",
    "co/bta_pan_co.c",
    "co/bta_gattc_co.c",
    "co/bta_gatts_co.c",
  ]

  include_dirs = [
    "include",
    "//",
    "//audio_a2dp_hw",
    "//bta/include",
    "//bta/sys",
    "//btcore/include",
    "//embdrv/sbc/encoder/include",
    "//gki/common",
    "//hci/include",
    "//osi/include",
    "//stack/a2dp",
    "//stack/btm",
    "//stack/include",
    "//third_party/tinyxml2",
    "//include",
    "//udrv/include",
    "//utils/include",
    "//vnd/include",
  ]

  # TODO(armansito): Remove all of these flags below. We want to enable all
  # warnings that we can.
  cflags = [
    "-Wno-unused-variable",
    "-Wno-unused-value",
    "-Wno-unused-function",
    "-Wno-int-to-pointer-cast",
  ]

  cflags_c = [
    "-Wno-pointer-to-int-cast",
  ]
}
+0 −2
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@

#define LOG_TAG "bt_btif_bta_ag"

#include <cutils/properties.h>

#include "bta/include/bta_ag_api.h"
#include "hci/include/hci_audio.h"
#include "osi/include/osi.h"
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "osi/include/alarm.h"
#include "btcore/include/bdaddr.h"
+26 −1
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@
 ***********************************************************************************/

#include <ctype.h>
#include <cutils/properties.h>
#include <dirent.h>
#include <fcntl.h>
#include <hardware/bluetooth.h>
@@ -35,6 +34,16 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

/**
 * TODO(armansito): On OSs other than Android, the sys/properties.h system
 * does not exist. Remove this conditional include once we have a generic way
 * to obtain system properties.
 */
#if !defined(OS_GENERIC)
#include <cutils/properties.h>
#endif  /* !defined(OS_GENERIC) */

#define LOG_TAG "bt_btif_core"
#include "btcore/include/bdaddr.h"
@@ -321,6 +330,13 @@ static void btif_fetch_local_bdaddr(bt_bdaddr_t *local_addr)
    char val[256];
    uint8_t valid_bda = FALSE;
    int val_size = 0;

  /**
   * TODO(armansito): On OSs other than Android, the sys/properties.h system
   * does not exist. Remove this conditional include once we have a generic way
   * to obtain system properties.
   */
#if !defined(OS_GENERIC)
    const uint8_t null_bdaddr[BD_ADDR_LEN] = {0,0,0,0,0,0};

    /* Get local bdaddr storage path from property */
@@ -369,6 +385,7 @@ static void btif_fetch_local_bdaddr(bt_bdaddr_t *local_addr)
            local_addr->address[0], local_addr->address[1], local_addr->address[2],
            local_addr->address[3], local_addr->address[4], local_addr->address[5]);
    }
#endif  /* !defined(OS_GENERIC) */

    /* Generate new BDA if necessary */
    if (!valid_bda)
@@ -391,8 +408,16 @@ static void btif_fetch_local_bdaddr(bt_bdaddr_t *local_addr)
        BTIF_TRACE_DEBUG("No preset BDA. Generating BDA: %s for prop %s",
             (char*)bdstr, PERSIST_BDADDR_PROPERTY);


  /**
   * TODO(armansito): On OSs other than Android, the sys/properties.h system
   * does not exist. Remove this conditional include once we have a generic way
   * to obtain system properties.
   */
#if !defined(OS_GENERIC)
        if (property_set(PERSIST_BDADDR_PROPERTY, (char*)bdstr) < 0)
            BTIF_TRACE_ERROR("Failed to set random BDA in prop %s",PERSIST_BDADDR_PROPERTY);
#endif  /* !defined(OS_GENERIC) */
    }

    //save the bd address to config file
+41 −2
Original line number Diff line number Diff line
@@ -37,7 +37,15 @@

#include <hardware/bluetooth.h>

/**
 * TODO(armansito): cutils/properties.h is only being used to pull-in runtime
 * settings on Android. Remove this conditional include once we have a generic
 * way to obtain system properties.
 */
#if !defined(OS_GENERIC)
#include <cutils/properties.h>
#endif  /* !defined(OS_GENERIC) */

#include "gki.h"
#include "btu.h"
#include "btcore/include/bdaddr.h"
@@ -2721,6 +2729,12 @@ void btif_dm_set_oob_for_io_req(tBTA_OOB_DATA *p_oob_data)
#ifdef BTIF_DM_OOB_TEST
void btif_dm_load_local_oob(void)
{
  /**
   * TODO(armansito): On OSs other than Android, the sys/properties.h system
   * does not exist. Remove this conditional include once we have a generic way
   * to obtain system properties.
   */
#if !defined(OS_GENERIC)
    char prop_oob[PROPERTY_VALUE_MAX];
    property_get("service.brcm.bt.oob", prop_oob, "3");
    BTIF_TRACE_DEBUG("btif_dm_load_local_oob prop_oob = %s",prop_oob);
@@ -2733,14 +2747,21 @@ void btif_dm_load_local_oob(void)
            BTIF_TRACE_DEBUG("btif_dm_load_local_oob: read OOB, call BTA_DmLocalOob()");
            BTA_DmLocalOob();
        }
#else
#else  /* (BTM_OOB_INCLUDED != TRUE) */
        BTIF_TRACE_ERROR("BTM_OOB_INCLUDED is FALSE!!(btif_dm_load_local_oob)");
#endif
#endif  /* (BTM_OOB_INCLUDED == TRUE) */
    }
#endif  /* !defined(OS_GENERIC) */
}

void btif_dm_proc_loc_oob(BOOLEAN valid, BT_OCTET16 c, BT_OCTET16 r)
{
  /**
   * TODO(armansito): On OSs other than Android, the sys/properties.h system
   * does not exist. Remove this conditional include once we have a generic way
   * to obtain system properties.
   */
#if !defined(OS_GENERIC)
    FILE *fp;
    char *path_a = "/data/misc/bluedroid/LOCAL/a.key";
    char *path_b = "/data/misc/bluedroid/LOCAL/b.key";
@@ -2776,9 +2797,17 @@ void btif_dm_proc_loc_oob(BOOLEAN valid, BT_OCTET16 c, BT_OCTET16 r)
            }
        }
    }
#endif  /* !defined(OS_GENERIC) */
}

BOOLEAN btif_dm_proc_rmt_oob(BD_ADDR bd_addr,  BT_OCTET16 p_c, BT_OCTET16 p_r)
{
  /**
   * TODO(armansito): On OSs other than Android, the sys/properties.h system
   * does not exist. Remove this conditional include once we have a generic way
   * to obtain system properties.
   */
#if !defined(OS_GENERIC)
    char t[128];
    FILE *fp;
    char *path_a = "/data/misc/bluedroid/LOCAL/a.key";
@@ -2829,6 +2858,9 @@ BOOLEAN btif_dm_proc_rmt_oob(BD_ADDR bd_addr, BT_OCTET16 p_c, BT_OCTET16 p_r)
    }
    BTIF_TRACE_DEBUG("btif_dm_proc_rmt_oob result=%d",result);
    return result;
#else  /* defined(OS_GENERIC) */
    return FALSE;
#endif  /* !defined(OS_GENERIC) */
}
#endif /*  BTIF_DM_OOB_TEST */
#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
@@ -3224,6 +3256,12 @@ void btif_dm_read_energy_info()
}

static char* btif_get_default_local_name() {
  /**
   * TODO(armansito): On OSs other than Android, the sys/properties.h system
   * does not exist. Remove this conditional include once we have a generic way
   * to obtain system properties.
   */
#if !defined(OS_GENERIC)
    if (btif_default_local_name[0] == '\0')
    {
        int max_len = sizeof(btif_default_local_name) - 1;
@@ -3239,5 +3277,6 @@ static char* btif_get_default_local_name() {
        }
        btif_default_local_name[max_len] = '\0';
    }
#endif  /* !defined(OS_GENERIC) */
    return btif_default_local_name;
}
Loading