根据前面的两篇文章,我们就来尝试一下对android蓝牙名称和地址进行修改。
一、 蓝牙地址:添加属性ro.bt.bdaddr_path及对应的配置文件,修改蓝牙地址为public类型。
1.修改 android/device/actions/s700_cb7/system.prop ,添加ro.bt.bdaddr_path属性。
#hdmi config
ro.hdmi.onoffmode=auto
# add by zdx
ro.bt.bdaddr_path=/etc/bluetooth/bt_addr.conf
#wifi config
# for wifi signal level,if not need them,only set 0
ro.wifi.signal.level.1=-70
ro.wifi.signal.level.2=-65
ro.wifi.signal.level.3=-60
ro.wifi.signal.level.4=-55
ro.wifi.suspend_policy=RMMOD_WLAN_KO
ro.wifi.captive_portal=0
#wifi.supplicant_scan_interval=120
#wifi.interface=wlan0
# 此处有省略
2.创建bt_addr.conf文件,并添加到Android.mk。
zdx@srv-pad:~/work/android/device/actions/common/hardware/bluetooth/broadcom/modules/ap6212/conf$ ls
Android.mk bcm43438a0.hcd bt_addr.conf bt_vendor.conf
bt_addr.conf文件的内容
zdx@srv-pad:~/work/android/device/actions/common/hardware/bluetooth/broadcom/modules/ap6212/conf$ cat bt_addr.conf
11:22:33:44:55:66
修改android/device/actions/common/hardware/bluetooth/broadcom/modules/ap6212/conf/Android.mk ,把bt_addr.conf添加进来。
# Configuration
AP_BT_FIRMWARE_DIR := bluetooth
LOCAL_PATH := $(call my-dir)
# 此处有省略
include $(CLEAR_VARS)
LOCAL_MODULE := bt_vendor.conf
LOCAL_MODULE_TAGS := optional eng
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/$(AP_BT_FIRMWARE_DIR)
LOCAL_SRC_FILES := bt_vendor.conf
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := bcm43438a0.hcd
LOCAL_MODULE_TAGS := optional eng
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/$(AP_BT_FIRMWARE_DIR)
LOCAL_SRC_FILES := bcm43438a0.hcd
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := bt_addr.conf
LOCAL_MODULE_TAGS := optional eng
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/$(AP_BT_FIRMWARE_DIR)
LOCAL_SRC_FILES := bt_addr.conf
include $(BUILD_PREBUILT)
3.修改 android/external/bluetooth/bluedroid/main/Android.mk ,把bt_addr.conf 添加进来。
LOCAL_PATH := $(call my-dir)
#
# Bluetooth HW module
#
# 此处有省略
LOCAL_MODULE := bluetooth.default
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_REQUIRED_MODULES := \
auto_pair_devlist.conf \
bt_did.conf \
bt_stack.conf \
bt_addr.conf \
libbt-vendor
LOCAL_MULTILIB := 32
include $(BUILD_SHARED_LIBRARY)
4.修改蓝牙地址类型为public
在 android/device/generic/common/bluetooth/bdroid_buildcfg.h 中定义BLE_LOCAL_PRIVACY_ENABLED宏值我FALSE。
/*
* Copyright (C) 2012 The Android Open Source Project
*
* 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.
*/
#ifndef _BDROID_BUILDCFG_H
#define _BDROID_BUILDCFG_H
#define BTM_DEF_LOCAL_NAME "Android BlueDroid"
#define BLE_LOCAL_PRIVACY_ENABLED FALSE
#endif
二、 蓝牙名称:修改宏 BTM_DEF_LOCAL_NAME 的值。
修改 android/device/generic/common/bluetooth/bdroid_buildcfg.h 中BTM_DEF_LOCAL_NAME的宏定义值。
/*
* Copyright (C) 2012 The Android Open Source Project
*
* 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.
*/
#ifndef _BDROID_BUILDCFG_H
#define _BDROID_BUILDCFG_H
#define BTM_DEF_LOCAL_NAME "S700 BlueDroid"
#define BLE_LOCAL_PRIVACY_ENABLED FALSE
#endif
三、编译
zdx@srv-pad:~/work/owl$ ./config.sh
Select board type:
1. s700_aio
2. s700_cb7
3. s700_miniPC
Which would you like? [s700_aio] 2
s700 android s700_cb7 configured.
zdx@srv-pad:~/work/android/external/bluetooth/bluedroid$ mm
zdx@srv-pad:~/work/owl$ make rootfs && make firmware
编译完成后进入out目录,查看配置是否生效:
1.查看 android\out\target\product\s700_cb7\system\build.prop里面是否有 ro.bt.bdaddr_path=/etc/bluetooth/bt_addr.conf。
2.查看android\out\target\product\s700_cb7\system\etc\bluetooth下是否有bt_addr.conf文件,文件内容是否正确。
四、烧录固件并开机
查看打印:
[10:57:17.657]D/bt-btif ( 2003): local bdaddr is stored in /etc/bluetooth/bt_addr.conf
[10:57:17.657]D/bt-btif ( 2003): Got Factory BDA 11:22:33:44:55:66
[10:57:17.657]I/bluedroid( 2003): get_profile_interface socket
[10:57:17.657]I/bluedroid( 2003): get_profile_interface map_client
[10:57:17.657]I/bt-btif ( 2003): btif_mce_get_interface
[10:57:17.657]I/bt-btif ( 2003): init
[10:57:17.658]D/bt-btif ( 2003): btif_enable_service: current services:0x2000000
[10:57:17.658]I/bt-btif ( 2003): btif_get_adapter_property 2
[10:57:17.658]D/bt-btif ( 2003): btif_transfer_context event 3, len 20
[10:57:17.658]I/bt-btif ( 2003): btif_get_adapter_property 1
[10:57:17.658]D/bt-btif ( 2003): btif_transfer_context event 3, len 20
[10:57:17.658]I/GKI_LINUX( 2003): gki_task_entry task_id=1 [BTIF] starting
[10:57:17.658]D/bt-btif ( 2003): btif task starting
[10:57:17.658]D/bt-btif ( 2003): btif_associate_evt: notify ASSOCIATE_JVM
[10:57:17.658]I/bt-btif ( 2003): HAL bt_hal_cbacks->thread_evt_cb
[10:57:17.658]D/bt-btif ( 2003): btif task fetched event a001
[10:57:17.658]D/bt-btif ( 2003): btif_context_switched
[10:57:17.658]I/bt-btif ( 2003): execute storage request event : 3
[10:57:17.658]I/bt-btif ( 2003): HAL bt_hal_cbacks->adapter_properties_cb
[10:57:17.659]D/BluetoothAdapterProperties( 2003): Address is:11:22:33:44:55:66
[10:57:17.659]D/bt-btif ( 2003): btif task fetched event a001
[10:57:17.659]D/bt-btif ( 2003): btif_context_switched
[10:57:17.659]I/bt-btif ( 2003): execute storage request event : 3
[10:57:17.659]D/bt-btif ( 2003): in, bd addr:, prop type:1, len:512
[10:57:17.659]I/bt-btif ( 2003): btif_dm_get_adapter_property: type=0x1
[10:57:17.659]I/bt-btif ( 2003): HAL bt_hal_cbacks->adapter_properties_cb
[10:57:17.660]I/ActivityManager( 426): Start proc 2066:com.android.calendar/u0a22 for broadcast com.android.calendar/.UpgradeReceiver
[10:57:17.660]D/BluetoothAdapterProperties( 2003): Name is: S700 BlueDroid
[10:57:17.660]D/BluetoothManagerService( 426): Bluetooth Adapter name changed to S700 BlueDroid
[10:57:17.998]D/BluetoothManagerService( 426): Stored Bluetooth name: S700 BlueDroid