Skip to content

Commit

Permalink
Add fallback start time values for cases where process creation time …
Browse files Browse the repository at this point in the history
…is unavailable
  • Loading branch information
bidetofevil committed Mar 14, 2024
1 parent aa3be55 commit f69b03b
Show file tree
Hide file tree
Showing 2 changed files with 195 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ internal class AppStartupTraceEmitter(

init {
val timestampAtDeviceStart = nowMs() - clock.nanoTime().nanosToMillis()
processCreateRequestedMs = if (versionChecker.isAtLeast(VERSION_CODES.N)) {
timestampAtDeviceStart + Process.getStartElapsedRealtime()
processCreateRequestedMs = if (versionChecker.isAtLeast(VERSION_CODES.TIRAMISU)) {
timestampAtDeviceStart + Process.getStartRequestedElapsedRealtime()
} else {
null
}
processCreatedMs = if (versionChecker.isAtLeast(VERSION_CODES.TIRAMISU)) {
timestampAtDeviceStart + Process.getStartRequestedElapsedRealtime()
processCreatedMs = if (versionChecker.isAtLeast(VERSION_CODES.N)) {
timestampAtDeviceStart + Process.getStartElapsedRealtime()
} else {
null
}
Expand Down Expand Up @@ -134,6 +134,7 @@ internal class AppStartupTraceEmitter(
}
}

@Suppress("CyclomaticComplexMethod", "ComplexMethod")
private fun recordStartup() {
val startupService = startupServiceProvider() ?: return
val sdkInitStartMs = startupService.getSdkInitStartMs()
Expand Down

0 comments on commit f69b03b

Please sign in to comment.