feat(location): durable offline GPS outbox and hourly daily uploads v0.1.50

This commit is contained in:
Codex
2026-10-19 00:57:33 +08:00
parent cd3ed420a2
commit e3afb2e07f
26 changed files with 697 additions and 135 deletions
@@ -2,7 +2,11 @@ package cn.ucvl.zhaodisplay;
/** Shared scheduling rule, independent of Android for deterministic testing. */
final class LocationCadence {
static int seconds(int value){return value==10||value==60||value==300?value:300;}
static final int MAX_SECONDS=30*86400;
static boolean valid(int value){return value==10||value==60||value==300||value>=3600&&value<=MAX_SECONDS&&value%3600==0;}
static int seconds(int value){return valid(value)?value:300;}
static int sample(int value){return value==10||value==60||value==300?value:60;}
static int custom(int value,boolean days){long seconds=value*(days?86400L:3600L);if(value<1||seconds>MAX_SECONDS)throw new IllegalArgumentException("周期需在 1 小时至 30 天内");return (int)seconds;}
static boolean due(long now,long lastAttempt,int interval,boolean firstFix){
return lastAttempt==0||now-lastAttempt>=1000L*(firstFix?10:seconds(interval));
}