custom ACRA sender to put stacktrace title in email Subject:
This should hopefully make it easier to sort through the emails.
This commit is contained in:
parent
a5746c03f3
commit
f24c5b6ac7
@ -70,9 +70,10 @@ import info.guardianproject.netcipher.proxy.OrbotHelper;
|
|||||||
import sun.net.www.protocol.bluetooth.Handler;
|
import sun.net.www.protocol.bluetooth.Handler;
|
||||||
|
|
||||||
@ReportsCrashes(mailTo = "reports@f-droid.org",
|
@ReportsCrashes(mailTo = "reports@f-droid.org",
|
||||||
mode = ReportingInteractionMode.DIALOG,
|
mode = ReportingInteractionMode.DIALOG,
|
||||||
reportDialogClass = CrashReportActivity.class
|
reportDialogClass = CrashReportActivity.class,
|
||||||
)
|
reportSenderFactoryClasses = org.fdroid.fdroid.acra.CrashReportSenderFactory.class
|
||||||
|
)
|
||||||
public class FDroidApp extends Application {
|
public class FDroidApp extends Application {
|
||||||
|
|
||||||
private static final String TAG = "FDroidApp";
|
private static final String TAG = "FDroidApp";
|
||||||
@ -276,12 +277,12 @@ public class FDroidApp extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public String generate(String imageUri) {
|
public String generate(String imageUri) {
|
||||||
return imageUri.substring(
|
return imageUri.substring(
|
||||||
imageUri.lastIndexOf('/') + 1);
|
imageUri.lastIndexOf('/') + 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 30 days in secs: 30*24*60*60 = 2592000
|
// 30 days in secs: 30*24*60*60 = 2592000
|
||||||
2592000)
|
2592000)
|
||||||
)
|
)
|
||||||
.threadPoolSize(4)
|
.threadPoolSize(4)
|
||||||
.threadPriority(Thread.NORM_PRIORITY - 2) // Default is NORM_PRIORITY - 1
|
.threadPriority(Thread.NORM_PRIORITY - 2) // Default is NORM_PRIORITY - 1
|
||||||
.build();
|
.build();
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
|
||||||
|
package org.fdroid.fdroid.acra;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.acra.ACRAConstants;
|
||||||
|
import org.acra.ReportField;
|
||||||
|
import org.acra.collections.ImmutableSet;
|
||||||
|
import org.acra.collector.CrashReportData;
|
||||||
|
import org.acra.config.ACRAConfiguration;
|
||||||
|
import org.acra.sender.ReportSender;
|
||||||
|
import org.acra.sender.ReportSenderException;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
public class CrashReportSender implements ReportSender {
|
||||||
|
|
||||||
|
private final ACRAConfiguration config;
|
||||||
|
|
||||||
|
public CrashReportSender(ACRAConfiguration config) {
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void send(@NonNull Context context, @NonNull CrashReportData errorContent)
|
||||||
|
throws ReportSenderException {
|
||||||
|
Intent emailIntent = new Intent("android.intent.action.SENDTO");
|
||||||
|
emailIntent.setData(Uri.fromParts("mailto", this.config.mailTo(), (String) null));
|
||||||
|
emailIntent.addFlags(268435456);
|
||||||
|
String[] subjectBody = this.buildSubjectBody(context, errorContent);
|
||||||
|
emailIntent.putExtra("android.intent.extra.SUBJECT", subjectBody[0]);
|
||||||
|
emailIntent.putExtra("android.intent.extra.TEXT", subjectBody[1]);
|
||||||
|
context.startActivity(emailIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] buildSubjectBody(Context context, CrashReportData errorContent) {
|
||||||
|
ImmutableSet fields = this.config.getReportFields();
|
||||||
|
if (fields.isEmpty()) {
|
||||||
|
fields = new ImmutableSet<ReportField>(ACRAConstants.DEFAULT_MAIL_REPORT_FIELDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
String subject = context.getPackageName() + " Crash Report";
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Iterator var4 = fields.iterator();
|
||||||
|
|
||||||
|
while (var4.hasNext()) {
|
||||||
|
ReportField field = (ReportField) var4.next();
|
||||||
|
builder.append(field.toString()).append('=');
|
||||||
|
builder.append(errorContent.get(field));
|
||||||
|
builder.append('\n');
|
||||||
|
if ("STACK_TRACE".equals(field.toString())) {
|
||||||
|
String stackTrace = errorContent.get(field);
|
||||||
|
if (stackTrace != null) {
|
||||||
|
subject = context.getPackageName() + ": "
|
||||||
|
+ stackTrace.substring(0, stackTrace.indexOf('\n'));
|
||||||
|
if (subject.length() > 72) {
|
||||||
|
subject = subject.substring(0, 72);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new String[]{subject, builder.toString()};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package org.fdroid.fdroid.acra;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.acra.config.ACRAConfiguration;
|
||||||
|
import org.acra.sender.ReportSender;
|
||||||
|
import org.acra.sender.ReportSenderFactory;
|
||||||
|
|
||||||
|
public class CrashReportSenderFactory implements ReportSenderFactory {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public ReportSender create(@NonNull Context context, @NonNull ACRAConfiguration acraConfiguration) {
|
||||||
|
return new CrashReportSender(acraConfiguration);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user