How to Acquire and Release a wakelock forcefully from Android shell

Sometime when you are developing some code where you need to acquire a wakelock or when you are debugging some bug where you need to identify whether wakelock is the problem, you can choose to acquire or release the wakelock forcefully so your debugging on an issue becomes easier.

Note: Following steps needs a root access to your Android device so its mostly helpful during the development or debugging, also make sure the device is connected over adb to get the shell.

Acquire a wakelock forcefully

Write “lockname” or “lockname timeout” to /sys/power/wake_lock lock and if needed create a wake lock.

$ echo lock_me > /sys/power/wake_lock 

This can be done from init.rc as,

on boot
write /sys/power/wake_lock lock_me 

Release above acquire wakelock

Write “lockname” to /sys/power/wake_unlock to unlock a user wake lock.

$ echo lock_me > /sys/power/wake_unlock
Valorant - How To Fix System Reboot... x
Valorant - How To Fix System Reboot Required Startup Error

Leave a Comment

Sign up to our newsletter!

ADB Commands Android Android Applications Android Build system Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia NDK / Middleware / HAL Operating System Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto Embedded Linux