Last active
October 12, 2015 07:50
-
-
Save stefan-girlich/adcf2eba5cb6463d0eba to your computer and use it in GitHub Desktop.
Obtains basic Android device information for debugging and reporting purposes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Obtains basic Android device information for debugging and reporting purposes and prints it to stdout. | |
# * adb needs to be installed | |
# * exactly one device needs to be connected | |
LAST_BRACKET_REGEX="\ \[(.*)\]" | |
declare -a PROPS_KEYS=("ro.build.version.release" "ro.product.manufacturer" "ro.product.model" "ro.product.locale.language" "ro.product.locale.region" "gsm.sim.state") | |
if ! type "adb" > /dev/null 2>&1; then | |
echo "adb not found." | |
exit 1 | |
fi | |
SERIAL_NO=$(adb get-serialno) | |
if [ SERIAL_NO == "unknown" ]; then | |
echo "No device or multiple devices connected." | |
exit 2 | |
fi | |
DEVICE_PROPS="$(adb -s $SERIAL_NO shell getprop)" | |
OUTPUT="" | |
for KEY in ${PROPS_KEYS[@]}; do | |
VALUE=$(printf %s "$DEVICE_PROPS"|grep $KEY) | |
if [[ $VALUE =~ $LAST_BRACKET_REGEX ]]; then | |
VALUE=${BASH_REMATCH[1]} | |
fi | |
OUTPUT=$OUTPUT"$KEY: $VALUE\n" | |
done | |
OUTPUT="\n$OUTPUT" | |
ANDROID_ID=$(adb shell settings get secure android_id) | |
OUTPUT="$OUTPUT\nANDROID_ID:\t$ANDROID_ID" | |
WLAN_INFO=$(adb shell netcfg|grep "wlan0") | |
WLAN_INFO_ARR=($WLAN_INFO) | |
MAC_ADDR=${WLAN_INFO_ARR[4]} | |
OUTPUT="$OUTPUT\nMAC address:\t$MAC_ADDR" | |
echo -e $OUTPUT | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment