From 4d844ca027873d14ab2be8e4539b0e265c788d80 Mon Sep 17 00:00:00 2001 From: Jackson Coxson Date: Tue, 13 May 2025 23:37:24 -0600 Subject: [PATCH] Implement lockdown set value --- idevice/src/services/lockdown.rs | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/idevice/src/services/lockdown.rs b/idevice/src/services/lockdown.rs index d9f8d14..883a738 100644 --- a/idevice/src/services/lockdown.rs +++ b/idevice/src/services/lockdown.rs @@ -142,6 +142,48 @@ impl LockdownClient { } } + /// Sets a value on the device + /// + /// # Arguments + /// * `key` - The key to set + /// * `value` - The plist value to set + /// * `domain` - An optional domain to set by + /// + /// # Errors + /// Returns `IdeviceError` if: + /// - Communication fails + /// - The response is malformed + /// + /// # Example + /// ```rust + /// client.set_value("EnableWifiDebugging", true.into(), Some("com.apple.mobile.wireless_lockdown".to_string())).await?; + /// ``` + pub async fn set_value( + &mut self, + key: impl Into, + value: Value, + domain: Option, + ) -> Result<(), IdeviceError> { + let key = key.into(); + + let mut req = plist::Dictionary::new(); + req.insert("Label".into(), self.idevice.label.clone().into()); + req.insert("Request".into(), "SetValue".into()); + req.insert("Key".into(), key.into()); + req.insert("Value".into(), value); + + if let Some(domain) = domain { + req.insert("Domain".into(), domain.into()); + } + + self.idevice + .send_plist(plist::Value::Dictionary(req)) + .await?; + self.idevice.read_plist().await?; + + Ok(()) + } + /// Starts a secure TLS session with the device /// /// # Arguments