Add GerVar

This commit is contained in:
timoxa0 2024-06-16 17:41:56 +05:00
parent e0508069b2
commit 6e4c7f0eaa

View file

@ -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 {