diff --git a/Cargo.lock b/Cargo.lock index 99b4d05..51509aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,8 +111,7 @@ dependencies = [ [[package]] name = "adb_client" version = "2.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f415b469dd4e79fefa23f04148a1f6b4d227c0247fe9e2577ab4e44d71038e0" +source = "git+https://github.com/lavafroth/adb_client?branch=with-read-timeout#5cfb7dc4dd04810522e3ac65ec8dfbe7eed34597" dependencies = [ "base64", "bincode", @@ -201,6 +200,56 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + [[package]] name = "arboard" version = "3.6.1" @@ -770,6 +819,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + [[package]] name = "combine" version = "4.6.7" @@ -1217,6 +1272,29 @@ dependencies = [ "syn", ] +[[package]] +name = "env_filter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "jiff", + "log", +] + [[package]] name = "epaint" version = "0.33.3" @@ -1821,12 +1899,42 @@ dependencies = [ "hashbrown 0.16.1", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + [[package]] name = "itoa" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +[[package]] +name = "jiff" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49cce2b81f2098e7e3efc35bc2e0a6b7abec9d34128283d7a26fa8f32a6dbb35" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-static" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "980af8b43c3ad5d8d349ace167ec8170839f753a42d233ba19e08afe1850fa69" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "jni" version = "0.21.1" @@ -2563,6 +2671,12 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + [[package]] name = "orbclient" version = "0.3.49" @@ -3809,6 +3923,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "uuid" version = "1.19.0" diff --git a/Cargo.toml b/Cargo.toml index 85f7616..c0605e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,8 +4,10 @@ version = "0.1.0" edition = "2024" [dependencies] -adb_client = "2.1.18" +adb_client = {version = "2.1.18", git = "https://github.com/lavafroth/adb_client", branch = "with-read-timeout"} eframe = "0.33.2" egui = "0.33.2" egui_alignments = "0.3.6" egui_extras = "0.33.2" +env_logger = "0.11.8" +rusb = "0.9.4" diff --git a/src/main.rs b/src/main.rs index 8080fd1..359f329 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,7 @@ use egui_alignments::{center_horizontal, column}; const WORKER_THREAD_POLL: Duration = Duration::from_secs(5); fn main() -> eframe::Result { - // env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`). + env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`). let options = eframe::NativeOptions { viewport: egui::ViewportBuilder::default().with_inner_size([800.0, 300.0]), ..Default::default() @@ -43,12 +43,11 @@ fn main() -> eframe::Result { } while let Some(device_mut) = device.as_mut() { - eprintln!("trying"); match fetch_packages(device_mut, &pkg_set) { Ok((diff, new_pkg_set)) => { if diff.added.is_empty() && diff.removed.is_empty() { - // sleep(WORKER_THREAD_POLL); + sleep(WORKER_THREAD_POLL); continue; } pkg_set = new_pkg_set; @@ -62,7 +61,7 @@ fn main() -> eframe::Result { } ctx.request_repaint(); - // sleep(WORKER_THREAD_POLL); + sleep(WORKER_THREAD_POLL); } } }); @@ -210,9 +209,21 @@ fn fetch_packages( pkg_set: &BTreeSet, ) -> Result<(PackageDiff, BTreeSet), String> { let mut buffer = vec![]; - device - .shell_command(&["pm list packages -f"], &mut buffer) - .map_err(|e| e.to_string())?; + match device.shell_command(&["pm list packages -f"], &mut buffer) { + Ok(_) => {} + Err(adb_client::RustADBError::UsbError(rusb::Error::Timeout)) => { + return Ok(( + PackageDiff { + added: vec![], + removed: vec![], + }, + pkg_set.clone(), + )); + } + Err(e) => { + return Err(e.to_string()); + } + }; let raw_pkg_text = std::str::from_utf8(&buffer) .map_err(|e| format!("failed to parse output of `pm list packages -f` {e}"))?;