various fixes
- Commit
ae78a301cd16077652990bd9aa906822700c32b4- Author
- vayun-mathur <[email protected]>
- When
- 2026-10-21 04:17 UTC (1 month ago)
- Parents
18a35a0
Diff
Cargo.lock
diff --git a/Cargo.lock b/Cargo.lockindex 4346a5b7a8..15e77372f5 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -35,7 +35,7 @@ dependencies = [ "percent-encoding", "precomputed-hash", "regex",- "rustc-hash",+ "rustc-hash 2.1.3", "seahash", "serde", "serde_json",@@ -53,6 +53,15 @@ dependencies = [ "psl-types", ] +[[package]]+name = "addr2line"+version = "0.21.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"+dependencies = [+ "gimli",+]+ [[package]] name = "adler2" version = "2.0.1"@@ -314,6 +323,17 @@ dependencies = [ "jni", ] +[[package]]+name = "async-trait"+version = "0.1.92"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 3.0.9",+]+ [[package]] name = "autocfg" version = "1.5.1"@@ -338,6 +358,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]]+name = "base64"+version = "0.21.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"+ [[package]] name = "base64" version = "0.22.1"@@ -356,6 +382,15 @@ version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" +[[package]]+name = "bincode"+version = "1.3.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"+dependencies = [+ "serde",+]+ [[package]] name = "bindgen" version = "0.72.1"@@ -371,7 +406,7 @@ dependencies = [ "proc-macro2", "quote", "regex",- "rustc-hash",+ "rustc-hash 2.1.3", "shlex", "syn 2.0.119", ]@@ -718,7 +753,7 @@ version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9c751b79415d4e559e3d1fcf128e09e720eb673a06d26cf6f392d37d75b66e0" dependencies = [- "heck",+ "heck 0.5.0", "proc-macro2", "quote", "syn 3.0.9",@@ -861,6 +896,15 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" +[[package]]+name = "cpp_demangle"+version = "0.4.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f2bb79cb74d735044c972aae58ed0aaa9a837e85b01106a54c39e42e97f62253"+dependencies = [+ "cfg-if",+]+ [[package]] name = "cpubits" version = "0.1.1"@@ -896,6 +940,115 @@ dependencies = [ "pkg-config", ] +[[package]]+name = "cranelift-bforest"+version = "0.107.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ebf72ceaf38f7d41194d0cf6748214d8ef7389167fe09aad80f87646dbfa325b"+dependencies = [+ "cranelift-entity",+]++[[package]]+name = "cranelift-codegen"+version = "0.107.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9ee7fde5cd9173f00ce02c491ee9e306d64740f4b1a697946e0474f389999e13"+dependencies = [+ "bumpalo",+ "cranelift-bforest",+ "cranelift-codegen-meta",+ "cranelift-codegen-shared",+ "cranelift-control",+ "cranelift-entity",+ "cranelift-isle",+ "gimli",+ "hashbrown 0.14.5",+ "log",+ "regalloc2",+ "smallvec",+ "target-lexicon",+]++[[package]]+name = "cranelift-codegen-meta"+version = "0.107.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b49bec6a517e78d4067500dc16acb558e772491a2bcb37301127448adfb8413c"+dependencies = [+ "cranelift-codegen-shared",+]++[[package]]+name = "cranelift-codegen-shared"+version = "0.107.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ead4ea497b2dc2ac31fcabd6d5d0d5dc25b3964814122e343724bdf65a53c843"++[[package]]+name = "cranelift-control"+version = "0.107.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f81e8028c8d711ea7592648e70221f2e54acb8665f7ecd49545f021ec14c3341"+dependencies = [+ "arbitrary",+]++[[package]]+name = "cranelift-entity"+version = "0.107.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "32acd0632ba65c2566e75f64af9ef094bb8d90e58a9fbd33d920977a9d85c054"+dependencies = [+ "serde",+ "serde_derive",+]++[[package]]+name = "cranelift-frontend"+version = "0.107.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a395a704934aa944ba8939cac9001174b9ae5236f48bc091f89e33bb968336f6"+dependencies = [+ "cranelift-codegen",+ "log",+ "smallvec",+ "target-lexicon",+]++[[package]]+name = "cranelift-isle"+version = "0.107.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b325ce81c4ee7082dc894537eb342c37898e14230fe7c02ea945691db3e2dd01"++[[package]]+name = "cranelift-native"+version = "0.107.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ea11f5ac85996fa093075d66397922d4f56085d5d84ec13043d0cd4f159c6818"+dependencies = [+ "cranelift-codegen",+ "libc",+ "target-lexicon",+]++[[package]]+name = "cranelift-wasm"+version = "0.107.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e4f175d4e299a8edabfbd64fa93c7650836cc8ad7f4879f9bd2632575a1f12d0"+dependencies = [+ "cranelift-codegen",+ "cranelift-entity",+ "cranelift-frontend",+ "itertools 0.12.1",+ "log",+ "smallvec",+ "wasmparser 0.202.0",+ "wasmtime-types",+]+ [[package]] name = "crc32fast" version = "1.5.2"@@ -1154,6 +1307,15 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06" +[[package]]+name = "debugid"+version = "0.8.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d"+dependencies = [+ "uuid",+]+ [[package]] name = "dem_ingest" version = "0.1.0"@@ -1248,6 +1410,27 @@ dependencies = [ "ctutils", ] +[[package]]+name = "directories-next"+version = "2.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc"+dependencies = [+ "cfg-if",+ "dirs-sys-next",+]++[[package]]+name = "dirs-sys-next"+version = "0.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"+dependencies = [+ "libc",+ "redox_users",+ "winapi",+]+ [[package]] name = "displaydoc" version = "0.2.7"@@ -1265,7 +1448,7 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e92f10a49176cbffacaedabfaa11d51db1ea0f80a83c26e1873b43cd1742c24" dependencies = [- "heck",+ "heck 0.5.0", "proc-macro2", "proc-macro2-diagnostics", ]@@ -1498,6 +1681,12 @@ dependencies = [ "once_cell", ] +[[package]]+name = "fallible-iterator"+version = "0.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"+ [[package]] name = "fastrand" version = "2.5.0"@@ -1656,6 +1845,28 @@ dependencies = [ "slab", ] +[[package]]+name = "fxhash"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"+dependencies = [+ "byteorder",+]++[[package]]+name = "fxprof-processed-profile"+version = "0.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "27d12c0aed7f1e24276a241aadc4cb8ea9f83000f34bc062b7cc2d51e3b0fabd"+dependencies = [+ "bitflags 2.13.2",+ "debugid",+ "fxhash",+ "serde",+ "serde_json",+]+ [[package]] name = "generic-array" version = "0.14.7"@@ -1719,6 +1930,17 @@ dependencies = [ "polyval 0.7.3", ] +[[package]]+name = "gimli"+version = "0.28.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"+dependencies = [+ "fallible-iterator",+ "indexmap",+ "stable_deref_trait",+]+ [[package]] name = "glam" version = "0.27.0"@@ -1851,6 +2073,15 @@ dependencies = [ "zerocopy", ] +[[package]]+name = "hashbrown"+version = "0.13.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"+dependencies = [+ "ahash",+]+ [[package]] name = "hashbrown" version = "0.14.5"@@ -1919,7 +2150,7 @@ dependencies = [ "image", "kurbo", "pic-scale",- "rustc-hash",+ "rustc-hash 2.1.3", "vello_cpu", ] @@ -1951,7 +2182,7 @@ dependencies = [ "kurbo", "moxcms", "phf",- "rustc-hash",+ "rustc-hash 2.1.3", "siphasher", "skrifa 0.46.2", "smallvec",@@ -1994,7 +2225,7 @@ dependencies = [ "hayro-jbig2", "hayro-jpeg2000", "memchr",- "rustc-hash",+ "rustc-hash 2.1.3", "smallvec", "zune-jpeg", ]@@ -2013,6 +2244,12 @@ dependencies = [ "num-traits", ] +[[package]]+name = "heck"+version = "0.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"+ [[package]] name = "heck" version = "0.5.0"@@ -2280,6 +2517,12 @@ dependencies = [ "zerovec", ] +[[package]]+name = "id-arena"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"+ [[package]] name = "idna" version = "1.1.0"@@ -2365,6 +2608,15 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" +[[package]]+name = "itertools"+version = "0.12.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"+dependencies = [+ "either",+]+ [[package]] name = "itertools" version = "0.13.0"@@ -2398,6 +2650,26 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" +[[package]]+name = "ittapi"+version = "0.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6b996fe614c41395cdaedf3cf408a9534851090959d90d54a535f675550b64b1"+dependencies = [+ "anyhow",+ "ittapi-sys",+ "log",+]++[[package]]+name = "ittapi-sys"+version = "0.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "52f5385394064fa2c886205dba02598013ce83d3e92d33dbdc0c52fe0e7bf4fc"+dependencies = [+ "cc",+]+ [[package]] name = "jni" version = "0.22.4"@@ -2688,6 +2960,18 @@ dependencies = [ "crypto_provider", ] +[[package]]+name = "leb128"+version = "0.2.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c83bff1d572d6b9aeef67ddfc8448e4a3737909cb28e81f97c791b9018703e52"++[[package]]+name = "leb128fmt"+version = "0.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"+ [[package]] name = "libc" version = "0.2.190"@@ -2942,6 +3226,15 @@ dependencies = [ "cc", ] +[[package]]+name = "libredox"+version = "0.1.25"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d"+dependencies = [+ "libc",+]+ [[package]] name = "linebender_resource_handle" version = "0.1.1"@@ -3009,6 +3302,15 @@ dependencies = [ "weezl 0.2.1", ] +[[package]]+name = "mach2"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44"+dependencies = [+ "libc",+]+ [[package]] name = "mamaps_build" version = "0.1.0"@@ -3059,6 +3361,15 @@ version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" +[[package]]+name = "memfd"+version = "0.6.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "57804b2c9b69967f1536a56f86297e367a33b19e98852ed624b84551cdbc0d90"+dependencies = [+ "rustix 1.1.5",+]+ [[package]] name = "memmap2" version = "0.9.11"@@ -3068,6 +3379,15 @@ dependencies = [ "libc", ] +[[package]]+name = "memoffset"+version = "0.9.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"+dependencies = [+ "autocfg",+]+ [[package]] name = "mimalloc" version = "0.1.50"@@ -3297,6 +3617,18 @@ dependencies = [ "autocfg", ] +[[package]]+name = "object"+version = "0.33.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d8dd6c0cdf9429bce006e1362bfce61fa1bfd8c898a643ed8d2b471934701d3d"+dependencies = [+ "crc32fast",+ "hashbrown 0.14.5",+ "indexmap",+ "memchr",+]+ [[package]] name = "office_engine" version = "0.1.0"@@ -3559,6 +3891,12 @@ dependencies = [ "serde", ] +[[package]]+name = "paste"+version = "1.0.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"+ [[package]] name = "pastey" version = "0.2.3"@@ -4001,6 +4339,15 @@ version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac" +[[package]]+name = "psm"+version = "0.1.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205"+dependencies = [+ "cc",+]+ [[package]] name = "pxfm" version = "0.1.30"@@ -4165,6 +4512,30 @@ dependencies = [ "bitflags 2.13.2", ] +[[package]]+name = "redox_users"+version = "0.4.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"+dependencies = [+ "getrandom 0.2.17",+ "libredox",+ "thiserror 1.0.69",+]++[[package]]+name = "regalloc2"+version = "0.9.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ad156d539c879b7a24a363a2016d77961786e71f48f2e2fc8302a92abd2429a6"+dependencies = [+ "hashbrown 0.13.2",+ "log",+ "rustc-hash 1.1.0",+ "slice-group-by",+ "smallvec",+]+ [[package]] name = "regex" version = "1.13.1"@@ -4240,6 +4611,18 @@ dependencies = [ "crossbeam-utils", ] +[[package]]+name = "rustc-demangle"+version = "0.1.28"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b74b56ffa8bb2830709a538c2cbcae9aa062db0d2a42563bfb09bdaae44020eb"++[[package]]+name = "rustc-hash"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"+ [[package]] name = "rustc-hash" version = "2.1.3"@@ -4459,8 +4842,17 @@ dependencies = [ ] [[package]]-name = "sha2"-version = "0.10.9"+name = "serde_spanned"+version = "0.6.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3"+dependencies = [+ "serde",+]++[[package]]+name = "sha2"+version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [@@ -4630,6 +5022,12 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" +[[package]]+name = "slice-group-by"+version = "0.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7"+ [[package]] name = "slotmap" version = "1.1.1"@@ -4683,6 +5081,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c0cdea5a20a06e7c57f627094e7b1618e5665592cd88f2d45fa4014e348db58" +[[package]]+name = "sptr"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a"+ [[package]] name = "stable_deref_trait" version = "1.2.1"@@ -4718,7 +5122,7 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664" dependencies = [- "heck",+ "heck 0.5.0", "proc-macro2", "quote", "syn 2.0.119",@@ -4763,6 +5167,12 @@ dependencies = [ "syn 3.0.9", ] +[[package]]+name = "target-lexicon"+version = "0.12.16"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"+ [[package]] name = "tempfile" version = "3.27.0"@@ -4912,6 +5322,47 @@ dependencies = [ "syn 2.0.119", ] +[[package]]+name = "toml"+version = "0.8.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"+dependencies = [+ "serde",+ "serde_spanned",+ "toml_datetime",+ "toml_edit",+]++[[package]]+name = "toml_datetime"+version = "0.6.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"+dependencies = [+ "serde",+]++[[package]]+name = "toml_edit"+version = "0.22.27"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"+dependencies = [+ "indexmap",+ "serde",+ "serde_spanned",+ "toml_datetime",+ "toml_write",+ "winnow",+]++[[package]]+name = "toml_write"+version = "0.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"+ [[package]] name = "tracing" version = "0.1.44"@@ -5166,6 +5617,26 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" +[[package]]+name = "unicode-width"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"++[[package]]+name = "unicode-xid"+version = "0.2.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"++[[package]]+name = "uniflix_seal"+version = "0.1.0"+dependencies = [+ "jni",+ "wasmtime",+]+ [[package]] name = "universal-hash" version = "0.5.1"@@ -5412,6 +5883,352 @@ dependencies = [ "unicode-ident", ] +[[package]]+name = "wasm-encoder"+version = "0.202.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bfd106365a7f5f7aa3c1916a98cbb3ad477f5ff96ddb130285a91c6e7429e67a"+dependencies = [+ "leb128",+]++[[package]]+name = "wasm-encoder"+version = "0.262.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4495a6f85dd94c411c749303efcbc5defade0b0cbdbc0541495241ab917a9b5a"+dependencies = [+ "leb128fmt",+ "wasmparser 0.262.0",+]++[[package]]+name = "wasmparser"+version = "0.202.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d6998515d3cf3f8b980ef7c11b29a9b1017d4cf86b99ae93b546992df9931413"+dependencies = [+ "bitflags 2.13.2",+ "indexmap",+ "semver",+]++[[package]]+name = "wasmparser"+version = "0.262.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "974d643b125b272607e2fff8012ea14a8328acd7621e4bafa7afb32500052b1b"+dependencies = [+ "bitflags 2.13.2",+ "indexmap",+ "semver",+]++[[package]]+name = "wasmprinter"+version = "0.202.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ab1cc9508685eef9502e787f4d4123745f5651a1e29aec047645d3cac1e2da7a"+dependencies = [+ "anyhow",+ "wasmparser 0.202.0",+]++[[package]]+name = "wasmtime"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4af5cb32045daee8476711eb12b8b71275c2dd1fc7a58cc2a11b33ce9205f6a2"+dependencies = [+ "addr2line",+ "anyhow",+ "async-trait",+ "bincode",+ "bumpalo",+ "cfg-if",+ "encoding_rs",+ "fxprof-processed-profile",+ "gimli",+ "indexmap",+ "ittapi",+ "libc",+ "log",+ "object",+ "once_cell",+ "paste",+ "rayon",+ "rustix 0.38.44",+ "semver",+ "serde",+ "serde_derive",+ "serde_json",+ "target-lexicon",+ "wasm-encoder 0.202.0",+ "wasmparser 0.202.0",+ "wasmtime-cache",+ "wasmtime-component-macro",+ "wasmtime-component-util",+ "wasmtime-cranelift",+ "wasmtime-environ",+ "wasmtime-fiber",+ "wasmtime-jit-debug",+ "wasmtime-jit-icache-coherence",+ "wasmtime-runtime",+ "wasmtime-slab",+ "wasmtime-winch",+ "wat",+ "windows-sys 0.52.0",+]++[[package]]+name = "wasmtime-asm-macros"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7515c4d24c8b55c0feab67e3d52a42f999fda8b9cfafbd69a82ed6bcf299d26e"+dependencies = [+ "cfg-if",+]++[[package]]+name = "wasmtime-cache"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c3aa2de7189ea6b3270727d0027790494aec5e7101ca50da3f9549a86628cae4"+dependencies = [+ "anyhow",+ "base64 0.21.7",+ "bincode",+ "directories-next",+ "log",+ "rustix 0.38.44",+ "serde",+ "serde_derive",+ "sha2 0.10.9",+ "toml",+ "windows-sys 0.52.0",+ "zstd",+]++[[package]]+name = "wasmtime-component-macro"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "794839a710a39a12677c67ff43fec54ef00d0ca6c6f631209a7c5524522221d3"+dependencies = [+ "anyhow",+ "proc-macro2",+ "quote",+ "syn 2.0.119",+ "wasmtime-component-util",+ "wasmtime-wit-bindgen",+ "wit-parser",+]++[[package]]+name = "wasmtime-component-util"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7839a1b9e15d17be1cb2a105f18be8e0bbf52bdec7a7cd6eb5d80d4c2cdf74f0"++[[package]]+name = "wasmtime-cranelift"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "57ec2d9a4b9990bea53a5dfd689d48663dbd19a46903eaf73e2022b3d1ef20d3"+dependencies = [+ "anyhow",+ "cfg-if",+ "cranelift-codegen",+ "cranelift-control",+ "cranelift-entity",+ "cranelift-frontend",+ "cranelift-native",+ "cranelift-wasm",+ "gimli",+ "log",+ "object",+ "target-lexicon",+ "thiserror 1.0.69",+ "wasmparser 0.202.0",+ "wasmtime-environ",+ "wasmtime-versioned-export-macros",+]++[[package]]+name = "wasmtime-environ"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ad72e2e3f7ea5b50fedf66dd36ba24634e4f445c370644683b433d45d88f6126"+dependencies = [+ "anyhow",+ "bincode",+ "cpp_demangle",+ "cranelift-entity",+ "gimli",+ "indexmap",+ "log",+ "object",+ "rustc-demangle",+ "serde",+ "serde_derive",+ "target-lexicon",+ "thiserror 1.0.69",+ "wasm-encoder 0.202.0",+ "wasmparser 0.202.0",+ "wasmprinter",+ "wasmtime-component-util",+ "wasmtime-types",+]++[[package]]+name = "wasmtime-fiber"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4dbdf3053e7e7ced0cd4ed76579995b62169a1a43696890584eae2de2e33bf54"+dependencies = [+ "anyhow",+ "cc",+ "cfg-if",+ "rustix 0.38.44",+ "wasmtime-asm-macros",+ "wasmtime-versioned-export-macros",+ "windows-sys 0.52.0",+]++[[package]]+name = "wasmtime-jit-debug"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "983ca409f2cd66385ce49486c022da0128acb7910c055beb5230998b49c6084c"+dependencies = [+ "object",+ "once_cell",+ "rustix 0.38.44",+ "wasmtime-versioned-export-macros",+]++[[package]]+name = "wasmtime-jit-icache-coherence"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ede45379f3b4d395d8947006de8043801806099a240a26db553919b68e96ab15"+dependencies = [+ "cfg-if",+ "libc",+ "windows-sys 0.52.0",+]++[[package]]+name = "wasmtime-runtime"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "65019d29d175c567b84173f2adf3b7a3af6d5592f8fe510dccae55d2569ec0d2"+dependencies = [+ "anyhow",+ "cc",+ "cfg-if",+ "encoding_rs",+ "indexmap",+ "libc",+ "log",+ "mach2",+ "memfd",+ "memoffset",+ "paste",+ "psm",+ "rustix 0.38.44",+ "sptr",+ "wasm-encoder 0.202.0",+ "wasmtime-asm-macros",+ "wasmtime-environ",+ "wasmtime-fiber",+ "wasmtime-jit-debug",+ "wasmtime-slab",+ "wasmtime-versioned-export-macros",+ "windows-sys 0.52.0",+]++[[package]]+name = "wasmtime-slab"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ca6585868f5c427c3e9d2a8c0c3354e6d7d4518a0d17723ab25a0c1eebf5d5b4"++[[package]]+name = "wasmtime-types"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "84d5381ff174faded38c7b2085fbe430dff59489c87a91403354d710075750fb"+dependencies = [+ "cranelift-entity",+ "serde",+ "serde_derive",+ "thiserror 1.0.69",+ "wasmparser 0.202.0",+]++[[package]]+name = "wasmtime-versioned-export-macros"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0d3b70422fdfa915c903f003b8b42554a8ae1aa0c6208429d8314ebf5721f3ac"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]++[[package]]+name = "wasmtime-winch"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "996360967b5196dec20ddcfce499ce4dc80cc925c088b0f2b376d29b96833a6a"+dependencies = [+ "anyhow",+ "cranelift-codegen",+ "gimli",+ "object",+ "target-lexicon",+ "wasmparser 0.202.0",+ "wasmtime-cranelift",+ "wasmtime-environ",+ "winch-codegen",+]++[[package]]+name = "wasmtime-wit-bindgen"+version = "20.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "01840c0cfbbb01664c796e3f4edbd656e58f9d76db083c7e7c6bba59ea657a96"+dependencies = [+ "anyhow",+ "heck 0.4.1",+ "indexmap",+ "wit-parser",+]++[[package]]+name = "wast"+version = "262.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "30612a0c29249b5f185888a107e8a519d920226b7d07f9d351fd094e9f75eb23"+dependencies = [+ "bumpalo",+ "leb128fmt",+ "memchr",+ "unicode-width",+ "wasm-encoder 0.262.0",+]++[[package]]+name = "wat"+version = "1.262.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e228027f2b07bbaf946980ebbe2437fca73be6f54c40c2a8d4f42f277075f8d1"+dependencies = [+ "wast",+]+ [[package]] name = "weather_om" version = "0.1.0"@@ -5511,6 +6328,23 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]]+name = "winch-codegen"+version = "0.18.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cefeb84a0f39227cf2eb665cf348e6150ebf3372d08adff03264064ab590fdf4"+dependencies = [+ "anyhow",+ "cranelift-codegen",+ "gimli",+ "regalloc2",+ "smallvec",+ "target-lexicon",+ "wasmparser 0.202.0",+ "wasmtime-cranelift",+ "wasmtime-environ",+]+ [[package]] name = "windows-core" version = "0.62.2"@@ -5661,6 +6495,33 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]]+name = "winnow"+version = "0.7.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945"+dependencies = [+ "memchr",+]++[[package]]+name = "wit-parser"+version = "0.202.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "744237b488352f4f27bca05a10acb79474415951c450e52ebd0da784c1df2bcc"+dependencies = [+ "anyhow",+ "id-arena",+ "indexmap",+ "log",+ "semver",+ "serde",+ "serde_derive",+ "serde_json",+ "unicode-xid",+ "wasmparser 0.202.0",+]+ [[package]] name = "wnaf" version = "0.14.1"
Cargo.toml
diff --git a/Cargo.toml b/Cargo.tomlindex ab72806429..c9b145e240 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -10,6 +10,7 @@ members = [ "networklocation/src/main/rust", "euicc/src/main/rust", "passwords/src/main/rust",+ "personal/uniflix/src/main/rust", "appstore/src/main/rust", "vpn/src/main/rust", "library/e2ee-p2p/src/main/rust",
appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.ktindex 5946719720..79cbe4e6dc 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt@@ -1,6 +1,7 @@ package com.vayunmathur.appstore.data import android.Manifest+import android.app.Activity import android.app.NotificationChannel import android.app.NotificationManager import android.app.PendingIntent@@ -24,10 +25,12 @@ import androidx.work.WorkManager import androidx.work.WorkerParameters import com.vayunmathur.appstore.MainActivity import com.vayunmathur.appstore.R-import com.vayunmathur.appstore.data.installer.InstallCoordinator import com.vayunmathur.appstore.data.accrescent.AccrescentRepository+import com.vayunmathur.appstore.data.accrescent.DeviceAttributesProvider+import com.vayunmathur.appstore.data.installer.InstallCoordinator import com.vayunmathur.appstore.data.play.PlayRepository import com.vayunmathur.appstore.data.security.ApkCertificates+import com.vayunmathur.appstore.tv.TvMainActivity import com.vayunmathur.library.network.NetworkClient import com.vayunmathur.library.network.TrustBundle import kotlinx.coroutines.CoroutineScope@@ -218,6 +221,17 @@ class UpdateCheckWorker( ) } + /**+ * Where an update notification lands: the TV entry on a TV, the phone pager elsewhere.+ *+ * "Am I a TV" is the same client-side fact the update streams filter on (see+ * [DeviceAttributesProvider.isTv]), so a notification about a TV-compatible update never+ * drops the user onto the phone pager on a device with no touch.+ */+ private fun openActivity(): Class<out Activity> =+ if (DeviceAttributesProvider(context.applicationContext).isTv()) TvMainActivity::class.java+ else MainActivity::class.java+ /** * Notify only when the set of updatable packages differs from last time. *@@ -253,7 +267,7 @@ class UpdateCheckWorker( val open = PendingIntent.getActivity( context, 0,- Intent(context, MainActivity::class.java)+ Intent(context, openActivity()) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE, )@@ -355,7 +369,7 @@ class UpdateCheckWorker( val open = PendingIntent.getActivity( context, 0,- Intent(context, MainActivity::class.java)+ Intent(context, openActivity()) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE, )
appstore/src/main/java/com/vayunmathur/appstore/tv/TvBrowse.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvBrowse.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvBrowse.ktindex c8d5a138a9..694dcbcfe1 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvBrowse.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvBrowse.kt@@ -152,21 +152,23 @@ private fun TvAppTile( stage: InstallStage?, onClick: () -> Unit, ) {- Card(onClick = onClick, modifier = Modifier.width(160.dp)) {+ // Ten-foot density: 200–250dp cards with a larger icon and a titleMedium/bodyMedium+ // floor, so tiles read from the couch instead of phone-scale.+ Card(onClick = onClick, modifier = Modifier.width(220.dp)) { Column(- modifier = Modifier.padding(12.dp),+ modifier = Modifier.padding(16.dp), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(8.dp), ) { TvAppIcon(app = app) Text( text = app.name,- style = MaterialTheme.typography.titleSmall,+ style = MaterialTheme.typography.titleMedium, color = MaterialTheme.colorScheme.onSurface, textAlign = TextAlign.Center, maxLines = 2, overflow = TextOverflow.Ellipsis,- modifier = Modifier.height(40.dp),+ modifier = Modifier.height(48.dp), ) val status = when { stage != null -> stage.tvLabel()@@ -176,7 +178,7 @@ private fun TvAppTile( if (status != null) { Text( text = status,- style = MaterialTheme.typography.labelSmall,+ style = MaterialTheme.typography.bodyMedium, color = if (stage is InstallStage.Failed) { MaterialTheme.colorScheme.error } else {@@ -193,8 +195,8 @@ private fun TvAppTile( @Composable private fun TvAppIcon(app: UnifiedApp) { val box = Modifier- .size(72.dp)- .clip(RoundedCornerShape(16.dp))+ .size(96.dp)+ .clip(RoundedCornerShape(20.dp)) if (app.iconUrl != null) { AsyncImage( model = app.iconUrl,
appstore/src/main/java/com/vayunmathur/appstore/tv/TvDetail.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvDetail.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvDetail.ktindex 26d3c9fbd3..487b82463a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvDetail.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvDetail.kt@@ -3,34 +3,53 @@ package com.vayunmathur.appstore.tv import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width-import androidx.compose.foundation.rememberScrollState-import androidx.compose.foundation.verticalScroll+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.LazyRow+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.tv.material3.Button import androidx.tv.material3.MaterialTheme+import androidx.tv.material3.Surface import androidx.tv.material3.Text import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.appstore.data.installer.InstallStage import com.vayunmathur.appstore.data.security.VerificationResult+import com.vayunmathur.appstore.ui.formatCount+import com.vayunmathur.appstore.ui.formatSize+import com.vayunmathur.library.image.compose.AsyncImage+import com.vayunmathur.library.image.compose.AsyncImageState+import com.vayunmathur.library.ui.IconDelete import com.vayunmathur.library.ui.IconTv /**- * One app's TV page: what it is, whether it runs on TV, and the install button.+ * One app's TV page: what it is, what it looks like, and the install button. * * The install and update buttons call the same [TvStoreViewModel.install] the browse * rows use — which runs the ordinary [InstallCoordinator] pipeline verbatim, including@@ -39,18 +58,26 @@ import com.vayunmathur.library.ui.IconTv * TV compatibility is stated explicitly rather than implied by presence: an app that * reached this screen passed the catalogue filter, and the line says why (a leanback * entry the source published) or that the source said nothing either way.+ *+ * Order mirrors the phone's detail page — screenshots, the install button, the+ * description, then the facts, then provenance — at ten-foot density: a+ * focus-scrolling [LazyColumn], 56–64dp buttons, 12–16dp fact gaps, and `bodyLarge`+ * body text. Share/browser/Play links and `market://` deep links are phone-only and+ * stay off this screen. */ @Composable fun TvAppDetail( viewModel: TvStoreViewModel,- onBack: () -> Unit, modifier: Modifier = Modifier,+ onBack: () -> Unit = {}, ) { val state by viewModel.detail.collectAsState() TvDetailScreen( state = state, onInstall = { app -> viewModel.install(app) }, onOpen = { pkg -> viewModel.openApp(pkg) },+ onUninstall = { pkg -> viewModel.uninstallApp(pkg) },+ onDismissFailure = { pkg -> viewModel.dismissInstallFailure(pkg) }, onBack = onBack, modifier = modifier, )@@ -60,97 +87,249 @@ fun TvAppDetail( * Stateless detail, so it can be rendered in a preview. * * // RAW SCAFFOLD EXCEPTION: androidx.tv has no AppScaffold equivalent; the detail is- * a single scrollable column with a back button, not a scaffolded phone screen.+ * a single focus-scrolling column with a back button, not a scaffolded phone screen. */ @Composable internal fun TvDetailScreen( state: TvDetailUiState,+ modifier: Modifier = Modifier, onInstall: (UnifiedApp) -> Unit = {}, onOpen: (String) -> Unit = {},+ onUninstall: (String) -> Unit = {},+ onDismissFailure: (String) -> Unit = {}, onBack: () -> Unit = {},- modifier: Modifier = Modifier, ) { val app = state.app ?: return val stage = state.stage val busy = stage != null && stage !is InstallStage.Failed- Column(+ // A LazyColumn, not a scrollable Column: D-pad focus moves item to item, and the+ // list scrolls the focused block into view. A Column would scroll the pixels while+ // focus stays wherever it was.+ LazyColumn( modifier = modifier .fillMaxSize() .background(MaterialTheme.colorScheme.background)- .verticalScroll(rememberScrollState()) .padding(horizontal = 48.dp, vertical = 32.dp), verticalArrangement = Arrangement.spacedBy(16.dp),+ contentPadding = PaddingValues(bottom = 24.dp), ) {- Button(onClick = onBack) {- Text(stringResource(R.string.tv_detail_back))- }- Text(- text = app.name,- style = MaterialTheme.typography.displaySmall,- color = MaterialTheme.colorScheme.onSurface,- )- if (app.summary.isNotBlank()) {- Text(- text = app.summary,- style = MaterialTheme.typography.titleMedium,- color = MaterialTheme.colorScheme.onSurfaceVariant,- )+ item("back") {+ Button(onClick = onBack, modifier = Modifier.heightIn(min = 56.dp)) {+ Text(stringResource(R.string.tv_detail_back), style = MaterialTheme.typography.bodyLarge)+ } }- TvCompatLine(app = app)- Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {- when {- busy -> Button(onClick = {}, enabled = false, modifier = Modifier.weight(1f)) {- Text(stage.tvStageLabel())+ item("title") {+ Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+ Text(+ text = app.name,+ style = MaterialTheme.typography.displaySmall,+ color = MaterialTheme.colorScheme.onSurface,+ )+ if (app.summary.isNotBlank()) {+ Text(+ text = app.summary,+ style = MaterialTheme.typography.titleMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ if (state.isLoadingDetails) {+ Text(+ text = stringResource(R.string.sync_in_progress),+ style = MaterialTheme.typography.bodyLarge,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ ) }- state.hasUpdate -> {- Button(onClick = { onInstall(app) }, modifier = Modifier.weight(1f)) {- Text(stringResource(R.string.action_update))+ }+ }+ item("compat") { TvCompatLine(app = app) }+ item("actions") {+ Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {+ when {+ busy -> Button(+ onClick = {},+ enabled = false,+ modifier = Modifier+ .weight(1f)+ .heightIn(min = 56.dp),+ ) {+ Text(stage.tvStageLabel(), style = MaterialTheme.typography.bodyLarge) }- Button(onClick = { onOpen(app.packageName) }) {- Text(stringResource(com.vayunmathur.library.ui.R.string.open))+ state.hasUpdate -> {+ Button(+ onClick = { onInstall(app) },+ modifier = Modifier+ .weight(1f)+ .heightIn(min = 56.dp),+ ) {+ Text(+ stringResource(R.string.action_update),+ style = MaterialTheme.typography.bodyLarge,+ )+ }+ Button(+ onClick = { onOpen(app.packageName) },+ modifier = Modifier.heightIn(min = 56.dp),+ ) {+ Text(+ stringResource(com.vayunmathur.library.ui.R.string.open),+ style = MaterialTheme.typography.bodyLarge,+ )+ } }- }- state.isInstalled -> {- Button(- onClick = { onOpen(app.packageName) },- modifier = Modifier.weight(1f),+ state.isInstalled -> {+ Button(+ onClick = { onOpen(app.packageName) },+ modifier = Modifier+ .weight(1f)+ .heightIn(min = 56.dp),+ ) {+ Text(+ stringResource(com.vayunmathur.library.ui.R.string.open),+ style = MaterialTheme.typography.bodyLarge,+ )+ }+ Button(+ onClick = { onUninstall(app.packageName) },+ modifier = Modifier.heightIn(min = 56.dp),+ ) {+ // IconXxx from library/ui — never Icon()/painterResource() in app modules.+ IconDelete()+ }+ }+ else -> Button(+ onClick = { onInstall(app) },+ modifier = Modifier+ .weight(1f)+ .heightIn(min = 56.dp), ) {- Text(stringResource(com.vayunmathur.library.ui.R.string.open))+ Text(+ stringResource(R.string.action_install),+ style = MaterialTheme.typography.bodyLarge,+ ) } }- else -> Button(onClick = { onInstall(app) }, modifier = Modifier.weight(1f)) {- Text(stringResource(R.string.action_install))- } } } if (stage is InstallStage.Failed) {- Text(- text = stringResource(R.string.stage_failed, stage.reason),- style = MaterialTheme.typography.bodyMedium,- color = MaterialTheme.colorScheme.error,- )+ item("failure") {+ Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {+ Text(+ text = stringResource(R.string.stage_failed, stage.reason),+ style = MaterialTheme.typography.bodyLarge,+ color = MaterialTheme.colorScheme.error,+ )+ // Retry is dismiss + install: clearing the stage re-arms the install+ // button, which reports the outcome once via AppMessages.+ Button(+ onClick = {+ onDismissFailure(app.packageName)+ onInstall(app)+ },+ modifier = Modifier.heightIn(min = 56.dp),+ ) {+ Text(+ stringResource(R.string.action_check_again),+ style = MaterialTheme.typography.bodyLarge,+ )+ }+ }+ } } state.verification.toMessage()?.let { message ->- Text(- text = message,- style = MaterialTheme.typography.bodySmall,- color = MaterialTheme.colorScheme.onSurfaceVariant,- )+ item("verification") {+ Text(+ text = message,+ style = MaterialTheme.typography.bodyLarge,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ } }+ // TV screenshots where the source publishes a separate set — phone-aspect shots+ // jump between ratios when mixed. Falls back to the phone set, mirroring the+ // phone's strip order (screenshots, not hero-first: the hero is phone-framed).+ val shots = app.tvScreenshots.ifEmpty { app.screenshots }+ if (shots.isNotEmpty()) {+ item("screenshots") {+ TvScreenshotStrip(urls = shots)+ }+ }+ item("facts") { TvDetailFactRow(app = app) } if (app.description.isNotBlank()) {- Text(- text = stringResource(R.string.tv_detail_about),- style = MaterialTheme.typography.titleLarge,- color = MaterialTheme.colorScheme.onSurface,- fontWeight = FontWeight.SemiBold,- )- Text(- text = app.description,- style = MaterialTheme.typography.bodyMedium,- color = MaterialTheme.colorScheme.onSurfaceVariant,- )+ item("about") {+ TvDetailAbout(app = app)+ }+ }+ if (app.whatsNew?.isNotBlank() == true) {+ item("whatsnew") {+ Column(+ modifier = Modifier.fillMaxWidth(),+ verticalArrangement = Arrangement.spacedBy(8.dp),+ ) {+ Text(+ text = stringResource(R.string.detail_whats_new),+ style = MaterialTheme.typography.titleLarge,+ color = MaterialTheme.colorScheme.onSurface,+ fontWeight = FontWeight.SemiBold,+ )+ app.updatedOn?.let {+ Text(+ text = it,+ style = MaterialTheme.typography.bodyLarge,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ Text(+ text = app.whatsNew,+ style = MaterialTheme.typography.bodyLarge,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ }+ }+ // Anti-features and reproducibility, simplified: the phone's chip row verbatim+ // would be a second focus axis; a plain list at bodyLarge reads at ten feet.+ val flags = buildList {+ if (app.reproducible) add(stringResource(R.string.chip_reproducible))+ if (app.containsAds) add(stringResource(R.string.chip_contains_ads))+ addAll(app.antiFeatures) }- TvDetailFacts(app = app)+ if (flags.isNotEmpty()) {+ item("flags") {+ Column(+ modifier = Modifier.fillMaxWidth(),+ verticalArrangement = Arrangement.spacedBy(8.dp),+ ) {+ flags.forEach { flag ->+ Text(+ text = flag,+ style = MaterialTheme.typography.bodyLarge,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ }+ }+ }+ if (app.permissions.isNotEmpty()) {+ item("permissions") {+ Column(+ modifier = Modifier.fillMaxWidth(),+ verticalArrangement = Arrangement.spacedBy(8.dp),+ ) {+ Text(+ text = stringResource(R.string.detail_permissions),+ style = MaterialTheme.typography.titleLarge,+ color = MaterialTheme.colorScheme.onSurface,+ fontWeight = FontWeight.SemiBold,+ )+ Text(+ text = app.permissions.joinToString("\n") { it.substringAfterLast('.') },+ style = MaterialTheme.typography.bodyLarge,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ }+ }+ item("details") { TvDetailFacts(app = app) } } } @@ -178,15 +357,147 @@ private fun TvCompatLine(app: UnifiedApp) { } } +/** TV screenshots at a fixed height so mixed aspect ratios still scroll as one strip. */+@Composable+private fun TvScreenshotStrip(urls: List<String>) {+ LazyRow(+ modifier = Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.spacedBy(16.dp),+ ) {+ items(urls, key = { it }) { url ->+ // The width has to be stated: AsyncImage draws its bitmap with matchParentSize,+ // which contributes nothing to the measure pass, so an image given only a+ // height resolves to zero wide. Start at 16:9 and switch to the real ratio+ // once the bitmap has been decoded.+ var ratio by remember(url) { mutableFloatStateOf(LANDSCAPE_SCREENSHOT_RATIO) }+ AsyncImage(+ model = url,+ contentDescription = null,+ modifier = Modifier+ .height(220.dp)+ .aspectRatio(ratio)+ .clip(RoundedCornerShape(12.dp))+ .background(MaterialTheme.colorScheme.surfaceVariant),+ contentScale = ContentScale.Fit,+ onState = { state ->+ val size = (state as? AsyncImageState.Success)?.painter?.intrinsicSize+ if (size != null && size.width > 0f && size.height > 0f) {+ ratio = size.width / size.height+ }+ },+ )+ }+ }+}++/** 16:9, the shape a TV screenshot is until its own is known. */+private const val LANDSCAPE_SCREENSHOT_RATIO = 16f / 9f++/** Rating, installs, size and age rating, in whatever subset the source published. */+@Composable+private fun TvDetailFactRow(app: UnifiedApp) {+ val cells = buildList<Pair<String, String>> {+ app.rating?.let {+ add(+ stringResource(R.string.fact_rating) to+ String.format(java.util.Locale.US, "%.1f★", it)+ )+ }+ if (app.installs > 0) add(stringResource(R.string.fact_installs) to formatCount(app.installs))+ if (app.sizeBytes > 0) add(stringResource(R.string.fact_size) to formatSize(app.sizeBytes))+ app.contentRating?.let { add(stringResource(R.string.fact_rated) to it) }+ app.versionName?.let { add(stringResource(R.string.fact_version) to it) }+ }+ if (cells.isEmpty()) return+ Row(+ modifier = Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.SpaceEvenly,+ ) {+ cells.take(4).forEachIndexed { index, (label, value) ->+ if (index > 0) {+ Spacer(+ Modifier+ .width(1.dp)+ .height(32.dp)+ .background(MaterialTheme.colorScheme.outlineVariant),+ )+ }+ TvStatCell(label = label, value = value, modifier = Modifier.weight(1f))+ }+ }+}++/** A labelled value in the facts row, at a ten-foot floor. */+@Composable+private fun TvStatCell(label: String, value: String, modifier: Modifier = Modifier) {+ Column(+ modifier = modifier,+ horizontalAlignment = Alignment.CenterHorizontally,+ ) {+ Text(+ text = value,+ style = MaterialTheme.typography.bodyLarge,+ fontWeight = FontWeight.SemiBold,+ color = MaterialTheme.colorScheme.onSurface,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ )+ Text(+ text = label,+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ )+ }+}++@Composable+private fun TvDetailAbout(app: UnifiedApp) {+ var expanded by remember(app.packageName) { mutableStateOf(false) }+ Column(+ modifier = Modifier.fillMaxWidth(),+ verticalArrangement = Arrangement.spacedBy(12.dp),+ ) {+ Text(+ text = stringResource(R.string.tv_detail_about),+ style = MaterialTheme.typography.titleLarge,+ color = MaterialTheme.colorScheme.onSurface,+ fontWeight = FontWeight.SemiBold,+ )+ Text(+ text = app.description,+ style = MaterialTheme.typography.bodyLarge,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ maxLines = if (expanded) Int.MAX_VALUE else 5,+ overflow = TextOverflow.Ellipsis,+ )+ Surface(onClick = { expanded = !expanded }) {+ Text(+ text = stringResource(+ if (expanded) R.string.action_show_less else R.string.action_read_more+ ),+ style = MaterialTheme.typography.bodyLarge,+ color = MaterialTheme.colorScheme.primary,+ modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp),+ )+ }+ }+}+ @Composable private fun TvDetailFacts(app: UnifiedApp) { Column( modifier = Modifier.fillMaxWidth(),- verticalArrangement = Arrangement.spacedBy(6.dp),+ verticalArrangement = Arrangement.spacedBy(12.dp), ) { app.versionName?.let { TvFact(stringResource(R.string.fact_version), it) } app.author?.let { TvFact(stringResource(R.string.tv_detail_author), it) } app.license?.let { TvFact(stringResource(R.string.detail_license), it) }+ app.targetSdk?.let { TvFact(stringResource(R.string.detail_target_sdk), it.toString()) }+ if (app.ratingCount > 0) {+ TvFact(stringResource(R.string.detail_rating_count), formatCount(app.ratingCount))+ } TvFact(stringResource(R.string.detail_package), app.packageName) } }@@ -196,12 +507,12 @@ private fun TvFact(label: String, value: String) { Column(Modifier.fillMaxWidth()) { Text( text = label,- style = MaterialTheme.typography.labelSmall,+ style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, ) Text( text = value,- style = MaterialTheme.typography.bodyMedium,+ style = MaterialTheme.typography.bodyLarge, color = MaterialTheme.colorScheme.onSurface, ) }
appstore/src/main/java/com/vayunmathur/appstore/tv/TvMainActivity.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvMainActivity.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvMainActivity.ktindex 13a66e1ab2..c3589e497a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvMainActivity.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvMainActivity.kt@@ -1,28 +1,70 @@ package com.vayunmathur.appstore.tv +import androidx.compose.foundation.background+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.stringResource import androidx.tv.material3.MaterialTheme+import androidx.tv.material3.Tab+import androidx.tv.material3.TabRow+import androidx.tv.material3.Text import androidx.tv.material3.darkColorScheme import androidx.lifecycle.viewmodel.compose.viewModel+import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.AppStoreDatabaseRepository import com.vayunmathur.appstore.data.UnifiedApp+import com.vayunmathur.appstore.data.UpdateCheckWorker import com.vayunmathur.library.ui.MaActivity+import com.vayunmathur.library.util.MainNavigation+import com.vayunmathur.library.util.NavBackStack+import com.vayunmathur.library.util.NavKey+import com.vayunmathur.library.util.rememberNavBackStack+import kotlinx.serialization.Serializable++/**+ * TV-only destinations: browse/search/updates tabs plus one pushed detail.+ *+ * A separate sealed interface from the phone [com.vayunmathur.appstore.Route], following+ * youpipe's `TvRoute`, so a TV destination can never leak into the phone back stack or+ * vice versa. Search and updates are tabs here rather than pushed routes: on a D-pad the+ * tab strip is the entry point, and each tab keeps its own screen so focus restores per tab.+ */+@Serializable+sealed interface TvStoreRoute : NavKey {+ /** The tab strip: browse, search, updates. No swipe, D-pad only. */+ @Serializable+ data object Main : TvStoreRoute++ /** One app's page, pushed over the tabs. */+ @Serializable+ data class Detail(val packageName: String) : TvStoreRoute+} /** * The TV entry: opened from TV launcher rows (LEANBACK_LAUNCHER). The phone MainActivity * stays exactly as it is — this activity hosts the D-pad store UI. *- * Browse and detail are two states, not a nav graph: one selected app or none. The- * ViewModel is the phone repositories reused verbatim, so installs go through the- * ordinary pipeline including the TV-compat gate.+ * Browse, search, updates, and detail are nav-graph destinations, not activity states: the+ * tab strip owns browse/search/updates, and detail pushes over it. The ViewModel is the+ * phone repositories reused verbatim, so installs go through the ordinary pipeline+ * including the TV-compat gate. */ class TvMainActivity : MaActivity() { override val edgeToEdge: Boolean = false + override fun onCreateBeforeContent() {+ // Same arming the phone does: keep the 12-hour update check scheduled from the TV+ // entry too, so a TV-driven install still gets its update notifications — which+ // route back here (see UpdateCheckWorker).+ UpdateCheckWorker.schedule(this)+ }+ @Composable override fun AppTheme(content: @Composable () -> Unit) { // Always dark, not dynamic: a TV has no wallpaper to derive a scheme from.@@ -35,28 +77,91 @@ class TvMainActivity : MaActivity() { val repository = remember { AppStoreDatabaseRepository.get(this) } val factory = remember { TvStoreViewModelFactory(this, repository.database) } val viewModel: TvStoreViewModel = viewModel(factory = factory)- TvRoot(viewModel = viewModel)+ TvStoreNavigation(viewModel = viewModel)+ }+}++/**+ * The TV navigation host: [rememberNavBackStack] + [MainNavigation] over [TvStoreRoute].+ *+ * The detail destination reads the selection the tab already set via+ * [TvStoreViewModel.selectApp] — popping clears it, so BACK from detail always lands on+ * the tab that opened it with no stale selection behind it.+ */+@Composable+private fun TvStoreNavigation(viewModel: TvStoreViewModel) {+ val backStack = rememberNavBackStack<TvStoreRoute>(TvStoreRoute.Main)+ MainNavigation(backStack) {+ entry<TvStoreRoute.Main> {+ TvStoreTabs(backStack = backStack, viewModel = viewModel)+ }+ entry<TvStoreRoute.Detail> {+ TvAppDetail(+ viewModel = viewModel,+ onBack = {+ backStack.pop()+ viewModel.clearSelection()+ },+ )+ } } } +/**+ * The three TV tabs as a D-pad strip: Browse, Search, Updates.+ *+ * Unlike the phone's `TabbedPagerScaffold`, tabs are destinations only — selecting one swaps+ * the content below without any swipe gesture. Per-tab focus restores because each tab's+ * screen owns its own list state.+ */ @Composable-private fun TvRoot(viewModel: TvStoreViewModel) {- var selected by remember { mutableStateOf<UnifiedApp?>(null) }- if (selected == null) {- TvStoreHome(- viewModel = viewModel,- onAppClick = { app ->- viewModel.selectApp(app)- selected = app- },- )- } else {- TvAppDetail(- viewModel = viewModel,- onBack = {- viewModel.clearSelection()- selected = null- },- )+private fun TvStoreTabs(+ backStack: NavBackStack<TvStoreRoute>,+ viewModel: TvStoreViewModel,+) {+ var tab by remember { mutableIntStateOf(TV_TAB_BROWSE) }++ fun openDetail(app: UnifiedApp) {+ viewModel.selectApp(app)+ backStack.add(TvStoreRoute.Detail(app.packageName))+ }++ Column(+ Modifier+ .fillMaxSize()+ .background(MaterialTheme.colorScheme.background),+ ) {+ TabRow(selectedTabIndex = tab) {+ Tab(+ selected = tab == TV_TAB_BROWSE,+ onFocus = { tab = TV_TAB_BROWSE },+ onClick = { tab = TV_TAB_BROWSE },+ ) {+ Text(stringResource(R.string.nav_home))+ }+ Tab(+ selected = tab == TV_TAB_SEARCH,+ onFocus = { tab = TV_TAB_SEARCH },+ onClick = { tab = TV_TAB_SEARCH },+ ) {+ Text(stringResource(R.string.nav_search))+ }+ Tab(+ selected = tab == TV_TAB_UPDATES,+ onFocus = { tab = TV_TAB_UPDATES },+ onClick = { tab = TV_TAB_UPDATES },+ ) {+ Text(stringResource(R.string.nav_updates))+ }+ }+ when (tab) {+ TV_TAB_SEARCH -> TvStoreSearch(viewModel = viewModel, onAppClick = ::openDetail)+ TV_TAB_UPDATES -> TvStoreUpdates(viewModel = viewModel, onAppClick = ::openDetail)+ else -> TvStoreHome(viewModel = viewModel, onAppClick = ::openDetail)+ } } }++private const val TV_TAB_BROWSE = 0+private const val TV_TAB_SEARCH = 1+private const val TV_TAB_UPDATES = 2
appstore/src/main/java/com/vayunmathur/appstore/tv/TvSearch.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvSearch.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvSearch.ktnew file mode 100644index 0000000000..e97e90f396--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvSearch.kt@@ -0,0 +1,332 @@+package com.vayunmathur.appstore.tv++import android.text.format.DateUtils+import androidx.compose.foundation.background+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.LazyRow+import androidx.compose.foundation.lazy.items+import androidx.compose.foundation.text.BasicTextField+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.collectAsState+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.focus.FocusRequester+import androidx.compose.ui.focus.focusRequester+import androidx.compose.ui.platform.LocalFocusManager+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.input.ImeAction+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import androidx.tv.material3.Card+import androidx.tv.material3.MaterialTheme+import androidx.tv.material3.Surface+import androidx.tv.material3.Tab+import androidx.tv.material3.TabRow+import androidx.tv.material3.Text+import com.vayunmathur.appstore.R+import com.vayunmathur.appstore.data.UnifiedApp+import com.vayunmathur.appstore.data.installer.InstallStage+import com.vayunmathur.appstore.util.SourceFilter+import com.vayunmathur.library.ui.IconDownload+import kotlinx.coroutines.delay++/**+ * The TV search hub: query field, source-filter chips, and the local-then-Play merged results.+ *+ * Follows youpipe's `TvSearchPage` D-pad pattern: an entry row holds initial focus and a+ * CENTER press moves focus into the field (opening the TV IME); the IME's search action+ * submits. Results arrive in two waves — the on-disk catalogues answer first, Play's reply+ * merges in a moment later — so the progress line sits above a list that already has+ * content. A Play refusal (e.g. 429) is said above the list, never a silent gap.+ */+@Composable+fun TvStoreSearch(+ viewModel: TvStoreViewModel,+ modifier: Modifier = Modifier,+ onAppClick: (UnifiedApp) -> Unit = {},+) {+ val state by viewModel.search.collectAsState()+ TvSearchScreen(+ state = state,+ onQueryChange = viewModel::setSearch,+ onFilterChange = viewModel::setSearchFilter,+ onAppClick = onAppClick,+ modifier = modifier,+ )+}++/**+ * Stateless search hub, so it can be rendered in a preview.+ *+ * // RAW SCAFFOLD EXCEPTION: androidx.tv has no AppScaffold equivalent; the hub is a+ * titled column with a D-pad list, not a scaffolded phone screen.+ */+@Composable+internal fun TvSearchScreen(+ state: TvSearchUiState,+ modifier: Modifier = Modifier,+ onQueryChange: (String) -> Unit = {},+ onFilterChange: (SourceFilter) -> Unit = {},+ onAppClick: (UnifiedApp) -> Unit = {},+) {+ var fieldText by remember(state.query) { mutableStateOf(state.query) }+ var fieldOpen by remember { mutableStateOf(false) }+ val entryFocus = remember { FocusRequester() }+ val fieldFocus = remember { FocusRequester() }+ val focusManager = LocalFocusManager.current++ fun submit() {+ onQueryChange(fieldText)+ fieldOpen = false+ focusManager.clearFocus()+ }++ TvSearchInitialFocus(entryFocus)+ Column(+ modifier = modifier+ .fillMaxSize()+ .background(MaterialTheme.colorScheme.background)+ .padding(horizontal = 48.dp, vertical = 32.dp),+ verticalArrangement = Arrangement.spacedBy(16.dp),+ ) {+ Text(+ text = stringResource(R.string.nav_search),+ style = MaterialTheme.typography.headlineLarge,+ color = MaterialTheme.colorScheme.onSurface,+ )+ // The entry row: focused by default, CENTER opens the field, never the IME directly.+ Surface(+ onClick = { fieldOpen = true },+ modifier = Modifier+ .fillMaxWidth()+ .focusRequester(entryFocus),+ ) {+ Text(+ text = fieldText.ifBlank { stringResource(R.string.search_placeholder) },+ style = MaterialTheme.typography.titleMedium,+ color = if (fieldText.isBlank()) {+ MaterialTheme.colorScheme.onSurfaceVariant+ } else {+ MaterialTheme.colorScheme.onSurface+ },+ modifier = Modifier.padding(16.dp),+ )+ }++ if (fieldOpen) {+ // The actual text field: only composed after the explicit open, so the IME can+ // only ever appear as the result of a CENTER press. IME search action submits.+ BasicTextField(+ value = fieldText,+ onValueChange = {+ fieldText = it+ onQueryChange(it)+ },+ modifier = Modifier+ .fillMaxWidth()+ .focusRequester(fieldFocus),+ keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),+ keyboardActions = KeyboardActions(onSearch = { submit() }),+ textStyle = MaterialTheme.typography.titleMedium.copy(+ color = MaterialTheme.colorScheme.onSurface,+ ),+ )+ LaunchedEffect(fieldFocus) {+ fieldFocus.requestFocus()+ }+ }++ TvSourceFilterRow(filter = state.filter, onFilterChange = onFilterChange)++ if (state.isSearching && state.results.isNotEmpty()) {+ Text(+ text = stringResource(R.string.updates_checking),+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }++ // Play's half refused (429): say so above the results rather than silently+ // showing a list that is missing half its sources.+ val playError = state.playError.takeIf { it.isNotBlank() }+ if (playError != null) {+ Text(+ text = playError,+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.error,+ )+ }++ when {+ state.query.isBlank() -> Box(+ Modifier.fillMaxSize(),+ contentAlignment = Alignment.Center,+ ) {+ Text(+ text = stringResource(R.string.search_prompt_message),+ style = MaterialTheme.typography.titleMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ textAlign = TextAlign.Center,+ )+ }++ state.results.isEmpty() && (state.isSearching || !state.hasSearched) -> Box(+ Modifier.fillMaxSize(),+ contentAlignment = Alignment.Center,+ ) {+ Text(+ text = stringResource(R.string.sync_in_progress),+ style = MaterialTheme.typography.titleMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }++ state.results.isEmpty() -> Box(+ Modifier.fillMaxSize(),+ contentAlignment = Alignment.Center,+ ) {+ Text(+ text = stringResource(R.string.search_no_results_title, state.query),+ style = MaterialTheme.typography.titleMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ textAlign = TextAlign.Center,+ )+ }++ else -> LazyColumn(+ modifier = Modifier.fillMaxSize(),+ verticalArrangement = Arrangement.spacedBy(12.dp),+ contentPadding = PaddingValues(bottom = 24.dp),+ ) {+ items(state.results, key = { it.packageName }) { app ->+ TvSearchRow(+ app = app,+ isInstalled = app.packageName in state.installedPackages,+ stage = state.stages[app.packageName],+ onClick = { onAppClick(app) },+ )+ }+ }+ }+ }+}++/** Source-filter chips as a focusable D-pad row. */+@Composable+private fun TvSourceFilterRow(+ filter: SourceFilter,+ onFilterChange: (SourceFilter) -> Unit,+) {+ // A TabRow is the tv-material D-pad answer to a chip row: LEFT/RIGHT moves between+ // filters, DOWN drops into the results. No swipe, no pointer.+ TabRow(selectedTabIndex = SourceFilter.entries.indexOf(filter)) {+ for (entry in SourceFilter.entries) {+ Tab(+ selected = filter == entry,+ onFocus = { onFilterChange(entry) },+ onClick = { onFilterChange(entry) },+ ) {+ Text(stringResource(entry.tvLabelRes()))+ }+ }+ }+}++private fun SourceFilter.tvLabelRes(): Int = when (this) {+ SourceFilter.ALL -> R.string.filter_all+ SourceFilter.MODERN_APPS -> R.string.source_chip_modern_apps+ SourceFilter.PROPRIETARY -> R.string.source_chip_proprietary+ SourceFilter.FDROID -> R.string.source_chip_fdroid+ SourceFilter.PLAYSTORE -> R.string.source_chip_play+ SourceFilter.ACCRESCENT -> R.string.source_chip_accrescent+}++/** One search hit: name, summary, source, and install/update status. */+@Composable+private fun TvSearchRow(+ app: UnifiedApp,+ isInstalled: Boolean,+ stage: InstallStage?,+ onClick: () -> Unit,+) {+ Card(onClick = onClick, modifier = Modifier.fillMaxWidth()) {+ Column(+ modifier = Modifier.padding(16.dp),+ verticalArrangement = Arrangement.spacedBy(4.dp),+ ) {+ Text(+ text = app.name,+ style = MaterialTheme.typography.titleMedium,+ color = MaterialTheme.colorScheme.onSurface,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ )+ if (app.summary.isNotBlank()) {+ Text(+ text = app.summary,+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ maxLines = 2,+ overflow = TextOverflow.Ellipsis,+ )+ }+ val status = when {+ stage != null -> stage.tvSearchLabel()+ isInstalled -> stringResource(R.string.installed)+ else -> null+ }+ if (status != null) {+ Text(+ text = status,+ style = MaterialTheme.typography.bodyMedium,+ color = if (stage is InstallStage.Failed) {+ MaterialTheme.colorScheme.error+ } else {+ MaterialTheme.colorScheme.onSurfaceVariant+ },+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ )+ }+ }+ }+}++@Composable+private fun InstallStage.tvSearchLabel(): String = when (this) {+ InstallStage.Preparing -> stringResource(R.string.stage_preparing)+ is InstallStage.Downloading -> stringResource(R.string.stage_downloading, (fraction * 100).toInt())+ InstallStage.Verifying -> stringResource(R.string.stage_verifying)+ InstallStage.Installing -> stringResource(R.string.stage_installing)+ is InstallStage.Failed -> stringResource(R.string.stage_failed, reason)+}++/** Request focus once composed, so the D-pad has somewhere to start on this hub. */+@Composable+private fun TvSearchInitialFocus(requester: FocusRequester) {+ LaunchedEffect(requester) {+ // One frame late: requesting during composition races the focus system on first+ // layout and silently drops, leaving the D-pad dead until the user presses something.+ delay(FRAME_DELAY_MS)+ runCatching { requester.requestFocus() }+ }+}++private const val FRAME_DELAY_MS = 16L
appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreViewModel.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreViewModel.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreViewModel.ktindex b1e76d9564..0351d7a046 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreViewModel.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreViewModel.kt@@ -1,24 +1,35 @@ package com.vayunmathur.appstore.tv import android.app.Application+import android.content.Intent import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.viewModelScope+import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.AppDatabase import com.vayunmathur.appstore.data.AppSource import com.vayunmathur.appstore.data.CatalogRepository import com.vayunmathur.appstore.data.DefaultRepos import com.vayunmathur.appstore.data.InstalledAppsRepository+import com.vayunmathur.appstore.data.InstalledInfo+import com.vayunmathur.appstore.data.SettingsRepository import com.vayunmathur.appstore.data.SyncStep import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.appstore.data.accrescent.AccrescentRepository import com.vayunmathur.appstore.data.installer.InstallCoordinator+import com.vayunmathur.appstore.data.installer.InstallFailureBatch import com.vayunmathur.appstore.data.installer.InstallStage+import com.vayunmathur.appstore.data.play.PlayAuthState import com.vayunmathur.appstore.data.play.PlayRepository import com.vayunmathur.appstore.data.priority+import com.vayunmathur.appstore.data.searchCandidate import com.vayunmathur.appstore.data.security.ApkCertificates-import com.vayunmathur.appstore.R+import com.vayunmathur.appstore.data.security.VerificationResult+import com.vayunmathur.appstore.domain.SearchRanking+import com.vayunmathur.appstore.util.SourceFilter import com.vayunmathur.library.util.AppMessages+import kotlinx.coroutines.Job+import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow@@ -45,6 +56,7 @@ class TvStoreViewModel( internal val play = PlayRepository(context) internal val accrescent = AccrescentRepository(context, db) internal val installedRepo = InstalledAppsRepository(context)+ internal val settings = SettingsRepository(context, viewModelScope) internal val installer = InstallCoordinator(context, db, play, accrescent, viewModelScope) { ApkCertificates.selfSigners(context) }@@ -54,6 +66,29 @@ class TvStoreViewModel( internal val isLoadingFlow = MutableStateFlow(true) internal val statusMessageFlow = MutableStateFlow("") internal val selectedAppFlow = MutableStateFlow<UnifiedApp?>(null)+ internal val isLoadingDetailsFlow = MutableStateFlow(false)+ internal var detailJob: Job? = null++ // --- Search hub state -----------------------------------------------------------+ internal val queryFlow = MutableStateFlow("")+ internal val searchResultsFlow = MutableStateFlow<List<UnifiedApp>>(emptyList())+ internal val searchFilterFlow = MutableStateFlow(SourceFilter.ALL)+ internal val isSearchingFlow = MutableStateFlow(false)+ internal val hasSearchedFlow = MutableStateFlow(false)+ /** Play's half of the last search failed (e.g. 429); shown above the list. */+ internal val searchPlayErrorFlow = MutableStateFlow("")+ internal var searchJob: Job? = null++ // --- Updates hub state ----------------------------------------------------------+ internal val catalogUpdatesFlow = MutableStateFlow<List<UnifiedApp>>(emptyList())+ internal val playUpdatesFlow = MutableStateFlow<List<UnifiedApp>>(emptyList())+ internal val accrescentUpdatesFlow = MutableStateFlow<List<UnifiedApp>>(emptyList())+ internal val isCheckingUpdatesFlow = MutableStateFlow(false)+ internal val lastUpdateCheckFlow = MutableStateFlow(0L)+ internal var updateAllJob: Job? = null++ // --- Accrescent home row --------------------------------------------------------+ internal val accrescentAppsFlow = MutableStateFlow<List<UnifiedApp>>(emptyList()) val home: StateFlow<TvHomeUiState> = combine( sectionsFlow,@@ -73,29 +108,105 @@ class TvStoreViewModel( val detail: StateFlow<TvDetailUiState> = combine( selectedAppFlow,+ isLoadingDetailsFlow, installedRepo.apps, installer.stages, installer.verification,- ) { app, installed, stages, verification ->+ ) { app, loading, installed, stages, verification -> val pkg = app?.packageName TvDetailUiState( app = app, installedInfo = installed.find { it.packageName == pkg }, stage = stages[pkg], verification = verification[pkg],+ isLoadingDetails = loading, ) }.stateIn(viewModelScope, SharingStarted.Eagerly, TvDetailUiState()) + /**+ * Everything the TV search hub draws.+ *+ * Same shape as the phone's `SearchUiState`: the raw two-wave results plus the+ * selected [SourceFilter], so the screen is a pure filter over the ranked merge.+ */+ val search: StateFlow<TvSearchUiState> = combine(+ queryFlow,+ combine(searchResultsFlow, searchFilterFlow) { results, filter ->+ results to filter+ },+ isSearchingFlow,+ hasSearchedFlow,+ combine(searchPlayErrorFlow, installedRepo.apps, installer.stages) { error, installed, stages ->+ Triple(error, installed.map { it.packageName }.toSet(), stages)+ },+ ) { query, (results, filter), searching, searched, (playError, installed, stages) ->+ TvSearchUiState(+ query = query,+ results = results.filter { filter.source == null || it.source == filter.source },+ filter = filter,+ isSearching = searching,+ hasSearched = searched,+ playError = playError,+ installedPackages = installed,+ stages = stages,+ )+ }.stateIn(viewModelScope, SharingStarted.Eagerly, TvSearchUiState())++ /**+ * Everything the TV updates hub draws.+ *+ * Same shape as the phone's `UpdatesUiState`: the merged update list plus the+ * installed versions behind it, so each row can show old → new.+ */+ val updatesUi: StateFlow<TvUpdatesUiState> = combine(+ catalogUpdatesFlow,+ playUpdatesFlow,+ accrescentUpdatesFlow,+ combine(installedRepo.apps, installer.stages) { installed, stages ->+ installed to stages+ },+ combine(isCheckingUpdatesFlow, lastUpdateCheckFlow, statusMessageFlow) { checking, checkedAt, message ->+ Triple(checking, checkedAt, message)+ },+ ) { catalogUpdates, playUpdates, accrescentUpdates, (installed, stages), (checking, checkedAt, message) ->+ // The surviving row's source decides which download-and-verify path the update+ // takes, so it has to be the same precedence search and the home rows use.+ // Re-check against what is on the device rather than trusting the lists: the+ // Play half is a snapshot from the last network check.+ val installedVersions = installed.associate { it.packageName to it.versionCode }+ val list = (catalogUpdates + playUpdates + accrescentUpdates)+ .sortedBy { it.source.priority }+ .distinctBy { it.packageName }+ .filter { app ->+ val installedVersion = installedVersions[app.packageName] ?: return@filter false+ app.versionCode > installedVersion+ }+ .sortedBy { it.name.lowercase() }+ TvUpdatesUiState(+ updates = list,+ installedInfos = installed.associateBy { it.packageName },+ stages = stages,+ isChecking = checking,+ lastCheckedAt = checkedAt,+ statusMessage = message,+ )+ }.stateIn(viewModelScope, SharingStarted.Eagerly, TvUpdatesUiState())+ init { viewModelScope.launch {+ enabledSourcesFlow.value = settings.readEnabledSources() installedRepo.refresh() if (AppSource.PLAYSTORE in enabledSourcesFlow.value) play.restore() syncIfNeverSynced() loadHome() }+ viewModelScope.launch { loadAccrescent(enabledSourcesFlow.value) } viewModelScope.launch { combine(catalog.packageIndex, installedRepo.updatable) { _, _ -> Unit }- .collect { loadHome() }+ .collect {+ loadHome()+ catalogUpdatesFlow.value = catalog.updatesFor(installedRepo.updatable.value)+ } } } @@ -116,8 +227,12 @@ class TvStoreViewModel( ) if (enabled.intersect(offlineSources).isEmpty()) return if (catalog.recentlyUpdatedBySource(AppSource.FDROID, 1).isNotEmpty() ||- catalog.recentlyUpdatedBySource(AppSource.MODERN_APPS, 1).isNotEmpty()+ catalog.recentlyUpdatedBySource(AppSource.MODERN_APPS, 1).isNotEmpty() ||+ catalog.recentlyUpdatedBySource(AppSource.PROPRIETARY, 1).isNotEmpty() ) {+ // The offline gate stays quiet, but Accrescent is network-backed: refresh its+ // allowlist + listings on every cold start that reaches this far, same as the phone.+ loadAccrescent(enabled) return } isLoadingFlow.value = true@@ -163,6 +278,12 @@ class TvStoreViewModel( add(TvSection("modern", "From Modern Apps", it)) } }+ if (AppSource.PROPRIETARY in enabled) {+ catalog.recentlyUpdatedBySource(AppSource.PROPRIETARY, ROW_LIMIT)+ .takeIf { it.isNotEmpty() }?.let {+ add(TvSection("proprietary", context.getString(R.string.section_proprietary_recent), it))+ }+ } if (AppSource.PLAYSTORE in enabled) { play.homeClusters() .filter { it.apps.isNotEmpty() }@@ -177,6 +298,17 @@ class TvStoreViewModel( add(TvSection("fdroid", "New on F-Droid", it)) } }+ if (AppSource.ACCRESCENT in enabled) {+ accrescentAppsFlow.value.takeIf { it.isNotEmpty() }?.let {+ add(+ TvSection(+ "accrescent",+ context.getString(R.string.source_chip_accrescent),+ it,+ )+ )+ }+ } } // Same precedence the phone uses: the surviving row's source decides the // download-and-verify path, so cross-source duplicates resolve identically.@@ -191,13 +323,243 @@ class TvStoreViewModel( } fun selectApp(app: UnifiedApp) {+ detailJob?.cancel() selectedAppFlow.value = app+ detailJob = viewModelScope.launch {+ // The catalogue row wins whenever there is one, even if the user tapped a Play+ // tile for the same package. It is the row an install would actually use — it+ // carries the signer and hash an authenticated index published — so showing+ // the Play listing here would describe a download this store is not going to+ // make. Mirrors the phone's selectApp.+ val cached = catalog.byPackage(app.packageName)+ if (cached != null) {+ selectedAppFlow.value = cached+ return@launch+ }+ // Accrescent listings from the home carousel are shells (no version code, no+ // signer yet); fetch the full listing before the page settles.+ if (app.source == AppSource.ACCRESCENT) {+ isLoadingDetailsFlow.value = true+ val details = accrescent.details(app.packageName)+ if (details != null) selectedAppFlow.value = details+ isLoadingDetailsFlow.value = false+ return@launch+ }+ // Play listings from a cluster are shells: no description, no screenshots, no+ // version code. Fill them in before the page settles.+ if (app.source == AppSource.PLAYSTORE && app.screenshots.isEmpty() &&+ AppSource.PLAYSTORE in enabledSourcesFlow.value+ ) {+ isLoadingDetailsFlow.value = true+ val details = play.details(app.packageName)+ if (details != null) selectedAppFlow.value = details+ isLoadingDetailsFlow.value = false+ }+ } } fun clearSelection() {+ detailJob?.cancel() selectedAppFlow.value = null } + // --- Search hub -------------------------------------------------------------------++ /**+ * Two-wave search: the on-disk catalogues answer instantly, then Accrescent's cached+ * listings and Play's reply merge in. Mirrors the phone's `setSearchImpl`: the local+ * half is published first so the user never waits on the network to see something.+ */+ fun setSearch(query: String) {+ queryFlow.value = query+ searchJob?.cancel()+ if (query.isBlank()) {+ searchResultsFlow.value = emptyList()+ hasSearchedFlow.value = false+ isSearchingFlow.value = false+ return+ }+ searchJob = viewModelScope.launch {+ delay(SEARCH_DEBOUNCE_MS)+ isSearchingFlow.value = true+ searchPlayErrorFlow.value = ""+ val enabled = enabledSourcesFlow.value++ val local = catalog.searchLocal(query)+ searchResultsFlow.value = SearchRanking.rank(local, query) { it.searchCandidate() }++ // Accrescent has no search RPC: client-side over the listings already cached+ // from the home carousel, so no extra network round-trip.+ val accrescentResults =+ if (AppSource.ACCRESCENT in enabled) accrescent.search(query) else emptyList()+ // Play may refuse (429): the auth state records the refusal and the local half+ // stays on screen — surfaced above the list, never as a silent gap.+ val remote = if (AppSource.PLAYSTORE in enabled) play.search(query) else emptyList()+ searchPlayErrorFlow.value = (play.authState.value as? PlayAuthState.Error)+ ?.let { context.getString(R.string.play_unavailable, it.message) }+ .orEmpty()+ searchResultsFlow.value = SearchRanking.rank(+ (local + remote + accrescentResults)+ .sortedBy { it.source.priority }+ .distinctBy { it.packageName },+ query,+ ) { it.searchCandidate() }+ isSearchingFlow.value = false+ hasSearchedFlow.value = true+ }+ }++ fun setSearchFilter(filter: SourceFilter) {+ searchFilterFlow.value = filter+ }++ // --- Updates hub ------------------------------------------------------------------++ /**+ * Recheck every enabled source for newer builds of installed packages. Mirrors the+ * phone's `checkForUpdatesImpl`: catalogue first, Play only for packages no offline+ * source lists, Accrescent's allowlist refresh then per-package update info.+ */+ fun checkForUpdates() {+ if (isCheckingUpdatesFlow.value) return+ viewModelScope.launch {+ try {+ val enabled = enabledSourcesFlow.value+ isCheckingUpdatesFlow.value = true+ statusMessageFlow.value = context.getString(R.string.updates_checking)++ installedRepo.refresh()+ catalogUpdatesFlow.value = catalog.updatesFor(installedRepo.updatable.value)++ val index = catalog.packageIndex.value+ val installed = installedRepo.updatable.value+ if (AppSource.PLAYSTORE in enabled) {+ val playCandidates = installed+ .filter { it.packageName !in index }+ .map { it.packageName }+ val remote = play.details(playCandidates).associateBy { it.packageName }+ playUpdatesFlow.value = installed.mapNotNull { inst ->+ remote[inst.packageName]?.takeIf { it.versionCode > inst.versionCode }+ }+ }++ if (AppSource.ACCRESCENT in enabled) {+ accrescent.refreshRepoData()+ val accrescentIds = accrescent.appIds()+ accrescentUpdatesFlow.value = installed+ .filter { it.packageName in accrescentIds }+ .mapNotNull { inst -> accrescentUpdate(inst.packageName, inst.versionCode) }+ }++ lastUpdateCheckFlow.value = System.currentTimeMillis()+ statusMessageFlow.value = ""+ } finally {+ // An escaping failure must not wedge the tab mid-check.+ isCheckingUpdatesFlow.value = false+ }+ }+ }++ /**+ * Update everything, sequentially, and report the run once when it is over. Mirrors the+ * phone's `updateAllImpl`: concurrent system dialogs would bury the user in prompts,+ * and failures are collected and summarised instead of one snackbar per app.+ */+ fun updateAll() {+ if (updateAllJob?.isActive == true) return+ updateAllJob = viewModelScope.launch {+ val batch = updatesUi.value.updates+ if (batch.isEmpty()) return@launch+ var started = 0+ val failures = mutableListOf<String>()+ var repeats = 0+ var previousReason: String? = null+ InstallFailureBatch.begin()+ try {+ for ((index, app) in batch.withIndex()) {+ statusMessageFlow.value = context.getString(+ R.string.updates_progress, app.name, index + 1, batch.size+ )+ val outcome = installer.install(app)+ if (outcome.started) {+ started+++ previousReason = null+ repeats = 0+ } else {+ val failure = when (val verdict = outcome.verification) {+ is VerificationResult.Rejected -> verdict.reason+ is VerificationResult.Unverified -> verdict.reason+ is VerificationResult.Verified ->+ context.getString(R.string.install_failure_unknown)+ }+ failures += failure+ repeats = if (failure == previousReason) repeats + 1 else 1+ previousReason = failure+ if (repeats >= REPEATED_FAILURE_LIMIT) break+ }+ }+ // PackageInstaller commits asynchronously: wait for the last verdict before+ // summarising, or it lands on its own afterwards.+ delay(INSTALL_SETTLE_MS)+ } finally {+ statusMessageFlow.value = ""+ failures += InstallFailureBatch.end()+ }++ AppMessages.show(+ if (failures.isEmpty()) {+ context.resources.getQuantityString(+ R.plurals.updates_batch_installed, started, started+ )+ } else {+ context.getString(+ R.string.updates_batch_partial,+ started,+ batch.size,+ failures.first(),+ )+ },+ duration = if (failures.isEmpty()) {+ AppMessages.Duration.Short+ } else {+ AppMessages.Duration.Long+ },+ )+ installedRepo.refresh()+ }+ }++ /**+ * The available Accrescent update for [packageName] as an installable listing, or null+ * when there is none. Same shape as the phone's helper: the version code is the+ * update's, so the updates filter keeps it only while genuinely newer.+ */+ private suspend fun accrescentUpdate(packageName: String, currentVersionCode: Long): UnifiedApp? {+ val update = runCatching {+ accrescent.updateInfo(packageName, currentVersionCode)+ }.getOrNull() ?: return null+ val details = accrescent.details(packageName) ?: UnifiedApp(+ packageName = packageName,+ source = AppSource.ACCRESCENT,+ name = packageName.substringAfterLast('.'),+ )+ return details.copy(versionCode = update.versionCode, versionName = update.versionName)+ }++ // --- Accrescent home row ------------------------------------------------------------++ /**+ * Refresh Accrescent's signed allowlist and its home listings. Fail soft like the+ * phone's `loadAccrescent`: a network blip leaves the previous rows in place rather+ * than emptying them.+ */+ private suspend fun loadAccrescent(enabled: Set<AppSource> = enabledSourcesFlow.value) {+ if (AppSource.ACCRESCENT !in enabled) return+ accrescent.refreshRepoData()+ val page = accrescent.listApps()+ if (page.apps.isNotEmpty()) accrescentAppsFlow.value = page.apps.take(ACCRow_LIMIT)+ }+ fun install(app: UnifiedApp) { viewModelScope.launch { val outcome = installer.install(app)@@ -206,17 +568,17 @@ class TvStoreViewModel( when (verdict) { is com.vayunmathur.appstore.data.security.VerificationResult.Rejected -> context.getString(- com.vayunmathur.appstore.R.string.install_blocked,+ R.string.install_blocked, app.name, verdict.reason, ) else -> if (outcome.started) context.getString(- com.vayunmathur.appstore.R.string.install_started,+ R.string.install_started, app.name, ) else context.getString(- com.vayunmathur.appstore.R.string.install_failed,+ R.string.install_failed, app.name, ) },@@ -226,14 +588,38 @@ class TvStoreViewModel( } fun openApp(packageName: String) {- val launchIntent = runCatching {- context.packageManager.getLaunchIntentForPackage(packageName)- }.getOrNull() ?: return+ val pm = context.packageManager+ val leanbackIntent = Intent(Intent.ACTION_MAIN).apply {+ addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER)+ setPackage(packageName)+ }+ val intent = if (leanbackIntent.resolveActivity(pm) != null) leanbackIntent+ else runCatching { pm.getLaunchIntentForPackage(packageName) }.getOrNull() ?: return runCatching {- context.startActivity(launchIntent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK))+ context.startActivity(intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) } } + /**+ * Uninstall via the system dialog. Mirrors the phone's uninstall: the store never+ * uninstalls silently, and a missing uninstaller surfaces once via AppMessages.+ */+ fun uninstallApp(packageName: String) {+ val started = runCatching {+ context.startActivity(+ Intent(Intent.ACTION_DELETE, android.net.Uri.parse("package:$packageName"))+ .putExtra(Intent.EXTRA_RETURN_RESULT, true)+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)+ )+ true+ }.getOrDefault(false)+ if (!started) AppMessages.show(context.getString(R.string.uninstaller_unavailable))+ }++ /** Clear a failed install's stage so the detail screen offers install again. */+ fun dismissInstallFailure(packageName: String) =+ installer.dismissFailure(packageName)+ override fun onCleared() { accrescent.shutdown() super.onCleared()@@ -242,6 +628,11 @@ class TvStoreViewModel( private companion object { const val ROW_LIMIT = 20 const val CLUSTER_LIMIT = 4+ const val ACCRow_LIMIT = 20+ const val SEARCH_DEBOUNCE_MS = 350L+ const val INSTALL_SETTLE_MS = 1_500L+ /** How many times in a row an update may fail for the same reason before the run ends. */+ const val REPEATED_FAILURE_LIMIT = 3 } } @@ -267,6 +658,8 @@ data class TvDetailUiState( val installedInfo: com.vayunmathur.appstore.data.InstalledInfo? = null, val stage: InstallStage? = null, val verification: com.vayunmathur.appstore.data.security.VerificationResult? = null,+ /** True while richer Play/Accrescent details are being fetched over the network. */+ val isLoadingDetails: Boolean = false, ) { val isInstalled: Boolean get() = installedInfo != null @@ -274,6 +667,35 @@ data class TvDetailUiState( get() = installedInfo != null && (app?.versionCode ?: 0L) > installedInfo.versionCode } +/** Everything the TV search hub draws. Same shape as the phone's `SearchUiState`. */+data class TvSearchUiState(+ val query: String = "",+ val results: List<UnifiedApp> = emptyList(),+ val filter: SourceFilter = SourceFilter.ALL,+ val isSearching: Boolean = false,+ /** True once a search has run for [query], so "no results" can be told from "not yet". */+ val hasSearched: Boolean = false,+ /**+ * Play's half failed (e.g. rate-limited) while the offline half answered. Blank when+ * Play answered or was never asked, so the list alone is the whole story.+ */+ val playError: String = "",+ val installedPackages: Set<String> = emptySet(),+ val stages: Map<String, InstallStage> = emptyMap(),+)++/** Everything the TV updates hub draws. Same shape as the phone's `UpdatesUiState`. */+data class TvUpdatesUiState(+ val updates: List<UnifiedApp> = emptyList(),+ /** Currently-installed info per package, so the row can show old → new versions. */+ val installedInfos: Map<String, InstalledInfo> = emptyMap(),+ val stages: Map<String, InstallStage> = emptyMap(),+ val isChecking: Boolean = false,+ /** ms since epoch of the last completed check, 0 if never. */+ val lastCheckedAt: Long = 0L,+ val statusMessage: String = "",+)+ class TvStoreViewModelFactory( private val context: android.content.Context, private val db: AppDatabase,
appstore/src/main/java/com/vayunmathur/appstore/tv/TvUpdates.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvUpdates.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvUpdates.ktnew file mode 100644index 0000000000..080d0dd522--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvUpdates.kt@@ -0,0 +1,240 @@+package com.vayunmathur.appstore.tv++import android.text.format.DateUtils+import androidx.compose.foundation.background+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.items+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.collectAsState+import androidx.compose.runtime.getValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.pluralStringResource+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.text.style.TextOverflow+import androidx.compose.ui.unit.dp+import androidx.tv.material3.Button+import androidx.tv.material3.Card+import androidx.tv.material3.MaterialTheme+import androidx.tv.material3.Text+import com.vayunmathur.appstore.R+import com.vayunmathur.appstore.data.UnifiedApp+import com.vayunmathur.appstore.data.installer.InstallStage+import com.vayunmathur.library.ui.IconDownload++/**+ * The TV updates hub: pending updates with old → new version deltas, plus update-all.+ *+ * Mirrors the phone's `UpdatesPage`: opening the tab is the request, so the first visit+ * kicks off a check; afterwards the list is the merged catalogue + Play + Accrescent+ * streams. No pull-to-refresh — a TV has no touch — so the check button is the refresh+ * path. Failures of an update-all run surface once via AppMessages (see+ * [TvStoreViewModel.updateAll]), not per row.+ */+@Composable+fun TvStoreUpdates(+ viewModel: TvStoreViewModel,+ modifier: Modifier = Modifier,+ onAppClick: (UnifiedApp) -> Unit = {},+) {+ val state by viewModel.updatesUi.collectAsState()+ // Opening the tab is the request: the phone made the user tap "Sync F-Droid" then+ // "Check Play" by hand, which nobody remembers to do.+ LaunchedEffect(Unit) {+ if (state.lastCheckedAt == 0L) viewModel.checkForUpdates()+ }+ TvUpdatesScreen(+ state = state,+ onCheckForUpdates = viewModel::checkForUpdates,+ onUpdateAll = viewModel::updateAll,+ onInstall = viewModel::install,+ onAppClick = onAppClick,+ modifier = modifier,+ )+}++/**+ * Stateless updates hub, so it can be rendered in a preview.+ *+ * // RAW SCAFFOLD EXCEPTION: androidx.tv has no AppScaffold equivalent; the hub is a+ * titled column with a D-pad list, not a scaffolded phone screen.+ */+@Composable+internal fun TvUpdatesScreen(+ state: TvUpdatesUiState,+ modifier: Modifier = Modifier,+ onCheckForUpdates: () -> Unit = {},+ onUpdateAll: () -> Unit = {},+ onInstall: (UnifiedApp) -> Unit = {},+ onAppClick: (UnifiedApp) -> Unit = {},+) {+ val anyInstalling = state.stages.values.any { it !is InstallStage.Failed }+ Column(+ modifier = modifier+ .fillMaxSize()+ .background(MaterialTheme.colorScheme.background)+ .padding(horizontal = 48.dp, vertical = 32.dp),+ verticalArrangement = Arrangement.spacedBy(16.dp),+ ) {+ Text(+ text = stringResource(R.string.nav_updates),+ style = MaterialTheme.typography.headlineLarge,+ color = MaterialTheme.colorScheme.onSurface,+ )+ Button(+ onClick = onCheckForUpdates,+ enabled = !state.isChecking,+ modifier = Modifier.fillMaxWidth(),+ ) {+ Text(+ if (state.isChecking) stringResource(R.string.updates_checking)+ else stringResource(R.string.action_check_again)+ )+ }+ if (state.updates.isNotEmpty()) {+ Button(+ onClick = onUpdateAll,+ enabled = !anyInstalling,+ modifier = Modifier.fillMaxWidth(),+ ) {+ // IconXxx from library/ui — never Icon()/painterResource() in app modules.+ IconDownload()+ Text(stringResource(R.string.update_all, state.updates.size))+ }+ }++ val status = state.statusMessage.takeIf { it.isNotBlank() }+ ?: state.lastCheckedAt.takeIf { it > 0 }?.let {+ stringResource(+ R.string.updates_last_checked,+ DateUtils.getRelativeTimeSpanString(+ it,+ System.currentTimeMillis(),+ DateUtils.MINUTE_IN_MILLIS,+ ),+ )+ }+ if (status != null) {+ Text(+ text = status,+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }++ if (state.updates.isEmpty() && !state.isChecking) {+ Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {+ Text(+ text = stringResource(R.string.all_apps_up_to_date),+ style = MaterialTheme.typography.titleMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ textAlign = TextAlign.Center,+ )+ }+ } else {+ Text(+ text = pluralStringResource(+ R.plurals.updates_count,+ state.updates.size,+ state.updates.size,+ ),+ style = MaterialTheme.typography.titleMedium,+ color = MaterialTheme.colorScheme.onSurface,+ )+ LazyColumn(+ modifier = Modifier.fillMaxSize(),+ verticalArrangement = Arrangement.spacedBy(12.dp),+ contentPadding = PaddingValues(bottom = 24.dp),+ ) {+ items(state.updates, key = { it.packageName }) { app ->+ val stage = state.stages[app.packageName]+ val installed = state.installedInfos[app.packageName]+ val versionLabel = installed?.let { info ->+ val old = info.versionName?.let { "$it (${info.versionCode})" }+ ?: info.versionCode.toString()+ val new = app.versionName?.let { "$it (${app.versionCode})" }+ ?: app.versionCode.toString()+ stringResource(R.string.version_update, old, new)+ }+ TvUpdateRow(+ app = app,+ versionLabel = versionLabel,+ stage = stage,+ onUpdate = { onInstall(app) },+ onClick = { onAppClick(app) },+ )+ }+ }+ }+ }+}++/** One pending update: name, old → new delta, and an update action. */+@Composable+private fun TvUpdateRow(+ app: UnifiedApp,+ versionLabel: String?,+ stage: InstallStage?,+ onUpdate: () -> Unit,+ onClick: () -> Unit,+) {+ Card(onClick = onClick, modifier = Modifier.fillMaxWidth()) {+ Column(+ modifier = Modifier.padding(16.dp),+ verticalArrangement = Arrangement.spacedBy(8.dp),+ ) {+ Text(+ text = app.name,+ style = MaterialTheme.typography.titleMedium,+ color = MaterialTheme.colorScheme.onSurface,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ )+ if (versionLabel != null) {+ Text(+ text = versionLabel,+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ )+ }+ if (stage is InstallStage.Failed) {+ Text(+ text = stringResource(R.string.stage_failed, stage.reason),+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.error,+ maxLines = 2,+ overflow = TextOverflow.Ellipsis,+ )+ }+ Button(+ onClick = onUpdate,+ enabled = stage == null || stage is InstallStage.Failed,+ ) {+ Text(+ if (stage != null && stage !is InstallStage.Failed) stage.tvUpdateStageLabel()+ else stringResource(R.string.action_update)+ )+ }+ }+ }+}++@Composable+private fun InstallStage.tvUpdateStageLabel(): String = when (this) {+ InstallStage.Preparing -> stringResource(R.string.stage_preparing)+ is InstallStage.Downloading -> stringResource(R.string.stage_downloading, (fraction * 100).toInt())+ InstallStage.Verifying -> stringResource(R.string.stage_verifying)+ InstallStage.Installing -> stringResource(R.string.stage_installing)+ is InstallStage.Failed -> stringResource(R.string.stage_failed, reason)+}
clock/src/main/java/com/vayunmathur/clock/MainActivity.kt
diff --git a/clock/src/main/java/com/vayunmathur/clock/MainActivity.kt b/clock/src/main/java/com/vayunmathur/clock/MainActivity.ktindex 72d723ae9e..4ceb6462dc 100644--- a/clock/src/main/java/com/vayunmathur/clock/MainActivity.kt+++ b/clock/src/main/java/com/vayunmathur/clock/MainActivity.kt@@ -18,7 +18,7 @@ class MainActivity : MaActivity() { ClockViewModelFactory(application, ClockRepository.get(application)) } private lateinit var ds: DataStoreUtils- private lateinit var initialRoute: Route+ private var initialRoute: Route? = null override fun onCreateBeforeContent() { createNotificationChannels(this)
communicate/src/main/rust-mls/src/jni_bridge.rs
diff --git a/communicate/src/main/rust-mls/src/jni_bridge.rs b/communicate/src/main/rust-mls/src/jni_bridge.rsindex c3299617ec..8a0d3a2ba4 100644--- a/communicate/src/main/rust-mls/src/jni_bridge.rs+++ b/communicate/src/main/rust-mls/src/jni_bridge.rs@@ -8,36 +8,33 @@ use crate::group::{self, MESSAGE_MAGIC, WELCOME_MAGIC}; use crate::keys; use crate::message::payload_kind;-use jni::objects::{JByteArray, JClass, JObject, JObjectArray};+use jni::objects::{JByteArray, JClass, JObjectArray};+use jni::strings::JNIString; use jni::sys::{jbyteArray, jint, jobjectArray};-use jni::JNIEnv;+use jni::{Env, EnvUnowned, jni_str}; // PACKAGE STRUCTURE EXCEPTION (JNI) -fn bytes_in<'a>(env: &mut JNIEnv<'a>, arr: &JByteArray<'a>) -> Option<Vec<u8>> {+fn bytes_in<'a>(env: &mut Env, arr: &JByteArray<'a>) -> Option<Vec<u8>> { if arr.is_null() { return None; } env.convert_byte_array(arr).ok() } -fn bytes_out<'a>(env: &mut JNIEnv<'a>, data: &[u8]) -> jbyteArray {+fn bytes_out(env: &mut Env, data: &[u8]) -> jbyteArray { match env.byte_array_from_slice(data) { Ok(a) => a.into_raw(), Err(_) => std::ptr::null_mut(), } } -fn throw_runtime(env: &mut JNIEnv<'_>, msg: &str) {- let _ = env.throw_new("java/lang/RuntimeException", msg);+fn throw_runtime(env: &mut Env, msg: &str) {+ let _ = env.throw_new(jni_str!("java/lang/RuntimeException"), JNIString::from(msg)); } -fn arrays_out<'a>(env: &mut JNIEnv<'a>, parts: &[&[u8]]) -> jobjectArray {- let cls = match env.find_class("[B") {- Ok(c) => c,- Err(_) => return std::ptr::null_mut(),- };- let arr = match env.new_object_array(parts.len() as i32, &cls, JObject::null()) {+fn arrays_out(env: &mut Env, parts: &[&[u8]]) -> jobjectArray {+ let arr = match env.new_object_type_array::<JByteArray>(parts.len(), JByteArray::null()) { Ok(o) => o, Err(_) => return std::ptr::null_mut(), };@@ -46,14 +43,14 @@ fn arrays_out<'a>(env: &mut JNIEnv<'a>, parts: &[&[u8]]) -> jobjectArray { Ok(x) => x, Err(_) => return std::ptr::null_mut(), };- if env.set_object_array_element(&arr, i as i32, jb).is_err() {+ if arr.set_element(&mut *env, i, &jb).is_err() { return std::ptr::null_mut(); } } arr.into_raw() } -fn fail<'a>(env: &mut JNIEnv<'a>, msg: String) -> jobjectArray {+fn fail(env: &mut Env, msg: String) -> jobjectArray { throw_runtime(env, &msg); std::ptr::null_mut() }@@ -63,19 +60,22 @@ fn fail<'a>(env: &mut JNIEnv<'a>, msg: String) -> jobjectArray { pub extern "system" fn Java_com_vayunmathur_communicate_data_rcs_e2e_RustMlsCrypto_generateIdentity< 'local, >(- mut env: JNIEnv<'local>,+ mut env: EnvUnowned<'local>, _cls: JClass<'local>, e164: JByteArray<'local>, ) -> jobjectArray {- let id_b = match bytes_in(&mut env, &e164) {- Some(b) => b,- None => return fail(&mut env, "e164 null".to_string()),- };- let id = String::from_utf8(id_b).unwrap_or_default();- match keys::generate_identity(&id) {- Ok(state) => arrays_out(&mut env, &[&[], &keys::serialize_identity(&state)]),- Err(e) => fail(&mut env, e.to_string()),- }+ env.with_env(|env| -> jni::errors::Result<jobjectArray> {+ let id_b = match bytes_in(&mut *env, &e164) {+ Some(b) => b,+ None => return Ok(fail(&mut *env, "e164 null".to_string())),+ };+ let id = String::from_utf8(id_b).unwrap_or_default();+ Ok(match keys::generate_identity(&id) {+ Ok(state) => arrays_out(&mut *env, &[&[], &keys::serialize_identity(&state)]),+ Err(e) => fail(&mut *env, e.to_string()),+ })+ })+ .resolve::<jni::errors::LogErrorAndDefault>() } /// Build a key package. `(storage_in, identity)` → `[storage_out, key_package_tls]`.@@ -83,20 +83,23 @@ pub extern "system" fn Java_com_vayunmathur_communicate_data_rcs_e2e_RustMlsCryp pub extern "system" fn Java_com_vayunmathur_communicate_data_rcs_e2e_RustMlsCrypto_buildKeyPackage< 'local, >(- mut env: JNIEnv<'local>,+ mut env: EnvUnowned<'local>, _cls: JClass<'local>, storage: JByteArray<'local>, identity: JByteArray<'local>, ) -> jobjectArray {- let s = bytes_in(&mut env, &storage).unwrap_or_default();- let id = match bytes_in(&mut env, &identity) {- Some(b) => b,- None => return fail(&mut env, "identity null".to_string()),- };- match group::build_key_package(&s, &id) {- Ok((storage_out, kp)) => arrays_out(&mut env, &[&storage_out, &kp]),- Err(e) => fail(&mut env, e.to_string()),- }+ env.with_env(|env| -> jni::errors::Result<jobjectArray> {+ let s = bytes_in(&mut *env, &storage).unwrap_or_default();+ let id = match bytes_in(&mut *env, &identity) {+ Some(b) => b,+ None => return Ok(fail(&mut *env, "identity null".to_string())),+ };+ Ok(match group::build_key_package(&s, &id) {+ Ok((storage_out, kp)) => arrays_out(&mut *env, &[&storage_out, &kp]),+ Err(e) => fail(&mut *env, e.to_string()),+ })+ })+ .resolve::<jni::errors::LogErrorAndDefault>() } /// Create a group. `(storage_in, identity)` → `[storage_out, group_id]`.@@ -104,20 +107,23 @@ pub extern "system" fn Java_com_vayunmathur_communicate_data_rcs_e2e_RustMlsCryp pub extern "system" fn Java_com_vayunmathur_communicate_data_rcs_e2e_RustMlsCrypto_createGroup< 'local, >(- mut env: JNIEnv<'local>,+ mut env: EnvUnowned<'local>, _cls: JClass<'local>, storage: JByteArray<'local>, identity: JByteArray<'local>, ) -> jobjectArray {- let s = bytes_in(&mut env, &storage).unwrap_or_default();- let id = match bytes_in(&mut env, &identity) {- Some(b) => b,- None => return fail(&mut env, "identity null".to_string()),- };- match group::create_group(&s, &id) {- Ok(created) => arrays_out(&mut env, &[&created.storage, &created.group_id]),- Err(e) => fail(&mut env, e.to_string()),- }+ env.with_env(|env| -> jni::errors::Result<jobjectArray> {+ let s = bytes_in(&mut *env, &storage).unwrap_or_default();+ let id = match bytes_in(&mut *env, &identity) {+ Some(b) => b,+ None => return Ok(fail(&mut *env, "identity null".to_string())),+ };+ Ok(match group::create_group(&s, &id) {+ Ok(created) => arrays_out(&mut *env, &[&created.storage, &created.group_id]),+ Err(e) => fail(&mut *env, e.to_string()),+ })+ })+ .resolve::<jni::errors::LogErrorAndDefault>() } /// Add members. `(storage_in, identity, group_id, key_packages[])`@@ -126,38 +132,41 @@ pub extern "system" fn Java_com_vayunmathur_communicate_data_rcs_e2e_RustMlsCryp pub extern "system" fn Java_com_vayunmathur_communicate_data_rcs_e2e_RustMlsCrypto_addMembers< 'local, >(- mut env: JNIEnv<'local>,+ mut env: EnvUnowned<'local>, _cls: JClass<'local>, storage: JByteArray<'local>, identity: JByteArray<'local>, group_id: JByteArray<'local>,- key_packages: JObjectArray<'local>,+ key_packages: JObjectArray<'local, JByteArray<'local>>, ) -> jobjectArray {- let s = bytes_in(&mut env, &storage).unwrap_or_default();- let id = match bytes_in(&mut env, &identity) {- Some(b) => b,- None => return fail(&mut env, "identity null".to_string()),- };- let gid = match bytes_in(&mut env, &group_id) {- Some(b) => b,- None => return fail(&mut env, "group_id null".to_string()),- };- let len = env.get_array_length(&key_packages).unwrap_or(0);- let mut kps = Vec::with_capacity(len.max(0) as usize);- for i in 0..len {- let item: JByteArray = match env.get_object_array_element(&key_packages, i) {- Ok(o) => o.into(),- Err(_) => return fail(&mut env, "key package null".to_string()),+ env.with_env(|env| -> jni::errors::Result<jobjectArray> {+ let s = bytes_in(&mut *env, &storage).unwrap_or_default();+ let id = match bytes_in(&mut *env, &identity) {+ Some(b) => b,+ None => return Ok(fail(&mut *env, "identity null".to_string())),+ };+ let gid = match bytes_in(&mut *env, &group_id) {+ Some(b) => b,+ None => return Ok(fail(&mut *env, "group_id null".to_string())), };- match bytes_in(&mut env, &item) {- Some(b) => kps.push(b),- None => return fail(&mut env, "key package null".to_string()),+ let len = key_packages.len(&*env).unwrap_or(0);+ let mut kps = Vec::with_capacity(len);+ for i in 0..len {+ let item: JByteArray = match key_packages.get_element(&mut *env, i) {+ Ok(o) => o,+ Err(_) => return Ok(fail(&mut *env, "key package null".to_string())),+ };+ match bytes_in(&mut *env, &item) {+ Some(b) => kps.push(b),+ None => return Ok(fail(&mut *env, "key package null".to_string())),+ } }- }- match group::add_members(&s, &id, &gid, &kps) {- Ok(added) => arrays_out(&mut env, &[&added.storage, &added.commit, &added.welcome]),- Err(e) => fail(&mut env, e.to_string()),- }+ Ok(match group::add_members(&s, &id, &gid, &kps) {+ Ok(added) => arrays_out(&mut *env, &[&added.storage, &added.commit, &added.welcome]),+ Err(e) => fail(&mut *env, e.to_string()),+ })+ })+ .resolve::<jni::errors::LogErrorAndDefault>() } /// Join from a Welcome envelope. `(storage_in, welcome_framed)`@@ -166,20 +175,23 @@ pub extern "system" fn Java_com_vayunmathur_communicate_data_rcs_e2e_RustMlsCryp pub extern "system" fn Java_com_vayunmathur_communicate_data_rcs_e2e_RustMlsCrypto_joinGroup< 'local, >(- mut env: JNIEnv<'local>,+ mut env: EnvUnowned<'local>, _cls: JClass<'local>, storage: JByteArray<'local>, welcome: JByteArray<'local>, ) -> jobjectArray {- let s = bytes_in(&mut env, &storage).unwrap_or_default();- let w = match bytes_in(&mut env, &welcome) {- Some(b) => b,- None => return fail(&mut env, "welcome null".to_string()),- };- match group::join_group(&s, &w) {- Ok((storage_out, gid)) => arrays_out(&mut env, &[&storage_out, &gid]),- Err(e) => fail(&mut env, e.to_string()),- }+ env.with_env(|env| -> jni::errors::Result<jobjectArray> {+ let s = bytes_in(&mut *env, &storage).unwrap_or_default();+ let w = match bytes_in(&mut *env, &welcome) {+ Some(b) => b,+ None => return Ok(fail(&mut *env, "welcome null".to_string())),+ };+ Ok(match group::join_group(&s, &w) {+ Ok((storage_out, gid)) => arrays_out(&mut *env, &[&storage_out, &gid]),+ Err(e) => fail(&mut *env, e.to_string()),+ })+ })+ .resolve::<jni::errors::LogErrorAndDefault>() } /// Encrypt. `(storage_in, identity, group_id, plaintext)`@@ -188,27 +200,30 @@ pub extern "system" fn Java_com_vayunmathur_communicate_data_rcs_e2e_RustMlsCryp pub extern "system" fn Java_com_vayunmathur_communicate_data_rcs_e2e_RustMlsCrypto_encrypt< 'local, >(- mut env: JNIEnv<'local>,+ mut env: EnvUnowned<'local>, _cls: JClass<'local>, storage: JByteArray<'local>, identity: JByteArray<'local>, group_id: JByteArray<'local>, plaintext: JByteArray<'local>, ) -> jobjectArray {- let s = bytes_in(&mut env, &storage).unwrap_or_default();- let id = match bytes_in(&mut env, &identity) {- Some(b) => b,- None => return fail(&mut env, "identity null".to_string()),- };- let gid = match bytes_in(&mut env, &group_id) {- Some(b) => b,- None => return fail(&mut env, "group_id null".to_string()),- };- let pt = bytes_in(&mut env, &plaintext).unwrap_or_default();- match group::encrypt(&s, &id, &gid,
Diff truncated.