private void attemptUploadWithRetry() { Fabric.getLogger() .m23d(Fabric.TAG, "Starting report processing in " + this.delay + " second(s)..."); if (this.delay > 0.0f) { try { Thread.sleep((long) (this.delay * 1000.0f)); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } } Crashlytics crashlytics = Crashlytics.getInstance(); CrashlyticsUncaughtExceptionHandler handler = crashlytics.getHandler(); List<Report> reports = ReportUploader.this.findReports(); if (!handler.isHandlingException()) { if (reports.isEmpty() || crashlytics.canSendWithUserApproval()) { int retryCount = 0; while (!reports.isEmpty() && !Crashlytics.getInstance().getHandler().isHandlingException()) { Fabric.getLogger() .m23d(Fabric.TAG, "Attempting to send " + reports.size() + " report(s)"); for (Report report : reports) { ReportUploader.this.forceUpload(report); } reports = ReportUploader.this.findReports(); if (!reports.isEmpty()) { int retryCount2 = retryCount + 1; long interval = (long) ReportUploader.RETRY_INTERVALS[ Math.min(retryCount, ReportUploader.RETRY_INTERVALS.length - 1)]; Fabric.getLogger() .m23d( Fabric.TAG, "Report submisson: scheduling delayed retry in " + interval + " seconds"); try { Thread.sleep(1000 * interval); retryCount = retryCount2; } catch (InterruptedException e2) { Thread.currentThread().interrupt(); return; } } } return; } Fabric.getLogger() .m23d(Fabric.TAG, "User declined to send. Removing " + reports.size() + " Report(s)."); for (Report report2 : reports) { report2.remove(); } } }
List<Report> findReports() { Fabric.getLogger().m23d(Fabric.TAG, "Checking for crash reports..."); synchronized (this.fileAccessLock) { File[] clsFiles = Crashlytics.getInstance().getSdkDirectory().listFiles(crashFileFilter); } List<Report> reports = new LinkedList(); for (File file : clsFiles) { Fabric.getLogger().m23d(Fabric.TAG, "Found crash report " + file.getPath()); reports.add(new SessionReport(file)); } if (reports.isEmpty()) { Fabric.getLogger().m23d(Fabric.TAG, "No reports found."); } return reports; }
boolean forceUpload(Report report) { boolean removed = false; synchronized (this.fileAccessLock) { try { boolean sent = this.createReportCall.invoke( new CreateReportRequest( new ApiKey().getValue(Crashlytics.getInstance().getContext()), report)); Fabric.getLogger() .m27i( Fabric.TAG, "Crashlytics report upload " + (sent ? "complete: " : "FAILED: ") + report.getFileName()); if (sent) { report.remove(); removed = true; } } catch (Exception e) { Fabric.getLogger().m26e(Fabric.TAG, "Error occurred sending report " + report, e); } } return removed; }