Add missing amfi actions

This commit is contained in:
Jackson Coxson
2025-07-02 19:47:47 -06:00
parent 2d9259f996
commit 4059e47a6e
2 changed files with 54 additions and 0 deletions

View File

@@ -111,4 +111,44 @@ impl AmfiClient {
Err(IdeviceError::UnexpectedResponse) Err(IdeviceError::UnexpectedResponse)
} }
} }
/// Gets the developer mode status
pub async fn get_developer_mode_status(&mut self) -> Result<bool, IdeviceError> {
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<bool, IdeviceError> {
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),
}
}
} }

View File

@@ -38,6 +38,8 @@ async fn main() {
.subcommand(Command::new("show").about("Shows the developer mode option in settings")) .subcommand(Command::new("show").about("Shows the developer mode option in settings"))
.subcommand(Command::new("enable").about("Enables developer mode")) .subcommand(Command::new("enable").about("Enables developer mode"))
.subcommand(Command::new("accept").about("Shows the accept dialogue for 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(); .get_matches();
if matches.get_flag("about") { if matches.get_flag("about") {
@@ -77,6 +79,18 @@ async fn main() {
.accept_developer_mode() .accept_developer_mode()
.await .await
.expect("Failed to show"); .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 { } else {
eprintln!("Invalid usage, pass -h for help"); eprintln!("Invalid usage, pass -h for help");
} }