/** * Store a report * * @param file the file to store in * @param crashData the content */ private void saveCrashReportFile(@NonNull File file, @NonNull CrashReportData crashData) { try { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Writing crash report file " + file); final CrashReportPersister persister = new CrashReportPersister(); persister.store(crashData, file); } catch (Exception e) { ACRA.log.e(LOG_TAG, "An error occurred while writing the report file...", e); } } }
/** * Send crash report given user's comment and email address. * * @param comment Comment (may be null) provided by the user. * @param userEmail Email address (may be null) provided by the client. */ protected final void sendCrash(@Nullable String comment, @Nullable String userEmail) { new Thread(() -> { final CrashReportPersister persister = new CrashReportPersister(); try { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Add user comment to " + reportFile); final CrashReportData crashData = persister.load(reportFile); crashData.put(USER_COMMENT, comment == null ? "" : comment); crashData.put(USER_EMAIL, userEmail == null ? "" : userEmail); persister.store(crashData, reportFile); } catch (IOException | JSONException e) { ACRA.log.w(LOG_TAG, "User comment not added: ", e); } // Start the report sending task new SchedulerStarter(this, config).scheduleReports(reportFile, false); }).start(); }
void convert() { ACRA.log.i(LOG_TAG, "Converting unsent ACRA reports to json"); final ReportLocator locator = new ReportLocator(context); final CrashReportPersister persister = new CrashReportPersister(); final List<File> reportFiles = new ArrayList<>(); reportFiles.addAll(Arrays.asList(locator.getUnapprovedReports()));
final CharSequence comment = remoteInput.getCharSequence(NotificationInteraction.KEY_COMMENT); if (comment != null && !"".equals(comment.toString())) { final CrashReportPersister persister = new CrashReportPersister(); try { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Add user comment to " + reportFile);
final CrashReportPersister persister = new CrashReportPersister(); final CrashReportData previousCrashReport = persister.load(reportFile); sendCrashReport(previousCrashReport);