mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
refactor: Simplify uninstallApp
code
This commit is contained in:
parent
9680f0cf12
commit
48a739c94e
1 changed files with 8 additions and 12 deletions
|
@ -25,20 +25,16 @@ class AppInfoViewModel extends BaseViewModel {
|
|||
PatchedApplication app,
|
||||
bool onlyUnpatch,
|
||||
) async {
|
||||
bool isUninstalled = true;
|
||||
if (app.isRooted) {
|
||||
final bool hasRootPermissions = await _rootAPI.hasRootPermissions();
|
||||
if (hasRootPermissions) {
|
||||
await _rootAPI.uninstall(
|
||||
app.packageName,
|
||||
);
|
||||
if (!onlyUnpatch) {
|
||||
await DeviceApps.uninstallApp(app.packageName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var isUninstalled = onlyUnpatch;
|
||||
|
||||
if (!onlyUnpatch) {
|
||||
isUninstalled = await DeviceApps.uninstallApp(app.packageName);
|
||||
}
|
||||
|
||||
if (isUninstalled && app.isRooted && await _rootAPI.hasRootPermissions()) {
|
||||
await _rootAPI.uninstall(app.packageName);
|
||||
}
|
||||
|
||||
if (isUninstalled) {
|
||||
await _managerAPI.deletePatchedApp(app);
|
||||
locator<HomeViewModel>().initialize(context);
|
||||
|
|
Loading…
Reference in a new issue