This guide explains how to control the PowerPlay audio player via ADB commands for automated testing of power-efficient audio features (PCM Offload).
# Build and install cd samples/powerplay ../../gradlew installDebug # Play with PCM Offload enabled adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ --es command play \ --es perf_mode offload # Monitor status adb logcat -s PowerPlay:V
| Parameter | Type | Description | Example |
|---|---|---|---|
command | string | Action: play, pause, stop | --es command play |
perf_mode | string | Performance mode: none, lowlat, powersave, offload | --es perf_mode offload |
song_index | int | Track index (0-2) | --ei song_index 1 |
volume | int | Volume percentage (0-100) | --ei volume 50 |
background | boolean | Move app to background after starting | --ez background true |
duration_ms | int | Auto-stop after N milliseconds | --ei duration_ms 10000 |
use_mmap | boolean | Enable/disable MMAP audio path | --ez use_mmap false |
buffer_frames | int | Buffer size in frames (offload only) | --ei buffer_frames 4096 |
adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ --es command play \ --es perf_mode offload
adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ --es command play \ --es perf_mode offload \ --ez background true
adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ --es command play \ --es perf_mode offload \ --ei duration_ms 10000
# Low Latency adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ --es command play --es perf_mode lowlat # Power Saving (non-offload) adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ --es command play --es perf_mode powersave # PCM Offload adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ --es command play --es perf_mode offload
adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ --es command stop
The app outputs status to logcat with the PowerPlay tag in a parseable format:
POWERPLAY_STATUS: PLAYING | SONG=0 | OFFLOAD=true | MMAP=true POWERPLAY_STATUS: PAUSED POWERPLAY_STATUS: STOPPED | REASON=AUTO_STOP
| Status | Meaning |
|---|---|
PLAYING | Audio playback is active |
PAUSED | Audio playback is paused |
STOPPED | Audio playback has stopped |
ERROR | An error occurred |
OFFLOAD_REVOKED | PCM Offload was revoked by the system |
# Real-time monitoring adb logcat -s PowerPlay:V # Filter for status only adb logcat -s PowerPlay:V | grep "POWERPLAY_STATUS" # Save to file adb logcat -s PowerPlay:V > powerplay_test.log
For automation scripts, you can also use the dedicated test action:
adb shell am start -a com.google.oboe.samples.powerplay.TEST \ --es command play \ --es perf_mode offload
To measure power consumption with offload vs non-offload:
# Reset battery stats adb shell dumpsys batterystats --reset # Run offload test for 5 minutes adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ --es command play \ --es perf_mode offload \ --ez background true \ --ei duration_ms 300000 # Wait for test to complete, then capture stats adb shell dumpsys batterystats > battery_offload.txt
AudioManager.isOffloadedPlaybackSupported()adb shell pm list packages | grep powerplayadb shell dumpsys package com.google.oboe.samples.powerplay