We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When I run reboot command to a target Android device, it throws java.io.EOFException. Is this an intentional behavior?
Here is my Device class which uses Kadb:
class Device( private val address: String, private val port: Int = 5555, private val code: String? = null, private val context: Context, ) { private lateinit var manager: Kadb suspend fun runAttach() = withContext(IO) { runKeygen() // if (code != null) Kadb.pair(address, port, code) manager = Kadb.create(address, port, connectTimeout = 5000, socketTimeout = 5000).also { val command = "connect $address:$port" it.shell(command) } } suspend fun runKeygen() = withContext(IO) { val sharing = context.getSharedPreferences("kadb", Context.MODE_PRIVATE) val cert = sharing.getString("cert", null) val key = sharing.getString("key", null) if (cert.isNullOrEmpty() || key.isNullOrEmpty()) { val pair = KadbCert.get() sharing.edit() .putString("cert", pair.first.decodeToString()) .putString("key", pair.second.decodeToString()).apply() return@withContext } try { KadbCert.set(cert.toByteArray(), key.toByteArray()) } catch (e: Exception) { if (e is CertificateExpiredException || e is CertificateNotYetValidException) { val pair = KadbCert.get() sharing.edit().putString("cert", pair.first.decodeToString()) .putString("key", pair.second.decodeToString()).apply() } throw e } } suspend fun runReboot() = withContext(IO) { manager.shell("reboot") // This is where the error is thrown // runCatching { manager.shell("reboot") } // Bypassing is working delay(4000) while (true) { try { runAttach() break } catch (e: Exception) { delay(2000) } } delay(8000) } }
Here is my ViewModel:
fun onButtonClicked() = viewModelScope.launch { loading.value = true val device = Device(address.value, context = context) try { device.runAttach() device.runReboot() // TODO: Do other things } catch (e: Exception) { content.value = e.message.toString() } loading.value = false }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When I run reboot command to a target Android device, it throws java.io.EOFException.
Is this an intentional behavior?
Here is my Device class which uses Kadb:
Here is my ViewModel:
The text was updated successfully, but these errors were encountered: