一. Android 蓝牙架构图
可以看到Android蓝牙一共分为几层:
- APPLICATION FRAMEWORK
- BLUETOOTH PROCESS
- JNI
- BLUETOOTH STACK
- HIDL INTERFACES
- VENDOR IMPLEMENTATAION
生成内容路径以rk3399举例,在更新的过程中会遇到这个问题,解决方式是:
root access is disabled by system setting - enable in settings -> development options
在开发者选项中选择Apps and ADB
然后每次push之前记得
adb root
adb remount
1.APPLICATION FRAMEWORK
路径:
android原生的设置apk路径如下:packages\apps\Settings
蓝牙的framework 路径如下:frameworks\base\core\java\android\bluetooth
NOTED: Android原生用蓝牙的apk是setting apk,如果你自己编写apk,不再讨论范围内
作用:
编译方式:
make Settings
清除:
make clean-Settings
生成内容:
out/target/product/rk3399_roc_pc_plus/product/priv-app/Settings/Settings.apk
NOTED:编译Setting需要在系统中编译或者需要额外签名
开发板位置:
/product/priv-app/Settings/Settings.apk
push方法:
adb push rk3399/rk3399_Android10.0/rk3399_Android10.0/out/target/product/rk3399_roc_pc_plus/product/priv-app/Settings/Settings.apk /product/priv-app/Settings/
2.BLUETOOTH PROCESS
作用:蓝牙internal apk,是一个service,对上通过binder跟framework api沟通,对下通过jni跟bluedroid蓝牙协议栈沟通
路径:packages\apps\Bluetooth
编译方式:
根目录下:make Bluetooth
清除:
make clean-Bluetooth
生成内容:
out/target/product/rk3399_roc_pc_plus/system/app/Bluetooth/Bluetooth.apk
NOTED:编译Setting需要在系统中编译或者需要额外签名
开发板位置:
/system/app/Bluetooth/Bluetooth.apk
push方法:
adb push rk3399/rk3399_Android10.0/rk3399_Android10.0/out/target/product/rk3399_roc_pc_plus/system/app/Bluetooth/Bluetooth.apk /system/app/Bluetooth/
3.JNI
作用:这个是蓝牙的jni库,编译在Bluetooth.apk中,主要通过jni跟底层的bluedroid蓝牙协议栈沟通
路径:packages\apps\Bluetooth\jni
编译方式:
make libbluetooth_jni
清除:
make clean-libbluetooth_jni
生成内容:
out/target/product/rk3399_roc_pc_plus/system/lib64/libbluetooth_jni.so
开发板位置:
/system/lib64/libbluetooth_jni.so
/system/app/Bluetooth/lib/arm64/libbluetooth_jni.so
虽然开发板中有两个位置,但是/system/app/Bluetooth/lib/arm64/libbluetooth_jni.so是一个软连接,所以真实的so还是在/system/lib64/libbluetooth_jni.so
push方法:
adb push rk3399/rk3399_Android10.0/rk3399_Android10.0/out/target/product/rk3399_roc_pc_plus/system/lib64/libbluetooth_jni.so /system/lib64/
4.BLUETOOTH STACK
作用:Android蓝牙Host本身,也就是蓝牙协议栈的主体
路径:system\bt
编译方式:
make libbluetooth
清除:
make clean-libbluetooth
生成内容:
out/target/product/rk3399_roc_pc_plus/system/lib64/libbluetooth.so
开发板位置:
/system/lib64/libbluetooth.so
/system/lib/libbluetooth.so
NOTED:要根据开发板是32位还是64位,分别push到特定的目录下
push方法:
adb push rk3399/rk3399_Android10.0/rk3399_Android10.0/out/target/product/rk3399_roc_pc_plus/system/lib64/libbluetooth.so /system/lib64/
补充:
协议栈有配置文件
/etc/bluetooth/bt_stack.conf
/etc/bluetooth/bt_did.conf
5.HIDL INTERFACES
作用:里面有几个作用,第一个是audio相关的,一个是uart相关的
路径:hardware\interfaces\bluetooth
编译方式:
make android.hardware.bluetooth@1.0-impl
清除:
make clean-android.hardware.bluetooth@1.0-impl
生成内容:
out/target/product/rk3399_roc_pc_plus/obj/SHARED_LIBRARIES/android.hardware.bluetooth@1.0-impl_intermediates/android.hardware.bluetooth@1.0-impl.so
6.VENDOR IMPLEMENTATAION
作用:特定芯片厂商的vendor部分,Android把特定常用的操作,比如power控制,下载固件,sco等行为抽象出来,用so的方式来达到切换的效果
路径:hardware\broadcom\libbt
如果是其他厂商的蓝牙,那么就是hardware\vendor_xxx\xxx_bt
编译方式:
make libbt-vendor
清除:
make clean-libbt-vendor
生成内容:
out/target/product/rk3399_roc_pc_plus/vendor/lib64/libbt-vendor.so
开发板位置:
/vendor/lib64/libbt-vendor.so
/vendor/lib/libbt-vendor.so
NOTED:要根据开发板是32位还是64位,分别push到特定的目录下
push方法:
adb push rk3399/rk3399_Android10.0/rk3399_Android10.0/
out/target/product/rk3399_roc_pc_plus/vendor/lib64/libbt-vendor.so /vendor/lib64/
补充:
bcm有vendor配置文件,具体路径在/vendor/etc/bluetooth/bt_vendor.conf
另外查看bt_vendor.conf可以查看到串口名称以及fw路径