1 #!/system/bin/sh 2 3 # Do not allow bugreports on user builds unless USB debugging 4 # is enabled. 5 if [ "x$(getprop ro.build.type)" = "xuser" -a \ 6 "x$(getprop init.svc.adbd)" != "xrunning" ]; then 7 exit 0 8 fi 9 10 timestamp=`date +'%Y-%m-%d-%H-%M-%S'` 11 storagePath="$EXTERNAL_STORAGE/bugreports" 12 bugreport=$storagePath/bugreport-$timestamp 13 screenshotPath="$EXTERNAL_STORAGE/Pictures/Screenshots" 14 screenshot=$screenshotPath/Screenshot_$timestamp.png 15 16 # check screen shot folder 17 if [ ! -e $screenshotPath ]; then 18 mkdir $screenshotPath 19 fi 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 30 chown root.sdcard_rw $bugreport.txt 31 chown 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