Skip to content

Instantly share code, notes, and snippets.

@mikepenz
Created November 12, 2019 11:28
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikepenz/f122742e75ddc67643ee211f25eee7b2 to your computer and use it in GitHub Desktop.
Save mikepenz/f122742e75ddc67643ee211f25eee7b2 to your computer and use it in GitHub Desktop.
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