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

* fixed: robovm failed to start application on ios13+ devices #708

Merged
merged 1 commit into from
Mar 10, 2023
Merged
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 @@ -64,6 +64,9 @@
import com.dd.plist.NSString;
import com.dd.plist.PropertyListParser;

import static org.robovm.libimobiledevice.binding.LibIMobileDeviceConstants.DEBUGSERVER_SECURE_SERVICE_NAME;
import static org.robovm.libimobiledevice.binding.LibIMobileDeviceConstants.DEBUGSERVER_SERVICE_NAME;

/**
* Launches an application on a device using the {@code com.apple.debuserver}
* service. The app must have the {@code get-task-allow} entitlement set to
Expand All @@ -72,7 +75,6 @@
public class AppLauncher {
public static final int DEFAULT_FORWARD_PORT = 17777;

private static final String DEBUG_SERVER_SERVICE_NAME = "com.apple.debugserver";
private static final char[] HEX_CHARS = "0123456789abcdef".toCharArray();
private static final int RECEIVE_TIMEOUT = 5000;
private static final byte[] BREAK = new byte[] { 0x03 };
Expand Down Expand Up @@ -682,7 +684,23 @@ private void mountDeveloperImage(LockdowndClient lockdowndClient) throws Excepti
}
}
}


private LockdowndServiceDescriptor startDebugServerService(LockdowndClient lockdowndClient, String serviceName) {
LockdowndServiceDescriptor serviceDescriptor;
try {
serviceDescriptor = lockdowndClient.startService(serviceName);
} catch (LibIMobileDeviceException e) {
if (e.getErrorCode() == LockdowndError.LOCKDOWN_E_INVALID_SERVICE.swigValue() &&
DEBUGSERVER_SECURE_SERVICE_NAME.equals(serviceName)) {
// fallback with non SSL version
return startDebugServerService(lockdowndClient, DEBUGSERVER_SERVICE_NAME);
} else {
throw e;
}
}
return serviceDescriptor;
}

private int launchInternal() throws Exception {
install();

Expand All @@ -699,13 +717,13 @@ private int launchInternal() throws Exception {
}
LockdowndServiceDescriptor serviceDescriptor;
try {
serviceDescriptor = lockdowndClient.startService(DEBUG_SERVER_SERVICE_NAME);
serviceDescriptor = startDebugServerService(lockdowndClient, DEBUGSERVER_SECURE_SERVICE_NAME);
} catch (LibIMobileDeviceException e) {
if (e.getErrorCode() == LockdowndError.LOCKDOWN_E_INVALID_SERVICE.swigValue()) {
// This happens when the developer image hasn't been mounted.
// Mount and try again.
mountDeveloperImage(lockdowndClient);
serviceDescriptor = lockdowndClient.startService(DEBUG_SERVER_SERVICE_NAME);
serviceDescriptor = startDebugServerService(lockdowndClient, DEBUGSERVER_SECURE_SERVICE_NAME);
} else {
throw e;
}
Expand Down Expand Up @@ -844,6 +862,8 @@ private int pipeStdOut(DebugServerClient client, String appPath) throws Exceptio
// when we exit.
wasInterrupted = Thread.currentThread().isInterrupted();
kill(client);
// FIXME: don't wait to graceful response as recent libmobiledevice returns SSL_ERROR
return -1;
}
}
} finally {
Expand Down Expand Up @@ -942,6 +962,8 @@ private int forward(DebugServerClient client, String appPath) throws Exception {
// when we exit.
wasInterrupted = Thread.currentThread().isInterrupted();
kill(client);
// FIXME: don't wait to graceful response as recent libmobiledevice returns SSL_ERROR
return -1;
}
}
} finally {
Expand Down