Skip to content
This repository was archived by the owner on May 27, 2024. It is now read-only.
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ $ adb shell /data/local/tmp/atx-agent server -d

# stop already running atx-agent and start daemon
$ adb shell /data/local/tmp/atx-agent server -d --stop

# 管控图片质量(1~100),默认80
adb shell /data/local/tmp/atx-agent server --nouia -d --quality=10

# 在服务运行过程中动态修改图片质量
adb shell /data/local/tmp/atx-agent server --reset --quality=80
```

默认监听的端口是7912。
Expand Down
8 changes: 8 additions & 0 deletions build_in_windows.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set GOOS=linux
set GOARCH=arm
set GOARM=7
set GOPROXY=https://goproxy.io
set GO111MODULE=on
go get -v github.com/shurcooL/vfsgen
go generate
go build -tags vfs
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/kr/binarydist v0.1.0 // indirect
github.com/kr/pty v1.1.8
github.com/creack/pty v1.1.15
github.com/levigross/grequests v0.0.0-20190130132859-37c80f76a0da
github.com/mholt/archiver v2.0.1-0.20171012052341-26cf5bb32d07+incompatible
github.com/mitchellh/ioprogress v0.0.0-20180201004757-6a23b12fa88e
Expand Down
31 changes: 28 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var (
owner = "openatx"
repo = "atx-agent"
listenAddr string
minicapQuality string
daemonLogPath = "/sdcard/atx-agent.daemon.log"

rotationPublisher = broadcast.NewBroadcaster(1)
Expand Down Expand Up @@ -184,7 +185,8 @@ type MinicapInfo struct {

var (
deviceRotation int
displayMaxWidthHeight = 800
displayMaxWidthHeight = 1080

)

func updateMinicapRotation(rotation int) {
Expand All @@ -196,7 +198,7 @@ func updateMinicapRotation(rotation int) {
devInfo := getDeviceInfo()
width, height := devInfo.Display.Width, devInfo.Display.Height
service.UpdateArgs("minicap", "/data/local/tmp/minicap", "-S", "-P",
fmt.Sprintf("%dx%d@%dx%d/%d", width, height, displayMaxWidthHeight, displayMaxWidthHeight, rotation))
fmt.Sprintf("%dx%d@%dx%d/%d", width, height, width, height, rotation), "-Q", minicapQuality)
if running {
service.Start("minicap")
}
Expand Down Expand Up @@ -414,6 +416,7 @@ func stopSelf() {
}

// to make sure stopped
killProcessByName("minicap")
killAgentProcess()
}

Expand Down Expand Up @@ -524,11 +527,15 @@ func main() {
cmdServer := kingpin.Command("server", "start server")
fDaemon := cmdServer.Flag("daemon", "daemon mode").Short('d').Bool()
fStop := cmdServer.Flag("stop", "stop server").Bool()
resetQuality := cmdServer.Flag("reset", "reset image quality").Bool()
cmdServer.Flag("addr", "listen port").Default(":7912").StringVar(&listenAddr) // Create on 2017/09/12
cmdServer.Flag("log", "log file path when in daemon mode").StringVar(&daemonLogPath)
// fServerURL := cmdServer.Flag("server", "server url").Short('t').String()
fNoUiautomator := cmdServer.Flag("nouia", "do not start uiautoamtor when start").Bool()

// 图片质量
cmdServer.Flag("quality", "传输图片质量,1~100").Default("80").StringVar(&minicapQuality)

// CMD: version
kingpin.Command("version", "show version")

Expand All @@ -541,6 +548,7 @@ func main() {
os.Setenv("COLUMNS", "160")

kingpin.Command("info", "show device info")

switch kingpin.Parse() {
case "curl":
subcmd.DoCurl()
Expand Down Expand Up @@ -572,6 +580,23 @@ func main() {
}
}

if *resetQuality {
running := service.Running("minicap")
if running {
Comment thread
HongFei1998 marked this conversation as resolved.
service.Stop("minicap")
killProcessByName("minicap") // kill not controlled minicap
}
devInfo := getDeviceInfo()
width, height := devInfo.Display.Width, devInfo.Display.Height
service.Add("minicap", cmdctrl.CommandInfo{
Environ: []string{"LD_LIBRARY_PATH=/data/local/tmp"},
Args: []string{"/data/local/tmp/minicap", "-S", "-P",
fmt.Sprintf("%dx%d@%dx%d/0", width, height, width, height), "-Q", minicapQuality},
})
service.Start("minicap")
}


// serverURL := *fServerURL
// if serverURL != "" {
// if !regexp.MustCompile(`https?://`).MatchString(serverURL) {
Expand Down Expand Up @@ -626,7 +651,7 @@ func main() {
service.Add("minicap", cmdctrl.CommandInfo{
Environ: []string{"LD_LIBRARY_PATH=/data/local/tmp"},
Args: []string{"/data/local/tmp/minicap", "-S", "-P",
fmt.Sprintf("%dx%d@%dx%d/0", width, height, displayMaxWidthHeight, displayMaxWidthHeight)},
fmt.Sprintf("%dx%d@%dx%d/0", width, height, width, height), "-Q", minicapQuality},
})

service.Add("apkagent", cmdctrl.CommandInfo{
Expand Down
2 changes: 1 addition & 1 deletion term_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/sirupsen/logrus"
"github.com/gorilla/websocket"
"github.com/kr/pty"
"github.com/creack/pty"
)

type windowSize struct {
Expand Down