2022-09-23 16:47:30 +02:00
|
|
|
// ignore_for_file: use_build_context_synchronously
|
2022-08-15 04:31:36 +02:00
|
|
|
import 'package:device_apps/device_apps.dart';
|
2023-03-05 10:12:46 +01:00
|
|
|
import 'package:flutter/foundation.dart';
|
2022-09-07 14:04:16 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-08-18 16:33:33 +02:00
|
|
|
import 'package:flutter/services.dart';
|
2022-08-15 04:31:36 +02:00
|
|
|
import 'package:flutter_background/flutter_background.dart';
|
2022-08-18 16:33:33 +02:00
|
|
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
2022-09-18 23:13:29 +02:00
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
2022-08-13 11:56:30 +02:00
|
|
|
import 'package:revanced_manager/app/app.locator.dart';
|
|
|
|
import 'package:revanced_manager/models/patch.dart';
|
2022-08-14 20:40:34 +02:00
|
|
|
import 'package:revanced_manager/models/patched_application.dart';
|
2022-08-25 01:51:47 +02:00
|
|
|
import 'package:revanced_manager/services/manager_api.dart';
|
2022-08-13 11:56:30 +02:00
|
|
|
import 'package:revanced_manager/services/patcher_api.dart';
|
2022-09-23 16:47:30 +02:00
|
|
|
import 'package:revanced_manager/services/root_api.dart';
|
2022-09-20 01:49:31 +02:00
|
|
|
import 'package:revanced_manager/services/toast.dart';
|
2022-08-14 04:07:28 +02:00
|
|
|
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
2022-09-23 09:30:30 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
2023-10-05 18:16:20 +02:00
|
|
|
import 'package:revanced_manager/utils/about_info.dart';
|
|
|
|
import 'package:screenshot_callback/screenshot_callback.dart';
|
2022-08-13 11:56:30 +02:00
|
|
|
import 'package:stacked/stacked.dart';
|
2023-10-28 16:19:07 +02:00
|
|
|
import 'package:wakelock_plus/wakelock_plus.dart';
|
2022-08-13 11:56:30 +02:00
|
|
|
|
|
|
|
class InstallerViewModel extends BaseViewModel {
|
2022-08-25 01:51:47 +02:00
|
|
|
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
2022-08-18 16:33:33 +02:00
|
|
|
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
|
2022-09-23 16:47:30 +02:00
|
|
|
final RootAPI _rootAPI = RootAPI();
|
2022-09-20 01:49:31 +02:00
|
|
|
final Toast _toast = locator<Toast>();
|
2022-09-06 15:40:49 +02:00
|
|
|
final PatchedApplication _app = locator<PatcherViewModel>().selectedApp!;
|
2022-08-18 16:33:33 +02:00
|
|
|
final List<Patch> _patches = locator<PatcherViewModel>().selectedPatches;
|
|
|
|
static const _installerChannel = MethodChannel(
|
2022-09-12 14:53:34 +02:00
|
|
|
'app.revanced.manager.flutter/installer',
|
2022-08-18 16:33:33 +02:00
|
|
|
);
|
2022-08-25 01:51:47 +02:00
|
|
|
final ScrollController scrollController = ScrollController();
|
2023-10-05 18:16:20 +02:00
|
|
|
final ScreenshotCallback screenshotCallback = ScreenshotCallback();
|
2022-08-17 13:48:03 +02:00
|
|
|
double? progress = 0.0;
|
2022-08-13 11:56:30 +02:00
|
|
|
String logs = '';
|
2022-08-23 20:13:06 +02:00
|
|
|
String headerLogs = '';
|
2022-09-23 16:47:30 +02:00
|
|
|
bool isRooted = false;
|
2022-08-24 15:17:16 +02:00
|
|
|
bool isPatching = true;
|
2022-08-15 04:31:36 +02:00
|
|
|
bool isInstalled = false;
|
2022-09-12 15:20:25 +02:00
|
|
|
bool hasErrors = false;
|
2023-08-03 23:40:08 +02:00
|
|
|
bool isCanceled = false;
|
|
|
|
bool cancel = false;
|
2023-10-05 18:16:20 +02:00
|
|
|
bool showPopupScreenshotWarning = true;
|
2022-08-13 11:56:30 +02:00
|
|
|
|
2022-08-18 16:33:33 +02:00
|
|
|
Future<void> initialize(BuildContext context) async {
|
2022-09-23 16:47:30 +02:00
|
|
|
isRooted = await _rootAPI.isRooted();
|
2022-09-18 23:13:29 +02:00
|
|
|
if (await Permission.ignoreBatteryOptimizations.isGranted) {
|
2022-09-17 15:55:00 +02:00
|
|
|
try {
|
2022-09-19 02:46:12 +02:00
|
|
|
FlutterBackground.initialize(
|
2022-09-17 15:55:00 +02:00
|
|
|
androidConfig: FlutterBackgroundAndroidConfig(
|
|
|
|
notificationTitle: FlutterI18n.translate(
|
|
|
|
context,
|
|
|
|
'installerView.notificationTitle',
|
|
|
|
),
|
|
|
|
notificationText: FlutterI18n.translate(
|
|
|
|
context,
|
|
|
|
'installerView.notificationText',
|
|
|
|
),
|
|
|
|
notificationIcon: const AndroidResource(
|
|
|
|
name: 'ic_notification',
|
|
|
|
),
|
2022-08-17 14:48:56 +02:00
|
|
|
),
|
2022-09-19 02:46:12 +02:00
|
|
|
).then((value) => FlutterBackground.enableBackgroundExecution());
|
2023-03-05 10:12:46 +01:00
|
|
|
} on Exception catch (e) {
|
|
|
|
if (kDebugMode) {
|
|
|
|
print(e);
|
|
|
|
} // ignore
|
2022-09-17 15:55:00 +02:00
|
|
|
}
|
2022-08-17 14:48:56 +02:00
|
|
|
}
|
2023-10-05 18:16:20 +02:00
|
|
|
screenshotCallback.addListener(() {
|
|
|
|
if (showPopupScreenshotWarning) {
|
|
|
|
showPopupScreenshotWarning = false;
|
|
|
|
screenshotDetected(context);
|
|
|
|
}
|
|
|
|
});
|
2023-10-28 16:19:07 +02:00
|
|
|
await WakelockPlus.enable();
|
2022-09-11 03:01:06 +02:00
|
|
|
await handlePlatformChannelMethods();
|
|
|
|
await runPatcher();
|
2022-08-13 11:56:30 +02:00
|
|
|
}
|
|
|
|
|
2022-08-18 16:33:33 +02:00
|
|
|
Future<dynamic> handlePlatformChannelMethods() async {
|
|
|
|
_installerChannel.setMethodCallHandler((call) async {
|
|
|
|
switch (call.method) {
|
2022-08-24 15:17:16 +02:00
|
|
|
case 'update':
|
2022-08-18 16:33:33 +02:00
|
|
|
if (call.arguments != null) {
|
2023-01-30 13:35:06 +01:00
|
|
|
final Map<dynamic, dynamic> arguments = call.arguments;
|
|
|
|
final double progress = arguments['progress'];
|
|
|
|
final String header = arguments['header'];
|
|
|
|
final String log = arguments['log'];
|
2022-08-24 15:17:16 +02:00
|
|
|
update(progress, header, log);
|
2022-08-18 16:33:33 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-08-07 17:28:09 +02:00
|
|
|
Future<void> update(double value, String header, String log) async {
|
2022-09-23 01:38:42 +02:00
|
|
|
if (value >= 0.0) {
|
2022-09-05 14:48:56 +02:00
|
|
|
progress = value;
|
|
|
|
}
|
2022-09-23 01:38:42 +02:00
|
|
|
if (value == 0.0) {
|
2022-08-13 11:56:30 +02:00
|
|
|
logs = '';
|
2022-09-23 01:38:42 +02:00
|
|
|
isPatching = true;
|
2022-08-29 16:01:51 +02:00
|
|
|
isInstalled = false;
|
2022-09-12 15:20:25 +02:00
|
|
|
hasErrors = false;
|
2022-09-23 01:38:42 +02:00
|
|
|
} else if (value == 1.0) {
|
|
|
|
isPatching = false;
|
|
|
|
hasErrors = false;
|
2023-08-07 17:28:09 +02:00
|
|
|
await _managerAPI.savePatches(
|
|
|
|
_patcherAPI.getFilteredPatches(_app.packageName),
|
|
|
|
_app.packageName,
|
|
|
|
);
|
2023-08-09 21:32:13 +02:00
|
|
|
await _managerAPI.setUsedPatches(_patches, _app.packageName);
|
2022-09-23 01:38:42 +02:00
|
|
|
} else if (value == -100.0) {
|
|
|
|
isPatching = false;
|
|
|
|
hasErrors = true;
|
2022-08-13 11:56:30 +02:00
|
|
|
}
|
2022-08-24 15:17:16 +02:00
|
|
|
if (header.isNotEmpty) {
|
|
|
|
headerLogs = header;
|
|
|
|
}
|
|
|
|
if (log.isNotEmpty && !log.startsWith('Merging L')) {
|
2022-08-17 13:48:03 +02:00
|
|
|
if (logs.isNotEmpty) {
|
|
|
|
logs += '\n';
|
|
|
|
}
|
2022-08-24 15:17:16 +02:00
|
|
|
logs += log;
|
2022-09-23 01:38:42 +02:00
|
|
|
if (logs[logs.length - 1] == '\n') {
|
|
|
|
logs = logs.substring(0, logs.length - 1);
|
|
|
|
}
|
2022-08-22 01:49:09 +02:00
|
|
|
Future.delayed(const Duration(milliseconds: 500)).then((value) {
|
|
|
|
scrollController.animateTo(
|
|
|
|
scrollController.position.maxScrollExtent,
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
curve: Curves.fastOutSlowIn,
|
|
|
|
);
|
|
|
|
});
|
2022-08-17 13:48:03 +02:00
|
|
|
}
|
2022-08-24 15:17:16 +02:00
|
|
|
notifyListeners();
|
2022-08-17 13:48:03 +02:00
|
|
|
}
|
|
|
|
|
2022-08-13 11:56:30 +02:00
|
|
|
Future<void> runPatcher() async {
|
2022-10-14 20:05:33 +02:00
|
|
|
try {
|
2023-10-04 18:45:13 +02:00
|
|
|
await _patcherAPI.runPatcher(
|
|
|
|
_app.packageName,
|
|
|
|
_app.apkFilePath,
|
|
|
|
_patches,
|
|
|
|
);
|
|
|
|
} on Exception catch (e) {
|
|
|
|
update(
|
|
|
|
-100.0,
|
|
|
|
'Failed...',
|
|
|
|
'Something went wrong:\n$e',
|
|
|
|
);
|
|
|
|
if (kDebugMode) {
|
|
|
|
print(e);
|
2022-08-13 11:56:30 +02:00
|
|
|
}
|
2023-10-04 18:45:13 +02:00
|
|
|
}
|
|
|
|
|
2023-10-12 02:00:39 +02:00
|
|
|
// Necessary to reset the state of patches so that they
|
|
|
|
// can be reloaded again.
|
2023-10-21 12:46:51 +02:00
|
|
|
_managerAPI.patches.clear();
|
2023-10-04 21:16:56 +02:00
|
|
|
await _patcherAPI.loadPatches();
|
2023-10-04 19:36:58 +02:00
|
|
|
|
2023-10-04 18:45:13 +02:00
|
|
|
try {
|
2022-10-14 20:05:33 +02:00
|
|
|
if (FlutterBackground.isBackgroundExecutionEnabled) {
|
|
|
|
try {
|
|
|
|
FlutterBackground.disableBackgroundExecution();
|
2023-03-05 10:12:46 +01:00
|
|
|
} on Exception catch (e) {
|
|
|
|
if (kDebugMode) {
|
|
|
|
print(e);
|
|
|
|
} // ignore
|
2022-10-14 20:05:33 +02:00
|
|
|
}
|
2022-09-17 15:55:00 +02:00
|
|
|
}
|
2023-10-28 16:19:07 +02:00
|
|
|
await WakelockPlus.disable();
|
2023-03-05 10:12:46 +01:00
|
|
|
} on Exception catch (e) {
|
|
|
|
if (kDebugMode) {
|
|
|
|
print(e);
|
|
|
|
}
|
2022-08-17 14:48:56 +02:00
|
|
|
}
|
2022-08-13 11:56:30 +02:00
|
|
|
}
|
|
|
|
|
2023-10-05 18:16:20 +02:00
|
|
|
Future<void> copyLogs() async {
|
|
|
|
final info = await AboutInfo.getInfo();
|
|
|
|
|
|
|
|
final formattedLogs = [
|
2023-10-17 08:19:18 +02:00
|
|
|
'- Device Info',
|
2023-10-05 18:16:20 +02:00
|
|
|
'ReVanced Manager: ${info['version']}',
|
|
|
|
'Build: ${info['flavor']}',
|
|
|
|
'Model: ${info['model']}',
|
|
|
|
'Android version: ${info['androidVersion']}',
|
|
|
|
'Supported architectures: ${info['supportedArch'].join(", ")}',
|
2023-10-21 12:46:51 +02:00
|
|
|
'Root permissions: ${isRooted ? 'Yes' : 'No'}',
|
|
|
|
|
2023-10-17 08:19:18 +02:00
|
|
|
'\n- Patch Info',
|
2023-10-05 18:16:20 +02:00
|
|
|
'App: ${_app.packageName} v${_app.version}',
|
|
|
|
'Patches version: ${_managerAPI.patchesVersion}',
|
2023-10-17 08:21:59 +02:00
|
|
|
'Patches: ${_patches.map((p) => p.name + (p.options.isEmpty ? '' : ' [${p.options.map((o) => '${o.title}: ${o.value}').join(", ")}]')).toList().join(", ")}',
|
2023-10-21 12:46:51 +02:00
|
|
|
|
2023-10-17 08:19:18 +02:00
|
|
|
'\n- Settings',
|
2023-10-15 11:56:02 +02:00
|
|
|
'Allow changing patch selection: ${_managerAPI.isPatchesChangeEnabled()}',
|
|
|
|
'Version compatibility check: ${_managerAPI.isVersionCompatibilityCheckEnabled()}',
|
2023-10-17 08:19:18 +02:00
|
|
|
'Show universal patches: ${_managerAPI.areUniversalPatchesEnabled()}',
|
2023-10-05 18:16:20 +02:00
|
|
|
'Patches source: ${_managerAPI.getPatchesRepo()}',
|
|
|
|
'Integration source: ${_managerAPI.getIntegrationsRepo()}',
|
2023-10-21 12:46:51 +02:00
|
|
|
|
2023-10-17 08:19:18 +02:00
|
|
|
'\n- Logs',
|
2023-10-05 18:16:20 +02:00
|
|
|
logs,
|
|
|
|
];
|
|
|
|
|
|
|
|
Clipboard.setData(ClipboardData(text: formattedLogs.join('\n')));
|
|
|
|
_toast.showBottom('installerView.copiedToClipboard');
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> screenshotDetected(BuildContext context) async {
|
|
|
|
await showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => AlertDialog(
|
|
|
|
title: I18nText(
|
|
|
|
'warning',
|
|
|
|
),
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
|
|
|
icon: const Icon(Icons.warning),
|
|
|
|
content: SingleChildScrollView(
|
|
|
|
child: I18nText('installerView.screenshotDetected'),
|
|
|
|
),
|
|
|
|
actions: <Widget>[
|
|
|
|
CustomMaterialButton(
|
|
|
|
isFilled: false,
|
|
|
|
label: I18nText('noButton'),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
CustomMaterialButton(
|
|
|
|
label: I18nText('yesButton'),
|
|
|
|
onPressed: () {
|
|
|
|
copyLogs();
|
|
|
|
showPopupScreenshotWarning = true;
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-08-10 14:02:30 +02:00
|
|
|
Future<void> installTypeDialog(BuildContext context) async {
|
|
|
|
final ValueNotifier<int> installType = ValueNotifier(0);
|
|
|
|
if (isRooted) {
|
|
|
|
await showDialog(
|
|
|
|
context: context,
|
|
|
|
barrierDismissible: false,
|
|
|
|
builder: (context) => AlertDialog(
|
|
|
|
title: I18nText(
|
|
|
|
'installerView.installType',
|
|
|
|
),
|
2023-08-12 10:07:04 +02:00
|
|
|
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
2023-08-10 14:02:30 +02:00
|
|
|
icon: const Icon(Icons.file_download_outlined),
|
|
|
|
contentPadding: const EdgeInsets.symmetric(vertical: 16),
|
2023-09-21 01:57:13 +02:00
|
|
|
content: SingleChildScrollView(
|
|
|
|
child: ValueListenableBuilder(
|
|
|
|
valueListenable: installType,
|
|
|
|
builder: (context, value, child) {
|
|
|
|
return Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 20,
|
|
|
|
vertical: 10,
|
|
|
|
),
|
|
|
|
child: I18nText(
|
|
|
|
'installerView.installTypeDescription',
|
|
|
|
child: Text(
|
|
|
|
'',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: Theme.of(context).colorScheme.secondary,
|
|
|
|
),
|
2023-08-10 14:02:30 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2023-09-21 01:57:13 +02:00
|
|
|
RadioListTile(
|
|
|
|
title: I18nText('installerView.installNonRootType'),
|
2023-10-04 18:45:13 +02:00
|
|
|
contentPadding:
|
|
|
|
const EdgeInsets.symmetric(horizontal: 16),
|
2023-09-21 01:57:13 +02:00
|
|
|
value: 0,
|
|
|
|
groupValue: value,
|
|
|
|
onChanged: (selected) {
|
|
|
|
installType.value = selected!;
|
|
|
|
},
|
|
|
|
),
|
|
|
|
RadioListTile(
|
|
|
|
title: I18nText('installerView.installRootType'),
|
2023-10-04 18:45:13 +02:00
|
|
|
contentPadding:
|
|
|
|
const EdgeInsets.symmetric(horizontal: 16),
|
2023-09-21 01:57:13 +02:00
|
|
|
value: 1,
|
|
|
|
groupValue: value,
|
|
|
|
onChanged: (selected) {
|
|
|
|
installType.value = selected!;
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2023-08-10 14:02:30 +02:00
|
|
|
),
|
|
|
|
actions: [
|
|
|
|
CustomMaterialButton(
|
|
|
|
label: I18nText('cancelButton'),
|
|
|
|
isFilled: false,
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
CustomMaterialButton(
|
|
|
|
label: I18nText('installerView.installButton'),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
installResult(context, installType.value == 1);
|
|
|
|
},
|
2023-08-12 09:33:15 +02:00
|
|
|
),
|
2023-08-10 14:02:30 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
installResult(context, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-03 23:40:08 +02:00
|
|
|
Future<void> stopPatcher() async {
|
|
|
|
try {
|
|
|
|
isCanceled = true;
|
2023-10-04 18:45:13 +02:00
|
|
|
update(0.5, 'Canceling...', 'Canceling patching process');
|
2023-08-03 23:40:08 +02:00
|
|
|
await _patcherAPI.stopPatcher();
|
2023-10-04 18:45:13 +02:00
|
|
|
update(-100.0, 'Canceled...', 'Press back to exit');
|
2023-08-03 23:40:08 +02:00
|
|
|
} on Exception catch (e) {
|
|
|
|
if (kDebugMode) {
|
|
|
|
print(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-30 13:35:06 +01:00
|
|
|
Future<void> installResult(BuildContext context, bool installAsRoot) async {
|
2022-10-14 20:05:33 +02:00
|
|
|
try {
|
|
|
|
_app.isRooted = installAsRoot;
|
2023-10-04 18:45:13 +02:00
|
|
|
update(
|
|
|
|
1.0,
|
|
|
|
'Installing...',
|
|
|
|
_app.isRooted
|
|
|
|
? 'Installing patched file using root method'
|
|
|
|
: 'Installing patched file using nonroot method',
|
|
|
|
);
|
|
|
|
isInstalled = await _patcherAPI.installPatchedFile(_app);
|
|
|
|
if (isInstalled) {
|
|
|
|
_app.isFromStorage = false;
|
|
|
|
_app.patchDate = DateTime.now();
|
|
|
|
_app.appliedPatches = _patches.map((p) => p.name).toList();
|
2023-09-29 20:12:39 +02:00
|
|
|
|
2023-10-04 18:45:13 +02:00
|
|
|
// In case a patch changed the app name or package name,
|
|
|
|
// update the app info.
|
|
|
|
final app =
|
|
|
|
await DeviceApps.getAppFromStorage(_patcherAPI.outFile!.path);
|
|
|
|
if (app != null) {
|
|
|
|
_app.name = app.appName;
|
|
|
|
_app.packageName = app.packageName;
|
|
|
|
}
|
2023-09-29 20:12:39 +02:00
|
|
|
|
2023-10-04 18:45:13 +02:00
|
|
|
await _managerAPI.savePatchedApp(_app);
|
2023-09-30 21:13:32 +02:00
|
|
|
|
2023-10-04 18:45:13 +02:00
|
|
|
update(1.0, 'Installed!', 'Installed!');
|
|
|
|
} else {
|
|
|
|
// TODO(aabed): Show error message.
|
|
|
|
}
|
2023-03-05 10:12:46 +01:00
|
|
|
} on Exception catch (e) {
|
|
|
|
if (kDebugMode) {
|
|
|
|
print(e);
|
|
|
|
}
|
2022-08-14 20:40:34 +02:00
|
|
|
}
|
2022-08-13 11:56:30 +02:00
|
|
|
}
|
|
|
|
|
2022-11-02 12:52:40 +01:00
|
|
|
void exportResult() {
|
|
|
|
try {
|
|
|
|
_patcherAPI.exportPatchedFile(_app.name, _app.version);
|
2023-03-05 10:12:46 +01:00
|
|
|
} on Exception catch (e) {
|
|
|
|
if (kDebugMode) {
|
|
|
|
print(e);
|
|
|
|
}
|
2022-11-02 12:52:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-22 02:31:27 +02:00
|
|
|
Future<void> cleanPatcher() async {
|
2022-10-14 20:05:33 +02:00
|
|
|
try {
|
|
|
|
_patcherAPI.cleanPatcher();
|
|
|
|
locator<PatcherViewModel>().selectedApp = null;
|
|
|
|
locator<PatcherViewModel>().selectedPatches.clear();
|
|
|
|
locator<PatcherViewModel>().notifyListeners();
|
2023-03-05 10:12:46 +01:00
|
|
|
} on Exception catch (e) {
|
|
|
|
if (kDebugMode) {
|
|
|
|
print(e);
|
|
|
|
}
|
2022-10-14 20:05:33 +02:00
|
|
|
}
|
2022-08-14 04:07:28 +02:00
|
|
|
}
|
2022-08-15 04:31:36 +02:00
|
|
|
|
|
|
|
void openApp() {
|
2022-09-06 15:40:49 +02:00
|
|
|
DeviceApps.openApp(_app.packageName);
|
|
|
|
}
|
|
|
|
|
2023-08-10 14:02:30 +02:00
|
|
|
void onButtonPressed(int value) {
|
2022-09-06 15:40:49 +02:00
|
|
|
switch (value) {
|
|
|
|
case 0:
|
2022-11-02 12:52:40 +01:00
|
|
|
exportResult();
|
|
|
|
break;
|
2023-08-10 14:02:30 +02:00
|
|
|
case 1:
|
2023-10-05 18:16:20 +02:00
|
|
|
copyLogs();
|
2022-09-06 15:40:49 +02:00
|
|
|
break;
|
2022-08-15 04:31:36 +02:00
|
|
|
}
|
|
|
|
}
|
2022-09-19 18:40:06 +02:00
|
|
|
|
|
|
|
Future<bool> onWillPop(BuildContext context) async {
|
|
|
|
if (isPatching) {
|
2023-08-03 23:40:08 +02:00
|
|
|
if (!cancel) {
|
|
|
|
cancel = true;
|
|
|
|
_toast.showBottom('installerView.pressBackAgain');
|
|
|
|
} else if (!isCanceled) {
|
|
|
|
await stopPatcher();
|
|
|
|
} else {
|
|
|
|
_toast.showBottom('installerView.noExit');
|
|
|
|
}
|
2022-09-19 18:40:06 +02:00
|
|
|
return false;
|
|
|
|
}
|
2023-08-03 23:40:08 +02:00
|
|
|
if (!cancel) {
|
|
|
|
cleanPatcher();
|
|
|
|
} else {
|
|
|
|
_patcherAPI.cleanPatcher();
|
|
|
|
}
|
2023-10-05 18:16:20 +02:00
|
|
|
screenshotCallback.dispose();
|
2022-09-19 18:40:06 +02:00
|
|
|
Navigator.of(context).pop();
|
|
|
|
return true;
|
|
|
|
}
|
2022-08-13 11:56:30 +02:00
|
|
|
}
|