Modern Apps git

← Modern-Apps.git

maps: guard offline-router native load; lazy saved places

Commit
e3a4b040da6df3cceddd055a48fc0b3fdb101bfd
Author
Vayun Mathur <[email protected]>
When
2026-11-20 19:04 UTC (15 days ago)
Parents
13ad167
Three fixes:

OfflineRouter loaded its native library unguarded in init
(System.loadLibrary + tile server start), so a missing .so
threw ExceptionInInitializerError and poisoned the class for
the process - and several callers caught only Exception, which
Errors escape anyway. The load now lives in the single
platform/OfflineRouterNative wrapper via NativeLoader
(available flag, never throws); the tile server starts lazily
and explicitly after a successful graph init; routing, transit
and traffic entry points degrade to null/empty when the native
side is unavailable. Two host tests encoded the old init
behaviour and were corrected to the equivalent new API.

SavedPlacesPage composed the whole saved list eagerly in a
scrolling Column; it is now one LazyColumn with keyed items for
saved places, list headers and members. SearchSheet's result
and recents lists were unbounded inside the free-height sheet;
they now take the weight(1f) the root Column intended.

Verified: :maps:testDevUnitTest 1199 tests, 0 failures
(incl. saved-places and search-sheet suites).

Diff

maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterLifecycle.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterLifecycle.kt b/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterLifecycle.ktindex 8b697006b8..e52ad60f7f 100644--- a/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterLifecycle.kt+++ b/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterLifecycle.kt@@ -28,12 +28,20 @@ internal object OfflineRouterLifecycle {     @Synchronized     fun initialize(context: Context) {         if (isInitialized) return+        if (!com.vayunmathur.maps.platform.OfflineRouterNative.available) {+            isInitialized = false+            return+        }         val path = context.getExternalFilesDir(null)?.absolutePath ?: return         OfflineRouter.basePath = path         Log.debug("OfflineRouter", "Initializing with path: $path")          isInitialized = OfflineRouter.initGraph(path)         Log.debug("OfflineRouter", "Initialization result: $isInitialized")+        if (isInitialized) {+            // Explicit, lazy tile-server start: only once the graph is usable.+            OfflineRouterTraffic.ensureTileServerStarted()+        }     }      /**
maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterRoadRoutes.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterRoadRoutes.kt b/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterRoadRoutes.ktindex 48c5ac16f3..4584cbe391 100644--- a/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterRoadRoutes.kt+++ b/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterRoadRoutes.kt@@ -74,7 +74,8 @@ internal object OfflineRouterRoadRoutes {         for (i in 0 until positions.size - 1) {             val leg = try {                 OfflineRouter.getRoute(context, positions[i], positions[i + 1], type)-            } catch (_: Exception) {+            } catch (_: Throwable) {+                // Includes LinkageError if the native lib vanished: no routing, no crash.                 return null             }             legs.add(leg)
maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterTraffic.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterTraffic.kt b/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterTraffic.ktindex b98d14467f..c0837e8895 100644--- a/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterTraffic.kt+++ b/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterTraffic.kt@@ -128,12 +128,16 @@ internal object OfflineRouterTraffic {      /**      * Loopback-only tile server for `/traffic/{z}/{x}/{y}`, extracted from-     * [OfflineRouter] to keep that file under the length limit. Started once-     * from [OfflineRouter]'s init; the tile bytes still come from-     * [OfflineRouter.getTrafficTileNative].+     * [OfflineRouter] to keep that file under the length limit. Started lazily+     * and explicitly via [ensureTileServerStarted] once the graph is up — never+     * from class init — so a missing native library or a bind failure degrades+     * to "no traffic tiles" instead of poisoning routing. Tile bytes still come+     * from [OfflineRouter.getTrafficTileNative].      */     private var serverPort = 0 +    @Volatile private var tileServerStarted = false+     /** Socket read timeout (ms) so a half-open client cannot hold a worker forever. */     private const val CLIENT_SO_TIMEOUT_MS = 5_000     /** Minimal HTTP request line (`GET /path`). */@@ -150,7 +154,19 @@ internal object OfflineRouterTraffic {             "Access-Control-Allow-Origin: *\r\n\r\n"     private const val NO_CONTENT = "HTTP/1.1 204 No Content\r\n\r\n" -    internal fun startLocalTileServer() {+    /**+     * Start the loopback tile server once, if the native router is usable.+     * Idempotent and failure-tolerant: any failure leaves [tileServerStarted]+     * false and is only logged, so traffic tiles degrade to empty responses+     * rather than crashing routing.+     */+    internal fun ensureTileServerStarted() {+        if (tileServerStarted) return+        if (!com.vayunmathur.maps.platform.OfflineRouterNative.available) return+        synchronized(this) {+            if (tileServerStarted) return+            tileServerStarted = true+        }         Thread {             try {                 // Bind to loopback ONLY. The previous `ServerSocket(0)` defaulted@@ -168,8 +184,9 @@ internal object OfflineRouterTraffic {                     runCatching { client.soTimeout = CLIENT_SO_TIMEOUT_MS }                     pool.execute { handleClient(client) }                 }-            } catch (e: java.io.IOException) {-                Log.error("OFFLINE_ROUTER", "Tile server error", e)+            } catch (e: Throwable) {+                tileServerStarted = false+                runCatching { Log.error("OFFLINE_ROUTER", "Tile server error", e) }             }         }.start()     }@@ -197,7 +214,15 @@ internal object OfflineRouterTraffic {         val x = pathParts[1].toIntOrNull() ?: 0         val y = pathParts[2].substringBefore("?").toIntOrNull() ?: 0 -        val bytes = OfflineRouter.getTrafficTileNative(z, x, y)+        val bytes = if (com.vayunmathur.maps.platform.OfflineRouterNative.available) {+            try {+                OfflineRouter.getTrafficTileNative(z, x, y)+            } catch (_: Throwable) {+                null+            }+        } else {+            null+        }         val output = client.getOutputStream()         if (bytes != null) {             output.write(OK_HEADERS.replace("{len}", bytes.size.toString()).toByteArray())
maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterTransit.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterTransit.kt b/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterTransit.ktindex 4ecdb11cc8..a0f19e82b6 100644--- a/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterTransit.kt+++ b/maps/src/main/java/com/vayunmathur/maps/data/OfflineRouterTransit.kt@@ -149,6 +149,7 @@ internal object OfflineRouterTransit {             end: GeoPoint,             departureOffsetSecs: Int,     ): RouteService.Route? = withContext(Dispatchers.Default) {+        if (!com.vayunmathur.maps.platform.OfflineRouterNative.available) return@withContext null         val base = OfflineRouterLifecycle.transitBase(context) ?: return@withContext null         val feeds = transitFeeds(base)         if (feeds.isEmpty()) return@withContext null@@ -204,7 +205,7 @@ internal object OfflineRouterTransit {                 clock.prevWeekday, clock.prevDate,                 overlay.coords, overlay.routes, overlay.times             )-        } catch (_: Exception) {+        } catch (_: Throwable) {             null         }     }@@ -266,6 +267,7 @@ internal object OfflineRouterTransit {             lat: Double,             lon: Double,     ): TransitStop? = withContext(Dispatchers.Default) {+        if (!com.vayunmathur.maps.platform.OfflineRouterNative.available) return@withContext null         val base = OfflineRouterLifecycle.transitBase(context) ?: return@withContext null         val feeds = transitFeeds(base)         for (feed in feeds) {@@ -297,6 +299,7 @@ internal object OfflineRouterTransit {             maxLat: Double,             maxLon: Double,     ): List<OfflineRouter.Vehicle> = withContext(Dispatchers.Default) {+        if (!com.vayunmathur.maps.platform.OfflineRouterNative.available) return@withContext emptyList()         val base = OfflineRouterLifecycle.transitBase(context) ?: return@withContext emptyList()         val feeds = transitFeeds(base)         if (feeds.isEmpty()) return@withContext emptyList()@@ -334,7 +337,7 @@ internal object OfflineRouterTransit {                 overlay.coords, overlay.routes, overlay.times,                 minLat, minLon, maxLat, maxLon             )-        } catch (_: Exception) {+        } catch (_: Throwable) {             null         } ?: return emptyList()         // TEMP-DIAG-A (light-rail icon): histogram the raw GTFS@@ -393,7 +396,7 @@ internal object OfflineRouterTransit {             OfflineRouter.getRailLinesNative(                 base, feed, minLat, minLon, maxLat, maxLon             )-        } catch (_: Exception) {+        } catch (_: Throwable) {             null         } ?: return emptyList()         return rawLinesToRailLines(raw)@@ -425,7 +428,7 @@ internal object OfflineRouterTransit {     private fun stopLinesForFeed(base: String, feed: String, lat: Double, lon: Double): List<RailLine> {         val raw = try {             OfflineRouter.getStopLinesNative(base, feed, lat, lon)-        } catch (_: Exception) {+        } catch (_: Throwable) {             null         } ?: return emptyList()         return rawLinesToRailLines(raw)@@ -682,7 +685,7 @@ internal object OfflineRouterTransit {                 clock.prevWeekday, clock.prevDate,                 overlay.coords, overlay.routes, overlay.times, max             )-        } catch (_: Exception) {+        } catch (_: Throwable) {             null         }     }
maps/src/main/java/com/vayunmathur/maps/data/TransitItineraries.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/data/TransitItineraries.kt b/maps/src/main/java/com/vayunmathur/maps/data/TransitItineraries.ktindex 7b241d0115..9b9930201a 100644--- a/maps/src/main/java/com/vayunmathur/maps/data/TransitItineraries.kt+++ b/maps/src/main/java/com/vayunmathur/maps/data/TransitItineraries.kt@@ -28,7 +28,7 @@ internal object TransitItineraries {                 clock.prevWeekday, clock.prevDate,                 overlay.coords, overlay.routes, overlay.times             )-        } catch (_: Exception) {+        } catch (_: Throwable) {             null         }     }
maps/src/main/java/com/vayunmathur/maps/platform/OfflineRouterNative.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/platform/OfflineRouterNative.kt b/maps/src/main/java/com/vayunmathur/maps/platform/OfflineRouterNative.ktnew file mode 100644index 0000000000..68907b23bd--- /dev/null+++ b/maps/src/main/java/com/vayunmathur/maps/platform/OfflineRouterNative.kt@@ -0,0 +1,19 @@+package com.vayunmathur.maps.platform++import com.vayunmathur.library.log.NativeLoader++/**+ * The single guarded loader for `libofflinerouter.so` (docs/package-structure.md §4.4).+ *+ * [OfflineRouter][com.vayunmathur.maps.util.OfflineRouter] keeps the JNI-frozen+ * surface — native code resolves its members by class and name — but it must never+ * load the library itself: an unguarded `init { System.loadLibrary(...) }` poisons+ * the class with [ExceptionInInitializerError] on every later touch when the `.so`+ * is absent (wrong ABI, failed Rust build). Every caller instead checks [available]+ * here and degrades to "no routing" when it is false.+ */+object OfflineRouterNative {++    /** Whether `libofflinerouter.so` loaded and the JNI surface is usable. */+    val available: Boolean = NativeLoader.load("offlinerouter", "OfflineRouterNative")+}
maps/src/main/java/com/vayunmathur/maps/ui/SavedPlacesPage.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/SavedPlacesPage.kt b/maps/src/main/java/com/vayunmathur/maps/ui/SavedPlacesPage.ktindex c0e04a40d0..78ba482cb1 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/SavedPlacesPage.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/SavedPlacesPage.kt@@ -4,8 +4,8 @@ import com.vayunmathur.maps.data.string import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.rememberScrollState-import androidx.compose.foundation.verticalScroll+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.items import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue@@ -60,21 +60,29 @@ fun SavedPlacesPage(backStack: NavBackStack<Route>, viewModel: SavedPlacesViewMo         title = stringResource(R.string.saved_places_title),         backStack = backStack,     ) { padding ->-        Column(+        // One bounded LazyColumn for the whole page: section headers and the+        // "new list" row are single items, the flat saved places and every+        // named list's members are lazy items with stable keys, so a long+        // library scrolls without composing every row. fillMaxSize keeps the+        // height bounded (required for lazy measurement, incl. in tests).+        LazyColumn(             Modifier                 .fillMaxSize()-                .padding(padding)-                .verticalScroll(rememberScrollState()),+                .padding(padding),         ) {             // --- Flat saved list ----            SettingsSection(title = stringResource(UiR.string.saved)) {-                if (saved.isEmpty()) {+            item(key = "saved-header") {+                SettingsSection(title = stringResource(UiR.string.saved)) {}+            }+            if (saved.isEmpty()) {+                item(key = "saved-empty") {                     SettingsRow(                         title = stringResource(R.string.saved_list_empty),                         enabled = false,                     )                 }-                saved.forEach { place ->+            } else {+                items(saved, key = { place -> "saved/${place.name}/${place.lat}/${place.lon}" }) { place ->                     SavedPlaceRow(                         place = place,                         onRename = { renameTarget = place },@@ -85,13 +93,18 @@ fun SavedPlacesPage(backStack: NavBackStack<Route>, viewModel: SavedPlacesViewMo             }              // --- Named lists ----            SettingsSection(title = stringResource(R.string.saved_lists_header)) {+            item(key = "lists-header") {+                SettingsSection(title = stringResource(R.string.saved_lists_header)) {}+            }+            item(key = "lists-new") {                 SettingsRow(                     title = stringResource(R.string.saved_lists_new),                     leadingContent = { IconAdd() },                     onClick = { showCreateList = true },                 )-                lists.forEach { (name, places) ->+            }+            lists.forEach { (name, places) ->+                item(key = "list/$name") {                     SettingsRow(                         title = name,                         supportingText = androidx.compose.ui.res.pluralStringResource(@@ -102,16 +115,16 @@ fun SavedPlacesPage(backStack: NavBackStack<Route>, viewModel: SavedPlacesViewMo                             IconButton(onClick = { viewModel.deleteList(name) }) { IconDelete() }                         },                     )-                    places.forEach { place ->-                        SettingsRow(-                            title = place.name,-                            modifier = Modifier.padding(start = 16.dp),-                            leadingContent = { IconStar() },-                            trailingContent = {-                                IconButton(onClick = { viewModel.removeFromList(name, place) }) { IconClose() }-                            },-                        )-                    }+                }+                items(places, key = { place -> "member/$name/${place.name}/${place.lat}/${place.lon}" }) { place ->+                    SettingsRow(+                        title = place.name,+                        modifier = Modifier.padding(start = 16.dp),+                        leadingContent = { IconStar() },+                        trailingContent = {+                            IconButton(onClick = { viewModel.removeFromList(name, place) }) { IconClose() }+                        },+                    )                 }             }         }
maps/src/main/java/com/vayunmathur/maps/ui/SearchSheet.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/SearchSheet.kt b/maps/src/main/java/com/vayunmathur/maps/ui/SearchSheet.ktindex 129aaddd9b..b85de275d8 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/SearchSheet.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/SearchSheet.kt@@ -90,8 +90,8 @@ fun SearchSheet(                 title = stringResource(R.string.no_results_found),                 modifier = Modifier.height(StatusBlockHeight),             )-            SearchPhase.Results -> ResultsList(state.results, actions, state.nearLat, state.nearLon)-            SearchPhase.Recents -> RecentsList(state.recents, actions)+            SearchPhase.Results -> ResultsList(state.results, actions, state.nearLat, state.nearLon, Modifier.weight(1f))+            SearchPhase.Recents -> RecentsList(state.recents, actions, Modifier.weight(1f))             SearchPhase.Idle -> Box(                 Modifier.fillMaxWidth().height(StatusBlockHeight),                 Alignment.Center,@@ -157,8 +157,9 @@ private fun ResultsList(     actions: SearchActions,     nearLat: Double = 0.0,     nearLon: Double = 0.0,+    modifier: Modifier = Modifier, ) {-    LazyColumn(Modifier.fillMaxWidth()) {+    LazyColumn(modifier.fillMaxWidth()) {         items(results, key = { it.id }) { result ->             val distanceText = if (nearLat != 0.0 || nearLon != 0.0) {                 com.vayunmathur.maps.platform.formatDistance(@@ -213,8 +214,8 @@ private fun ResultsList( }  @Composable-private fun RecentsList(recents: List<String>, actions: SearchActions) {-    LazyColumn(Modifier.fillMaxWidth()) {+private fun RecentsList(recents: List<String>, actions: SearchActions, modifier: Modifier = Modifier) {+    LazyColumn(modifier.fillMaxWidth()) {         item {             Row(                 modifier = Modifier
maps/src/main/java/com/vayunmathur/maps/ui/map/MapSurfaceHelpers.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/map/MapSurfaceHelpers.kt b/maps/src/main/java/com/vayunmathur/maps/ui/map/MapSurfaceHelpers.ktindex 8f916f2b79..16008d1cff 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/map/MapSurfaceHelpers.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/map/MapSurfaceHelpers.kt@@ -78,6 +78,7 @@ internal const val TRAFFIC_MAX_SQUARES = 16L  * enumerated.  */ internal fun prefetchTrafficSquares(bounds: GeoBounds) {+    if (!com.vayunmathur.maps.platform.OfflineRouterNative.available) return     val lonMin = floor(bounds.west).toInt()     val lonMax = floor(bounds.east).toInt()     val latMin = floor(bounds.south).toInt()@@ -86,7 +87,12 @@ internal fun prefetchTrafficSquares(bounds: GeoBounds) {     if (cells < 1L || cells > TRAFFIC_MAX_SQUARES) return     for (lat in latMin..latMax) {         for (lon in lonMin..lonMax) {-            OfflineRouter.ensureTrafficLoadedNative(lat + 0.5, lon + 0.5, true)+            try {+                OfflineRouter.ensureTrafficLoadedNative(lat + 0.5, lon + 0.5, true)+            } catch (_: Throwable) {+                // Native unavailable: traffic prefetch degrades to no-op.+                return+            }         }     } }
maps/src/main/java/com/vayunmathur/maps/util/OfflineRouter.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/util/OfflineRouter.kt b/maps/src/main/java/com/vayunmathur/maps/util/OfflineRouter.ktindex c5445b4bb2..0fc290d262 100644--- a/maps/src/main/java/com/vayunmathur/maps/util/OfflineRouter.kt+++ b/maps/src/main/java/com/vayunmathur/maps/util/OfflineRouter.kt@@ -29,10 +29,10 @@ import com.vayunmathur.library.map.GeoPoint  * [OfflineRouterRouteBuilder] (native steps → [RouteService.Route]).  */ object OfflineRouter {-    init {-        System.loadLibrary("offlinerouter")-        OfflineRouterTraffic.startLocalTileServer()-    }+    // No init-time load: the library is loaded once, guarded, by+    // OfflineRouterNative (platform/). Touching this object must never throw+    // ExceptionInInitializerError — callers check OfflineRouterNative.available+    // and degrade to no-routing when the .so is missing.      /** At least an origin and a destination for a multi-waypoint route. */     private const val MIN_ROUTE_POSITIONS = 2@@ -40,7 +40,14 @@ object OfflineRouter {     private external fun init(basePath: String): Boolean      /** Invoker so [OfflineRouterLifecycle] can init without touching JNI visibility. */-    internal fun initGraph(basePath: String): Boolean = init(basePath)+    internal fun initGraph(basePath: String): Boolean {+        if (!com.vayunmathur.maps.platform.OfflineRouterNative.available) return false+        return try {+            init(basePath)+        } catch (_: Throwable) {+            false+        }+    }     private external fun findRouteNative(             sLat: Double,             sLon: Double,@@ -281,11 +288,21 @@ object OfflineRouter {     }      internal fun updateTraffic(edgeIds: LongArray, speeds: ByteArray, packedSquare: Int) {-        updateTrafficNative(edgeIds, speeds, packedSquare)+        if (!com.vayunmathur.maps.platform.OfflineRouterNative.available) return+        try {+            updateTrafficNative(edgeIds, speeds, packedSquare)+        } catch (_: Throwable) {+            // Native unavailable mid-session: drop the update, never crash.+        }     }      internal fun finishTrafficFetch(packedSquare: Int) {-        notifyTrafficFetchFinishedNative(packedSquare)+        if (!com.vayunmathur.maps.platform.OfflineRouterNative.available) return+        try {+            notifyTrafficFetchFinishedNative(packedSquare)+        } catch (_: Throwable) {+            // See updateTraffic.+        }     }      /** Type representing raw step. */@@ -472,6 +489,9 @@ object OfflineRouter {         mode: RouteService.TravelMode,     ): RouteService.Route =         withContext(Dispatchers.Default) {+            if (!com.vayunmathur.maps.platform.OfflineRouterNative.available) {+                throw IllegalStateException("Offline router unavailable")+            }             Log.dev("OfflineRouter", "getRoute: mode=$mode, start=$start, end=$end")             if (!OfflineRouterLifecycle.isInitialized) {                 OfflineRouterLifecycle.initialize(context)@@ -479,14 +499,17 @@ object OfflineRouter {             Log.debug("OfflineRouter", "isInitialized=${OfflineRouterLifecycle.isInitialized}")              val rawSteps =-                findRouteNative(-                    start.latitude,-                    start.longitude,-                    end.latitude,-                    end.longitude,-                    mode.ordinal-                )-                    ?: throw IllegalStateException("No route found")+                try {+                    findRouteNative(+                        start.latitude,+                        start.longitude,+                        end.latitude,+                        end.longitude,+                        mode.ordinal+                    )+                } catch (_: Throwable) {+                    null+                } ?: throw IllegalStateException("No route found")              buildRoute(context, rawSteps, mode)         }
maps/src/test/java/com/vayunmathur/maps/util/MapsTrafficServerC5Test.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/util/MapsTrafficServerC5Test.kt b/maps/src/test/java/com/vayunmathur/maps/util/MapsTrafficServerC5Test.ktindex bd09fb3e5a..4679233105 100644--- a/maps/src/test/java/com/vayunmathur/maps/util/MapsTrafficServerC5Test.kt+++ b/maps/src/test/java/com/vayunmathur/maps/util/MapsTrafficServerC5Test.kt@@ -32,7 +32,7 @@ class MapsTrafficServerC5Test {     @BeforeTest     fun startServer() {         if (port() == 0) {-            OfflineRouterTraffic.startLocalTileServer()+            OfflineRouterTraffic.ensureTileServerStarted()             // The listener binds on its own thread.             repeat(100) {                 if (port() != 0) return
maps/src/test/java/com/vayunmathur/maps/util/OfflineRouterTransitSlice3ExtraTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/util/OfflineRouterTransitSlice3ExtraTest.kt b/maps/src/test/java/com/vayunmathur/maps/util/OfflineRouterTransitSlice3ExtraTest.ktindex 48d29211ce..6c6d3446e4 100644--- a/maps/src/test/java/com/vayunmathur/maps/util/OfflineRouterTransitSlice3ExtraTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/util/OfflineRouterTransitSlice3ExtraTest.kt@@ -30,12 +30,9 @@ class OfflineRouterTransitSlice3ExtraTest {      private val ctx: Context get() = ApplicationProvider.getApplicationContext() -    private fun nativeAvailable(): Boolean = try {-        // Loading the object runs its System.loadLibrary init.-        @Suppress("UNUSED_EXPRESSION")-        OfflineRouter.basePath-        true-    } catch (_: Throwable) { false }+    private fun nativeAvailable(): Boolean =+        // Touching OfflineRouter no longer loads anything; availability is the guarded wrapper's answer.+        com.vayunmathur.maps.platform.OfflineRouterNative.available      @Test fun gtfsRouteTypeModes() {         // Pure mapping, independent of the native pack