Preventing Android Devices from Sleeping: Practical Methods from ADB Settings to Root Configurations
When repurposing Android phones as dedicated appliances—such as continuous testbeds for Android TV development, wall-mounted dashboards, or local server monitoring nodes—preventing the device from entering deep sleep or turning off the screen is an everyday necessity.
Depending on whether your device has root access, here are the most dependable methods to keep your Android devices awake.
⚡ Method 1: The settings Command (Cleanest & No Root Required)
The simplest approach modifies Android’s internal system settings provider via ADB or a local terminal emulator (like Termux). This requires zero root permissions:
1. Stay Awake While Charging (Developer Favorite)
Instructs the OS never to sleep as long as it is plugged into AC power or a USB cable:
1 | # 3 = 1 (AC) + 2 (USB); set to 7 to include wireless charging |
To revert back to default behavior:
1 | adb shell settings put global stay_on_while_plugged_in 0 |
2. Extend Screen Timeout to Maximum Value
Sets the standard display timeout to integer maximum (~24.8 days):
1 | adb shell settings put system screen_off_timeout 2147483647 |
🛠️ Method 2: The svc power Subsystem
Android’s built-in svc tool directly interfaces with the OS PowerManager service:
1 | # Force the display to remain powered on continuously |
🔒 Method 3: Modifying build.prop (Requires Root)
If you need a persistent, boot-proof configuration baked directly into the system image, append a persistent property to /system/build.prop:
1 | # Append to build.prop |
⚠️ Warning: Always back up
/system/build.propbefore editing. Corrupting syntax or permissions on this file can cause a bootloop.
🤖 Method 4: Automation via Tasker or Termux
For dynamic scenarios where the display should stay awake only when specific apps run:
- In Tasker, create a Profile triggered by
App > (Select your target app). - Assign an Action under
Display > Display Timeoutand set the slider to maximum. - Or execute a direct Shell action on launch:
1
svc power stayon true
📋 Quick Reference Table
| Approach | Root Required? | Scope | Best Used For |
|---|---|---|---|
settings put global stay_on_while_plugged_in 3 |
❌ No | Global | Dedicated bench testing over USB |
settings put system screen_off_timeout 2147483647 |
❌ No | Display | Dashboard / kiosk displays |
svc power stayon true |
❌ No | Subsystem | Dynamic scripting via shell |
persist.sys.screen_on=1 |
✅ Yes | System Image | Headless custom ROM appliances |
For 95% of developer workloads, combining stay_on_while_plugged_in 3 with ADB provides an instantaneous, non-destructive solution.