From c92932cb2e55f4b622a6c8694078d3ba4e531f53 Mon Sep 17 00:00:00 2001 From: electricbubble Date: Fri, 22 Apr 2022 22:13:37 +0800 Subject: [PATCH] fix: get more values by session > https://github.com/electricbubble/gidevice/issues/26 --- device.go | 16 ++++++++++++++-- lockdown_test.go | 5 ++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/device.go b/device.go index 072a7d4..389fb6b 100644 --- a/device.go +++ b/device.go @@ -182,7 +182,19 @@ func (d *device) GetValue(domain, key string) (v interface{}, err error) { if _, err = d.lockdownService(); err != nil { return nil, err } - return d.lockdown.GetValue(domain, key) + if d.lockdown.pairRecord == nil { + if err = d.lockdown.handshake(); err != nil { + return nil, err + } + } + if err = d.lockdown.startSession(d.lockdown.pairRecord); err != nil { + return nil, err + } + if v, err = d.lockdown.GetValue(domain, key); err != nil { + return nil, err + } + err = d.lockdown.stopSession() + return } func (d *device) Pair() (pairRecord *PairRecord, err error) { @@ -730,7 +742,7 @@ func (d *device) XCTest(bundleID string, opts ...XCTestOption) (out <-chan strin if _err := d.AppKill(pid); _err != nil { debugLog(fmt.Sprintf("xctest kill: %d", pid)) } - //time.Sleep(time.Second) + // time.Sleep(time.Second) close(_out) return }() diff --git a/lockdown_test.go b/lockdown_test.go index bd123c9..d6f2374 100644 --- a/lockdown_test.go +++ b/lockdown_test.go @@ -34,7 +34,10 @@ func Test_lockdown_QueryType(t *testing.T) { func Test_lockdown_GetValue(t *testing.T) { setupLockdownSrv(t) - v, err := lockdownSrv.GetValue("", "") + // v, err := dev.GetValue("com.apple.mobile.iTunes", "") + // v, err := dev.GetValue("com.apple.mobile.internal", "") + v, err := dev.GetValue("com.apple.mobile.battery", "") + // v, err := lockdownSrv.GetValue("", "ProductVersion") // v, err := lockdownSrv.GetValue("", "DeviceName") // v, err := lockdownSrv.GetValue("com.apple.mobile.iTunes", "")