mirror of
https://github.com/etesync/android
synced 2025-02-02 19:01:06 +00:00
Debug info: when sharing, also share the full ACRA info.
This commit is contained in:
parent
7f015dc661
commit
64a86e50d4
@ -81,6 +81,7 @@ import okhttp3.internal.tls.OkHostnameVerifier;
|
||||
|
||||
@AcraCore(buildConfigClass = BuildConfig.class)
|
||||
@AcraMailSender(mailTo = "reports@etesync.com",
|
||||
subject = R.string.crash_email_subject,
|
||||
reportFileName = "ACRA-report.stacktrace.json")
|
||||
@AcraToast(resText = R.string.crash_message,
|
||||
length = Toast.LENGTH_LONG)
|
||||
|
@ -43,6 +43,7 @@ import com.etesync.syncadapter.model.ServiceDB;
|
||||
import com.etesync.syncadapter.model.ServiceEntity;
|
||||
import com.etesync.syncadapter.resource.LocalAddressBook;
|
||||
|
||||
import org.acra.ACRA;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
@ -89,49 +90,11 @@ public class DebugInfoActivity extends BaseActivity implements LoaderManager.Loa
|
||||
|
||||
|
||||
public void onShare(MenuItem item) {
|
||||
if (!TextUtils.isEmpty(report)) {
|
||||
Intent sendIntent = new Intent();
|
||||
sendIntent.setAction(Intent.ACTION_SEND);
|
||||
sendIntent.setType("text/plain");
|
||||
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name) + " " + BuildConfig.VERSION_NAME + " debug info");
|
||||
|
||||
// since Android 4.1, FileProvider permissions are handled in a useful way (using ClipData)
|
||||
boolean asAttachment = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
|
||||
|
||||
if (asAttachment)
|
||||
try {
|
||||
File debugInfoDir = new File(getCacheDir(), "debug-info");
|
||||
debugInfoDir.mkdir();
|
||||
|
||||
reportFile = new File(debugInfoDir, "debug.txt");
|
||||
App.log.fine("Writing debug info to " + reportFile.getAbsolutePath());
|
||||
FileWriter writer = new FileWriter(reportFile);
|
||||
writer.write(report);
|
||||
writer.close();
|
||||
|
||||
sendIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this, getString(R.string.authority_log_provider), reportFile));
|
||||
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
|
||||
} catch(IOException e) {
|
||||
// creating an attachment failed, so send it inline
|
||||
asAttachment = false;
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder .append("Couldn't write debug info file:\n")
|
||||
.append(ExceptionUtils.getStackTrace(e))
|
||||
.append("\n\n")
|
||||
.append(report);
|
||||
report = builder.toString();
|
||||
}
|
||||
|
||||
if (!asAttachment)
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, report);
|
||||
|
||||
startActivity(Intent.createChooser(sendIntent, null));
|
||||
}
|
||||
ACRA.getErrorReporter().putCustomData("debug_info", report);
|
||||
ACRA.getErrorReporter().handleSilentException(null);
|
||||
ACRA.getErrorReporter().removeCustomData("debug_info");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Loader<String> onCreateLoader(int id, Bundle args) {
|
||||
return new ReportLoader(this, args);
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright © 2013 – 2015 Ricki Hirner (bitfire web engineering).
|
||||
~ All rights reserved. This program and the accompanying materials
|
||||
~ are made available under the terms of the GNU Public License v3.0
|
||||
@ -8,16 +7,29 @@
|
||||
-->
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="10dp">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:typeface="monospace"
|
||||
android:text="@string/please_wait"
|
||||
android:id="@+id/text_report"/>
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/debug_info_more_data_shared"
|
||||
android:layout_marginBottom="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_report"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/please_wait"
|
||||
android:typeface="monospace" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -23,6 +23,7 @@
|
||||
|
||||
<!-- Crash -->
|
||||
<string name="crash_message">EteSync has crashed, please send stack trace to developers.</string>
|
||||
<string name="crash_email_subject">EteSync Debug Info</string>
|
||||
|
||||
<!-- tourguide -->
|
||||
<string name="tourguide_title">Did you know?</string>
|
||||
@ -295,6 +296,7 @@
|
||||
<!-- sync errors and DebugInfoActivity -->
|
||||
<string name="authority_log_provider" translatable="false">com.etesync.syncadapter.log</string>
|
||||
<string name="debug_info_title">Debug info</string>
|
||||
<string name="debug_info_more_data_shared">Clicking share will open the email app with the data below, as well as some additional debug information attached. You will be prompted before the email is sent.</string>
|
||||
<string name="sync_error_permissions">EteSync permissions</string>
|
||||
<string name="sync_error_permissions_text">Additional permissions required</string>
|
||||
<string name="sync_error_calendar">Calendar sync failed (%s)</string>
|
||||
|
Loading…
Reference in New Issue
Block a user