diff --git a/.github/ISSUE_TEMPLATE/add-new-package-s-.md b/.github/ISSUE_TEMPLATE/add-new-package-s-.md
index adcd949..95492d7 100644
--- a/.github/ISSUE_TEMPLATE/add-new-package-s-.md
+++ b/.github/ISSUE_TEMPLATE/add-new-package-s-.md
@@ -1,28 +1,34 @@
---
name: Add new package(s)
about: You want to add new apps in the debloat list
-title: ''
+title: ""
labels: package::addition
-assignees: ''
-
+assignees: ""
---
-**Your phone:**
+**Your phone model:**
**Packages:**
+
```
com.this.is.a.bad.application
com.this.is.another.bad.application
...
```
+
- [ ] **I removed all those packages on my phone**
-If not why. Leave the brackets blank and explain why.
+ If not why. Leave the brackets blank and explain why.
## Document each package the best you can
-**List**: `Google`|`Misc`|`Oem` (manufacturer)|`Aosp`|`Pending`|`Carrier` (isp).
-**Removal**: `Recommended`, `Advanced`, `Expert` (this can break important features), `Unsafe` (this can bootloop the phone or break extremely important features).
+
+**List**: `Google`|`Misc`|`OEM` (manufacturer)|`AOSP`|`Pending`|`Carrier` (isp).
+
+**Removal**: `Recommended`, `Advanced`, `Expert` (this can break important features),
+or `Unsafe` (this can bootloop the phone or break extremely important features).
### \
-**List**: \
+
+**List**: \
**Removal**: \
+
> Description. Link to its Playstore page if it exists.
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 91cbc68..ff0523b 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -1,10 +1,9 @@
---
name: Bug report
about: You have an issue with the UAD software itself
-title: ''
+title: ""
labels: bug
-assignees: ''
-
+assignees: ""
---
**Describe the bug**
diff --git a/.github/ISSUE_TEMPLATE/debloat-issue-report.md b/.github/ISSUE_TEMPLATE/debloat-issue-report.md
index 8c3675c..e660ca6 100644
--- a/.github/ISSUE_TEMPLATE/debloat-issue-report.md
+++ b/.github/ISSUE_TEMPLATE/debloat-issue-report.md
@@ -1,13 +1,12 @@
---
name: Debloat issue report
about: Your phone has unexpected issues after debloating
-title: ''
+title: ""
labels: package::breakage
-assignees: ''
-
+assignees: ""
---
-**Your phone**: \
+**Your phone model**:
**Describe the issue**
A clear and concise description of what the problem is.
@@ -16,4 +15,4 @@ A clear and concise description of what the problem is.
What to do to fix the issue.
**UAD log**
-Upload the logfile generated by UAD. You can hardly be helped without.
+Upload the logfile generated by UAD. It would be difficult to help you without it.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index 5f98c43..b91ffca 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -1,10 +1,9 @@
---
name: Feature request
about: You want a new feature
-title: ''
+title: ""
labels: enhancement
-assignees: ''
-
+assignees: ""
---
**Describe the feature you want**
diff --git a/.github/ISSUE_TEMPLATE/update-apps-description-or-recommendation.md b/.github/ISSUE_TEMPLATE/update-apps-description-or-recommendation.md
index 9a5ec9b..2f1770b 100644
--- a/.github/ISSUE_TEMPLATE/update-apps-description-or-recommendation.md
+++ b/.github/ISSUE_TEMPLATE/update-apps-description-or-recommendation.md
@@ -1,30 +1,37 @@
---
name: Update apps description or recommendation
about: You want to improve/update a description/recommendation
-title: ''
+title: ""
labels: package::documentation
-assignees: ''
-
+assignees: ""
---
-**Your phone**: \
+**Your phone model**:
**Packages documentation to update:**
+
```
com.this.is.a.application
com.this.is.another.application
...
```
-## Documentation chage
-**List**: `Google`|`Misc`|`Oem` (manufacturer)|`Aosp`|`Pending`|`Carrier` (isp).
-**Removal**: `Recommended`, `Advanced`, `Expert` (this can break important features), `Unsafe` (this can bootloop the phone or break extremely important features).
+
+## Documentation Change
+
+**List**: `Google`|`Misc`|`OEM` (manufacturer)|`AOSP`|`Pending`|`Carrier` (isp).
+**Removal**: `Recommended`, `Advanced`, `Expert` (this can break important features),
+or `Unsafe` (this can bootloop the phone or break extremely important features).
### \
-**List**: \ :arrow_right: \
-**Removal**: \ :arrow_right: \
-**Current description**
+**List**: \ :arrow_right: \
+**Removal**: \
+:arrow_right: \
+
+### Current description
+
> Current description
-**Proposed description**
+### Proposed description
+
> Proposed description
diff --git a/.github/workflows/build_artifacts.yml b/.github/workflows/build_artifacts.yml
index 6435c6a..c5c1d23 100644
--- a/.github/workflows/build_artifacts.yml
+++ b/.github/workflows/build_artifacts.yml
@@ -25,9 +25,9 @@ jobs:
- graphics: glow
renderer: "-opengl"
- graphics: wgpu
- renderer: '' # Vulkan but we don't want this in the binary filename
+ renderer: "" # Vulkan but we don't want this in the binary filename
- update_feature: self-update
- update_name: '' # we don't want this in the binary filename
+ update_name: "" # we don't want this in the binary filename
- update_feature: no-self-update
update_name: "-noseflupdate"
steps:
@@ -62,4 +62,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: uad_gui${{ matrix.update_name }}-${{ matrix.build_target }}${{ matrix.renderer }}
- path: bin/uad_gui-*
\ No newline at end of file
+ path: bin/uad_gui-*
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index fc44f15..8774054 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -2,16 +2,16 @@ name: Continuous Integration
on:
push:
paths:
- - '**.rs'
- - 'Cargo.lock'
- - 'Cargo.toml'
- - '**.json'
+ - "**.rs"
+ - "Cargo.lock"
+ - "Cargo.toml"
+ - "**.json"
pull_request:
paths:
- - '**.rs'
- - 'Cargo.lock'
- - 'Cargo.toml'
- - '**.json'
+ - "**.rs"
+ - "Cargo.lock"
+ - "Cargo.toml"
+ - "**.json"
jobs:
lint:
@@ -33,7 +33,7 @@ jobs:
- lint: check
args: " --all-features"
- lint: test
- args: ''
+ args: ""
- lint: clippy
args: " --all --all-features -- -D warnings"
- lint: fmt
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 409d1c8..e56f565 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -5,9 +5,9 @@ on:
branches:
- main
paths:
- - '**.rs'
- - 'Cargo.lock'
- - 'Cargo.toml'
+ - "**.rs"
+ - "Cargo.lock"
+ - "Cargo.toml"
tags-ignore:
- dev-build
diff --git a/.gitignore b/.gitignore
index ddaaa38..ef930cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
debug/
target/
-*.log
\ No newline at end of file
+*.log
diff --git a/LICENSE b/LICENSE
index a91c83b..b1fdb54 100644
--- a/LICENSE
+++ b/LICENSE
@@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Universal Android Debloater GUI
- Copyright (C) 2021 W1nst0n
+ Copyright (C) 2021 W1nst0n
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
- Copyright (C) 2021 W1nst0n
+ Universal Android Debloater GUI Copyright (C) 2021 W1nst0n
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
diff --git a/README.md b/README.md
index 7940235..c4598a6 100644
--- a/README.md
+++ b/README.md
@@ -1,97 +1,122 @@
# Universal Android Debloater GUI
-**DISCLAIMER**: Use at your own risk. I am not responsible for anything that could happen to your phone.
+
+**DISCLAIMER**: Use at your own risk. I am not responsible for anything that
+could happen to your phone.
**This software is still in an early stage of development. Check out the issues, and feel free to contribute!**
## Summary
-This is a complete rewrite in Rust of the [UAD project](https://gitlab.com/W1nst0n/universal-android-debloater), which aims to improve privacy and battery performance by removing unnecessary and obscure system apps. This can also contribute to improve security by reducing [the attack surface](https://en.wikipedia.org/wiki/Attack_surface).
-Packages are as well documented as possible in order to provide a better understanding of what you can delete or not. The worst thing which could happen is removing an essential system package needed during boot causing then an unfortunate bootloop. After about 5 failed system boots, the phone will automatically reboot in recovery mode and you'll have to perform a FACTORY RESET. So make a backup first!
+This is a complete rewrite in Rust of the [UAD project](https://gitlab.com/W1nst0n/universal-android-debloater),
+which aims to improve privacy and battery performance by removing unnecessary
+and obscure system apps.
+This can also contribute to improve security by reducing [the attack surface](https://en.wikipedia.org/wiki/Attack_surface).
-In any case, you can NOT brick your device with this software! That's the main thing, right?
+Packages are as well documented as possible in order to provide a better
+understanding of what you can delete or not. The worst issue that could happen
+is removing an essential system package needed during boot causing then an unfortunate
+bootloop. After about 5 failed system boots, the phone will automatically reboot
+in recovery mode, and you'll have to perform a FACTORY RESET. Make a backup first!
+
+In any case, you **CANNOT** brick your device with this software!
+That's the main point, right?
## Features
-* [X] Uninstall/Disable and Restore/Enable system packages
-* [X] Multi-user support (e.g apps in work profiles)
-* [X] Export/Import your selection in `uad_exported_selection.txt`
-* [X] Multi-device support: you can connect multiple phones at the same time
-* [X] All your actions are logged so you never forget what you've done
-NB : System apps cannot really be uninstalled without root (see the [FAQ](https://github.com/0x192/universal-android-debloater/wiki/FAQ))
+- [x] Uninstall/Disable and Restore/Enable system packages
+- [x] Multi-user support (e.g. apps in work profiles)
+- [x] Export/Import your selection in `uad_exported_selection.txt`
+- [x] Multi-device support: you can connect multiple phones at the same time
+- [x] All your actions are logged, so you never forget what you've done
-## Universal debloat lists
-* [X] GFAM (Google/Facebook/Amazon/Microsoft)
-* [X] AOSP
-* [X] Manufacturers (OEM)
-* [X] Mobile carriers
-* [X] Qualcomm / Mediatek / Miscellaneous
+NB : System apps cannot truly be uninstalled without root (see the [FAQ](https://github.com/0x192/universal-android-debloater/wiki/FAQ))
+
+## Universal Debloat Lists
+
+- [x] GFAM (Google/Facebook/Amazon/Microsoft)
+- [x] AOSP
+- [x] Manufacturers (OEM)
+- [x] Mobile carriers
+- [x] Qualcomm / Mediatek / Miscellaneous
## Manufacturers debloat lists
-* [ ] Archos
-* [X] Asus
-* [ ] Blackberry
-* [ ] Gionee
-* [X] LG
-* [X] Google
-* [ ] iQOO
-* [X] Fairphone
-* [ ] HTC
-* [X] Huawei
-* [X] Motorola
-* [X] Nokia
-* [X] OnePlus
-* [X] Oppo
-* [X] Realme
-* [X] Samsung
-* [X] Sony
-* [X] Tecno
-* [ ] TCL
-* [X] Unihertz
-* [X] Vivo/iQOO
-* [ ] Wiko
-* [X] Xiaomi
-* [X] ZTE
+
+- [ ] Archos
+- [x] Asus
+- [ ] Blackberry
+- [ ] Gionee
+- [x] LG
+- [x] Google
+- [ ] iQOO
+- [x] Fairphone
+- [ ] HTC
+- [x] Huawei
+- [x] Motorola
+- [x] Nokia
+- [x] OnePlus
+- [x] Oppo
+- [x] Realme
+- [x] Samsung
+- [x] Sony
+- [x] Tecno
+- [ ] TCL
+- [x] Unihertz
+- [x] Vivo/iQOO
+- [ ] Wiko
+- [x] Xiaomi
+- [x] ZTE
## Mobile carriers debloat lists
-| Country | Carriers |
-|-----------------|-----------------------------------|
-| France | Orange, SFR, Free, Bouygues |
-| USA | T-Mobile, Verizon, Sprint, AT&T |
-| Germany | Telekom |
-| UK | EE |
+| Country | Carriers |
+| ------- | ------------------------------- |
+| France | Orange, SFR, Free, Bouygues |
+| USA | T-Mobile, Verizon, Sprint, AT&T |
+| Germany | Telekom |
+| UK | EE |
## How to use it
+
- **Read the [FAQ](https://github.com/0x192/universal-android-debloater/wiki/FAQ)!**
- **Do a proper backup of your data! You can never be too careful!**
-- Enable *Developer Options* on your smartphone.
-- Turn on *USB Debugging* from the developer panel.
-- From the settings, disconnect from any OEM accounts (when you delete an OEM account package it could lock you on the lockscreen because the phone can't associate your identity anymore)
+- Enable _Developer Options_ on your smartphone.
+- Turn on _USB Debugging_ from the developer panel.
+- From the settings, disconnect from any OEM accounts (when you delete an OEM
+ account package it could lock you on the lockscreen because the phone can't
+ associate your identity anymore)
- Install ADB (see the intructions by clicking on your OS below):
LINUX
- - Install *Android platform tools* on your PC :
+ - Install _Android platform tools_ on your PC :
Debian Base:
+
```bash
- $ sudo apt install android-sdk-platform-tools
+ sudo apt install android-sdk-platform-tools
```
+
Arch-Linux Base:
+
```bash
- $ sudo pacman -S android-tools
+ sudo pacman -S android-tools
```
+
Red Hat Base:
+
```bash
- $ sudo yum install android-tools
+ sudo yum install android-tools
```
+
OpenSUSE Base:
+
```bash
- $ sudo zypper install android-tools
+ sudo zypper install android-tools
```
+
@@ -100,42 +125,55 @@ NB : System apps cannot really be uninstalled without root (see the [FAQ](https:
MAC OS
- Install [Homebrew](https://brew.sh/)
- - Install *Android platform tools*
+ - Install _Android platform tools_
+
```bash
- $ brew install android-platform-tools
+ brew install android-platform-tools
```
-
-
+
+
+
WINDOWS
- - Download [android platform tools](https://dl.google.com/android/repository/platform-tools-latest-windows.zip) and unzip it somewhere.
- - [Add the android platform tools to your PATH](https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/) **OR** make sure to launch UAD from the same directory.
+ - Download [android platform tools](https://dl.google.com/android/repository/platform-tools-latest-windows.zip)
+ and unzip it somewhere.
+ - [Add the android platform tools to your PATH](https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/)
+ **OR** make sure to launch UAD from the same directory.
- [Install USB drivers for your device](https://developer.android.com/studio/run/oem-usb#Drivers)
- Check your device is detected:
- ```batch
- > adb devices
+
+ ```bash
+ adb devices
```
-
-
+
+
-- Download the latest release of UAD GUI for your Operating System [here](https://github.com/0x192/universal-android-debloater/releases). Take the `opengl` version only if the default version (with a Vulkan backend) doesn't launch.
+- Download the latest release of UAD GUI for your Operating System [here](https://github.com/0x192/universal-android-debloater/releases).
+ Take the `opengl` version only if the default version (with a Vulkan backend)
+ doesn't launch.
-**NOTE:** Chinese phones users may need to use the AOSP list for removing some stock apps because those Chinese manufacturers (especially Xiaomi and Huawei) have been using the name of AOSP packages for their own (modified & closed-source) apps.
+**NOTE:** Chinese phones users may need to use the AOSP list for removing some stock
+apps because those Chinese manufacturers (especially Xiaomi and Huawei) have been
+using the name of AOSP packages for their own (modified & closed-source) apps.
-**IMPORTANT NOTE:** You will have to run this software whenever your OEM pushes an update to your phone as some *uninstalled* system apps could be reinstalled.
+**IMPORTANT NOTE:** You will have to run this software whenever your OEM pushes
+an update to your phone as some _uninstalled_ system apps could be reinstalled.
## How to contribute
-Hey-hey-hey! Don't go away so fast! This is a community project. That means I need you! I'm sure you want to make this project better anyway.
+Hey-hey-hey! Don't go away so fast! This is a community project.
+That means I need you! I'm sure you want to make this project better anyway.
==> [How to contribute](https://github.com/0x192/universal-android-debloater/wiki)
## Special thanks
-- [@mawilms](https://github.com/mawilms) for his LotRO plugin manager ([Lembas](https://github.com/mawilms/lembas)) which helped me a lot to understand how to use the [Iced](https://github.com/hecrj/iced) GUI library.
+- [@mawilms](https://github.com/mawilms) for his LotRO plugin manager ([Lembas](https://github.com/mawilms/lembas))
+ which helped me a lot to understand how to use the [Iced](https://github.com/hecrj/iced)
+ GUI library.
- [@casperstorm](https://github.com/casperstorm) for the UI/UX inspiration.
diff --git a/src/core/config.rs b/src/core/config.rs
index 7fed6df..1243866 100644
--- a/src/core/config.rs
+++ b/src/core/config.rs
@@ -55,43 +55,38 @@ static CONFIG_FILE: PathBuf = CONFIG_DIR.join("config.toml");
impl Config {
pub fn save_changes(settings: &Settings, device_id: &String) {
let mut config = Self::load_configuration_file();
- match config
+ if let Some(device) = config
.devices
.iter_mut()
.find(|x| x.device_id == *device_id)
{
- Some(device) => {
- *device = settings.device.clone();
- config.general = settings.general.clone();
- }
- None => {
- debug!("config: New device settings saved");
- config.devices.push(settings.device.clone());
- config.general = settings.general.clone();
- }
+ *device = settings.device.clone();
+ } else {
+ debug!("config: New device settings saved");
+ config.devices.push(settings.device.clone());
}
+ config.general = settings.general.clone();
let toml = toml::to_string(&config).unwrap();
fs::write(&*CONFIG_FILE, toml).expect("Could not write config file to disk!");
}
+ #[allow(clippy::option_if_let_else)]
pub fn load_configuration_file() -> Self {
- match fs::read_to_string(&*CONFIG_FILE) {
- Ok(s) => match toml::from_str(&s) {
+ if let Ok(s) = fs::read_to_string(&*CONFIG_FILE) {
+ match toml::from_str(&s) {
Ok(config) => config,
Err(e) => {
error!("Invalid config file: `{}`", e);
error!("Restoring default config file");
- let toml = toml::to_string(&Config::default()).unwrap();
+ let toml = toml::to_string(&Self::default()).unwrap();
fs::write(&*CONFIG_FILE, toml).expect("Could not write config file to disk!");
- Config::default()
+ Self::default()
}
- },
- Err(_) => {
- let default_conf = toml::to_string(&Config::default()).unwrap();
- fs::write(&*CONFIG_FILE, default_conf)
- .expect("Could not write config file to disk!");
- Config::default()
}
+ } else {
+ let default_conf = toml::to_string(&Self::default()).unwrap();
+ fs::write(&*CONFIG_FILE, default_conf).expect("Could not write config file to disk!");
+ Self::default()
}
}
}
diff --git a/src/core/save.rs b/src/core/save.rs
index 222d734..3a6697d 100644
--- a/src/core/save.rs
+++ b/src/core/save.rs
@@ -44,7 +44,7 @@ pub async fn backup_phone(
user_backup.packages.push(CorePackage {
name: p.name.clone(),
state: p.state,
- })
+ });
}
backup.users.push(user_backup);
}
@@ -71,6 +71,7 @@ pub async fn backup_phone(
}
pub fn list_available_backups(dir: &Path) -> Vec {
+ #[allow(clippy::option_if_let_else)]
match fs::read_dir(dir) {
Ok(files) => files
.filter_map(|e| e.ok())
@@ -129,15 +130,14 @@ pub fn restore_backup(
let mut commands = vec![];
for u in phone_backup.users {
- let mut _index = 0;
- match selected_device.user_list.iter().find(|x| x.id == u.id) {
- Some(i) => _index = i.index,
+ let index = match selected_device.user_list.iter().find(|x| x.id == u.id) {
+ Some(i) => i.index,
None => return Err(format!("user {} doesn't exist", u.id)),
};
for (i, backup_package) in u.packages.iter().enumerate() {
let package: CorePackage;
- match packages[_index]
+ match packages[index]
.iter()
.find(|x| x.name == backup_package.name)
{
@@ -150,8 +150,8 @@ pub fn restore_backup(
}
}
let p_commands = apply_pkg_state_commands(
- package,
- &backup_package.state,
+ &package,
+ backup_package.state,
&settings
.backup
.selected_user
diff --git a/src/core/sync.rs b/src/core/sync.rs
index 13fbcc4..0ad8b7c 100644
--- a/src/core/sync.rs
+++ b/src/core/sync.rs
@@ -29,7 +29,7 @@ impl Default for Phone {
model: "fetching devices...".to_string(),
android_sdk: 0,
user_list: vec![],
- adb_id: "".to_string(),
+ adb_id: String::new(),
}
}
}
@@ -54,9 +54,10 @@ impl std::fmt::Display for User {
}
pub fn adb_shell_command(shell: bool, args: &str) -> Result {
- let adb_command = match shell {
- true => vec!["shell", args],
- false => vec![args],
+ let adb_command = if shell {
+ vec!["shell", args]
+ } else {
+ vec![args]
};
#[cfg(target_os = "windows")]
@@ -77,7 +78,12 @@ pub fn adb_shell_command(shell: bool, args: &str) -> Result {
Err("ADB was not found".to_string())
}
Ok(o) => {
- if !o.status.success() {
+ if o.status.success() {
+ Ok(String::from_utf8(o.stdout)
+ .map_err(|e| e.to_string())?
+ .trim_end()
+ .to_string())
+ } else {
let stdout = String::from_utf8(o.stdout)
.map_err(|e| e.to_string())?
.trim_end()
@@ -90,11 +96,6 @@ pub fn adb_shell_command(shell: bool, args: &str) -> Result {
// ADB does really weird things. Some errors are not redirected to stderr
let err = if stdout.is_empty() { stderr } else { stdout };
Err(err)
- } else {
- Ok(String::from_utf8(o.stdout)
- .map_err(|e| e.to_string())?
- .trim_end()
- .to_string())
}
}
}
@@ -139,26 +140,28 @@ pub async fn perform_adb_commands(
}
pub fn list_all_system_packages(user_id: Option<&User>) -> String {
+ #[allow(clippy::option_if_let_else)]
let action = match user_id {
Some(user_id) => format!("pm list packages -s -u --user {}", user_id.id),
None => "pm list packages -s -u".to_string(),
};
adb_shell_command(true, &action)
- .unwrap_or_else(|_| "".to_string())
+ .unwrap_or_else(|_| String::new())
.replace("package:", "")
}
pub fn hashset_system_packages(state: PackageState, user_id: Option<&User>) -> HashSet {
+ #[allow(clippy::option_if_let_else)]
let user = match user_id {
Some(user_id) => format!(" --user {}", user_id.id),
- None => "".to_string(),
+ None => String::new(),
};
let action = match state {
PackageState::Enabled => format!("pm list packages -s -e{user}"),
PackageState::Disabled => format!("pm list package -s -d{user}"),
- _ => "".to_string(), // You probably don't need to use this function for anything else
+ _ => String::new(), // You probably don't need to use this function for anything else
};
adb_shell_command(true, &action)
@@ -178,7 +181,7 @@ pub struct CorePackage {
impl From<&mut PackageRow> for CorePackage {
fn from(pr: &mut PackageRow) -> Self {
- CorePackage {
+ Self {
name: pr.name.clone(),
state: pr.state,
}
@@ -186,7 +189,7 @@ impl From<&mut PackageRow> for CorePackage {
}
impl From for CorePackage {
fn from(pr: PackageRow) -> Self {
- CorePackage {
+ Self {
name: pr.name.clone(),
state: pr.state,
}
@@ -195,7 +198,7 @@ impl From for CorePackage {
impl From<&PackageRow> for CorePackage {
fn from(pr: &PackageRow) -> Self {
- CorePackage {
+ Self {
name: pr.name.clone(),
state: pr.state,
}
@@ -203,8 +206,8 @@ impl From<&PackageRow> for CorePackage {
}
pub fn apply_pkg_state_commands(
- package: CorePackage,
- wanted_state: &PackageState,
+ package: &CorePackage,
+ wanted_state: PackageState,
selected_user: &User,
phone: &Phone,
) -> Vec {
@@ -242,24 +245,25 @@ pub fn apply_pkg_state_commands(
},
_ => vec![],
},
- _ => vec![],
+ PackageState::All => vec![],
};
if phone.android_sdk < 21 {
- request_builder(commands, &package.name, None)
+ request_builder(&commands, &package.name, None)
} else {
- request_builder(commands, &package.name, Some(selected_user))
+ request_builder(&commands, &package.name, Some(selected_user))
}
}
-pub fn request_builder(commands: Vec<&str>, package: &str, user: Option<&User>) -> Vec {
- if let Some(u) = user {
- commands
- .iter()
- .map(|c| format!("{} --user {} {}", c, u.id, package))
- .collect()
- } else {
- commands.iter().map(|c| format!("{c} {package}")).collect()
- }
+pub fn request_builder(commands: &[&str], package: &str, user: Option<&User>) -> Vec {
+ user.map_or_else(
+ || commands.iter().map(|c| format!("{c} {package}")).collect(),
+ |u| {
+ commands
+ .iter()
+ .map(|c| format!("{} --user {} {}", c, u.id, package))
+ .collect()
+ },
+ )
}
pub fn get_phone_model() -> String {
@@ -277,17 +281,14 @@ pub fn get_phone_model() -> String {
}
pub fn get_android_sdk() -> u8 {
- match adb_shell_command(true, "getprop ro.build.version.sdk") {
- Ok(sdk) => sdk.parse().unwrap(),
- Err(_) => 0,
- }
+ adb_shell_command(true, "getprop ro.build.version.sdk").map_or(0, |sdk| sdk.parse().unwrap())
}
pub fn get_phone_brand() -> String {
format!(
"{} {}",
adb_shell_command(true, "getprop ro.product.brand")
- .unwrap_or_else(|_| "".to_string())
+ .unwrap_or_else(|_| String::new())
.trim(),
get_phone_model()
)
@@ -300,6 +301,8 @@ pub fn is_protected_user(user_id: &str) -> bool {
pub fn get_user_list() -> Vec {
#[dynamic]
static RE: Regex = Regex::new(r"\{([0-9]+)").unwrap();
+
+ #[allow(clippy::option_if_let_else)]
match adb_shell_command(true, "pm list users") {
Ok(users) => RE
.find_iter(&users)
@@ -316,7 +319,7 @@ pub fn get_user_list() -> Vec {
// getprop ro.serialno
pub async fn get_devices_list() -> Vec {
- match retry(
+ retry(
Fixed::from_millis(500).take(120),
|| match adb_shell_command(false, "devices") {
Ok(devices) => {
@@ -341,8 +344,6 @@ pub async fn get_devices_list() -> Vec {
OperationResult::Retry(test)
}
},
- ) {
- Ok(devices) => devices,
- Err(_) => vec![],
- }
+ )
+ .map_or_else(|_| vec![], |devices| devices)
}
diff --git a/src/core/theme.rs b/src/core/theme.rs
index 7b42780..ffc1379 100644
--- a/src/core/theme.rs
+++ b/src/core/theme.rs
@@ -39,7 +39,7 @@ pub struct ColorPalette {
impl Theme {
pub const ALL: [Self; 3] = [Self::Lupin, Self::Dark, Self::Light];
- pub fn palette(&self) -> ColorPalette {
+ pub fn palette(self) -> ColorPalette {
match self {
Self::Dark => ColorPalette {
base: BaseColors {
@@ -105,9 +105,9 @@ impl std::fmt::Display for Theme {
f,
"{}",
match self {
- Theme::Dark => "Dark",
- Theme::Light => "Light",
- Theme::Lupin => "Lupin",
+ Self::Dark => "Dark",
+ Self::Light => "Light",
+ Self::Lupin => "Lupin",
}
)
}
diff --git a/src/core/uad_lists.rs b/src/core/uad_lists.rs
index d169c11..abefa40 100644
--- a/src/core/uad_lists.rs
+++ b/src/core/uad_lists.rs
@@ -44,24 +44,24 @@ impl std::fmt::Display for UadListState {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let date = last_modified_date(CACHE_DIR.join("uad_lists.json"));
let s = match self {
- UadListState::Downloading => "Checking updates...".to_string(),
- UadListState::Done => format!("Done (last was {})", format_diff_time_from_now(date)),
- UadListState::Failed => "Failed to check update!".to_string(),
+ Self::Downloading => "Checking updates...".to_string(),
+ Self::Done => format!("Done (last was {})", format_diff_time_from_now(date)),
+ Self::Failed => "Failed to check update!".to_string(),
};
write!(f, "{s}")
}
}
impl UadList {
- pub const ALL: [UadList; 8] = [
- UadList::All,
- UadList::Aosp,
- UadList::Carrier,
- UadList::Google,
- UadList::Misc,
- UadList::Oem,
- UadList::Pending,
- UadList::Unlisted,
+ pub const ALL: [Self; 8] = [
+ Self::All,
+ Self::Aosp,
+ Self::Carrier,
+ Self::Google,
+ Self::Misc,
+ Self::Oem,
+ Self::Pending,
+ Self::Unlisted,
];
}
@@ -71,14 +71,14 @@ impl std::fmt::Display for UadList {
f,
"{}",
match self {
- UadList::All => "All lists",
- UadList::Aosp => "aosp",
- UadList::Carrier => "carrier",
- UadList::Google => "google",
- UadList::Misc => "misc",
- UadList::Oem => "oem",
- UadList::Pending => "pending",
- UadList::Unlisted => "unlisted",
+ Self::All => "All lists",
+ Self::Aosp => "aosp",
+ Self::Carrier => "carrier",
+ Self::Google => "google",
+ Self::Misc => "misc",
+ Self::Oem => "oem",
+ Self::Pending => "pending",
+ Self::Unlisted => "unlisted",
}
)
}
@@ -94,12 +94,7 @@ pub enum PackageState {
}
impl PackageState {
- pub const ALL: [PackageState; 4] = [
- PackageState::All,
- PackageState::Enabled,
- PackageState::Uninstalled,
- PackageState::Disabled,
- ];
+ pub const ALL: [Self; 4] = [Self::All, Self::Enabled, Self::Uninstalled, Self::Disabled];
}
impl std::fmt::Display for PackageState {
@@ -108,10 +103,10 @@ impl std::fmt::Display for PackageState {
f,
"{}",
match self {
- PackageState::All => "All packages",
- PackageState::Enabled => "Enabled",
- PackageState::Uninstalled => "Uninstalled",
- PackageState::Disabled => "Disabled",
+ Self::All => "All packages",
+ Self::Enabled => "Enabled",
+ Self::Uninstalled => "Uninstalled",
+ Self::Disabled => "Disabled",
}
)
}
@@ -122,17 +117,17 @@ pub trait Opposite {
}
impl Opposite for PackageState {
- fn opposite(&self, disable: bool) -> PackageState {
+ fn opposite(&self, disable: bool) -> Self {
match self {
- PackageState::Enabled => {
+ Self::Enabled => {
if disable {
- PackageState::Disabled
+ Self::Disabled
} else {
- PackageState::Uninstalled
+ Self::Uninstalled
}
}
- PackageState::Uninstalled | PackageState::Disabled => PackageState::Enabled,
- PackageState::All => PackageState::All,
+ Self::Uninstalled | Self::Disabled => Self::Enabled,
+ Self::All => Self::All,
}
}
}
@@ -150,13 +145,13 @@ pub enum Removal {
}
impl Removal {
- pub const ALL: [Removal; 6] = [
- Removal::All,
- Removal::Recommended,
- Removal::Advanced,
- Removal::Expert,
- Removal::Unsafe,
- Removal::Unlisted,
+ pub const ALL: [Self; 6] = [
+ Self::All,
+ Self::Recommended,
+ Self::Advanced,
+ Self::Expert,
+ Self::Unsafe,
+ Self::Unlisted,
];
}
@@ -166,12 +161,12 @@ impl std::fmt::Display for Removal {
f,
"{}",
match self {
- Removal::All => "All",
- Removal::Recommended => "Recommended",
- Removal::Advanced => "Advanced",
- Removal::Expert => "Expert",
- Removal::Unsafe => "Unsafe",
- Removal::Unlisted => "Unlisted",
+ Self::All => "All",
+ Self::Recommended => "Recommended",
+ Self::Advanced => "Advanced",
+ Self::Expert => "Expert",
+ Self::Unsafe => "Unsafe",
+ Self::Unlisted => "Unlisted",
}
)
}
@@ -182,10 +177,10 @@ pub fn load_debloat_lists(remote: bool) -> (Result = if remote {
- match retry(Fixed::from_millis(1000).take(60), || {
+ retry(Fixed::from_millis(1000).take(60), || {
match ureq::get(
"https://raw.githubusercontent.com/0x192/universal-android-debloater/\
- main/resources/assets/uad_lists.json",
+ main/resources/assets/uad_lists.json",
)
.call()
{
@@ -201,10 +196,8 @@ pub fn load_debloat_lists(remote: bool) -> (Result::new())
}
}
- }) {
- Ok(list) => list,
- Err(_) => get_local_lists(),
- }
+ })
+ .map_or_else(|_| get_local_lists(), |list| list)
} else {
warn!("Could not load remote debloat list");
get_local_lists()
diff --git a/src/core/update.rs b/src/core/update.rs
index ca05c50..3d63469 100644
--- a/src/core/update.rs
+++ b/src/core/update.rs
@@ -41,10 +41,10 @@ pub enum SelfUpdateStatus {
impl std::fmt::Display for SelfUpdateStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let s = match self {
- SelfUpdateStatus::Checking => "Checking updates...",
- SelfUpdateStatus::Updating => "Updating...",
- SelfUpdateStatus::Failed => "Failed to check update!",
- SelfUpdateStatus::Done => "Done",
+ Self::Checking => "Checking updates...",
+ Self::Updating => "Updating...",
+ Self::Failed => "Failed to check update!",
+ Self::Done => "Done",
};
write!(f, "{s}")
}
@@ -52,7 +52,7 @@ impl std::fmt::Display for SelfUpdateStatus {
/// Download a file from the internet
#[cfg(feature = "self-update")]
-pub async fn download_file(url: T, dest_file: PathBuf) -> Result<(), String> {
+pub async fn download_file(url: T, dest_file: PathBuf) -> Result<(), String> {
let url = url.to_string();
debug!("downloading file from {}", &url);
@@ -200,7 +200,7 @@ pub fn get_latest_release() -> Result