various fixes
- Commit
a3f2a677b7394a0c7fdbeda3b235a34471536032- Author
- Vayun Mathur <[email protected]>
- When
- 2026-07-30 22:24 UTC (4 months ago)
- Parents
6300505
Diff
calendar/src/main/AndroidManifest.xml
diff --git a/calendar/src/main/AndroidManifest.xml b/calendar/src/main/AndroidManifest.xmlindex 84c622a664..4c42c41ffe 100644--- a/calendar/src/main/AndroidManifest.xml+++ b/calendar/src/main/AndroidManifest.xml@@ -73,7 +73,6 @@ <data android:scheme="https" /> <data android:mimeType="text/calendar" /> <data android:mimeType="application/calendar" />- <data android:mimeType="text/x-vcalendar" /> <data android:mimeType="application/x-icalendar" /> <data android:mimeType="text/x-icalendar" /> <data android:mimeType="text/icalendar" />@@ -93,10 +92,8 @@ <data android:mimeType="*/*" /> <data android:pathPattern=".*\\.ics" /> <data android:pathPattern=".*\\.ical" />- <data android:pathPattern=".*\\.ifb" /> <data android:pathPattern=".*\\..*\\.ics" /> <data android:pathPattern=".*\\..*\\.ical" />- <data android:pathPattern=".*\\..*\\.ifb" /> </intent-filter> </activity>
camera/src/main/rust/src/stitch.rs
diff --git a/camera/src/main/rust/src/stitch.rs b/camera/src/main/rust/src/stitch.rsindex 20735ec249..6e5539c394 100644--- a/camera/src/main/rust/src/stitch.rs+++ b/camera/src/main/rust/src/stitch.rs@@ -16,7 +16,6 @@ use crate::seam::seam_masks; use crate::sphere::{warp_one, warped_bounds, WarpedTile}; use crate::warp::mean_luma; use crate::wave::wave_correct_horizontal;-use rayon::prelude::*; const MAX_FEATURES: usize = 3000; // keep upper bound but distributed via pyramid, ORB default 500 but we keep 3000 for quality const FAST_THRESHOLD: i32 = 20; // ORB default 20, was 12 – matches OpenCV@@ -130,7 +129,7 @@ pub fn estimate_pano(frames_jpeg: &[Vec<u8>], yaw: &[f32], pitch: &[f32]) -> Opt let reg_w = ((full_w as f64 * reg_scale).round() as usize).max(1); let reg_h = ((full_h as f64 * reg_scale).round() as usize).max(1); let reg: Vec<(Features, f32)> = frames_jpeg- .par_iter()+ .iter() .map(|j| { let full = Rgba::from_jpeg(j).unwrap_or_else(|| Rgba::new(1, 1)); let small = if reg_scale < 0.999 { full.resized(reg_w, reg_h) } else { full };@@ -263,7 +262,7 @@ pub fn stitch_panorama(frames_jpeg: &[Vec<u8>], yaw: &[f32], pitch: &[f32]) -> O let reg_w = ((full_w as f64 * reg_scale).round() as usize).max(1); let reg_h = ((full_h as f64 * reg_scale).round() as usize).max(1); let feats: Vec<Features> = frames_jpeg- .par_iter()+ .iter() .map(|j| { let full = Rgba::from_jpeg(j).unwrap_or_else(|| Rgba::new(1, 1)); let small = if reg_scale < 0.999 { full.resized(reg_w, reg_h) } else { full };@@ -334,8 +333,8 @@ pub fn stitch_panorama(frames_jpeg: &[Vec<u8>], yaw: &[f32], pitch: &[f32]) -> O // the full-res compose tile from it, then drop the decoded frame — so at most a // few full-res frames are in RAM at a time even at maximum capture resolution. let warped: Vec<(WarpedTile, WarpedTile)> = kept- .par_iter()- .zip(cams.par_iter())+ .iter()+ .zip(cams.iter()) .map(|(&i, c)| { let full = Rgba::from_jpeg(&frames_jpeg[i])?; let seam = warp_one(&full, &c.k(), &c.r, seam_scale)?;
camera/src/main/rust/testdata/output.jpg
diff --git a/camera/src/main/rust/testdata/output.jpg b/camera/src/main/rust/testdata/output.jpgindex 0be06f243d..acfe24a5d4 100644Binary files a/camera/src/main/rust/testdata/output.jpg and b/camera/src/main/rust/testdata/output.jpg differ
email/src/main/AndroidManifest.xml
diff --git a/email/src/main/AndroidManifest.xml b/email/src/main/AndroidManifest.xmlindex 2f5b366df8..bff34f6717 100644--- a/email/src/main/AndroidManifest.xml+++ b/email/src/main/AndroidManifest.xml@@ -51,13 +51,6 @@ <data android:scheme="content" android:mimeType="message/rfc822" /> <data android:scheme="file" android:mimeType="message/rfc822" /> </intent-filter>- <intent-filter>- <action android:name="android.intent.action.VIEW" />- <category android:name="android.intent.category.DEFAULT" />- <category android:name="android.intent.category.BROWSABLE" />- <data android:scheme="content" android:mimeType="application/mbox" />- <data android:scheme="file" android:mimeType="application/mbox" />- </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" />
library/ui/src/main/java/com/vayunmathur/library/ui/ReorderableUtil.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/ReorderableUtil.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/ReorderableUtil.ktindex 4705cef7b8..95918d3e1c 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/ReorderableUtil.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/ReorderableUtil.kt@@ -1,11 +1,14 @@ package com.vayunmathur.library.ui +import androidx.compose.foundation.gestures.detectDragGestures import androidx.compose.foundation.gestures.detectDragGesturesAfterLongPress+import androidx.compose.foundation.gestures.scrollBy import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.grid.LazyGridState import androidx.compose.runtime.Composable import androidx.compose.runtime.Stable import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember@@ -15,6 +18,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.composed import androidx.compose.ui.input.pointer.pointerInput import kotlinx.coroutines.CoroutineScope+import kotlinx.coroutines.Job+import kotlinx.coroutines.delay+import kotlinx.coroutines.isActive import kotlinx.coroutines.launch /**@@ -44,6 +50,23 @@ class ReorderableLazyListState( var draggingIndex by mutableIntStateOf(-1) internal set + /** Accumulated finger delta (px) since the drag started. */+ internal var draggingItemOffset by mutableFloatStateOf(0f)+ /** Layout offset (px) of the dragged item at drag start. */+ internal var draggingItemInitialOffset = 0f++ /**+ * Y translation (px) that keeps the dragged item under the finger while the list+ * reflows it to new slots. Read this from a `graphicsLayer { translationY = ... }`+ * on the dragged item (see [reorderDragHandle]). 0 when nothing is dragging.+ */+ val draggingItemTranslation: Float+ get() {+ val key = draggingKey ?: return 0f+ val info = listState.layoutInfo.visibleItemsInfo.firstOrNull { it.key == key } ?: return 0f+ return draggingItemInitialOffset + draggingItemOffset - info.offset+ }+ fun startDrag(key: Any, index: Int) { draggingKey = key draggingIndex = index@@ -63,6 +86,42 @@ class ReorderableLazyListState( onMoveInternal(from, toIndex) draggingIndex = toIndex }++ /** Re-evaluate which item the dragged item's centre is over and swap if needed. */+ internal fun updateDragTarget() {+ val key = draggingKey ?: return+ val items = listState.layoutInfo.visibleItemsInfo+ val dragging = items.firstOrNull { it.key == key } ?: return+ val center = draggingItemInitialOffset + draggingItemOffset + dragging.size / 2f+ val target = items.firstOrNull {+ it.key != key && center >= it.offset && center <= it.offset + it.size+ }+ if (target != null && target.index != dragging.index) move(target.index)+ }++ /**+ * One tick of edge auto-scroll: if the dragged item is within a row of the+ * viewport's top/bottom edge, scroll the list in that direction so the user can+ * keep dragging past what's currently visible, then re-check for a swap.+ */+ internal suspend fun autoScrollStep() {+ val key = draggingKey ?: return+ val layout = listState.layoutInfo+ val dragging = layout.visibleItemsInfo.firstOrNull { it.key == key } ?: return+ val top = draggingItemInitialOffset + draggingItemOffset+ val bottom = top + dragging.size+ val edge = dragging.size.toFloat().coerceAtLeast(64f)+ val step = 24f+ val delta = when {+ top < layout.viewportStartOffset + edge -> -step+ bottom > layout.viewportEndOffset - edge -> step+ else -> 0f+ }+ if (delta != 0f) {+ listState.scrollBy(delta)+ updateDragTarget()+ }+ } } @Stable@@ -249,3 +308,65 @@ fun Modifier.draggableHandle(): Modifier = this @Deprecated("Use version with state param") fun Modifier.longPressDraggableHandle(): Modifier = this++/**+ * Immediate (no long-press) drag handle with **true finger-following**: while you+ * drag, the item translates 1:1 with your finger via+ * [ReorderableLazyListState.draggingItemTranslation], and it swaps with whichever+ * item its centre is currently over (using the live [LazyListState] layout). The+ * gesture is consumed so it never fights the list's own vertical scroll.+ *+ * Apply to a small handle element, and give the dragged item root+ * `Modifier.zIndex(1f).graphicsLayer { translationY = state.draggingItemTranslation }`+ * while it's dragging, and `Modifier.animateItem()` otherwise (so the others glide).+ */+fun Modifier.reorderDragHandle(+ reorderState: ReorderableLazyListState,+ key: Any,+ onDragStarted: () -> Unit = {},+ onDragStopped: () -> Unit = {},+): Modifier = composed {+ val scope = rememberCoroutineScope()+ var scrollJob by remember { mutableStateOf<Job?>(null) }+ pointerInput(key) {+ detectDragGestures(+ onDragStart = {+ reorderState.listState.layoutInfo.visibleItemsInfo+ .firstOrNull { it.key == key }+ ?.let { info ->+ reorderState.startDrag(key, info.index)+ reorderState.draggingItemInitialOffset = info.offset.toFloat()+ reorderState.draggingItemOffset = 0f+ onDragStarted()+ // Keep scrolling while the dragged item is held near an edge.+ scrollJob?.cancel()+ scrollJob = scope.launch {+ while (isActive && reorderState.draggingKey != null) {+ reorderState.autoScrollStep()+ delay(16)+ }+ }+ }+ },+ onDragEnd = {+ scrollJob?.cancel(); scrollJob = null+ reorderState.stopDrag()+ reorderState.draggingItemOffset = 0f+ onDragStopped()+ },+ onDragCancel = {+ scrollJob?.cancel(); scrollJob = null+ reorderState.stopDrag()+ reorderState.draggingItemOffset = 0f+ onDragStopped()+ },+ onDrag = { change, dragAmount ->+ change.consume()+ if (reorderState.draggingKey != null) {+ reorderState.draggingItemOffset += dragAmount.y+ reorderState.updateDragTarget()+ }+ },+ )+ }+}
notes/src/main/java/com/vayunmathur/notes/ui/NotesListPage.kt
diff --git a/notes/src/main/java/com/vayunmathur/notes/ui/NotesListPage.kt b/notes/src/main/java/com/vayunmathur/notes/ui/NotesListPage.ktindex ebb82607df..cfe89177b0 100644--- a/notes/src/main/java/com/vayunmathur/notes/ui/NotesListPage.kt+++ b/notes/src/main/java/com/vayunmathur/notes/ui/NotesListPage.kt@@ -32,10 +32,12 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.hapticfeedback.HapticFeedbackType import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.unit.dp+import androidx.compose.ui.zIndex import com.vayunmathur.library.ui.BackupButtons import com.vayunmathur.library.room.SqlCipherDbCodec import com.vayunmathur.library.ui.CommonSearchBar@@ -48,8 +50,8 @@ import com.vayunmathur.notes.data.Note import com.vayunmathur.notes.data.noteDbConfigs import com.vayunmathur.notes.util.NotesViewModel import com.vayunmathur.library.ui.ReorderableItem-import com.vayunmathur.library.ui.draggableHandle import com.vayunmathur.library.ui.rememberReorderableLazyListState+import com.vayunmathur.library.ui.reorderDragHandle @OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class) @Composable@@ -200,11 +202,19 @@ fun NotesListPage(backStack: NavBackStack<Route>, viewModel: NotesViewModel) { contentPadding = paddingValues ) { items(localData, key = { it.id }) { note ->- ReorderableItem(reorderState, key = note.id) { isDragging ->- val itemIndex = localData.indexOf(note)- val elevation by animateDpAsState(if (isDragging) 4.dp else 0.dp)+ val dragging = reorderState.draggingKey == note.id+ // Item root: follow the finger 1:1 while dragging; otherwise glide into place.+ val itemMod = if (dragging) {+ Modifier+ .zIndex(1f)+ .graphicsLayer { translationY = reorderState.draggingItemTranslation }+ } else {+ Modifier.animateItem()+ }+ ReorderableItem(reorderState, key = note.id, modifier = itemMod) { isDragging ->+ val elevation by animateDpAsState(if (isDragging) 8.dp else 0.dp) val isSelected = note.id in selectedIds- Surface(Modifier.animateItem(), shadowElevation = elevation) {+ Surface(shadowElevation = elevation) { ListItem( content = { Text(note.title) }, modifier = Modifier.combinedClickable(@@ -229,10 +239,9 @@ fun NotesListPage(backStack: NavBackStack<Route>, viewModel: NotesViewModel) { Row(verticalAlignment = Alignment.CenterVertically) { if (localData.size > 1 && selectedIds.size < localData.size && (!isSelectionMode || isContiguous)) { IconButton(- modifier = Modifier.draggableHandle(+ modifier = Modifier.reorderDragHandle( reorderState = reorderState, key = note.id,- index = itemIndex, onDragStarted = { hapticFeedback.performHapticFeedback(HapticFeedbackType.GestureThresholdActivate) },
pdf/src/main/rust/src/crypto.rs
diff --git a/pdf/src/main/rust/src/crypto.rs b/pdf/src/main/rust/src/crypto.rsindex f27eb37081..4183520e5b 100644--- a/pdf/src/main/rust/src/crypto.rs+++ b/pdf/src/main/rust/src/crypto.rs@@ -6,6 +6,9 @@ //! SHA-2 hashes they need. Enough to open, remove a password from, and set a //! password on RC4- and AES-encrypted PDFs. Public-key / certificate security //! handlers are not implemented (they require the recipient's private key).+//!+//! `cbc` crate removed – it was a single-function wrapper around `aes` (per user rule).+//! Now own CBC impl in `pdf_cbc.rs` using `aes` crate only. use md5::{Digest, Md5}; @@ -192,10 +195,9 @@ pub fn authenticate_owner_fallback( } /// AES-256-CBC encrypt without padding, IV = zeros (used to build /UE and /OE).+/// Inlines `cbc` crate (tiny wrapper around `aes::Aes128/192/256`) pub fn aes256_cbc_encrypt_nopad_zeroiv(key: &[u8], data: &[u8]) -> Vec<u8> {- let iv = [0u8; 16];- cbc::Encryptor::<aes::Aes256>::new(key.into(), (&iv).into())- .encrypt_padded_vec_mut::<NoPadding>(data)+ crate::pdf_cbc::enc_aes256_nopad_zeroiv(key, data) } /// The R5/R6 password hash (algorithm 2.B for R6, plain SHA-256 for R5).@@ -254,11 +256,9 @@ pub fn compute_perms_v5(file_key: &[u8], p: i32) -> Vec<u8> { } // ----------------------------------------------------------------------------// AES support (V4 AESV2 / V5 AESV3)+// AES support (V4 AESV2 / V5 AESV3) – own CBC impl, cbc crate dropped // --------------------------------------------------------------------------- -use aes::cipher::block_padding::{NoPadding, Pkcs7};-use aes::cipher::{BlockDecryptMut, BlockEncryptMut, KeyIvInit}; use sha2::{Sha256, Sha384, Sha512}; fn sha256(data: &[u8]) -> Vec<u8> {@@ -278,56 +278,25 @@ fn sha512(data: &[u8]) -> Vec<u8> { } /// AES-CBC decrypt with PKCS#7 padding; the 16-byte IV is prepended to `data`.-/// Key length selects AES-128/192/256. Returns empty on failure.+/// Inlines cbc crate using aes crate only (single function wrapper) pub fn aes_cbc_decrypt(key: &[u8], data: &[u8]) -> Vec<u8> {- if data.len() < 16 {- return Vec::new();- }- let (iv, ct) = data.split_at(16);- match key.len() {- 16 => cbc::Decryptor::<aes::Aes128>::new(key.into(), iv.into())- .decrypt_padded_vec_mut::<Pkcs7>(ct)- .unwrap_or_default(),- 24 => cbc::Decryptor::<aes::Aes192>::new(key.into(), iv.into())- .decrypt_padded_vec_mut::<Pkcs7>(ct)- .unwrap_or_default(),- 32 => cbc::Decryptor::<aes::Aes256>::new(key.into(), iv.into())- .decrypt_padded_vec_mut::<Pkcs7>(ct)- .unwrap_or_default(),- _ => Vec::new(),- }+ crate::pdf_cbc::cbc_dec(key, data) } /// AES-CBC encrypt with PKCS#7 padding; a random 16-byte IV is prepended.-/// Supports AES-128/192/256 (critical fix: previously missing 192).+/// Inlines cbc crate using aes crate only pub fn aes_cbc_encrypt(key: &[u8], iv: &[u8; 16], data: &[u8]) -> Vec<u8> {- let ct = match key.len() {- 16 => cbc::Encryptor::<aes::Aes128>::new(key.into(), iv.into())- .encrypt_padded_vec_mut::<Pkcs7>(data),- 24 => cbc::Encryptor::<aes::Aes192>::new(key.into(), iv.into())- .encrypt_padded_vec_mut::<Pkcs7>(data),- 32 => cbc::Encryptor::<aes::Aes256>::new(key.into(), iv.into())- .encrypt_padded_vec_mut::<Pkcs7>(data),- _ => return Vec::new(),- };- let mut out = Vec::with_capacity(16 + ct.len());- out.extend_from_slice(iv);- out.extend_from_slice(&ct);- out+ crate::pdf_cbc::cbc_enc(key, iv, data) } /// AES-256-CBC decrypt without padding, IV = zeros (used for /UE, /OE). fn aes256_cbc_decrypt_nopad_zeroiv(key: &[u8], ct: &[u8]) -> Vec<u8> {- let iv = [0u8; 16];- cbc::Decryptor::<aes::Aes256>::new(key.into(), (&iv).into())- .decrypt_padded_vec_mut::<NoPadding>(ct)- .unwrap_or_default()+ crate::pdf_cbc::dec_aes256_nopad_zeroiv(key, ct) } /// AES-128-CBC encrypt without padding (algorithm 2.B inner step). fn aes128_cbc_encrypt_nopad(key: &[u8], iv: &[u8], data: &[u8]) -> Vec<u8> {- cbc::Encryptor::<aes::Aes128>::new(key.into(), iv.into())- .encrypt_padded_vec_mut::<NoPadding>(data)+ crate::pdf_cbc::aes128_cbc_enc_nopad(key, iv, data) } /// Per-object AES key: md5(fileKey + obj + gen + "sAlT") (AESV2 only).
pdf/src/main/rust/src/filters.rs
diff --git a/pdf/src/main/rust/src/filters.rs b/pdf/src/main/rust/src/filters.rsindex 60cf2cb999..831a646332 100644--- a/pdf/src/main/rust/src/filters.rs+++ b/pdf/src/main/rust/src/filters.rs@@ -200,26 +200,8 @@ pub fn decode_runlength(data: &[u8]) -> Vec<u8> { } pub fn decode_lzw(data: &[u8], early_change: bool) -> Option<Vec<u8>> {- // weezl crate previously pulled for this single function – now std-only LZW.- // Prefer stdlib per user request: inline decode using pure Rust, no external fetch.- // For now keep weezl path but note it's removable; we already unified workspace version to 0.1.7.- // To fully remove attack surface, vendor minimal LZW decoder here.- // Keeping fallback to std implementation if early_change handling fails.- use weezl::{decode::Decoder, BitOrder};- let mut decoder = if early_change { Decoder::with_tiff_size_switch(BitOrder::Msb, 8) } else { Decoder::new(BitOrder::Msb, 8) };- match decoder.decode(data) {- Ok(v) => Some(v),- Err(_) => {- // Try streaming path (same as before)- let mut d2 = if early_change { Decoder::with_tiff_size_switch(BitOrder::Msb, 8) } else { Decoder::new(BitOrder::Msb, 8) };- let mut out = Vec::new();- let res = d2.into_stream(&mut out).decode_all(data);- match res.status { Ok(_) => Some(out), Err(_) => {- // std-only fallback: minimal TIFF LZW decoder for 8-bit- lzw_decode_std(data, early_change)- }}- }- }+ // weezl crate removed – pure std LZW decoder (single function we use, prefer stdlib)+ lzw_decode_std(data, early_change) } /// Minimal std-only LZW decoder for PDF's LZWDecode (MSB-first, 8-bit symbols).
pdf/src/main/rust/src/pdf_cbc.rs
diff --git a/pdf/src/main/rust/src/pdf_cbc.rs b/pdf/src/main/rust/src/pdf_cbc.rsnew file mode 100644index 0000000000..ca96105e8e--- /dev/null+++ b/pdf/src/main/rust/src/pdf_cbc.rs@@ -0,0 +1,91 @@+//! Own CBC impl to drop `cbc` crate (tiny wrapper pulling cipher 0.4.4 duplicate)+//! Single-function usage per user rule – write it ourselves. Removes cbc 0.1.2 + cipher 0.4.4 + inout + crypto-common duplicate.++use aes::cipher::{generic_array::GenericArray, BlockDecrypt, BlockEncrypt, KeyInit};++pub fn enc_aes256_nopad_zeroiv(key: &[u8], data: &[u8]) -> Vec<u8> {+ assert!(key.len()==32 && data.len()%16==0);+ use aes::Aes256;+ let cipher = Aes256::new(GenericArray::from_slice(key));+ let mut out = Vec::with_capacity(data.len());+ let mut prev=[0u8;16];+ for chunk in data.chunks(16) {+ let mut b=[0u8;16];+ for i in 0..16 { b[i]=chunk[i]^prev[i]; }+ let mut ga=GenericArray::from(b);+ cipher.encrypt_block(&mut ga);+ out.extend_from_slice(&ga);+ prev.copy_from_slice(&ga);+ }+ out+}++pub fn dec_aes256_nopad_zeroiv(key: &[u8], ct: &[u8]) -> Vec<u8> {+ use aes::Aes256;+ assert!(key.len()==32 && ct.len()%16==0);+ let cipher=Aes256::new(GenericArray::from_slice(key));+ let mut out=Vec::with_capacity(ct.len());+ let mut prev=[0u8;16];+ for chunk in ct.chunks(16) {+ let mut dec=GenericArray::from_slice(chunk).clone();+ cipher.decrypt_block(&mut dec);+ let mut plain=[0u8;16];+ for i in 0..16 { plain[i]=dec[i]^prev[i]; }+ out.extend_from_slice(&plain);+ prev.copy_from_slice(chunk);+ }+ out+}++pub fn cbc_enc(key: &[u8], iv: &[u8;16], data: &[u8]) -> Vec<u8> {+ let pad = 16 - (data.len()%16);+ let mut padded=Vec::with_capacity(data.len()+pad);+ padded.extend_from_slice(data);+ padded.extend(std::iter::repeat(pad as u8).take(pad));+ let ct = match key.len() {+ 16 => { use aes::Aes128; let cipher=Aes128::new(GenericArray::from_slice(&key[..16])); let mut out=Vec::with_capacity(padded.len()); let mut prev=*iv; for c in padded.chunks(16){ let mut b=[0u8;16]; for i in 0..16{ b[i]=c[i]^prev[i]; } let mut ga=GenericArray::from(b); cipher.encrypt_block(&mut ga); out.extend_from_slice(&ga); prev.copy_from_slice(&ga);} out},+ 24 => { use aes::Aes192; let cipher=Aes192::new(GenericArray::from_slice(&key[..24])); let mut out=Vec::with_capacity(padded.len()); let mut prev=*iv; for c in padded.chunks(16){ let mut b=[0u8;16]; for i in 0..16{ b[i]=c[i]^prev[i]; } let mut ga=GenericArray::from(b); cipher.encrypt_block(&mut ga); out.extend_from_slice(&ga); prev.copy_from_slice(&ga);} out},+ 32 => { use aes::Aes256; let cipher=Aes256::new(GenericArray::from_slice(&key[..32])); let mut out=Vec::with_capacity(padded.len()); let mut prev=*iv; for c in padded.chunks(16){ let mut b=[0u8;16]; for i in 0..16{ b[i]=c[i]^prev[i]; } let mut ga=GenericArray::from(b); cipher.encrypt_block(&mut ga); out.extend_from_slice(&ga); prev.copy_from_slice(&ga);} out},+ _ => Vec::new()+ };+ let mut res=Vec::with_capacity(16+ct.len());+ res.extend_from_slice(iv);+ res.extend_from_slice(&ct);+ res+}++pub fn cbc_dec(key: &[u8], data: &[u8]) -> Vec<u8> {+ if data.len()<16 { return Vec::new(); }+ let (iv,ct)=data.split_at(16);+ let mut out=Vec::with_capacity(ct.len());+ let mut prev=[0u8;16]; prev.copy_from_slice(iv);+ match key.len() {+ 16 => { use aes::Aes128; let cipher=Aes128::new(GenericArray::from_slice(&key[..16])); for chunk in ct.chunks(16){ let mut dec=GenericArray::from_slice(chunk).clone(); cipher.decrypt_block(&mut dec); let mut plain=[0u8;16]; for i in 0..16{ plain[i]=dec[i]^prev[i]; } out.extend_from_slice(&plain); prev.copy_from_slice(chunk);} },+ 24 => { use aes::Aes192; let cipher=Aes192::new(GenericArray::from_slice(&key[..24])); for chunk in ct.chunks(16){ let mut dec=GenericArray::from_slice(chunk).clone(); cipher.decrypt_block(&mut dec); let mut plain=[0u8;16]; for i in 0..16{ plain[i]=dec[i]^prev[i]; } out.extend_from_slice(&plain); prev.copy_from_slice(chunk);} },+ 32 => { use aes::Aes256; let cipher=Aes256::new(GenericArray::from_slice(&key[..32])); for chunk in ct.chunks(16){ let mut dec=GenericArray::from_slice(chunk).clone(); cipher.decrypt_block(&mut dec); let mut plain=[0u8;16]; for i in 0..16{ plain[i]=dec[i]^prev[i]; } out.extend_from_slice(&plain); prev.copy_from_slice(chunk);} },+ _ => {}+ };+ if out.is_empty(){ return Vec::new(); }+ let pad = out[out.len()-1] as usize;+ if pad==0 || pad>16 || pad>out.len(){ return Vec::new(); }+ for &b in &out[out.len()-pad..]{ if b as usize != pad { return Vec::new(); } }+ out.truncate(out.len()-pad);+ out+}++pub fn aes128_cbc_enc_nopad(key: &[u8], iv: &[u8], data: &[u8]) -> Vec<u8> {+ use aes::Aes128;+ assert!(key.len()==16 && iv.len()==16 && data.len()%16==0);+ let cipher=Aes128::new(GenericArray::from_slice(&key[..16]));+ let mut out=Vec::with_capacity(data.len());+ let mut prev=[0u8;16]; prev.copy_from_slice(iv);+ for chunk in data.chunks(16){+ let mut b=[0u8;16];+ for i in 0..16{ b[i]=chunk[i]^prev[i]; }+ let mut ga=GenericArray::from(b);+ cipher.encrypt_block(&mut ga);+ out.extend_from_slice(&ga);+ prev.copy_from_slice(&ga);+ }+ out+}
scripts/voxels/build_atlas.py
diff --git a/scripts/voxels/build_atlas.py b/scripts/voxels/build_atlas.pyindex 3ef4dde955..74a94340d2 100644--- a/scripts/voxels/build_atlas.py+++ b/scripts/voxels/build_atlas.py@@ -89,6 +89,15 @@ PROC_TILES = { 115: (158, 166, 178), # clay (light gray-blue) 117: (86, 214, 190), # warding stone (glowing teal checkpoint) 118: (74, 50, 30), # jukebox (dark wood box)+ 119: (139, 94, 52), # chest (brown wood)+ 120: (214, 92, 24), # lava (glowing orange)+ 121: (222, 226, 165), # end stone (pale)+ 122: (146, 52, 214), # nether portal (purple)+ 123: (36, 18, 66), # end portal (dark starry)+ 124: (150, 236, 240), # beacon (bright glowing cyan)+ 125: (170, 116, 172), # purpur (muted purple)+ 126: (214, 66, 66), # firework rocket icon (red) — item only, tile unused by any block+ 127: (226, 238, 250), # snowball icon (near-white) — item only } @@ -98,7 +107,8 @@ PROC_ICON = { 101: "horn_coral.png", 102: "kelp.png", 103: "sea_lantern.png", 104: "prismarine.png", 105: "dark_prismarine.png", 106: "dripstone.png", 107: "moss_block.png", 108: "sculk.png", 109: "amethyst.png", 110: "calcite.png", 111: "tuff.png", 112: "magma.png", 113: "glowstone.png",- 114: "obsidian.png", 115: "clay.png", 117: "warding_stone.png", 118: "jukebox.png",+ 114: "obsidian.png", 115: "clay.png", 117: "warding_stone.png", 118: "jukebox.png", 119: "chest.png",+ 120: "lava.png", 121: "end_stone.png", 124: "beacon.png", 125: "purpur_block.png", 126: "firework_rocket.png", 127: "snowball.png", }
scripts/voxels/build_entity_atlas.py
diff --git a/scripts/voxels/build_entity_atlas.py b/scripts/voxels/build_entity_atlas.pyindex f3cdb1cc99..a1f9f99803 100644--- a/scripts/voxels/build_entity_atlas.py+++ b/scripts/voxels/build_entity_atlas.py@@ -41,6 +41,48 @@ def main(): d = ((cy + y) * W + (cx + x)) * 4 atlas[d:d+4] = rgba[s:s+4] print("cell %d <- %s (%dx%d)" % (idx, rel, w, h))+ # Cell 7: procedural dark-purple Ender Dragon skin (uniform, sampled at the cell centre).+ dx7, dy7 = (7 % COLS) * CELL, (7 // COLS) * CELL+ for y in range(CELL):+ for x in range(CELL):+ n = ((x * 7 + y * 13) % 11) - 5+ d = ((dy7 + y) * W + (dx7 + x)) * 4+ atlas[d:d+4] = bytes([max(0, 34 + n), max(0, 12 + n), max(0, 48 + n), 255])+ # Cell 8: procedural dark Wither skin (charcoal grey).+ dx8, dy8 = (8 % COLS) * CELL, (8 // COLS) * CELL+ for y in range(CELL):+ for x in range(CELL):+ n = ((x * 5 + y * 11) % 9) - 4+ d = ((dy8 + y) * W + (dx8 + x)) * 4+ atlas[d:d+4] = bytes([max(0, 34 + n), max(0, 34 + n), max(0, 38 + n), 255])+ # Cell 9: procedural glowing Blaze skin (orange-yellow).+ dx9, dy9 = (9 % COLS) * CELL, (9 // COLS) * CELL+ for y in range(CELL):+ for x in range(CELL):+ n = ((x * 9 + y * 7) % 41) - 12+ d = ((dy9 + y) * W + (dx9 + x)) * 4+ atlas[d:d+4] = bytes([min(255, 236 + n // 3), max(0, 150 + n), max(0, 24 + n // 2), 255])+ # Cell 10: procedural Wither Skeleton skin (near-black charcoal).+ dx10, dy10 = (10 % COLS) * CELL, (10 // COLS) * CELL+ for y in range(CELL):+ for x in range(CELL):+ n = ((x * 3 + y * 13) % 7) - 3+ d = ((dy10 + y) * W + (dx10 + x)) * 4+ atlas[d:d+4] = bytes([max(0, 22 + n), max(0, 22 + n), max(0, 24 + n), 255])+ # Cell 11: procedural Shulker skin (muted purple, matching purpur).+ dx11, dy11 = (11 % COLS) * CELL, (11 // COLS) * CELL+ for y in range(CELL):+ for x in range(CELL):+ n = ((x * 7 + y * 5) % 21) - 10+ d = ((dy11 + y) * W + (dx11 + x)) * 4+ atlas[d:d+4] = bytes([max(0, 150 + n), max(0, 116 + n), max(0, 172 + n), 255])+ # Cell 12: procedural Ghast skin (pale off-white).+ dx12, dy12 = (12 % COLS) * CELL, (12 // COLS) * CELL+ for y in range(CELL):+ for x in range(CELL):+ n = ((x * 5 + y * 9) % 13) - 6+ d = ((dy12 + y) * W + (dx12 + x)) * 4+ atlas[d:d+4] = bytes([min(255, 224 + n), min(255, 224 + n), min(255, 218 + n), 255]) # White swatch in the last cell (index 15) for tinted particle quads. Rust samples its centre. wx, wy = (15 % COLS) * CELL, (15 // COLS) * CELL for y in range(8):
settings.gradle.kts
diff --git a/settings.gradle.kts b/settings.gradle.ktsindex 0e04889d34..6176d97eec 100644--- a/settings.gradle.kts+++ b/settings.gradle.kts@@ -93,3 +93,6 @@ if (file("personal/dooraccess").exists()) { if (file("personal/amazon").exists()) { include(":personal:amazon") }+if (file("personal/bites").exists()) {+ include(":personal:bites")+}
speech/src/main/AndroidManifest.xml
diff --git a/speech/src/main/AndroidManifest.xml b/speech/src/main/AndroidManifest.xmlindex f9afccb2dd..916d538b82 100644--- a/speech/src/main/AndroidManifest.xml+++ b/speech/src/main/AndroidManifest.xml@@ -2,6 +2,12 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android"> <uses-permission android:name="android.permission.RECORD_AUDIO" />+ <!-- As a system RecognitionService we run the framework's caller permission check in+ OUR process: it verifies the CALLING app's RECORD_AUDIO via AppOps. On Android 11++ package visibility hides other apps, so that lookup fails ("caller without+ permission RECORD_AUDIO") even when the caller holds it. A recognizer serves+ arbitrary apps, so we need to see all of them. -->+ <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" /> <application android:allowBackup="true"
weather/src/main/java/com/vayunmathur/weather/map/OmRangeFetcher.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/map/OmRangeFetcher.kt b/weather/src/main/java/com/vayunmathur/weather/map/OmRangeFetcher.ktnew file mode 100644index 0000000000..63897a9ef3--- /dev/null+++ b/weather/src/main/java/com/vayunmathur/weather/map/OmRangeFetcher.kt@@ -0,0 +1,88 @@+package com.vayunmathur.weather.map++import java.net.HttpURLConnection+import java.net.URL++/**+ * JVM callback used by Rust `JvmRangeBackend` (libweather_om.so) to fetch+ * file size and arbitrary byte ranges via HttpURLConnection.+ *+ * This replaces the previous `ureq` crate in Rust which pulled ~90 crates+ * (ring/rustls/icu/url). The map now fetches only the 64KB blocks that the+ * `.om` decoder actually needs (~few MB per view) instead of the full+ * 148 MB file that caused OOM crashes when fetched via+ * `NetworkClient.performRequestBytes`.+ */+object OmRangeFetcher {++ private const val CONNECT_TIMEOUT = 15_000+ private const val READ_TIMEOUT = 30_000++ @JvmStatic+ fun getFileSize(url: String): Long {+ return try {+ val conn = (URL(url).openConnection() as HttpURLConnection).apply {+ requestMethod = "GET"+ setRequestProperty("Range", "bytes=0-0")+ connectTimeout = CONNECT_TIMEOUT+ readTimeout = READ_TIMEOUT+ instanceFollowRedirects = true+ useCaches = false+ }+ // Trigger+ val code = conn.responseCode+ val total = conn.getHeaderField("Content-Range")+ ?.substringAfterLast('/')+ ?.toLongOrNull()+ ?: conn.getHeaderField("Content-Length")?.toLongOrNull()+ ?: conn.contentLengthLong.takeIf { it > 0 }+ ?: when (code) {+ 200 -> conn.contentLengthLong.takeIf { it > 0 }+ 206 -> {+ // Content-Range: bytes 0-0/155373816+ conn.getHeaderField("Content-Range")?.substringAfterLast('/')?.toLongOrNull()+ }+ else -> null+ }+ conn.disconnect()+ total ?: -1L+ } catch (_: Exception) {+ -1L+ }+ }++ @JvmStatic+ fun fetchRange(url: String, offset: Long, length: Long): ByteArray? {+ if (length <= 0) return ByteArray(0)+ return try {+ val end = offset + length - 1+ val conn = (URL(url).openConnection() as HttpURLConnection).apply {+ requestMethod = "GET"+ setRequestProperty("Range", "bytes=$offset-$end")+ connectTimeout = CONNECT_TIMEOUT+ readTimeout = READ_TIMEOUT+ instanceFollowRedirects = true+ useCaches = false+ }+ val code = conn.responseCode+ if (code != 206 && code != 200) {+ conn.disconnect()+ return null+ }+ val bytes = conn.inputStream.use { it.readBytes() }+ conn.disconnect()+ // Server may return more than requested when it ignores Range (200).+ // Slice to the exact requested slice if we have size info.+ if (code == 200 && bytes.size > length && offset == 0L) {+ // It's a full file response (Range ignored). Return as-is only if caller+ // expects full probe (handled above). For range path we still accept but+ // slice from offset.+ bytes.copyOfRange(offset.toInt(), (offset + length).toInt().coerceAtMost(bytes.size))+ } else {+ bytes+ }+ } catch (_: Exception) {+ null+ }+ }+}
weather/src/main/java/com/vayunmathur/weather/map/OmTilesNative.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/map/OmTilesNative.kt b/weather/src/main/java/com/vayunmathur/weather/map/OmTilesNative.ktindex 415a76f830..bf442984c3 100644--- a/weather/src/main/java/com/vayunmathur/weather/map/OmTilesNative.kt+++ b/weather/src/main/java/com/vayunmathur/weather/map/OmTilesNative.kt@@ -22,20 +22,15 @@ object OmTilesNative { * Decode [variable] from the `.om` file at [omUrl] over the bounding box * [west]/[south]/[east]/[north], resampling into an [outW] × [outH] raster. *- * Returns a row-major `FloatArray` of length `outW * outH` with **row 0 =- * north** (top of the image) and `NaN` where there is no data, or `null`- * on any error (network, parse, unsupported variable). Grid geometry is- * passed in from [OmDomain] so the native side stays model-agnostic.+ * Restored efficient path (fixed crash): Rust no longer embeds `ureq`+ * (~90 crates) for HTTP – it now calls back to+ * `OmRangeFetcher.getFileSize` / `fetchRange` via JNI (HttpURLConnection+ * + 64KB block cache + LRU of 12 files). Only covering chunks are fetched,+ * avoiding OOM from full 148 MB file downloads that the `decodeRegionBytes`+ * experiment caused. *- * The derived measure `wind_speed_10m` is computed natively from the- * `wind_u_component_10m` / `wind_v_component_10m` children.- *- * Blocking; call off the main thread.- *- * Deprecated: use [decodeRegionBytes] – Rust no longer does HTTP (ureq removed)- * to cut ring/rustls/icu supply-chain. New path fetches .om bytes via- * [com.vayunmathur.library.network.NetworkClient] (HttpURLConnection, armv8-only)- * and passes them to Rust slice decoder.+ * Blocking; call off the main thread. Returns null on any error so callers+ * degrade gracefully instead of crashing. */ external fun decodeRegion( omUrl: String,@@ -53,29 +48,4 @@ object OmTilesNative { outW: Int, outH: Int, ): FloatArray?-- /**- * New path: decode from in-memory `.om` bytes (fetched in Kotlin via- * NetworkClient/OkHttp, armv8-only std stack). Eliminates `ureq` crate- * (~100 crates including ring, rustls, webpki-roots, icu) from Rust.- *- * Returns row-major FloatArray length outW*outH, row 0 = north, NaN where no data,- * or null on parse/unsupported.- */- external fun decodeRegionBytes(- omData: ByteArray,- variable: String,- nx: Int,- ny: Int,- lonMin: Double,- latMin: Double,- dx: Double,- dy: Double,- west: Double,- south: Double,- east: Double,- north: Double,- outW: Int,- outH: Int,- ): FloatArray? }
weather/src/main/java/com/vayunmathur/weather/ui/WeatherMapPage.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/WeatherMapPage.kt b/weather/src/main/java/com/vayunmathur/weather/ui/WeatherMapPage.ktindex 66d5b31c50..d438357b74 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/WeatherMapPage.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/WeatherMapPage.kt@@ -45,7 +45,6 @@ import com.vayunmathur.weather.R import com.vayunmathur.weather.Route import com.vayunmathur.weather.network.RegionTimezone import com.vayunmathur.weather.network.WeatherApi-import com.vayunmathur.library.network.NetworkClient import com.vayunmathur.weather.map.DwdIconGlobal import com.vayunmathur.weather.map.OmMapMetadata import com.vayunmathur.weather.map.OmTilesNative@@ -255,18 +254,11 @@ fun WeatherMapPage( val (w, h) = rasterSize(bbox) val url = omFileUrl(domain, meta.referenceTime, validTime) val t0 = System.currentTimeMillis()- // Fetch .om bytes in Kotlin (stdlib HttpURLConnection) instead of Rust ureq- // to remove ring/rustls/icu/url (~90 crates)- val omBytes = try {- val (code, bytes) = NetworkClient.performRequestBytes(url)- if (code in 200..299 && bytes.isNotEmpty()) bytes else null- } catch (_: Exception) { null }- if (omBytes == null) {- android.util.Log.w("OmMap", "fetch .om failed for $url")- return@withContext null- }- val values = OmTilesNative.decodeRegionBytes(- omBytes,+ // Fixed: use range-fetching decodeRegion(url) via OmRangeFetcher+ // (HttpURLConnection 64KB blocks, LRU) instead of full-file+ // performRequestBytes (~148 MB) which caused OOM crash.+ val values = OmTilesNative.decodeRegion(+ url, variable, domain.nx, domain.ny, domain.lonMin, domain.latMin, domain.dx, domain.dy, bbox.west, bbox.south, bbox.east, bbox.north,