Skip to content

Commit

Permalink
use pty when call adb install
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Dec 9, 2018
1 parent 6d93d4f commit dee9a7b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module github.com/codeskyblue/fa

require (
github.com/cavaliercoder/grab v2.0.0+incompatible
github.com/kr/pty v1.1.1
github.com/manifoldco/promptui v0.3.2
github.com/mattn/go-runewidth v0.0.3 // indirect
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4
Expand Down
13 changes: 9 additions & 4 deletions install.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/cavaliercoder/grab"
"github.com/kr/pty"
"github.com/pkg/errors"
"github.com/shogo82148/androidbinary/apk"
"github.com/urfave/cli"
Expand Down Expand Up @@ -90,10 +91,14 @@ func actInstall(ctx *cli.Context) error {

// install
outBuffer := bytes.NewBuffer(nil)
c := adbCommand(serial, "install", apkpath)
c.Stdout = io.MultiWriter(os.Stdout, outBuffer)
c.Stderr = os.Stderr
if err := c.Run(); err != nil {
c := adbCommand(serial, "install", "-r", apkpath)
ttyf, err := pty.Start(c)
if err != nil {
return err
}
mwr := io.MultiWriter(os.Stdout, outBuffer)
io.Copy(mwr, ttyf)
if err := c.Wait(); err != nil {
return err
}

Expand Down

0 comments on commit dee9a7b

Please sign in to comment.