Open ccaapton opened 10 years ago
Dunno if you need this anymore but simply: add (cpu) wakelock:
echo 'blabla_lock' > /sys/power/wake_lock
remove wakelock:
echo 'blabla_lock' > /sys/power/wake_unlock
You can use this script: https://gist.github.com/twaik/a4d62c256652818054548e4c62760050
based on twaik script
#!/bin/bash
# android 9 wake lock admin script
case $1 in
1) grep -q ld /sys/power/wake_lock || ( echo ld > /sys/power/wake_lock && echo "Wake Locked" );;
0) grep -q ld /sys/power/wake_lock && echo ld > /sys/power/wake_unlock && echo "Wake Unlocked";;
*) printf "usage: $0 [0|1]\nNeed to be root for make changes.\n\nActive Wake Locks:\n"; cat /sys/power/wake_lock;;
esac
The most annoy part of running linux commands on android is that they are not "wakelock-aware". When I need to run a python scripts that take 3 minutes, the job will often be paused when android goes to sleep.
I hope to have a wrapper script, some like "keepwake.sh". so I can execute my command like
keepawake.sh mypythonscript.py
. The script will acquire a wakelock at the beginning, then start the mypythonscript.py. After the job is done, the script release wakelock and terminate. Could you help me to figure out how to do it? Thanks a lot!