mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 22:46:14 +01:00
Add missing amfi actions
This commit is contained in:
@@ -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),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user