Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / findfamily / build.gradle.kts
build.gradle.kts174 lines · 9.3 KiBRaw
| 1 | plugins { |
| 2 | id("common-conventions-app") |
| 3 | // Listing screenshots come from Compose previews (src/screenshotTest), not from an |
| 4 | // instrumented test on a device. Same `:<module>:metadata` task name either way. |
| 5 | id("common-conventions-preview-metadata") |
| 6 | alias(libs.plugins.ksp) |
| 7 | } |
| 8 | |
| 9 | launcherIcon { |
| 10 | symbol = "moved_location" |
| 11 | } |
| 12 | |
| 13 | // Pixel Watch 5 is armeabi-v7a (32-bit) only: an arm64-only APK is rejected at install. |
| 14 | nativeAbis { |
| 15 | armv7 = true |
| 16 | } |
| 17 | |
| 18 | android { |
| 19 | defaultConfig { |
| 20 | applicationId = "com.vayunmathur.findfamily" |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | // Only the classes below actually load a native library: they execute a |
| 25 | // path that touches the Rust pairing/PQC crypto in :library:e2ee-p2p |
| 26 | // (libe2ee_pqc via Pqc / PqcIdentity, reached through Networking's |
| 27 | // generatePqc* / seal / sign / verify helpers, TrackerProtocol.sealReport, |
| 28 | // CreateLinkIntent's link keygen, or TrackerBinder's tracker keygen), or |
| 29 | // they call Networking.init / initDirectBoot, whose PqcIdentity.loadOrCreate |
| 30 | // mints the identity through the same JNI bridge on a fresh store. Tests |
| 31 | // that merely call the pure SecurityCode / InviteFingerprint helpers, use |
| 32 | // fake keypair mints (PoweredOffRecoveryTest), or hit the fail-closed |
| 33 | // no-session branches never load the library and stay in the main task. |
| 34 | // Quarantine the loaders and the shared-JVM polluters below into |
| 35 | // testDevUnitTestNative (forkEvery = 1); the remaining classes batch |
| 36 | // 20-per-JVM in testDevUnitTest, which depends on the quarantine task so |
| 37 | // the usual invocation still runs everything. |
| 38 | rustNativeTests { |
| 39 | nativeClasses.addAll( |
| 40 | listOf( |
| 41 | "com.vayunmathur.findfamily.Y3FinalReportTest", |
| 42 | "com.vayunmathur.findfamily.intents.AssistantIntentsRealRepoTest", |
| 43 | "com.vayunmathur.findfamily.platform.FixCeilingAlarmTest", |
| 44 | "com.vayunmathur.findfamily.platform.PoweredOffBeaconArmTest", |
| 45 | "com.vayunmathur.findfamily.platform.PoweredOffBeaconRealRepoTest", |
| 46 | "com.vayunmathur.findfamily.platform.UwbHandshakeSdk36Test", |
| 47 | "com.vayunmathur.findfamily.tracker.BleFailClosedTest", |
| 48 | "com.vayunmathur.findfamily.ui.MainPageChromeRealRepoTest", |
| 49 | "com.vayunmathur.findfamily.ui.dialogs.DialogsRealRepoInteractionsTest", |
| 50 | "com.vayunmathur.findfamily.util.CrowdFindingRealRepoTest", |
| 51 | "com.vayunmathur.findfamily.util.FindFamilyViewModelStatesRealTest", |
| 52 | "com.vayunmathur.findfamily.util.InboundEnrichRealRepoTest", |
| 53 | "com.vayunmathur.findfamily.util.LocationTrackingHeartbeatTest", |
| 54 | "com.vayunmathur.findfamily.util.NetworkingCodecTest", |
| 55 | "com.vayunmathur.findfamily.util.NetworkingDirectBootBootstrapTest", |
| 56 | "com.vayunmathur.findfamily.util.NetworkingDirectBootTest", |
| 57 | "com.vayunmathur.findfamily.util.NetworkingFramesRealRepoTest", |
| 58 | "com.vayunmathur.findfamily.util.NetworkingLiveSessionTest", |
| 59 | "com.vayunmathur.findfamily.util.NetworkingOfflineTest", |
| 60 | "com.vayunmathur.findfamily.util.NetworkingOutboundSpoolTest", |
| 61 | "com.vayunmathur.findfamily.util.NetworkingUwbAndBackupTest", |
| 62 | ) |
| 63 | ) |
| 64 | // Shared-JVM polluters keep forkEvery = 1 in the same companion task: |
| 65 | // DataStoreUtils is a process-wide singleton whose init eagerly |
| 66 | // collects the preferences DataStore, and FindFamilyViewModel turns |
| 67 | // its (and the repository's) flows into viewModelScope collectors |
| 68 | // (several SharingStarted.WhileSubscribed / Eagerly) that are never |
| 69 | // cleared when the test never calls onCleared; persisted DataStore |
| 70 | // state also leaks into classes expecting defaults. Same hazard for |
| 71 | // tests that drive the UwbSessionManager process-wide StateFlow |
| 72 | // singleton. Audit rule: any test instantiating FindFamilyViewModel |
| 73 | // (or launching MainActivity, which builds one), using |
| 74 | // DataStoreUtils.getInstance / a TrackerStore over it directly, or |
| 75 | // driving UwbSessionManager.init/start belongs here. The same rule |
| 76 | // covers indirect DataStore drivers: LocationServiceController's |
| 77 | // persisted flags are DataStoreUtils-backed, and its flow collectors |
| 78 | // leaked into a sibling class (UncaughtExceptionsBeforeTest) and its |
| 79 | // persisted flags broke the defaults-first assertions when |
| 80 | // PlatformServicesTest and MapAndControllerTest shared a JVM. |
| 81 | // The LocationTrackingService lifecycle drivers (Y3TrackingService / |
| 82 | // TrackingServiceLifecycle / LocationTrackingLifecycleReal) also |
| 83 | // belong here: startTracking/onStartCommand launch the service's |
| 84 | // scope loops, which outlive the sandbox that created them. Same |
| 85 | // evidence for LocationTrackingInboundTest: batched, its |
| 86 | // processIncomingLocations Dispatchers.IO enrich job outlived the |
| 87 | // test's closed in-memory Room database and surfaced as |
| 88 | // UncaughtExceptionsBeforeTest ("Database is closed" at |
| 89 | // FindFamilyRepository.updateLocationMeta) in whichever batched |
| 90 | // runTest class ran next in the JVM. All other classes batch. |
| 91 | isolatedClasses.addAll( |
| 92 | listOf( |
| 93 | "com.vayunmathur.findfamily.MainActivityRealLaunchTest", |
| 94 | "com.vayunmathur.findfamily.Y3TrackingServiceTest", |
| 95 | "com.vayunmathur.findfamily.platform.PlatformServicesTest", |
| 96 | "com.vayunmathur.findfamily.platform.UwbSessionManagerSdk36Test", |
| 97 | "com.vayunmathur.findfamily.service.TilesBootAndChannelsTest", |
| 98 | "com.vayunmathur.findfamily.ui.DialogsWithVmTest", |
| 99 | "com.vayunmathur.findfamily.ui.FirstRunSheetTest", |
| 100 | "com.vayunmathur.findfamily.ui.MainPageActionsRealRepoTest", |
| 101 | "com.vayunmathur.findfamily.ui.MainPageNavigationRealRepoTest", |
| 102 | "com.vayunmathur.findfamily.util.CrowdFindingAndControllerTest", |
| 103 | "com.vayunmathur.findfamily.util.DirectBootAndStoresRealTest", |
| 104 | "com.vayunmathur.findfamily.util.FindFamilyViewModelDbTest", |
| 105 | "com.vayunmathur.findfamily.util.FindFamilyViewModelProbeTest", |
| 106 | "com.vayunmathur.findfamily.util.FindFamilyViewModelRealRepoTest", |
| 107 | "com.vayunmathur.findfamily.util.LocationTrackingInboundTest", |
| 108 | "com.vayunmathur.findfamily.util.LocationTrackingLifecycleRealTest", |
| 109 | "com.vayunmathur.findfamily.util.MapAndControllerTest", |
| 110 | "com.vayunmathur.findfamily.util.PlatformAndUwbStateTest", |
| 111 | "com.vayunmathur.findfamily.util.TrackingServiceLifecycleTest", |
| 112 | "com.vayunmathur.findfamily.util.UwbSessionManagerRealRepoTest", |
| 113 | ) |
| 114 | ) |
| 115 | } |
| 116 | |
| 117 | dependencies { |
| 118 | |
| 119 | // HTTP + JSON |
| 120 | implementation(project(":library:network")) |
| 121 | implementation(project(":library:e2ee-p2p")) |
| 122 | |
| 123 | implementRoom(libs) |
| 124 | implementation(project(":library:room")) |
| 125 | |
| 126 | implementation(libs.androidx.work.runtime.ktx) |
| 127 | implementation(project(":library:work")) |
| 128 | testImplementation(libs.androidx.work.testing) |
| 129 | |
| 130 | implementation(project(":library:image")) |
| 131 | |
| 132 | implementation(project(":library:map")) |
| 133 | // Both sides of the Wear OS sync live in this one APK (same |
| 134 | // applicationId and signing, as the WearLink handshake requires): |
| 135 | // sync/WearFindFamilySync publishes the phone snapshot, sync/ |
| 136 | // WearLinkBridge receives it on a watch. FormFactor picks the side |
| 137 | // at runtime. |
| 138 | implementation(project(":library:wearlink")) |
| 139 | implementation(project(":library:weartiles")) |
| 140 | // Watch experience (ui/Wear*): Wear Compose for the watch screens. |
| 141 | implementation(libs.androidx.wear.compose.material) |
| 142 | implementation(libs.androidx.wear.compose.foundation) |
| 143 | // @SystemApi android.nearby.NearbyManager, for powered-off finding. Present at runtime, |
| 144 | // absent from the public SDK, and must NOT be packaged. See :library:aosp-stubs. |
| 145 | compileOnly(project(":library:aosp-stubs")) |
| 146 | } |
| 147 | |
| 148 | // The Compose screenshot renderer draws previews from the compiled `screenshotTest` classes |
| 149 | // directory (the renderer's screenshotProjectClassPath). JVM resources placed under |
| 150 | // src/screenshotTest/resources are NOT otherwise put on that classpath, so the metadata |
| 151 | // previews can't load the bundled CARTO map via getResourceAsStream. Stage those resources |
| 152 | // into the classes output so the previews can read them at render time. Because this asset |
| 153 | // lives only in the screenshotTest source set it ships in neither the dev nor the release APK. |
| 154 | val screenshotTestClasses = layout.buildDirectory.dir( |
| 155 | "intermediates/built_in_kotlinc/devScreenshotTest/compileDevScreenshotTestKotlin/classes" |
| 156 | ) |
| 157 | val stageDevScreenshotTestResources = tasks.register<Copy>("stageDevScreenshotTestResources") { |
| 158 | from(layout.projectDirectory.dir("src/screenshotTest/resources")) |
| 159 | into(screenshotTestClasses) |
| 160 | mustRunAfter("compileDevScreenshotTestKotlin") |
| 161 | outputs.upToDateWhen { false } |
| 162 | } |
| 163 | // `rustNativeTests` (above) makes RustNative's split register a |
| 164 | // `…Native` companion for every Test task — including the screenshot |
| 165 | // renderer's update/validate tasks — and both the renderer and its |
| 166 | // companion read the compiled classes dir this staging task writes into. |
| 167 | // Match by prefix so both the AGP tasks and their `Native` companions |
| 168 | // declare the dependency; naming only the two AGP tasks leaves the |
| 169 | // companions with an implicit-dependency validation failure. |
| 170 | tasks.matching { |
| 171 | it.name.startsWith("updateDevScreenshotTest") || it.name.startsWith("validateDevScreenshotTest") |
| 172 | }.configureEach { |
| 173 | dependsOn(stageDevScreenshotTestResources) |
| 174 | } |