1#!/system/bin/sh 2 3# Do not allow bugreports on user builds unless USB debugging 4# is enabled. 5if [ "x$(getprop ro.build.type)" = "xuser" -a \ 6 "x$(getprop init.svc.adbd)" != "xrunning" ]; then 7 exit 0 8fi 9 10timestamp=`date +'%Y-%m-%d-%H-%M-%S'` 11storagePath="$EXTERNAL_STORAGE/bugreports" 12bugreport=$storagePath/bugreport-$timestamp 13screenshotPath="$EXTERNAL_STORAGE/Pictures/Screenshots" 14screenshot=$screenshotPath/Screenshot_$timestamp.png 15 16# check screen shot folder 17if [ ! -e $screenshotPath ]; then 18 mkdir $screenshotPath 19fi 20 21# take screen shot 22# we run this as a bg job in case screencap is stuck 23/system/bin/screencap -p $screenshot & 24 25# run bugreport 26/system/bin/dumpstate -o $bugreport $@ 27 28 29# make files readable 30chown root.sdcard_rw $bugreport.txt 31chown root.sdcard_rw $screenshot 32 33# invoke send_bug to look up email accounts and fire intents 34# make it convenient to send bugreport to oneself 35/system/bin/send_bug $bugreport.txt $screenshot 36