Revert "manager: Optimized import, optimized all libsu shell calls, and fixed WebUI memory leaks #369

This reverts commit c3533861f2.
This commit is contained in:
ShirkNeko
2025-09-13 20:18:30 +08:00
parent 0c578e4518
commit cead5b03f4
9 changed files with 253 additions and 166 deletions

View File

@@ -1,13 +1,15 @@
package io.sukisu.ultra;
import com.topjohnwu.superuser.Shell;
import java.util.ArrayList;
import com.sukisu.ultra.ui.util.KsuCli;
public class UltraShellHelper {
public static String runCmd(String cmds) {
StringBuilder sb = new StringBuilder();
for(String str : Shell.cmd(cmds)
for(String str : KsuCli.INSTANCE.getGLOBAL_MNT_SHELL()
.newJob()
.add(cmds)
.to(new ArrayList<>(), null)
.exec()
.getOut()) {
@@ -16,6 +18,11 @@ public class UltraShellHelper {
return sb.toString();
}
public static boolean isPathExists(String path) {
String result = runCmd("test -f '" + path + "' && echo 'exists'");
return result.contains("exists");
}
public static void CopyFileTo(String path, String target) {
runCmd("cp -f '" + path + "' '" + target + "' 2>&1");
}

View File

@@ -1,7 +1,5 @@
package io.sukisu.ultra;
import com.topjohnwu.superuser.io.SuFile;
import static com.sukisu.ultra.ui.util.KsuCliKt.getKpmmgrPath;
import static com.sukisu.ultra.ui.util.KsuCliKt.getSuSFSDaemonPath;
@@ -13,17 +11,15 @@ public class UltraToolInstall {
@SuppressLint("SetWorldReadable")
@SuppressWarnings("ResultOfMethodCallIgnored")
public static void tryToInstall() {
SuFile KpmmgrFile = new SuFile(OUTSIDE_KPMMGR_PATH);
if (KpmmgrFile.exists()) {
UltraShellHelper.CopyFileTo(getKpmmgrPath(), OUTSIDE_KPMMGR_PATH);
KpmmgrFile.setReadable(true, false);
KpmmgrFile.setExecutable(true, false);
String kpmmgrPath = getKpmmgrPath();
if (UltraShellHelper.isPathExists(OUTSIDE_KPMMGR_PATH)) {
UltraShellHelper.CopyFileTo(kpmmgrPath, OUTSIDE_KPMMGR_PATH);
UltraShellHelper.runCmd("chmod a+rx " + OUTSIDE_KPMMGR_PATH);
}
SuFile SuSFSDaemonFile = new SuFile(OUTSIDE_SUSFSD_PATH);
if (SuSFSDaemonFile.exists()) {
UltraShellHelper.CopyFileTo(getSuSFSDaemonPath(), OUTSIDE_SUSFSD_PATH);
SuSFSDaemonFile.setReadable(true, false);
SuSFSDaemonFile.setExecutable(true, false);
String SuSFSDaemonPath = getSuSFSDaemonPath();
if (UltraShellHelper.isPathExists(OUTSIDE_SUSFSD_PATH)) {
UltraShellHelper.CopyFileTo(SuSFSDaemonPath, OUTSIDE_SUSFSD_PATH);
UltraShellHelper.runCmd("chmod a+rx " + OUTSIDE_SUSFSD_PATH);
}
}
}