1 #!/system/bin/sh 2 3 # Don't waste time trying to dump logs for a device that doesn't exist. 4 isWrigleyFound=0 5 for dev in $(ls /sys/bus/usb/devices); do 6 case $(cat /sys/bus/usb/devices/$dev/product 2>/dev/null) in 7 "Motorola LTE Datacard") 8 isWrigleyFound=1 9 break 10 ;; 11 esac 12 done 13 case $isWrigleyFound in 0) echo "Skipping dump for non-existent Wrigley"; exit 1;; esac 14 15 echo "Dumping Wrigley logs" 16 echo "I am running as $(id)" 17 hostName=$(getprop ro.product.device) 18 19 # The host-side iptables are important for logging functionality, and 20 # they are not currently part of the AP bugreport. 21 echo "file:begin:txt:${hostName}-iptables.txt" 22 iptables -L 23 iptables -t nat -L 24 echo "file:end:txt:${hostName}-iptables.txt" 25 26 # The host-side IPv6 routes are important, and they are not currently 27 # part of the AP bugreport. 28 echo "file:begin:txt:/${hostName}-ipv6_route.txt" 29 cat /proc/net/ipv6_route 30 echo "file:end:txt:/${hostName}-ipv6_route.txt" 31 32 # Get the rest of the info from dumpd. Specify a timeout to netcat to ensure 33 # we don't hang forever on BP panics. The -w option in netcat is used both as 34 # a connect timeout and a timeout on the main select() loop when doing reads 35 # and writes. Use a value that is not likely to false-positive, but also 36 # provides adequate protection against hanging for a long time. 37 for cmd in "state" "files" "atvc"; do 38 echo "-o wrigley $cmd" | nc -w 10 192.168.20.2 3002 39 done 40 echo "file:begin:txt:wrigley/AdditionalExtractionInstructions.txt" 41 echo "To extract logs.gz and panic.gz, you must do the following:" 42 echo " gunzip logs.gz" 43 echo " extract-embedded-files logs" 44 echo " gunzip panic.gz" 45 echo " extract-embedded-files panic" 46 echo "" 47 echo "These additional steps are required, because we are dumping an enormous" 48 echo "amount of data into the bugreport. Google demanded we reduce the overall" 49 echo "number of lines we are generating. To accomplish the reduction, we are" 50 echo "doing compression prior to dumping into the bugreport. We are sorry for" 51 echo "the inconvenience." 52 echo "file:end:txt:wrigley/AdditionalExtractionInstructions.txt" 53 for cmd in "logs" "panic"; do 54 echo "file:begin:bin:wrigley/${cmd}.gz" 55 echo "$cmd" | nc -w 10 192.168.20.2 3002 | gzip | base64 -e 56 echo "file:end:bin:wrigley/${cmd}.gz" 57 done 58