Chicago Is Not Your Location
A fresh install of the Hello Weather Android app has a current-location row before it has a location. The row holds Chicago’s coordinates, 41.88 and -87.63, until the first real GPS fix replaces them. That seed keeps the database simple, because every row always has coordinates. In November it also put Chicago on a tester’s home screen, in a build that never reached production.
The privacy problem
A customer turned location access on by accident, turned it off again, and still saw their old place in the Locations list, with no way to remove it. They read it as a privacy problem, and they were right to.
On Android it was worse than the list. The current-location row kept its last fix after access was revoked. While that row was selected, the widgets, the ongoing notification, the daily report, and the rain and alerts worker kept sending those coordinates to our server every time they refreshed. Only the Forecast screen checked the permission. On iOS the old place stayed on the Locations row, and one flagged-off feature could still fetch it, but nothing in the shipping app was sending it.
The first fix was too big
The first approach added a permission check to each part of the app that reads the location: each widget, the notification, the workers, the radar. Each one then needed a new “location needed” state to show instead. Across both apps that came to about 500 added lines over eight PRs. Emulator and simulator QA on the stack confirmed it worked: no request for the old spot in any window where access was off.
It was too much code for the problem. The first Android PR in the stack merged, and the owner reverted it about half an hour later to regroup on something simpler. The other seven closed unmerged. The issue that followed ranked six simpler options by value for effort, with file and line numbers for each.
The simple fix: reset the row
The winner on Android was about 20 lines. When location access is revoked, Android kills the app’s process. So every widget and worker that runs afterward starts the process fresh, through the application’s onCreate. That’s the revoke callback Android doesn’t otherwise give you. One query puts the current-location row back to its fresh-install values, and it runs at startup whenever access is off:
@Query("UPDATE location SET latitude = 41.88, longitude = -87.63, city = 'Chicago', state = 'IL', address = NULL, name = NULL WHERE position = 0 AND (latitude != 41.88 OR longitude != -87.63)")
suspend fun resetGpsLocation()
override fun onCreate() {
initKoin()
val locationsDao by inject<LocationsDao>()
if (!locationAllowed(this)) runBlocking { locationsDao.resetGpsLocation() }
// ...the rest of startup
}
The runBlocking is there on purpose. The rest of the database setup runs in the background, and a worker restarted by the system could read the row before an async reset finished. The WHERE clause skips the write when the row already holds the seed. The PR said plainly what users would see: with access off and the current location selected, the widgets and notification would show Chicago, the same as a fresh install that never granted access. The iOS side was smaller. The Locations screen forgets the saved device location when it sees access is off, and the flagged-off feature stops fetching it.
Both merged the same day. The Android one went to Google Play’s internal test track first.
Then the widgets moved to Chicago
Someone on that internal build reported that their small widget no longer followed their position. It seemed to show the first saved place in their list instead. The first seeded saved city is also Chicago, so that’s what it looked like from outside.
The cause was the one-time permission. Android’s location prompt offers “Only this time,” and the system setting for it is “Ask every time.” With that choice, Android takes access back about a minute after the app leaves the screen. The next time a widget refreshed, the process started without access, the reset ran, and the widget drew Chicago. The issue for the reset had listed “Only this time” as a risk to check. Before the reset, those users’ widgets had kept refreshing their last real spot.
The agent reproduced it on the emulator. It set the location to Denver, chose “Only this time,” and confirmed the widgets showed Denver. Then it went home and waited about 60 seconds for Android to take access back, and forced the widget jobs to run. The widgets switched to Chicago.
Keeping a place and drawing a place
The fix brought back the same helper the first PR had added, the one the owner had reverted. This time it answers a different question:
// The GPS row is the seeded Chicago until a fix; keep the last real weather instead
fun locationUsable(location: Location, locationAllowed: Boolean): Boolean =
!location.isGpsLocation() || (locationAllowed && !location.atSeedSpot())
private fun Location.atSeedSpot() = latitude == 41.88 && longitude == -87.63
The reverted version only checked the permission. The new one also checks that the row holds a real fix and not the seed. When it isn’t usable, the four background readers skip their fetch. The widgets keep their last drawing, the notification stays as it was, and the alerts worker skips this run and books its next one. Nothing fetches Chicago. The reset stays, so the old spot is still not stored. iOS already behaved this way: its widget keeps the last cached weather when it can’t get a location.
The seed check matters even with access on. A fresh review found a gap: right after someone taps Allow, before the first fix arrives, a widget refresh would still have drawn Chicago and kept it once access lapsed. Checking for the seed closes that.
The two fixes look like they conflict, and they don’t. The reset answers “should we keep this place?” The answer is no, so the coordinates are gone. The helper answers “can we draw this place?” and the answer is “not if it’s a placeholder.” The first attempt mixed the two questions in one gate, which is part of why it touched so much code.
Results
- With location access off, no background work sends the old position, and the saved row no longer holds it.
- Widgets and the notification keep showing the last real place and weather, but stop refreshing until the app opens again. Before the reset they kept refreshing the last spot. We accepted that trade for privacy.
- Daily reports and rain and severe alerts are off while access is off, rather than sent for Chicago.
- The drawing has no age limit and no “this is old” marker, which matches iOS.
Lessons Learned
- A placeholder that looks like real data will be shown as real data. Give readers a way to tell them apart.
- Check every path through a permission prompt, including one-time grants that expire on their own.
- Keep “should we store this?” and “can we show this?” as separate checks.
- When a fix needs a gate in every consumer, look for one place every consumer passes through first.
- A reverted helper can be the right answer to a different question. Say which question in the PR.