在模拟器上测试蓝牙音频
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
在 Wear OS 模拟器上,搭载 Wear OS 4 或更高版本的系统映像包含
支持模拟蓝牙。得益于此,您可以测试与蓝牙音频相关的多个使用情形。
与模拟手机配对
通过模拟器的蓝牙支持,您可以与模拟手机配对。为此,请从命令行启用设置向导:
-append-userspace-opt androidboot.setupwizard_mode=REQUIRED
通过模拟输出设备播放音频
借助模拟器的蓝牙支持,您还可以通过模拟的蓝牙输出设备播放音频。如需在模拟器中测试音频输出切换功能,请使用开源 Bumble 项目连接到模拟的蓝牙输出设备。
准备环境
如需准备开发机器以使用 Bumble,请完成以下步骤:
获取 Bumble 源代码:
git clone https://github.com/google/bumble
前往 bumble
目录,然后构建并安装 Bumble 模块:
cd bumble && python3 -m pip install "."
启动模拟蓝牙音箱
如需启动模拟音箱,请完成以下步骤:
启动支持 Wear OS 4 或更高版本的模拟器版本。
注意:如果您使用的是模拟器版本
低于 33.1.10 的版本,请使用
-packet-streamer-endpoint default
参数。
如需发现并连接到模拟音箱,请在 bumble
目录中运行以下命令:
python3 examples/run_a2dp_sink.py examples/a2dp_sink1.json \
android-netsim stdout | ffplay -i
系统将通过计算机的扬声器播放音频输出。
您还可以将输出重定向到文件:
python3 examples/run_a2dp_sink.py examples/a2dp_sink1.json \
android-netsim output.sbc
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Test Bluetooth audio on emulators\n\nOn the Wear OS emulator, system images that run Wear OS 4 or higher include\nsupport for emulated Bluetooth. This support lets you test several use cases\nrelated to Bluetooth audio.\n\nPair with an emulated phone\n---------------------------\n\nUsing the emulator's Bluetooth support, you can pair with an emulated phone. To\ndo so, enable the setup wizard from the command line: \n\n -append-userspace-opt androidboot.setupwizard_mode=REQUIRED\n\nPlay audio through an emulated output device\n--------------------------------------------\n\nUsing the emulator's Bluetooth support, you can also play audio through an\nemulated Bluetooth output device. To test audio output switching in the\nemulator, connect to an emulated Bluetooth output device using the open source\n[Bumble project](https://www.github.com/google/bumble).\n\n### Prepare your environment\n\nTo prepare your development machine for using Bumble, complete the following\nsteps:\n\n1. Fetch the Bumble source code:\n\n ```\n git clone https://github.com/google/bumble\n ```\n2. Navigate to the `bumble` directory, then build and install\n Bumble modules:\n\n ```\n cd bumble && python3 -m pip install \".\"\n ```\n\n### Launch emulated Bluetooth speaker\n\nTo launch the emulated speaker, complete the following steps:\n\n1. Launch a version of the emulator that supports Wear OS 4 or higher.\n\n **Note:** If you're using an emulator version\n lower than 33.1.10, launch the emulator from the command line using the\n `-packet-streamer-endpoint default` parameter.\n2. To discover and connect to the emulated speaker, run the following\n command in the `bumble` directory:\n\n ```\n python3 examples/run_a2dp_sink.py examples/a2dp_sink1.json \\\n android-netsim stdout | ffplay -i\n ```\n\n The audio output is played through your computer's speakers.\n\n You can also redirect output to a file: \n\n ```\n python3 examples/run_a2dp_sink.py examples/a2dp_sink1.json \\\n android-netsim output.sbc\n ```"]]