T12-T14: platform liveness via geolocator; drop flutter_foreground_task

geolocator_android's ForegroundNotificationConfig raises a service with
foregroundServiceType=location and holds a wake lock for as long as the position
stream is subscribed, and the plugin declares that service in its own manifest.
That covers everything the native TrackingService used a foreground service and
a PARTIAL_WAKE_LOCK for, so flutter_foreground_task is gone -- and with it both
deprecation warnings that were recorded under T01.

Known parity gap for T27: geolocator's notification cannot carry actions, so the
native Pause/Resume buttons in the shade are not reproduced.

iOS: UIBackgroundModes plus allowBackgroundLocationUpdates keep the isolate and
the writer timer alive while updates flow. Two settings matter more than they
look -- pauseLocationUpdatesAutomatically is false because CoreLocation does not
reliably restart, and activityType is otherNavigation rather than
automotiveNavigation, which would snap fixes to the road network and silently
falsify the recorded path. Usage strings are specific, not generic.

Android deliberately does not request ACCESS_BACKGROUND_LOCATION: a foreground
service with a visible notification is exactly the supported case, and asking
would trigger the harder "Allow all the time" flow for no benefit.

T14 process-death resume is implemented and called at startup, covered by four
tests including the 111 km crash-gap guard.

Verified by building both platforms and launching on the iOS simulator: Drift
opened, Riverpod resolved, restore found no active trip, controls correct.
lib/main.dart is a harness so the pipeline can be exercised on hardware before
Phase 4 builds screens; T15 replaces it.

Phase 3 done: 145 tests passing, analyze clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-15 12:14:37 -05:00
parent 5a7c598610
commit ee3ef74331
10 changed files with 462 additions and 121 deletions

View File

@@ -1,6 +1,25 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Recording permissions. Mirrors the native app's manifest.
ACCESS_BACKGROUND_LOCATION is deliberately NOT requested. The ride is recorded by
a foreground service with a visible notification, which is exactly the case
Android intends foregroundServiceType="location" to cover. Asking for background
location as well would trigger the "Allow all the time" flow, which is a harder
permission to be granted and is not needed for pocket-to-stop recording. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.INTERNET"/>
<!-- GPS is the whole point; do not offer the app to devices without it. -->
<uses-feature android:name="android.hardware.location.gps" android:required="true"/>
<application
android:label="rippr"
android:label="Rippr"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity