Repository navigation
devices/home: a never-set strap RTC reads "time unknown", not "no data" (follow-up to #758) #762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -383,6 +383,26 @@ bool isPlausibleUnix( | |
| return true; | ||
| } | ||
|
|
||
| /// The record frontier (`rec_ts_hw`) as a wall-clock instant for display, or | ||
| /// null when it is missing or below the plausible floor. A strap whose RTC was | ||
| /// never set banks factory-epoch records; the frontier cursor and `lastRecordAt` | ||
| /// guard only `> 0` / `!= null`, so such a frontier reached the devices "last | ||
| /// data" line as a 1970/2019 date the records never supported. Applying the | ||
| /// same [kMinPlausibleUnix] floor the ingest gate uses keeps that honest. | ||
| DateTime? plausibleRecordInstant(int? tsSec) => | ||
| (tsSec == null || tsSec < kMinPlausibleUnix) | ||
| ? null | ||
| : DateTime.fromMillisecondsSinceEpoch(tsSec * 1000); | ||
|
|
||
| /// True when a record frontier exists but its time cannot be trusted: a | ||
| /// positive `rec_ts_hw` below the plausible floor, which is what a strap whose | ||
| /// RTC was never set banks (factory-epoch records). It means data WAS recorded — | ||
| /// so "nothing banked yet" is wrong — but its timestamp is unusable, which is | ||
| /// different again from a plausible frontier. [plausibleRecordInstant] returns | ||
| /// null for both this and a truly missing frontier; this tells them apart. | ||
| bool recordTimestampUntrusted(int? tsSec) => | ||
| tsSec != null && tsSec > 0 && tsSec < kMinPlausibleUnix; | ||
|
Comment on lines
+403
to
+404
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Archive-only offloads leave When a burst contains only records with a positive sub-floor timestamp, the commit stores them only in The commit must record that records were banked with an unusable timestamp, or the state must be derived from the archived records. Choose the mechanism that leaves the plausible frontier and the record gate unchanged.
|
||
|
|
||
| /// A stricter, single-purpose sanity check for a band-reported "newest | ||
| /// record" timestamp (GET_DATA_RANGE's `range_newest`) that sits implausibly | ||
| /// far in the future — the signature of a corrupt/never-set strap RTC. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -851,6 +851,9 @@ class HealthSource { | |
| /// sleep, recovery and temperature are all still abstaining. | ||
| final bool isBand; | ||
|
|
||
| /// Band only: data was banked but its timestamp is untrusted (unset RTC). | ||
| final bool timeUnknown; | ||
|
|
||
| /// The `device` row this source is, for a paired sensor. Null for the | ||
| /// primary band (whose row is `LocalDb.kPrimaryDeviceId`, `''`) and for the | ||
| /// phone. It is the `device_id` every measurement this source wrote carries, | ||
|
|
@@ -889,6 +892,7 @@ class HealthSource { | |
| this.batteryPackPct, | ||
| this.lastData, | ||
| this.isBand = false, | ||
| this.timeUnknown = false, | ||
| this.deviceId, | ||
| this.family, | ||
| this.flagOff = false, | ||
|
|
@@ -1030,6 +1034,7 @@ List<HealthSource> liveSources(AppState app, | |
| batteryPackPct: app.device.batteryPackPct, | ||
| lastData: app.lastRecordAt, | ||
| isBand: true, | ||
| timeUnknown: app.bandRecordTimeUnknown, | ||
|
sourcery-ai[bot] marked this conversation as resolved.
Resolved
|
||
| // The stored generation when no link has come up this launch, so a | ||
| // disconnected band keeps its family-gated rows (Worn on, signals). | ||
| family: app.device.generation ?? app.paired?.generation, | ||
|
|
@@ -2627,10 +2632,18 @@ class DeviceDetailView extends StatelessWidget { | |
| ], | ||
| SetRow(LucideIcons.refreshCw, C.purple, | ||
| l?.devicesLastData ?? 'Last data', | ||
| value: last == null ? '' : formatDayTime(last, l), | ||
| sub: last == null | ||
| ? (l?.devicesNothingBankedYet ?? 'Nothing banked yet') | ||
| : '', | ||
| value: last != null | ||
| ? formatDayTime(last, l) | ||
| : s.timeUnknown | ||
| ? (l?.devicesTimeUnknown ?? 'Time unknown') | ||
| : '', | ||
| sub: last != null | ||
| ? '' | ||
| : s.timeUnknown | ||
| ? (l?.devicesClockNotSetSub ?? | ||
| 'The strap recorded data but its clock is not set') | ||
| : (l?.devicesNothingBankedYet ?? | ||
| 'Nothing banked yet'), | ||
|
Comment on lines
+2635
to
+2646
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the unreachable clock-state branches from the sensor "Last data" row. No sensor source sets Suggested fix
|
||
| chevron: false), | ||
| // A wearable with a column in the metric x device | ||
| // table: what we measure from it, and its own values. | ||
|
|
@@ -2767,10 +2780,18 @@ class DeviceDetailView extends StatelessWidget { | |
| ], | ||
| SetRow(LucideIcons.refreshCw, C.purple, | ||
| l?.devicesLastData ?? 'Last data', | ||
| value: last == null ? '' : formatDayTime(last, l), | ||
| sub: last == null | ||
| ? (l?.devicesNothingBankedYet ?? 'Nothing banked yet') | ||
| : '', | ||
| value: last != null | ||
| ? formatDayTime(last, l) | ||
| : s.timeUnknown | ||
| ? (l?.devicesTimeUnknown ?? 'Time unknown') | ||
| : '', | ||
| sub: last != null | ||
| ? '' | ||
| : s.timeUnknown | ||
| ? (l?.devicesClockNotSetSub ?? | ||
| 'The strap recorded data but its clock is not set') | ||
| : (l?.devicesNothingBankedYet ?? | ||
| 'Nothing banked yet'), | ||
| chevron: false), | ||
| if (calibration != null) ...[ | ||
| Divider(color: p.line, height: 1), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.