Skip to content

Commit 474b942

Browse files
committed
RUM-8785: post-review fixes
1 parent e317b45 commit 474b942

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/vitals/FPSVitalListener.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*/
66
package com.datadog.android.rum.internal.vitals
77

8+
import android.annotation.SuppressLint
89
import android.os.Build
10+
import androidx.annotation.RequiresApi
911
import androidx.metrics.performance.FrameData
1012
import com.datadog.android.core.internal.system.BuildSdkVersionProvider
1113
import com.datadog.android.rum.internal.domain.FrameMetricsData
@@ -16,6 +18,7 @@ internal class FPSVitalListener(
1618
private val buildSdkVersionProvider: BuildSdkVersionProvider = BuildSdkVersionProvider.DEFAULT,
1719
private var screenRefreshRate: Double = 60.0
1820
) : FrameStateListener {
21+
@RequiresApi(Build.VERSION_CODES.S)
1922
private var frameDeadline = EXPECTED_60_FPS_FRAME_DURATION_NS
2023
private var displayRefreshRate: Double = SIXTY_FPS
2124

@@ -24,6 +27,7 @@ internal class FPSVitalListener(
2427
if (durationNs > 0.0) {
2528
var frameRate = (ONE_SECOND_NS / durationNs)
2629

30+
@SuppressLint("NewApi")
2731
if (buildSdkVersionProvider.version >= Build.VERSION_CODES.S) {
2832
screenRefreshRate = ONE_SECOND_NS / frameDeadline
2933
} else if (buildSdkVersionProvider.version == Build.VERSION_CODES.R) {
@@ -42,6 +46,7 @@ internal class FPSVitalListener(
4246

4347
override fun onFrameMetricsData(data: FrameMetricsData) {
4448
displayRefreshRate = data.displayRefreshRate
49+
@SuppressLint("NewApi")
4550
if (buildSdkVersionProvider.version >= Build.VERSION_CODES.S) {
4651
frameDeadline = data.deadline
4752
}

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/vitals/JankStatsActivityLifecycleListener.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ internal class JankStatsActivityLifecycleListener(
214214
if (frameMetricsListener == null) {
215215
frameMetricsListener = DDFrameMetricsListener()
216216
}
217-
// todo RUM-8799: handler thread can be used instead
217+
// TODO RUM-8799: handler thread can be used instead
218218
val handler = Handler(Looper.getMainLooper())
219219
val decorView = window.peekDecorView()
220220

@@ -296,7 +296,7 @@ internal class JankStatsActivityLifecycleListener(
296296
commandIssueDuration = frameMetrics.getMetric(FrameMetrics.COMMAND_ISSUE_DURATION)
297297
swapBuffersDuration = frameMetrics.getMetric(FrameMetrics.SWAP_BUFFERS_DURATION)
298298
totalDuration = frameMetrics.getMetric(FrameMetrics.TOTAL_DURATION)
299-
firstDrawFrame = frameMetrics.getMetric(FrameMetrics.FIRST_DRAW_FRAME) == TRUE
299+
firstDrawFrame = frameMetrics.getMetric(FrameMetrics.FIRST_DRAW_FRAME) == IS_FIRST_DRAW_FRAME
300300
}
301301
@SuppressLint("InlinedApi")
302302
if (buildSdkVersionProvider.version >= Build.VERSION_CODES.O) {
@@ -320,6 +320,6 @@ internal class JankStatsActivityLifecycleListener(
320320
internal const val JANK_STATS_TRACKING_DISABLE_ERROR =
321321
"Failed to disable JankStats tracking"
322322
private const val SIXTY_FPS: Double = 60.0
323-
private const val TRUE = 1L
323+
private const val IS_FIRST_DRAW_FRAME = 1L
324324
}
325325
}

0 commit comments

Comments
 (0)