如果是标准的android 4.4系统,只要定义宏 BTM_DEF_LOCAL_NAME (从明显,蓝牙模块默认名)的值即可。 在源码根目录的external/bluetooth/bluedroid/bluedroid/main/bte_conf.c 可以看到有以下代码 local_device_default_name = BTM_DEF_LOCAL_NAME; 如果没有定义该宏 ,根据external/bluetooth/bluedroid/btif/src/btif_dm.c 文件中 btif_get_default_local_name函数会去用ro.product.model属性值作为蓝牙名字。从google官方的源码Code Review网站(https://android.googlesource.com/?format=HTML 可能需要FQ才能访问)里, 在类似 device等仓库中,
device/asus/deb
device/asus/flo
device/asus/flo-kernel
device/asus/grouper Files specific to Nexus 7
device/asus/tilapia
device/common
device/generic/armv7-a
device/generic/armv7-a-neon
device/generic/art
device/generic/common
。。。。。。。。。。。
例如 device/lge/hammerhead(https://android.googlesource.com/device/asus/grouper/+/android-4.4.2_r2/bluetooth/bdroid_buildcfg.h) ,里面的bluetooth/bdroid_buildcfg.h 会有类似以下
blob: 6bb11fb967ee5e4ee0e955dcfbe6e0cddca111d9 [file history] [blame]
1./*
2. * Copyright (C) 2012 The Android Open Source Project
3. *
4. * Licensed under the Apache License, Version 2.0 (the "License");
5. * you may not use this file except in compliance with the License.
6. * You may obtain a copy of the License at
7. *
8. * http://www.apache.org/licenses/LICENSE-2.0
9. *
10. * Unless required by applicable law or agreed to in writing, software
11. * distributed under the License is distributed on an "AS IS" BASIS,
12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13. * See the License for the specific language governing permissions and
14. * limitations under the License.
15. */
16.
17.#ifndef _BDROID_BUILDCFG_H
18.#define _BDROID_BUILDCFG_H
19.
20.#define BTM_DEF_LOCAL_NAME "Nexus 7"
综上所说,可以仿官网作法,也可以直接在external/bluetooth/bluedroid/include/bt_target.h 修改,
把#define BTM_DEF_LOCAL_NAME "" 定义为你想要的名字。 重新编译系统后,记得要清掉用户数据,不然很可能Settings.apk显示的蓝牙名字可能是旧的。