|
| 1 | +# PowerPlay Automation Guide |
| 2 | + |
| 3 | +This guide explains how to control the PowerPlay audio player via ADB commands for automated testing of power-efficient audio features (PCM Offload). |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +```bash |
| 8 | +# Build and install |
| 9 | +cd samples/powerplay |
| 10 | +../../gradlew installDebug |
| 11 | + |
| 12 | +# Play with PCM Offload enabled |
| 13 | +adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ |
| 14 | + --es command play \ |
| 15 | + --es perf_mode offload |
| 16 | + |
| 17 | +# Monitor status |
| 18 | +adb logcat -s PowerPlay:V |
| 19 | +``` |
| 20 | + |
| 21 | +## Supported ADB Parameters |
| 22 | + |
| 23 | +| Parameter | Type | Description | Example | |
| 24 | +| -------------------- | ------- | ---------------------------------------------------------- | ------------------------------ | |
| 25 | +| `command` | string | Action: `play`, `pause`, `stop` | `--es command play` | |
| 26 | +| `perf_mode` | string | Performance mode: `none`, `lowlat`, `powersave`, `offload` | `--es perf_mode offload` | |
| 27 | +| `song_index` | int | Track index (0-2) | `--ei song_index 1` | |
| 28 | +| `volume` | int | Volume percentage (0-100) | `--ei volume 50` | |
| 29 | +| `background` | boolean | Move app to background after starting | `--ez background true` | |
| 30 | +| `duration_ms` | int | Auto-stop after N milliseconds | `--ei duration_ms 10000` | |
| 31 | +| `use_mmap` | boolean | Enable/disable MMAP audio path | `--ez use_mmap false` | |
| 32 | +| `buffer_frames` | int | Buffer size in frames (offload only) | `--ei buffer_frames 4096` | |
| 33 | + |
| 34 | +## Common Test Scenarios |
| 35 | + |
| 36 | +### Test PCM Offload Mode |
| 37 | +```bash |
| 38 | +adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ |
| 39 | + --es command play \ |
| 40 | + --es perf_mode offload |
| 41 | +``` |
| 42 | + |
| 43 | +### Background Playback Test |
| 44 | +```bash |
| 45 | +adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ |
| 46 | + --es command play \ |
| 47 | + --es perf_mode offload \ |
| 48 | + --ez background true |
| 49 | +``` |
| 50 | + |
| 51 | +### Timed Playback (10 seconds) |
| 52 | +```bash |
| 53 | +adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ |
| 54 | + --es command play \ |
| 55 | + --es perf_mode offload \ |
| 56 | + --ei duration_ms 10000 |
| 57 | +``` |
| 58 | + |
| 59 | +### Compare Performance Modes |
| 60 | +```bash |
| 61 | +# Low Latency |
| 62 | +adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ |
| 63 | + --es command play --es perf_mode lowlat |
| 64 | + |
| 65 | +# Power Saving (non-offload) |
| 66 | +adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ |
| 67 | + --es command play --es perf_mode powersave |
| 68 | + |
| 69 | +# PCM Offload |
| 70 | +adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ |
| 71 | + --es command play --es perf_mode offload |
| 72 | +``` |
| 73 | + |
| 74 | +### Stop Playback |
| 75 | +```bash |
| 76 | +adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ |
| 77 | + --es command stop |
| 78 | +``` |
| 79 | + |
| 80 | +## Machine-Readable Status Logs |
| 81 | + |
| 82 | +The app outputs status to logcat with the `PowerPlay` tag in a parseable format: |
| 83 | + |
| 84 | +``` |
| 85 | +POWERPLAY_STATUS: PLAYING | SONG=0 | OFFLOAD=true | MMAP=true |
| 86 | +POWERPLAY_STATUS: PAUSED |
| 87 | +POWERPLAY_STATUS: STOPPED | REASON=AUTO_STOP |
| 88 | +``` |
| 89 | + |
| 90 | +### Status Values |
| 91 | +| Status | Meaning | |
| 92 | +| ----------------- | ------------------------------------- | |
| 93 | +| `PLAYING` | Audio playback is active | |
| 94 | +| `PAUSED` | Audio playback is paused | |
| 95 | +| `STOPPED` | Audio playback has stopped | |
| 96 | +| `ERROR` | An error occurred | |
| 97 | +| `OFFLOAD_REVOKED` | PCM Offload was revoked by the system | |
| 98 | + |
| 99 | +### Log Monitoring |
| 100 | +```bash |
| 101 | +# Real-time monitoring |
| 102 | +adb logcat -s PowerPlay:V |
| 103 | + |
| 104 | +# Filter for status only |
| 105 | +adb logcat -s PowerPlay:V | grep "POWERPLAY_STATUS" |
| 106 | + |
| 107 | +# Save to file |
| 108 | +adb logcat -s PowerPlay:V > powerplay_test.log |
| 109 | +``` |
| 110 | + |
| 111 | +## Using the Test Action |
| 112 | + |
| 113 | +For automation scripts, you can also use the dedicated test action: |
| 114 | + |
| 115 | +```bash |
| 116 | +adb shell am start -a com.google.oboe.samples.powerplay.TEST \ |
| 117 | + --es command play \ |
| 118 | + --es perf_mode offload |
| 119 | +``` |
| 120 | + |
| 121 | +## Battery Testing |
| 122 | + |
| 123 | +To measure power consumption with offload vs non-offload: |
| 124 | + |
| 125 | +```bash |
| 126 | +# Reset battery stats |
| 127 | +adb shell dumpsys batterystats --reset |
| 128 | + |
| 129 | +# Run offload test for 5 minutes |
| 130 | +adb shell am start -n com.google.oboe.samples.powerplay/.MainActivity \ |
| 131 | + --es command play \ |
| 132 | + --es perf_mode offload \ |
| 133 | + --ez background true \ |
| 134 | + --ei duration_ms 300000 |
| 135 | + |
| 136 | +# Wait for test to complete, then capture stats |
| 137 | +adb shell dumpsys batterystats > battery_offload.txt |
| 138 | +``` |
| 139 | + |
| 140 | +## Troubleshooting |
| 141 | + |
| 142 | +### Offload Not Activating |
| 143 | +- Ensure device supports PCM Offload: check `AudioManager.isOffloadedPlaybackSupported()` |
| 144 | +- Some devices only support offload with specific sample rates (usually 48kHz) |
| 145 | +- Display must be off for some implementations |
| 146 | + |
| 147 | +### App Doesn't Respond to Commands |
| 148 | +- Make sure the app is installed: `adb shell pm list packages | grep powerplay` |
| 149 | +- Check if activity is exported: `adb shell dumpsys package com.google.oboe.samples.powerplay` |
0 commit comments