Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add restart function to IOSDevice #16

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -88,7 +89,7 @@ private List<ApplicationInfo> 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.");
}
Expand All @@ -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);
Expand All @@ -129,6 +130,8 @@ public void onLog(SysLogLine line) {
// ignore
} catch (ExecutionException e) {
// ignore
} catch (CancellationException e) {
// ignore
} finally {
device.getSysLogService().remove(checkSyslogForCompletion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"));
Expand Down