summaryrefslogtreecommitdiff
path: root/bugmailer/bugmailer.sh
blob: 93d1c8a4e005d36b81588b0094acf802f6628ee2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/system/bin/sh

# Do not allow bugreports on user builds unless USB debugging
# is enabled.
if [ "x$(getprop ro.build.type)" = "xuser" -a \
     "x$(getprop init.svc.adbd)" != "xrunning" ]; then
  exit 0
fi

timestamp=`date +'%Y-%m-%d-%H-%M-%S'`
storagePath="$EXTERNAL_STORAGE/bugreports"
bugreport=$storagePath/bugreport-$timestamp
screenshotPath="$EXTERNAL_STORAGE/Pictures/Screenshots"
screenshot=$screenshotPath/Screenshot_$timestamp.png

# check screen shot folder
if [ ! -e $screenshotPath ]; then
  mkdir $screenshotPath
fi

# take screen shot
# we run this as a bg job in case screencap is stuck
/system/bin/screencap -p $screenshot &

# run bugreport
/system/bin/dumpstate -o $bugreport $@


# make files readable
chown root.sdcard_rw $bugreport.txt
chown root.sdcard_rw $screenshot

# invoke send_bug to look up email accounts and fire intents
# make it convenient to send bugreport to oneself
/system/bin/send_bug $bugreport.txt $screenshot