Android Doze Mode and Screen-Off Behavior
Android Doze mode is the most critical technical constraint for a voice distress app that must detect a trigger phrase when the phone is locked, the screen is off, and the app is in the background. Understanding Doze is essential because it is exactly the scenario in which a distress app needs to work — and exactly the scenario Android tries to shut down to preserve battery.
Doze mode activates when three conditions are simultaneously met: the screen is off, the device is stationary (as detected by motion sensors), and the device is not plugged in to charge. When in Doze, Android restricts background CPU usage, suspends network access, releases partial wakelocks, and suspends job schedulers and sync adapters. A deep Doze maintenance window occurs periodically (every few hours) to allow apps to execute deferred work.
The reliable technical pattern for surviving Doze while maintaining continuous audio capture is: (1) run as an Android foreground service with a persistent user-visible notification, (2) acquire a PARTIAL_WAKE_LOCK via the WakeLock API to keep the CPU running, and (3) use the audio foreground service type (foregroundServiceType="microphone" in Android 14+). This combination keeps the microphone open and the wake word inference engine running through screen-off and Doze conditions. The music player pattern — using MediaPlayer or AudioManager to keep the service classified as an audio session — is the most robust documented approach, as music apps are specifically exempt from Doze restrictions.
The critical complication is that major Android OEMs used heavily in South Africa — Samsung (Galaxy A-series), Xiaomi (Redmi), and Huawei — apply proprietary battery optimization layers on top of standard Android Doze. These layers can terminate even properly-configured foreground services. Users must manually add the app to a “never sleeping” or “no restrictions” list in each OEM’s battery settings — a multi-step process that varies by manufacturer and Android version. This setup friction is a primary source of support requests and negative reviews for background audio apps globally.
Connections
- Android Background Voice Recognition — caused_by (Doze is a sub-constraint of the broader background limitation), source: https://stackoverflow.com/questions/41665500/android-doze-mode
- Picovoice Porcupine — mitigates (efficient on-device engine reduces battery drain), source: https://github.com/Picovoice/porcupine
- Valor — limited_by, screen-off and locked operation not confirmed for Valor
Ontology Android Doze Mode and Screen-Off Behavior [part-of] Android Background Voice Recognition Android Doze Mode and Screen-Off Behavior [relates] Valor Picovoice Porcupine [mitigates] Android Doze Mode and Screen-Off Behavior