use of org.robovm.libimobiledevice.InstallationProxyClient.Options in project robovm by robovm.
the class AppLauncher method installInternal.
private void installInternal() throws Exception {
try (LockdowndClient lockdowndClient = new LockdowndClient(device, getClass().getSimpleName(), true)) {
final LibIMobileDeviceException[] ex = new LibIMobileDeviceException[1];
final CountDownLatch countDownLatch = new CountDownLatch(1);
LockdowndServiceDescriptor instproxyService = lockdowndClient.startService(InstallationProxyClient.SERVICE_NAME);
try (InstallationProxyClient instClient = new InstallationProxyClient(device, instproxyService)) {
instClient.upgrade("/PublicStaging/" + localAppPath.getName(), new Options().packageType(localAppPath.isDirectory() ? PackageType.Developer : null), new StatusCallback() {
@Override
public void progress(String status, int percentComplete) {
if (installStatusCallback != null) {
installStatusCallback.progress(status, percentComplete);
} else {
log("[%3d%%] %s", 50 + percentComplete / 2, status);
}
}
@Override
public void success() {
try {
if (installStatusCallback != null) {
installStatusCallback.success();
} else {
log("[100%%] Installation complete");
}
} finally {
countDownLatch.countDown();
}
}
@Override
public void error(String message) {
try {
ex[0] = new LibIMobileDeviceException(message);
if (installStatusCallback != null) {
installStatusCallback.error(message);
} else {
log("Error: %s", message);
}
} finally {
countDownLatch.countDown();
}
}
});
countDownLatch.await();
}
if (ex[0] != null) {
throw ex[0];
}
}
}
use of org.robovm.libimobiledevice.InstallationProxyClient.Options in project robovm by robovm.
the class InstallationProxyClientTest method testUpgradeIPA.
//removed as test until it can be rewritten to re-sign the ipa
public void testUpgradeIPA() throws Exception {
Path tmpDir = Files.createTempDirectory(getClass().getSimpleName());
Files.copy(getClass().getResourceAsStream("/demo.ipa"), tmpDir.resolve("demo.ipa"));
afcClient.upload(tmpDir.resolve("demo.ipa").toFile(), "/TestStaging", new UploadProgressCallback() {
public void progress(File path, int percentComplete) {
System.out.format("[%3d%%] Uploading %s\n", percentComplete, path);
}
public void success() {
System.out.format("[100%%] Upload done\n");
}
public void error(String message) {
System.out.format("Error: %s\n", message);
}
});
final boolean[] success = new boolean[] { false };
final CountDownLatch countDownLatch = new CountDownLatch(1);
client.upgrade("/TestStaging/demo.ipa", new Options(), new StatusCallback() {
@Override
public void progress(String status, int percentComplete) {
System.out.format("[%3d%%] %s\n", percentComplete, status);
}
@Override
public void success() {
System.out.format("[100%%] Complete\n");
success[0] = true;
countDownLatch.countDown();
}
@Override
public void error(String message) {
System.out.println("Error: " + message);
countDownLatch.countDown();
}
});
countDownLatch.await(10, TimeUnit.SECONDS);
assertTrue(success[0]);
}
use of org.robovm.libimobiledevice.InstallationProxyClient.Options in project robovm by robovm.
the class InstallationProxyClientTest method testUpgradeAppBundle.
//removed as test until it can be rewritten to re-sign the ipa
public void testUpgradeAppBundle() throws Exception {
Path tmpDir = Files.createTempDirectory(getClass().getSimpleName());
Path ipaFile = tmpDir.resolve("demo.ipa");
Files.copy(getClass().getResourceAsStream("/demo.ipa"), ipaFile);
extractZip(ipaFile, tmpDir);
Path appDir = tmpDir.resolve("Payload/demo.app");
afcClient.upload(appDir.toFile(), "/TestStaging", new UploadProgressCallback() {
public void progress(File path, int percentComplete) {
System.out.format("[%3d%%] Uploading %s\n", percentComplete, path);
}
public void success() {
System.out.format("[100%%] Upload done\n");
}
public void error(String message) {
System.out.format("Error: %s\n", message);
}
});
final boolean[] success = new boolean[] { false };
final CountDownLatch countDownLatch = new CountDownLatch(1);
client.upgrade("/TestStaging/demo.app", new Options().packageType(PackageType.Developer), new StatusCallback() {
@Override
public void progress(String status, int percentComplete) {
System.out.format("[%3d%%] %s\n", percentComplete, status);
}
@Override
public void success() {
System.out.format("[100%%] Complete\n");
success[0] = true;
countDownLatch.countDown();
}
@Override
public void error(String message) {
System.out.println("Error: " + message);
countDownLatch.countDown();
}
});
countDownLatch.await(10, TimeUnit.SECONDS);
assertTrue(success[0]);
}
Aggregations