diff --git a/src/core/sync.rs b/src/core/sync.rs index 3c133ce..a3fa7da 100644 --- a/src/core/sync.rs +++ b/src/core/sync.rs @@ -151,29 +151,6 @@ pub fn user_flag(user_id: Option) -> String { .unwrap_or_default() } -/// If `device_serial` is empty, it lets ADB choose the default device. -pub fn hashset_system_packages( - state: PackageState, - device_serial: &str, - user_id: Option, -) -> HashSet { - let user = user_flag(user_id); - let action = match state { - PackageState::Enabled => format!("{PM_LIST_PACKS} -s -e{user}"), - PackageState::Disabled => format!("{PM_LIST_PACKS} -s -d{user}"), - _ => return HashSet::default(), // You probably don't need to use this function for anything else - }; - - match adb_cmd(true, device_serial, &action) { - Ok(s) => s - .lines() - // Assume every line has the same prefix - .map(|ln| String::from(&ln[PACK_URI_LEN as usize..])) - .collect(), - _ => HashSet::default(), - } -} - // Minimum information for processing adb commands #[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)] pub struct CorePackage { diff --git a/src/core/utils.rs b/src/core/utils.rs index 520b9c5..9066a38 100644 --- a/src/core/utils.rs +++ b/src/core/utils.rs @@ -8,6 +8,7 @@ use crate::gui::widgets::package_row::PackageRow; use chrono::{offset::Utc, DateTime, Local}; use csv::Writer; use std::{ + collections::HashSet, fmt, fs, path::{Path, PathBuf}, process::Command, @@ -33,9 +34,21 @@ pub fn fetch_packages( .pm() .ls_packs(Some(PmLsPackFlag::U), user_id) .unwrap_or_default(); - let enabled_sys_packs = hashset_system_packages(PackageState::Enabled, device_serial, user_id); - let disabled_sys_packs = - hashset_system_packages(PackageState::Disabled, device_serial, user_id); + let enabled_sys_packs: HashSet = AdbCmd::new() + .sh(device_serial) + .pm() + .ls_packs(Some(PmLsPackFlag::E), user_id) + .unwrap_or_default() + .into_iter() + .collect(); + let disabled_sys_packs: HashSet = AdbCmd::new() + .sh(device_serial) + .pm() + .ls_packs(Some(PmLsPackFlag::D), user_id) + .unwrap_or_default() + .into_iter() + .collect(); + let mut description; let mut uad_list; let mut state;