Modern Apps git

← Modern-Apps.git

fix build errors, warnings, and lints

Commit
e1b86f950bc8484c90ae8357b9b77e97e90faa9d
Author
vayun-mathur <[email protected]>
When
2026-10-06 21:05 UTC (2 months ago)
Parents
b031c8c

Diff

appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.ktindex e76493ccda..1453660859 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.kt@@ -176,15 +176,13 @@ object FDroidRepository {         r.endObject()     } -    companion object {-        private const val PACKAGES_KEY = "packages"-        private const val CONNECT_TIMEOUT_MS = 30000-        private const val READ_TIMEOUT_MS = 120000-        private const val DOWNLOAD_BUFFER_SIZE = 32 * 1024-        private const val HTTP_OK_MIN = 200-        private const val HTTP_OK_MAX = 299-        private const val USER_AGENT = "ModernAppStore/1.0"-    }+    private const val PACKAGES_KEY = "packages"+    private const val CONNECT_TIMEOUT_MS = 30000+    private const val READ_TIMEOUT_MS = 120000+    private const val DOWNLOAD_BUFFER_SIZE = 32 * 1024+    private const val HTTP_OK_MIN = 200+    private const val HTTP_OK_MAX = 299+    private const val USER_AGENT = "ModernAppStore/1.0"      private class PackageBuilder {         var metaName: String? = null
appstore/src/main/java/com/vayunmathur/appstore/data/security/ApkCertificates.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/security/ApkCertificates.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/security/ApkCertificates.ktindex 4197b99d03..82599575cc 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/security/ApkCertificates.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/security/ApkCertificates.kt@@ -140,11 +140,9 @@ object ApkCertificates {      private fun ByteArray.toHex(): String = joinToString("") { "%02x".format(it) } -    private companion object {-        private const val SHA256_HEX_LEN = 64-        private const val SHA256_BYTES = 32-        private const val HASH_BUFFER_SIZE = 64 * 1024-        private const val HEX_PAIR_LEN = 2-        private const val ABBREVIATED_PAIRS = 8-    }+    private const val SHA256_HEX_LEN = 64+    private const val SHA256_BYTES = 32+    private const val HASH_BUFFER_SIZE = 64 * 1024+    private const val HEX_PAIR_LEN = 2+    private const val ABBREVIATED_PAIRS = 8 }
appstore/src/main/java/com/vayunmathur/appstore/data/security/TrustProfile.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/security/TrustProfile.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/security/TrustProfile.ktindex 13ccf140ae..be31a8f90b 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/security/TrustProfile.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/security/TrustProfile.kt@@ -100,10 +100,10 @@ enum class TrustProfile {     val title: Int         get() = when (this) {             MODERN_APPS -> R.string.trust_modern_apps_title-            FDROID -> R.string.trust_fdroid_title-            GRAPHENEOS -> R.string.trust_grapheneos_title+            FDROID -> R.string.source_chip_fdroid+            GRAPHENEOS -> R.string.source_chip_grapheneos             PLAY -> R.string.trust_play_title-            ACCRESCENT -> R.string.trust_accrescent_title+            ACCRESCENT -> R.string.source_chip_accrescent         }      /** One line, shown under the heading on the app's page. */
appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailSections.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailSections.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailSections.ktindex fb20942623..c7d235e4e5 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailSections.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailSections.kt@@ -14,6 +14,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import com.vayunmathur.appstore.R+import com.vayunmathur.library.ui.R as UiR import com.vayunmathur.appstore.data.AppSource import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.appstore.data.installer.InstallStage@@ -67,7 +68,7 @@ internal fun AppInstallActions(                         Text(stringResource(R.string.action_update))                     }                     FilledTonalButton(onClick = { actions.openApp(app.packageName) }) {-                        Text(stringResource(R.string.open))+                        Text(stringResource(UiR.string.open))                     }                 } @@ -76,7 +77,7 @@ internal fun AppInstallActions(                         onClick = { actions.openApp(app.packageName) },                         modifier = Modifier.weight(1f),                     ) {-                        Text(stringResource(R.string.open))+                        Text(stringResource(UiR.string.open))                     }                     OutlinedButton(onClick = onUninstall) { IconDelete() }                 }
appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.ktindex 9d6438c93e..97566b4b5a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt@@ -284,7 +284,7 @@ private fun CategoryRow(             FilterChip(                 selected = selected == null,                 onClick = { onSelect(null) },-                label = { Text(stringResource(R.string.category_all)) },+                label = { Text(stringResource(R.string.filter_all)) },             )         }         items(categories, key = { it }) { category ->
appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.ktindex 51d015902b..af5d723624 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.kt@@ -76,7 +76,7 @@ fun SourcesPage(             ) {                 Text(                     stringResource(-                        if (home.isSyncing) R.string.repos_syncing+                        if (home.isSyncing) R.string.sync_in_progress                         else R.string.repos_sync_sources                     )                 )@@ -119,7 +119,7 @@ fun SourcesPage(             onEnabledChange = { viewModel.setSourceEnabled(AppSource.MODERN_APPS, it) },         )         SourceCard(-            title = stringResource(R.string.source_fdroid),+            title = stringResource(R.string.source_chip_fdroid),             subtitle = DefaultRepos.FDROID.url,             pinLabel = stringResource(R.string.source_fdroid_pin),             pins = setOfNotNull(@@ -139,7 +139,7 @@ fun SourcesPage(             onEnabledChange = { viewModel.setSourceEnabled(AppSource.PLAYSTORE, it) },         )         SourceCard(-            title = stringResource(R.string.source_accrescent),+            title = stringResource(R.string.source_chip_accrescent),             subtitle = AccrescentRepo.REPOSITORY_URL,             pinLabel = stringResource(R.string.source_accrescent_pin),             pins = setOf(AccrescentRepo.REPODATA_PUBKEY),
appstore/src/main/java/com/vayunmathur/appstore/ui/TrustPage.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/TrustPage.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/TrustPage.ktindex 5f4d0be627..daa424c924 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/TrustPage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/TrustPage.kt@@ -155,6 +155,13 @@ private fun ProfileCard(profile: TrustProfile) {                 style = MaterialTheme.typography.bodySmall,                 color = MaterialTheme.colorScheme.onSurfaceVariant,             )+            if (profile != TrustProfile.PLAY) {+                Text(+                    stringResource(R.string.trust_no_takedown),+                    style = MaterialTheme.typography.bodySmall,+                    color = MaterialTheme.colorScheme.onSurfaceVariant,+                )+            }         }     } }
appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.ktindex 6511a2ed2d..ee6cde1290 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.kt@@ -102,7 +102,7 @@ internal fun AppStoreViewModel.updateAllImpl() {                 statusMessageFlow.value = context.getString(                     R.string.updates_progress, app.name, index + 1, batch.size                 )-                if (run.record(installer.install(app))) break+                if (run.record(this@updateAllImpl, installer.install(app))) break             }             // PackageInstaller commits asynchronously, so the last app's real verdict             // is still on its way. Wait for it before summarising, or it lands on its@@ -146,14 +146,14 @@ private class UpdateRun {      * Records one install outcome. Returns true when the run should stop:      * the same reason has failed [REPEATED_FAILURE_LIMIT] times in a row.      */-    fun AppStoreViewModel.record(outcome: com.vayunmathur.appstore.data.installer.SessionInstaller.Outcome): Boolean {+    fun record(viewModel: AppStoreViewModel, outcome: com.vayunmathur.appstore.data.installer.SessionInstaller.Outcome): Boolean {         if (outcome.started) {             started++             previousReason = null             repeats = 0             return false         }-        val failure = reason(outcome.verification)+        val failure = viewModel.reason(outcome.verification)         failures += failure         repeats = if (failure == previousReason) repeats + 1 else 1         previousReason = failure
appstore/src/main/res/values/strings.xml
diff --git a/appstore/src/main/res/values/strings.xml b/appstore/src/main/res/values/strings.xmlindex 6452165adf..077a2e51d1 100644--- a/appstore/src/main/res/values/strings.xml+++ b/appstore/src/main/res/values/strings.xml@@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <resources>     <string name="app_name">App Store</string>-    <string name="open">Open</string>     <string name="uninstall">Uninstall</string>     <string name="view_in_play_store">View in Play Store</string>     <string name="installed">Installed</string>@@ -11,7 +10,7 @@     <string name="last_sync">Last sync: %1$s</string>     <string name="repositories">Sources</string>     <!-- Sources page, under the title. Explains that the list is fixed but each entry can be switched off. -->-    <string name="sources_are_fixed">These sources are built in and no others can be added — other F-Droid repos just hand out binaries someone else built, so there is nothing to check them against. Switch off any you do not want the store to use.</string>+    <string name="sources_are_fixed">Built-in sources only; no others can be added. Other repos hand out unchecked binaries someone else built. Switch off any you do not use.</string>     <!-- Sources page, warning shown when the user has switched every source off. -->     <string name="sources_all_disabled">Every source is switched off, so there is nothing to browse, search or update from.</string> @@ -29,7 +28,6 @@     <string name="source_chip_accrescent">Accrescent</string>     <string name="filter_all">All</string>     <string name="filter_with_count">%1$s (%2$d)</string>-    <string name="category_all">All</string>      <!-- Home. -->     <string name="section_modern_apps">From Modern Apps</string>@@ -78,11 +76,11 @@     <string name="updates_checking">Checking for updates…</string>     <string name="updates_last_checked">Last checked %1$s</string>     <string name="updates_notification_body">Open the App Store to review and install them.</string>-    <string name="updates_confirm_notification_body">Android only lets the App Store update apps it installed itself, so these need a tap from you. Open the App Store to install them.</string>+    <string name="updates_confirm_notification_body">Android only lets the store update apps it installed, so these need your tap. Open the App Store to install them.</string>     <string name="updates_channel_name">App updates</string>     <string name="updates_channel_description">Tells you when apps you installed here have a newer version.</string>     <string name="setting_auto_install_updates_title">Automatically install updates</string>-    <string name="setting_auto_install_updates_summary">Install updates as soon as they are found, with no tap. When off, updates wait until you tap Update. Either way apps this store installed update without asking each time; anything else just notifies you.</string>+    <string name="setting_auto_install_updates_summary">When on, updates install when found. When off, they wait for a tap. Store-installed apps update silently; the rest just notify.</string>     <plurals name="updates_count">         <item quantity="one">%1$d update available</item>         <item quantity="other">%1$d updates available</item>@@ -189,6 +187,9 @@     <string name="trust_own_key_detail">Modern Apps downloads have to be signed by this key. It is read off your phone at install time, so it is always the key this copy of the store was really signed with.</string>     <string name="trust_own_key_unreadable">Couldn\'t read this app\'s signing key.</string> +    <!-- Shared clause factored out of the per-source limits strings below. -->+    <string name="trust_no_takedown">There is no way to pull a bad release off phones that already took it.</string>+     <string name="trust_modern_apps_title" translatable="false">Modern Apps</string>     <string name="trust_modern_apps_summary">Built in the same repo as this store and signed with the same key, which your phone can check against the copy of the store you are holding.</string>     <string name="trust_modern_apps_practice_open">All of it is open source, in one public repository</string>@@ -196,9 +197,8 @@     <string name="trust_modern_apps_check_index_signed">The repository index is signed and checked against this store\'s own pinned key</string>     <string name="trust_modern_apps_check_key">Signed by this app\'s own key, read straight from your phone at install time</string>     <string name="trust_modern_apps_check_hash">The file matches the hash in the repository\'s signed index</string>-    <string name="trust_modern_apps_limits">One developer, one key, no independent review and nobody rebuilding the source to confirm the app matches it. There is no scanning and no way to pull a bad release off phones that already took it.</string>+    <string name="trust_modern_apps_limits">One developer, one key, no independent review and nobody rebuilding the source to confirm the app matches it. There is no scanning.</string> -    <string name="trust_fdroid_title">F-Droid</string>     <string name="trust_fdroid_summary">Built from public source code. Versions a second machine independently rebuilt to an identical file are badged as reproducible.</string>     <string name="trust_fdroid_practice_source">Every app is built from source F-Droid publishes, not from a binary a developer sent in</string>     <string name="trust_fdroid_practice_rebuild">A second build server rebuilds many apps and compares the result byte for byte</string>@@ -207,8 +207,7 @@     <string name="trust_fdroid_check_chained">Every entry in that list is chained back to the signature</string>     <string name="trust_fdroid_check_rebuilt">Versions F-Droid\'s second build server reproduced bit-for-bit are badged as reproducible</string>     <string name="trust_fdroid_check_hash_and_key">The hash and the signing key both come from the signed list</string>-    <string name="trust_fdroid_limits">F-Droid holds the signing key, not the developer, so its build servers can sign anything. Nobody checks what an app does, only that it matches its source. Updates wait to be rebuilt, which can take days or weeks - security fixes included - and there is no way to pull a bad app back off phones.</string>-    <string name="trust_grapheneos_title">GrapheneOS</string>+    <string name="trust_fdroid_limits">F-Droid holds the signing key, not the developer, so its build servers can sign anything. Nobody checks what an app does, only that it matches its source. Updates wait to be rebuilt, which can take days or weeks, security fixes included.</string>     <string name="trust_grapheneos_summary">Google\'s own signed builds of the Sandboxed Google Play components, re-hosted by GrapheneOS behind a signed list naming each file\'s hash and signing key.</string>     <string name="trust_grapheneos_practice_official">The files are Google\'s own signed builds, re-hosted unchanged rather than rebuilt</string>     <string name="trust_grapheneos_practice_signed_index">GrapheneOS signs the list of versions, file hashes and expected signing keys with its release key</string>@@ -216,7 +215,7 @@     <string name="trust_grapheneos_check_index_signed">That signed list is checked against a key built into this store</string>     <string name="trust_grapheneos_check_rollback">A list older than the last one seen is refused, so an old build cannot be pushed back onto you</string>     <string name="trust_grapheneos_check_hash_and_key">Every downloaded file matches the hash and the signing key that list names for it</string>-    <string name="trust_grapheneos_limits">These are Google\'s closed-source apps. Nothing is built from published source and nothing is reproducible, so what is proven is that you received the file GrapheneOS listed, not anything about what that file does. The source carries only the Sandboxed Google Play components, and there is no way to pull a bad release back off phones.</string>+    <string name="trust_grapheneos_limits">These are Google\'s closed-source apps. Nothing is built from published source and nothing is reproducible, so what is proven is that you received the file GrapheneOS listed, not anything about what that file does. The source carries only the Sandboxed Google Play components.</string>     <string name="trust_play_title">Google Play</string>     <string name="trust_play_summary">Reviewed, scanned and signed by Google, who verify who the developer is and can pull an app from every phone at once.</string>     <string name="trust_play_practice_identity">Developers have to prove who they are, with a real name and address on file</string>@@ -226,9 +225,8 @@     <string name="trust_play_check_hash">Each downloaded file matches the hash Google sent with it</string>     <string name="trust_play_check_key">Signed by the key Google lists for this app</string>     <string name="trust_play_check_stamp">The app\'s publisher stamp is saved the first time you install it, and has to stay the same afterwards</string>-    <string name="trust_play_limits">No source code and no second build, so nothing proves the app matches any published source. Google supplies both the file and the expectation it is checked against, so these checks catch a tampered download but not a bad update Google signs itself. This store also reaches Play through an anonymous account rather than the official client, so it sees less than the Play app does.</string>+    <string name="trust_play_limits">No source code and no second build, so nothing proves the app matches any source. Google supplies both the file and the expectation, catching a tampered download but not a bad update Google signs itself. This store\'s anonymous account sees less than the Play app.</string> -    <string name="trust_accrescent_title">Accrescent</string>     <string name="trust_accrescent_summary">Apps signed by their own developers, listed on Accrescent\'s ed25519-signed allowlist which pins each app\'s signing key and lowest allowed version.</string>     <string name="trust_accrescent_practice_developer_key">Each app is signed by its developer\'s own key, not by Accrescent</string>     <string name="trust_accrescent_practice_signed_list">Which apps are legitimate, and each one\'s expected key, come from a single ed25519-signed list</string>@@ -236,17 +234,14 @@     <string name="trust_accrescent_check_list_signed">The app list is signed and checked against a key built into this store, with a timestamp that can never go backwards</string>     <string name="trust_accrescent_check_key">The download is signed by exactly the key the signed list names for this app</string>     <string name="trust_accrescent_check_min_version">The download\'s version is at or above the minimum the signed list allows</string>-    <string name="trust_accrescent_limits">Accrescent publishes no per-file hashes and no reproducible builds, so the guarantee is the signature and minimum version, not a match against source. Listings and download links come from an ordinary server over gRPC; a bad response can only ever produce a file that fails these signature and version checks. Nobody scans the apps, and there is no way to pull a bad release back off phones.</string>+    <string name="trust_accrescent_limits">Accrescent publishes no per-file hashes and no reproducible builds, so the guarantee is the signature and minimum version, not source. Listings come from an ordinary server over gRPC; a bad response can only produce a file that fails these checks. Nobody scans the apps.</string>      <!-- Sources page. -->-    <string name="repos_syncing">Syncing…</string>     <string name="repos_sync_sources">Sync sources</string>     <string name="source_modern_apps" translatable="false">Modern Apps</string>     <string name="source_modern_apps_pin">Pinned to this app\'s own signing key</string>-    <string name="source_fdroid">F-Droid</string>     <string name="source_fdroid_pin">Pinned to F-Droid\'s app list signing key</string>     <string name="source_play">Play Store (anonymous)</string>     <string name="source_play_pin">Nothing to pin: Google holds the signing key</string>-    <string name="source_accrescent">Accrescent</string>     <string name="source_accrescent_pin">Pinned to Accrescent\'s repodata signing key (ed25519)</string> </resources>
astronomy/src/main/java/com/vayunmathur/astronomy/data/CatalogRepository.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/data/CatalogRepository.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/data/CatalogRepository.ktindex 8e2978701b..10df44d9e0 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/data/CatalogRepository.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/data/CatalogRepository.kt@@ -122,9 +122,7 @@ object BuiltInCatalogs {         Star(27, 2.3898913, 1.0427, 1.25, 0.0, "Beta Crucis", "Mimosa", "Beta", null, "Cru", 280.0, "B0.5 III"),     ) + generateFillerStars() -    private companion object {-        const val FILLER_STAR_COUNT = 4000-    }+    private const val FILLER_STAR_COUNT = 4000      private fun generateFillerStars(): List<Star> {         val rnd = java.util.Random(42)
astronomy/src/main/java/com/vayunmathur/astronomy/platform/AstronomyViewModel.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/platform/AstronomyViewModel.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/platform/AstronomyViewModel.ktindex 3084f29efc..4b1ca044d5 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/platform/AstronomyViewModel.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/platform/AstronomyViewModel.kt@@ -404,7 +404,7 @@ class AstronomyViewModel(app: Application) : AndroidViewModel(app), SkyMapAction             loc?.let {                 val latDeg = it.latitude; val lonDeg = it.longitude                 _observer.value = ObserverLocation(latDeg.toRad(), lonDeg.toRad(), latDeg, lonDeg, it.altitude)-                saveDouble("astro_lat", latDeg); saveDouble("astro_lon", lonDeg)+                prefs.saveDouble("astro_lat", latDeg); prefs.saveDouble("astro_lon", lonDeg)                 orientationMgr.updateLocation(latDeg, lonDeg, it.altitude.toFloat())             } ?: run { _observer.value?.let { obs -> orientationMgr.updateLocation(obs.latDeg, obs.lonDeg) } }         }
auto/src/main/java/com/vayunmathur/auto/service/ProjectionService.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/service/ProjectionService.kt b/auto/src/main/java/com/vayunmathur/auto/service/ProjectionService.ktindex d3113b8d84..da50a07545 100644--- a/auto/src/main/java/com/vayunmathur/auto/service/ProjectionService.kt+++ b/auto/src/main/java/com/vayunmathur/auto/service/ProjectionService.kt@@ -178,7 +178,7 @@ class ProjectionService : Service() {      * Best-effort: any failure answers "day" rather than failing the      * bring-up, and the head unit's stream overrides it anyway.      */-    private fun isNightNow(): Boolean = runCatching {+    internal fun isNightNow(): Boolean = runCatching {         val uiMode = getSystemService(UiModeManager::class.java)?.nightMode             ?: resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK         when (uiMode) {@@ -559,7 +559,7 @@ class ProjectionService : Service() {         }     } -    private var video: VideoSinkChannel? = null+    internal var video: VideoSinkChannel? = null      /**      * The Phase 2 input owner, created when the entry carrying `input_source`@@ -570,9 +570,9 @@ class ProjectionService : Service() {      * forward into the car UI and count as consumed when the render pair is      * up.      */-    private var input: InputChannel? = null+    internal var input: InputChannel? = null     /** Discovery-bound input channel id; null until the input entry opens. */-    private var inputChannelId: Int? = null+    internal var inputChannelId: Int? = null      /**      * The Phase 7 messaging owner, created when ch14 opens in [openNext] like@@ -582,7 +582,7 @@ class ProjectionService : Service() {      * replies on the ch6 mic source); [MessagingAudio.NoOp] remains the seam's      * pre-audio holder for tests. Assumptions live in `MessagingAudio.kt`.      */-    private var messaging: MessagingCarAppService? = null+    internal var messaging: MessagingCarAppService? = null      /**      * The Phase 3 audio owners: system sink (ch4, transient) and media sink@@ -593,8 +593,8 @@ class ProjectionService : Service() {      * 0x13 via the session's focus listener. Ch3 guidance stays with      * sensors-dev's [GuidanceChannel] stub -- this owner answers only for 4/5.      */-    private var audioSys: AudioSinkChannel? = null-    private var audioMedia: AudioSinkChannel? = null+    internal var audioSys: AudioSinkChannel? = null+    internal var audioMedia: AudioSinkChannel? = null      /**      * The Phase 3 mic owner (upstream), created when the entry carrying@@ -603,9 +603,9 @@ class ProjectionService : Service() {      * session above. Retention is permission-gated ([MicPermission]) --      * without the grant chunks are acked and counted only.      */-    private var mic: MicSourceChannel? = null+    internal var mic: MicSourceChannel? = null     /** Discovery-bound mic channel id; null until the mic entry opens. */-    private var micChannelId: Int? = null+    internal var micChannelId: Int? = null      /**      * Phone-side TTS feeding the system sink. Outlives nothing: started with@@ -613,7 +613,7 @@ class ProjectionService : Service() {      * arrive before ch4 opens), stopped with it. Feeds through the sink's      * thread-safe `feedWav`; never blocks the caller.      */-    private var tts: CarTts? = null+    internal var tts: CarTts? = null      /**      * The Phase 5 sensor owner, created when the entry carrying@@ -624,9 +624,9 @@ class ProjectionService : Service() {      * 0); live values land with Phase 6 maps-dev through the [SensorChannel]      * seams.      */-    private var sensors: SensorChannel? = null+    internal var sensors: SensorChannel? = null     /** Discovery-bound sensor channel id; null until the sensor entry opens. */-    private var sensorChannelId: Int? = null+    internal var sensorChannelId: Int? = null      /**      * The Phase 5 guidance owner, created when ch3 opens in [openNext] like@@ -635,7 +635,7 @@ class ProjectionService : Service() {      * shape and stays idle; live TTS starts the stream through the      * [GuidanceChannel] seam.      */-    private var guidance: GuidanceChannel? = null+    internal var guidance: GuidanceChannel? = null      /**      * The Phase 5 nav-status owner, created when ch10 opens in [openNext]@@ -643,17 +643,17 @@ class ProjectionService : Service() {      * Posts the inactive stub on its grant; live turn updates land with Phase      * 6 maps-dev through [NavStatusChannel.postStatus].      */-    private var navStatus: NavStatusChannel? = null+    internal var navStatus: NavStatusChannel? = null      /** Outlives sessions; owned by the service, not the pump thread. */-    private var mediaMonitor: MediaPlaybackMonitor? = null+    internal var mediaMonitor: MediaPlaybackMonitor? = null      /**      * Session-scoped phone status (signal/battery/DND/badge) for the rail      * cluster. Started with the session like TTS; the cluster pulls the      * latest snapshot on its 1Hz tick. Stopped with the session.      */-    private var phoneStatusMonitor: PhoneStatusMonitor? = null+    internal var phoneStatusMonitor: PhoneStatusMonitor? = null      /**      * Session-scoped guidance, like TTS: started with the session (position@@ -662,8 +662,8 @@ class ProjectionService : Service() {      * last-known. The car-app host rides alongside through      * [carAppHostSession] (split for the 800-line limit).      */-    private var guidanceMonitor: NavGuidanceMonitor? = null-    private val carAppHostSession = CarAppHostSession(this) { video }+    internal var guidanceMonitor: NavGuidanceMonitor? = null+    internal val carAppHostSession = CarAppHostSession(this) { video }      /**      * Seeds the credential-expiry flow once per service start, off the pump thread.@@ -682,222 +682,8 @@ class ProjectionService : Service() {         }     } -    /**-     * Opens the next not-yet-attempted advertised service, in the HU's wire order.-     *-     * Only one open is ever in flight: while `pendingChannels` is non-empty the-     * head unit still owes us an answer, so wait.-     *-     * Service 1 IS sent, first: gearhead opens channel 0 locally and never sends-     * a 0x7 for it, but DHU 2.0 rejects a first-0x7 for service 2 with an empty-     * 0xff and no 0x8 (Run 4) -- so the HU-side may expect the wire-order-     * sequence to start at 1. If the HU 0xffs/0x8-refuses service 1 as well, it-     * lands in refusedChannels like any other refusal and the bring-up moves on-     * to service 2; the experiment then distinguishes "first-open must be 1"-     * (0x8 arrives for 1) from "video refused regardless" (both refused).-     */-    private fun openNext(connection: GalConnection) {-        val session = connection.session-        if (session.pendingChannels.isNotEmpty()) return-        val next = session.services.firstOrNull {-            it.id !in session.openChannels &&-                it.id !in session.refusedChannels-        } ?: return-        connection.send(session.openChannel(next))-        Log.i(TAG, "requesting channel open for service ${next.id}")-        maybeCreateVideoSink(next, connection)-        maybeCreateMessaging(next, connection)-        maybeCreateInput(next, connection)-        maybeCreateSensors(next, connection)-        maybeCreateGuidance(next, connection)-        maybeCreateNavStatus(next, connection)-        maybeCreateAudioSinks(next, connection)-        maybeCreateMic(next, connection)-        observeUnownedService(next)-    }--    /** Creates the video sink when its entry opens; wires every display feed. */-    private fun maybeCreateVideoSink(next: GalServiceProto, connection: GalConnection) {-        if (next.id != GalService.VIDEO_SINK.id || !next.hasMediaSink()) return-        video = VideoSinkChannel(this, next, connection, AutoSessionState::onVideoEvent)-            .also { sink ->-                sink.wiring.setNowPlayingSource(-                    get = { AutoSessionState.nowPlaying.value },-                    onTap = { mediaMonitor?.toggle() },-                )-                // Prev/next ride the same monitor as the card tap; unset-                // (null monitor) means the buttons show but stay disabled.-                sink.wiring.setTransportCallbacks(-                    onPrevious = { mediaMonitor?.seekToPrevious() },-                    onNext = { mediaMonitor?.seekToNext() },-                )-                // Night, map surface and map touches ride the session's-                // car-app host (owned by CarAppHostSession, split for-                // the 800-line limit).-                carAppHostSession.wireInto(-                    sink,-                    snapshots = { guidanceMonitor?.snapshots?.value },-                )-                // Rail cluster + call card feeds: the display caches-                // both for presentations created later.-                sink.wiring.setPhoneStatusSource { phoneStatusMonitor?.snapshot }-                sink.wiring.setCallSource(-                    get = { AutoSessionState.activeCall.value },-                    onAnswer = { CarProjectionInCallService.answerCall() },-                    onEnd = { CarProjectionInCallService.endCall() },-                    onHold = { CarProjectionInCallService.toggleHold() },-                    onMute = { CarProjectionInCallService.toggleMute() },-                )-            }-    }--    /**-     * Creates the ch14 messaging owner when it opens.-     *-     * The audio seam resolves channels lazily -- ch14 opens before ch4/6-     * in wire order, and TTS started with the session above, so early-     * utterances wait for no grant. The owner starts mirroring on its grant-     * (see MessagingCarAppService.onChannelOpen).-     */-    private fun maybeCreateMessaging(next: GalServiceProto, connection: GalConnection) {-        if (next.id != GalService.NOTIFICATION.id) return-        messaging = MessagingCarAppService(-            connection,-            audio = CarMessagingAudio(-                tts = { tts },-                mic = { mic },-                onEvent = AutoSessionState::onAudioEvent,-            ),-            onEvent = AutoSessionState::onMessagingEvent,-            onReply = { threadId, text ->-                Log.i(TAG, "head-unit reply for $threadId (${text.length} chars)")-            },-            context = { this },-        )-    }--    /**-     * Creates the ch8 input owner when the entry carrying `input_source`-     * opens. Binding is payload-driven, not id-driven: the DHU 2.0 discovery-     * advertises services 1-7 with ids that do NOT match gearhead's `rro`-     * (sensor on 1, input on 3, mic on 7 -- verified by decoding the 0x6-     * payload), while gearhead numbers them 7/8/6. Gearhead binds by-     * payload (`jlf.a(xpa)` reads the sensor config out of the service-     * entry), and so do we: the entry carrying `input_source` owns input-     * wherever its id lands. The video/audio-sink ids (2/4/5) happen to-     * line up, so those keep their id checks as a second factor.-     */-    private fun maybeCreateInput(next: GalServiceProto, connection: GalConnection) {-        if (!next.hasInputSource()) return-        inputChannelId = next.id-        input = InputChannel(-            service = next,-            connection = connection,-            isInputAllowed = { connection.session.focus.inputAllowed },-            displaySize = { video?.displaySize() },-            onEvent = AutoSessionState::onInputEvent,-            touchSink = { touch -> video?.injectTouch(touch) ?: false },-            keySink = { key -> video?.injectKey(key.keycode, key.down) ?: false },-            scrollSink = { delta -> video?.injectScroll(delta) ?: false },-        )-    }--    /**-     * Creates the sensor owner when the entry carrying `sensor_source` opens-     * (DHU 2.0: service 1; gearhead rro: 7 -- payload-driven, see above).-     * Night follows the phone until the first NIGHT_MODE batch; the-     * UiModeManager seam stays out of the service -- maps-dev owns the live-     * night source next.-     */-    private fun maybeCreateSensors(next: GalServiceProto, connection: GalConnection) {-        if (!next.hasSensorSource()) return-        sensorChannelId = next.id-        sensors = SensorChannel(-            connection = connection,-            night = NightSource { isNightNow() },-            onEvent = AutoSessionState::onSensorEvent,-            channelId = next.id,-        )-    }--    /**-     * Creates the ch3 guidance owner when it opens. The owner claims the-     * sink on its grant (see GuidanceChannel). The stream itself is-     * TTS-owned: the session predates ch3, so the grant arms it when the-     * TTS session is already running.-     */-    private fun maybeCreateGuidance(next: GalServiceProto, connection: GalConnection) {-        if (next.id != GalService.AUDIO_SINK_GUIDANCE.id || !next.hasMediaSink()) return-        guidance = GuidanceChannel(-            service = next,-            connection = connection,-            ttsActive = { tts != null },-            onEvent = AutoSessionState::onSensorEvent,-        )-    }--    /**-     * Creates the ch10 nav-status owner when it opens. The owner posts the-     * inactive stub on its grant (see NavStatusChannel.onChannelOpen).-     */-    private fun maybeCreateNavStatus(next: GalServiceProto, connection: GalConnection) {-        if (next.id != GalService.NAVIGATION_STATUS.id) return-        navStatus = NavStatusChannel(-            connection = connection,-            onEvent = AutoSessionState::onSensorEvent,-        )-    }--    /**-     * Creates the ch4/ch5 audio sink owners when they open.-     *-     * Focus asks ride control 0x18 right after setup -- the head unit-     * answers with 0x13 notifications, which refresh the sink gains.-     */-    private fun maybeCreateAudioSinks(next: GalServiceProto, connection: GalConnection) {-        if (next.id == AudioSinkRole.SYSTEM.serviceId && next.hasMediaSink()) {-            audioSys = AudioSinkChannel(-                role = AudioSinkRole.SYSTEM,-                service = next,-                connection = connection,-                focus = { connection.session.focus },-                onEvent = AutoSessionState::onAudioEvent,-            )-        }-        if (next.id == AudioSinkRole.MEDIA.serviceId && next.hasMediaSink()) {-            audioMedia = AudioSinkChannel(-                role = AudioSinkRole.MEDIA,-                service = next,-                connection = connection,-                focus = { connection.session.focus },-                onEvent = AutoSessionState::onAudioEvent,-            )-            // The music-capture service resolves this lazily per feed; publish-            // it now so capture starts flowing once the sink starts.-            MusicCaptureSinkHolder.sink = audioMedia-        }-    }--    /**-     * Creates the mic owner when the entry carrying `media_source` opens-     * (DHU 2.0: service 7; gearhead rro: 6 -- payload-driven, see above).-     *-     * Retention needs RECORD_AUDIO; without it chunks are acked and-     * counted only, so the head unit still sees a live endpoint.-     */-    private fun maybeCreateMic(next: GalServiceProto, connection: GalConnection) {-        if (!next.hasMediaSource()) return-        micChannelId = next.id-        mic = MicSourceChannel(-            connection = connection,-            retentionAllowed = { MicPermission.isGranted(this) },-            onEvent = AutoSessionState::onAudioEvent,-            channelId = next.id,-        )-    }-     companion object {-        private const val TAG = "MaAuto.Service"+        internal const val TAG = "MaAuto.Service"          /** Radix for hex message-id logging. */         private const val HEX_RADIX = 16
auto/src/main/java/com/vayunmathur/auto/service/ProjectionServiceChannels.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/service/ProjectionServiceChannels.kt b/auto/src/main/java/com/vayunmathur/auto/service/ProjectionServiceChannels.ktnew file mode 100644index 0000000000..970b1016b7--- /dev/null+++ b/auto/src/main/java/com/vayunmathur/auto/service/ProjectionServiceChannels.kt@@ -0,0 +1,237 @@+package com.vayunmathur.auto.service++import android.util.Log+import com.vayunmathur.auto.platform.AudioSinkChannel+import com.vayunmathur.auto.platform.AutoSessionState+import com.vayunmathur.auto.platform.GuidanceChannel+import com.vayunmathur.auto.platform.InputChannel+import com.vayunmathur.auto.platform.MicPermission+import com.vayunmathur.auto.platform.MicSourceChannel+import com.vayunmathur.auto.platform.MusicCaptureSinkHolder+import com.vayunmathur.auto.platform.NavStatusChannel+import com.vayunmathur.auto.platform.NightSource+import com.vayunmathur.auto.platform.SensorChannel+import com.vayunmathur.auto.platform.VideoSinkChannel+import com.vayunmathur.auto.protocol.AudioSinkRole+import com.vayunmathur.auto.protocol.GalConnection+import com.vayunmathur.auto.protocol.GalService+import com.vayunmathur.auto.protocol.gal.Service as GalServiceProto+import com.vayunmathur.auto.service.ProjectionService.Companion.TAG+import com.vayunmathur.auto.telephony.CarProjectionInCallService++// Channel bring-up: openNext + the per-service maybeCreate* factories.+// Split from ProjectionService.kt to keep that file under the 800-line limit.++/**+ * Opens the next not-yet-attempted advertised service, in the HU's wire order.+ *+ * Only one open is ever in flight: while `pendingChannels` is non-empty the+ * head unit still owes us an answer, so wait.+ *+ * Service 1 IS sent, first: gearhead opens channel 0 locally and never sends+ * a 0x7 for it, but DHU 2.0 rejects a first-0x7 for service 2 with an empty+ * 0xff and no 0x8 (Run 4) -- so the HU-side may expect the wire-order+ * sequence to start at 1. If the HU 0xffs/0x8-refuses service 1 as well, it+ * lands in refusedChannels like any other refusal and the bring-up moves on+ * to service 2; the experiment then distinguishes "first-open must be 1"+ * (0x8 arrives for 1) from "video refused regardless" (both refused).+ */+internal fun ProjectionService.openNext(connection: GalConnection) {+    val session = connection.session+    if (session.pendingChannels.isNotEmpty()) return+    val next = session.services.firstOrNull {+        it.id !in session.openChannels &&+            it.id !in session.refusedChannels+    } ?: return+    connection.send(session.openChannel(next))+    Log.i(TAG, "requesting channel open for service ${next.id}")+    maybeCreateVideoSink(next, connection)+    maybeCreateMessaging(next, connection)+    maybeCreateInput(next, connection)+    maybeCreateSensors(next, connection)+    maybeCreateGuidance(next, connection)+    maybeCreateNavStatus(next, connection)+    maybeCreateAudioSinks(next, connection)+    maybeCreateMic(next, connection)+    observeUnownedService(next)+}++/** Creates the video sink when its entry opens; wires every display feed. */+private fun ProjectionService.maybeCreateVideoSink(next: GalServiceProto, connection: GalConnection) {+    if (next.id != GalService.VIDEO_SINK.id || !next.hasMediaSink()) return+    video = VideoSinkChannel(this, next, connection, AutoSessionState::onVideoEvent)+        .also { sink ->+            sink.wiring.setNowPlayingSource(+                get = { AutoSessionState.nowPlaying.value },+                onTap = { mediaMonitor?.toggle() },+            )+            // Prev/next ride the same monitor as the card tap; unset+            // (null monitor) means the buttons show but stay disabled.+            sink.wiring.setTransportCallbacks(+                onPrevious = { mediaMonitor?.seekToPrevious() },+                onNext = { mediaMonitor?.seekToNext() },+            )+            // Night, map surface and map touches ride the session's+            // car-app host (owned by CarAppHostSession, split for+            // the 800-line limit).+            carAppHostSession.wireInto(+                sink,+                snapshots = { guidanceMonitor?.snapshots?.value },+            )+            // Rail cluster + call card feeds: the display caches+            // both for presentations created later.+            sink.wiring.setPhoneStatusSource { phoneStatusMonitor?.snapshot }+            sink.wiring.setCallSource(+                get = { AutoSessionState.activeCall.value },+                onAnswer = { CarProjectionInCallService.answerCall() },+                onEnd = { CarProjectionInCallService.endCall() },+                onHold = { CarProjectionInCallService.toggleHold() },+                onMute = { CarProjectionInCallService.toggleMute() },+            )+        }+}++/**+ * Creates the ch14 messaging owner when it opens.+ *+ * The audio seam resolves channels lazily -- ch14 opens before ch4/6+ * in wire order, and TTS started with the session above, so early+ * utterances wait for no grant. The owner starts mirroring on its grant+ * (see MessagingCarAppService.onChannelOpen).+ */+private fun ProjectionService.maybeCreateMessaging(next: GalServiceProto, connection: GalConnection) {+    if (next.id != GalService.NOTIFICATION.id) return+    messaging = MessagingCarAppService(+        connection,+        audio = CarMessagingAudio(+            tts = { tts },+            mic = { mic },+            onEvent = AutoSessionState::onAudioEvent,+        ),+        onEvent = AutoSessionState::onMessagingEvent,+        onReply = { threadId, text ->+            Log.i(TAG, "head-unit reply for $threadId (${text.length} chars)")+        },+        context = { this },+    )+}++/**+ * Creates the ch8 input owner when the entry carrying `input_source`+ * opens. Binding is payload-driven, not id-driven: the DHU 2.0 discovery+ * advertises services 1-7 with ids that do NOT match gearhead's `rro`+ * (sensor on 1, input on 3, mic on 7 -- verified by decoding the 0x6+ * payload), while gearhead numbers them 7/8/6. Gearhead binds by+ * payload (`jlf.a(xpa)` reads the sensor config out of the service+ * entry), and so do we: the entry carrying `input_source` owns input+ * wherever its id lands. The video/audio-sink ids (2/4/5) happen to+ * line up, so those keep their id checks as a second factor.+ */+private fun ProjectionService.maybeCreateInput(next: GalServiceProto, connection: GalConnection) {+    if (!next.hasInputSource()) return+    inputChannelId = next.id+    input = InputChannel(+        service = next,+        connection = connection,+        isInputAllowed = { connection.session.focus.inputAllowed },+        displaySize = { video?.displaySize() },+        onEvent = AutoSessionState::onInputEvent,+        touchSink = { touch -> video?.injectTouch(touch) ?: false },+        keySink = { key -> video?.injectKey(key.keycode, key.down) ?: false },+        scrollSink = { delta -> video?.injectScroll(delta) ?: false },+    )+}++/**+ * Creates the sensor owner when the entry carrying `sensor_source` opens+ * (DHU 2.0: service 1; gearhead rro: 7 -- payload-driven, see above).+ * Night follows the phone until the first NIGHT_MODE batch; the+ * UiModeManager seam stays out of the service -- maps-dev owns the live+ * night source next.+ */+private fun ProjectionService.maybeCreateSensors(next: GalServiceProto, connection: GalConnection) {+    if (!next.hasSensorSource()) return+    sensorChannelId = next.id+    sensors = SensorChannel(+        connection = connection,+        night = NightSource { isNightNow() },+        onEvent = AutoSessionState::onSensorEvent,+        channelId = next.id,+    )+}++/**+ * Creates the ch3 guidance owner when it opens. The owner claims the+ * sink on its grant (see GuidanceChannel). The stream itself is+ * TTS-owned: the session predates ch3, so the grant arms it when the+ * TTS session is already running.+ */+private fun ProjectionService.maybeCreateGuidance(next: GalServiceProto, connection: GalConnection) {+    if (next.id != GalService.AUDIO_SINK_GUIDANCE.id || !next.hasMediaSink()) return+    guidance = GuidanceChannel(+        service = next,+        connection = connection,+        ttsActive = { tts != null },+        onEvent = AutoSessionState::onSensorEvent,+    )+}++/**+ * Creates the ch10 nav-status owner when it opens. The owner posts the+ * inactive stub on its grant (see NavStatusChannel.onChannelOpen).+ */+private fun ProjectionService.maybeCreateNavStatus(next: GalServiceProto, connection: GalConnection) {+    if (next.id != GalService.NAVIGATION_STATUS.id) return+    navStatus = NavStatusChannel(+        connection = connection,+        onEvent = AutoSessionState::onSensorEvent,+    )+}++/**+ * Creates the ch4/ch5 audio sink owners when they open.+ *+ * Focus asks ride control 0x18 right after setup -- the head unit+ * answers with 0x13 notifications, which refresh the sink gains.+ */+private fun ProjectionService.maybeCreateAudioSinks(next: GalServiceProto, connection: GalConnection) {+    if (next.id == AudioSinkRole.SYSTEM.serviceId && next.hasMediaSink()) {+        audioSys = AudioSinkChannel(+            role = AudioSinkRole.SYSTEM,+            service = next,+            connection = connection,+            focus = { connection.session.focus },+            onEvent = AutoSessionState::onAudioEvent,+        )+    }+    if (next.id == AudioSinkRole.MEDIA.serviceId && next.hasMediaSink()) {+        audioMedia = AudioSinkChannel(+            role = AudioSinkRole.MEDIA,+            service = next,+            connection = connection,+            focus = { connection.session.focus },+            onEvent = AutoSessionState::onAudioEvent,+        )+        // The music-capture service resolves this lazily per feed; publish+        // it now so capture starts flowing once the sink starts.+        MusicCaptureSinkHolder.sink = audioMedia+    }+}++/**+ * Creates the mic owner when the entry carrying `media_source` opens+ * (DHU 2.0: service 7; gearhead rro: 6 -- payload-driven, see above).+ *+ * Retention needs RECORD_AUDIO; without it chunks are acked and+ * counted only, so the head unit still sees a live endpoint.+ */+private fun ProjectionService.maybeCreateMic(next: GalServiceProto, connection: GalConnection) {+    if (!next.hasMediaSource()) return+    micChannelId = next.id+    mic = MicSourceChannel(+        connection = connection,+        retentionAllowed = { MicPermission.isGranted(this) },+        onEvent = AutoSessionState::onAudioEvent,+        channelId = next.id,+    )+}
auto/src/main/java/com/vayunmathur/auto/ui/AudioRow.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/ui/AudioRow.kt b/auto/src/main/java/com/vayunmathur/auto/ui/AudioRow.ktindex d3ad201070..dc85497a17 100644--- a/auto/src/main/java/com/vayunmathur/auto/ui/AudioRow.kt+++ b/auto/src/main/java/com/vayunmathur/auto/ui/AudioRow.kt@@ -35,11 +35,11 @@ fun AudioRow(     )     ListItem(         headlineContent = { Text(stringResource(R.string.session_audio_bytes)) },-        supportingContent = { Text(stringResource(R.string.session_audio_bytes_value, bytesSent)) },+        supportingContent = { Text(stringResource(R.string.session_stat_value, bytesSent)) },     )     ListItem(         headlineContent = { Text(stringResource(R.string.session_audio_music_captured)) },-        supportingContent = { Text(stringResource(R.string.session_audio_music_captured_value, musicCaptured)) },+        supportingContent = { Text(stringResource(R.string.session_stat_value, musicCaptured)) },     )     ListItem(         headlineContent = { Text(stringResource(R.string.session_audio_mic)) },@@ -49,7 +49,7 @@ fun AudioRow(     )     ListItem(         headlineContent = { Text(stringResource(R.string.session_audio_tts)) },-        supportingContent = { Text(stringResource(R.string.session_audio_tts_value, ttsSpoken)) },+        supportingContent = { Text(stringResource(R.string.session_stat_value, ttsSpoken)) },     ) } 
auto/src/main/java/com/vayunmathur/auto/ui/AutoScreen.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/ui/AutoScreen.kt b/auto/src/main/java/com/vayunmathur/auto/ui/AutoScreen.ktindex 242a073b26..3594e7da6f 100644--- a/auto/src/main/java/com/vayunmathur/auto/ui/AutoScreen.kt+++ b/auto/src/main/java/com/vayunmathur/auto/ui/AutoScreen.kt@@ -94,7 +94,7 @@ fun AutoScreen(viewModel: AutoViewModel, onPairing: () -> Unit, onPinnedApps: ()                     supportingContent = { Text(stringResource(R.string.pinned_apps_body, PinnedAppsPrefs.MAX_PINNED)) },                     trailingContent = {                         TextButton(onClick = onPinnedApps) {-                            Text(stringResource(R.string.pinned_apps_open))+                            Text(stringResource(R.string.pinned_apps_title))                         }                     },                 )
auto/src/main/java/com/vayunmathur/auto/ui/MusicCaptureCard.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/ui/MusicCaptureCard.kt b/auto/src/main/java/com/vayunmathur/auto/ui/MusicCaptureCard.ktindex 8c797d1321..2b6c093be0 100644--- a/auto/src/main/java/com/vayunmathur/auto/ui/MusicCaptureCard.kt+++ b/auto/src/main/java/com/vayunmathur/auto/ui/MusicCaptureCard.kt@@ -92,7 +92,7 @@ fun MusicCaptureCard(modifier: Modifier = Modifier) {                                     messenger.show(context.getString(R.string.music_capture_denied))                                 }                             }) {-                                Text(stringResource(R.string.music_capture_allow))+                                Text(stringResource(R.string.mic_allow))                             }                         }                     },
auto/src/main/java/com/vayunmathur/auto/ui/PairingScreen.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/ui/PairingScreen.kt b/auto/src/main/java/com/vayunmathur/auto/ui/PairingScreen.ktindex bde74eabee..ab7b0da0a2 100644--- a/auto/src/main/java/com/vayunmathur/auto/ui/PairingScreen.kt+++ b/auto/src/main/java/com/vayunmathur/auto/ui/PairingScreen.kt@@ -163,7 +163,7 @@ private fun WirelessRow(     Card(modifier.fillMaxWidth()) {         Column {             ListItem(-                headlineContent = { Text(stringResource(R.string.pairing_wireless)) },+                headlineContent = { Text(stringResource(R.string.pairing_transport_wireless)) },                 supportingContent = { Text(line) },             )             when (state) {
auto/src/main/java/com/vayunmathur/auto/ui/SessionCard.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/ui/SessionCard.kt b/auto/src/main/java/com/vayunmathur/auto/ui/SessionCard.ktindex 97490a5b60..94222542d3 100644--- a/auto/src/main/java/com/vayunmathur/auto/ui/SessionCard.kt+++ b/auto/src/main/java/com/vayunmathur/auto/ui/SessionCard.kt@@ -81,7 +81,7 @@ fun SessionCard(session: SessionSnapshot, modifier: Modifier = Modifier) {                     headlineContent = { Text(stringResource(R.string.session_ack_mismatch)) },                     supportingContent = {                         Text(-                            stringResource(R.string.session_ack_mismatch_value, session.ackMismatches),+                            stringResource(R.string.session_stat_value, session.ackMismatches),                         )                     },                 )@@ -104,8 +104,8 @@ fun SessionCard(session: SessionSnapshot, modifier: Modifier = Modifier) {                 supportingContent = {                     Text(                         session.lastAckSeq?.let {-                            stringResource(R.string.session_ack_seq_value, it)-                        } ?: stringResource(R.string.session_ack_seq_none),+stringResource(R.string.session_stat_value, it)+                        } ?: stringResource(R.string.session_value_none),                     )                 },             )@@ -115,14 +115,14 @@ fun SessionCard(session: SessionSnapshot, modifier: Modifier = Modifier) {                     Text(                         session.avgEncodeLatencyUs?.let {                             stringResource(R.string.session_latency_value, it)-                        } ?: stringResource(R.string.session_latency_none),+                        } ?: stringResource(R.string.session_value_none),                     )                 },             )             ListItem(                 headlineContent = { Text(stringResource(R.string.session_drains)) },                 supportingContent = {-                    Text(stringResource(R.string.session_drains_value, session.encoderDrains))+                    Text(stringResource(R.string.session_stat_value, session.encoderDrains))                 },             )             ListItem(@@ -171,20 +171,20 @@ fun SessionCard(session: SessionSnapshot, modifier: Modifier = Modifier) { private fun InputRow(touches: Long, keys: Long, scrolls: Long, dropped: Long) {     ListItem(         headlineContent = { Text(stringResource(R.string.session_input_touches)) },-        supportingContent = { Text(stringResource(R.string.session_input_touches_value, touches)) },+        supportingContent = { Text(stringResource(R.string.session_stat_value, touches)) },     )     ListItem(         headlineContent = { Text(stringResource(R.string.session_input_keys)) },-        supportingContent = { Text(stringResource(R.string.session_input_keys_value, keys)) },+        supportingContent = { Text(stringResource(R.string.session_stat_value, keys)) },     )     ListItem(         headlineContent = { Text(stringResource(R.string.session_input_scrolls)) },-        supportingContent = { Text(stringResource(R.string.session_input_scrolls_value, scrolls)) },+        supportingContent = { Text(stringResource(R.string.session_stat_value, scrolls)) },     )     if (dropped > 0) {         ListItem(             headlineContent = { Text(stringResource(R.string.session_input_dropped)) },-            supportingContent = { Text(stringResource(R.string.session_input_dropped_value, dropped)) },+            supportingContent = { Text(stringResource(R.string.session_stat_value, dropped)) },         )     } }@@ -225,15 +225,15 @@ private fun NowPlayingRow(nowPlaying: NowPlayingInfo?) { private fun MessagingRow(threads: Long, messages: Long, replies: Long) {     ListItem(         headlineContent = { Text(stringResource(R.string.session_messaging_threads)) },-        supportingContent = { Text(stringResource(R.string.session_messaging_threads_value, threads)) },+        supportingContent = { Text(stringResource(R.string.session_stat_value, threads)) },     )     ListItem(         headlineContent = { Text(stringResource(R.string.session_messaging_messages)) },-        supportingContent = { Text(stringResource(R.string.session_messaging_messages_value, messages)) },+        supportingContent = { Text(stringResource(R.string.session_stat_value, messages)) },     )     ListItem(         headlineContent = { Text(stringResource(R.string.session_messaging_replies)) },-        supportingContent = { Text(stringResource(R.string.session_messaging_replies_value, replies)) },+        supportingContent = { Text(stringResource(R.string.session_stat_value, replies)) },     ) } @@ -320,7 +320,7 @@ private fun SessionElapsedRow(sessionStartedAt: Long?) {     // recomposes each second rather than the whole screen.     tick = now()     val elapsed = sessionStartedAt?.let { formatElapsed(tick - it) }-        ?: stringResource(R.string.session_elapsed_none)+        ?: stringResource(R.string.session_value_none)     ListItem(         headlineContent = { Text(stringResource(R.string.session_elapsed)) },         supportingContent = { Text(elapsed) },
auto/src/main/res/values/strings.xml
diff --git a/auto/src/main/res/values/strings.xml b/auto/src/main/res/values/strings.xmlindex b16fb9af5e..a720d9063c 100644--- a/auto/src/main/res/values/strings.xml+++ b/auto/src/main/res/values/strings.xml@@ -48,10 +48,13 @@     <string name="session_frames">Frames / acks</string>     <!-- %1$d is frames sent, %2$d is acks seen. -->     <string name="session_frames_value"><xliff:g example="120" id="frames">%1$d</xliff:g> / <xliff:g example="118" id="acks">%2$d</xliff:g></string>+    <!-- Shared value for every bare session-stat count on the session card+         (ack mismatches, ack sequence, drains, thread/message/reply counts,+         touch/key/scroll/drop counts, audio bytes, music captured, TTS).+         %1$d is the count. -->+    <string name="session_stat_value"><xliff:g example="3" id="count">%1$d</xliff:g></string>     <!-- Heading of the row counting acks that named the wrong session. -->     <string name="session_ack_mismatch">Ack mismatches</string>-    <!-- %1$d is the count of mismatched acks. -->-    <string name="session_ack_mismatch_value"><xliff:g example="1" id="count">%1$d</xliff:g></string>     <!-- Heading of the row showing the encode-side and ack rates over a sliding window.          Sender-side only: sent frames per second and head-unit acks per second. -->     <string name="session_rates">Rates sent / acked</string>@@ -71,20 +74,14 @@     <string name="session_ack_age_none">No acks yet</string>     <!-- Heading of the row showing the highest head-unit ack counter seen. -->     <string name="session_ack_seq">Ack sequence</string>-    <!-- %1$d is the highest 0x8004 ack counter seen so far. -->-    <string name="session_ack_seq_value"><xliff:g example="118" id="seq">%1$d</xliff:g></string>-    <!-- Shown when no ack has carried a sequence counter yet. -->-    <string name="session_ack_seq_none">—</string>+    <!-- Shared dash shown when there is no session value to display. -->+    <string name="session_value_none">—</string>     <!-- Heading of the row showing the mean encode-to-send latency. -->     <string name="session_latency">Encode latency</string>     <!-- %1$d is the rolling mean encode-to-send latency in microseconds. -->     <string name="session_latency_value"><xliff:g example="8300" id="latency_us">%1$d</xliff:g> µs</string>-    <!-- Shown when no frame has been sent yet to measure latency from. -->-    <string name="session_latency_none">—</string>     <!-- Heading of the row counting encoder drains. -->     <string name="session_drains">Encoder drains</string>-    <!-- %1$d is the count of encoder drains so far. -->-    <string name="session_drains_value"><xliff:g example="240" id="count">%1$d</xliff:g></string>     <!-- Heading of the row showing whether the virtual display plus encoder input          surface pair is currently up. -->     <string name="session_surface">Surface</string>@@ -127,8 +124,6 @@     <string name="session_credential_expired">Expired — projection needs a new credential</string>     <!-- Heading of the row showing how long the session has been active. -->     <string name="session_elapsed">Session time</string>-    <!-- Shown when there is no active session to time. -->-    <string name="session_elapsed_none">—</string>      <!-- Heading of the card gating message mirroring. Both switches must be on          before a notification reaches the car: the system listener binding and@@ -154,33 +149,19 @@     <string name="messaging_open_settings">Open settings</string>     <!-- Heading of the row counting ch14 thread snapshots posted this session. -->     <string name="session_messaging_threads">Message threads</string>-    <!-- %1$d is the count of thread snapshots posted. -->-    <string name="session_messaging_threads_value"><xliff:g example="3" id="count">%1$d</xliff:g></string>     <!-- Heading of the row counting ch14 message bodies posted this session. -->     <string name="session_messaging_messages">Messages posted</string>-    <!-- %1$d is the count of message bodies posted. -->-    <string name="session_messaging_messages_value"><xliff:g example="5" id="count">%1$d</xliff:g></string>     <!-- Heading of the row counting head-unit replies received this session. -->     <string name="session_messaging_replies">Car replies</string>-    <!-- %1$d is the count of replies received. -->-    <string name="session_messaging_replies_value"><xliff:g example="1" id="count">%1$d</xliff:g></string>      <!-- Heading of the row counting ch8 touch frames injected this session. -->     <string name="session_input_touches">Car touches</string>-    <!-- %1$d is the count of touch frames injected. -->-    <string name="session_input_touches_value"><xliff:g example="40" id="count">%1$d</xliff:g></string>     <!-- Heading of the row counting ch8 key presses/releases injected this session. -->     <string name="session_input_keys">Car keys</string>-    <!-- %1$d is the count of keys injected. -->-    <string name="session_input_keys_value"><xliff:g example="7" id="count">%1$d</xliff:g></string>     <!-- Heading of the row counting ch8 scroll ticks injected this session. -->     <string name="session_input_scrolls">Car scrolls</string>-    <!-- %1$d is the count of scroll ticks injected. -->-    <string name="session_input_scrolls_value"><xliff:g example="3" id="count">%1$d</xliff:g></string>     <!-- Heading of the row counting ch8 reports dropped for lack of input focus. -->     <string name="session_input_dropped">Input dropped</string>-    <!-- %1$d is the count of reports dropped without input focus. -->-    <string name="session_input_dropped_value"><xliff:g example="2" id="count">%1$d</xliff:g></string>      <!-- Heading of the row showing what the on-device media session is playing. -->     <string name="session_now_playing">Now playing</string>@@ -219,8 +200,6 @@     <string name="pairing_usb_connected">Connected %1$s</string>     <!-- Shown when the USB accessory went away after having been seen. -->     <string name="pairing_usb_lost">Cable disconnected</string>-    <!-- Heading of the row showing the wireless bring-up state. -->-    <string name="pairing_wireless">Wireless</string>     <!-- Shown before wireless discovery starts. -->     <string name="pairing_wireless_idle">Not looking for cars</string>     <!-- Button starting WiFi Direct discovery. -->@@ -259,16 +238,8 @@      <!-- Second line of the car status bar, under the product name. -->     <string name="car_connected">Connected</string>-    <!-- Heading of the single now-playing card on the car display (Phase 4 time-box). -->-    <string name="car_now_playing">Now playing</string>-    <!-- Shown on the car card while audio is playing. -->-    <string name="car_now_playing_playing">Playing</string>-    <!-- Shown on the car card while playback is paused. -->-    <string name="car_now_playing_paused">Paused</string>-    <!-- Shown on the car card when the media session reports no title. -->-    <string name="car_now_playing_unknown">Unknown track</string>-    <!-- Shown on the car card when the media session reports no artist. -->-    <string name="car_now_playing_unknown_artist">Unknown artist</string>+    <!-- The car display now-playing card reuses the session now-playing strings+         above (session_now_playing*); no car-specific copies are kept. -->     <!-- Shown on the car display when no launchable apps were found on the phone. -->     <string name="car_no_apps">No apps available — install Maps or Music to get started</string>     <!-- Label of the hotseat drawer cell and the drawer heading listing every car app. -->@@ -291,14 +262,10 @@     <string name="session_audio_sink_idle">Idle</string>     <!-- Shown for a streaming sink. %1$s is the arbitrated gain ("Full", "Ducked"). -->     <string name="session_audio_sink_streaming">Streaming (<xliff:g example="Full" id="gain">%1$s</xliff:g>)</string>-    <!-- Heading of the session-card row counting PCM bytes framed out on ch4/5. -->+    <!-- Heading of the row counting PCM bytes framed out on ch4/5. -->     <string name="session_audio_bytes">Audio bytes</string>-    <!-- %1$d is PCM bytes framed out this session. -->-    <string name="session_audio_bytes_value"><xliff:g example="48000" id="bytes">%1$d</xliff:g></string>-    <!-- Heading of the session-card row counting music PCM captured into ch5. -->+    <!-- Heading of the row counting music PCM captured into ch5. -->     <string name="session_audio_music_captured">Music captured</string>-    <!-- %1$d is music PCM bytes captured into the ch5 sink this session. -->-    <string name="session_audio_music_captured_value"><xliff:g example="48000" id="bytes">%1$d</xliff:g></string>      <!-- Heading of the card gating car music. Both switches must be on before          phone audio reaches the head unit: the in-app consent below and the@@ -320,8 +287,8 @@     <string name="music_capture_projection_granted">Allowed — MA Auto can capture media audio</string>     <!-- Shown when the system media-projection grant is not stored. -->     <string name="music_capture_projection_missing">Not allowed — grant permission to send music to the car</string>-    <!-- Button launching the system media-projection consent dialog. -->-    <string name="music_capture_allow">Allow</string>+    <!-- Button launching the system media-projection consent dialog. Reuses+         the mic permission label below ("Allow"). -->     <!-- Snackbar when the media-projection consent dialog is denied or fails. -->     <string name="music_capture_denied">Permission denied — music stays on the phone</string>     <!-- Ongoing notification while music capture runs (its own service holds@@ -331,10 +298,8 @@     <string name="session_audio_mic">Car mic</string>     <!-- %1$d is mic turns that yielded PCM, %2$d is chunks acked upstream. -->     <string name="session_audio_mic_value"><xliff:g example="2" id="turns">%1$d</xliff:g> turns / <xliff:g example="140" id="acks">%2$d</xliff:g> acked</string>-    <!-- Heading of the session-card row counting TTS utterances that reached the car. -->+    <!-- Heading of the row counting TTS utterances that reached the car. -->     <string name="session_audio_tts">Car TTS</string>-    <!-- %1$d is utterances spoken on the car speakers this session. -->-    <string name="session_audio_tts_value"><xliff:g example="3" id="count">%1$d</xliff:g></string>      <!-- Heading of the card gating car-mic voice retention on the microphone permission. -->     <string name="mic_headline">Car microphone</string>@@ -427,12 +392,10 @@     <!-- Shown on the car call card hold button while held. -->     <string name="car_call_resume">Resume</string> -    <!-- Title of the car dock pin picker. -->+    <!-- Title of the car dock pin picker; also used for the button opening it. -->     <string name="pinned_apps_title">Car dock</string>     <!-- Explains the picker: check apps to pin, reorder with the arrows. %1$d is the max pins. -->     <string name="pinned_apps_body">Choose up to %1$d car apps for the bottom bar, in order.</string>-    <!-- Button opening the pin picker from the status card. -->-    <string name="pinned_apps_open">Car dock</string>     <!-- %1$d is the pinned position, 1-based. -->     <string name="pinned_apps_rank">Pinned %1$d</string>     <!-- Snackbar when pinning while the dock is full. %1$d is the max pins. -->
calculator/src/main/java/com/vayunmathur/calculator/util/Units.kt
diff --git a/calculator/src/main/java/com/vayunmathur/calculator/util/Units.kt b/calculator/src/main/java/com/vayunmathur/calculator/util/Units.ktindex c4bce635bc..f3ad977629 100644--- a/calculator/src/main/java/com/vayunmathur/calculator/util/Units.kt+++ b/calculator/src/main/java/com/vayunmathur/calculator/util/Units.kt@@ -1,8 +1,6 @@ package com.vayunmathur.calculator.util  import kotlin.math.PI-import kotlin.math.floor-import kotlin.math.pow  /**  * A dimensional-analysis layer that lets the expression engine carry units through a@@ -14,215 +12,8 @@ import kotlin.math.pow  * documented on [Quantity].  */ -/** The seven SI base dimensions, plus INFORMATION so bytes/bits are first-class, and- * CURRENCY for the live money converter (converter-only; never used inside equations). */-enum class BaseDim { LENGTH, MASS, TIME, CURRENT, TEMPERATURE, AMOUNT, LUMINOUS, INFORMATION, CURRENCY }--/**- * A product of base dimensions with integer exponents (so speed is `LENGTH·TIME⁻¹`). Zero- * exponents are dropped, so structural [equals] doubles as dimensional compatibility.- */-class Dimension private constructor(val exponents: Map<BaseDim, Int>) {--    val isDimensionless: Boolean get() = exponents.isEmpty()--    operator fun times(other: Dimension) = of(merge(exponents, other.exponents, 1))-    operator fun div(other: Dimension) = of(merge(exponents, other.exponents, -1))-    fun pow(n: Int) = of(exponents.mapValues { it.value * n })--    override fun equals(other: Any?) = other is Dimension && other.exponents == exponents-    override fun hashCode() = exponents.hashCode()-    override fun toString() =-        if (isDimensionless) "1" else exponents.entries.joinToString("·") { "${it.key}^${it.value}" }--    companion object {-        val NONE = Dimension(emptyMap())--        fun of(map: Map<BaseDim, Int>) = Dimension(map.filterValues { it != 0 })-        private fun base(d: BaseDim) = of(mapOf(d to 1))--        private fun merge(a: Map<BaseDim, Int>, b: Map<BaseDim, Int>, sign: Int): Map<BaseDim, Int> {-            val out = a.toMutableMap()-            for ((k, v) in b) out[k] = (out[k] ?: 0) + sign * v-            return out-        }--        // Base dimensions.-        val LENGTH = base(BaseDim.LENGTH)-        val MASS = base(BaseDim.MASS)-        val TIME = base(BaseDim.TIME)-        val CURRENT = base(BaseDim.CURRENT)-        val TEMPERATURE = base(BaseDim.TEMPERATURE)-        val AMOUNT = base(BaseDim.AMOUNT)-        val INFORMATION = base(BaseDim.INFORMATION)-        val CURRENCY = base(BaseDim.CURRENCY)--        // Common derived dimensions.-        val AREA = LENGTH.pow(2)-        val VOLUME = LENGTH.pow(3)-        val SPEED = LENGTH / TIME-        val FREQUENCY = TIME.pow(-1)-        val FORCE = MASS * LENGTH / TIME.pow(2)-        val ENERGY = FORCE * LENGTH-        val POWER = ENERGY / TIME-        val PRESSURE = FORCE / AREA-        val CHARGE = CURRENT * TIME-        val VOLTAGE = POWER / CURRENT-        val RESISTANCE = VOLTAGE / CURRENT-        val CAPACITANCE = CHARGE / VOLTAGE-    }-}--/**- * A magnitude with a [dimension], as produced by evaluating an expression node.- *- * [value] is the linear magnitude in coherent base units (m, kg, s, …). Temperature is affine- * and gets special treatment: [value] is a **kelvin-sized delta** and [tempOffsetK] distinguishes- * an *absolute* temperature (`tempOffsetK != null`, absolute kelvin = `value + tempOffsetK`) from- * a *delta* (`tempOffsetK == null`).- *- * The user's rule for `+`/`-` chains of temperatures (example `200k - 5c → 195K`): the first- * temperature is absolute; each one added/subtracted onto it contributes only its degree-size- * (its [value]), so `5c` behaves like a 5 K offset rather than 278.15 K.- */-class Quantity(-    val value: Double,-    val dimension: Dimension,-    val tempOffsetK: Double? = null,-    /**-     * True when this is an absolute point in time (a date/datetime), as opposed to a duration.-     * Only meaningful for [Dimension.TIME]: an instant holds epoch seconds in [value]. Instants-     * combine with durations (instant ± duration = instant) and with each other only by-     * subtraction (instant − instant = duration); every other operation is rejected.-     */-    val instant: Boolean = false,-) {-    val isDimensionless: Boolean get() = dimension.isDimensionless-    private val isTemperature: Boolean get() = dimension == Dimension.TEMPERATURE--    operator fun unaryMinus() = Quantity(-value, dimension, tempOffsetK)--    operator fun plus(other: Quantity) = addOrSub(other, 1.0)-    operator fun minus(other: Quantity) = addOrSub(other, -1.0)--    private fun addOrSub(other: Quantity, sign: Double): Quantity {-        if (dimension != other.dimension) {-            throw ExpressionError("Cannot add or subtract incompatible units")-        }-        if (isTemperature) {-            // The right operand always collapses to its degree-size (a delta).-            val rightDelta = other.value-            return if (tempOffsetK != null) {-                // Absolute left: fold into absolute kelvin, then re-normalise (offset 0).-                Quantity((value + tempOffsetK) + sign * rightDelta, Dimension.TEMPERATURE, 0.0)-            } else {-                Quantity(value + sign * rightDelta, Dimension.TEMPERATURE, null)-            }-        }-        if (instant || other.instant) {-            // Both operands are TIME here (the dimension check above passed). Dates are absolute-            // points; they combine with durations, and subtract from each other to give a span.-            return addOrSubInstant(other, sign)-        }-        return Quantity(value + sign * other.value, dimension, null)-    }--    private fun addOrSubInstant(other: Quantity, sign: Double): Quantity {-        if (instant && other.instant) {-            if (sign > 0) throw ExpressionError("Cannot add two dates together")-            return Quantity(value - other.value, Dimension.TIME) // date − date = duration-        }-        if (instant) {-            return Quantity(value + sign * other.value, Dimension.TIME, instant = true) // date ± duration-        }-        if (sign < 0) throw ExpressionError("Cannot subtract a date from a duration")-        return Quantity(value + other.value, Dimension.TIME, instant = true) // duration + date-    }--    operator fun times(other: Quantity): Quantity {-        if (instant || other.instant) throw ExpressionError("A date only supports + or − with a duration")-        // A dimensionless scalar scales the other operand and preserves its temperature offset,-        // which is what turns `20 * celsius` into an absolute 293.15 K.-        if (isDimensionless && tempOffsetK == null) {-            return Quantity(value * other.value, other.dimension, other.tempOffsetK)-        }-        if (other.isDimensionless && other.tempOffsetK == null) {-            return Quantity(value * other.value, dimension, tempOffsetK)-        }-        // Two dimensional operands: combine dimensions; any temperature collapses to a delta.-        return Quantity(value * other.value, dimension * other.dimension, null)-    }--    operator fun div(other: Quantity): Quantity {-        if (instant || other.instant) throw ExpressionError("A date only supports + or − with a duration")-        if (other.isDimensionless && other.tempOffsetK == null) {-            return Quantity(value / other.value, dimension, tempOffsetK)-        }-        return Quantity(value / other.value, dimension / other.dimension, null)-    }--    operator fun rem(other: Quantity): Quantity {-        if (instant || other.instant) throw ExpressionError("A date only supports + or − with a duration")-        if (!other.isDimensionless && dimension != other.dimension) {-            throw ExpressionError("Cannot take the remainder of incompatible units")-        }-        return Quantity(value % other.value, dimension, null)-    }--    fun pow(other: Quantity): Quantity {-        if (instant || other.instant) throw ExpressionError("A date only supports + or − with a duration")-        val n = checkPowExponent(other)-        if (isDimensionless) return Quantity(value.pow(n), Dimension.NONE)-        return Quantity(value.pow(n), dimension.pow(n.toInt()))-    }--    private fun checkPowExponent(other: Quantity): Double {-        if (!other.isDimensionless) throw ExpressionError("Exponent must be dimensionless")-        val n = other.value-        if (n != floor(n)) throw ExpressionError("Cannot raise a unit to a non-integer power")-        return n-    }--    fun abs(): Quantity = Quantity(kotlin.math.abs(value), dimension, tempOffsetK)--    companion object {-        fun scalar(value: Double) = Quantity(value, Dimension.NONE)-    }-}--/**- * One unit the user can pick. [token] is the ASCII spelling the parser understands (inserted- * by the keypad picker, e.g. `degC`, `um`, `ohm`); [symbol] is the pretty display form- * (`°C`, `µm`, `Ω`); [aliases] are extra spellings the parser also accepts (e.g. `c` for `degC`).- *- * [factorToBase] scales a magnitude to coherent base units. [offsetK] is set only for affine- * temperature units and is the absolute kelvin at zero of the unit (0 for K, 273.15 for °C).- */-class UnitDef(-    val token: String,-    val symbol: String,-    val name: String,-    val dimension: Dimension,-    val factorToBase: Double,-    val offsetK: Double? = null,-    val aliases: List<String> = emptyList(),-) {-    /** Magnitude in this unit → coherent base value (absolute kelvin for temperatures). */-    fun toBase(magnitude: Double): Double = magnitude * factorToBase + (offsetK ?: 0.0)--    /** Coherent base value → magnitude in this unit. */-    fun fromBase(baseValue: Double): Double = (baseValue - (offsetK ?: 0.0)) / factorToBase-}--/** A named group of units, shown as one tab in the converter. */-class UnitCategory(-    val name: String,-    val units: List<UnitDef>,-    /** Whether these units are also usable inside equations (angle units are converter-only). */-    val inEquations: Boolean = true,-)- /**+ * The single source of unit truth  * The single source of unit truth: the converter's [categories], the parser's [parseTokens],  * and the output-selector's [unitsFor].  */
calculator/src/main/java/com/vayunmathur/calculator/util/UnitsModel.kt
diff --git a/calculator/src/main/java/com/vayunmathur/calculator/util/UnitsModel.kt b/calculator/src/main/java/com/vayunmathur/calculator/util/UnitsModel.ktnew file mode 100644index 0000000000..dc1896b66a--- /dev/null+++ b/calculator/src/main/java/com/vayunmathur/calculator/util/UnitsModel.kt@@ -0,0 +1,212 @@+package com.vayunmathur.calculator.util++import kotlin.math.floor+import kotlin.math.pow++/** The seven SI base dimensions, plus INFORMATION so bytes/bits are first-class, and+ * CURRENCY for the live money converter (converter-only; never used inside equations). */+enum class BaseDim { LENGTH, MASS, TIME, CURRENT, TEMPERATURE, AMOUNT, LUMINOUS, INFORMATION, CURRENCY }++/**+ * A product of base dimensions with integer exponents (so speed is `LENGTH·TIME⁻¹`). Zero+ * exponents are dropped, so structural [equals] doubles as dimensional compatibility.+ */+class Dimension private constructor(val exponents: Map<BaseDim, Int>) {++    val isDimensionless: Boolean get() = exponents.isEmpty()++    operator fun times(other: Dimension) = of(merge(exponents, other.exponents, 1))+    operator fun div(other: Dimension) = of(merge(exponents, other.exponents, -1))+    fun pow(n: Int) = of(exponents.mapValues { it.value * n })++    override fun equals(other: Any?) = other is Dimension && other.exponents == exponents+    override fun hashCode() = exponents.hashCode()+    override fun toString() =+        if (isDimensionless) "1" else exponents.entries.joinToString("·") { "${it.key}^${it.value}" }++    companion object {+        val NONE = Dimension(emptyMap())++        fun of(map: Map<BaseDim, Int>) = Dimension(map.filterValues { it != 0 })+        private fun base(d: BaseDim) = of(mapOf(d to 1))++        private fun merge(a: Map<BaseDim, Int>, b: Map<BaseDim, Int>, sign: Int): Map<BaseDim, Int> {+            val out = a.toMutableMap()+            for ((k, v) in b) out[k] = (out[k] ?: 0) + sign * v+            return out+        }++        // Base dimensions.+        val LENGTH = base(BaseDim.LENGTH)+        val MASS = base(BaseDim.MASS)+        val TIME = base(BaseDim.TIME)+        val CURRENT = base(BaseDim.CURRENT)+        val TEMPERATURE = base(BaseDim.TEMPERATURE)+        val AMOUNT = base(BaseDim.AMOUNT)+        val INFORMATION = base(BaseDim.INFORMATION)+        val CURRENCY = base(BaseDim.CURRENCY)++        // Common derived dimensions.+        val AREA = LENGTH.pow(2)+        val VOLUME = LENGTH.pow(3)+        val SPEED = LENGTH / TIME+        val FREQUENCY = TIME.pow(-1)+        val FORCE = MASS * LENGTH / TIME.pow(2)+        val ENERGY = FORCE * LENGTH+        val POWER = ENERGY / TIME+        val PRESSURE = FORCE / AREA+        val CHARGE = CURRENT * TIME+        val VOLTAGE = POWER / CURRENT+        val RESISTANCE = VOLTAGE / CURRENT+        val CAPACITANCE = CHARGE / VOLTAGE+    }+}++/**+ * A magnitude with a [dimension], as produced by evaluating an expression node.+ *+ * [value] is the linear magnitude in coherent base units (m, kg, s, …). Temperature is affine+ * and gets special treatment: [value] is a **kelvin-sized delta** and [tempOffsetK] distinguishes+ * an *absolute* temperature (`tempOffsetK != null`, absolute kelvin = `value + tempOffsetK`) from+ * a *delta* (`tempOffsetK == null`).+ *+ * The user's rule for `+`/`-` chains of temperatures (example `200k - 5c → 195K`): the first+ * temperature is absolute; each one added/subtracted onto it contributes only its degree-size+ * (its [value]), so `5c` behaves like a 5 K offset rather than 278.15 K.+ */+class Quantity(+    val value: Double,+    val dimension: Dimension,+    val tempOffsetK: Double? = null,+    /**+     * True when this is an absolute point in time (a date/datetime), as opposed to a duration.+     * Only meaningful for [Dimension.TIME]: an instant holds epoch seconds in [value]. Instants+     * combine with durations (instant ± duration = instant) and with each other only by+     * subtraction (instant − instant = duration); every other operation is rejected.+     */+    val instant: Boolean = false,+) {+    val isDimensionless: Boolean get() = dimension.isDimensionless+    private val isTemperature: Boolean get() = dimension == Dimension.TEMPERATURE++    operator fun unaryMinus() = Quantity(-value, dimension, tempOffsetK)++    operator fun plus(other: Quantity) = addOrSub(other, 1.0)+    operator fun minus(other: Quantity) = addOrSub(other, -1.0)++    private fun addOrSub(other: Quantity, sign: Double): Quantity {+        if (dimension != other.dimension) {+            throw ExpressionError("Cannot add or subtract incompatible units")+        }+        if (isTemperature) {+            // The right operand always collapses to its degree-size (a delta).+            val rightDelta = other.value+            return if (tempOffsetK != null) {+                // Absolute left: fold into absolute kelvin, then re-normalise (offset 0).+                Quantity((value + tempOffsetK) + sign * rightDelta, Dimension.TEMPERATURE, 0.0)+            } else {+                Quantity(value + sign * rightDelta, Dimension.TEMPERATURE, null)+            }+        }+        if (instant || other.instant) {+            // Both operands are TIME here (the dimension check above passed). Dates are absolute+            // points; they combine with durations, and subtract from each other to give a span.+            return addOrSubInstant(other, sign)+        }+        return Quantity(value + sign * other.value, dimension, null)+    }++    private fun addOrSubInstant(other: Quantity, sign: Double): Quantity {+        if (instant && other.instant) {+            if (sign > 0) throw ExpressionError("Cannot add two dates together")+            return Quantity(value - other.value, Dimension.TIME) // date − date = duration+        }+        if (instant) {+            return Quantity(value + sign * other.value, Dimension.TIME, instant = true) // date ± duration+        }+        if (sign < 0) throw ExpressionError("Cannot subtract a date from a duration")+        return Quantity(value + other.value, Dimension.TIME, instant = true) // duration + date+    }++    operator fun times(other: Quantity): Quantity {+        if (instant || other.instant) throw ExpressionError("A date only supports + or − with a duration")+        // A dimensionless scalar scales the other operand and preserves its temperature offset,+        // which is what turns `20 * celsius` into an absolute 293.15 K.+        if (isDimensionless && tempOffsetK == null) {+            return Quantity(value * other.value, other.dimension, other.tempOffsetK)+        }+        if (other.isDimensionless && other.tempOffsetK == null) {+            return Quantity(value * other.value, dimension, tempOffsetK)+        }+        // Two dimensional operands: combine dimensions; any temperature collapses to a delta.+        return Quantity(value * other.value, dimension * other.dimension, null)+    }++    operator fun div(other: Quantity): Quantity {+        if (instant || other.instant) throw ExpressionError("A date only supports + or − with a duration")+        if (other.isDimensionless && other.tempOffsetK == null) {+            return Quantity(value / other.value, dimension, tempOffsetK)+        }+        return Quantity(value / other.value, dimension / other.dimension, null)+    }++    operator fun rem(other: Quantity): Quantity {+        if (instant || other.instant) throw ExpressionError("A date only supports + or − with a duration")+        if (!other.isDimensionless && dimension != other.dimension) {+            throw ExpressionError("Cannot take the remainder of incompatible units")+        }+        return Quantity(value % other.value, dimension, null)+    }++    fun pow(other: Quantity): Quantity {+        if (instant || other.instant) throw ExpressionError("A date only supports + or − with a duration")+        val n = checkPowExponent(other)+        if (isDimensionless) return Quantity(value.pow(n), Dimension.NONE)+        return Quantity(value.pow(n), dimension.pow(n.toInt()))+    }++    private fun checkPowExponent(other: Quantity): Double {+        if (!other.isDimensionless) throw ExpressionError("Exponent must be dimensionless")+        val n = other.value+        if (n != floor(n)) throw ExpressionError("Cannot raise a unit to a non-integer power")+        return n+    }++    fun abs(): Quantity = Quantity(kotlin.math.abs(value), dimension, tempOffsetK)++    companion object {+        fun scalar(value: Double) = Quantity(value, Dimension.NONE)+    }+}++/**+ * One unit the user can pick. [token] is the ASCII spelling the parser understands (inserted+ * by the keypad picker, e.g. `degC`, `um`, `ohm`); [symbol] is the pretty display form+ * (`°C`, `µm`, `Ω`); [aliases] are extra spellings the parser also accepts (e.g. `c` for `degC`).+ *+ * [factorToBase] scales a magnitude to coherent base units. [offsetK] is set only for affine+ * temperature units and is the absolute kelvin at zero of the unit (0 for K, 273.15 for °C).+ */+class UnitDef(+    val token: String,+    val symbol: String,+    val name: String,+    val dimension: Dimension,+    val factorToBase: Double,+    val offsetK: Double? = null,+    val aliases: List<String> = emptyList(),+) {+    /** Magnitude in this unit → coherent base value (absolute kelvin for temperatures). */+    fun toBase(magnitude: Double): Double = magnitude * factorToBase + (offsetK ?: 0.0)++    /** Coherent base value → magnitude in this unit. */+    fun fromBase(baseValue: Double): Double = (baseValue - (offsetK ?: 0.0)) / factorToBase+}++/** A named group of units, shown as one tab in the converter. */+class UnitCategory(+    val name: String,+    val units: List<UnitDef>,+    /** Whether these units are also usable inside equations (angle units are converter-only). */+    val inEquations: Boolean = true,+)
calendar/src/main/java/com/vayunmathur/calendar/glance/CalendarGlanceWidget.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/glance/CalendarGlanceWidget.kt b/calendar/src/main/java/com/vayunmathur/calendar/glance/CalendarGlanceWidget.ktindex c48d81c22a..0e03d84309 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/glance/CalendarGlanceWidget.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/glance/CalendarGlanceWidget.kt@@ -43,6 +43,7 @@ import com.vayunmathur.calendar.R import com.vayunmathur.calendar.ui.atEndOfDayIn import com.vayunmathur.calendar.ui.dateRangeString import com.vayunmathur.library.ui.DateString+import com.vayunmathur.library.ui.R as UiR import com.vayunmathur.library.widgets.DynamicThemeGlance import kotlinx.datetime.DatePeriod import kotlinx.datetime.LocalDate@@ -199,7 +200,7 @@ fun Content(context: Context, positionedEvents: Map<LocalDate, List<Instance>>)  /** "Today"/"Tomorrow" for those days, otherwise the weekday + date. */ private fun dayHeaderLabel(day: LocalDate, today: LocalDate, context: Context): String = when (day) {-    today -> context.getString(R.string.today)+    today -> context.getString(UiR.string.today)     today + DatePeriod(days = 1) -> context.getString(R.string.tomorrow)     else -> DateString.dateWeekday(day) }
calendar/src/main/java/com/vayunmathur/calendar/ui/HolidayCalendarsScreen.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/ui/HolidayCalendarsScreen.kt b/calendar/src/main/java/com/vayunmathur/calendar/ui/HolidayCalendarsScreen.ktindex 6767bdb42a..47b7c609ef 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/ui/HolidayCalendarsScreen.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/ui/HolidayCalendarsScreen.kt@@ -169,7 +169,7 @@ fun HolidayCalendarsScreen(viewModel: CalendarViewModel, backStack: NavBackStack                         value = langQuery,                         onValueChange = { langQuery = it },                         modifier = Modifier.fillMaxWidth().padding(bottom = 8.dp),-                        label = { Text(stringResource(R.string.search)) },+                        label = { Text(stringResource(UiR.string.search)) },                         singleLine = true,                     )                     LazyColumn(modifier = Modifier.height(360.dp)) {
calendar/src/main/java/com/vayunmathur/calendar/ui/IcsParser.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/ui/IcsParser.kt b/calendar/src/main/java/com/vayunmathur/calendar/ui/IcsParser.ktindex 2b8b5d24c1..1e4c4c57fc 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/ui/IcsParser.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/ui/IcsParser.kt@@ -2,19 +2,11 @@ package com.vayunmathur.calendar.ui  import android.util.Log import com.vayunmathur.calendar.data.Event-import com.vayunmathur.calendar.util.AllDayFormat-import com.vayunmathur.calendar.util.BasicIsoInstantFormat import com.vayunmathur.calendar.util.RRule-import kotlinx.datetime.LocalDate-import kotlinx.datetime.LocalDateTime import kotlinx.datetime.TimeZone-import kotlinx.datetime.atStartOfDayIn-import kotlinx.datetime.format.char-import kotlinx.datetime.toInstant import kotlinx.datetime.toLocalDateTime import java.io.BufferedInputStream import java.io.InputStream-import kotlin.time.Duration import kotlin.time.Duration.Companion.days import kotlin.time.Instant @@ -198,156 +190,3 @@ private fun buildEventFromProps(     }     return added }--/** Reverses RFC 5545 TEXT escaping. */-internal fun unescapeIcsText(value: String): String {-    if ('\\' !in value) return value-    val out = StringBuilder(value.length)-    var i = 0-    while (i < value.length) {-        val c = value[i]-        if (c == '\\' && i + 1 < value.length) {-            when (val next = value[i + 1]) {-                'n', 'N' -> out.append('\n')-                else -> out.append(next)-            }-            i += 2-        } else {-            out.append(c)-            i++-        }-    }-    return out.toString()-}--/** The days a set of RDATE or EXDATE lines names, in [zone]. */-internal fun parseIcsDates(props: List<Pair<String, String>>, zone: TimeZone): List<LocalDate> =-    props.flatMap { (left, values) -> values.split(",").map { left to it.trim() } }-        .mapNotNull { (left, value) ->-            if (value.length == 8 && value.all { it.isDigit() }) {-                runCatching { AllDayFormat.parse(value) }.getOrNull()-            } else {-                parseICSTime(left, value).first?.let {-                    Instant.fromEpochMilliseconds(it).toLocalDateTime(zone).date-                }-            }-        }-        .distinct()-        .sorted()--// Parse ICS time value with optional params-left (like DTSTART;TZID=America/Los_Angeles)-internal fun parseICSTime(propLeft: String?, value: String?): Triple<Long?, Boolean, String?> {-    if (value == null) return Triple(null, false, null)--    val left = propLeft ?: ""-    val up = left.uppercase()--    val isAllDay = up.contains("VALUE=DATE") || value.length == 8 && value.all { it.isDigit() }--    return try {-        if (isAllDay) {-            val dt = AllDayFormat.parse(value)-            val start = dt.atStartOfDayIn(TimeZone.UTC).toEpochMilliseconds()-            Triple(start, true, "UTC")-        } else {-            if (value.endsWith("Z")) {-                val instant = runCatching { BasicIsoInstantFormat.parse(value).toInstantUsingOffset() }-                    .getOrElse { Instant.parse(value) }-                Triple(instant.toEpochMilliseconds(), false, "UTC")-            } else if (hasExplicitOffset(value)) {-                val instant = runCatching { BasicIsoInstantFormat.parse(value).toInstantUsingOffset() }-                    .getOrElse { Instant.parse(value) }-                Triple(instant.toEpochMilliseconds(), false, "UTC")-            } else {-                val tzid = extractTZID(left)-                val parsed = parseFloatingTime(value, tzid)-                if (parsed != null) {-                    Triple(parsed.toEpochMilliseconds(), false,-                        tzid ?: TimeZone.currentSystemDefault().id)-                } else {-                    Triple(null, false, tzid)-                }-            }-        }-    } catch (expected: Exception) {-        Log.e("IcsImport", "Error parsing ICS time: $value", expected)-        Triple(null, false, null)-    }-}--internal fun extractTZID(left: String): String? =-    left.split(';')-        .map { it.split('=', limit = 2) }-        .firstOrNull { it.size == 2 && it[0].uppercase() == "TZID" }-        ?.get(1)--/** Parses a floating (offset-less) ICS datetime in [tzid], trying each known format. */-private fun parseFloatingTime(value: String, tzid: String?): Instant? {-    val candidates = listOf(-        DateTimeFormat, DateTimeShortFormat, DashedDateTimeFormat, DashedDateTimeShortFormat,-    )-    for (fmt in candidates) {-        try {-            val ldt = LocalDateTime.parse(value, fmt)-            val zone = tzid?.let { TimeZone.of(it) } ?: TimeZone.currentSystemDefault()-            return ldt.toInstant(zone)-        } catch (_: IllegalArgumentException) {-            // try next candidate-        }-    }-    return null-}--internal fun tryParseDurationMillis(duration: String, startMillis: Long): Long? =-    runCatching { startMillis + Duration.parse(duration).inWholeMilliseconds }.getOrNull()--// Formats for local times without offset-val DateTimeFormat = LocalDateTime.Format {-    year(); monthNumber(); day()-    char('T')-    hour(); minute(); second()-}--val DateTimeShortFormat = LocalDateTime.Format {-    year(); monthNumber(); day()-    char('T')-    hour(); minute()-}--// Dashed ISO-8601 floating forms (e.g. 2025-01-01T09:00:00).-val DashedDateTimeFormat = LocalDateTime.Format {-    year(); char('-'); monthNumber(); char('-'); day()-    char('T')-    hour(); char(':'); minute(); char(':'); second()-}--val DashedDateTimeShortFormat = LocalDateTime.Format {-    year(); char('-'); monthNumber(); char('-'); day()-    char('T')-    hour(); char(':'); minute()-}--/** True when [value] carries an explicit numeric UTC offset (not a date dash). */-internal fun hasExplicitOffset(value: String): Boolean {-    if ('+' in value) return true-    val tIndex = value.indexOf('T')-    if (tIndex < 0) return false-    return '-' in value.substring(tIndex + 1)-}--/**- * Parses a VALARM TRIGGER value to minutes-before-start, or null when it cannot be expressed- * that way. Handles negative durations, zero (at-start = 0), and duration-with-absolute-time- * forms (keeps only the duration half before ';'). Absolute datetimes and positive- * (post-start) durations return null.- */-internal fun parseTriggerMinutesBefore(raw: String): Int? {-    val durationPart = raw.substringBefore(';').trim()-    if (durationPart.isEmpty()) return null-    val s = durationPart.uppercase()-    if (!s.startsWith("P") && !s.startsWith("-P")) return null-    val duration = runCatching { Duration.parse(durationPart) }.getOrNull() ?: return null-    if (duration.isPositive()) return null-    val minutes = duration.absoluteValue.inWholeMinutes-    return if (minutes > Int.MAX_VALUE) Int.MAX_VALUE else minutes.toInt()-}
calendar/src/main/java/com/vayunmathur/calendar/ui/IcsParserFormats.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/ui/IcsParserFormats.kt b/calendar/src/main/java/com/vayunmathur/calendar/ui/IcsParserFormats.ktnew file mode 100644index 0000000000..1a3b9f6893--- /dev/null+++ b/calendar/src/main/java/com/vayunmathur/calendar/ui/IcsParserFormats.kt@@ -0,0 +1,167 @@+package com.vayunmathur.calendar.ui++import android.util.Log+import com.vayunmathur.calendar.util.AllDayFormat+import com.vayunmathur.calendar.util.BasicIsoInstantFormat+import kotlinx.datetime.LocalDate+import kotlinx.datetime.LocalDateTime+import kotlinx.datetime.TimeZone+import kotlinx.datetime.atStartOfDayIn+import kotlinx.datetime.format.char+import kotlinx.datetime.toInstant+import kotlinx.datetime.toLocalDateTime+import kotlin.time.Duration+import kotlin.time.Instant++/** Reverses RFC 5545 TEXT escaping. */+internal fun unescapeIcsText(value: String): String {+    if ('\\' !in value) return value+    val out = StringBuilder(value.length)+    var i = 0+    while (i < value.length) {+        val c = value[i]+        if (c == '\\' && i + 1 < value.length) {+            when (val next = value[i + 1]) {+                'n', 'N' -> out.append('\n')+                else -> out.append(next)+            }+            i += 2+        } else {+            out.append(c)+            i+++        }+    }+    return out.toString()+}++/** The days a set of RDATE or EXDATE lines names, in [zone]. */+internal fun parseIcsDates(props: List<Pair<String, String>>, zone: TimeZone): List<LocalDate> =+    props.flatMap { (left, values) -> values.split(",").map { left to it.trim() } }+        .mapNotNull { (left, value) ->+            if (value.length == 8 && value.all { it.isDigit() }) {+                runCatching { AllDayFormat.parse(value) }.getOrNull()+            } else {+                parseICSTime(left, value).first?.let {+                    Instant.fromEpochMilliseconds(it).toLocalDateTime(zone).date+                }+            }+        }+        .distinct()+        .sorted()++// Parse ICS time value with optional params-left (like DTSTART;TZID=America/Los_Angeles)+internal fun parseICSTime(propLeft: String?, value: String?): Triple<Long?, Boolean, String?> {+    if (value == null) return Triple(null, false, null)++    val left = propLeft ?: ""+    val up = left.uppercase()++    val isAllDay = up.contains("VALUE=DATE") || value.length == 8 && value.all { it.isDigit() }++    return try {+        if (isAllDay) {+            val dt = AllDayFormat.parse(value)+            val start = dt.atStartOfDayIn(TimeZone.UTC).toEpochMilliseconds()+            Triple(start, true, "UTC")+        } else {+            if (value.endsWith("Z")) {+                val instant = runCatching { BasicIsoInstantFormat.parse(value).toInstantUsingOffset() }+                    .getOrElse { Instant.parse(value) }+                Triple(instant.toEpochMilliseconds(), false, "UTC")+            } else if (hasExplicitOffset(value)) {+                val instant = runCatching { BasicIsoInstantFormat.parse(value).toInstantUsingOffset() }+                    .getOrElse { Instant.parse(value) }+                Triple(instant.toEpochMilliseconds(), false, "UTC")+            } else {+                val tzid = extractTZID(left)+                val parsed = parseFloatingTime(value, tzid)+                if (parsed != null) {+                    Triple(parsed.toEpochMilliseconds(), false,+                        tzid ?: TimeZone.currentSystemDefault().id)+                } else {+                    Triple(null, false, tzid)+                }+            }+        }+    } catch (expected: Exception) {+        Log.e("IcsImport", "Error parsing ICS time: $value", expected)+        Triple(null, false, null)+    }+}++internal fun extractTZID(left: String): String? =+    left.split(';')+        .map { it.split('=', limit = 2) }+        .firstOrNull { it.size == 2 && it[0].uppercase() == "TZID" }+        ?.get(1)++/** Parses a floating (offset-less) ICS datetime in [tzid], trying each known format. */+private fun parseFloatingTime(value: String, tzid: String?): Instant? {+    val candidates = listOf(+        DateTimeFormat, DateTimeShortFormat, DashedDateTimeFormat, DashedDateTimeShortFormat,+    )+    for (fmt in candidates) {+        try {+            val ldt = LocalDateTime.parse(value, fmt)+            val zone = tzid?.let { TimeZone.of(it) } ?: TimeZone.currentSystemDefault()+            return ldt.toInstant(zone)+        } catch (_: IllegalArgumentException) {+            // try next candidate+        }+    }+    return null+}++internal fun tryParseDurationMillis(duration: String, startMillis: Long): Long? =+    runCatching { startMillis + Duration.parse(duration).inWholeMilliseconds }.getOrNull()++// Formats for local times without offset+val DateTimeFormat = LocalDateTime.Format {+    year(); monthNumber(); day()+    char('T')+    hour(); minute(); second()+}++val DateTimeShortFormat = LocalDateTime.Format {+    year(); monthNumber(); day()+    char('T')+    hour(); minute()+}++// Dashed ISO-8601 floating forms (e.g. 2025-01-01T09:00:00).+val DashedDateTimeFormat = LocalDateTime.Format {+    year(); char('-'); monthNumber(); char('-'); day()+    char('T')+    hour(); char(':'); minute(); char(':'); second()+}++val DashedDateTimeShortFormat = LocalDateTime.Format {+    year(); char('-'); monthNumber(); char('-'); day()+    char('T')+    hour(); char(':'); minute()+}++/** True when [value] carries an explicit numeric UTC offset (not a date dash). */+internal fun hasExplicitOffset(value: String): Boolean {+    if ('+' in value) return true+    val tIndex = value.indexOf('T')+    if (tIndex < 0) return false+    return '-' in value.substring(tIndex + 1)+}++/**+ * Parses a VALARM TRIGGER value to minutes-before-start, or null when it cannot be expressed+ * that way. Handles negative durations, zero (at-start = 0), and duration-with-absolute-time+ * forms (keeps only the duration half before ';'). Absolute datetimes and positive+ * (post-start) durations return null.+ */+internal fun parseTriggerMinutesBefore(raw: String): Int? {+    val durationPart = raw.substringBefore(';').trim()+    if (durationPart.isEmpty()) return null+    val s = durationPart.uppercase()+    if (!s.startsWith("P") && !s.startsWith("-P")) return null+    val duration = runCatching { Duration.parse(durationPart) }.getOrNull() ?: return null+    if (duration.isPositive()) return null+    val minutes = duration.absoluteValue.inWholeMinutes+    return if (minutes > Int.MAX_VALUE) Int.MAX_VALUE else minutes.toInt()+}
calendar/src/main/java/com/vayunmathur/calendar/ui/dialogs/SettingsAddCalendarDialog.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/ui/dialogs/SettingsAddCalendarDialog.kt b/calendar/src/main/java/com/vayunmathur/calendar/ui/dialogs/SettingsAddCalendarDialog.ktindex 7e1da49f50..255604d8ab 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/ui/dialogs/SettingsAddCalendarDialog.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/ui/dialogs/SettingsAddCalendarDialog.kt@@ -78,7 +78,7 @@ fun SettingsAddCalendarDialog(viewModel: CalendarViewModel, backStack: NavBackSt                 val accessLevel = android.provider.CalendarContract.Calendars.CAL_ACCESS_EDITOR                 viewModel.createLocalCalendar("Offline Calendar", newDisplayName.ifEmpty { "New Calendar" }, newColor, true, accessLevel)                 backStack.pop()-            }) { Text(stringResource(R.string.create)) }+            }) { Text(stringResource(UiR.string.create)) }         },         dismissButton = {             Button(onClick = { backStack.pop() }) { Text(stringResource(UiR.string.cancel)) }
calendar/src/main/java/com/vayunmathur/calendar/ui/dialogs/TimezonePickerDialog.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/ui/dialogs/TimezonePickerDialog.kt b/calendar/src/main/java/com/vayunmathur/calendar/ui/dialogs/TimezonePickerDialog.ktindex ca4c66cba5..5124d70a5c 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/ui/dialogs/TimezonePickerDialog.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/ui/dialogs/TimezonePickerDialog.kt@@ -62,7 +62,7 @@ fun TimezonePickerDialog(backStack: NavBackStack<com.vayunmathur.calendar.Route>         text = {             Column {                 // Search field-                OutlinedTextField(value = query, onValueChange = { query = it }, modifier = Modifier.fillMaxWidth().padding(bottom = 8.dp), label = { Text(stringResource(R.string.search)) })+                OutlinedTextField(value = query, onValueChange = { query = it }, modifier = Modifier.fillMaxWidth().padding(bottom = 8.dp), label = { Text(stringResource(UiR.string.search)) })                  // Scrollable list of zones with offsets                 LazyColumn(modifier = Modifier.height(360.dp)) {
calendar/src/main/res/values/strings.xml
diff --git a/calendar/src/main/res/values/strings.xml b/calendar/src/main/res/values/strings.xmlindex cc4c27728f..1c45e98366 100644--- a/calendar/src/main/res/values/strings.xml+++ b/calendar/src/main/res/values/strings.xml@@ -58,13 +58,8 @@     </plurals>      <!-- Common actions: generic buttons used across dialogs -->-    <!-- Generic create action. Verb. Creates new item -->-    <string name="create">Create</string>     <!-- Event details: button to add a reminder/notification for event -->     <string name="add_reminder">Add reminder</string>-    <!-- Toolbar: search events. Verb. -->-    <string name="search">Search</string>-     <!-- Event display: titles and date formatting -->     <!-- Shown when event has empty title -->     <string name="no_title">(No title)</string>@@ -367,6 +362,5 @@     <!-- ReminderReceiver: Notification body. %1$s = formatted event start time, e.g. 3:00 PM -->     <string name="reminder_notification_text">Starts at <xliff:g id="start_time" example="3:00 PM">%1$s</xliff:g></string>     <!-- Calendar widget day-group headers for the current/next day -->-    <string name="today">Today</string>     <string name="tomorrow">Tomorrow</string> </resources>
camera/src/main/java/com/vayunmathur/camera/platform/CameraCapabilities.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/platform/CameraCapabilities.kt b/camera/src/main/java/com/vayunmathur/camera/platform/CameraCapabilities.ktindex 6d90fe379f..9c1c4116e1 100644--- a/camera/src/main/java/com/vayunmathur/camera/platform/CameraCapabilities.kt+++ b/camera/src/main/java/com/vayunmathur/camera/platform/CameraCapabilities.kt@@ -1,7 +1,6 @@ package com.vayunmathur.camera.platform  import android.util.Log-import androidx.camera.camera2.interop.ExperimentalCamera2Interop import androidx.camera.core.Camera import com.vayunmathur.camera.domain.LensSelectionLogic import com.vayunmathur.camera.util.CameraViewModel@@ -40,7 +39,6 @@ data class LensCapabilities(  * Call on the main thread (LiveData `observeForever` expects it); the heavier  * extension probe hops to Dispatchers.Default like the UI's launcher effect.  */-@OptIn(ExperimentalCamera2Interop::class) suspend fun CameraViewModel.refreshCapabilities(bound: Camera, lensId: String?) {     val (minZoom, maxZoom) = readZoomBounds(bound)     updateZoomLevels(minZoom, maxZoom)
camera/src/main/java/com/vayunmathur/camera/platform/LensSelector.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/platform/LensSelector.kt b/camera/src/main/java/com/vayunmathur/camera/platform/LensSelector.ktindex 8e50e95ce3..2e1001eb5b 100644--- a/camera/src/main/java/com/vayunmathur/camera/platform/LensSelector.kt+++ b/camera/src/main/java/com/vayunmathur/camera/platform/LensSelector.kt@@ -4,7 +4,6 @@ import android.hardware.camera2.CameraCharacteristics import android.hardware.camera2.CameraMetadata import android.util.Log import androidx.camera.camera2.interop.Camera2CameraInfo-import androidx.camera.camera2.interop.ExperimentalCamera2Interop import androidx.camera.core.Camera import androidx.camera.core.CameraSelector import androidx.camera.lifecycle.ProcessCameraProvider@@ -40,7 +39,6 @@ fun Int.toLensFacing(): LensFacing? = when (this) {  *  * Safe to call off the main thread; never throws (returns empty on failure).  */-@OptIn(ExperimentalCamera2Interop::class) fun enumerateLenses(provider: ProcessCameraProvider): List<PhysicalLens> {     val raws = provider.availableCameraInfos.mapNotNull { info -> readRawLens(info) } @@ -54,7 +52,6 @@ private const val ULTRA_WIDE_RATIO = 0.85f private const val TELEPHOTO_RATIO = 1.4f  /** Reads one camera info's physical-lens description; null when unusable. */-@OptIn(ExperimentalCamera2Interop::class) private fun readRawLens(info: androidx.camera.core.CameraInfo): RawLens? {     return try {         readRawLensOrThrow(info)@@ -65,7 +62,7 @@ private fun readRawLens(info: androidx.camera.core.CameraInfo): RawLens? { }  /** Physical-lens description probed off one CameraInfo (null for external/unknown lenses). */-@OptIn(ExperimentalCamera2Interop::class)+@Suppress("DEPRECATION") private fun readRawLensOrThrow(info: androidx.camera.core.CameraInfo): RawLens? {     val cam2 = Camera2CameraInfo.from(info)     val facing = when (@@ -201,7 +198,7 @@ fun CameraViewModel.currentLensFamily(): List<PhysicalLens> {  * the logical camera ID when non-null. A null lens keeps the legacy facing-only  * behavior.  */-@OptIn(ExperimentalCamera2Interop::class)+@Suppress("DEPRECATION") fun CameraViewModel.lensSelector(facingInt: Int, lens: PhysicalLens?): CameraSelector {     val builder = CameraSelector.Builder().requireLensFacing(facingInt)     if (lens != null) {
camera/src/main/java/com/vayunmathur/camera/ui/CameraPreviewBox.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/ui/CameraPreviewBox.kt b/camera/src/main/java/com/vayunmathur/camera/ui/CameraPreviewBox.ktindex ebdd8e8f78..e36f3160b2 100644--- a/camera/src/main/java/com/vayunmathur/camera/ui/CameraPreviewBox.kt+++ b/camera/src/main/java/com/vayunmathur/camera/ui/CameraPreviewBox.kt@@ -118,7 +118,7 @@ internal fun BoxWithConstraintsScope.CameraPreviewBox(                         ) {                             val localMask = currentMask                             val shader = bokehShader?.value-                            if (shader != null && localMask != null &&+                            if (shader != null &&                                 !localMask.isRecycled &&                                 size.width > 0 && size.height > 0                             ) {
camera/src/main/java/com/vayunmathur/camera/util/CameraManualControls.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/CameraManualControls.kt b/camera/src/main/java/com/vayunmathur/camera/util/CameraManualControls.ktindex 9f5a05b80c..1d3e2bf6cb 100644--- a/camera/src/main/java/com/vayunmathur/camera/util/CameraManualControls.kt+++ b/camera/src/main/java/com/vayunmathur/camera/util/CameraManualControls.kt@@ -1,7 +1,6 @@ package com.vayunmathur.camera.util  import android.util.Log-import androidx.camera.camera2.interop.ExperimentalCamera2Interop  fun CameraViewModel.setExposureTimeIndex(index: Int) {     exposureTimeIndexMutable.value = index.coerceIn(0, CameraViewModel.EXPOSURE_TIME_STOPS.lastIndex)@@ -14,7 +13,7 @@ fun CameraViewModel.setManualIsoIndex(index: Int) {     applyManualControls() } -@OptIn(ExperimentalCamera2Interop::class)+@Suppress("DEPRECATION") internal fun CameraViewModel.camera2ControlOrNull(): androidx.camera.camera2.interop.Camera2CameraControl? = try {     boundCamera?.cameraControl?.let {         androidx.camera.camera2.interop.Camera2CameraControl.from(it)@@ -38,7 +37,7 @@ internal fun CameraViewModel.isExposureAuto(): Boolean =  * the options are cleared, reverting to CameraX's default auto behavior (including tap-to-focus).  * Called on every manual-control change and re-applied after a session rebind.  */-@OptIn(ExperimentalCamera2Interop::class)+@Suppress("DEPRECATION") fun CameraViewModel.applyManualControls() {     val cam2 = camera2ControlOrNull() ?: return     val builder = androidx.camera.camera2.interop.CaptureRequestOptions.Builder()@@ -73,7 +72,7 @@ fun CameraViewModel.applyManualControls() { }  /** Reads the bound sensor's ISO range → stop list for the manual ISO control. */-@OptIn(ExperimentalCamera2Interop::class)+@Suppress("DEPRECATION") internal fun CameraViewModel.readManualControlRanges() {     Log.d(         "NightPreview",
camera/src/main/java/com/vayunmathur/camera/util/CameraNightCapture.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/CameraNightCapture.kt b/camera/src/main/java/com/vayunmathur/camera/util/CameraNightCapture.ktindex c2c3a2f8cc..de714a0e7c 100644--- a/camera/src/main/java/com/vayunmathur/camera/util/CameraNightCapture.kt+++ b/camera/src/main/java/com/vayunmathur/camera/util/CameraNightCapture.kt@@ -5,7 +5,6 @@ import android.graphics.Matrix import android.graphics.Rect import android.net.Uri import android.util.Log-import androidx.camera.camera2.interop.ExperimentalCamera2Interop import androidx.camera.core.ImageCapture import androidx.camera.core.ImageCaptureException import androidx.camera.core.ImageProxy@@ -31,6 +30,7 @@ import kotlin.math.roundToInt  * moon button keeps tracking brightness. The extension does its own timing, so no manual  * long-exposure countdown here.  */+@Suppress("DEPRECATION") internal suspend fun CameraViewModel.captureNightPhotoExtension() {     isCapturingMutable.value = true     // Drop the photo session so the UI's analyzer effect re-attaches PhotoAnalyzer once we restore.@@ -171,7 +171,7 @@ private suspend fun CameraViewModel.mergeNightFrames(frames: List<Bitmap>): Uri?  * Falls back to empty list if [imageCapture] is unavailable, which makes  * [captureNightPhotoCustom] fall back to single-frame long-exposure.  */-@OptIn(ExperimentalCamera2Interop::class)+@Suppress("DEPRECATION") internal fun CameraViewModel.captureNightBurst(exposure: NightExposure, onDone: (List<Bitmap>) -> Unit) {     if (imageCapture == null) {         onDone(emptyList())@@ -189,7 +189,7 @@ internal fun CameraViewModel.captureNightBurst(exposure: NightExposure, onDone: }  /** Camera2 control handle; null (logged) when unavailable. */-@OptIn(ExperimentalCamera2Interop::class)+@Suppress("DEPRECATION") private fun CameraViewModel.camera2ControlQuietly():     androidx.camera.camera2.interop.Camera2CameraControl? {     return try {@@ -207,7 +207,7 @@ private fun CameraViewModel.camera2ControlQuietly():  * captures back-to-back, converts each to an upright bitmap and restores 3A + the  * manual-control state when done.  */-@OptIn(ExperimentalCamera2Interop::class)+@Suppress("DEPRECATION") private class NightBurstDriver(     private val viewModel: CameraViewModel,     private val cam2Control: androidx.camera.camera2.interop.Camera2CameraControl?,@@ -307,6 +307,7 @@ private class NightBurstDriver( }  /** Locks AE off + night exposure/ISO + AWB, then runs [onLocked]. Falls through on failure. */+@Suppress("DEPRECATION") private fun CameraViewModel.lockNightExposure(     cam2Control: androidx.camera.camera2.interop.Camera2CameraControl,     exposure: NightExposure,@@ -348,7 +349,7 @@ internal data class NightExposure(val nanos: Long, val iso: Int?)  * into the sensor's exposure-time range and picks a high fraction of its sensitivity range.  * Falls back to [targetNanos] (and auto ISO) if the characteristics are unavailable.  */-@OptIn(ExperimentalCamera2Interop::class)+@Suppress("DEPRECATION") internal fun CameraViewModel.computeNightExposure(     targetNanos: Long = CameraViewModel.NIGHT_TARGET_EXPOSURE_NANOS ): NightExposure {
camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoSessionSetup.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoSessionSetup.kt b/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoSessionSetup.ktindex 0b65bbac72..01076b57df 100644--- a/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoSessionSetup.kt+++ b/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoSessionSetup.kt@@ -24,7 +24,6 @@ import com.vayunmathur.camera.platform.refreshCapabilities  * limits, it falls back to a default ImageCapture resolution. ImageAnalysis is always  * capped (~1.2 MP) — see the note in [CameraViewModel.bindSession].  */-@OptIn(androidx.camera.camera2.interop.ExperimentalCamera2Interop::class) suspend fun CameraViewModel.setupPhotoSession(): Boolean {     Log.d(         "NightPreview",@@ -66,7 +65,6 @@ internal data class PhotoSessionPrep( )  /** Binds provider/owner/preview and probes Ultra HDR; the bind ladder runs next. */-@OptIn(androidx.camera.camera2.interop.ExperimentalCamera2Interop::class) internal suspend fun CameraViewModel.preparePhotoSession(): PhotoSessionPrep? {     val provider = ProcessCameraProvider.awaitInstance(app)     cameraProvider = provider@@ -105,7 +103,6 @@ internal suspend fun CameraViewModel.preparePhotoSession(): PhotoSessionPrep? { }  /** Runs the max-res → default → plain-JPEG bind ladder and records the bound lens. */-@OptIn(androidx.camera.camera2.interop.ExperimentalCamera2Interop::class) internal suspend fun CameraViewModel.bindPhotoLadder(session: PhotoSessionPrep) {     var boundLensId: String? = null     boundCamera = try {@@ -160,7 +157,6 @@ internal suspend fun CameraViewModel.bindPhotoLadder(session: PhotoSessionPrep) }  /** Binds Preview + ImageCapture + capped ImageAnalysis for the photo session. */-@OptIn(androidx.camera.camera2.interop.ExperimentalCamera2Interop::class) internal fun CameraViewModel.bindPhotoUseCases(     session: PhotoSessionPrep,     lensSelector: CameraSelector,
camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoSessionShared.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoSessionShared.kt b/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoSessionShared.ktindex 58e53ccf47..7f4adc4614 100644--- a/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoSessionShared.kt+++ b/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoSessionShared.kt@@ -12,6 +12,7 @@ import com.vayunmathur.camera.platform.lensSelector  */  /** Attaches the AE snapshot callback to a preview builder ([tag] names the session). */+@Suppress("DEPRECATION") internal fun CameraViewModel.attachAeSnapshot(     previewBuilder: Preview.Builder,     tag: String
camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoSessions.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoSessions.kt b/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoSessions.ktindex 0a1c7f07f9..a57ed2b347 100644--- a/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoSessions.kt+++ b/camera/src/main/java/com/vayunmathur/camera/util/CameraPhotoSessions.kt@@ -2,7 +2,6 @@ package com.vayunmathur.camera.util  import android.util.Log import android.util.Size-import androidx.camera.camera2.interop.ExperimentalCamera2Interop import androidx.camera.core.Camera import androidx.camera.core.CameraSelector import androidx.camera.core.ImageAnalysis@@ -79,6 +78,7 @@ internal data class NightPreviewPrep(  * Resolves provider/manager/lens and probes extension + analysis support.  * Null when the manager is missing (caller falls back to the normal photo session).  */+@Suppress("DEPRECATION") internal suspend fun CameraViewModel.prepareNightPreview(): NightPreviewPrep? {     val provider = ProcessCameraProvider.awaitInstance(app)     cameraProvider = provider
camera/src/main/java/com/vayunmathur/camera/util/CameraPortraitSession.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/CameraPortraitSession.kt b/camera/src/main/java/com/vayunmathur/camera/util/CameraPortraitSession.ktindex 77d36dd953..aafd0109f7 100644--- a/camera/src/main/java/com/vayunmathur/camera/util/CameraPortraitSession.kt+++ b/camera/src/main/java/com/vayunmathur/camera/util/CameraPortraitSession.kt@@ -1,7 +1,6 @@ package com.vayunmathur.camera.util  import android.util.Log-import androidx.camera.camera2.interop.ExperimentalCamera2Interop import androidx.camera.core.Camera import androidx.camera.core.CameraSelector import androidx.camera.core.ImageAnalysis@@ -28,7 +27,6 @@ import com.vayunmathur.camera.platform.refreshCapabilities  * Fallback ladder prioritizes keeping max-res capture:  * capped+max+UHD → capped+max+JPEG → capped+default+UHD → capped+default+JPEG → default+default  */-@OptIn(ExperimentalCamera2Interop::class) suspend fun CameraViewModel.setupPortraitSession(): Boolean {     Log.d(         "NightPreview",@@ -69,7 +67,6 @@ internal data class PortraitSessionPrep( )  /** Binds provider/owner/preview and probes Ultra HDR for the portrait session. */-@OptIn(ExperimentalCamera2Interop::class) internal suspend fun CameraViewModel.preparePortraitSession(): PortraitSessionPrep {     val provider = ProcessCameraProvider.awaitInstance(app)     cameraProvider = provider@@ -146,7 +143,6 @@ internal fun portraitAttempts(ultraHdrSupported: Boolean): List<PortraitAttempt>  * Runs the portrait bind ladder (each resolution rung across the lens ladder),  * keeping max-res capture. Records the bound lens id.  */-@OptIn(ExperimentalCamera2Interop::class) internal suspend fun CameraViewModel.bindPortraitLadder(session: PortraitSessionPrep) {     var bound: Camera? = null     var portraitBoundLensId: String? = null@@ -181,7 +177,6 @@ internal data class PortraitRungResult( )  /** Tries one resolution rung across the lens ladder (requested → wide → any). */-@OptIn(ExperimentalCamera2Interop::class) internal fun CameraViewModel.tryPortraitRungSet(     session: PortraitSessionPrep,     capped: Boolean,@@ -210,7 +205,6 @@ internal fun CameraViewModel.tryPortraitRungSet( internal var portraitLastError: Exception? = null  /** Tries one portrait rung on one lens; true when it binds. */-@OptIn(ExperimentalCamera2Interop::class) internal fun CameraViewModel.tryPortraitRung(     session: PortraitSessionPrep,     candidate: com.vayunmathur.camera.domain.PhysicalLens?,@@ -260,7 +254,6 @@ internal fun CameraViewModel.tryPortraitRung( }  /** Binds Preview + ImageCapture + capped/default ImageAnalysis for portrait. */-@OptIn(ExperimentalCamera2Interop::class) internal fun CameraViewModel.bindPortraitUseCases(     session: PortraitSessionPrep,     candidate: com.vayunmathur.camera.domain.PhysicalLens?,
camera/src/main/java/com/vayunmathur/camera/util/CameraSessions.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/CameraSessions.kt b/camera/src/main/java/com/vayunmathur/camera/util/CameraSessions.ktindex 9e321f797b..8f3357153f 100644--- a/camera/src/main/java/com/vayunmathur/camera/util/CameraSessions.kt+++ b/camera/src/main/java/com/vayunmathur/camera/util/CameraSessions.kt@@ -1,7 +1,6 @@ package com.vayunmathur.camera.util  import android.util.Log-import androidx.camera.camera2.interop.ExperimentalCamera2Interop import androidx.camera.core.Camera import androidx.camera.core.CameraSelector import androidx.camera.core.ImageCapture@@ -161,7 +160,7 @@ internal fun CameraViewModel.hlgSupportedByCamera(cameraInfo: androidx.camera.co  * range exists we return null and let CameraX pick its default, which avoids the  * crop-switch flicker.  */-@OptIn(ExperimentalCamera2Interop::class)+@Suppress("DEPRECATION") internal fun CameraViewModel.highestFpsRange(     cameraInfo: androidx.camera.core.CameraInfo ): android.util.Range<Int>? = try {@@ -204,7 +203,7 @@ internal fun CameraViewModel.highestFpsRange(  * Preferred video stabilization mode for Cinematic: preview-stabilization ("EIS") when the  * device lists it, else on-mode, else null (unsupported → stabilization is skipped).  */-@OptIn(ExperimentalCamera2Interop::class)+@Suppress("DEPRECATION") internal fun CameraViewModel.preferredStabilizationMode(cameraInfo: androidx.camera.core.CameraInfo): Int? = try {     val modes = androidx.camera.camera2.interop.Camera2CameraInfo.from(cameraInfo)         .getCameraCharacteristic(@@ -235,7 +234,7 @@ private const val VIDEO_FPS_STANDARD = 30 private const val VIDEO_FPS_HIGH = 60  /** Applies max-fps + (optional) stabilization capture options onto a Preview/VideoCapture builder. */-@OptIn(ExperimentalCamera2Interop::class)+@Suppress("DEPRECATION") internal fun <T> CameraViewModel.applyVideoCaptureRequestOptions(     builder: androidx.camera.core.ExtendableBuilder<T>,     fpsRange: android.util.Range<Int>?,
camera/src/main/java/com/vayunmathur/camera/util/CameraSingleCapture.kt
diff --git a/camera/src/main/java/com/vayunmathur/camera/util/CameraSingleCapture.kt b/camera/src/main/java/com/vayunmathur/camera/util/CameraSingleCapture.ktindex e066120cd0..c3c7985c70 100644--- a/camera/src/main/java/com/vayunmathur/camera/util/CameraSingleCapture.kt+++ b/camera/src/main/java/com/vayunmathur/camera/util/CameraSingleCapture.kt@@ -5,7 +5,6 @@ import android.graphics.BitmapFactory import android.graphics.Rect import android.net.Uri import android.util.Log-import androidx.camera.camera2.interop.ExperimentalCamera2Interop import androidx.camera.core.ImageCapture import androidx.camera.core.ImageCaptureException import androidx.camera.core.ImageProxy@@ -15,7 +14,6 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -@OptIn(ExperimentalCamera2Interop::class) internal fun CameraViewModel.captureSinglePhoto() {     val capture = imageCapture ?: return     isCapturingMutable.value = true@@ -36,6 +34,7 @@ internal fun CameraViewModel.captureSinglePhoto() { }  /** Everything doCapture/runSingleCapture needs, resolved up front. */+@Suppress("DEPRECATION") private data class SingleCapturePlan(     val capture: ImageCapture,     val pending: PendingStill,@@ -55,7 +54,7 @@ private data class SingleCapturePlan(  * Resolves the capture use cases, night override and preview-effect state.  * Null when there is no save target (caller clears the in-flight flag).  */-@OptIn(ExperimentalCamera2Interop::class)+@Suppress("DEPRECATION") private fun CameraViewModel.buildSingleCapturePlan(pending: PendingStill): SingleCapturePlan? {     val capture = imageCapture ?: return null     val outputOptions = pending.outputOptions@@ -98,7 +97,7 @@ private fun Came

Diff truncated.