Skip to content

Commit bdb0317

Browse files
authored
fix: "Save patched app" attempts to copy APK when patching fails (#2565)
1 parent b046440 commit bdb0317

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lib/ui/views/installer/installer_viewmodel.dart

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class InstallerViewModel extends BaseViewModel {
125125
});
126126
await WakelockPlus.enable();
127127
await handlePlatformChannelMethods();
128-
await runPatcher(context);
128+
await runPatcher();
129129
}
130130

131131
Future<dynamic> handlePlatformChannelMethods() async {
@@ -164,6 +164,16 @@ class InstallerViewModel extends BaseViewModel {
164164
_managerAPI.setLastUsedPatchesVersion(
165165
version: _managerAPI.patchesVersion,
166166
);
167+
_app.appliedPatches = _patches.map((p) => p.name).toList();
168+
if (_managerAPI.isLastPatchedAppEnabled()) {
169+
await _managerAPI.setLastPatchedApp(_app, _patcherAPI.outFile!);
170+
} else {
171+
_app.patchedFilePath = _patcherAPI.outFile!.path;
172+
}
173+
final homeViewModel = locator<HomeViewModel>();
174+
_managerAPI
175+
.reAssessPatchedApps()
176+
.then((_) => homeViewModel.getPatchedApps());
167177
} else if (value == -100.0) {
168178
isPatching = false;
169179
hasErrors = true;
@@ -187,24 +197,14 @@ class InstallerViewModel extends BaseViewModel {
187197
notifyListeners();
188198
}
189199

190-
Future<void> runPatcher(BuildContext context) async {
200+
Future<void> runPatcher() async {
191201
try {
192202
await _patcherAPI.runPatcher(
193203
_app.packageName,
194204
_app.apkFilePath,
195205
_patches,
196206
_app.isFromStorage,
197207
);
198-
_app.appliedPatches = _patches.map((p) => p.name).toList();
199-
if (_managerAPI.isLastPatchedAppEnabled()) {
200-
await _managerAPI.setLastPatchedApp(_app, _patcherAPI.outFile!);
201-
} else {
202-
_app.patchedFilePath = _patcherAPI.outFile!.path;
203-
}
204-
final homeViewModel = locator<HomeViewModel>();
205-
_managerAPI
206-
.reAssessPatchedApps()
207-
.then((_) => homeViewModel.getPatchedApps());
208208
} on Exception catch (e) {
209209
update(
210210
-100.0,
@@ -506,7 +506,7 @@ class InstallerViewModel extends BaseViewModel {
506506
_app.isRooted = installAsRoot;
507507
if (headerLogs != 'Installing...') {
508508
update(
509-
.85,
509+
-1.0,
510510
'Installing...',
511511
_app.isRooted ? 'Mounting patched app' : 'Installing patched app',
512512
);
@@ -534,15 +534,15 @@ class InstallerViewModel extends BaseViewModel {
534534
update(1.0, 'Installed', 'Installed');
535535
} else if (response == 3) {
536536
update(
537-
.85,
537+
-1.0,
538538
'Installation canceled',
539539
'Installation canceled',
540540
);
541541
} else if (response == 10) {
542542
installResult(context, installAsRoot);
543543
} else {
544544
update(
545-
.85,
545+
-1.0,
546546
'Installation failed',
547547
'Installation failed',
548548
);

0 commit comments

Comments
 (0)