mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2025-05-18 23:16:50 +08:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
a6a7ff5040 | |||
1028ec8e2a | |||
f9242c1958 | |||
f9865166b0 | |||
f0f934f6a1 | |||
3d25655851 |
@ -74,7 +74,6 @@ class MainActivity : FlutterActivity() {
|
||||
result.notImplemented()
|
||||
}
|
||||
}
|
||||
|
||||
else -> result.notImplemented()
|
||||
}
|
||||
}
|
||||
@ -101,6 +100,8 @@ class MainActivity : FlutterActivity() {
|
||||
val integrations = File(integrationsPath)
|
||||
val keyStoreFile = File(keyStoreFilePath)
|
||||
|
||||
Thread {
|
||||
try {
|
||||
val patches = DexPatchBundle(
|
||||
patchBundleFilePath,
|
||||
DexClassLoader(
|
||||
@ -111,7 +112,6 @@ class MainActivity : FlutterActivity() {
|
||||
)
|
||||
).loadPatches().filter { patch -> selectedPatches.any { it == patch.patchName } }
|
||||
|
||||
Thread {
|
||||
handler.post {
|
||||
installerChannel.invokeMethod(
|
||||
"update",
|
||||
@ -176,6 +176,7 @@ class MainActivity : FlutterActivity() {
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
patcher.addPatches(patches)
|
||||
patcher.applyPatches().forEach { (patch, res) ->
|
||||
if (res.isSuccess) {
|
||||
@ -252,10 +253,21 @@ class MainActivity : FlutterActivity() {
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
handler.post { result.success(null) }
|
||||
} catch (ex: Throwable) {
|
||||
val stack = ex.stackTraceToString()
|
||||
handler.post {
|
||||
installerChannel.invokeMethod(
|
||||
"update",
|
||||
mapOf(
|
||||
"progress" to -100.0,
|
||||
"header" to "Aborting...",
|
||||
"log" to "An error occurred! Aborting\nError:\n$stack"
|
||||
)
|
||||
)
|
||||
}
|
||||
.start()
|
||||
}
|
||||
handler.post { result.success(null) }
|
||||
}.start()
|
||||
}
|
||||
|
||||
inner class ManagerLogger : Logger {
|
||||
|
@ -89,19 +89,25 @@ class PatcherAPI {
|
||||
|
||||
Future<bool> needsIntegrations(List<Patch> selectedPatches) async {
|
||||
return selectedPatches.any(
|
||||
(patch) => patch.dependencies.contains('integrations'),
|
||||
(patch) => patch.dependencies.any(
|
||||
(dep) => dep.contains('integrations'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> needsResourcePatching(List<Patch> selectedPatches) async {
|
||||
return selectedPatches.any(
|
||||
(patch) => patch.dependencies.any((dep) => dep.contains('resource-')),
|
||||
(patch) => patch.dependencies.any(
|
||||
(dep) => dep.contains('resource-'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> needsSettingsPatch(List<Patch> selectedPatches) async {
|
||||
return selectedPatches.any(
|
||||
(patch) => patch.dependencies.contains('settings'),
|
||||
(patch) => patch.dependencies.any(
|
||||
(dep) => dep.contains('settings'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,12 @@ class RootAPI {
|
||||
|
||||
Future<bool> hasRootPermissions() async {
|
||||
try {
|
||||
bool? isRooted = await Root.isRooted();
|
||||
bool? isRooted = await Root.isRootAvailable();
|
||||
if (isRooted != null && isRooted) {
|
||||
isRooted = await Root.isRooted();
|
||||
return isRooted != null && isRooted;
|
||||
}
|
||||
return false;
|
||||
} on Exception {
|
||||
return false;
|
||||
}
|
||||
|
@ -78,14 +78,20 @@ class InstallerViewModel extends BaseViewModel {
|
||||
}
|
||||
|
||||
void update(double value, String header, String log) {
|
||||
if (value > 0) {
|
||||
if (value >= 0.0) {
|
||||
progress = value;
|
||||
}
|
||||
isPatching = progress == 1.0 ? false : true;
|
||||
if (progress == 0.0) {
|
||||
if (value == 0.0) {
|
||||
logs = '';
|
||||
isPatching = true;
|
||||
isInstalled = false;
|
||||
hasErrors = false;
|
||||
} else if (value == 1.0) {
|
||||
isPatching = false;
|
||||
hasErrors = false;
|
||||
} else if (value == -100.0) {
|
||||
isPatching = false;
|
||||
hasErrors = true;
|
||||
}
|
||||
if (header.isNotEmpty) {
|
||||
headerLogs = header;
|
||||
@ -95,6 +101,9 @@ class InstallerViewModel extends BaseViewModel {
|
||||
logs += '\n';
|
||||
}
|
||||
logs += log;
|
||||
if (logs[logs.length - 1] == '\n') {
|
||||
logs = logs.substring(0, logs.length - 1);
|
||||
}
|
||||
Future.delayed(const Duration(milliseconds: 500)).then((value) {
|
||||
scrollController.animateTo(
|
||||
scrollController.position.maxScrollExtent,
|
||||
@ -117,12 +126,14 @@ class InstallerViewModel extends BaseViewModel {
|
||||
_patches,
|
||||
);
|
||||
} catch (e) {
|
||||
hasErrors = true;
|
||||
update(-1.0, 'Aborting...', 'An error occurred! Aborting\nError: $e');
|
||||
update(
|
||||
-100.0,
|
||||
'Aborting...',
|
||||
'An error occurred! Aborting\nError:\n$e',
|
||||
);
|
||||
}
|
||||
} else {
|
||||
hasErrors = true;
|
||||
update(-1.0, 'Aborting...', 'No app or patches selected! Aborting');
|
||||
update(-100.0, 'Aborting...', 'No app or patches selected! Aborting');
|
||||
}
|
||||
if (FlutterBackground.isBackgroundExecutionEnabled) {
|
||||
try {
|
||||
@ -132,7 +143,6 @@ class InstallerViewModel extends BaseViewModel {
|
||||
}
|
||||
}
|
||||
await Wakelock.disable();
|
||||
isPatching = false;
|
||||
}
|
||||
|
||||
void installResult(BuildContext context, bool installAsRoot) async {
|
||||
|
@ -104,14 +104,12 @@ class AppInfoView extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (app.isRooted)
|
||||
VerticalDivider(
|
||||
color: Theme.of(context).canvasColor,
|
||||
indent: 12.0,
|
||||
endIndent: 12.0,
|
||||
width: 1.0,
|
||||
),
|
||||
if (app.isRooted)
|
||||
Expanded(
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
|
@ -20,20 +20,26 @@ class AppInfoViewModel extends BaseViewModel {
|
||||
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
|
||||
final RootAPI _rootAPI = RootAPI();
|
||||
|
||||
Future<void> uninstallApp(PatchedApplication app, bool onlyUnpatch) async {
|
||||
Future<void> uninstallApp(
|
||||
BuildContext context,
|
||||
PatchedApplication app,
|
||||
bool onlyUnpatch,
|
||||
) async {
|
||||
bool isUninstalled = true;
|
||||
if (app.isRooted) {
|
||||
bool hasRootPermissions = await _rootAPI.hasRootPermissions();
|
||||
if (hasRootPermissions) {
|
||||
_rootAPI.deleteApp(app.packageName, app.apkFilePath);
|
||||
_managerAPI.deletePatchedApp(app);
|
||||
await _rootAPI.deleteApp(app.packageName, app.apkFilePath);
|
||||
if (!onlyUnpatch) {
|
||||
DeviceApps.uninstallApp(app.packageName);
|
||||
await DeviceApps.uninstallApp(app.packageName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DeviceApps.uninstallApp(app.packageName).then(
|
||||
(value) => _managerAPI.deletePatchedApp(app),
|
||||
);
|
||||
isUninstalled = await DeviceApps.uninstallApp(app.packageName);
|
||||
}
|
||||
if (isUninstalled) {
|
||||
await _managerAPI.deletePatchedApp(app);
|
||||
locator<HomeViewModel>().initialize(context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,8 +93,7 @@ class AppInfoViewModel extends BaseViewModel {
|
||||
CustomMaterialButton(
|
||||
label: I18nText('yesButton'),
|
||||
onPressed: () {
|
||||
uninstallApp(app, onlyUnpatch);
|
||||
locator<HomeViewModel>().initialize(context);
|
||||
uninstallApp(context, app, onlyUnpatch);
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
@ -97,8 +102,7 @@ class AppInfoViewModel extends BaseViewModel {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
uninstallApp(app, onlyUnpatch);
|
||||
locator<HomeViewModel>().initialize(context);
|
||||
uninstallApp(context, app, onlyUnpatch);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ homepage: https://github.com/revanced/revanced-manager
|
||||
|
||||
publish_to: 'none'
|
||||
|
||||
version: 0.0.17+17
|
||||
version: 0.0.19+19
|
||||
|
||||
environment:
|
||||
sdk: ">=2.17.5 <3.0.0"
|
||||
@ -54,7 +54,10 @@ dependencies:
|
||||
path_provider: ^2.0.11
|
||||
permission_handler: ^10.0.0
|
||||
pull_to_refresh: ^2.0.0
|
||||
root: ^2.0.2
|
||||
root:
|
||||
git:
|
||||
url: https://github.com/gokul1630/root
|
||||
ref: main
|
||||
share_extend: ^2.0.0
|
||||
shared_preferences: ^2.0.15
|
||||
skeletons: ^0.0.3
|
||||
|
Reference in New Issue
Block a user