use of org.robovm.libimobiledevice.binding.PlistRef in project robovm by robovm.
the class LockdowndClient method getValue.
/**
* Retrieves a preferences plist using an optional domain and/or key name.
*
* @param domain the domain to query on or <code>null</code> for the global
* domain.
* @param key the key name to request or <code>null</code> to query for all
* keys.
* @return a plist node representing the result value node.
*/
public NSObject getValue(String domain, String key) throws IOException {
PlistRefOut plistOut = new PlistRefOut();
try {
checkResult(LibIMobileDevice.lockdownd_get_value(getRef(), domain, key, plistOut));
PlistRef plist = plistOut.getValue();
return PlistUtil.toJavaPlist(plist);
} finally {
plistOut.delete();
}
}
use of org.robovm.libimobiledevice.binding.PlistRef in project robovm by robovm.
the class MobileImageMounterClient method lookupImage.
/**
* Checks if an image of the specified type has already been mounted. This
* method returns a plist similar to this when an image has been mounted:
* <pre>
* <plist version="1.0">
* <dict>
* <key>ImageDigest</key>
* <data>rBSGlwMv4yovqGM7sOk44vrE6xI=</data>
* <key>ImagePresent</key>
* <true/>
* <key>Status</key>
* <string>Complete</string>
* </dict>
* </plist>
* </pre>
* The {@code ImageDigest} value is the SHA-1 digest if the image file.
* <p>
* If no image has been mounted {@code ImagePresent=false} and there will be
* no {@code ImageDigest} in the response.
* <p>
* NOTE! It seems like this only returns {@code ImagePresent=true} the first
* time it is called after an image has been mounted. On subsequent calls
* it returns {@code ImagePresent=false} even if the image is still mounted.
*
* @param imageType type of the image to look for. If <code>null</code> is
* passed {@code Developer} will be used.
* @return the result of the lookup.
*/
public NSDictionary lookupImage(String imageType) throws IOException {
if (imageType == null) {
imageType = "Developer";
}
PlistRefOut plistOut = new PlistRefOut();
try {
checkResult(LibIMobileDevice.mobile_image_mounter_lookup_image(getRef(), imageType, plistOut));
PlistRef plist = plistOut.getValue();
return (NSDictionary) PlistUtil.toJavaPlist(plist);
} finally {
plistOut.delete();
}
}
use of org.robovm.libimobiledevice.binding.PlistRef in project robovm by robovm.
the class MobileImageMounterClient method mountImage.
/**
* Mounts an image on the device. After an image has been mounted it will
* remain mounted until the device is rebooted. Returns an
* {@link NSDictionary} with {@code Status=Complete} on success. On error
* the {@link NSDictionary} will contain {@code Error=ImageMountFailed}.
*
* @param imagePath the path of the image to be mounted. Should be an
* absolute path inside the AFC jail on the device.
* @param imageSignature the image's signature data.
* @param imageType type of the image. If <code>null</code> is passed
* {@code Developer} will be used.
* @return the result of the mount.
*/
public NSDictionary mountImage(String imagePath, byte[] imageSignature, String imageType) throws IOException {
if (imagePath == null) {
throw new NullPointerException("imagePath");
}
if (imageSignature == null) {
throw new NullPointerException("imageSignature");
}
if (imageType == null) {
imageType = "Developer";
}
if (!imagePath.startsWith("/")) {
imagePath = "/" + imagePath;
}
imagePath = PRIVATE_MOUNT_PREFIX + imagePath;
PlistRefOut plistOut = new PlistRefOut();
try {
checkResult(LibIMobileDevice.mobile_image_mounter_mount_image(getRef(), imagePath, imageSignature, (short) imageSignature.length, imageType, plistOut));
PlistRef plist = plistOut.getValue();
return (NSDictionary) PlistUtil.toJavaPlist(plist);
} finally {
plistOut.delete();
}
}
use of org.robovm.libimobiledevice.binding.PlistRef in project robovm by robovm.
the class InstallationProxyClient method browse.
/**
* Lists installed applications of the specified type.
*
* @param type the type of applications to list. Either
* {@link ApplicationType#User} or {@link ApplicationType#System}
* applications. Pass <code>null</code> to list all.
* @return an {@link NSArray} of {@link NSDictionary}s holding information
* about the installed applications.
*/
public NSArray browse(Options.ApplicationType type) throws IOException {
PlistRefOut plistOut = new PlistRefOut();
PlistRef clientOpts = new Options().applicationType(type).toPlistRef();
try {
checkResult(LibIMobileDevice.instproxy_browse(getRef(), clientOpts, plistOut));
PlistRef plist = plistOut.getValue();
return (NSArray) PlistUtil.toJavaPlist(plist);
} finally {
plistOut.delete();
LibIMobileDevice.plist_free(clientOpts);
}
}
use of org.robovm.libimobiledevice.binding.PlistRef in project robovm by robovm.
the class InstallationProxyClient method installOrUpgrade.
private void installOrUpgrade(String pkgPath, Options options, StatusCallback callback, boolean upgrade) throws IOException {
PlistRef clientOpts = options.toPlistRef();
try {
long cb = 0L;
int cbId = 0;
if (callback != null) {
cb = LibIMobileDevice.get_global_instproxy_status_cb();
cbId = Callbacks.registerInstproxyCallback(callback);
}
if (upgrade) {
checkResult(LibIMobileDevice.instproxy_upgrade(getRef(), pkgPath, clientOpts, cb, cbId));
} else {
checkResult(LibIMobileDevice.instproxy_install(getRef(), pkgPath, clientOpts, cb, cbId));
}
} finally {
LibIMobileDevice.plist_free(clientOpts);
}
}
Aggregations