Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
main ▾

Modern-Apps.git / networklocation / build.gradle.kts

build.gradle.kts79 lines · 3.8 KiBRaw
1plugins {
2 id("common-conventions-app")
3 // Listing screenshots come from Compose previews (src/screenshotTest), not from an
4 // instrumented test on a device. Same `:networklocation:metadata` task name either way.
5 id("common-conventions-preview-metadata")
6}
7
8launcherIcon {
9 symbol = "my_location"
10}
11
12android {
13 defaultConfig {
14 applicationId = "com.vayunmathur.networklocation"
15 }
16}
17
18androidComponents {
19 onVariants { variant ->
20 variant.sources.jniLibs?.addStaticSourceDirectory(
21 layout.buildDirectory.dir("rustJniLibs").get().asFile.absolutePath
22 )
23 }
24}
25
26// Native code for this module, loaded as libnetworklocation.so: RANSAC + EM multilateration
27// device-position estimation over the resolved beacon fixes, AND the offline geocoder
28// search over geocoder.db. Both live in networklocation/src/main/rust/.
29rustNativeLib("networklocation")
30
31// Only the classes below actually load libnetworklocation: they call
32// the *Native bridges directly, or drive OfflineBeaconStore /
33// GeocodeService / LocationReportingTask, which open and query through
34// WpsStoreNative / GeocoderNative / NetworkLocationNative (touching a
35// bridge's `available` already loads the library). Pure key/position
36// math, feed, provider-contract and compose tests never touch a bridge
37// and stay in the main task. Quarantine the loaders into
38// testDevUnitTestNative (forkEvery = 1); the remaining classes batch
39// 20-per-JVM in testDevUnitTest, which depends on the quarantine task so
40// the usual invocation still runs everything. No isolatedClasses: this
41// module has no ViewModel and no DataStore owner (OfflineDatabases is
42// plain files, and every test installs/clears them itself), so no
43// shared-JVM polluters exist here.
44rustNativeTests {
45 nativeClasses.addAll(
46 listOf(
47 "com.vayunmathur.networklocation.GeocodeServiceTest",
48 "com.vayunmathur.networklocation.NativeBridgesTest",
49 "com.vayunmathur.networklocation.provider.LocationReportingTaskTest",
50 "com.vayunmathur.networklocation.provider.OfflineBeaconStoreTest",
51 )
52 )
53}
54
55// The offline databases (geocoder.db, wifi.wpsdb up to ~2 GB, cells.wpsdb far
56// smaller) are NOT bundled. Shipping them as assets put a 3.5 GB APK in the MAOS system image,
57// which pushed the factory install zip past fastboot's 4 GiB zip limit. They are downloaded to
58// device-protected storage on request instead — see OfflineDatabases.kt. Until they arrive every
59// lookup misses, which the readers already treat as "no data": beacons stay unresolved and no
60// position is reported, and the geocoder reports itself unavailable.
61
62dependencies {
63 // Compile-only stubs for the framework's unbundled provider API (com.android.location.provider).
64 // Provided at runtime by <uses-library>; must NOT be packaged.
65 compileOnly(project(":library:locationprovider"))
66 // Reporting loop + IO for the offline database fetch.
67 implementation(libs.kotlinx.coroutines.android)
68 // Resumable, checksummed, unmetered-only fetch of the offline databases, which are no
69 // longer bundled (see OfflineDatabases). Also supplies the progress UI on the status screen.
70 implementation(project(":library:downloadservice"))
71 // The provider stubs are compile-only in production (the framework supplies them
72 // at runtime), but unit tests exercise GeocodeService's provider callbacks on the
73 // JVM, so the stub signatures must be on the test runtime classpath too.
74 testImplementation(project(":library:locationprovider"))
75 // For initializing WorkManager when a test taps the offline-database download button.
76 testImplementation(libs.androidx.work.runtime.ktx)
77 // The offline geocoder search runs natively (Rust/ruzstd) over geocoder.db; there is no
78 // Kotlin-side DB code, so no zstd-jni / serialization deps are needed here.
79}