Skip to content

Commit d74cfd7

Browse files
authored
Merge f5e504e into 6d645d0
2 parents 6d645d0 + f5e504e commit d74cfd7

File tree

1 file changed

+9
-1
lines changed
  • firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/send

1 file changed

+9
-1
lines changed

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/send/ReportQueue.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import android.annotation.SuppressLint;
1818
import android.database.SQLException;
19+
import android.os.SystemClock;
1920
import com.google.android.datatransport.Event;
2021
import com.google.android.datatransport.Priority;
2122
import com.google.android.datatransport.Transport;
@@ -39,10 +40,12 @@ final class ReportQueue {
3940
private static final int MS_PER_SECOND = 1_000;
4041
private static final int MS_PER_MINUTE = 60_000;
4142
private static final int MAX_DELAY_MS = 3_600_000; // 1 hour.
43+
private static final int STARTUP_DURATION_MS = 2_000; // 2 seconds.
4244

4345
private final double ratePerMinute;
4446
private final double base;
4547
private final long stepDurationMs;
48+
private final long startTimeMs;
4649

4750
private final int queueCapacity;
4851
private final BlockingQueue<Runnable> queue;
@@ -77,6 +80,8 @@ final class ReportQueue {
7780
this.transport = transport;
7881
this.onDemandCounter = onDemandCounter;
7982

83+
startTimeMs = SystemClock.elapsedRealtime();
84+
8085
// The queue capacity is the per-minute rate number. // TODO(mrober): Round up to next int?
8186
queueCapacity = (int) ratePerMinute;
8287
queue = new ArrayBlockingQueue<>(queueCapacity);
@@ -146,14 +151,17 @@ private void sendReport(
146151
TaskCompletionSource<CrashlyticsReportWithSessionId> tcs) {
147152
Logger.getLogger()
148153
.d("Sending report through Google DataTransport: " + reportWithSessionId.getSessionId());
154+
boolean isStartup = (SystemClock.elapsedRealtime() - startTimeMs) < STARTUP_DURATION_MS;
149155
transport.schedule(
150156
Event.ofUrgent(reportWithSessionId.getReport()),
151157
error -> {
152158
if (error != null) {
153159
tcs.trySetException(error);
154160
return;
155161
}
156-
flushScheduledReportsIfAble();
162+
if (isStartup) {
163+
flushScheduledReportsIfAble();
164+
}
157165
tcs.trySetResult(reportWithSessionId);
158166
});
159167
}

0 commit comments

Comments
 (0)