first commit
This commit is contained in:
commit
669f49b1d6
342 files changed
+320811
No files matched your search
@@ -0,0 +1,112 @@
|
||||
# 01_启动初始化流程
|
||||
|
||||
## 目标
|
||||
|
||||
搞清楚蓝牙音乐模块什么时候初始化、初始化了哪些对象。
|
||||
|
||||
## 启动流程
|
||||
|
||||
```text
|
||||
1. 蓝牙 App 进程启动
|
||||
↓
|
||||
2. BluetoothApplication.onCreate()
|
||||
↓
|
||||
3. 调用父类 BluetoothSdkApplication.onCreate()
|
||||
↓
|
||||
4. BluetoothSdkApplication.setPlatform()
|
||||
↓
|
||||
5. 初始化各蓝牙业务 Manager
|
||||
↓
|
||||
6. BtMusicControlManager.getInstance().init(context)
|
||||
↓
|
||||
7. 创建 BtMusicManager
|
||||
↓
|
||||
8. BtMusicManager.init(context)
|
||||
↓
|
||||
9. 初始化 BluetoothAvrcpClient
|
||||
↓
|
||||
10. 初始化 BtMusicAudioManager
|
||||
↓
|
||||
11. BluetoothApplication 启动 BluetoothService
|
||||
```
|
||||
|
||||
## 关键源码
|
||||
|
||||
### 1. 蓝牙 App 启动
|
||||
|
||||
```text
|
||||
文件:
|
||||
F:\zdCode\tongli\YX_BlueTooth\src\main\java\com\yaxon\bluetooth\BluetoothApplication.java
|
||||
|
||||
核心:
|
||||
onCreate()
|
||||
-> super.onCreate()
|
||||
-> SharedPrefsManager.init()
|
||||
-> initBluetoothService()
|
||||
```
|
||||
|
||||
### 2. SDK 初始化
|
||||
|
||||
```text
|
||||
文件:
|
||||
F:\zdCode\tongli\YX_BluetoothSDK\src\main\java\com\yaxon\bluetoothsdk\BluetoothSdkApplication.java
|
||||
|
||||
核心:
|
||||
setPlatform()
|
||||
-> BtContactsControlManager.init()
|
||||
-> BtSettingControlManager.init()
|
||||
-> BtPhoneControlManager.init()
|
||||
-> BtCallRecordsControlManager.init()
|
||||
-> BtMusicControlManager.init()
|
||||
-> BtVoiceControlManager.init()
|
||||
```
|
||||
|
||||
### 3. 蓝牙音乐初始化
|
||||
|
||||
```text
|
||||
文件:
|
||||
F:\zdCode\tongli\YX_BluetoothSDK\src\main\java\com\yaxon\bluetoothsdk\manager\BtMusicControlManager.java
|
||||
|
||||
核心:
|
||||
init(context)
|
||||
-> new BtMusicManager()
|
||||
-> mBtMusicManager.init(context)
|
||||
-> mBtMusicManager.initMusicInfo()
|
||||
```
|
||||
|
||||
### 4. 音乐核心初始化
|
||||
|
||||
```text
|
||||
文件:
|
||||
F:\zdCode\tongli\YX_BluetoothSDK\src\main\java\com\yaxon\bluetoothsdk\modules\BtMusicManager.java
|
||||
|
||||
核心:
|
||||
init(context)
|
||||
-> initData(context)
|
||||
-> initListener()
|
||||
|
||||
initData(context)
|
||||
-> mMusicInfoBean = new MusicInfo()
|
||||
-> BluetoothAvrcpClient.getInstance().init(context)
|
||||
-> BtMusicAudioManager.getInstance().init(context, this)
|
||||
-> BluetoothA2dpSinkClient.getInstance()
|
||||
```
|
||||
|
||||
## 初始化后已经具备的能力
|
||||
|
||||
| 能力 | 是否已准备 |
|
||||
|---|---|
|
||||
| 接收 AVRCP 歌曲信息 | 是 |
|
||||
| 接收 AVRCP 播放状态 | 是 |
|
||||
| 下发播放/暂停/切歌控制 | 是 |
|
||||
| 监听 Launcher 控制命令 | 是 |
|
||||
| 申请/释放音频焦点 | 是 |
|
||||
| 推送蓝牙音乐信息给 Launcher | 是 |
|
||||
|
||||
## 记忆点
|
||||
|
||||
```text
|
||||
蓝牙音乐模块不是进入 BluetoothMusicActivity 才初始化。
|
||||
只要蓝牙 App 启动,BtMusicManager 和相关 SDK 就已经初始化。
|
||||
```
|
||||
|
||||
Reference in new issue
Block a user