diff --git a/manager/app/src/main/java/io/sukisu/ultra/UltraShellHelper.java b/manager/app/src/main/java/io/sukisu/ultra/UltraShellHelper.java index 6d0a7bd7..643a382d 100644 --- a/manager/app/src/main/java/io/sukisu/ultra/UltraShellHelper.java +++ b/manager/app/src/main/java/io/sukisu/ultra/UltraShellHelper.java @@ -19,10 +19,12 @@ public class UltraShellHelper { } public static boolean isPathExists(String path) { - return runCmd("file " + path).contains("No such file or directory"); + 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); + public static boolean CopyFileTo(String path, String target) { + String result = runCmd("cp -f '" + path + "' '" + target + "' 2>&1"); + return !result.contains("cp: "); } } diff --git a/manager/app/src/main/java/zako/zako/zako/zakoui/activity/component/BottomBar.kt b/manager/app/src/main/java/zako/zako/zako/zakoui/activity/component/BottomBar.kt index c0217eed..12debc22 100644 --- a/manager/app/src/main/java/zako/zako/zako/zakoui/activity/component/BottomBar.kt +++ b/manager/app/src/main/java/zako/zako/zako/zakoui/activity/component/BottomBar.kt @@ -59,7 +59,7 @@ fun BottomBar(navController: NavHostController) { ) { BottomBarDestination.entries.forEach { destination -> if (destination == BottomBarDestination.Kpm) { - if (kpmVersion.isNotEmpty() && !kpmVersion.startsWith("Error") && !showKpmInfo && Natives.version >= Natives.MINIMAL_SUPPORTED_KPM) { + if (kpmVersion.isNotEmpty() && !showKpmInfo && Natives.version >= Natives.MINIMAL_SUPPORTED_KPM) { if (!isFullFeatured && destination.rootRequired) return@forEach val isCurrentDestOnBackStack by navController.isRouteOnBackStackAsState(destination.direction) NavigationBarItem( diff --git a/manager/app/src/main/java/zako/zako/zako/zakoui/activity/util/AppData.kt b/manager/app/src/main/java/zako/zako/zako/zakoui/activity/util/AppData.kt index 1ec67f81..3c498a1b 100644 --- a/manager/app/src/main/java/zako/zako/zako/zakoui/activity/util/AppData.kt +++ b/manager/app/src/main/java/zako/zako/zako/zakoui/activity/util/AppData.kt @@ -88,7 +88,7 @@ object AppData { val version = getKpmVersion() if (version.isEmpty()) "" else version } catch (e: Exception) { - "Error: ${e.message}" + "" } } diff --git a/manager/app/src/main/java/zako/zako/zako/zakoui/flash/KernelFlash.kt b/manager/app/src/main/java/zako/zako/zako/zakoui/flash/KernelFlash.kt index b71b0ef1..8ed0838b 100644 --- a/manager/app/src/main/java/zako/zako/zako/zakoui/flash/KernelFlash.kt +++ b/manager/app/src/main/java/zako/zako/zako/zakoui/flash/KernelFlash.kt @@ -287,16 +287,10 @@ class HorizonKernelWorker( } private fun runCommand(su: Boolean, cmd: String): Int { - val process = ProcessBuilder(if (su) "su" else "sh") - .redirectErrorStream(true) - .start() + val shell = if (su) "su" else "sh" + val process = Runtime.getRuntime().exec(arrayOf(shell, "-c", cmd)) return try { - process.outputStream.bufferedWriter().use { writer -> - writer.write("$cmd\n") - writer.write("exit\n") - writer.flush() - } process.waitFor() } finally { process.destroy() @@ -304,16 +298,10 @@ class HorizonKernelWorker( } private fun runCommandGetOutput(su: Boolean, cmd: String): String? { - val process = ProcessBuilder(if (su) "su" else "sh") - .redirectErrorStream(true) - .start() + val shell = if (su) "su" else "sh" + val process = Runtime.getRuntime().exec(arrayOf(shell, "-c", cmd)) return try { - process.outputStream.bufferedWriter().use { writer -> - writer.write("$cmd\n") - writer.write("exit\n") - writer.flush() - } process.inputStream.bufferedReader().use { reader -> reader.readText().trim() } @@ -326,7 +314,7 @@ class HorizonKernelWorker( private fun rootAvailable(): Boolean { return try { - val process = Runtime.getRuntime().exec("su -c id") + val process = Runtime.getRuntime().exec("su -c true") val exitValue = process.waitFor() exitValue == 0 } catch (_: Exception) {