From 4059e47a6ea466f68197d0cb239f38925c30fc4e Mon Sep 17 00:00:00 2001 From: Jackson Coxson Date: Wed, 2 Jul 2025 19:47:47 -0600 Subject: [PATCH] Add missing amfi actions --- idevice/src/services/amfi.rs | 40 ++++++++++++++++++++++++++++++++++++ tools/src/amfi.rs | 14 +++++++++++++ 2 files changed, 54 insertions(+) diff --git a/idevice/src/services/amfi.rs b/idevice/src/services/amfi.rs index f4be150..1997290 100644 --- a/idevice/src/services/amfi.rs +++ b/idevice/src/services/amfi.rs @@ -111,4 +111,44 @@ impl AmfiClient { Err(IdeviceError::UnexpectedResponse) } } + + /// Gets the developer mode status + pub async fn get_developer_mode_status(&mut self) -> Result { + let mut request = Dictionary::new(); + request.insert("action".into(), 3.into()); + self.idevice + .send_plist(plist::Value::Dictionary(request)) + .await?; + + let res = self.idevice.read_plist().await?; + match res.get("success").and_then(|x| x.as_boolean()) { + Some(true) => (), + _ => return Err(IdeviceError::UnexpectedResponse), + } + + match res.get("status").and_then(|x| x.as_boolean()) { + Some(b) => Ok(b), + _ => Err(IdeviceError::UnexpectedResponse), + } + } + + /// Gets the developer mode status + pub async fn get_sep_device_state(&mut self) -> Result { + let mut request = Dictionary::new(); + request.insert("action".into(), 4.into()); + self.idevice + .send_plist(plist::Value::Dictionary(request)) + .await?; + + let res = self.idevice.read_plist().await?; + match res.get("success").and_then(|x| x.as_boolean()) { + Some(true) => (), + _ => return Err(IdeviceError::UnexpectedResponse), + } + + match res.get("status").and_then(|x| x.as_boolean()) { + Some(b) => Ok(b), + _ => Err(IdeviceError::UnexpectedResponse), + } + } } diff --git a/tools/src/amfi.rs b/tools/src/amfi.rs index be1d594..2276ff5 100644 --- a/tools/src/amfi.rs +++ b/tools/src/amfi.rs @@ -38,6 +38,8 @@ async fn main() { .subcommand(Command::new("show").about("Shows the developer mode option in settings")) .subcommand(Command::new("enable").about("Enables developer mode")) .subcommand(Command::new("accept").about("Shows the accept dialogue for developer mode")) + .subcommand(Command::new("status").about("Gets the developer mode status")) + .subcommand(Command::new("state").about("Gets the device SEP state")) .get_matches(); if matches.get_flag("about") { @@ -77,6 +79,18 @@ async fn main() { .accept_developer_mode() .await .expect("Failed to show"); + } else if matches.subcommand_matches("status").is_some() { + let status = amfi_client + .get_developer_mode_status() + .await + .expect("Failed to get status"); + println!("Enabled: {status}"); + } else if matches.subcommand_matches("state").is_some() { + let status = amfi_client + .get_sep_device_state() + .await + .expect("Failed to get state"); + println!("Enabled: {status}"); } else { eprintln!("Invalid usage, pass -h for help"); }