package cn.ucvl.zhaodisplay; /** Shared scheduling rule, independent of Android for deterministic testing. */ final class LocationCadence { 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)); } }