Skip to content

Commit

Permalink
Merge pull request #708 from dkimitsa/fix/failed_to_start_on_ios13_dev
Browse files Browse the repository at this point in the history
* fixed: robovm failed to start application on ios13+ devices
  • Loading branch information
Tom-Ski authored Mar 10, 2023
2 parents a51c772 + c7bd79b commit 0816ac5
Showing 1 changed file with 26 additions and 4 deletions.
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

0 comments on commit 0816ac5

Please sign in to comment.