mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-05-03 15:24:25 +02:00
fix: root installation (still wip)
This commit is contained in:
parent
034731a35f
commit
8fd942a808
@ -69,7 +69,7 @@
|
|||||||
},
|
},
|
||||||
"rootCheckerView": {
|
"rootCheckerView": {
|
||||||
"widgetTitle": "Is your device rooted?",
|
"widgetTitle": "Is your device rooted?",
|
||||||
"widgetDescription": "Don't know what's this or prefer to use non-root version? Just click button below!",
|
"widgetDescription": "Don't know what this means or prefer to use non-root version? Just click on the button below!",
|
||||||
"grantPermission": "Grant Root Permission",
|
"grantPermission": "Grant Root Permission",
|
||||||
"grantedPermission": "Magisk permission granted: {isRooted}"
|
"grantedPermission": "Magisk permission granted: {isRooted}"
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,9 @@ class RootAPI {
|
|||||||
String patchedFilePath,
|
String patchedFilePath,
|
||||||
) async {
|
) async {
|
||||||
try {
|
try {
|
||||||
Directory managerDir = Directory(managerDirPath);
|
await Root.exec(
|
||||||
managerDir.createSync();
|
cmd: 'mkdir "$managerDirPath"',
|
||||||
|
);
|
||||||
String newPatchedFilePath = '$managerDirPath/$packageName.apk';
|
String newPatchedFilePath = '$managerDirPath/$packageName.apk';
|
||||||
installServiceDScript(
|
installServiceDScript(
|
||||||
packageName,
|
packageName,
|
||||||
@ -39,15 +40,17 @@ class RootAPI {
|
|||||||
originalFilePath,
|
originalFilePath,
|
||||||
newPatchedFilePath,
|
newPatchedFilePath,
|
||||||
);
|
);
|
||||||
File(patchedFilePath).renameSync(newPatchedFilePath);
|
|
||||||
await Root.exec(
|
await Root.exec(
|
||||||
cmd: 'chmod 644 $newPatchedFilePath',
|
cmd: 'cp $patchedFilePath $newPatchedFilePath',
|
||||||
);
|
);
|
||||||
await Root.exec(
|
await Root.exec(
|
||||||
cmd: 'chown system:system $newPatchedFilePath',
|
cmd: 'chmod 644 "$newPatchedFilePath"',
|
||||||
);
|
);
|
||||||
await Root.exec(
|
await Root.exec(
|
||||||
cmd: 'chcon u:object_r:apk_data_file:s0 $newPatchedFilePath',
|
cmd: 'chown system:system "$newPatchedFilePath"',
|
||||||
|
);
|
||||||
|
await Root.exec(
|
||||||
|
cmd: 'chcon u:object_r:apk_data_file:s0 "$newPatchedFilePath"',
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
} on Exception {
|
} on Exception {
|
||||||
@ -65,9 +68,11 @@ class RootAPI {
|
|||||||
'sleep 1\n'
|
'sleep 1\n'
|
||||||
'chcon u:object_r:apk_data_file:s0 $patchedFilePath\n'
|
'chcon u:object_r:apk_data_file:s0 $patchedFilePath\n'
|
||||||
'mount -o bind $patchedFilePath $originalFilePath';
|
'mount -o bind $patchedFilePath $originalFilePath';
|
||||||
File scriptFile = File('$serviceDDirPath/$packageName.sh');
|
String scriptFilePath = '$serviceDDirPath/$packageName.sh';
|
||||||
await scriptFile.writeAsString(content);
|
await Root.exec(
|
||||||
await Root.exec(cmd: 'chmod 744 ${scriptFile.path}');
|
cmd: 'echo "$content" > "$scriptFilePath"',
|
||||||
|
);
|
||||||
|
await Root.exec(cmd: 'chmod 744 "$scriptFilePath"');
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> installPostFsDataScript(
|
Future<void> installPostFsDataScript(
|
||||||
@ -78,8 +83,10 @@ class RootAPI {
|
|||||||
String content = '#!/system/bin/sh\n'
|
String content = '#!/system/bin/sh\n'
|
||||||
'while read line; do echo \$line | grep $originalFilePath | '
|
'while read line; do echo \$line | grep $originalFilePath | '
|
||||||
'awk \'{print \$2}\' | xargs umount -l; done< /proc/mounts';
|
'awk \'{print \$2}\' | xargs umount -l; done< /proc/mounts';
|
||||||
File scriptFile = File('$postFsDataDirPath/$packageName.sh');
|
String scriptFilePath = '$postFsDataDirPath/$packageName.sh';
|
||||||
await scriptFile.writeAsString(content);
|
await Root.exec(
|
||||||
await Root.exec(cmd: 'chmod 744 ${scriptFile.path}');
|
cmd: 'echo "$content" > "$scriptFilePath"',
|
||||||
|
);
|
||||||
|
await Root.exec(cmd: 'chmod 744 $scriptFilePath');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,16 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
PatchedApplication? selectedApp =
|
PatchedApplication? selectedApp =
|
||||||
locator<AppSelectorViewModel>().selectedApp;
|
locator<AppSelectorViewModel>().selectedApp;
|
||||||
if (selectedApp != null) {
|
if (selectedApp != null) {
|
||||||
|
addLog(selectedApp.isRooted
|
||||||
|
? 'Installing patched file using root method...'
|
||||||
|
: 'Installing patched file using nonroot method...');
|
||||||
|
bool isSucess =
|
||||||
await locator<PatcherAPI>().installPatchedFile(selectedApp);
|
await locator<PatcherAPI>().installPatchedFile(selectedApp);
|
||||||
|
if (isSucess) {
|
||||||
|
addLog('Done');
|
||||||
|
} else {
|
||||||
|
addLog('An error occurred! Aborting...');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user