android修改蓝牙默认名称

高通平台蓝牙定义名称在:device/qcom/common/bdroid_buildcfg.h文件中;

#define BTM_DEF_LOCAL_NAME   "QCOM-BTD"

获取蓝牙默认名称函数:

 代码路径:system\bt\btif\src\btif_dm.c

#define PROPERTY_PRODUCT_MODEL "ro.product.model"
static char* btif_get_default_local_name() {
    if (btif_default_local_name[0] == '\0')
    {
        int max_len = sizeof(btif_default_local_name) - 1;
        if (BTM_DEF_LOCAL_NAME[0] != '\0')
        {
            strncpy(btif_default_local_name, BTM_DEF_LOCAL_NAME, max_len);
        }
        else
        {
            char prop_model[PROPERTY_VALUE_MAX];
            osi_property_get(PROPERTY_PRODUCT_MODEL, prop_model, "");
            strncpy(btif_default_local_name, prop_model, max_len);
        }
        btif_default_local_name[max_len] = '\0';
    }
    return btif_default_local_name;
}

首先判断BTM_DEF_LOCAL_NAME是否为空, 如果为空则通过获取属性ro.product.model

BTM_DEF_LOCAL_NAME 在  bt_target.h的定义如下:

/* Fixed Default String. When this is defined as null string, the device's
 * product model name is used as the default local name.
 */
#ifndef BTM_DEF_LOCAL_NAME
#define BTM_DEF_LOCAL_NAME      ""
#endif

如果没有定义BTM_DEF_LOCAL_NAME,则定义BTM_DEF_LOCAL_NAME为空。

在bt_target.h文件的开头就包含了bdroid_buildcfg.h 头文件

#ifdef HAS_BDROID_BUILDCFG
#include "bdroid_buildcfg.h"
#endif

HAS_BDROID_BUILDCFG的定义可以查看Android.mk

system/bt/Android.mk 中 可以看到

# Setup Bluetooth local make variables for handling configuration
ifneq ($(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR),)
  bluetooth_C_INCLUDES := $(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR)
  bluetooth_CFLAGS += -DHAS_BDROID_BUILDCFG
else
  bluetooth_C_INCLUDES :=
  bluetooth_CFLAGS += -DHAS_NO_BDROID_BUILDCFG
endif

BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR  定义在

device/qcom/common/base.mk

BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/qcom/common

 

 

你可能感兴趣的:(蓝牙)