diff --git a/packages/core/android/src/main/kotlin/com/datadog/reactnative/FrameRateProvider.kt b/packages/core/android/src/main/kotlin/com/datadog/reactnative/FrameRateProvider.kt index 1e4ccfd00..99a8c1f7f 100644 --- a/packages/core/android/src/main/kotlin/com/datadog/reactnative/FrameRateProvider.kt +++ b/packages/core/android/src/main/kotlin/com/datadog/reactnative/FrameRateProvider.kt @@ -6,7 +6,7 @@ package com.datadog.reactnative -import com.facebook.react.modules.core.ChoreographerCompat +import android.view.Choreographer internal class FrameRateProvider( reactFrameRateCallback: ((Double) -> Unit), @@ -30,9 +30,9 @@ internal class FrameRateProvider( internal class FpsFrameCallback( private val reactFrameRateCallback: ((Double) -> Unit), private val uiThreadExecutor: UiThreadExecutor -) : ChoreographerCompat.FrameCallback() { +) : Choreographer.FrameCallback { - private var choreographer: ChoreographerCompat? = null + private var choreographer: Choreographer? = null private var lastFrameTime = -1L override fun doFrame(time: Long) { @@ -45,14 +45,14 @@ internal class FpsFrameCallback( fun start() { uiThreadExecutor.runOnUiThread { - choreographer = ChoreographerCompat.getInstance() + choreographer = Choreographer.getInstance() choreographer?.postFrameCallback(this@FpsFrameCallback) } } fun stop() { uiThreadExecutor.runOnUiThread { - choreographer = ChoreographerCompat.getInstance() + choreographer = Choreographer.getInstance() choreographer?.removeFrameCallback(this@FpsFrameCallback) } } diff --git a/packages/core/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt b/packages/core/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt index 3f72b571b..46bffe029 100644 --- a/packages/core/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +++ b/packages/core/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt @@ -38,7 +38,6 @@ import com.datadog.tools.unit.toReadableMap import com.facebook.react.bridge.Promise import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.bridge.ReadableMap -import com.facebook.react.modules.core.ChoreographerCompat import fr.xgouchet.elmyr.Forge import fr.xgouchet.elmyr.annotation.AdvancedForgery import fr.xgouchet.elmyr.annotation.BoolForgery @@ -81,13 +80,6 @@ import org.mockito.kotlin.verifyNoInteractions import org.mockito.kotlin.whenever import org.mockito.quality.Strictness -fun mockChoreographerCompatInstance(mock: ChoreographerCompat = mock()) { - ChoreographerCompat::class.java.setStaticValue( - "sInstance", - mock - ) -} - fun mockChoreographerInstance(mock: Choreographer = mock()) { Choreographer::class.java.setStaticValue( "sThreadInstance", @@ -135,9 +127,6 @@ internal class DdSdkTest { @Mock lateinit var mockChoreographer: Choreographer - @Mock - lateinit var mockChoreographerCompat: ChoreographerCompat - @BeforeEach fun `set up`() { val mockLooper = mock() @@ -148,10 +137,8 @@ internal class DdSdkTest { whenever(mockRumMonitor._getInternal()) doReturn mockRumInternalProxy doNothing().whenever(mockChoreographer).postFrameCallback(any()) - doNothing().whenever(mockChoreographerCompat).postFrameCallback(any()) mockChoreographerInstance(mockChoreographer) - mockChoreographerCompatInstance(mockChoreographerCompat) whenever(mockReactContext.applicationContext) doReturn mockContext whenever(mockContext.packageName) doReturn "packageName" @@ -1581,8 +1568,9 @@ internal class DdSdkTest { .hasField("featureConfiguration") { it.hasFieldEqualTo("vitalsMonitorUpdateFrequency", VitalsUpdateFrequency.RARE) } - argumentCaptor { - verify(mockChoreographerCompat).postFrameCallback(capture()) + + argumentCaptor { + verify(mockChoreographer).postFrameCallback(capture()) assertThat(firstValue).isInstanceOf(FpsFrameCallback::class.java) } } @@ -1592,7 +1580,7 @@ internal class DdSdkTest { @Forgery configuration: DdSdkConfiguration ) { // Given - doThrow(IllegalStateException()).whenever(mockChoreographerCompat).postFrameCallback(any()) + doThrow(IllegalStateException()).whenever(mockChoreographer).postFrameCallback(any()) val bridgeConfiguration = configuration.copy( vitalsUpdateFrequency = "NEVER", longTaskThresholdMs = 0.0 @@ -1620,7 +1608,7 @@ internal class DdSdkTest { .hasField("featureConfiguration") { it.hasFieldEqualTo("vitalsMonitorUpdateFrequency", VitalsUpdateFrequency.NEVER) } - verifyNoInteractions(mockChoreographerCompat) + verifyNoInteractions(mockChoreographer) } @Test @@ -1660,8 +1648,8 @@ internal class DdSdkTest { .hasField("featureConfiguration") { it.hasFieldEqualTo("vitalsMonitorUpdateFrequency", VitalsUpdateFrequency.AVERAGE) } - argumentCaptor { - verify(mockChoreographerCompat).postFrameCallback(capture()) + argumentCaptor { + verify(mockChoreographer).postFrameCallback(capture()) assertThat(firstValue).isInstanceOf(FpsFrameCallback::class.java) // When @@ -1698,8 +1686,8 @@ internal class DdSdkTest { testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise) // Then - argumentCaptor { - verify(mockChoreographerCompat).postFrameCallback(capture()) + argumentCaptor { + verify(mockChoreographer).postFrameCallback(capture()) // When firstValue.doFrame(timestampNs) @@ -1735,8 +1723,8 @@ internal class DdSdkTest { testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise) // Then - argumentCaptor { - verify(mockChoreographerCompat).postFrameCallback(capture()) + argumentCaptor { + verify(mockChoreographer).postFrameCallback(capture()) // When firstValue.doFrame(timestampNs)