diff --git a/lib/services/patcher_api.dart b/lib/services/patcher_api.dart index ecc3b218..9a094bec 100644 --- a/lib/services/patcher_api.dart +++ b/lib/services/patcher_api.dart @@ -28,7 +28,7 @@ class PatcherAPI { List _universalPatches = []; List _compatiblePackages = []; Map filteredPatches = >{}; - File? _outFile; + File? outFile; Future initialize() async { await _loadPatches(); @@ -162,7 +162,7 @@ class PatcherAPI { final Directory workDir = _tmpDir.createTempSync('tmp-'); final File inputFile = File('${workDir.path}/base.apk'); final File patchedFile = File('${workDir.path}/patched.apk'); - _outFile = File('${workDir.path}/out.apk'); + outFile = File('${workDir.path}/out.apk'); final Directory cacheDir = Directory('${workDir.path}/cache'); cacheDir.createSync(); final String originalFilePath = apkFilePath; @@ -174,7 +174,7 @@ class PatcherAPI { 'originalFilePath': originalFilePath, 'inputFilePath': inputFile.path, 'patchedFilePath': patchedFile.path, - 'outFilePath': _outFile!.path, + 'outFilePath': outFile!.path, 'integrationsPath': integrationsFile!.path, 'selectedPatches': selectedPatches.map((p) => p.name).toList(), 'cacheDirPath': cacheDir.path, @@ -201,7 +201,7 @@ class PatcherAPI { } Future installPatchedFile(PatchedApplication patchedApp) async { - if (_outFile != null) { + if (outFile != null) { try { if (patchedApp.isRooted) { final bool hasRootPermissions = await _rootAPI.hasRootPermissions(); @@ -209,11 +209,11 @@ class PatcherAPI { return _rootAPI.installApp( patchedApp.packageName, patchedApp.apkFilePath, - _outFile!.path, + outFile!.path, ); } } else { - final install = await InstallPlugin.installApk(_outFile!.path); + final install = await InstallPlugin.installApk(outFile!.path); return install['isSuccess']; } } on Exception catch (e) { @@ -228,11 +228,11 @@ class PatcherAPI { void exportPatchedFile(String appName, String version) { try { - if (_outFile != null) { + if (outFile != null) { final String newName = _getFileName(appName, version); CRFileSaver.saveFileWithDialog( SaveFileDialogParams( - sourceFilePath: _outFile!.path, + sourceFilePath: outFile!.path, destinationFileName: newName, ), ); @@ -246,12 +246,12 @@ class PatcherAPI { void sharePatchedFile(String appName, String version) { try { - if (_outFile != null) { + if (outFile != null) { final String newName = _getFileName(appName, version); - final int lastSeparator = _outFile!.path.lastIndexOf('/'); + final int lastSeparator = outFile!.path.lastIndexOf('/'); final String newPath = - _outFile!.path.substring(0, lastSeparator + 1) + newName; - final File shareFile = _outFile!.copySync(newPath); + outFile!.path.substring(0, lastSeparator + 1) + newName; + final File shareFile = outFile!.copySync(newPath); ShareExtend.share(shareFile.path, 'file'); } } on Exception catch (e) { diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 52318967..426b0669 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -285,7 +285,7 @@ class InstallerViewModel extends BaseViewModel { // In case a patch changed the app name or package name, // update the app info. - final app = await DeviceApps.getAppFromStorage(_app.apkFilePath); + final app = await DeviceApps.getAppFromStorage(_patcherAPI.outFile!.path); if (app != null) { _app.name = app.appName; _app.packageName = app.packageName;