# 00_总览_一页看懂 ## 一句话理解 ```text 手机音乐 App 负责播放内容 车机蓝牙音乐模块负责: 1. 接收手机音乐声音 2. 显示歌名、歌手、封面、进度 3. 控制手机播放、暂停、上一曲、下一曲 4. 和收音机、USB 音乐、电话、导航等音源抢焦点 5. 把蓝牙音乐状态同步给 Launcher 卡片 ``` ## 模块角色 | 角色 | 简单解释 | 关键类 | | ---------------- | ---------------------- | ------------------------- | | A2DP Sink | 声音通道,手机把音乐声音推给车机。 | `BluetoothA2dpSinkClient` | | AVRCP Controller | 控制通道,车机控制手机音乐,也接收歌曲信息。 | `BluetoothAvrcpClient` | | MediaBrowser | 连接 Android 蓝牙媒体服务。 | `MediaBrowserClient` | | 音频焦点 | 决定蓝牙音乐是否可以出声。 | `BtMusicAudioManager` | | 蓝牙音乐核心 | 汇总连接、控制、歌曲信息、焦点。 | `BtMusicManager` | | 页面 | 给用户看的蓝牙音乐界面。 | `BluetoothMusicActivity` | | Launcher 卡片 | 桌面小组件显示和控制蓝牙音乐。 | `BluetoothMusicCardView` | ## 总体关系 ```text 手机音乐 App │ ├─ 声音流:A2DP │ ↓ │ BluetoothA2dpSinkClient │ └─ 控制/歌曲信息:AVRCP ↓ MediaBrowserClient ↓ BluetoothAvrcpClient ↓ BtMusicManager ↓ BtMusicControlManager ↓ BtMusicViewModel ↓ BluetoothMusicActivity BtMusicManager ├─ 调用 BtMusicAudioManager 管理音频焦点 └─ 调用 BtInfoPushManager 推送给 Launcher ``` ## 看代码时的方向 如果你想知道“点击按钮后发生了什么”,从上往下看: ```text BluetoothMusicActivity ↓ BtMusicViewModel ↓ BtMusicControlManager ↓ BtMusicManager ↓ BluetoothAvrcpClient ``` 如果你想知道“歌名歌手从哪里来”,从底层往页面看: ```text MediaBrowserClient ↓ BluetoothAvrcpClient ↓ BtMusicManager ↓ BtMusicViewModel ↓ BluetoothMusicActivity ``` 如果你想知道“Launcher 卡片为什么会刷新”,看: ```text BluetoothAvrcpClient ↓ BtInfoPushManager ↓ DataManager.putObject(BT_MUSIC_INFO) ↓ Id3Info ↓ BluetoothMusicCardView ```