Skip to content

Commit

Permalink
Dump sockets for debug
Browse files Browse the repository at this point in the history
  • Loading branch information
JingMatrix committed Apr 24, 2023
1 parent 6e3bb9a commit c03ef64
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/src/main/java/org/matrix/chromext/DevTools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,19 @@ private class forwardStreamThread(
}
}

private fun InputStream.pipe(out: OutputStream, bufferSize: Int = DEFAULT_BUFFER_SIZE): Long {
private fun InputStream.pipe(
out: OutputStream,
debug: Boolean = false,
bufferSize: Int = DEFAULT_BUFFER_SIZE
): Long {
if (!debug) {
return this.copyTo(out, bufferSize)
}
var bytesCopied: Long = 0
val buffer = ByteArray(bufferSize)
var bytes = read(buffer)
Log.d(String(buffer))
while (bytes >= 0) {
// Uncomment to debug
// Log.i(String(buffer))
out.write(buffer, 0, bytes)
bytesCopied += bytes
bytes = read(buffer)
Expand Down

0 comments on commit c03ef64

Please sign in to comment.