mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 06:26:15 +01:00
Implement SavePairRecord
This commit is contained in:
@@ -335,6 +335,32 @@ impl UsbmuxdConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Tells usbmuxd to save the pairing record in its storage
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
/// * `device_id` - usbmuxd device ID
|
||||||
|
/// * `udid` - the device UDID/serial
|
||||||
|
/// * `pair_record` - a serialized plist of the pair record
|
||||||
|
pub async fn save_pair_record(
|
||||||
|
&mut self,
|
||||||
|
device_id: u32,
|
||||||
|
udid: &str,
|
||||||
|
pair_record: Vec<u8>,
|
||||||
|
) -> Result<(), IdeviceError> {
|
||||||
|
let req = crate::plist!(dict {
|
||||||
|
"MessageType": "SavePairRecord",
|
||||||
|
"PairRecordData": pair_record,
|
||||||
|
"DeviceID": device_id,
|
||||||
|
"PairRecordID": udid,
|
||||||
|
});
|
||||||
|
self.write_plist(req).await?;
|
||||||
|
let res = self.read_plist().await?;
|
||||||
|
match res.get("Number").and_then(|x| x.as_unsigned_integer()) {
|
||||||
|
Some(0) => Ok(()),
|
||||||
|
_ => Err(IdeviceError::UnexpectedResponse),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Writes a PLIST message to usbmuxd
|
/// Writes a PLIST message to usbmuxd
|
||||||
async fn write_plist(&mut self, req: plist::Dictionary) -> Result<(), IdeviceError> {
|
async fn write_plist(&mut self, req: plist::Dictionary) -> Result<(), IdeviceError> {
|
||||||
let raw = raw_packet::RawPacket::new(
|
let raw = raw_packet::RawPacket::new(
|
||||||
|
|||||||
@@ -74,10 +74,13 @@ async fn main() {
|
|||||||
.expect("Pairing file test failed");
|
.expect("Pairing file test failed");
|
||||||
|
|
||||||
// Add the UDID (jitterbug spec)
|
// Add the UDID (jitterbug spec)
|
||||||
pairing_file.udid = Some(dev.udid);
|
pairing_file.udid = Some(dev.udid.clone());
|
||||||
|
let pairing_file = pairing_file.serialize().expect("failed to serialize");
|
||||||
|
|
||||||
println!(
|
println!("{}", String::from_utf8(pairing_file.clone()).unwrap());
|
||||||
"{}",
|
|
||||||
String::from_utf8(pairing_file.serialize().unwrap()).unwrap()
|
// Save with usbmuxd
|
||||||
);
|
u.save_pair_record(dev.device_id, &dev.udid, pairing_file)
|
||||||
|
.await
|
||||||
|
.expect("no save");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user