mirror of
https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation.git
synced 2026-08-09 15:19:11 +02:00
refactor: replace hashset_system_packages by new API
This commit is contained in:
parent
4c61dc32f5
commit
4ec1acd769
2 changed files with 16 additions and 26 deletions
|
|
@ -151,29 +151,6 @@ pub fn user_flag(user_id: Option<User>) -> 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<User>,
|
||||
) -> HashSet<String> {
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -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<String> = AdbCmd::new()
|
||||
.sh(device_serial)
|
||||
.pm()
|
||||
.ls_packs(Some(PmLsPackFlag::E), user_id)
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.collect();
|
||||
let disabled_sys_packs: HashSet<String> = 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue