fix|reboot detection via boot_id + bump to 4.0.1.alpha#165
fix|reboot detection via boot_id + bump to 4.0.1.alpha#165PeterWagih90 wants to merge 2 commits into
Conversation
Replace elapsed-time heuristic with /proc/sys/kernel/random/boot_id comparison in TimeKeeper. SntpResult now carries the boot ID captured at sync time; TimeKeeper compares it on cache validation to reliably detect reboots regardless of uptime. Falls back to old elapsed-time check for cached entries that predate this change. Also add consumer-rules.pro to keep the public TrueTime API under ProGuard/R8, and wire it into the release build type.
| package com.instacart.truetime.sntp | ||
|
|
||
| class SntpResult(val ntpResult: LongArray) { | ||
| class SntpResult(val ntpResult: LongArray, val bootId: String = "") { |
There was a problem hiding this comment.
Adding bootId to the primary constructor changes the JVM signature of SntpResult from SntpResult(long[]) to SntpResult(long[], String). This type is part of the public surface through CacheProvider and TrueTimeEventListener, so downstream Java callers and already-compiled binaries that instantiate it will break on upgrade. Please keep the old constructor signature available, for example with an explicit secondary constructor delegating to this(ntpResult, "") or another JVM-compatible overload.
| @@ -0,0 +1,9 @@ | |||
| # Keep TrueTime public API | |||
| -keep public class com.instacart.truetime.time.TrueTime { *; } | |||
There was a problem hiding this comment.
TrueTime is declared as an interface, not a class, so this keep rule does not match the library's main public API type. As written, consumer R8/ProGuard can still rename or strip TrueTime. This should be a -keep public interface ... rule.
- consumer-rules.pro: TrueTime is an interface, use -keep public interface - SntpResult: add explicit secondary constructor(LongArray) to preserve JVM binary compatibility for existing Java callers
Replace elapsed-time heuristic with /proc/sys/kernel/random/boot_id comparison in TimeKeeper. SntpResult now carries the boot ID captured at sync time; TimeKeeper compares it on cache validation to reliably detect reboots regardless of uptime. Falls back to old elapsed-time check for cached entries that predate this change.
Also add consumer-rules.pro to keep the public TrueTime API under ProGuard/R8, and wire it into the release build type.