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
2
# 3 = 1 (AC) + 2 (USB); set to 7 to include wireless charging
adb shell settings put global stay_on_while_plugged_in 3

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
2
3
4
5
6
7
8
9
# Force the display to remain powered on continuously
adb shell svc power stayon true

# Specific charging conditions:
adb shell svc power stayon usb
adb shell svc power stayon ac

# Reset back to default
adb shell svc power stayon false

🔒 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
2
# Append to build.prop
persist.sys.screen_on=1

⚠️ Warning: Always back up /system/build.prop before 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:

  1. In Tasker, create a Profile triggered by App > (Select your target app).
  2. Assign an Action under Display > Display Timeout and set the slider to maximum.
  3. 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.