Repository navigation
Conversation
Settings -> Tags -> Keep location history: forever (the default), 1 year, 6 months, 3 months or 1 month. Until now the app never deleted a location report, and with the default it still doesn't: nothing is read from the database at start unless a period has been chosen. Choosing a shorter period asks first, then saves it and deletes older reports. The save goes first through RxFlows.onlyAfter, so a failed save deletes nothing (updateDataAsync starts writing when called, so store.andThen(prune) would not wait for it). A longer period or forever is only saved. After that the app prunes on each start, off the main thread. Each tag's newest report is kept however old, since it is the tag's last known position on the map, not history. The per-day fetch markers are kept too, so the History screen doesn't ask Apple for a day it has deleted; the shortest period, a month, is well past what Apple keeps. The pruner sits behind AppDependencies so the Settings test can drive the row without deleting a phone's real history. Tests: KeepingLocationHistoryTest and HistoryRetentionRowTest (JVM), PruningOldLocationHistoryTest (in-memory Room) and HistoryRetentionSettingTest (Espresso, fake pruner). Strings added to all ten locales with add_strings.py. Part of parawanderer#318. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lazzurs
temporarily deployed
to
Android Build
November 24, 2026 00:06 — with
GitHub Actions
Inactive
lazzurs
had a problem deploying
to
Android Build
November 24, 2026 00:06 — with
GitHub Actions
Failure
1 of 30 tasks
lazzurs
temporarily deployed
to
Android Build
November 24, 2026 16:33 — with
GitHub Actions
Inactive
Owner
|
Same flake as #320, at 00:24 UTC: #322 replaces the seeded times with ones anchored to local midnight, so after it merges a rebase here ends the problem for good.
|
This branch was previously deployed
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.
Adds a setting for how long location history is kept, the retention half of audit finding S-04. Until now nothing in the app ever deleted a
LocationReport, so a phone held every position of every tag since install. #315 lets people delete a tag's history or everything; this lets them keep a rolling window instead.What it does
Schedulers.io(), inOpenAirTagApplication(main process only, after the:adiprobe/:macadiearly return). That covers the background scan's process too. I chose app start over "after history is persisted" because the write paths are inBeaconRepository, which Delete a removed tag's keys, and offer to erase its history #315 changes heavily, and a once-per-start delete is cheap and enough for a period measured in months.What's kept, and why
(beacon_id, timestamp)index).DailyHistoryFetchRecord(the per-day "already fetched" markers). They hold no position, and removing one makes the History screen ask Apple for that day again. The shortest choice is a month, so a deleted day is always far older than anything Apple still has.Sequencing
The save is a DataStore write, and
updateDataAsyncstarts when called, sosave.andThen(prune)would start the delete regardless. It usesRxFlows.onlyAfterfrom #317: the delete is only created once the save has completed. If the save fails, nothing is deleted, the old period is restored on screen and the existing "Error updating settings" message is shown. If the delete fails, the new period stays and a toast says the app will try again at the next start.Code
UserSettings.historyRetentionDays+HISTORY_RETENTION_DAYSint key inuser_settings, read and written likeLEFT_BEHIND_AFTER_SECONDS(0 for "forever", since an int key can't hold null).LocationReportDao.deleteOlderThanExceptNewest(cutoff).HistoryPruner(interface) andLocationHistoryRetention(the real one), behindAppDependencies.historyPrunerso the Settings test can choose a period without deleting the history on whatever phone runs the suite.ui/settings/HistoryRetentionRow, in the same shape asUpdateSettingsRow. It sharesSettingsActivity'sUserSettingsobject, because the screen saves the whole object on other changes and a second copy would write the old period back.scripts/add_strings.py,--checkpasses. German and Dutch use the informal register as the rest of those files do. I placed them next to the left-behind strings rather than at the end of each file, so they don't collide with Delete a removed tag's keys, and offer to erase its history #315's additions there.Tests
db/repo/model/KeepingLocationHistoryTest(JVM): unset, zero and negative mean forever; each choice resolves to itself; unknown values round up, never down; cutoff maths, including "no cutoff" for forever.ui/settings/HistoryRetentionRowTest(JVM): which changes ask before deleting (any period from Forever, any shorter period) and which don't (longer, Forever); every choice has its own label, in order.db/repo/PruningOldLocationHistoryTest(in-memory Room, fixed clock): Forever deletes nothing; older reports go and newer stay; a tag keeps its newest however old; a tag with one old report keeps it; each tag is judged on its own newest and the map query still returns both; a report exactly at the cutoff stays; local and Google reports follow the same rule; fetch markers are untouched.ui/settings/HistoryRetentionSettingTest(Espresso, fake pruner,DeviceStateGuard): default subtitle is Forever; choosing a month asks; Cancel saves and deletes nothing; confirming deletes with 31 days, and the fake reads the stored period when it's called, so it fails if the delete started before the save landed; back to Forever and a longer period save without asking or deleting; a shorter period from a year asks again; a failed delete keeps the new period.Verified
:app:testDebugUnitTest(587 tests, 0 failures, 1 skipped),add_strings.py --check,check_java_imports.py.:app:lintDebugtotals are identical tomain(no new findings).DELETEquery at build time.Not verified
PruningOldLocationHistoryTestcovers, and with the default it returns before touching the database.VACUUMafter pruning, so deleted rows can stay in the database file's free pages until SQLite reuses them. Vacuuming on every start would rewrite the whole file each time. If Delete a removed tag's keys, and offer to erase its history #315 merges, its compaction could be run after an explicit change in Settings; I've left that out so this PR stands alone.Relationship
Part of #318 (the retention half of "Encrypt the key columns … and add a location-history retention setting"; encryption at rest will get its own issue first). parawanderer agreed to this follow-up on #315.
Branched from
mainand independent of #313, #315 and #320. #315 is still open and also touchesSettingsActivity,activity_settings.xml,AppDependenciesand all tenstrings.xml. I kept this PR's edits away from #315's hunks in those files, andgit merge-treemerges it cleanly with #315, #313 and #320 in either order.🤖 Generated with Claude Code