99import android .os .Bundle ;
1010import android .os .Handler ;
1111import android .os .Looper ;
12- import android .os .SystemClock ;
1312import io .sentry .FullyDisplayedReporter ;
1413import io .sentry .IScope ;
1514import io .sentry .IScopes ;
@@ -83,7 +82,6 @@ public final class ActivityLifecycleIntegration
8382 private final @ NotNull WeakHashMap <Activity , ActivityLifecycleSpanHelper > activitySpanHelpers =
8483 new WeakHashMap <>();
8584 private @ NotNull SentryDate lastPausedTime = new SentryNanotimeDate (new Date (0 ), 0 );
86- private long lastPausedUptimeMillis = 0 ;
8785 private @ Nullable Future <?> ttfdAutoCloseFuture = null ;
8886
8987 // WeakHashMap isn't thread safe but ActivityLifecycleCallbacks is only called from the
@@ -400,7 +398,6 @@ public void onActivityPreCreated(
400398 scopes != null
401399 ? scopes .getOptions ().getDateProvider ().now ()
402400 : AndroidDateUtils .getCurrentSentryDateTime ();
403- lastPausedUptimeMillis = SystemClock .uptimeMillis ();
404401 helper .setOnCreateStartTimestamp (lastPausedTime );
405402 }
406403
@@ -411,7 +408,6 @@ public void onActivityCreated(
411408 onActivityPreCreated (activity , savedInstanceState );
412409 }
413410 try (final @ NotNull ISentryLifecycleToken ignored = lock .acquire ()) {
414- setColdStart (savedInstanceState );
415411 if (scopes != null && options != null && options .isEnableScreenTracking ()) {
416412 final @ Nullable String activityClassName = ClassUtil .getClassName (activity );
417413 scopes .configureScope (scope -> scope .setScreen (activityClassName ));
@@ -516,7 +512,6 @@ public void onActivityPrePaused(@NotNull Activity activity) {
516512 scopes != null
517513 ? scopes .getOptions ().getDateProvider ().now ()
518514 : AndroidDateUtils .getCurrentSentryDateTime ();
519- lastPausedUptimeMillis = SystemClock .uptimeMillis ();
520515 }
521516
522517 @ Override
@@ -577,7 +572,7 @@ public void onActivityDestroyed(final @NotNull Activity activity) {
577572 // if the activity is opened again and not in memory, transactions will be created normally.
578573 activitiesWithOngoingTransactions .remove (activity );
579574
580- if (activitiesWithOngoingTransactions .isEmpty ()) {
575+ if (activitiesWithOngoingTransactions .isEmpty () && ! activity . isChangingConfigurations () ) {
581576 clear ();
582577 }
583578 }
@@ -586,7 +581,6 @@ public void onActivityDestroyed(final @NotNull Activity activity) {
586581 private void clear () {
587582 firstActivityCreated = false ;
588583 lastPausedTime = new SentryNanotimeDate (new Date (0 ), 0 );
589- lastPausedUptimeMillis = 0 ;
590584 activitySpanHelpers .clear ();
591585 }
592586
@@ -728,27 +722,6 @@ WeakHashMap<Activity, ISpan> getTtfdSpanMap() {
728722 return ttfdSpanMap ;
729723 }
730724
731- private void setColdStart (final @ Nullable Bundle savedInstanceState ) {
732- if (!firstActivityCreated ) {
733- final @ NotNull TimeSpan appStartSpan = AppStartMetrics .getInstance ().getAppStartTimeSpan ();
734- // If the app start span already started and stopped, it means the app restarted without
735- // killing the process, so we are in a warm start
736- // If the app has an invalid cold start, it means it was started in the background, like
737- // via BroadcastReceiver, so we consider it a warm start
738- if ((appStartSpan .hasStarted () && appStartSpan .hasStopped ())
739- || (!AppStartMetrics .getInstance ().isColdStartValid ())) {
740- AppStartMetrics .getInstance ().restartAppStart (lastPausedUptimeMillis );
741- AppStartMetrics .getInstance ().setAppStartType (AppStartMetrics .AppStartType .WARM );
742- } else {
743- AppStartMetrics .getInstance ()
744- .setAppStartType (
745- savedInstanceState == null
746- ? AppStartMetrics .AppStartType .COLD
747- : AppStartMetrics .AppStartType .WARM );
748- }
749- }
750- }
751-
752725 private @ NotNull String getTtidDesc (final @ NotNull String activityName ) {
753726 return activityName + " initial display" ;
754727 }
0 commit comments