Skip to content

Commit

Permalink
Fix incomplete deviceinfo (danielpaulus#22)
Browse files Browse the repository at this point in the history
* fix ios info by returning the full plist

* return "value" object of the response instead of the whole response
  • Loading branch information
danielpaulus authored Mar 30, 2021
1 parent fe37f32 commit 694a9e5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
17 changes: 17 additions & 0 deletions ios/lockdown_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,23 @@ func getAllValuesResponseFromBytes(plistBytes []byte) GetAllValuesResponse {
return getAllValuesResponse
}

//GetValuesPlist returns the full lockdown values response as a map, so it can be converted to JSON easily.
func GetValuesPlist(device DeviceEntry) (map[string]interface{}, error) {
lockdownConnection := ConnectLockdownWithSession(device)
defer lockdownConnection.Close()
lockdownConnection.Send(newGetValue(""))
resp, err := lockdownConnection.ReadMessage()
if err != nil {
return map[string]interface{}{}, err
}
plist, err := ParsePlist(resp)
plist, ok := plist["Value"].(map[string]interface{})
if !ok {
return plist, fmt.Errorf("Failed converting lockdown response:%+v", plist)
}
return plist, err
}

//GetValues returns all values of deviceInformation from lockdown
func GetValues(device DeviceEntry) GetAllValuesResponse {
lockdownConnection := ConnectLockdownWithSession(device)
Expand Down
2 changes: 1 addition & 1 deletion ios/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func GetDevice(udid string) (DeviceEntry, error) {
if len(deviceList.DeviceList) == 0 {
return DeviceEntry{}, errors.New("no iOS devices are attached to this host")
}
log.WithFields(log.Fields{"udid": deviceList.DeviceList[0].Properties.SerialNumber}).Info("no udid specified using default")
log.WithFields(log.Fields{"udid": deviceList.DeviceList[0].Properties.SerialNumber}).Debug("no udid specified using default")
return deviceList.DeviceList[0], nil
}
for _, device := range deviceList.DeviceList {
Expand Down
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,11 @@ func startListening() {
}

func printDeviceInfo(device ios.DeviceEntry) {
allValues := ios.GetValues(device)
fmt.Println(convertToJSONString(allValues.Value))
allValues, err := ios.GetValuesPlist(device)
if err != nil {
failWithError("failed getting info", err)
}
fmt.Println(convertToJSONString(allValues))
}

func runSyslog(device ios.DeviceEntry) {
Expand Down Expand Up @@ -603,3 +606,7 @@ func convertToJSONString(data interface{}) string {
}
return string(b)
}

func failWithError(msg string, err error) {
log.WithFields(log.Fields{"err": err}).Fatalf(msg)
}

0 comments on commit 694a9e5

Please sign in to comment.