Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
aoliaoaoaojiao committed Dec 7, 2022
1 parent 768e875 commit 6f023f5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion device.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ func (d *device) Reboot() (err error) {
return
}

func (d *device) PowerSource() (powerInfo interface{}, err error) {
func (d *device) PowerSource() (powerInfo map[string]interface{}, err error) {
if _, err = d.lockdownService(); err != nil {
return
}
Expand Down
16 changes: 8 additions & 8 deletions diagnosticsrelay.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type diagnostics struct {
func (d *diagnostics) Reboot() (err error) {
var pkt libimobiledevice.Packet
if pkt, err = d.client.NewXmlPacket(
d.client.NewBasicRequest("Restart"),
d.client.NewBasicRequest("Restart", nil),
); err != nil {
return
}
Expand All @@ -30,7 +30,7 @@ func (d *diagnostics) Reboot() (err error) {
func (d *diagnostics) Shutdown() (err error) {
var pkt libimobiledevice.Packet
if pkt, err = d.client.NewXmlPacket(
d.client.NewBasicRequest("Shutdown"),
d.client.NewBasicRequest("Shutdown", nil),
); err != nil {
return
}
Expand All @@ -40,14 +40,11 @@ func (d *diagnostics) Shutdown() (err error) {
return
}

func (d *diagnostics) PowerSource() (powerInfo interface{}, err error) {
var data map[string]string
data["Request"] = "IORegistry"
data["EntryClass"] = "IOPMPowerSource"
data["Label"] = "org.cloud.sonic.gidevice"
func (d *diagnostics) PowerSource() (powerInfo map[string]interface{}, err error) {
var pkt libimobiledevice.Packet
ioRegistry := "IOPMPowerSource"
if pkt, err = d.client.NewXmlPacket(
d.client.NewBasicRequest("Shutdown"),
d.client.NewBasicRequest("IORegistry", &ioRegistry),
); err != nil {
return nil, err
}
Expand All @@ -57,6 +54,9 @@ func (d *diagnostics) PowerSource() (powerInfo interface{}, err error) {
if pkt, err = d.client.ReceivePacket(); err != nil {
return nil, err
}
if powerInfo == nil {
powerInfo = make(map[string]interface{})
}
if err = pkt.Unmarshal(powerInfo); err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions idevice.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type Device interface {

Reboot() error
Shutdown() error
PowerSource() (powerInfo interface{}, err error)
PowerSource() (powerInfo map[string]interface{}, err error)

crashReportMoverService() (crashReportMover CrashReportMover, err error)
MoveCrashReport(hostDir string, opts ...CrashReportMoverOption) (err error)
Expand Down Expand Up @@ -235,7 +235,7 @@ type Perfd interface {
type DiagnosticsRelay interface {
Reboot() error
Shutdown() error
PowerSource() (powerInfo interface{}, err error)
PowerSource() (powerInfo map[string]interface{}, err error)
}

type WebInspector interface {
Expand Down
12 changes: 7 additions & 5 deletions pkg/libimobiledevice/diagnosticsrelay.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ const (
)

type DiagnosticsRelayBasicRequest struct {
Request string `plist:"Request"`
Label string `plist:"Label"`
Request string `plist:"Request"`
Label string `plist:"Label"`
EntryClass *string `plist:"EntryClass,omitempty"`
}

func NewDiagnosticsRelayClient(innerConn InnerConn) *DiagnosticsRelayClient {
Expand All @@ -23,10 +24,11 @@ func (c *DiagnosticsRelayClient) InnerConn() InnerConn {
return c.client.innerConn
}

func (c *DiagnosticsRelayClient) NewBasicRequest(relayType string) *DiagnosticsRelayBasicRequest {
func (c *DiagnosticsRelayClient) NewBasicRequest(relayType string, entryClass *string) *DiagnosticsRelayBasicRequest {
return &DiagnosticsRelayBasicRequest{
Request: relayType,
Label: BundleID,
Request: relayType,
Label: BundleID,
EntryClass: entryClass,
}
}

Expand Down

0 comments on commit 6f023f5

Please sign in to comment.