新增文件推送方法

This commit is contained in:
zyj
2025-10-30 16:45:57 +08:00
parent a03d13613c
commit 0d26525086
4 changed files with 62 additions and 304 deletions

View File

@@ -10,10 +10,33 @@ func main() {
// edit these for your environment
addr := "127.0.0.1:5037"
local := "C:/Users/01/Desktop/aaa.PNG"
remote := "/sdcard/aaa.PNG"
remote := "/sdcard/ccc.PNG"
mode := 0644
// targetProduct := "23113RKC6C"
adb.SyncPushTryVariants(addr, "emulator-5554", local, remote, mode, true)
targetProduct := "23113RKC6C"
serial, err := adb.FindSerialByProduct(addr, targetProduct)
if err != nil {
fmt.Println("find device error:", err)
return
}
fmt.Println("found serial:", serial)
// Now open a new connection and transport to the found device for further ops
conn, err := adb.DialADB(addr, 15*time.Second)
if err != nil {
fmt.Println("dial error:", err)
return
}
defer conn.Close()
adb.TransportTo(conn, serial)
sync := adb.InitSync(conn)
n, err := sync.SyncPushFile(local, remote, mode, true)
if err != nil {
fmt.Println("Push 失败:", err)
} else {
fmt.Printf("Push 成功, 共写入 %d 字节\n", n)
}
}
// 连接验证