Colota - Android GPS Location tracker
fix(permissions): keep every runtime prompt behind the location disclosure (#623)
Max Dietrich4de75715a130
diff --git a/apps/docs/docs/development/permissions.md b/apps/docs/docs/development/permissions.mdindex 275770cb..ee635165 100644--- a/apps/docs/docs/development/permissions.md+++ b/apps/docs/docs/development/permissions.md@@ -83,7 +83,7 @@ If tracking was active when the device was powered off, Colota automatically resandroid.permission.POST_NOTIFICATIONS```-On Android 13 and later, apps need this permission before they can show notifications. Colota asks for it but does not require it - tracking runs either way. Denying it hides the tracking notification, so you lose the live status and any alert when tracking stops.+On Android 13 and later, apps need this permission before they can show notifications. Colota asks for it but does not require it - tracking runs either way. Denying it hides the tracking notification, so you lose the live status and the tap-to-resume alert when Android kills tracking.### Local Network Accessdiff --git a/apps/mobile/src/components/ui/LocationDisclosureModal.tsx b/apps/mobile/src/components/ui/LocationDisclosureModal.tsxindex 3657110f..72da760c 100644--- a/apps/mobile/src/components/ui/LocationDisclosureModal.tsx+++ b/apps/mobile/src/components/ui/LocationDisclosureModal.tsx@@ -22,7 +22,8 @@ export function LocationDisclosureModal() {title="Location Data Collection"paragraphs={["Colota collects location data to enable GPS tracking and sending your position to your configured server, even when the app is closed or not in use.",- "This data is sent only to the server you set up. No data is shared with third parties."+ "This data is sent only to the server you set up. No data is shared with third parties.",+ "While tracking runs, a persistent notification shows its status. Battery optimization should be disabled for reliable background operation."]}confirmLabel="Agree"registerCallback={registerDisclosureCallback}diff --git a/apps/mobile/src/services/LocationServicePermission.ts b/apps/mobile/src/services/LocationServicePermission.tsindex bda875d0..ebc3375d 100644--- a/apps/mobile/src/services/LocationServicePermission.ts+++ b/apps/mobile/src/services/LocationServicePermission.ts@@ -83,11 +83,12 @@ export async function ensurePermissions(): Promise<boolean> {const result = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION)if (result !== PermissionsAndroid.RESULTS.GRANTED) return false}- }- // Notifications (Android 13+, non-blocking) - the app has no other way to ask- if (Platform.Version >= ANDROID_13 && !status.notifications) {- await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS)+ // Notifications (Android 13+, non-blocking). Kept inside the disclosure-gated block so every+ // runtime prompt is preceded by the disclosure; Android auto-denies re-asks after two denials anyway.+ if (Platform.Version >= ANDROID_13 && !status.notifications) {+ await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS)+ }}// Battery optimization exemption (optional)@@ -108,7 +109,7 @@ function fallbackDisclosure(): Promise<boolean> {return new Promise((resolve) => {Alert.alert("Location Data Collection",- "Colota collects location data to enable GPS tracking and sending your position to your configured server, even when the app is closed or not in use.\n\nNo data is shared with third parties.",+ "Colota collects location data in the background to enable continuous GPS tracking, recording your position history and uploading it to your own server, even when the app is closed or not in use.\n\nYour location is sent only to the server you configure. No data is shared with third parties.",[{ text: "Not Now", style: "cancel", onPress: () => resolve(false) },{ text: "Agree", onPress: () => resolve(true) }diff --git a/apps/mobile/src/services/__tests__/LocationServicePermission.test.ts b/apps/mobile/src/services/__tests__/LocationServicePermission.test.tsindex c18fa962..6cddb430 100644--- a/apps/mobile/src/services/__tests__/LocationServicePermission.test.ts+++ b/apps/mobile/src/services/__tests__/LocationServicePermission.test.ts@@ -90,7 +90,8 @@ describe("ensurePermissions", () => {expect(result).toBe(true)expect(disclosureSpy).not.toHaveBeenCalled()- expect(requestSpy).toHaveBeenCalledWith(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS)+ // No prompt without a disclosure before it: the notification ask only rides along with the location grants+ expect(requestSpy).not.toHaveBeenCalled()})it("starts tracking when notifications are denied even if the disclosure would be declined", async () => {diff --git a/fastlane/metadata/android/en-US/changelogs/47.txt b/fastlane/metadata/android/en-US/changelogs/47.txtnew file mode 100644index 00000000..726e3700--- /dev/null+++ b/fastlane/metadata/android/en-US/changelogs/47.txt@@ -0,0 +1,6 @@+- Map requests identify the app by name and version, never the device or user+- Tracking no longer refuses to start when notifications are turned off+- Geofence heartbeat keeps recording while the phone sleeps+- Tracking restarts itself when Android kills it in the background+- Notes saved on the map no longer disappear when you switch tabs+- Every permission prompt is preceded by the location disclosure