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

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

build.gradle.kts175 lines · 9.5 KiBRaw
1plugins {
2 id("common-conventions-app")
3 // Listing images are hybrid. The viewfinder is the screen, and Layoutlib cannot
4 // open a camera, so the phone images are hand-captured on a real device and
5 // committed under metadata_data/photos/camera/phone/ (the release build picks
6 // them up into graphics/phone-screenshots). The wide *controls* layout is real
7 // preview-renderable UI, so src/screenshotTest captures it at expanded width
8 // into the large-tablet bucket; the collect task only replaces buckets a run
9 // rendered, so the hand-captured phone bucket survives `:camera:metadata`.
10 id("common-conventions-preview-metadata")
11}
12
13launcherIcon {
14 symbol = "photo_camera"
15}
16
17// Pixel Watch 5 is armeabi-v7a (32-bit) only: an arm64-only APK is rejected at install.
18nativeAbis {
19 armv7 = true
20}
21
22android {
23 defaultConfig {
24 applicationId = "com.vayunmathur.camera"
25 }
26 androidResources {
27 // *.maml are read straight out of the APK by the segmenters, so
28 // leave them uncompressed: fp16 weights barely deflate, and a compressed asset would
29 // have to be inflated into a heap buffer before it could be uploaded.
30 noCompress += "maml"
31 }
32}
33
34androidComponents {
35 onVariants { variant ->
36 variant.sources.jniLibs?.addStaticSourceDirectory(
37 layout.buildDirectory.dir("rustJniLibs").get().asFile.absolutePath
38 )
39 }
40}
41
42// Native panorama stitcher + night burst aligner (Rust). See camera/src/main/rust/.
43// camera_stitch also links vision_core (library/vision), and :library:ml's
44// modelrunner is in the graph too, so the host .so set is not just camera's own.
45// extraAbis: the .so must also load on the 32-bit Pixel Watch 5 (see nativeAbis above).
46rustNativeLib("camera_stitch", "camera", extraAbis = listOf("armeabi-v7a"))
47
48// Only the classes below actually load a native library: they call
49// StitchNative directly (the two host-.so tests), execute a path that
50// touches StitchNative.isAvailable (PanoramaEngine.startSweep/stitch,
51// NightCaptureEngine.merge), or construct a segmenter that loads
52// :library:ml's modelrunner (BokehAnalyzer -> SelfieSegmenter,
53// StillBokehRenderer -> ModnetSegmenter). Tests that merely call the pure
54// math helpers (NightCaptureEngine.mergeScaledDimensions,
55// GpuStitcher.parseEstimate, LumaPlaneMath) or the pure Camera2 driver
56// fakes under platform/camera2 never load either library and stay in the
57// main task. Quarantine the loaders and the shared-JVM polluters below
58// into testDevUnitTestNative (forkEvery = 1); the remaining classes batch
59// 20-per-JVM in testDevUnitTest, which depends on the quarantine task so
60// the usual invocation still runs everything.
61rustNativeTests {
62 nativeClasses.addAll(
63 listOf(
64 "com.vayunmathur.camera.platform.BokehAnalyzerMathTest",
65 "com.vayunmathur.camera.platform.BurstConvertExtraTest",
66 "com.vayunmathur.camera.platform.CameraControlsExtraTest",
67 "com.vayunmathur.camera.platform.CameraCovC2LogicTest",
68 "com.vayunmathur.camera.platform.CameraCovC2PanoramaSensorTest",
69 "com.vayunmathur.camera.platform.CameraCovW3Wave4Test",
70 "com.vayunmathur.camera.platform.CameraCovW3Wave8Test",
71 "com.vayunmathur.camera.platform.CameraCovX4SessionsTest",
72 "com.vayunmathur.camera.platform.LumaStatsNativeTest",
73 "com.vayunmathur.camera.platform.NightCaptureEngineMathTest",
74 "com.vayunmathur.camera.platform.PanoramaEngineExtraTest",
75 "com.vayunmathur.camera.platform.PanoramaSaveExtraTest",
76 "com.vayunmathur.camera.platform.PortraitBokehMathTest",
77 "com.vayunmathur.camera.platform.StillEncoderNativeTest",
78 "com.vayunmathur.camera.ui.CameraCovX4ComposeTest",
79 )
80 )
81 // Shared-JVM polluters keep forkEvery = 1 in the same companion task:
82 // CameraViewModel's init runs loadSettings() over the process-wide
83 // DataStoreUtils singleton and starts viewModelScope collectors
84 // (SharingStarted.Eagerly stateIn flows plus launch{} collectors)
85 // that are never cleared when the test never calls onCleared;
86 // persisted DataStore state also leaks into classes expecting
87 // defaults. Audit rule: any test instantiating CameraViewModel or
88 // launching MainActivity (which builds one), or using
89 // DataStoreUtils / the CameraSettings extensions directly, belongs
90 // here. All other classes batch.
91 isolatedClasses.addAll(
92 listOf(
93 "com.vayunmathur.camera.MainActivityExtraTest",
94 "com.vayunmathur.camera.data.SafPrepareExtraTest",
95 "com.vayunmathur.camera.platform.AeConvergenceGateTest",
96 "com.vayunmathur.camera.platform.CameraCovC2CapabilitiesTest",
97 "com.vayunmathur.camera.platform.CameraCovC2SessionsTest",
98 "com.vayunmathur.camera.platform.CameraCovW3MockSessionsTest",
99 "com.vayunmathur.camera.platform.CameraCovW3SessionsTest",
100 "com.vayunmathur.camera.platform.CameraCovW3Wave11Test",
101 "com.vayunmathur.camera.platform.CameraCovW3Wave3Test",
102 "com.vayunmathur.camera.platform.CameraCovW3Wave5Test",
103 "com.vayunmathur.camera.platform.CameraCovW3Wave6Test",
104 "com.vayunmathur.camera.platform.CameraCovW3Wave7Test",
105 "com.vayunmathur.camera.platform.CameraCovW3Wave9Test",
106 "com.vayunmathur.camera.platform.CameraCovX4CaptureTest",
107 "com.vayunmathur.camera.platform.CameraCovX4CharacteristicsTest",
108 "com.vayunmathur.camera.platform.CameraSessionBindRetryTest",
109 "com.vayunmathur.camera.platform.CameraSessionsExtraTest",
110 "com.vayunmathur.camera.platform.CameraSettingsExtraTest",
111 "com.vayunmathur.camera.platform.CameraViewModelLogicTest",
112 "com.vayunmathur.camera.platform.CaptureProcessingMathTest",
113 "com.vayunmathur.camera.platform.CaptureRoutingExtraTest",
114 "com.vayunmathur.camera.platform.ControlsRecordingExtraTest",
115 "com.vayunmathur.camera.platform.FinalCoverageExtraTest",
116 "com.vayunmathur.camera.platform.ManualControlsExtraTest",
117 "com.vayunmathur.camera.platform.ManualPreviewExposureTest",
118 "com.vayunmathur.camera.platform.MediaStoreSaverAndProcessingTest",
119 "com.vayunmathur.camera.platform.MotionPhotoCaptureStateTest",
120 "com.vayunmathur.camera.platform.NightCaptureRestoreTest",
121 "com.vayunmathur.camera.platform.NightLogicExtraTest",
122 "com.vayunmathur.camera.platform.NightSessionEntryExtraTest",
123 "com.vayunmathur.camera.platform.QuerySessionConfigExtraTest",
124 "com.vayunmathur.camera.platform.RecordingRebindDeferralTest",
125 "com.vayunmathur.camera.platform.Restore3AExtraTest",
126 "com.vayunmathur.camera.platform.SessionEntryPointsTest",
127 "com.vayunmathur.camera.platform.SessionLaddersExtraTest",
128 "com.vayunmathur.camera.platform.SingleCaptureNightTest",
129 "com.vayunmathur.camera.platform.SloMoLogicExtraTest",
130 "com.vayunmathur.camera.platform.ZoomStopLensSyncTest",
131 "com.vayunmathur.camera.platform.ZslGatingTest",
132 "com.vayunmathur.camera.ui.BottomControlsComposeExtraTest",
133 "com.vayunmathur.camera.ui.CameraBindFailedComposeTest",
134 "com.vayunmathur.camera.ui.CameraCovC2ScreenStatesTest",
135 "com.vayunmathur.camera.ui.CameraCovC2SettingsTest",
136 "com.vayunmathur.camera.ui.CameraCovW3ComposeTest",
137 "com.vayunmathur.camera.ui.CameraCovW3Wave6ComposeTest",
138 "com.vayunmathur.camera.ui.CameraScreenComposeTest",
139 "com.vayunmathur.camera.ui.CameraScreenModesComposeTest",
140 "com.vayunmathur.camera.ui.CameraSettingsPageComposeTest",
141 "com.vayunmathur.camera.ui.PreviewGalleryComposeExtraTest",
142 "com.vayunmathur.camera.ui.SettingsInteractionsComposeTest",
143 )
144 )
145}
146
147dependencies {
148 implementation(libs.androidx.exifinterface)
149 implementation(libs.zxing.core)
150 // On-device portrait segmentation and matting. MediaPipe Selfie Segmentation
151 // (Apache-2.0) for the preview plus MODNet photographic-portrait matting
152 // (Apache-2.0) for still capture, both on our own Vulkan compute runtime;
153 // see camera/src/main/assets/README.md.
154 //
155 // ncnn is gone from the whole tree, not just this app: `:translate` was the last consumer and
156 // it now runs SMaLL-100 on `:library:ml` too, so `libncnn_android.so` is in no APK here.
157 implementation(project(":library:ml"))
158 // Wear OS experience (live viewfinder + remote controls) lives in this
159 // one APK: phone side platform/WearCameraSync, watch side
160 // sync/WearLinkBridge + ui/Wear*, same applicationId and signing on
161 // both form factors; FEATURE_WATCH (platform/FormFactor)
162 // picks the side at runtime. Watch conduit client transport
163 // (WearLinkClientNode) with no Play services.
164 implementation(project(":library:wearlink"))
165 // Watch experience (ui/Wear*): Wear Compose + the repo log facade the
166 // watch sync code writes through.
167 implementation(libs.androidx.wear.compose.material)
168 implementation(libs.androidx.wear.compose.foundation)
169 implementation(project(":library:log"))
170 implementation(libs.kotlinx.coroutines.android)
171 // Mockito is already a cataloged test dep used the same way by
172 // sibling modules (e.g. :office): ContentResolver is final-method
173 // heavy, so null-stream failure paths are tested with a mock.
174 testImplementation(libs.mockito.core)
175}