Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dadb/src/main/kotlin/dadb/Dadb.kt
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ interface Dadb : AutoCloseable {

@Throws(InterruptedException::class)
fun tcpForward(hostPort: Int, targetPort: Int): AutoCloseable {
return tcpForward(hostPort, "tcp:$targetPort")
}

@Throws(InterruptedException::class)
fun tcpForward(hostPort: Int, targetPort: String): AutoCloseable {
val forwarder = TcpForwarder(this, hostPort, targetPort)
forwarder.start()

Expand Down
4 changes: 2 additions & 2 deletions dadb/src/main/kotlin/dadb/forwarding/TcpForwarder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import kotlin.concurrent.thread
internal class TcpForwarder(
private val dadb: Dadb,
private val hostPort: Int,
private val targetPort: Int,
private val targetPort: String,
) : AutoCloseable {

private var state: State = State.STOPPED
Expand Down Expand Up @@ -61,7 +61,7 @@ internal class TcpForwarder(
val client = serverRef.accept()

clientExecutor?.execute {
val adbStream = dadb.open("tcp:$targetPort")
val adbStream = dadb.open(targetPort)

val readerThread = thread {
forward(
Expand Down