AGENTS.md — maps/ (':maps')
Scoped supplement. Global rules in root AGENTS.md apply. Stay inside maps/ + allowed shared modules. Do not root-scan.
Install: ./install maps (dev by default).
- Gradle: :maps / dir: maps/
- Package roots present: ui, data, domain, platform, service, intents, sync, util (single JNI-exception file)
- Entry files: MainActivity.kt (sole launcher; routes watches to WearMainActivity), Route.kt, Navigation.kt (
Route+Navigationin their own files beside it), ui/WearMainActivity.kt - Deps: :library:map, :library:image, :library:network, :library:downloadservice, :library:wearlink, :library:log, Wear Compose (material + foundation)
- Metadata: metadata_data/maps.md (present)
- Rust: yes / screenshotTest: yes
Overview
Purpose: A fast open-source map + navigation app on OpenStreetMap, with all routing on device. Internet only for new tiles, search, traffic, and transit delays. Key features:
- On-device routing (drive/walk/bike/transit) over a single packed
.mamapsarchive, downloaded once on first launch; viewed areas keep working offline - Turn-by-turn navigation with voice (TTS), lane guidance, speed-limit widget, and elevation; Android Auto via
platform/ - Place details, saved places, transit departure boards, Street View, parking, and POI search (offline index from the archive; ratings/review counts/summaries are archive-only,
poi_attrskeys 10-12) - Globe body switch (zoomed-out globe only, session-only): Earth vector basemap plus bundled raster globes for Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune and the Moon — colour mosaics for all, packed DEMs for Mercury/Mars/Moon, ring strips for Saturn/Uranus/Neptune; all baked offline (sources/licences in
planet-data/DATASETS.md, converterplanet-data/convert_planets.py), never fetched at runtime - Google is used for exactly two opt-in features (Settings → Google services): Street View and non-review place details (photos, hours, phone/website, popular times) via
GooglePoiDataSource. No Google search, traffic, POI discovery or reviews - Handles external
geo:/google.navigation:/ Google-Maps links from other apps
Architecture / data-flow: ui/ map surface + sheets over per-concern platform/ ViewModels (SelectedFeatureViewModel, MapsSearchViewModel, SavedPlacesViewModel, …) → data/ stores/parsers + data/OfflineRouter* routing against the memory-mapped archive; guidance runs in the service/NavigationService foreground service via NavigationSessionManager. onCreateBeforeContent: NetworkClient.init(FIRST_PARTY) → delete the legacy world_z0-6.pmtiles → route the cold-start deep link; Content() gates on the .mamaps download before the map renders. Entry points + reading order: Route (MapPage / SavedPlacesPage / SettingsPage / StreetView / Navigating + dialog destinations) → MainActivity.kt (handleIntent, navigateTo) → ui/MapPage.kt → platform/SelectedFeatureViewModel.kt → data/OfflineRouterRoadRoutes.kt.
One APK, two form factors (phone + watch)
This module is the single Maps APK for phones and watches: same applicationId = "com.vayunmathur.maps" and signing on both, as the WearLink handshake requires. The manifest deliberately declares no android.hardware.type.watch feature (required=true would block phones; required=false is disallowed for this feature), plus touchscreen not-required and com.google.android.wearable.standalone=false; distribution is sideload/F-Droid, not Play's watch channel, so the APK installs on phones and watches alike. platform/FormFactor.kt reads PackageManager.FEATURE_WATCH at runtime: MainActivity (the sole launcher entry) forwards watches to ui/WearMainActivity before any phone state loads; phones get the map UI. The phone sync (platform/WearMapsSync) gates on the same signal and never starts on a watch; the one manifest receiver, the conduit sync-trigger receiver (sync/ConduitSyncTriggerReceiver), invokes only that phone-gated sync, so it is inert on a watch.
Wear sync (Watch conduit client)
Protocol: shared wire types live in :library:wearlink at com.vayunmathur.library.wearlink.maps.WearMapsProtocol; the golden-JSON tests in this module pin the shared code's wire format.
- Region snapshot: conduit data item (
/maps/region, phone -> watch) — bounded, simplified, quantized vector geometry for the watch Canvas renderer; the watch carries no tile stack and no planet data - Route overlay: conduit data item (
/maps/route, phone -> watch);active=falseis the explicit clear when navigation ends - Position: conduit data item (
/maps/position, phone -> watch) - Watch state: conduit data item (
/maps/watch-state, watch -> phone) - Fresh region: conduit message (
/maps/request-region), watch -> phone - Transport: Watch conduit client — phone side
platform/WearMapsSync.ktand watch sidesync/WearLinkBridge.ktboth useWearLinkClientNode(Messenger to the Watch app'swatch_conduitservice, appIdmaps); this app owns no RFCOMM link and holds no Bluetooth permission for this channel, so neither entry activity prompts for Bluetooth. With the Watch app absent the node reportsNotInstalled/Unavailableand the sync stays idle; region and route republish on conduitConnected. The phone supplies the region and is the position source (its location manager / navigation session); the watch runs no GPS of its own. The phone republishes the region when the user nears the snapshot edge (hysteresis, 65% of radius); with the link down the watch renders the last region as-is (no live-data label is shown on the map-only screen). - Push triggers: the publish also runs on the phone Watch app's scheduled sync-trigger intent (
sync/ConduitSyncTriggerReceiver, exported only under theCONDUITsignature permission, invokingWearMapsSync.triggerPush()— no UI, no prompt). Data arriving while the receiving process is dead lands in the conduit host's persistent store and replays on registration.
Watch experience (in this module)
ui/WearMainActivity(aWearShellActivity,exported=false, no launcher filter) routesui/WearRouteto the rendered map only — no route-detail/saved screens, no phone-directed text, buttons or Open-on-phone action on the watch.- The watch renders one phone-supplied vector snapshot with a plain Canvas projection (
ui/WearMapCanvas.kt,domain/WearMapProjection.kt): no tile stack, no planet data, no native renderer (the arm64-onlylibmap_renderercannot load on 32-bit watch userspace), north-up. The canvas always draws (land, user puck, scale, north) even before the first snapshot arrives, and all stroke/dot sizes are dp-based. Saved places and the live route draw as map dots/line only. On conduit (re)connect the bridge asks the phone for a fresh region (WearLinkBridge) — a data-path trigger, not a user action. - Watch state persists in
data/WearMapsStore(wear-maps-*.json); the watch experience has no UI strings of its own. - Watch listing screenshots are the
group = "wear"previews insrc/screenshotTest/.../ui/WearMetadataPreviews.kt, collected by:maps:metadataintometadata_data/photos/maps/wear/; phone shots use thephonebucket.
Dialogs + screenshots: every dialog is a Route.…Dialog destination (DialogPage() entries in Navigation.kt, args in the route, stateless content under ui/dialogs/; hosts act on the ViewModels, the contact chooser returns its pick via the RESULT_CONTACT_ADDRESS_* result keys) — never show…/pending-target state in a screen. Each route has a deterministic capture in src/screenshotTest (<n>-<route-key>, group phone); StreetView is exempted in Route.kt (live Google panorama + GL sphere). Search is a sheet over the live map, so SearchSheet carries a SCAFFOLD SEARCH EXCEPTION. Gotchas:
- The
.mamapsgate hosts app start — the archive URL must be live before a version ships;adb pushthe file to sideload a locally built archive singleTopwarm-start geo/navigation links arrive viaonNewIntent, not a freshonCreate- The map itself never splits panes (list/detail metadata only for settings/saved); its expanded side panel is separate inside
MapPage util/now holds onlyOfflineRouter.kt(JNI package exception); car, cross-app clients and ViewModels all live in closed roots (platform/,intents/)
Key files
Root — entry + navigation
- com/vayunmathur/maps/MainActivity.kt — geo-link handling, archive gate
- com/vayunmathur/maps/Route.kt —
Routedestinations incl.…Dialogroutes - com/vayunmathur/maps/Navigation.kt —
MainNavigationentries (DialogPage()dialog hosts)
Watch experience (ui/ + platform/ + data/ + domain/ + sync/)
- com/vayunmathur/maps/ui/WearMainActivity.kt — watch entry (WearShellActivity)
- com/vayunmathur/maps/ui/WearRoute.kt, WearMapScreen.kt, WearMapCanvas.kt
- com/vayunmathur/maps/platform/FormFactor.kt — watch detection (
FEATURE_WATCH) - com/vayunmathur/maps/platform/WearMapsSync.kt — phone conduit client node; region/route/position publish, request-region handling (gated to phones)
- com/vayunmathur/maps/sync/WearLinkBridge.kt — watch conduit client node; region/route/position receive into the store, watch-state publish
- com/vayunmathur/maps/data/WearMapsStore.kt — persisted watch region/route/position
- com/vayunmathur/maps/domain/WearMapProjection.kt — north-up Canvas projection + route/saved helpers
platform/ — Android Auto surface
- com/vayunmathur/maps/platform/MapsCarAppService.kt
- com/vayunmathur/maps/platform/MapsSession.kt
- com/vayunmathur/maps/platform/NavMapScreen.kt
- com/vayunmathur/maps/platform/CarMapRenderer.kt
- com/vayunmathur/maps/platform/CarManeuvers.kt
- com/vayunmathur/maps/platform/CarSearchScreen.kt
data/ — prefs, places, POI + transit sources
- com/vayunmathur/maps/data/MapPreferences.kt
- com/vayunmathur/maps/data/MapLinkParser.kt — external geo/maps URL parsing
- com/vayunmathur/maps/data/GeoJson.kt
- com/vayunmathur/maps/data/SpecificFeature.kt
- com/vayunmathur/maps/data/OpeningHours.kt
- com/vayunmathur/maps/data/OsmMaxspeed.kt
- com/vayunmathur/maps/data/SavedPlace.kt
- com/vayunmathur/maps/data/SavedPlaceStore.kt
- com/vayunmathur/maps/data/RecentSearchStore.kt
- com/vayunmathur/maps/data/ParkingStore.kt
- com/vayunmathur/maps/data/google/GooglePoiDataSource.kt — Google place details (photos/hours/phone; no ratings/reviews)
- com/vayunmathur/maps/data/google/GooglePoiModels.kt
- com/vayunmathur/maps/data/PoiPin.kt — offline map POI pin
- com/vayunmathur/maps/data/google/GoogleResponse.kt
- com/vayunmathur/maps/data/google/StreetViewDataSource.kt
- com/vayunmathur/maps/data/google/StreetViewModels.kt
- com/vayunmathur/maps/data/transit/TransitousDataSource.kt
- com/vayunmathur/maps/data/transit/TransitousModels.kt
intents/ — assistant IPC
- com/vayunmathur/maps/intents/DirectionsIntent.kt
- com/vayunmathur/maps/intents/SearchPlacesIntent.kt — OpenAssistant
maps_search_places: offline POI text search (optional near/category), provider-clamped to ≤10 rows, name/address ≤120 chars; coordinates chain into directions/taxi tools - com/vayunmathur/maps/intents/SavedPlacesIntent.kt — OpenAssistant
maps_get_saved_places: saved (starred + listed) places, summaries only (name + coordinates), ≤10 rows
intents/ — cross-app estimate/lookup clients
- com/vayunmathur/maps/intents/RideEstimateClient.kt — launches taxi intents
- com/vayunmathur/maps/intents/OrderLookupClient.kt — launches fooddelivery intents
- com/vayunmathur/maps/intents/FamilyLocationClient.kt
- com/vayunmathur/maps/intents/FamilyLocationProtocol.kt
- com/vayunmathur/maps/intents/IntentLaunch.kt
ui/ — pages, sheets, layers
- com/vayunmathur/maps/ui/MapPage.kt
- com/vayunmathur/maps/ui/MapPageScope.kt
- com/vayunmathur/maps/ui/MapContentBox.kt
- com/vayunmathur/maps/ui/MapSearchActions.kt
- com/vayunmathur/maps/ui/MapSheets.kt
- com/vayunmathur/maps/ui/MapSheetEffects.kt
- com/vayunmathur/maps/ui/MapSidePanel.kt
- com/vayunmathur/maps/ui/MapWideHost.kt
- com/vayunmathur/maps/ui/MapWideLayout.kt
- com/vayunmathur/maps/ui/BottomSheetContent.kt
- com/vayunmathur/maps/ui/BottomSheetHeader.kt
- com/vayunmathur/maps/ui/SearchSheet.kt
- com/vayunmathur/maps/ui/PlaceSheet.kt
- com/vayunmathur/maps/ui/PlaceSheetHeader.kt
- com/vayunmathur/maps/ui/PlaceSheetHours.kt
- com/vayunmathur/maps/ui/PlaceActionRow.kt
- com/vayunmathur/maps/ui/ContactAddressButton.kt
- com/vayunmathur/maps/ui/MapContactAddressEffects.kt — consent route push + contact chooser result delivery
- com/vayunmathur/maps/ui/dialogs/ — stateless dialog contents + route hosts (Google consent, contact chooser, end-trip, saved-places rename/create/add-to-list, shared text entry)
- com/vayunmathur/maps/ui/SearchResultLayer.kt
- com/vayunmathur/maps/ui/RouteSheet.kt
- com/vayunmathur/maps/ui/RouteSheetTabs.kt
- com/vayunmathur/maps/ui/TripSheet.kt
- com/vayunmathur/maps/ui/NavigationOverlay.kt
- com/vayunmathur/maps/ui/DeparturesSheet.kt
- com/vayunmathur/maps/ui/DepartureTime.kt
- com/vayunmathur/maps/ui/CategoryChips.kt
- com/vayunmathur/maps/ui/LayersButton.kt
- com/vayunmathur/maps/ui/LayersSheet.kt
- com/vayunmathur/maps/ui/CompassButton.kt
- com/vayunmathur/maps/ui/MapScaleBar.kt
- com/vayunmathur/maps/ui/VoiceSearchButton.kt
- com/vayunmathur/maps/ui/SavedPlacesPage.kt
- com/vayunmathur/maps/ui/SavedPlacesLayer.kt
- com/vayunmathur/maps/ui/FamilyLocationLayer.kt
- com/vayunmathur/maps/ui/ParkingLayer.kt
- com/vayunmathur/maps/ui/ParkingSheet.kt
- com/vayunmathur/maps/ui/RoadsLayer.kt
- com/vayunmathur/maps/ui/SafetyLayer.kt
- com/vayunmathur/maps/ui/SatelliteLayer.kt
- com/vayunmathur/maps/ui/TransitStopsLayer.kt
- com/vayunmathur/maps/ui/PoiEnrichment.kt
- com/vayunmathur/maps/ui/RestaurantItem.kt
- com/vayunmathur/maps/ui/LineBadge.kt
- com/vayunmathur/maps/ui/ManeuverIcon.kt
ui/map/ — surface, camera, overlays
- com/vayunmathur/maps/ui/map/MapSurface.kt
- com/vayunmathur/maps/ui/map/MapSurfaceHelpers.kt
- com/vayunmathur/maps/ui/map/MapCamera.kt
- com/vayunmathur/maps/ui/map/MapChrome.kt
- com/vayunmathur/maps/ui/map/MapChromeState.kt
- com/vayunmathur/maps/ui/map/MapFabStack.kt
- com/vayunmathur/maps/ui/map/MapLayers.kt
- com/vayunmathur/maps/ui/map/MapOverlays.kt
- com/vayunmathur/maps/ui/map/MapFeaturePicker.kt
- com/vayunmathur/maps/ui/map/MapPinFeatures.kt
- com/vayunmathur/maps/ui/map/RouteOverlayBuilder.kt
- com/vayunmathur/maps/ui/map/RailLines.kt
- com/vayunmathur/maps/ui/map/TransitVehicles.kt
- com/vayunmathur/maps/ui/map/TrafficPrefetchEffect.kt
- com/vayunmathur/maps/ui/map/WaypointList.kt
ui/nav/ — guidance widgets
- com/vayunmathur/maps/ui/nav/ManeuverBanner.kt
- com/vayunmathur/maps/ui/nav/LaneGuidance.kt
- com/vayunmathur/maps/ui/nav/SpeedWidget.kt
- com/vayunmathur/maps/ui/nav/RouteShield.kt
- com/vayunmathur/maps/ui/nav/ArrivalSummary.kt
- com/vayunmathur/maps/ui/nav/StepsSheet.kt
- com/vayunmathur/maps/ui/nav/ElevationChart.kt
ui/streetview/ + ui/settings/ + ui/theme/
- com/vayunmathur/maps/ui/streetview/StreetViewScreen.kt
- com/vayunmathur/maps/ui/streetview/StreetViewPegman.kt
- com/vayunmathur/maps/ui/streetview/StreetViewArrows.kt
- com/vayunmathur/maps/ui/settings/MapSettingsPage.kt
- com/vayunmathur/maps/ui/theme/MapTokens.kt
- com/vayunmathur/maps/ui/theme/BasemapPalette.kt
- com/vayunmathur/maps/ui/theme/MapChromeMetrics.kt
platform/ + data/ + domain/ + service/ — ViewModels, offline router, navigation service
- com/vayunmathur/maps/platform/BodyAssetLoader.kt — per-body bundled raster specs + loader (assets/<body>/)
- com/vayunmathur/maps/platform/SelectedFeatureViewModel.kt
- com/vayunmathur/maps/platform/MapsSearchViewModel.kt
- com/vayunmathur/maps/platform/MapsUiContract.kt
- com/vayunmathur/maps/platform/SavedPlacesViewModel.kt
- com/vayunmathur/maps/platform/MapSettingsViewModel.kt
- com/vayunmathur/maps/platform/PlacePanelState.kt
- com/vayunmathur/maps/platform/PoiMapViewModel.kt — map POI pins from the offline index
- com/vayunmathur/maps/platform/TransitStopsViewModel.kt
- com/vayunmathur/maps/domain/TransitClock.kt
- com/vayunmathur/maps/platform/ParkingViewModel.kt
- com/vayunmathur/maps/data/MapTileCache.kt —
.mamapsarchive access - com/vayunmathur/maps/util/OfflineRouter.kt
- com/vayunmathur/maps/data/OfflineRouterRoadRoutes.kt
- com/vayunmathur/maps/data/OfflineRouterRouteBuilder.kt
- com/vayunmathur/maps/data/OfflineRouterTraffic.kt
- com/vayunmathur/maps/data/OfflineRouterTransit.kt
- com/vayunmathur/maps/domain/RouteService.kt
- com/vayunmathur/maps/service/NavigationService.kt — foreground guidance service
- com/vayunmathur/maps/platform/NavigationSessionManager.kt
- com/vayunmathur/maps/platform/NavigationTts.kt
- com/vayunmathur/maps/domain/PolylineProgress.kt
- com/vayunmathur/maps/data/GTFSProvider.kt
- com/vayunmathur/maps/data/PoiIndex.kt
- com/vayunmathur/maps/data/PoiIndexAttrs.kt
- com/vayunmathur/maps/data/PoiIndexSpatial.kt
- com/vayunmathur/maps/data/PoiIndexWords.kt
- com/vayunmathur/maps/data/PoiIndexRegion.kt —
poi_region(kind 15) boundary links - com/vayunmathur/maps/data/PoiIndexAdmin.kt —
poi_admin(kind 16) hierarchy; search-row locality ("City, State, Country") - com/vayunmathur/maps/data/PoiSearchEngine.kt — indexed name search (ordinal scans + grid join, blended text/distance rank)
- com/vayunmathur/maps/data/PoiSearchHits.kt — ordinal hit table for the search engine
- com/vayunmathur/maps/data/PoiArchive.kt — POI sections out of the archive (per-section mmaps; planet is ~80 GB)
- com/vayunmathur/maps/data/PoiCategories.kt
- com/vayunmathur/maps/domain/SpatialKey.kt
- com/vayunmathur/maps/platform/RegionalUnits.kt
- com/vayunmathur/maps/domain/ItineraryWording.kt
- com/vayunmathur/maps/domain/CameraBounds.kt
- com/vayunmathur/maps/platform/ContactLookup.kt
- com/vayunmathur/maps/platform/FrameworkLocationManager.kt
Verify (this module only)
./gradlew :maps:compileDevKotlin
./gradlew :maps:lint
./gradlew :maps:checkMetadata