3 # TODO: restructure this to keep bugreports entirely on internal storage
5 # Do not allow bugreports on user builds unless USB debugging
7 if [ "x$(getprop ro.build.type)" = "xuser" -a \
8 "x$(getprop init.svc.adbd)" != "xrunning" ]; then
12 # Build emulated storage paths when appropriate
13 # See storage config details at http://source.android.com/tech/storage/
14 if [ -n "$EMULATED_STORAGE_SOURCE" ]; then
15 writePath="$EMULATED_STORAGE_SOURCE/0"
16 readPath="$EMULATED_STORAGE_TARGET/0"
18 writePath="$EXTERNAL_STORAGE"
19 readPath="$EXTERNAL_STORAGE"
22 tmpPath="/data/local/tmp"
23 bugreportPath="bugreports"
24 screenshotPath="Pictures/Screenshots"
26 # Create directories if needed
27 if [ ! -e "$writePath/$bugreportPath" ]; then
28 mkdir "$writePath/$bugreportPath"
30 if [ ! -e "$writePath/$screenshotPath" ]; then
31 mkdir "$writePath/$screenshotPath"
34 timestamp=`date +'%Y-%m-%d-%H-%M-%S'`
37 # we run this as a bg job in case screencap is stuck
38 /system/bin/screencap -p "$writePath/$screenshotPath/Screenshot_$timestamp.png" &
41 /system/bin/dumpstate -o "$tmpPath/bugreport-$timestamp" $@
43 # copy finished bugreport into place for sending
44 cp "$tmpPath/bugreport-$timestamp.txt" "$writePath/$bugreportPath/bugreport-$timestamp.txt"
45 # clean up any remaining files
46 rm $tmpPath/bugreport*
48 # invoke send_bug to look up email accounts and fire intents
49 # make it convenient to send bugreport to oneself
50 /system/bin/send_bug "$readPath/$bugreportPath/bugreport-$timestamp.txt" "$readPath/$screenshotPath/Screenshot_$timestamp.png"