From 39cb07a012202d3d17b3e632f8d3cac58a5b2481 Mon Sep 17 00:00:00 2001 From: Himadri Bhattacharjee <107522312+lavafroth@users.noreply.github.com> Date: Sun, 28 Apr 2024 10:33:39 +0530 Subject: [PATCH] codecov: move serial environment variable name into constant --- src/core/sync.rs | 3 ++- src/core/utils.rs | 2 ++ src/gui/mod.rs | 4 ++-- src/gui/views/list.rs | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/sync.rs b/src/core/sync.rs index 776efbe..482e025 100644 --- a/src/core/sync.rs +++ b/src/core/sync.rs @@ -1,4 +1,5 @@ use crate::core::uad_lists::PackageState; +use crate::core::utils::ANDROID_SERIAL; use crate::gui::views::list::PackageInfo; use crate::gui::widgets::package_row::PackageRow; use regex::Regex; @@ -322,7 +323,7 @@ pub async fn get_devices_list() -> Vec { return OperationResult::Retry(vec![]); } for device in RE.captures_iter(&devices) { - env::set_var("ANDROID_SERIAL", &device[1]); + env::set_var(ANDROID_SERIAL, &device[1]); device_list.push(Phone { model: get_phone_brand(), android_sdk: get_android_sdk(), diff --git a/src/core/utils.rs b/src/core/utils.rs index b95d881..207966a 100644 --- a/src/core/utils.rs +++ b/src/core/utils.rs @@ -8,6 +8,8 @@ use std::path::PathBuf; use std::process::Command; use std::{fmt, fs}; +pub const ANDROID_SERIAL: &str = "ANDROID_SERIAL"; + pub fn fetch_packages(uad_lists: &PackageHashMap, user_id: Option<&User>) -> Vec { 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); diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 9fda70c..5ea7966 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -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; +use crate::core::utils::{string_to_theme, ANDROID_SERIAL}; use iced::advanced::graphics::image::image_rs::ImageFormat; use iced::font; @@ -261,7 +261,7 @@ 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); + env::set_var(ANDROID_SERIAL, s_device.adb_id); info!("{:-^65}", "-"); info!( "ANDROID_SDK: {} | DEVICE: {}", diff --git a/src/gui/views/list.rs b/src/gui/views/list.rs index 1173bf2..947deff 100644 --- a/src/gui/views/list.rs +++ b/src/gui/views/list.rs @@ -8,6 +8,7 @@ use crate::core::uad_lists::{ }; use crate::core::utils::fetch_packages; use crate::core::utils::open_url; +use crate::core::utils::ANDROID_SERIAL; use crate::gui::style; use crate::gui::widgets::navigation_menu::ICONS; use std::env; @@ -784,7 +785,7 @@ impl List { let (uad_lists, _) = load_debloat_lists(remote); match uad_lists { Ok(list) => { - env::set_var("ANDROID_SERIAL", phone.adb_id.clone()); + env::set_var(ANDROID_SERIAL, phone.adb_id.clone()); if phone.adb_id.is_empty() { error!("AppsView ready but no phone found"); }