public boolean performCrashDetectingFlow() {
    final File newCrashFile = new File(mApp.getFilesDir(), NEW_CRASH_FILENAME);
    if (newCrashFile.isFile()) {
      String ackReportFilename = getAckReportFilename();
      StringBuilder header = new StringBuilder();
      StringBuilder report = new StringBuilder();
      try (BufferedReader reader =
          new BufferedReader(
              new InputStreamReader(
                  mApp.openFileInput(NEW_CRASH_FILENAME), Charset.forName("UTF-8")))) {
        try (BufferedWriter writer =
            new BufferedWriter(
                new OutputStreamWriter(
                    mApp.openFileOutput(ackReportFilename, Context.MODE_PRIVATE),
                    Charset.forName("UTF-8")))) {
          Logger.i(TAG, "Archiving crash report to %s.", ackReportFilename);
          Logger.d(TAG, "Crash report:");
          String line;
          boolean stillInHeader = true;
          while (null != (line = reader.readLine())) {
            writer.write(line);
            writer.newLine();
            report.append(line).append(NEW_LINE);
            if (line.equals(HEADER_BREAK_LINE)) stillInHeader = false;
            if (stillInHeader) header.append(line).append(NEW_LINE);
            Logger.d(TAG, "err: %s", line);
          }
        }
      } catch (Exception e) {
        Logger.e(TAG, "Failed to write crash report to archive!");
        return false;
      }

      if (!newCrashFile.delete()) {
        Logger.e(TAG, "Failed to delete crash log! %s", newCrashFile.getAbsolutePath());
      }

      sendNotification(
          header.toString(), report.toString(), new File(mApp.getFilesDir(), ackReportFilename));

      return true;
    }
    return false;
  }
@Test
  public void testDoesNotCreateArchivedReportIfNotCrashed() {
    Context app = ApplicationProvider.getApplicationContext();
    var notificationDriver = Mockito.mock(NotificationDriver.class);
    TestableChewbaccaUncaughtExceptionHandler underTest =
        new TestableChewbaccaUncaughtExceptionHandler(app, null, notificationDriver);
    Assert.assertFalse(underTest.performCrashDetectingFlow());
    Assert.assertFalse(new File(app.getFilesDir(), "crashes").exists());
    Mockito.verify(notificationDriver, Mockito.never()).notify(Mockito.any(), Mockito.anyBoolean());
  }