@@ -323,25 +323,25 @@ private void recordOnDrawFrontOfQueue() {
323
323
logExperimentTrace (this .experimentTtid );
324
324
}
325
325
326
- private boolean isStartedFromBackground () {
326
+ private void resolveIsStartedFromBackground () {
327
327
// This a fix for b/339891952 where the runnable on the background thread can run before the
328
328
// activity lifecycle callbacks.
329
329
if (mainThreadRunnableTime == null ) {
330
- return false ;
330
+ return ;
331
331
}
332
332
333
333
if (isStartedFromBackground
334
334
&& (mainThreadRunnableTime .getDurationMicros () < MAX_BACKGROUND_THREAD_DELAY )) {
335
335
// Reset it to false as it was executed pre-emptively.
336
336
isStartedFromBackground = false ;
337
337
}
338
-
339
- return isStartedFromBackground ;
340
338
}
341
339
342
340
@ Override
343
341
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()
345
345
) {
346
346
return ;
347
347
}
@@ -357,7 +357,7 @@ public synchronized void onActivityCreated(Activity activity, Bundle savedInstan
357
357
358
358
@ Override
359
359
public synchronized void onActivityStarted (Activity activity ) {
360
- if (isStartedFromBackground ()
360
+ if (isStartedFromBackground
361
361
|| onStartTime != null // An activity already called onStart()
362
362
|| isTooLateToInitUI ) {
363
363
return ;
@@ -367,7 +367,7 @@ public synchronized void onActivityStarted(Activity activity) {
367
367
368
368
@ Override
369
369
public synchronized void onActivityResumed (Activity activity ) {
370
- if (isStartedFromBackground () || isTooLateToInitUI ) {
370
+ if (isStartedFromBackground || isTooLateToInitUI ) {
371
371
return ;
372
372
}
373
373
@@ -460,7 +460,7 @@ private void logAppStartTrace() {
460
460
461
461
@ Override
462
462
public void onActivityPaused (Activity activity ) {
463
- if (isStartedFromBackground ()
463
+ if (isStartedFromBackground
464
464
|| isTooLateToInitUI
465
465
|| !configResolver .getIsExperimentTTIDEnabled ()) {
466
466
return ;
@@ -478,7 +478,7 @@ public void onActivityStopped(Activity activity) {}
478
478
@ Keep
479
479
@ OnLifecycleEvent (Lifecycle .Event .ON_START )
480
480
public void onAppEnteredForeground () {
481
- if (isStartedFromBackground () || isTooLateToInitUI || firstForegroundTime != null ) {
481
+ if (isStartedFromBackground || isTooLateToInitUI || firstForegroundTime != null ) {
482
482
return ;
483
483
}
484
484
// firstForeground is equivalent to the first Activity onStart. This marks the beginning of
@@ -496,7 +496,7 @@ public void onAppEnteredForeground() {
496
496
@ Keep
497
497
@ OnLifecycleEvent (Lifecycle .Event .ON_STOP )
498
498
public void onAppEnteredBackground () {
499
- if (isStartedFromBackground () || isTooLateToInitUI || firstBackgroundTime != null ) {
499
+ if (isStartedFromBackground || isTooLateToInitUI || firstBackgroundTime != null ) {
500
500
return ;
501
501
}
502
502
firstBackgroundTime = clock .getTime ();
0 commit comments