From bdb0317a9e093eefe75916b3fcc9192c8c17a694 Mon Sep 17 00:00:00 2001 From: kitadai31 <90122968+kitadai31@users.noreply.github.com> Date: Sat, 31 May 2025 16:22:55 +0900 Subject: [PATCH] fix: "Save patched app" attempts to copy APK when patching fails (#2565) --- .../views/installer/installer_viewmodel.dart | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 7e7cfdcf..09094acd 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -125,7 +125,7 @@ class InstallerViewModel extends BaseViewModel { }); await WakelockPlus.enable(); await handlePlatformChannelMethods(); - await runPatcher(context); + await runPatcher(); } Future handlePlatformChannelMethods() async { @@ -164,6 +164,16 @@ class InstallerViewModel extends BaseViewModel { _managerAPI.setLastUsedPatchesVersion( version: _managerAPI.patchesVersion, ); + _app.appliedPatches = _patches.map((p) => p.name).toList(); + if (_managerAPI.isLastPatchedAppEnabled()) { + await _managerAPI.setLastPatchedApp(_app, _patcherAPI.outFile!); + } else { + _app.patchedFilePath = _patcherAPI.outFile!.path; + } + final homeViewModel = locator(); + _managerAPI + .reAssessPatchedApps() + .then((_) => homeViewModel.getPatchedApps()); } else if (value == -100.0) { isPatching = false; hasErrors = true; @@ -187,7 +197,7 @@ class InstallerViewModel extends BaseViewModel { notifyListeners(); } - Future runPatcher(BuildContext context) async { + Future runPatcher() async { try { await _patcherAPI.runPatcher( _app.packageName, @@ -195,16 +205,6 @@ class InstallerViewModel extends BaseViewModel { _patches, _app.isFromStorage, ); - _app.appliedPatches = _patches.map((p) => p.name).toList(); - if (_managerAPI.isLastPatchedAppEnabled()) { - await _managerAPI.setLastPatchedApp(_app, _patcherAPI.outFile!); - } else { - _app.patchedFilePath = _patcherAPI.outFile!.path; - } - final homeViewModel = locator(); - _managerAPI - .reAssessPatchedApps() - .then((_) => homeViewModel.getPatchedApps()); } on Exception catch (e) { update( -100.0, @@ -506,7 +506,7 @@ class InstallerViewModel extends BaseViewModel { _app.isRooted = installAsRoot; if (headerLogs != 'Installing...') { update( - .85, + -1.0, 'Installing...', _app.isRooted ? 'Mounting patched app' : 'Installing patched app', ); @@ -534,7 +534,7 @@ class InstallerViewModel extends BaseViewModel { update(1.0, 'Installed', 'Installed'); } else if (response == 3) { update( - .85, + -1.0, 'Installation canceled', 'Installation canceled', ); @@ -542,7 +542,7 @@ class InstallerViewModel extends BaseViewModel { installResult(context, installAsRoot); } else { update( - .85, + -1.0, 'Installation failed', 'Installation failed', );