|
|
|
@ -236,8 +236,13 @@ func getFailureCode(r *regexp.Regexp, line string) string { |
|
|
|
|
|
|
|
|
|
|
|
var installFailureRegex = regexp.MustCompile(`^Failure \[INSTALL_(.+)\]$`) |
|
|
|
var installFailureRegex = regexp.MustCompile(`^Failure \[INSTALL_(.+)\]$`) |
|
|
|
|
|
|
|
|
|
|
|
func (d *Device) Install(path string) error { |
|
|
|
func withOpts(cmd string, opts []string, args ...string) []string { |
|
|
|
cmd := d.AdbCmd("install", path) |
|
|
|
v := append([]string{"install"}, opts...) |
|
|
|
|
|
|
|
return append(v, args...) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (d *Device) install(opts []string, path string) error { |
|
|
|
|
|
|
|
cmd := d.AdbCmd(withOpts("install", opts, path)...) |
|
|
|
stdout, err := cmd.StdoutPipe() |
|
|
|
stdout, err := cmd.StdoutPipe() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
@ -252,6 +257,14 @@ func (d *Device) Install(path string) error { |
|
|
|
return parseError(getFailureCode(installFailureRegex, line)) |
|
|
|
return parseError(getFailureCode(installFailureRegex, line)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (d *Device) Install(path string) error { |
|
|
|
|
|
|
|
return d.install(nil, path) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (d *Device) Upgrade(path string) error { |
|
|
|
|
|
|
|
return d.install([]string{"-r"}, path) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func getResultLine(out io.ReadCloser) string { |
|
|
|
func getResultLine(out io.ReadCloser) string { |
|
|
|
scanner := bufio.NewScanner(out) |
|
|
|
scanner := bufio.NewScanner(out) |
|
|
|
for scanner.Scan() { |
|
|
|
for scanner.Scan() { |
|
|
|
|