Merge pull request #322 from dylanaraps/android2

Add Android support 2
This commit is contained in:
Dylan Araps 2016-10-27 09:30:23 +11:00 committed by GitHub
commit 51354b2235
2 changed files with 40 additions and 6 deletions

15
ascii/distro/android Normal file
View file

@ -0,0 +1,15 @@
"\
${c1} ╲ ▁▂▂▂▁
▄███████▄
▄██${c2} ${c1}███${c2} ${c1}██▄
▄███████████▄
▄█ ▄▄▄▄▄▄▄▄▄▄▄▄▄ █▄
██ █████████████ ██
██ █████████████ ██
██ █████████████ ██
██ █████████████ ██
█████████████
███████████
██ ██
██ ██
"

View file

@ -41,7 +41,10 @@ getos() {
getmodel() { getmodel() {
case "$os" in case "$os" in
"Linux") "Linux")
if [ -f /sys/devices/virtual/dmi/id/product_name ] ||\ if [ -d "/system/app/" ] && [ -d "/system/priv-app" ]; then
model="$(getprop ro.product.brand) $(getprop ro.product.model)"
elif [ -f /sys/devices/virtual/dmi/id/product_name ] ||\
[ -f /sys/devices/virtual/dmi/id/product_version ]; then [ -f /sys/devices/virtual/dmi/id/product_version ]; then
model="$(< /sys/devices/virtual/dmi/id/product_name)" model="$(< /sys/devices/virtual/dmi/id/product_name)"
model+=" $(< /sys/devices/virtual/dmi/id/product_version)" model+=" $(< /sys/devices/virtual/dmi/id/product_version)"
@ -147,6 +150,9 @@ getdistro() {
"tiny") distro="${distro//version*}" ;; "tiny") distro="${distro//version*}" ;;
esac esac
elif [ -d "/system/app/" ] && [ -d "/system/priv-app" ]; then
distro="Android $(getprop ro.build.version.release)"
else else
# Workarounds are included in every shorthand option # Workarounds are included in every shorthand option
case "$distro_shorthand" in case "$distro_shorthand" in
@ -432,6 +438,8 @@ getpackages() {
packages="$((packages+=$(ls -1 /cygdrive/c/ProgramData/chocolatey/lib | wc -l)))" packages="$((packages+=$(ls -1 /cygdrive/c/ProgramData/chocolatey/lib | wc -l)))"
;; ;;
esac esac
[ "$packages" == "0" ] && unset packages
} }
# }}} # }}}
@ -681,7 +689,10 @@ getcpu() {
case "$os" in case "$os" in
"Linux" | "Windows") "Linux" | "Windows")
# Get cpu name # Get cpu name
cpu="$(awk -F ': | @' '/model name/ {printf $2; exit}' /proc/cpuinfo)" case "$distro" in
"Android"*) cpu="$(getprop ro.product.board)" ;;
*) cpu="$(awk -F ': | @' '/model name|Processor/ {printf $2; exit}' /proc/cpuinfo)" ;;
esac
speed_dir="/sys/devices/system/cpu/cpu0/cpufreq" speed_dir="/sys/devices/system/cpu/cpu0/cpufreq"
temp_dir="/sys/class/hwmon/hwmon0/temp1_input" temp_dir="/sys/class/hwmon/hwmon0/temp1_input"
@ -1521,6 +1532,7 @@ getdisk() {
case "$distro" in case "$distro" in
"OpenWRT"*) df_flags="-h"; df_dir="rootfs" ;; "OpenWRT"*) df_flags="-h"; df_dir="rootfs" ;;
"Android"*) return ;;
esac esac
;; ;;
@ -1913,14 +1925,16 @@ getascii() {
ascii_strip="${ascii_strip//'\\'/ }" ascii_strip="${ascii_strip//'\\'/ }"
ascii_strip="${ascii_strip//'\'}" ascii_strip="${ascii_strip//'\'}"
# Get lines/columns of the ascii file in pure bash. # Get lines/columns of the ascii file.
ascii_length=0
lines=1 lines=1
while IFS='\n' read -r line 2>/dev/null; do while IFS='\n' read -r line 2>/dev/null; do
[ ${#line} -gt "$ascii_length" ] && ascii_length=${#line} [ "${#line}" -gt "${ascii_length:-0}" ] && ascii_length="${#line}"
lines=$((lines+=1)) lines="$((lines+=1))"
done <<< "$ascii_strip" done <<< "$ascii_strip"
# Overwrite padding if ascii_length_force is set.
[ "$ascii_length_force" ] && ascii_length="$ascii_length_force"
padding="\033[$((ascii_length + gap))C" padding="\033[$((ascii_length + gap))C"
printf "%b%s" "$print" printf "%b%s" "$print"
export LC_ALL=C export LC_ALL=C
@ -2440,6 +2454,11 @@ colors() {
setcolors 2 7 setcolors 2 7
;; ;;
"Android"*)
setcolors 2 7
ascii_length_force="19"
;;
"NetBSD"* | "Parabola"* | "Tails"* | "BLAG"*) "NetBSD"* | "Parabola"* | "Tails"* | "BLAG"*)
setcolors 5 7 setcolors 5 7
;; ;;