此文描述的是 AOSP11(Android R) 版本的藍(lán)牙內(nèi)容。
1. AOSP11 Bluetooth Relative Repos
Repos | Documents | Installed Product |
---|---|---|
packages/apps/Settings/ | src/com/android/settings/bluetooth/ | Settings.apk |
src/com/android/settings/development/bluetooth/ | Settings.apk | |
frameworks/base/ | packages/SettingsLib/src/com/android/settingslib/bluetooth/ | ?? |
core/java/android/bluetooth/ | framework.jar | |
services/core/java/com/android/server/ | services.jar | |
packages/apps/Bluetooth/ | * (exclude jni/) | Bluetooth.apk |
jni/ | libbluetooth_jni.so | |
system/bt/ | * | libbluetooth.so |
hardware/interfaces/ | bluetooth/ | ?? |
- packages/apps/Settings/ 包含藍(lán)牙的設(shè)置和開發(fā)者選項(xiàng)晒来;
- frameworks/base/ 包含藍(lán)牙的 API封裝(供設(shè)置等系統(tǒng)應(yīng)用使用)踩验、標(biāo)準(zhǔn)API绢片、system_server中運(yùn)行的常駐藍(lán)牙服務(wù)府怯;
- packages/apps/Bluetooth/ 包含藍(lán)牙的核心服務(wù)和各種profile服務(wù)等盅弛;
- system/bt/ 包含藍(lán)牙的協(xié)議棧實(shí)現(xiàn)赂乐、apex赡突、binder接口定義(AIDL);
- hardware/interfaces/ 包含藍(lán)牙的 HAL 層接口定義(AIDL/HIDL)袁辈。
2. AOSP11 Bluetooth Architecture
AOSP11 Bluetooth Architecture
- 紫色框是進(jìn)程菜谣;
- 黑色框是模塊(Android 上可獨(dú)立修改安裝的包)。
- 由于藍(lán)牙進(jìn)程(com.android.bluetooth)僅在藍(lán)牙開啟時(shí)運(yùn)行,因此尾膊,在藍(lán)牙進(jìn)程未啟動(dòng)時(shí)媳危,在系統(tǒng)中需要有一個(gè)常駐模塊接收并處理 enable bluetooth 操作,該模塊即為 system_server 進(jìn)程中的 BluetoothManagerService冈敛。
2.1 AOSP11 Bluetooth Stack Architecture
AOSP11 Bluetooth Stack Architecture
注意:以上名稱主要來自AOSP的目錄名稱待笑,不確保具備通用性。
- BTIF:Bluetooth Interface抓谴,表示 JNI 與 BTA 之間的接口暮蹂;
- BTA:Bluetooth Application,表示藍(lán)牙應(yīng)用(如 profile或 與profile相關(guān))的實(shí)現(xiàn)癌压;
- STACK:Bluetooth Stack椎侠,表示藍(lán)牙核心協(xié)議棧的 Protocol 的實(shí)現(xiàn)(可能包含部分 Profile 的實(shí)現(xiàn));
- BTU:Bluetooth Upper措拇,表示 HCI 的上層,是 HCI 與 Stack 之間的接口慎宾,主要是對 HCI 操作的封裝丐吓;
- HCI:Host Controller Interface,表示藍(lán)牙 Core Spec 描述的 HCI 在AOSP中的實(shí)現(xiàn)趟据。
3. AOSP11 Bluetooth Code Description
3.1 system/bt/
Part of Bluetooth Code Description
4 AOSP11 Bluetooth Initialization Arch
Bluetooth initialization - enable in Settings & System_server process
?? Bluetooth initialization - Bluetooth process Initialization - Framework(Java)
?? Bluetooth initialization - Bluetooth process Initialization - Native(Cpp)
Bluetooth initialization - enable in Bluetooth process