添加安装工具类,并增加把kpmmgr安装到/data/adb/ksu/bin的功能,方便模块调用
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
package io.sukisu.ultra;
|
||||||
|
|
||||||
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import shirkneko.zako.sukisu.ui.util.KsuCli;
|
||||||
|
|
||||||
|
public class UltraShellHelper {
|
||||||
|
public static String runCmd(String cmds) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for(String str : KsuCli.INSTANCE.getGLOBAL_MNT_SHELL()
|
||||||
|
.newJob()
|
||||||
|
.add(cmds)
|
||||||
|
.to(new ArrayList<>(), null)
|
||||||
|
.exec()
|
||||||
|
.getOut()) {
|
||||||
|
sb.append(str).append("\n");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isPathExists(String path) {
|
||||||
|
return !runCmd("file " + path).contains("No such file or directory");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CopyFileTo(String path, String target) {
|
||||||
|
runCmd("cp -f " + path + " " + target);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package io.sukisu.ultra;
|
||||||
|
|
||||||
|
import static shirkneko.zako.sukisu.ui.util.KsuCliKt.getKpmmgrPath;
|
||||||
|
import shirkneko.zako.sukisu.ui.util.KsuCli;
|
||||||
|
|
||||||
|
public class UltraToolInstall {
|
||||||
|
private static final String OUTSIDE_KPMMGR_PATH = "/data/adb/ksu/bin/kpmmgr";
|
||||||
|
public static void tryToInstall() {
|
||||||
|
String kpmmgrPath = getKpmmgrPath();
|
||||||
|
if (!UltraShellHelper.isPathExists(OUTSIDE_KPMMGR_PATH)) {
|
||||||
|
UltraShellHelper.CopyFileTo(kpmmgrPath, OUTSIDE_KPMMGR_PATH);
|
||||||
|
UltraShellHelper.runCmd("chmod a+rx " + OUTSIDE_KPMMGR_PATH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -41,6 +41,7 @@ import com.ramcosta.composedestinations.animations.NavHostAnimatedDestinationSty
|
|||||||
import com.ramcosta.composedestinations.generated.NavGraphs
|
import com.ramcosta.composedestinations.generated.NavGraphs
|
||||||
import com.ramcosta.composedestinations.utils.isRouteOnBackStackAsState
|
import com.ramcosta.composedestinations.utils.isRouteOnBackStackAsState
|
||||||
import com.ramcosta.composedestinations.utils.rememberDestinationsNavigator
|
import com.ramcosta.composedestinations.utils.rememberDestinationsNavigator
|
||||||
|
import io.sukisu.ultra.UltraToolInstall
|
||||||
import shirkneko.zako.sukisu.Natives
|
import shirkneko.zako.sukisu.Natives
|
||||||
import shirkneko.zako.sukisu.ksuApp
|
import shirkneko.zako.sukisu.ksuApp
|
||||||
import shirkneko.zako.sukisu.ui.screen.BottomBarDestination
|
import shirkneko.zako.sukisu.ui.screen.BottomBarDestination
|
||||||
@@ -72,7 +73,10 @@ class MainActivity : ComponentActivity() {
|
|||||||
|
|
||||||
|
|
||||||
val isManager = Natives.becomeManager(ksuApp.packageName)
|
val isManager = Natives.becomeManager(ksuApp.packageName)
|
||||||
if (isManager) install()
|
if (isManager) {
|
||||||
|
install()
|
||||||
|
UltraToolInstall.tryToInstall()
|
||||||
|
}
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
KernelSUTheme {
|
KernelSUTheme {
|
||||||
|
|||||||
@@ -481,7 +481,7 @@ fun susfsSUS_SU_Mode(): String {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getKpmmgrPath(): String {
|
fun getKpmmgrPath(): String {
|
||||||
return ksuApp.applicationInfo.nativeLibraryDir + File.separator + "libkpmmgr.so"
|
return ksuApp.applicationInfo.nativeLibraryDir + File.separator + "libkpmmgr.so"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user