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