Skip to content

Commit 263ae6e

Browse files
committed
Move currentTimeUs into WallClock
1 parent 78f303c commit 263ae6e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

firebase-sessions/src/main/kotlin/com/google/firebase/sessions/SessionEvents.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ internal object SessionEvents {
103103
fun startSession(
104104
firebaseApp: FirebaseApp,
105105
sessionDetails: SessionDetails,
106-
currentTimeUs: Long = System.currentTimeMillis() * 1000
106+
currentTimeUs: Long = WallClock.currentTimeUs(),
107107
) =
108108
SessionEvent(
109109
eventType = EventType.SESSION_START,

firebase-sessions/src/main/kotlin/com/google/firebase/sessions/WallClock.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,12 @@ import kotlin.time.Duration.Companion.milliseconds
2424
internal object WallClock {
2525
/** Gets the [Duration] elapsed in "wall clock" time since device boot. */
2626
fun elapsedRealtime(): Duration = SystemClock.elapsedRealtime().milliseconds
27+
28+
/**
29+
* Gets the current time in microseconds. The clock can be set by the user or phone network so it
30+
* is not universally accurate or increasing.
31+
*/
32+
fun currentTimeUs(): Long {
33+
return System.currentTimeMillis() * 1000
34+
}
2735
}

0 commit comments

Comments
 (0)