various fixes
- Commit
c7e067081374aa8fd4ffaee41208a7b0877ffe3a- Author
- vayun-mathur <[email protected]>
- When
- 2026-10-24 21:12 UTC (1 month ago)
- Parents
17759fe
Diff
globalesim/src/main/java/com/vayunmathur/globalesim/domain/CheckoutUrls.kt
diff --git a/globalesim/src/main/java/com/vayunmathur/globalesim/domain/CheckoutUrls.kt b/globalesim/src/main/java/com/vayunmathur/globalesim/domain/CheckoutUrls.ktnew file mode 100644index 0000000000..ab3f1c3340--- /dev/null+++ b/globalesim/src/main/java/com/vayunmathur/globalesim/domain/CheckoutUrls.kt@@ -0,0 +1,13 @@+package com.vayunmathur.globalesim.domain++/**+ * NOWPayments sometimes returns a cleartext `http:` checkout link, which the+ * app's network security config blocks. Their checkout serves TLS, so+ * upgrade to `https:` — anything already secure passes through untouched.+ */+fun upgradeCheckoutUrl(url: String): String =+ if (url.startsWith("http://", ignoreCase = true)) {+ "https://" + url.substring("http://".length)+ } else {+ url+ }
globalesim/src/main/java/com/vayunmathur/globalesim/domain/EsimActivationCode.kt
diff --git a/globalesim/src/main/java/com/vayunmathur/globalesim/domain/EsimActivationCode.kt b/globalesim/src/main/java/com/vayunmathur/globalesim/domain/EsimActivationCode.ktnew file mode 100644index 0000000000..3c76cc9302--- /dev/null+++ b/globalesim/src/main/java/com/vayunmathur/globalesim/domain/EsimActivationCode.kt@@ -0,0 +1,29 @@+package com.vayunmathur.globalesim.domain++/**+ * Builds the full SGP.22 activation code (`LPA:1$<smdp>$<matchingId>`) the+ * LPA needs, from the server's [rawCode] + [smdpAddress] pair.+ *+ * The server sometimes returns the code already joined but with the `$`+ * between SM-DP+ host and matching ID missing+ * (`LPA:1$<smdp><matchingId>`), which the LPA rejects straight to manual+ * entry. When the tail starts with our known SM-DP+ address, split there+ * and re-insert the separator instead of passing the fused string through.+ */+fun buildActivationCode(rawCode: String, smdpAddress: String): String {+ val body = rawCode.trim().let {+ if (it.startsWith("LPA:", ignoreCase = true)) it.substring(4) else it+ }+ if ('$' !in body) return "LPA:1\$$smdpAddress\$$body"+ val parts = body.split('$')+ if (parts.size >= 3) return "LPA:$body"+ // Fused `<smdp><matchingId>` tail: split at the known SM-DP+ address.+ val tail = parts.last()+ if (smdpAddress.isNotEmpty() &&+ tail.startsWith(smdpAddress) &&+ tail.length > smdpAddress.length+ ) {+ return "LPA:1\$$smdpAddress\$${tail.substring(smdpAddress.length)}"+ }+ return "LPA:$body"+}
globalesim/src/main/java/com/vayunmathur/globalesim/platform/EsimViewModel.kt
diff --git a/globalesim/src/main/java/com/vayunmathur/globalesim/platform/EsimViewModel.kt b/globalesim/src/main/java/com/vayunmathur/globalesim/platform/EsimViewModel.ktindex c09d9a5a85..bbdffb96d7 100644--- a/globalesim/src/main/java/com/vayunmathur/globalesim/platform/EsimViewModel.kt+++ b/globalesim/src/main/java/com/vayunmathur/globalesim/platform/EsimViewModel.kt@@ -10,6 +10,7 @@ import com.vayunmathur.globalesim.data.AnonymousIdStore import com.vayunmathur.globalesim.data.api.EsimApi import com.vayunmathur.globalesim.data.api.ProfileDto import com.vayunmathur.globalesim.data.api.RateDto+import com.vayunmathur.globalesim.domain.upgradeCheckoutUrl import com.vayunmathur.library.log.Log import java.util.UUID import kotlinx.coroutines.launch@@ -178,14 +179,18 @@ class EsimViewModel(app: Application) : AndroidViewModel(app) { ) runCatching { EsimApi.nowPayInvoice(accountId(), amountCents) } .onSuccess {+ // NOWPayments sometimes returns a cleartext http link,+ // which cleartext blocking rejects — upgrade once here so+ // every consumer (state, open callback) is secure.+ val secureUrl = upgradeCheckoutUrl(it.invoiceUrl) state = state.copy( loading = false,- pendingInvoiceUrl = it.invoiceUrl,+ pendingInvoiceUrl = secureUrl, pendingInvoiceId = it.invoiceId, pendingBonusCents = it.bonusUsdCents, pendingAmountCents = amountCents, )- onInvoiceReady(it.invoiceUrl)+ onInvoiceReady(secureUrl) } .onFailure { state = state.copy(loading = false, error = it.message) } }
globalesim/src/main/java/com/vayunmathur/globalesim/ui/HomeScreen.kt
diff --git a/globalesim/src/main/java/com/vayunmathur/globalesim/ui/HomeScreen.kt b/globalesim/src/main/java/com/vayunmathur/globalesim/ui/HomeScreen.ktindex f0973ab747..f14283b89b 100644--- a/globalesim/src/main/java/com/vayunmathur/globalesim/ui/HomeScreen.kt+++ b/globalesim/src/main/java/com/vayunmathur/globalesim/ui/HomeScreen.kt@@ -29,6 +29,7 @@ import com.stripe.android.paymentsheet.PaymentSheet import com.stripe.android.paymentsheet.PaymentSheetResult import com.stripe.android.paymentsheet.rememberPaymentSheet import com.vayunmathur.globalesim.domain.QuoteMath+import com.vayunmathur.globalesim.domain.buildActivationCode import com.vayunmathur.globalesim.platform.EsimUiState import com.vayunmathur.library.intents.euicc.EsimLink import com.vayunmathur.library.ui.AppScaffold@@ -167,13 +168,15 @@ fun HomeScreen( // The vendor stores SM-DP+ and matching ID separately; // the LPA needs the full LPA:1$<smdp>$<code> string. // A bare matching ID fails validation and lands on a- // blank manual-entry page.- val code = profile.activationCode- val full = if (code.startsWith("LPA:", ignoreCase = true) || '$' in code) {- code- } else {- "LPA:1$${profile.smdpAddress}$code"- }+ // blank manual-entry page. The server sometimes fuses+ // smdp+code with the `$` missing, so normalize first.+ val full = buildActivationCode(profile.activationCode, profile.smdpAddress)+ // TEMP-DEBUG: part counts only, never the code itself.+ com.vayunmathur.library.log.Log.status(+ "Esim",+ "install len=${full.length} parts=${full.split('$').size} " ++ "smdpLen=${profile.smdpAddress.length} codeLen=${profile.activationCode.length}",+ ) val intent = Intent( Intent.ACTION_VIEW, EsimLink.provisioningUri(full),
globalesim/src/test/java/com/vayunmathur/globalesim/domain/CheckoutUrlsTest.kt
diff --git a/globalesim/src/test/java/com/vayunmathur/globalesim/domain/CheckoutUrlsTest.kt b/globalesim/src/test/java/com/vayunmathur/globalesim/domain/CheckoutUrlsTest.ktnew file mode 100644index 0000000000..a2dd90ab6a--- /dev/null+++ b/globalesim/src/test/java/com/vayunmathur/globalesim/domain/CheckoutUrlsTest.kt@@ -0,0 +1,20 @@+package com.vayunmathur.globalesim.domain++import kotlin.test.Test+import kotlin.test.assertEquals++class CheckoutUrlsTest {+ @Test+ fun httpCheckoutUpgradesToHttps() {+ assertEquals(+ "https://nowpayments.io/payment/?iid=123",+ upgradeCheckoutUrl("http://nowpayments.io/payment/?iid=123"),+ )+ }++ @Test+ fun httpsCheckoutPassesThrough() {+ val url = "https://nowpayments.io/payment/?iid=123"+ assertEquals(url, upgradeCheckoutUrl(url))+ }+}
globalesim/src/test/java/com/vayunmathur/globalesim/domain/EsimActivationCodeTest.kt
diff --git a/globalesim/src/test/java/com/vayunmathur/globalesim/domain/EsimActivationCodeTest.kt b/globalesim/src/test/java/com/vayunmathur/globalesim/domain/EsimActivationCodeTest.ktnew file mode 100644index 0000000000..3bac3f5e8d--- /dev/null+++ b/globalesim/src/test/java/com/vayunmathur/globalesim/domain/EsimActivationCodeTest.kt@@ -0,0 +1,34 @@+package com.vayunmathur.globalesim.domain++import kotlin.test.Test+import kotlin.test.assertEquals++class EsimActivationCodeTest {+ @Test+ fun bareMatchingIdGetsFullPrefix() {+ assertEquals(+ "LPA:1\$smdp.example\$TN123",+ buildActivationCode("TN123", "smdp.example"),+ )+ }++ @Test+ fun wellFormedCodePassesThrough() {+ assertEquals(+ "LPA:1\$smdp.example\$TN123",+ buildActivationCode("LPA:1\$smdp.example\$TN123", "smdp.example"),+ )+ }++ @Test+ fun fusedSmdpAndMatchingIdAreSplit() {+ // The exact shape seen in the broken handoff: one `$` missing.+ assertEquals(+ "LPA:1\$consumer.e-sim.global\$TN2026021619282618FF23C5",+ buildActivationCode(+ "LPA:1\$consumer.e-sim.globalTN2026021619282618FF23C5",+ "consumer.e-sim.global",+ ),+ )+ }+}
library/map/src/main/java/com/vayunmathur/library/map/MapNative.kt
diff --git a/library/map/src/main/java/com/vayunmathur/library/map/MapNative.kt b/library/map/src/main/java/com/vayunmathur/library/map/MapNative.ktindex ad23d55f77..4e57f92608 100644--- a/library/map/src/main/java/com/vayunmathur/library/map/MapNative.kt+++ b/library/map/src/main/java/com/vayunmathur/library/map/MapNative.kt@@ -44,7 +44,7 @@ internal object MapNative { * * [localPath] is an optional path to a `.mamaps` archive already on the device. When * it names an existing file the renderer reads that file directly and does no- * networking at all; `null` or empty keeps the built-in `planet2.mamaps` URL and its+ * networking at all; `null` or empty keeps the built-in `planet3.mamaps` URL and its * range cache unchanged. */ external fun create(
library/map/src/main/java/com/vayunmathur/library/map/MapOptions.kt
diff --git a/library/map/src/main/java/com/vayunmathur/library/map/MapOptions.kt b/library/map/src/main/java/com/vayunmathur/library/map/MapOptions.ktindex 0792ade54d..f20a098893 100644--- a/library/map/src/main/java/com/vayunmathur/library/map/MapOptions.kt+++ b/library/map/src/main/java/com/vayunmathur/library/map/MapOptions.kt@@ -64,7 +64,7 @@ data class MapOptions( val layerOptions: LayerOptions = LayerOptions(), /** * Where tiles come from. [TileSource.Server] (default) streams range requests for- * `planet2.mamaps` over HTTP with a disk range cache; [TileSource.LocalFile] reads a+ * `planet3.mamaps` over HTTP with a disk range cache; [TileSource.LocalFile] reads a * pushed `.mamaps` archive from the app's external files dir and does no networking. * Today only `maps` pushes an archive, so every other app stays on the default. */@@ -89,7 +89,7 @@ enum class MapBody { * Where the renderer reads its tiles from. */ enum class TileSource {- /** Stream `planet2.mamaps` range requests over HTTP, cached on disk. */+ /** Stream `planet3.mamaps` range requests over HTTP, cached on disk. */ Server, /** Read a pushed `.mamaps` archive from external files; no networking. Falls back to * [Server] when no archive file is present, so a missing push degrades to streaming
library/map/src/main/java/com/vayunmathur/library/map/VectorMap.kt
diff --git a/library/map/src/main/java/com/vayunmathur/library/map/VectorMap.kt b/library/map/src/main/java/com/vayunmathur/library/map/VectorMap.ktindex 4ed3025010..1cb45c3c40 100644--- a/library/map/src/main/java/com/vayunmathur/library/map/VectorMap.kt+++ b/library/map/src/main/java/com/vayunmathur/library/map/VectorMap.kt@@ -32,8 +32,8 @@ import kotlin.math.roundToInt /** * The vector map. *- * Renders the planet-scale v8 single-file `planet2.mamaps` archive- * (`data.maproj.org/planet2.mamaps`: 9 layers, 128-byte header) with our own+ * Renders the planet-scale v8 single-file `planet3.mamaps` archive+ * (`data.maproj.org/planet3.mamaps`: 9 layers, 128-byte header) with our own * Vulkan renderer. No third-party tile CDN and no API key, which is the whole point: * watermarked, and that broke the basemap in five apps (#615). *
library/map/src/main/rust/Cargo.toml
diff --git a/library/map/src/main/rust/Cargo.toml b/library/map/src/main/rust/Cargo.tomlindex 3e996aabe0..0ac0f13b2d 100644--- a/library/map/src/main/rust/Cargo.toml+++ b/library/map/src/main/rust/Cargo.toml@@ -2,7 +2,7 @@ # # Replaces the CARTO raster basemap in findfamily, photos, weather, taxi and # fooddelivery (#615) with our own renderer over the planet-scale v7-# single-file planet.mamaps archive.+# single-file planet3.mamaps archive. # # Why Vulkan and not `androidx.webgpu`: that wrapper bundles Dawn as a 5.79 MB # `libwebgpu_c_bundled.so` per ABI, to translate to the Vulkan that is already on@@ -20,7 +20,7 @@ version = "0.1.0" edition = "2021" publish = false license = "GPL-2.0-only"-description = "Vulkan vector-tile map renderer: planet.mamaps v7 in, triangles out"+description = "Vulkan vector-tile map renderer: planet3.mamaps v7 in, triangles out" [lib] name = "map_renderer"@@ -39,7 +39,7 @@ sha2.workspace = true serde_json.workspace = true # The .mamaps codec, shared with `scripts/maps`, which builds the-# planet.mamaps archive this reads. One implementation, so the two cannot drift.+# planet3.mamaps archive this reads. One implementation, so the two cannot drift. tilecodec = { path = "../../../../tilecodec/src/main/rust" } # HTTP goes back out through Kotlin: this crate opens no sockets and carries no TLS
library/map/src/main/rust/src/lib.rs
diff --git a/library/map/src/main/rust/src/lib.rs b/library/map/src/main/rust/src/lib.rsindex c01c702450..1e2b5b6065 100644--- a/library/map/src/main/rust/src/lib.rs+++ b/library/map/src/main/rust/src/lib.rs@@ -2,7 +2,7 @@ //! //! Replaces the CARTO raster basemap in findfamily, photos, weather, taxi and //! fooddelivery (#615) with our own renderer over the planet-scale v7-//! single-file `planet.mamaps` archive at `data.maproj.org/planet.mamaps`+//! single-file `planet3.mamaps` archive at `data.maproj.org/planet3.mamaps` //! (12 layers, 128-byte header). //! //! # Layout
library/map/src/main/rust/src/tile/cache/tests.rs
diff --git a/library/map/src/main/rust/src/tile/cache/tests.rs b/library/map/src/main/rust/src/tile/cache/tests.rsindex 6bf0a05959..53debe550b 100644--- a/library/map/src/main/rust/src/tile/cache/tests.rs+++ b/library/map/src/main/rust/src/tile/cache/tests.rs@@ -25,8 +25,8 @@ impl Drop for Fixture { } } -const URL: &str = "https://data.maproj.org/planet.mamaps";-const ORIGIN: &str = "v1|https://data.maproj.org/planet.mamaps";+const URL: &str = "https://data.maproj.org/planet3.mamaps";+const ORIGIN: &str = "v1|https://data.maproj.org/planet3.mamaps"; fn cache_with(dir: &Path, clock: Arc<AtomicU64>, max_bytes: u64) -> RangeCache { let c = clock.clone();
library/map/src/main/rust/src/tile/source/urls.rs
diff --git a/library/map/src/main/rust/src/tile/source/urls.rs b/library/map/src/main/rust/src/tile/source/urls.rsindex 8f42a8bd68..2e654ed375 100644--- a/library/map/src/main/rust/src/tile/source/urls.rs+++ b/library/map/src/main/rust/src/tile/source/urls.rs@@ -1,6 +1,6 @@ /// Where this renderer reads its tiles from: the planet-scale v8 single-file /// full `.mamaps` archive (9 layers, 128-byte header).-pub const BASEMAP_ARCHIVE_URL: &str = "https://data.maproj.org/planet2.mamaps";+pub const BASEMAP_ARCHIVE_URL: &str = "https://data.maproj.org/planet3.mamaps"; /// Bumped when the on-disk cache layout changes, so old entries are dropped rather than /// misread. The URL is in the marker too, because the archive is republished under the
library/map/src/main/rust/src/vulkan/swapchain/chain.rs
diff --git a/library/map/src/main/rust/src/vulkan/swapchain/chain.rs b/library/map/src/main/rust/src/vulkan/swapchain/chain.rsindex 5033e74181..2cc2752a10 100644--- a/library/map/src/main/rust/src/vulkan/swapchain/chain.rs+++ b/library/map/src/main/rust/src/vulkan/swapchain/chain.rs@@ -3,6 +3,7 @@ use crate::vulkan::context::Context; use ash::vk; use super::msaa::MsaaTarget;+use super::present::{choose_present_mode, present_mode_name}; use super::samples::supported_samples; use super::stencil::{stencil_format, StencilTarget}; @@ -462,76 +463,3 @@ struct BuiltAttachments { stencil: StencilTarget, image_count_hint: usize, }--/// Pick the swapchain present mode: MAILBOX where offered, FIFO otherwise.-///-/// Pure so it is host-testable: no device, just the driver's offered list. MAILBOX is-/// tear-free like FIFO but replaces the queued frame instead of waiting behind it, so-/// a 60fps gesture presents newer poses; FIFO is the spec-mandated fallback and the-/// previous behaviour. IMMEDIATE is never chosen even when it is the only other-/// option — tearing on a map is worse than vsync latency — so a driver offering only-/// IMMEDIATE keeps the old `present_modes[0]` answer.-fn choose_present_mode(present_modes: &[vk::PresentModeKHR]) -> vk::PresentModeKHR {- if present_modes.contains(&vk::PresentModeKHR::MAILBOX) {- vk::PresentModeKHR::MAILBOX- } else if present_modes.contains(&vk::PresentModeKHR::FIFO) {- vk::PresentModeKHR::FIFO- } else {- // Unreachable on a conformant driver (FIFO is mandatory), but the old code- // indexed [0] here and a panic on a non-conformant driver is worse than a- // torn frame. `new` already errors on an empty format list; an empty mode- // list fails below at creation with the driver's own error.- present_modes.first().copied().unwrap_or(vk::PresentModeKHR::FIFO)- }-}--/// The creation-time log line names the negotiated mode, so a device run can confirm-/// which path the driver took without a second build. By discriminant rather than-/// `Debug`: `ash`'s bitflag-style enums do not implement it.-fn present_mode_name(mode: vk::PresentModeKHR) -> &'static str {- match mode {- vk::PresentModeKHR::IMMEDIATE => "IMMEDIATE",- vk::PresentModeKHR::MAILBOX => "MAILBOX",- vk::PresentModeKHR::FIFO => "FIFO",- vk::PresentModeKHR::FIFO_RELAXED => "FIFO_RELAXED",- _ => "UNKNOWN",- }-}--#[cfg(test)]-mod tests {- use super::*;-- /// MAILBOX wins where offered (tear-free and fresher through gestures); FIFO is- /// the mandated fallback and the old behaviour; IMMEDIATE is never picked even- /// when it is the only other option.- ///- /// Android-gated like the rest of this module (`ash` is an Android-only- /// dependency), so `cargo test` on the host never runs it — it compiles and runs- /// under the Android test target instead. The creation-time logcat line naming- /// the negotiated mode is the on-device proof in the meantime.- #[test]- fn mailbox_wins_over_fifo_and_immediate_is_never_picked() {- use vk::PresentModeKHR::*;- assert_eq!(- choose_present_mode(&[FIFO, MAILBOX, IMMEDIATE]),- MAILBOX,- "tear-free with the freshest queued frame"- );- assert_eq!(- choose_present_mode(&[FIFO, IMMEDIATE]),- FIFO,- "the old behaviour where MAILBOX is absent"- );- assert_eq!(- choose_present_mode(&[IMMEDIATE]),- IMMEDIATE,- "a non-conformant driver keeps the old [0] answer, not a panic"- );- assert_eq!(- choose_present_mode(&[]),- FIFO,- "empty degrades to the mandated mode for the creation error below"- );- }-}
library/map/src/main/rust/src/vulkan/swapchain/mod.rs
diff --git a/library/map/src/main/rust/src/vulkan/swapchain/mod.rs b/library/map/src/main/rust/src/vulkan/swapchain/mod.rsindex e863a9a124..4a565b5a2f 100644--- a/library/map/src/main/rust/src/vulkan/swapchain/mod.rs+++ b/library/map/src/main/rust/src/vulkan/swapchain/mod.rs@@ -35,7 +35,7 @@ //! frame replace the queued one, so a 60fps gesture presents poses up to a frame //! fresher; the on-demand loop queues nothing while idle, so there is no power cost //! when the map is still. IMMEDIATE is never picked (tearing), FIFO is the-//! spec-mandated fallback — see [`chain`](self::chain) for the selection and the+//! spec-mandated fallback — see [`present`](self::present) for the selection and the //! creation-time logcat line naming the negotiated mode. //! //! # Two hard-won details carried over from `games/voxels`@@ -64,6 +64,7 @@ mod chain; mod msaa;+mod present; mod samples; mod stencil;
library/map/src/main/rust/src/vulkan/swapchain/present.rs
diff --git a/library/map/src/main/rust/src/vulkan/swapchain/present.rs b/library/map/src/main/rust/src/vulkan/swapchain/present.rsnew file mode 100644index 0000000000..64f40a3c19--- /dev/null+++ b/library/map/src/main/rust/src/vulkan/swapchain/present.rs@@ -0,0 +1,74 @@+use ash::vk;++/// Pick the swapchain present mode: MAILBOX where offered, FIFO otherwise.+///+/// Pure so it is host-testable: no device, just the driver's offered list. MAILBOX is+/// tear-free like FIFO but replaces the queued frame instead of waiting behind it, so+/// a 60fps gesture presents newer poses; FIFO is the spec-mandated fallback and the+/// previous behaviour. IMMEDIATE is never chosen even when it is the only other+/// option — tearing on a map is worse than vsync latency — so a driver offering only+/// IMMEDIATE keeps the old `present_modes[0]` answer.+pub(super) fn choose_present_mode(present_modes: &[vk::PresentModeKHR]) -> vk::PresentModeKHR {+ if present_modes.contains(&vk::PresentModeKHR::MAILBOX) {+ vk::PresentModeKHR::MAILBOX+ } else if present_modes.contains(&vk::PresentModeKHR::FIFO) {+ vk::PresentModeKHR::FIFO+ } else {+ // Unreachable on a conformant driver (FIFO is mandatory), but the old code+ // indexed [0] here and a panic on a non-conformant driver is worse than a+ // torn frame. `new` already errors on an empty format list; an empty mode+ // list fails below at creation with the driver's own error.+ present_modes.first().copied().unwrap_or(vk::PresentModeKHR::FIFO)+ }+}++/// The creation-time log line names the negotiated mode, so a device run can confirm+/// which path the driver took without a second build. By discriminant rather than+/// `Debug`: `ash`'s bitflag-style enums do not implement it.+pub(super) fn present_mode_name(mode: vk::PresentModeKHR) -> &'static str {+ match mode {+ vk::PresentModeKHR::IMMEDIATE => "IMMEDIATE",+ vk::PresentModeKHR::MAILBOX => "MAILBOX",+ vk::PresentModeKHR::FIFO => "FIFO",+ vk::PresentModeKHR::FIFO_RELAXED => "FIFO_RELAXED",+ _ => "UNKNOWN",+ }+}++#[cfg(test)]+mod tests {+ use super::*;++ /// MAILBOX wins where offered (tear-free and fresher through gestures); FIFO is+ /// the mandated fallback and the old behaviour; IMMEDIATE is never picked even+ /// when it is the only other option.+ ///+ /// Android-gated like the rest of this module (`ash` is an Android-only+ /// dependency), so `cargo test` on the host never runs it — it compiles and runs+ /// under the Android test target instead. The creation-time logcat line naming+ /// the negotiated mode is the on-device proof in the meantime.+ #[test]+ fn mailbox_wins_over_fifo_and_immediate_is_never_picked() {+ use vk::PresentModeKHR::*;+ assert_eq!(+ choose_present_mode(&[FIFO, MAILBOX, IMMEDIATE]),+ MAILBOX,+ "tear-free with the freshest queued frame"+ );+ assert_eq!(+ choose_present_mode(&[FIFO, IMMEDIATE]),+ FIFO,+ "the old behaviour where MAILBOX is absent"+ );+ assert_eq!(+ choose_present_mode(&[IMMEDIATE]),+ IMMEDIATE,+ "a non-conformant driver keeps the old [0] answer, not a panic"+ );+ assert_eq!(+ choose_present_mode(&[]),+ FIFO,+ "empty degrades to the mandated mode for the creation error below"+ );+ }+}
maps/src/main/java/com/vayunmathur/maps/util/MapTileCache.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/util/MapTileCache.kt b/maps/src/main/java/com/vayunmathur/maps/util/MapTileCache.ktindex 8a6e3d5e41..990833dca9 100644--- a/maps/src/main/java/com/vayunmathur/maps/util/MapTileCache.kt+++ b/maps/src/main/java/com/vayunmathur/maps/util/MapTileCache.kt@@ -19,7 +19,7 @@ object MapTileCache { /** Where [BASEMAP_ARCHIVE_FILE] is fetched from on a first launch that has no copy yet. */ const val BASEMAP_ARCHIVE_URL =- "https://data.maproj.org/planet2.mamaps"+ "https://data.maproj.org/planet3.mamaps" /** * The single source of truth for the streamed basemap PMTiles URL.
metadata_data/photos/securemail/2.png
diff --git a/metadata_data/photos/securemail/2.png b/metadata_data/photos/securemail/2.pngindex 0075f53743..780737abc2 100644Binary files a/metadata_data/photos/securemail/2.png and b/metadata_data/photos/securemail/2.png differ
metadata_data/photos/securemail/3.png
diff --git a/metadata_data/photos/securemail/3.png b/metadata_data/photos/securemail/3.pngindex 9af2c87bef..051583a8a3 100644Binary files a/metadata_data/photos/securemail/3.png and b/metadata_data/photos/securemail/3.png differ
scripts/maps/upload_planet.py
diff --git a/scripts/maps/upload_planet.py b/scripts/maps/upload_planet.pyindex 3d13d47d62..7150263115 100644--- a/scripts/maps/upload_planet.py+++ b/scripts/maps/upload_planet.py@@ -1,10 +1,10 @@-"""Upload any local file to R2 as planet2.mamaps (bucket: maps).+"""Upload any local file to R2 as planet3.mamaps (bucket: maps). Usage: python upload_planet.py <local-file> Verifies server-side size matches, then deletes nothing local. Progress prints every ~1 GB. -Serves https://data.maproj.org/planet2.mamaps, which the apps'+Serves https://data.maproj.org/planet3.mamaps, which the apps' basemap URLs point at (library/map urls.rs, maps MapTileCache.kt). SECURITY: credentials/config come from ENVIRONMENT VARIABLES, never baked@@ -27,7 +27,7 @@ import boto3 from boto3.s3.transfer import TransferConfig BUCKET = os.environ.get("R2_BUCKET", "maps")-KEY = "planet2.mamaps"+KEY = "planet3.mamaps" PART_SIZE = 100 * 1024 * 1024 # 100 MB parts, 10-way concurrency
securemail/src/main/java/com/vayunmathur/securemail/network/MailSocket.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/network/MailSocket.kt b/securemail/src/main/java/com/vayunmathur/securemail/network/MailSocket.ktindex 95e991a90a..b8311f1389 100644--- a/securemail/src/main/java/com/vayunmathur/securemail/network/MailSocket.kt+++ b/securemail/src/main/java/com/vayunmathur/securemail/network/MailSocket.kt@@ -159,13 +159,32 @@ object MailSocket { /** Publish an already-encrypted PGP/MIME blob to [recipient]. False when offline. */ suspend fun publish(recipient: String, raw: ByteArray, unencrypted: Boolean = false): Boolean {- val s = session ?: return false+ val s = session+ if (s == null) {+ lastPublishError = "no session (relay offline)"+ return false+ } return runCatching { s.send(pubFrame(recipient, raw, unencrypted))+ lastPublishError = null true- }.onFailure { Log.status(TAG, "publish failed", it) }.getOrDefault(false)+ }.onFailure {+ lastPublishError = it.message?.takeIf { m -> m.isNotBlank() }+ ?: it.javaClass.simpleName ?: "socket write failed"+ Log.status(TAG, "publish failed", it)+ }.getOrDefault(false) } + /**+ * Cause of the most recent [publish] failure (null after a success).+ * Read immediately after a `false` return — the next publish overwrites it.+ * Surfaced to the outbox `lastError` so retry shows the real cause instead+ * of one generic string.+ */+ @Volatile+ var lastPublishError: String? = null+ private set+ /** Directory lookup over the socket (request/response with timeout). */ suspend fun getKey(address: String): KeyResult? { val s = session ?: return null
securemail/src/main/java/com/vayunmathur/securemail/platform/MailViewModel.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/platform/MailViewModel.kt b/securemail/src/main/java/com/vayunmathur/securemail/platform/MailViewModel.ktindex 0ce82c8323..23227ddc8a 100644--- a/securemail/src/main/java/com/vayunmathur/securemail/platform/MailViewModel.kt+++ b/securemail/src/main/java/com/vayunmathur/securemail/platform/MailViewModel.kt@@ -642,29 +642,57 @@ class MailViewModel(app: Application) : AndroidViewModel(app) { val ownSecret = keyManager.getSecretArmor() val ownPassphrase = requirePassphrase() for (entry in pending) {+ var reason = "relay publish failed" val ok = runCatching { val to = entry.toJson.split(",").map { it.trim() }.filter { it.isNotEmpty() } val mime = buildMimeBody(entry.subject, entry.body) var entryOk = true for (address in to) { val cached = repo.keyDao().get(address)- if (cached != null) {- val raw = PgpCrypto.encryptSigned(- mime, cached.armoredPublic, ownSecret, ownPassphrase,- )- if (MailSocket.publish(address, buildEncryptedBody(raw))) continue+ val published = if (cached != null) {+ val raw = try {+ PgpCrypto.encryptSigned(+ mime, cached.armoredPublic, ownSecret, ownPassphrase,+ )+ } catch (e: Exception) {+ reason = "encrypt failed: " ++ (e.message?.takeIf { it.isNotBlank() } ?: e.javaClass.simpleName)+ Log.status(TAG, "outbox encrypt failed", e)+ null+ }+ if (raw == null) {+ false+ } else if (MailSocket.publish(address, buildEncryptedBody(raw))) {+ true+ } else {+ reason = "publish failed: " ++ (MailSocket.lastPublishError ?: "socket write failed")+ false+ } } else {- if (MailSocket.publish(address, mime, unencrypted = true)) continue+ if (MailSocket.publish(address, mime, unencrypted = true)) {+ true+ } else {+ reason = "publish failed: " ++ (MailSocket.lastPublishError ?: "socket write failed")+ false+ } }- entryOk = false+ if (!published) entryOk = false } entryOk+ }.onFailure {+ if (reason == "relay publish failed") {+ reason = "outbox error: " ++ (it.message?.takeIf { m -> m.isNotBlank() } ?: it.javaClass.simpleName)+ }+ Log.status(TAG, "outbox entry failed", it) }.getOrDefault(false) if (ok) { repo.outboxDao().delete(entry.rowId) sent++ } else {- repo.outboxDao().noteAttempt(entry.rowId, "relay publish failed")+ repo.outboxDao().noteAttempt(entry.rowId, reason) failed++ } }
securemail/src/main/java/com/vayunmathur/securemail/ui/InboxScreen.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/ui/InboxScreen.kt b/securemail/src/main/java/com/vayunmathur/securemail/ui/InboxScreen.ktindex e6a43c6197..cfe3dc9ca9 100644--- a/securemail/src/main/java/com/vayunmathur/securemail/ui/InboxScreen.kt+++ b/securemail/src/main/java/com/vayunmathur/securemail/ui/InboxScreen.kt@@ -102,6 +102,8 @@ fun InboxScreen( msg = msg, onOpen = { onOpen(msg.id) }, inTrash = folder == MailFolder.TRASH,+ // Sent rows show the destination (From is always us).+ showRecipient = folder == MailFolder.SENT, onTrash = { onTrash(msg.id) }, onRestore = { onRestore(msg.id) }, )@@ -118,6 +120,7 @@ private fun MessageRow( msg: StoredMessage, onOpen: () -> Unit, inTrash: Boolean,+ showRecipient: Boolean = false, onTrash: () -> Unit, onRestore: () -> Unit, ) {@@ -128,7 +131,7 @@ private fun MessageRow( ) { Row(modifier = Modifier.fillMaxWidth()) { Text(- msg.from.ifBlank { "(encrypted sender)" },+ if (showRecipient) "To: ${msg.toJson.ifBlank { "(unknown)" }}" else msg.from.ifBlank { "(encrypted sender)" }, style = MaterialTheme.typography.titleSmall, modifier = Modifier.weight(1f), )
securemail/src/main/java/com/vayunmathur/securemail/ui/ReaderScreen.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/ui/ReaderScreen.kt b/securemail/src/main/java/com/vayunmathur/securemail/ui/ReaderScreen.ktindex 9b58076fb3..61f7aa2e45 100644--- a/securemail/src/main/java/com/vayunmathur/securemail/ui/ReaderScreen.kt+++ b/securemail/src/main/java/com/vayunmathur/securemail/ui/ReaderScreen.kt@@ -48,7 +48,11 @@ fun ReaderScreen( verticalArrangement = Arrangement.spacedBy(8.dp), ) { Text(- "From: ${msg.from.ifBlank { "(encrypted sender)" }}",+ if (msg.folder == com.vayunmathur.securemail.data.MailFolder.SENT) {+ "To: ${msg.toJson.ifBlank { "(unknown)" }}"+ } else {+ "From: ${msg.from.ifBlank { "(encrypted sender)" }}"+ }, style = MaterialTheme.typography.labelMedium, ) Text(
web/src/main/java/com/vayunmathur/web/ui/BrowserOmniboxEditor.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/BrowserOmniboxEditor.kt b/web/src/main/java/com/vayunmathur/web/ui/BrowserOmniboxEditor.ktindex bcd17305bc..6681e00a79 100644--- a/web/src/main/java/com/vayunmathur/web/ui/BrowserOmniboxEditor.kt+++ b/web/src/main/java/com/vayunmathur/web/ui/BrowserOmniboxEditor.kt@@ -11,6 +11,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember@@ -69,11 +70,19 @@ internal fun OmniboxEditor( BoxWithConstraints(Modifier.fillMaxSize()) { val effectiveAtBottom = viewModel.searchBarAtBottom && maxHeight >= 480.dp- // TextFieldValue so entering the field selects everything: the first- // keystroke replaces the URL instead of appending to it.- var fieldValue by remember(viewModel.searchDraft) {+ // Local field state, keyed once: re-creating TextFieldValue on every+ // keystroke (remember(searchDraft)) pinned the cursor to the end and+ // reset the internal scroll offset, so mid-URL edits were impossible+ // and dragging the cursor left never scrolled. External changes+ // (tab switch) still reset via the LaunchedEffect below.+ var fieldValue by remember { mutableStateOf(TextFieldValue(viewModel.searchDraft, TextRange(viewModel.searchDraft.length))) }+ LaunchedEffect(viewModel.searchDraft) {+ if (viewModel.searchDraft != fieldValue.text) {+ fieldValue = TextFieldValue(viewModel.searchDraft, TextRange(viewModel.searchDraft.length))+ }+ } val omniboxField: @Composable (Modifier) -> Unit = { fieldModifier -> OutlinedTextField( value = fieldValue,
web/src/main/java/com/vayunmathur/web/ui/WebViewClients.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/WebViewClients.kt b/web/src/main/java/com/vayunmathur/web/ui/WebViewClients.ktindex 7c78dc7c5b..834137fb3e 100644--- a/web/src/main/java/com/vayunmathur/web/ui/WebViewClients.kt+++ b/web/src/main/java/com/vayunmathur/web/ui/WebViewClients.kt@@ -60,7 +60,13 @@ internal fun createBrowserWebViewClient( context = ctx, shieldsFor = { host -> viewModel.shieldsFor(host, isPrivateTab) }, onBlocked = { _, _ -> viewModel.onRequestBlocked(tabId) },- onNavigate = { _, rewritten -> viewModel.onTabUrlChange(tabId, rewritten) },+ // Load the rewritten URL, not just mirror it: returning true above+ // cancels the original load, so without this the tab shows the old+ // page while the omnibox shows the new URL (reads as a scheme flip).+ onNavigate = { view, rewritten ->+ viewModel.onTabUrlChange(tabId, rewritten)+ view.loadUrl(rewritten)+ }, ) { override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean { val scheme = request.url.scheme ?: return false