diff --git a/src/main/java/org/libimobiledevice/ios/driver/binding/services/IOSDevice.java b/src/main/java/org/libimobiledevice/ios/driver/binding/services/IOSDevice.java index 44f40b5..132f465 100644 --- a/src/main/java/org/libimobiledevice/ios/driver/binding/services/IOSDevice.java +++ b/src/main/java/org/libimobiledevice/ios/driver/binding/services/IOSDevice.java @@ -22,6 +22,7 @@ import java.util.logging.Logger; import static org.libimobiledevice.ios.driver.binding.exceptions.SDKErrorCode.throwIfNeeded; +import static org.libimobiledevice.ios.driver.binding.raw.ImobiledeviceSdkLibrary.sdk_idevice_restart; import static org.libimobiledevice.ios.driver.binding.raw.ImobiledeviceSdkLibrary.sdk_idevice_free; import static org.libimobiledevice.ios.driver.binding.raw.ImobiledeviceSdkLibrary.sdk_idevice_new; import static org.libimobiledevice.ios.driver.binding.raw.ImobiledeviceSdkLibrary.sdk_idevice_t; @@ -67,6 +68,11 @@ public SysLogService getSysLogService() throws SDKException { } return sysLogService; } + + public void restart() throws SDKException { + DeviceService.remove(uuid); + throwIfNeeded(sdk_idevice_restart(sdk_handle)); + } } diff --git a/src/main/java/org/libimobiledevice/ios/driver/binding/services/InstallerService.java b/src/main/java/org/libimobiledevice/ios/driver/binding/services/InstallerService.java index a597c8b..63b00ec 100644 --- a/src/main/java/org/libimobiledevice/ios/driver/binding/services/InstallerService.java +++ b/src/main/java/org/libimobiledevice/ios/driver/binding/services/InstallerService.java @@ -23,6 +23,7 @@ import java.util.Date; import java.util.List; import java.util.concurrent.Callable; +import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -88,7 +89,7 @@ private List parse(String raw) { return infos; } - public void install(final File ipa, final InstallCallback cb) throws SDKException { + public void install(final String appId, final File ipa, final InstallCallback cb) throws SDKException { if (!ipa.exists()) { throw new SDKException("the ipa file " + ipa + " doesn't exist."); } @@ -111,7 +112,7 @@ public Integer call() throws Exception { @Override public void onLog(SysLogLine line) { if (line.getMessage() - .equals("LaunchServices: Adding com.ebay.iphone to registration list")) { + .contains("ADDING REMOTE " + appId)) { if (line.getDate().after(now)) { cb.onUpdate("Done from syslog", 100, "Done"); future.cancel(true); @@ -129,6 +130,8 @@ public void onLog(SysLogLine line) { // ignore } catch (ExecutionException e) { // ignore + } catch (CancellationException e) { + // ignore } finally { device.getSysLogService().remove(checkSyslogForCompletion); } diff --git a/src/main/java/org/libimobiledevice/ios/driver/binding/services/SysLogService.java b/src/main/java/org/libimobiledevice/ios/driver/binding/services/SysLogService.java index 2dcfce6..0768793 100644 --- a/src/main/java/org/libimobiledevice/ios/driver/binding/services/SysLogService.java +++ b/src/main/java/org/libimobiledevice/ios/driver/binding/services/SysLogService.java @@ -30,7 +30,7 @@ public class SysLogService { private final SyslogMessageListeners handlers = new SyslogMessageListeners(); private boolean started = false; - SysLogService(IOSDevice d) throws SDKException { + public SysLogService(IOSDevice d) throws SDKException { PointerByReference ptr = new PointerByReference(); throwIfNeeded(syslog_service_new(d.getSDKHandle(), ptr)); diff --git a/src/test/java/org/libimobiledevice/ios/driver/test/DebugTest.java b/src/test/java/org/libimobiledevice/ios/driver/test/DebugTest.java index 256aff3..aa56b3b 100644 --- a/src/test/java/org/libimobiledevice/ios/driver/test/DebugTest.java +++ b/src/test/java/org/libimobiledevice/ios/driver/test/DebugTest.java @@ -34,6 +34,7 @@ public void openURL() throws InterruptedException, IOSDevice d = DeviceService.get(main); InstallerService installer = new InstallerService(d); + String appId = "ios-driver.ios-driver"; try { installer.getApplication("ios-driver.ios-driver"); } catch (SDKException e) { @@ -43,7 +44,7 @@ protected void onUpdate(String operation, int percent, String message) { sout(operation, percent, message); } }; - installer.install(new File("/Users/freynaud/ios-driver.ipa"), cb); + installer.install(appId, new File("/Users/freynaud/ios-driver.ipa"), cb); } DebugService service = new DebugService(DeviceService.get(main)); diff --git a/src/test/java/org/libimobiledevice/ios/driver/test/InstallTest.java b/src/test/java/org/libimobiledevice/ios/driver/test/InstallTest.java index 6245d58..565380e 100644 --- a/src/test/java/org/libimobiledevice/ios/driver/test/InstallTest.java +++ b/src/test/java/org/libimobiledevice/ios/driver/test/InstallTest.java @@ -11,6 +11,7 @@ import java.io.File; import java.util.List; +import static org.libimobiledevice.ios.driver.test.ConnectedDevices.ebayId4; import static org.libimobiledevice.ios.driver.test.ConnectedDevices.main; public class InstallTest { @@ -45,8 +46,9 @@ protected void onUpdate(String operation, int percent, String message) { File ui = new File("/Users/freynaud/UICatalog.ipa"); // File ui = new File("/Users/freynaud/out/com.yourcompany.UICatalog.ipa"); File eBay = new File("/Users/freynaud/tmp/com.ebay.iphone.ipa"); + String appId = "com.ebay.iphone"; - service.install(ui, cb); + service.install(appId, eBay, cb); service.free(); // service.install(new File("/Users/freynaud/Downloads/ebay_iphone_enterprise_3.2.0a1_build6.ipa"));