From 64a86e50d4da18db15fdf81c25d375583f15d220 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 24 Jan 2018 11:58:40 +0000 Subject: [PATCH] Debug info: when sharing, also share the full ACRA info. --- .../java/com/etesync/syncadapter/App.java | 1 + .../syncadapter/ui/DebugInfoActivity.java | 45 ++----------------- .../main/res/layout/activity_debug_info.xml | 34 +++++++++----- app/src/main/res/values/strings.xml | 2 + 4 files changed, 30 insertions(+), 52 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/App.java b/app/src/main/java/com/etesync/syncadapter/App.java index 846c33a3..34096af2 100644 --- a/app/src/main/java/com/etesync/syncadapter/App.java +++ b/app/src/main/java/com/etesync/syncadapter/App.java @@ -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) diff --git a/app/src/main/java/com/etesync/syncadapter/ui/DebugInfoActivity.java b/app/src/main/java/com/etesync/syncadapter/ui/DebugInfoActivity.java index 735e7caf..47fb32e0 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/DebugInfoActivity.java +++ b/app/src/main/java/com/etesync/syncadapter/ui/DebugInfoActivity.java @@ -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 onCreateLoader(int id, Bundle args) { return new ReportLoader(this, args); diff --git a/app/src/main/res/layout/activity_debug_info.xml b/app/src/main/res/layout/activity_debug_info.xml index 64b1da79..e5fdc76c 100644 --- a/app/src/main/res/layout/activity_debug_info.xml +++ b/app/src/main/res/layout/activity_debug_info.xml @@ -1,5 +1,4 @@ - - + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:padding="10dp"> - + android:orientation="vertical"> + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 59cfb1fc..2cadd7b8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -23,6 +23,7 @@ EteSync has crashed, please send stack trace to developers. + EteSync Debug Info Did you know? @@ -295,6 +296,7 @@ com.etesync.syncadapter.log Debug info + 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. EteSync permissions Additional permissions required Calendar sync failed (%s)