fix(android): auto-request media location so GPS survives upload #1389

Merged
chris merged 1 commit from fix/android-media-location-request into main 2026-10-25 20:05:51 +01:00
Owner

Problem\nUploaded images lost their GPS EXIF when ACCESS_MEDIA_LOCATION was never granted: MediaStore.setRequireOriginal (AndroidMediaStoreScanner) then returns redacted bytes. The permission existed as an optional wizard card, but was only requested on an explicit tap — skip it and GPS was silently stripped forever.\n\n## Fix\nAll paths now auto-fire the location request through one shared gate (autoRequestLocationIfEligible() in BackupPermissions.kt):\n- wizard entry when media access is already granted (once, ask-once respected)\n- chained after a full media grant result (both wizard and backup tab)\n- retry path ensureMediaPermissions() no longer strands a missing location\n- backup tab startup chain unchanged (deduplicated onto the shared gate)\n\nSeparate launcher design kept (OEM auto-denial avoidance). Card stays optional/denyable — the change only guarantees the user is asked.\n\n## Verification\n./gradlew :app:testDebugUnitTest :core:test :app:assembleDebug → BUILD SUCCESSFUL (app 826 tests, core 176 tests, 0 failures; BackupPermissionsTest 108 cases across SDK 25/29/33 incl. 14 new auto-ask cases).

## Problem\nUploaded images lost their GPS EXIF when `ACCESS_MEDIA_LOCATION` was never granted: `MediaStore.setRequireOriginal` (AndroidMediaStoreScanner) then returns redacted bytes. The permission existed as an optional wizard card, but was only requested on an explicit tap — skip it and GPS was silently stripped forever.\n\n## Fix\nAll paths now auto-fire the location request through one shared gate (`autoRequestLocationIfEligible()` in BackupPermissions.kt):\n- wizard entry when media access is already granted (once, ask-once respected)\n- chained after a full media grant result (both wizard and backup tab)\n- retry path `ensureMediaPermissions()` no longer strands a missing location\n- backup tab startup chain unchanged (deduplicated onto the shared gate)\n\nSeparate launcher design kept (OEM auto-denial avoidance). Card stays optional/denyable — the change only guarantees the user is asked.\n\n## Verification\n`./gradlew :app:testDebugUnitTest :core:test :app:assembleDebug` → BUILD SUCCESSFUL (app 826 tests, core 176 tests, 0 failures; BackupPermissionsTest 108 cases across SDK 25/29/33 incl. 14 new auto-ask cases).
fix(android): auto-request media location so GPS survives upload
All checks were successful
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build Android CI image (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Deploy review instance (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 10s
Build and Deploy / Android unit tests and debug APK (push) Successful in 4m36s
90a07e7feb
User report: uploaded images lost their GPS EXIF because ACCESS_MEDIA_LOCATION
was only ever requested from an explicit wizard card tap — the optional card
nobody taps. Without the grant the scanner cannot mark its Uri with
MediaStore.setRequireOriginal, so originals come back redacted and the GPS
EXIF is stripped on upload.

All automatic location asks now funnel through one shared gate,
BackupPermissionState.autoRequestLocationIfEligible (ask-once, Q+ only,
media reads granted, grant not already held), reached from every path where
the earlier steps have settled: the startup chain, a full media grant result
(payload stays the authority there — pre-refactor behavior), the retry path
(ensureMediaPermissions now recovers a never-asked location too), and the
wizard's first composition via rememberBackupPermissionState's manual-mode
LaunchedEffect. The separate location launcher is untouched (OEM
auto-denial), the card stays optional/denyable, and an explicit Allow still
bypasses the ask-once flag.
chris merged commit 8d52aef81d into main 2026-10-25 20:05:51 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
chris/memories!1389
No description provided.