mirror of
https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation.git
synced 2026-08-09 15:19:11 +02:00
refactor(set_var-serial): define set_adb_serial
This commit is contained in:
parent
8ddbe68ebe
commit
8a80cdc921
4 changed files with 30 additions and 8 deletions
|
|
@ -13,6 +13,8 @@ use std::process::Command;
|
|||
#[cfg(target_os = "windows")]
|
||||
use std::os::windows::process::CommandExt;
|
||||
|
||||
use super::utils::set_adb_serial;
|
||||
|
||||
const PM_LS_PKG: &str = "pm list packages";
|
||||
const PM_C: &str = "pm clear";
|
||||
|
||||
|
|
@ -327,7 +329,10 @@ pub async fn get_devices_list() -> Vec<Phone> {
|
|||
return OperationResult::Retry(vec![]);
|
||||
}
|
||||
for device in RE.captures_iter(&devices) {
|
||||
env::set_var(ANDROID_SERIAL, &device[1]);
|
||||
#[allow(unsafe_code)]
|
||||
unsafe {
|
||||
set_adb_serial(&device[1])
|
||||
};
|
||||
device_list.push(Phone {
|
||||
model: get_phone_brand(),
|
||||
android_sdk: get_android_sdk(),
|
||||
|
|
|
|||
|
|
@ -5,10 +5,13 @@ use crate::gui::widgets::package_row::PackageRow;
|
|||
use chrono::offset::Utc;
|
||||
use chrono::{DateTime, Local};
|
||||
use csv::Writer;
|
||||
use std::ffi::OsStr;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
use std::{fmt, fs};
|
||||
|
||||
use super::sync::Phone;
|
||||
|
||||
/// Canonical shortened name of the application
|
||||
pub const NAME: &str = "UAD-ng";
|
||||
/// Global environment variable to keep
|
||||
|
|
@ -24,6 +27,15 @@ pub enum Error {
|
|||
DialogClosed,
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
#[allow(
|
||||
clippy::semicolon_if_nothing_returned,
|
||||
reason = "fn must return whatever `set_var` returns"
|
||||
)]
|
||||
pub unsafe fn set_adb_serial<D: AsRef<OsStr>>(device: D) {
|
||||
std::env::set_var(ANDROID_SERIAL, device)
|
||||
}
|
||||
|
||||
pub fn fetch_packages(uad_lists: &PackageHashMap, user_id: Option<&User>) -> Vec<PackageRow> {
|
||||
let all_system_packages = list_all_system_packages(user_id); // installed and uninstalled packages
|
||||
let enabled_system_packages = hashset_system_packages(PackageState::Enabled, user_id);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::core::sync::{get_devices_list, initial_load, perform_adb_commands, Co
|
|||
use crate::core::theme::Theme;
|
||||
use crate::core::uad_lists::UadListState;
|
||||
use crate::core::update::{get_latest_release, Release, SelfUpdateState, SelfUpdateStatus};
|
||||
use crate::core::utils::{string_to_theme, ANDROID_SERIAL, NAME};
|
||||
use crate::core::utils::{set_adb_serial, string_to_theme, ANDROID_SERIAL, NAME};
|
||||
|
||||
use iced::advanced::graphics::image::image_rs::ImageFormat;
|
||||
use iced::font;
|
||||
|
|
@ -255,7 +255,10 @@ impl Application for UadGui {
|
|||
Message::DeviceSelected(s_device) => {
|
||||
self.selected_device = Some(s_device.clone());
|
||||
self.view = View::List;
|
||||
env::set_var(ANDROID_SERIAL, s_device.adb_id);
|
||||
#[allow(unsafe_code)]
|
||||
unsafe {
|
||||
set_adb_serial(s_device.adb_id)
|
||||
};
|
||||
info!("{:-^65}", "-");
|
||||
info!(
|
||||
"ANDROID_SDK: {} | DEVICE: {}",
|
||||
|
|
|
|||
|
|
@ -8,11 +8,10 @@ use crate::core::uad_lists::{
|
|||
load_debloat_lists, Opposite, PackageHashMap, PackageState, Removal, UadList, UadListState,
|
||||
};
|
||||
use crate::core::utils::{
|
||||
export_selection, fetch_packages, open_url, ANDROID_SERIAL, EXPORT_FILE_NAME, NAME,
|
||||
export_selection, fetch_packages, open_url, set_adb_serial, EXPORT_FILE_NAME, NAME,
|
||||
};
|
||||
use crate::gui::style;
|
||||
use crate::gui::widgets::navigation_menu::ICONS;
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::gui::views::settings::Settings;
|
||||
|
|
@ -864,12 +863,15 @@ impl List {
|
|||
}
|
||||
|
||||
#[expect(clippy::unused_async, reason = "1 call-site")]
|
||||
async fn init_apps_view(remote: bool, phone: Phone) -> (PackageHashMap, UadListState) {
|
||||
async fn init_apps_view(remote: bool, device: Phone) -> (PackageHashMap, UadListState) {
|
||||
let uad_lists = load_debloat_lists(remote);
|
||||
match uad_lists {
|
||||
Ok(list) => {
|
||||
env::set_var(ANDROID_SERIAL, phone.adb_id.clone());
|
||||
if phone.adb_id.is_empty() {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe {
|
||||
set_adb_serial(device.adb_id.clone())
|
||||
};
|
||||
if device.adb_id.is_empty() {
|
||||
error!("AppsView ready but no phone found");
|
||||
}
|
||||
(list, UadListState::Done)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue