示例#1
0
  private void checkAndSendReports() {
    TLog.d(TCrash.TAG, "#checkAndSendReports - start");
    CrashReportFinder reportFinder = new CrashReportFinder();
    String[] reportFiles = reportFinder.getCrashReportFiles();
    Arrays.sort(reportFiles);

    int reportsSentCount = 0;

    for (String curFileName : reportFiles)
      if (reportsSentCount > 1) {
        deleteFile(curFileName);
      } else {
        TLog.i(TCrash.TAG, "Sending file " + curFileName);
        try {
          TCrashReportPersister persister = new TCrashReportPersister();
          CrashReportData previousCrashReport = persister.load(curFileName);
          sendCrashReport(previousCrashReport);
          deleteFile(curFileName);
        } catch (RuntimeException e) {
          TLog.e(TCrash.TAG, "Failed to send crash reports for " + curFileName + e.getMessage());
          deleteFile(curFileName);
          break;
        } catch (IOException e) {
          TLog.e(TCrash.TAG, "Failed to load crash report for " + curFileName + e.getMessage());
          deleteFile(curFileName);
          break;
        } catch (ReportSenderException e) {
          TLog.e(TCrash.TAG, "Failed to send crash report for " + curFileName + e.getMessage());
          break;
        }

        reportsSentCount++;
      }
    TLog.d(TCrash.TAG, "#checkAndSendReports - finish");
  }
示例#2
0
  private void approvePendingReports() {
    TLog.d(TCrash.TAG, "Mark all pending reports as approved.");

    CrashReportFinder reportFinder = new CrashReportFinder();
    String[] reportFileNames = reportFinder.getCrashReportFiles();

    for (String reportFileName : reportFileNames)
      if (!this.fileNameParser.isApproved(reportFileName)) {
        File reportFile = new File(TCrash.getInstance().getFilePath(), reportFileName);

        String newName = reportFileName.replace(".stacktrace", "-approved.stacktrace");

        File newFile = new File(TCrash.getInstance().getFilePath(), newName);
        if (!reportFile.renameTo(newFile))
          TLog.e(
              TCrash.TAG, "Could not rename approved report from " + reportFile + " to " + newFile);
      }
  }