Skip to content

Commit

Permalink
Fixed the problem that "java.io.IOException: Unexpected sync packet i…
Browse files Browse the repository at this point in the history
…d: FAIL" was thrown when UTF8 characters appeared in the path parameter of the push method.
  • Loading branch information
flyfishxu committed Jan 22, 2024
1 parent 1ce63d3 commit b5174e9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ publishing {
create<MavenPublication>("mavenJava") {
groupId = "com.flyfishxu"
artifactId = "kadb"
version = "1.0.0"
version = "1.0.1"

afterEvaluate { artifact(tasks.getByName("bundleReleaseAar")) }
artifact(sourceJar)
Expand Down
1 change: 0 additions & 1 deletion app/src/main/kotlin/com/flyfishxu/kadb/AdbConnection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ internal class AdbConnection internal constructor(
fun connect(socket: Socket, keyPair: AdbKeyPair? = null): AdbConnection {
val source = socket.source()
val sink = socket.sink()
File("").sink()

return connect(socket, source, sink, keyPair, socket)
}
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/kotlin/com/flyfishxu/kadb/AdbSync.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.flyfishxu.kadb

import android.util.Log
import okio.*
import java.io.IOException
import java.nio.charset.StandardCharsets
Expand All @@ -41,10 +42,12 @@ class AdbSyncStream(

private val buffer = Buffer()


@Throws(IOException::class)
fun send(source: Source, remotePath: String, mode: Int, lastModifiedMs: Long) {
val remote = "$remotePath,$mode"
writePacket(SEND, remote.length)
val length = remote.toByteArray().size
writePacket(SEND, length)

stream.sink.apply {
writeString(remote, StandardCharsets.UTF_8)
Expand Down

0 comments on commit b5174e9

Please sign in to comment.