Skip to content

Commit b90accd

Browse files
committed
Refactor
1 parent c187fa7 commit b90accd

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -323,25 +323,25 @@ private void recordOnDrawFrontOfQueue() {
323323
logExperimentTrace(this.experimentTtid);
324324
}
325325

326-
private boolean isStartedFromBackground() {
326+
private void resolveIsStartedFromBackground() {
327327
// This a fix for b/339891952 where the runnable on the background thread can run before the
328328
// activity lifecycle callbacks.
329329
if (mainThreadRunnableTime == null) {
330-
return false;
330+
return;
331331
}
332332

333333
if (isStartedFromBackground
334334
&& (mainThreadRunnableTime.getDurationMicros() < MAX_BACKGROUND_THREAD_DELAY)) {
335335
// Reset it to false as it was executed pre-emptively.
336336
isStartedFromBackground = false;
337337
}
338-
339-
return isStartedFromBackground;
340338
}
341339

342340
@Override
343341
public synchronized void onActivityCreated(Activity activity, Bundle savedInstanceState) {
344-
if (isStartedFromBackground() || onCreateTime != null // An activity already called onCreate()
342+
resolveIsStartedFromBackground();
343+
344+
if (isStartedFromBackground || onCreateTime != null // An activity already called onCreate()
345345
) {
346346
return;
347347
}
@@ -357,7 +357,7 @@ public synchronized void onActivityCreated(Activity activity, Bundle savedInstan
357357

358358
@Override
359359
public synchronized void onActivityStarted(Activity activity) {
360-
if (isStartedFromBackground()
360+
if (isStartedFromBackground
361361
|| onStartTime != null // An activity already called onStart()
362362
|| isTooLateToInitUI) {
363363
return;
@@ -367,7 +367,7 @@ public synchronized void onActivityStarted(Activity activity) {
367367

368368
@Override
369369
public synchronized void onActivityResumed(Activity activity) {
370-
if (isStartedFromBackground() || isTooLateToInitUI) {
370+
if (isStartedFromBackground || isTooLateToInitUI) {
371371
return;
372372
}
373373

@@ -460,7 +460,7 @@ private void logAppStartTrace() {
460460

461461
@Override
462462
public void onActivityPaused(Activity activity) {
463-
if (isStartedFromBackground()
463+
if (isStartedFromBackground
464464
|| isTooLateToInitUI
465465
|| !configResolver.getIsExperimentTTIDEnabled()) {
466466
return;
@@ -478,7 +478,7 @@ public void onActivityStopped(Activity activity) {}
478478
@Keep
479479
@OnLifecycleEvent(Lifecycle.Event.ON_START)
480480
public void onAppEnteredForeground() {
481-
if (isStartedFromBackground() || isTooLateToInitUI || firstForegroundTime != null) {
481+
if (isStartedFromBackground || isTooLateToInitUI || firstForegroundTime != null) {
482482
return;
483483
}
484484
// firstForeground is equivalent to the first Activity onStart. This marks the beginning of
@@ -496,7 +496,7 @@ public void onAppEnteredForeground() {
496496
@Keep
497497
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
498498
public void onAppEnteredBackground() {
499-
if (isStartedFromBackground() || isTooLateToInitUI || firstBackgroundTime != null) {
499+
if (isStartedFromBackground || isTooLateToInitUI || firstBackgroundTime != null) {
500500
return;
501501
}
502502
firstBackgroundTime = clock.getTime();

0 commit comments

Comments
 (0)