Add allowed-window restriction and harden daily location - #232
Open
patriciojofre wants to merge 3 commits into
Open
Add allowed-window restriction and harden daily location#232patriciojofre wants to merge 3 commits into
patriciojofre wants to merge 3 commits into
Conversation
Restrict daily-location acquisition/send to a server-configured window (settings.local.location_schedule in status.json), evaluated in UTC. With no config the location is still sent daily ASAP. - LocationScheduleWindow: pure, unit-tested UTC window evaluation (per-weekday booleans + start_at/end_at, inclusive; fail-open on empty/malformed config). - PreyStatus: parse settings.local.location_schedule; PreyConfig: LOCATION_SCHEDULE. - DailyLocation: gate on the window, switch the "already sent today" guard to UTC, keep the most-accurate fix over a wider window (send best obtained), and replace RuntimeException with logging; drop duplicate setLastLocation. - LocationScheduled: replace setInexactRepeating with a self-rescheduling setAndAllowWhileIdle/setExact alarm so it survives Doze; AlarmLocationReceiver re-arms the next fire before running. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Restricts the daily-location report to a server-configured time window and hardens the surrounding flow. The window comes from
settings.local.location_schedulein/devices/:key/status.jsonand is evaluated in UTC. With no config, the location is still sent daily ASAP (unchanged behavior).Config shape:
{ "start_at": "10:00", "end_at": "11:00", "sunday": false, "monday": true, "tuesday": true, "wednesday": true, "thursday": true, "friday": true, "saturday": false }Changes
New allowed-window restriction
Hardening / fixes
Guard order in DailyLocation.run: already-sent-today (UTC) → skip · airplane mode OR outside window → skip · else acquire + send · store UTC date only on HTTP 200/201 → one send per allowed UTC day.
Testing