support uptime from Android 9+

parent cc78503b
......@@ -1211,8 +1211,14 @@ get_uptime() {
# Get uptime in seconds.
case "$os" in
"Linux" | "Windows" | "MINIX")
seconds="$(< /proc/uptime)"
seconds="${seconds/.*}"
if [ -f /proc/uptime ]; then
seconds="$(< /proc/uptime)"
seconds="${seconds/.*}"
else # Android >= 9 denies /proc/uptime access
boot=$(date -d"$(uptime -s)" +%s) \
&& now="$(date +%s)" \
&& seconds="$((now - boot))"
fi
;;
"Mac OS X" | "iPhone OS" | "BSD" | "FreeMiNT")
......
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