Add GerVar
This commit is contained in:
parent
e0508069b2
commit
6e4c7f0eaa
|
@ -1,6 +1,7 @@
|
|||
package fastboot
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
|
@ -21,6 +22,12 @@ var Status = struct {
|
|||
INFO: "INFO",
|
||||
}
|
||||
|
||||
var Error = struct {
|
||||
VarNotFound error
|
||||
}{
|
||||
VarNotFound: errors.New("Variable not found"),
|
||||
}
|
||||
|
||||
type FastbootDevice struct {
|
||||
Serial string
|
||||
Device *gousb.Device
|
||||
|
@ -148,6 +155,18 @@ func (d *FastbootDevice) Recv() (FastbootResponseStatus, []byte, error) {
|
|||
return status, data[4:], nil
|
||||
}
|
||||
|
||||
func (d *FastbootDevice) GerVar(variable string) (string, error) {
|
||||
d.Send([]byte(fmt.Sprintf("getvar:%s", variable)))
|
||||
status, resp, err := d.Recv()
|
||||
if status == Status.FAIL {
|
||||
err = Error.VarNotFound
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(resp), nil
|
||||
}
|
||||
|
||||
func (d *FastbootDevice) BootImage(data []byte) error {
|
||||
err := d.download(data)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue