diff --git a/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/ActivityLoadEventEmitter.kt b/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/UiLoadExt.kt similarity index 53% rename from embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/ActivityLoadEventEmitter.kt rename to embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/UiLoadExt.kt index 3ce2eb9c9..c2330f529 100644 --- a/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/ActivityLoadEventEmitter.kt +++ b/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/capture/activity/UiLoadExt.kt @@ -1,9 +1,9 @@ package io.embrace.android.embracesdk.internal.capture.activity import android.app.Activity -import android.app.Application.ActivityLifecycleCallbacks -import android.os.Build +import android.os.Build.VERSION_CODES import android.os.Bundle +import androidx.annotation.RequiresApi import io.embrace.android.embracesdk.annotation.ObservedActivity import io.embrace.android.embracesdk.internal.clock.nanosToMillis import io.embrace.android.embracesdk.internal.session.lifecycle.ActivityLifecycleListener @@ -11,92 +11,126 @@ import io.embrace.android.embracesdk.internal.utils.VersionChecker import io.opentelemetry.sdk.common.Clock /** - * Maps [ActivityLifecycleCallbacks] events to [UiLoadEventListener] depending on version of the OS and whether or - * not the given [Activity]'s load should be traced. + * Creates [ActivityLifecycleListener] that maps Activity lifecycle events to the given [UiLoadEventListener]. + * It will create an implementation that uses the most suitable API given the OS version. * - * The purpose of this is to leverage Activity lifecycle events to provide data for the underlying workflow to bring a new Activity on - * screen. Due to the varying capabilities of the APIs available on the different versions of Android, the precise triggering events for - * the start and intermediate steps may differ. - * - * See [UiLoadTraceEmitter] for details about how these events are turned into traces. + * For details of how these events are used to create UI Load traces, see [UiLoadTraceEmitter] for details. */ -class ActivityLoadEventEmitter( - private val uiLoadEventListener: UiLoadEventListener, - private val clock: Clock, - private val versionChecker: VersionChecker, +fun createActivityLoadEventEmitter( + uiLoadEventListener: UiLoadEventListener, + clock: Clock, + versionChecker: VersionChecker, +): ActivityLifecycleListener { + val uiLoadEventEmitter = UiLoadEventEmitter( + uiLoadEventListener = uiLoadEventListener, + clock = clock, + ) + return if (versionChecker.isAtLeast(VERSION_CODES.Q)) { + ActivityLoadEventEmitter(uiLoadEventEmitter) + } else { + LegacyActivityLoadEventEmitter(uiLoadEventEmitter) + } +} + +private fun Activity.observeOpening() = javaClass.isAnnotationPresent(ObservedActivity::class.java) + +/** + * Implementation that works with Android 10+ APIs + */ +@RequiresApi(VERSION_CODES.Q) +private class ActivityLoadEventEmitter( + private val uiLoadEventEmitter: UiLoadEventEmitter ) : ActivityLifecycleListener { override fun onActivityPreCreated(activity: Activity, savedInstanceState: Bundle?) { if (activity.observeOpening()) { - create(activity) - } - } - - override fun onActivityCreated(activity: Activity, bundle: Bundle?) { - if (activity.observeOpening() && !versionChecker.firePrePostEvents()) { - create(activity) + uiLoadEventEmitter.create(activity) } } override fun onActivityPostCreated(activity: Activity, savedInstanceState: Bundle?) { if (activity.observeOpening()) { - createEnd(activity) + uiLoadEventEmitter.createEnd(activity) } } override fun onActivityPreStarted(activity: Activity) { if (activity.observeOpening()) { - start(activity) + uiLoadEventEmitter.start(activity) } } - override fun onActivityStarted(activity: Activity) { - if (activity.observeOpening() && !versionChecker.firePrePostEvents()) { - createEnd(activity) - start(activity) + override fun onActivityPostStarted(activity: Activity) { + if (activity.observeOpening()) { + uiLoadEventEmitter.startEnd(activity) } } - override fun onActivityPostStarted(activity: Activity) { + override fun onActivityPreResumed(activity: Activity) { if (activity.observeOpening()) { - startEnd(activity) + uiLoadEventEmitter.resume(activity) } } - override fun onActivityPreResumed(activity: Activity) { + override fun onActivityPostResumed(activity: Activity) { if (activity.observeOpening()) { - resume(activity) + uiLoadEventEmitter.resumeEnd(activity) } } - override fun onActivityResumed(activity: Activity) { - if (activity.observeOpening() && !versionChecker.firePrePostEvents()) { - startEnd(activity) - resume(activity) + override fun onActivityPrePaused(activity: Activity) { + uiLoadEventEmitter.abandonTrace(activity) + } + + override fun onActivityStopped(activity: Activity) { + uiLoadEventEmitter.reset(activity) + } +} + +/** + * Version of [ActivityLoadEventEmitter] that works with all Android version and used for Android 9 or lower + */ +private class LegacyActivityLoadEventEmitter( + private val uiLoadEventEmitter: UiLoadEventEmitter +) : ActivityLifecycleListener { + + override fun onActivityCreated(activity: Activity, bundle: Bundle?) { + if (activity.observeOpening()) { + uiLoadEventEmitter.create(activity) } } - override fun onActivityPostResumed(activity: Activity) { + override fun onActivityStarted(activity: Activity) { if (activity.observeOpening()) { - resumeEnd(activity) + uiLoadEventEmitter.createEnd(activity) + uiLoadEventEmitter.start(activity) } } - override fun onActivityPrePaused(activity: Activity) { - abandonTrace(activity) + override fun onActivityResumed(activity: Activity) { + if (activity.observeOpening()) { + uiLoadEventEmitter.startEnd(activity) + uiLoadEventEmitter.resume(activity) + } } override fun onActivityPaused(activity: Activity) { - if (!versionChecker.firePrePostEvents()) { - abandonTrace(activity) - } + uiLoadEventEmitter.abandonTrace(activity) } override fun onActivityStopped(activity: Activity) { - reset(activity) + uiLoadEventEmitter.reset(activity) } +} - private fun abandonTrace(activity: Activity) { +/** + * Maps an Activity instance's UI Load events the app-wide UI [UiLoadEventListener] + */ +private class UiLoadEventEmitter( + private val uiLoadEventListener: UiLoadEventListener, + private val clock: Clock, +) { + fun abandonTrace(activity: Activity) { uiLoadEventListener.abandon( instanceId = traceInstanceId(activity), activityName = activity.localClassName, @@ -104,13 +138,13 @@ class ActivityLoadEventEmitter( ) } - private fun reset(activity: Activity) { + fun reset(activity: Activity) { uiLoadEventListener.reset( lastInstanceId = traceInstanceId(activity), ) } - private fun create(activity: Activity) { + fun create(activity: Activity) { uiLoadEventListener.create( instanceId = traceInstanceId(activity), activityName = activity.localClassName, @@ -118,14 +152,14 @@ class ActivityLoadEventEmitter( ) } - private fun createEnd(activity: Activity) { + fun createEnd(activity: Activity) { uiLoadEventListener.createEnd( instanceId = traceInstanceId(activity), timestampMs = nowMs() ) } - private fun start(activity: Activity) { + fun start(activity: Activity) { uiLoadEventListener.start( instanceId = traceInstanceId(activity), activityName = activity.localClassName, @@ -133,14 +167,14 @@ class ActivityLoadEventEmitter( ) } - private fun startEnd(activity: Activity) { + fun startEnd(activity: Activity) { uiLoadEventListener.startEnd( instanceId = traceInstanceId(activity), timestampMs = nowMs() ) } - private fun resume(activity: Activity) { + fun resume(activity: Activity) { uiLoadEventListener.resume( instanceId = traceInstanceId(activity), activityName = activity.localClassName, @@ -148,18 +182,14 @@ class ActivityLoadEventEmitter( ) } - private fun resumeEnd(activity: Activity) { + fun resumeEnd(activity: Activity) { uiLoadEventListener.resumeEnd( instanceId = traceInstanceId(activity), timestampMs = nowMs() ) } - private fun VersionChecker.firePrePostEvents(): Boolean = isAtLeast(Build.VERSION_CODES.Q) - private fun traceInstanceId(activity: Activity): Int = activity.hashCode() private fun nowMs(): Long = clock.now().nanosToMillis() - - private fun Activity.observeOpening() = javaClass.isAnnotationPresent(ObservedActivity::class.java) } diff --git a/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/injection/DataCaptureServiceModule.kt b/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/injection/DataCaptureServiceModule.kt index cd285012e..50d334d2e 100644 --- a/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/injection/DataCaptureServiceModule.kt +++ b/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/injection/DataCaptureServiceModule.kt @@ -1,6 +1,5 @@ package io.embrace.android.embracesdk.internal.injection -import io.embrace.android.embracesdk.internal.capture.activity.ActivityLoadEventEmitter import io.embrace.android.embracesdk.internal.capture.activity.UiLoadEventListener import io.embrace.android.embracesdk.internal.capture.crumbs.ActivityBreadcrumbTracker import io.embrace.android.embracesdk.internal.capture.crumbs.PushNotificationCaptureService @@ -8,6 +7,7 @@ import io.embrace.android.embracesdk.internal.capture.startup.AppStartupDataColl import io.embrace.android.embracesdk.internal.capture.startup.StartupService import io.embrace.android.embracesdk.internal.capture.startup.StartupTracker import io.embrace.android.embracesdk.internal.capture.webview.WebViewService +import io.embrace.android.embracesdk.internal.session.lifecycle.ActivityLifecycleListener /** * This modules provides services that capture data from within an application. It could be argued @@ -43,5 +43,5 @@ interface DataCaptureServiceModule { val uiLoadTraceEmitter: UiLoadEventListener - val activityLoadEventEmitter: ActivityLoadEventEmitter? + val activityLoadEventEmitter: ActivityLifecycleListener? } diff --git a/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/injection/DataCaptureServiceModuleImpl.kt b/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/injection/DataCaptureServiceModuleImpl.kt index 2a20ff2ab..83646cc59 100644 --- a/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/injection/DataCaptureServiceModuleImpl.kt +++ b/embrace-android-features/src/main/kotlin/io/embrace/android/embracesdk/internal/injection/DataCaptureServiceModuleImpl.kt @@ -1,9 +1,9 @@ package io.embrace.android.embracesdk.internal.injection import io.embrace.android.embracesdk.internal.Systrace -import io.embrace.android.embracesdk.internal.capture.activity.ActivityLoadEventEmitter import io.embrace.android.embracesdk.internal.capture.activity.UiLoadEventListener import io.embrace.android.embracesdk.internal.capture.activity.UiLoadTraceEmitter +import io.embrace.android.embracesdk.internal.capture.activity.createActivityLoadEventEmitter import io.embrace.android.embracesdk.internal.capture.crumbs.ActivityBreadcrumbTracker import io.embrace.android.embracesdk.internal.capture.crumbs.PushNotificationCaptureService import io.embrace.android.embracesdk.internal.capture.startup.AppStartupDataCollector @@ -14,6 +14,7 @@ import io.embrace.android.embracesdk.internal.capture.startup.StartupTracker import io.embrace.android.embracesdk.internal.capture.webview.EmbraceWebViewService import io.embrace.android.embracesdk.internal.capture.webview.WebViewService import io.embrace.android.embracesdk.internal.config.ConfigService +import io.embrace.android.embracesdk.internal.session.lifecycle.ActivityLifecycleListener import io.embrace.android.embracesdk.internal.utils.BuildVersionChecker import io.embrace.android.embracesdk.internal.utils.VersionChecker import io.embrace.android.embracesdk.internal.worker.Worker @@ -78,12 +79,12 @@ internal class DataCaptureServiceModuleImpl @JvmOverloads constructor( ) } - override val activityLoadEventEmitter: ActivityLoadEventEmitter? by singleton { + override val activityLoadEventEmitter: ActivityLifecycleListener? by singleton { if (configService.autoDataCaptureBehavior.isUiLoadPerfCaptureEnabled()) { - ActivityLoadEventEmitter( + createActivityLoadEventEmitter( uiLoadEventListener = uiLoadTraceEmitter, clock = openTelemetryModule.openTelemetryClock, - versionChecker = versionChecker, + versionChecker = versionChecker ) } else { null diff --git a/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/ActivityLoadEventEmitterTest.kt b/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/UiLoadExtTest.kt similarity index 87% rename from embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/ActivityLoadEventEmitterTest.kt rename to embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/UiLoadExtTest.kt index 25d97d8a2..bcdf84825 100644 --- a/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/ActivityLoadEventEmitterTest.kt +++ b/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/UiLoadExtTest.kt @@ -12,6 +12,7 @@ import io.embrace.android.embracesdk.internal.ClockTickingActivityLifecycleCallb import io.embrace.android.embracesdk.internal.ClockTickingActivityLifecycleCallbacks.Companion.POST_DURATION import io.embrace.android.embracesdk.internal.ClockTickingActivityLifecycleCallbacks.Companion.PRE_DURATION import io.embrace.android.embracesdk.internal.ClockTickingActivityLifecycleCallbacks.Companion.STATE_DURATION +import io.embrace.android.embracesdk.internal.session.lifecycle.ActivityLifecycleListener import io.embrace.android.embracesdk.internal.utils.BuildVersionChecker import org.junit.Assert.assertEquals import org.junit.Before @@ -24,10 +25,10 @@ import org.robolectric.annotation.Config import kotlin.reflect.KClass @RunWith(AndroidJUnit4::class) -internal class ActivityLoadEventEmitterTest { +internal class UiLoadExtTest { private lateinit var clock: FakeClock - private lateinit var openEvents: FakeUiLoadEventListener - private lateinit var eventEmitter: ActivityLoadEventEmitter + private lateinit var uiLoadEventListener: FakeUiLoadEventListener + private lateinit var eventEmitter: ActivityLifecycleListener private lateinit var activityController: ActivityController<*> private var startTimeMs: Long = 0L private var instanceId = 0 @@ -36,17 +37,15 @@ internal class ActivityLoadEventEmitterTest { @Before fun setUp() { clock = FakeClock() - val initModule = FakeInitModule(clock = clock) - clock.tick(100L) - openEvents = FakeUiLoadEventListener() - eventEmitter = ActivityLoadEventEmitter( - uiLoadEventListener = openEvents, - clock = initModule.openTelemetryModule.openTelemetryClock, - versionChecker = BuildVersionChecker, - ) + uiLoadEventListener = FakeUiLoadEventListener() RuntimeEnvironment.getApplication().registerActivityLifecycleCallbacks( ClockTickingActivityLifecycleCallbacks(clock) ) + eventEmitter = createActivityLoadEventEmitter( + uiLoadEventListener = uiLoadEventListener, + clock = FakeInitModule(clock = clock).openTelemetryModule.openTelemetryClock, + versionChecker = BuildVersionChecker + ) RuntimeEnvironment.getApplication().registerActivityLifecycleCallbacks(eventEmitter) startTimeMs = clock.now() setupActivityController(FakeObservedActivity::class) @@ -54,9 +53,9 @@ internal class ActivityLoadEventEmitterTest { @Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE]) @Test - fun `check cold open event stages in U`() { + fun `check cold ui load event stages in U`() { stepThroughActivityLifecycle() - openEvents.events.assertEventData( + uiLoadEventListener.events.assertEventData( listOf( createEvent( stage = "create", @@ -95,9 +94,9 @@ internal class ActivityLoadEventEmitterTest { @Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE]) @Test - fun `check hot open event stages in U`() { + fun `check hot ui load event stages in U`() { stepThroughActivityLifecycle(isColdOpen = false) - openEvents.events.assertEventData( + uiLoadEventListener.events.assertEventData( listOf( createEvent( stage = "start", @@ -126,11 +125,29 @@ internal class ActivityLoadEventEmitterTest { ) } + @Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE]) + @Test + fun `unobserved activities will not emit ui load events in U`() { + setupActivityController(Activity::class) + stepThroughActivityLifecycle() + uiLoadEventListener.events.assertEventData( + listOf( + createEvent( + stage = "abandon", + timestampMs = startTimeMs + (POST_DURATION + STATE_DURATION + PRE_DURATION) * 3 + PRE_DURATION + ), + createEvent( + stage = "reset", + ), + ) + ) + } + @Config(sdk = [Build.VERSION_CODES.LOLLIPOP]) @Test - fun `check cold open event stages in L`() { + fun `check cold ui load event stages in L`() { stepThroughActivityLifecycle() - openEvents.events.assertEventData( + uiLoadEventListener.events.assertEventData( listOf( createEvent( stage = "create", @@ -165,9 +182,9 @@ internal class ActivityLoadEventEmitterTest { @Config(sdk = [Build.VERSION_CODES.LOLLIPOP]) @Test - fun `check hot open event stages in L`() { + fun `check hot ui load event stages in L`() { stepThroughActivityLifecycle(isColdOpen = false) - openEvents.events.assertEventData( + uiLoadEventListener.events.assertEventData( listOf( createEvent( stage = "createEnd", @@ -196,30 +213,12 @@ internal class ActivityLoadEventEmitterTest { ) } - @Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE]) - @Test - fun `unobserved activities will not emit open events in U`() { - setupActivityController(Activity::class) - stepThroughActivityLifecycle() - openEvents.events.assertEventData( - listOf( - createEvent( - stage = "abandon", - timestampMs = startTimeMs + (POST_DURATION + STATE_DURATION + PRE_DURATION) * 3 + PRE_DURATION - ), - createEvent( - stage = "reset", - ), - ) - ) - } - @Config(sdk = [Build.VERSION_CODES.LOLLIPOP]) @Test - fun `unobserved activities will not emit open events in L`() { + fun `unobserved activities will not emit ui load events in L`() { setupActivityController(Activity::class) stepThroughActivityLifecycle() - openEvents.events.assertEventData( + uiLoadEventListener.events.assertEventData( listOf( createEvent( stage = "abandon", diff --git a/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/UiLoadTraceEmitterTest.kt b/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/UiLoadTraceEmitterTest.kt index 80542744c..8bbcd9661 100644 --- a/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/UiLoadTraceEmitterTest.kt +++ b/embrace-android-features/src/test/java/io/embrace/android/embracesdk/internal/capture/activity/UiLoadTraceEmitterTest.kt @@ -42,7 +42,7 @@ internal class UiLoadTraceEmitterTest { @Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE]) @Test - fun `verify cold open trace from another activity in U`() { + fun `verify cold ui load trace from another activity in U`() { verifyOpen( previousState = PreviousState.FROM_ACTIVITY, uiLoadType = UiLoadType.COLD, @@ -53,7 +53,7 @@ internal class UiLoadTraceEmitterTest { @Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE]) @Test - fun `verify cold open trace from the same activity in U`() { + fun `verify cold ui load trace from the same activity in U`() { verifyOpen( lastActivityName = ACTIVITY_NAME, previousState = PreviousState.FROM_ACTIVITY, @@ -66,7 +66,7 @@ internal class UiLoadTraceEmitterTest { @Ignore("Not working yet") @Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE]) @Test - fun `verify cold open trace from an interrupted opening of another activity in U`() { + fun `verify cold ui load trace from an interrupted opening of another activity in U`() { verifyOpen( previousState = PreviousState.FROM_INTERRUPTED_LOAD, uiLoadType = UiLoadType.COLD, @@ -78,7 +78,7 @@ internal class UiLoadTraceEmitterTest { @Ignore("Not working yet") @Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE]) @Test - fun `verify cold open trace from an interrupted opening of the same activity in U`() { + fun `verify cold ui load trace from an interrupted opening of the same activity in U`() { verifyOpen( lastActivityName = ACTIVITY_NAME, previousState = PreviousState.FROM_INTERRUPTED_LOAD, @@ -90,7 +90,7 @@ internal class UiLoadTraceEmitterTest { @Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE]) @Test - fun `verify cold open trace from background in U`() { + fun `verify cold ui load trace from background in U`() { verifyOpen( previousState = PreviousState.FROM_BACKGROUND, uiLoadType = UiLoadType.COLD, @@ -101,7 +101,7 @@ internal class UiLoadTraceEmitterTest { @Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE]) @Test - fun `verify hot open trace in from background in U`() { + fun `verify hot ui load trace in from background in U`() { verifyOpen( previousState = PreviousState.FROM_BACKGROUND, uiLoadType = UiLoadType.HOT, @@ -112,7 +112,7 @@ internal class UiLoadTraceEmitterTest { @Config(sdk = [Build.VERSION_CODES.LOLLIPOP]) @Test - fun `verify cold open trace in from another activity L`() { + fun `verify cold ui load trace in from another activity L`() { verifyOpen( previousState = PreviousState.FROM_ACTIVITY, uiLoadType = UiLoadType.COLD, @@ -123,7 +123,7 @@ internal class UiLoadTraceEmitterTest { @Config(sdk = [Build.VERSION_CODES.LOLLIPOP]) @Test - fun `verify cold open trace from background in L`() { + fun `verify cold ui load trace from background in L`() { verifyOpen( previousState = PreviousState.FROM_BACKGROUND, uiLoadType = UiLoadType.COLD, @@ -134,7 +134,7 @@ internal class UiLoadTraceEmitterTest { @Config(sdk = [Build.VERSION_CODES.LOLLIPOP]) @Test - fun `verify hot open trace in L from background`() { + fun `verify hot ui load trace in L from background`() { verifyOpen( previousState = PreviousState.FROM_BACKGROUND, uiLoadType = UiLoadType.HOT, diff --git a/embrace-android-sdk/src/integrationTest/kotlin/io/embrace/android/embracesdk/testcases/features/UiLoadTest.kt b/embrace-android-sdk/src/integrationTest/kotlin/io/embrace/android/embracesdk/testcases/features/UiLoadTest.kt index 5fbc25265..13227ee1c 100644 --- a/embrace-android-sdk/src/integrationTest/kotlin/io/embrace/android/embracesdk/testcases/features/UiLoadTest.kt +++ b/embrace-android-sdk/src/integrationTest/kotlin/io/embrace/android/embracesdk/testcases/features/UiLoadTest.kt @@ -57,7 +57,7 @@ internal class UiLoadTest { @Config(sdk = [Build.VERSION_CODES.LOLLIPOP]) @Test - fun `opening first non-startup activity creates cold open trace in L`() { + fun `opening first non-startup activity creates cold ui load trace in L`() { var preLaunchTimeMs = 0L testRule.runTest( setupAction = { @@ -108,7 +108,7 @@ internal class UiLoadTest { @Config(sdk = [Build.VERSION_CODES.LOLLIPOP]) @Test - fun `foregrounding and initializing new activity creates cold open trace in L`() { + fun `foregrounding and initializing new activity creates cold ui load trace in L`() { var preLaunchTimeMs = 0L testRule.runTest( setupAction = { @@ -161,7 +161,7 @@ internal class UiLoadTest { @Config(sdk = [Build.VERSION_CODES.LOLLIPOP]) @Test - fun `foregrounding already-created activity creates hot open trace in L`() { + fun `foregrounding already-created activity creates hot ui load trace in L`() { var preLaunchTimeMs = 0L testRule.runTest( setupAction = { diff --git a/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/fakes/injection/FakeDataCaptureServiceModule.kt b/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/fakes/injection/FakeDataCaptureServiceModule.kt index e22131d41..a100eda0b 100644 --- a/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/fakes/injection/FakeDataCaptureServiceModule.kt +++ b/embrace-android-sdk/src/test/java/io/embrace/android/embracesdk/fakes/injection/FakeDataCaptureServiceModule.kt @@ -7,7 +7,6 @@ import io.embrace.android.embracesdk.fakes.FakeFeatureModule import io.embrace.android.embracesdk.fakes.FakeStartupService import io.embrace.android.embracesdk.fakes.FakeUiLoadEventListener import io.embrace.android.embracesdk.fakes.FakeWebViewService -import io.embrace.android.embracesdk.internal.capture.activity.ActivityLoadEventEmitter import io.embrace.android.embracesdk.internal.capture.activity.UiLoadEventListener import io.embrace.android.embracesdk.internal.capture.crumbs.ActivityBreadcrumbTracker import io.embrace.android.embracesdk.internal.capture.crumbs.PushNotificationCaptureService @@ -16,6 +15,7 @@ import io.embrace.android.embracesdk.internal.capture.startup.StartupService import io.embrace.android.embracesdk.internal.capture.startup.StartupTracker import io.embrace.android.embracesdk.internal.capture.webview.WebViewService import io.embrace.android.embracesdk.internal.injection.DataCaptureServiceModule +import io.embrace.android.embracesdk.internal.session.lifecycle.ActivityLifecycleListener import io.mockk.mockk internal class FakeDataCaptureServiceModule( @@ -35,5 +35,5 @@ internal class FakeDataCaptureServiceModule( override val uiLoadTraceEmitter: UiLoadEventListener = FakeUiLoadEventListener() - override val activityLoadEventEmitter: ActivityLoadEventEmitter = mockk(relaxed = true) + override val activityLoadEventEmitter: ActivityLifecycleListener = object : ActivityLifecycleListener { } }