@@ 316,6 316,33 @@ func (d *FastbootDevice) openIOEndpoints(intf *gousb.Interface) (epIn *gousb.InE
return
}
+// GetVar retrieves a fastboot variable, or err if the variable doesn't exist
+func (d *FastbootDevice) GetVar(variable string) (value string, err error) {
+ ctx := gousb.NewContext()
+ defer ctx.Close()
+
+ resp, err := d.getVar(ctx, variable)
+
+ value = resp.Response
+ return
+}
+
+// getVar retrieves a fastboot variable, or err if the variable doesn't exist.
+// This is the non-exported version that receives an open gousb.Context
+func (d *FastbootDevice) getVar(ctx *gousb.Context, variable string) (resp fastbootResponse, err error) {
+ resp, err = d.sendCommand(ctx, fmt.Sprintf("getvar:%s", variable))
+ if err != nil {
+ err = fmt.Errorf("jankboot.getVar(): %w", err)
+ return
+ }
+
+ if !checkResponse(resp, "OKAY", "") {
+ err = fmt.Errorf("jankboot.getVar(): invalid response recieved when requesting variable %q: %s", variable, resp)
+ }
+
+ return
+}
+
// getResponse parses the response from the client into a fastbootResponse type
func getResponse(ctx *gousb.Context, epIn *gousb.InEndpoint) (resp fastbootResponse, err error) {