@@ -671,6 +671,16 @@ WeakHashMap<Activity, ITransaction> getActivitiesWithOngoingTransactions() {
671671 return activitiesWithOngoingTransactions ;
672672 }
673673
674+ @ TestOnly
675+ @ NotNull WeakHashMap <Activity , ActivityLifecycleTimeSpan > getActivityLifecycleMap () {
676+ return activityLifecycleMap ;
677+ }
678+
679+ @ TestOnly
680+ void setFirstActivityCreated (boolean firstActivityCreated ) {
681+ this .firstActivityCreated = firstActivityCreated ;
682+ }
683+
674684 @ TestOnly
675685 @ NotNull
676686 ActivityFramesTracker getActivityFramesTracker () {
@@ -697,33 +707,21 @@ WeakHashMap<Activity, ISpan> getTtfdSpanMap() {
697707
698708 private void setColdStart (final @ Nullable Bundle savedInstanceState ) {
699709 if (!firstActivityCreated ) {
700- // if Activity has savedInstanceState then its a warm start
701- // https://developer.android.com/topic/performance/vitals/launch-time#warm
702- // SentryPerformanceProvider sets this already
703- // pre-performance-v2: back-fill with best guess
704- if (options != null && !options .isEnablePerformanceV2 ()) {
710+ final @ NotNull TimeSpan appStartSpan = AppStartMetrics .getInstance ().getAppStartTimeSpan ();
711+ // If the app start span already started and stopped, it means the app restarted without
712+ // killing the process, so we are in a warm start
713+ // If the app has an invalid cold start, it means it was started in the background, like
714+ // via BroadcastReceiver, so we consider it a warm start
715+ if ((appStartSpan .hasStarted () && appStartSpan .hasStopped ())
716+ || (!AppStartMetrics .getInstance ().isColdStartValid ())) {
717+ AppStartMetrics .getInstance ().restartAppStart (lastPausedUptimeMillis );
718+ AppStartMetrics .getInstance ().setAppStartType (AppStartMetrics .AppStartType .WARM );
719+ } else {
705720 AppStartMetrics .getInstance ()
706721 .setAppStartType (
707722 savedInstanceState == null
708723 ? AppStartMetrics .AppStartType .COLD
709724 : AppStartMetrics .AppStartType .WARM );
710- } else {
711- final @ NotNull TimeSpan appStartSpan = AppStartMetrics .getInstance ().getAppStartTimeSpan ();
712- // If the app start span already started and stopped, it means the app restarted without
713- // killing the process, so we are in a warm start
714- // If the app has an invalid cold start, it means it was started in the background, like
715- // via BroadcastReceiver, so we consider it a warm start
716- if ((appStartSpan .hasStarted () && appStartSpan .hasStopped ())
717- || (!AppStartMetrics .getInstance ().isColdStartValid ())) {
718- AppStartMetrics .getInstance ().restartAppStart (lastPausedUptimeMillis );
719- AppStartMetrics .getInstance ().setAppStartType (AppStartMetrics .AppStartType .WARM );
720- } else {
721- AppStartMetrics .getInstance ()
722- .setAppStartType (
723- savedInstanceState == null
724- ? AppStartMetrics .AppStartType .COLD
725- : AppStartMetrics .AppStartType .WARM );
726- }
727725 }
728726 }
729727 }
0 commit comments