Skip to content

Commit 03effc9

Browse files
committed
Fix multiple checks
1 parent 07495da commit 03effc9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

firebase-perf/src/main/java/com/google/firebase/perf/metrics/AppStartTrace.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,19 @@ private void recordOnDrawFrontOfQueue() {
324324
}
325325

326326
private void resolveIsStartedFromBackground() {
327-
// If the runnable hasn't run, it isn't a background start.
327+
// If the mainThreadRunnableTime is null, either the runnable hasn't run, or this check has
328+
// already been made.
328329
if (mainThreadRunnableTime == null) {
329330
return;
330331
}
331332

332333
// Set it to true if the runnable ran more than 100ms prior to onActivityCreated()
333-
if (mainThreadRunnableTime.getDurationMicros() >= MAX_BACKGROUND_RUNNABLE_DELAY) {
334+
if (mainThreadRunnableTime.getDurationMicros() > MAX_BACKGROUND_RUNNABLE_DELAY) {
334335
isStartedFromBackground = true;
335336
}
337+
338+
// Set this to null to prevent additional checks if `onActivityCreated()` is called again.
339+
mainThreadRunnableTime = null;
336340
}
337341

338342
@Override

0 commit comments

Comments
 (0)