Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick helper script to detect the speed of the USB connection of connected Android devices
#!/bin/bash
# some helper vars
# https://unix.stackexchange.com/a/10065/138249
if test -t 1; then
ncolors=$(tput colors)
if test -n "$ncolors" && test $ncolors -ge 8; then
bold=$(tput bold)
normal=$(tput sgr0)
success=$(tput setaf 2)
failure=$(tput setaf 1)
fi
fi
echo "Checking connected Android device USB Speeds"
echo ""
adb devices | while read line
do
if [ ! "$line" = "" ] && [ `echo $line | awk '{print $2}'` = "device" ]
then
device=`echo $line | awk '{print $1}'`
system_profiler SPUSBDataType 2> /dev/null \
| awk '
/Serial Number:/{p=$3}
/Speed:/{x=$4$5}
/Location ID:/{sub(/.*: /,""); printf("[%s] connected with speed up to: %s\n", p, x);}
' | while read line2
do
if [[ ( ${line2} == "[${device}"* ) ]]; then
device_model=$(adb -s "${device}" shell getprop ro.product.model)
echo ${bold}${device_model}${normal} ${line2}
fi
done
fi
done
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment