Przetestuj dźwięk Bluetooth na emulatorach
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
W emulatorze Wear OS obrazy systemu z Wear OS 4 lub nowszym obejmują
obsługa emulowanego Bluetootha. Ta funkcja umożliwia przetestowanie kilku przypadków użycia
związane z dźwiękiem przez Bluetooth.
Sparuj z emulowanym telefonem
Za pomocą funkcji Bluetooth w emulatorze możesz sparować z emulowanym telefonem. Do
W tym celu włącz kreator konfiguracji z poziomu wiersza poleceń:
-append-userspace-opt androidboot.setupwizard_mode=REQUIRED
Odtwarzanie dźwięku przez emulowane urządzenie wyjściowe
Dzięki obsłudze Bluetootha emulatora możesz też odtwarzać dźwięk przez
emulowanego wyjściowego urządzenia Bluetooth. Aby przetestować przełączanie wyjścia audio w
emulator, połącz się z emulowanym urządzeniem wyjściowym Bluetooth za pomocą oprogramowania open source
Projekt Bumble.
Przygotowywanie środowiska
Aby przygotować programistę do korzystania z Bumble, wykonaj te czynności
kroki:
Pobierz kod źródłowy Bumble:
git clone https://github.com/google/bumble
Przejdź do katalogu bumble
, a następnie skompiluj i zainstaluj
Moduły Bumble:
cd bumble && python3 -m pip install "."
Uruchom emulowany głośnik Bluetooth
Aby uruchomić emulowany głośnik, wykonaj te czynności:
Uruchom wersję emulatora, która obsługuje Wear OS 4 lub nowszy.
Uwaga: jeśli używasz wersji emulatora
niż w wersji 33.1.10, uruchom emulator z poziomu wiersza poleceń,
-packet-streamer-endpoint default
.
Aby wykryć emulowany głośnik i się z nim połączyć, uruchom to
w katalogu bumble
:
python3 examples/run_a2dp_sink.py examples/a2dp_sink1.json \
android-netsim stdout | ffplay -i
Dźwięk jest odtwarzany przez głośniki komputera.
Możesz też przekierować dane wyjściowe do pliku:
python3 examples/run_a2dp_sink.py examples/a2dp_sink1.json \
android-netsim output.sbc
Treść strony i umieszczone na niej fragmenty kodu podlegają licencjom opisanym w Licencji na treści. Java i OpenJDK są znakami towarowymi lub zastrzeżonymi znakami towarowymi należącymi do firmy Oracle lub jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-27 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-07-27 UTC."],[],[],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 ```"]]