uptime for Android 9+ (refactorized)

parent 78b9d3e1
...@@ -1211,13 +1211,13 @@ get_uptime() { ...@@ -1211,13 +1211,13 @@ get_uptime() {
# Get uptime in seconds. # Get uptime in seconds.
case "$os" in case "$os" in
"Linux" | "Windows" | "MINIX") "Linux" | "Windows" | "MINIX")
if [ -f /proc/uptime ]; then if [[ -r /proc/uptime ]]; then
seconds="$(< /proc/uptime)" seconds="$(< /proc/uptime)"
seconds="${seconds/.*}" seconds="${seconds/.*}"
else # Android >= 9 denies /proc/uptime access else
boot=$(date -d"$(uptime -s)" +%s) \ boot="$(date -d"$(uptime -s)" +%s)"
&& now="$(date +%s)" \ now="$(date +%s)"
&& seconds="$((now - boot))" seconds="$((now - boot))"
fi fi
;; ;;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment