Merge branch 'include-crash-in-acra-subject' into 'master'
Include crash in ACRA subject This makes it so the first chunk of the crash is put in email subject. This also lays the foundation for other ACRA customizations. This is ready to be merged, but it is based on !386, so its marked WIP. See merge request !391
This commit is contained in:
commit
ba8c39d3a9
@ -395,7 +395,7 @@
|
||||
android:value=".FDroid" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.fdroid.fdroid.CrashReportActivity"
|
||||
android:name=".acra.CrashReportActivity"
|
||||
android:theme="@style/AppThemeDark"
|
||||
android:process=":error_report"
|
||||
android:launchMode="singleInstance"
|
||||
|
@ -70,9 +70,10 @@ import info.guardianproject.netcipher.proxy.OrbotHelper;
|
||||
import sun.net.www.protocol.bluetooth.Handler;
|
||||
|
||||
@ReportsCrashes(mailTo = "reports@f-droid.org",
|
||||
mode = ReportingInteractionMode.DIALOG,
|
||||
reportDialogClass = CrashReportActivity.class
|
||||
)
|
||||
mode = ReportingInteractionMode.DIALOG,
|
||||
reportDialogClass = org.fdroid.fdroid.acra.CrashReportActivity.class,
|
||||
reportSenderFactoryClasses = org.fdroid.fdroid.acra.CrashReportSenderFactory.class
|
||||
)
|
||||
public class FDroidApp extends Application {
|
||||
|
||||
private static final String TAG = "FDroidApp";
|
||||
@ -276,12 +277,12 @@ public class FDroidApp extends Application {
|
||||
@Override
|
||||
public String generate(String imageUri) {
|
||||
return imageUri.substring(
|
||||
imageUri.lastIndexOf('/') + 1);
|
||||
imageUri.lastIndexOf('/') + 1);
|
||||
}
|
||||
},
|
||||
// 30 days in secs: 30*24*60*60 = 2592000
|
||||
2592000)
|
||||
)
|
||||
)
|
||||
.threadPoolSize(4)
|
||||
.threadPriority(Thread.NORM_PRIORITY - 2) // Default is NORM_PRIORITY - 1
|
||||
.build();
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.fdroid.fdroid;
|
||||
package org.fdroid.fdroid.acra;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
@ -6,8 +6,10 @@ import android.support.v7.app.AlertDialog;
|
||||
import android.widget.EditText;
|
||||
|
||||
import org.acra.dialog.BaseCrashReportDialog;
|
||||
import org.fdroid.fdroid.R;
|
||||
|
||||
public class CrashReportActivity extends BaseCrashReportDialog implements DialogInterface.OnDismissListener, DialogInterface.OnClickListener {
|
||||
public class CrashReportActivity extends BaseCrashReportDialog
|
||||
implements DialogInterface.OnDismissListener, DialogInterface.OnClickListener {
|
||||
|
||||
private static final String STATE_COMMENT = "comment";
|
||||
private EditText comment;
|
@ -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