private fun runShellCommandWithShizuku(command: Array<String>): Pair<String, String> {
return try {
val clazz = Class.forName("rikka.shizuku.Shizuku")
val method = clazz.getDeclaredMethod("newProcess", Array<String>::class.java, Array<String>::class.java, String::class.java)
method.isAccessible = true
val remoteProcess = method.invoke(null, command, null, null) as rikka.shizuku.ShizukuRemoteProcess
val output = remoteProcess.inputStream.bufferedReader().use { it.readText() }
val error = remoteProcess.errorStream.bufferedReader().use { it.readText() }
remoteProcess.destroy()
Pair(output.trim(), error.trim())
} catch (exception: Exception) {
Pair("", "Exception: ${exception.message}")
}
}
Please do not remove or deprecate this API. I use it solely to execute shell commands via Shizuku and do not require the UserProcess features of the Shizuku API. A straightforward way to run commands as the shell user is essential for my use case, so I kindly request that this functionality remains available.
Please do not remove or deprecate this API. I use it solely to execute shell commands via Shizuku and do not require the UserProcess features of the Shizuku API. A straightforward way to run commands as the shell user is essential for my use case, so I kindly request that this functionality remains available.