Skip to content

Commit caacc0e

Browse files
authored
add patch for older devices (danielpaulus#61)
image mount and list should work now for older devices
1 parent 929c727 commit caacc0e

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

ios/imagemounter/imagemounter.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package imagemounter
33
import (
44
"errors"
55
"fmt"
6+
"github.com/Masterminds/semver"
67
"github.com/danielpaulus/go-ios/ios"
78
log "github.com/sirupsen/logrus"
89
"io"
@@ -16,17 +17,23 @@ const serviceName string = "com.apple.mobile.mobile_image_mounter"
1617
type Connection struct {
1718
deviceConn ios.DeviceConnectionInterface
1819
plistCodec ios.PlistCodec
20+
version *semver.Version
1921
}
2022

2123
//New returns a new mobile image mounter Connection for the given DeviceID and Udid
2224
func New(device ios.DeviceEntry) (*Connection, error) {
25+
version, err := ios.GetProductVersion(device)
26+
if err != nil {
27+
return nil, err
28+
}
2329
deviceConn, err := ios.ConnectToService(device, serviceName)
2430
if err != nil {
2531
return &Connection{}, err
2632
}
2733
return &Connection{
2834
deviceConn: deviceConn,
2935
plistCodec: ios.NewPlistCodec(),
36+
version: version,
3037
}, nil
3138
}
3239

@@ -56,9 +63,13 @@ func (conn *Connection) ListImages() ([][]byte, error) {
5663
if ok {
5764
return nil, fmt.Errorf("device error: %v", deviceError)
5865
}
66+
5967
signatures, ok := resp["ImageSignature"]
6068
if !ok {
61-
return nil, fmt.Errorf("invalid response: %+v", signatures)
69+
if conn.version.LessThan(semver.MustParse("14.0")) {
70+
return [][]byte{}, nil
71+
}
72+
return nil, fmt.Errorf("invalid response: %+v", resp)
6273
}
6374

6475
array, ok := signatures.([]interface{})

ios/lockdown_value.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ios
33
import (
44
"bytes"
55
"fmt"
6+
"github.com/Masterminds/semver"
67

78
plist "howett.net/plist"
89
)
@@ -150,6 +151,21 @@ func (lockDownConn *LockDownConnection) GetValues() (GetAllValuesResponse, error
150151
return response, nil
151152
}
152153

154+
//GetProductVersion gets the iOS version of a device
155+
func GetProductVersion(device DeviceEntry) (*semver.Version, error) {
156+
lockdownConnection, err := ConnectLockdownWithSession(device)
157+
if err != nil {
158+
return &semver.Version{}, err
159+
}
160+
defer lockdownConnection.Close()
161+
version, err := lockdownConnection.GetProductVersion()
162+
if err != nil {
163+
return &semver.Version{}, err
164+
}
165+
v, err := semver.NewVersion(version)
166+
return v, err
167+
}
168+
153169
//GetProductVersion returns the ProductVersion of the device f.ex. "10.3"
154170
func (lockDownConn *LockDownConnection) GetProductVersion() (string, error) {
155171
msg, err := lockDownConn.GetValue("ProductVersion")

0 commit comments

Comments
 (0)