ksud: add is_safe_mode
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
use std::path::Path;
|
||||
use std::{
|
||||
path::Path,
|
||||
process::{Command, Stdio},
|
||||
};
|
||||
|
||||
use anyhow::{Result, ensure};
|
||||
use anyhow::{ensure, Result};
|
||||
use subprocess::Exec;
|
||||
|
||||
pub fn mount_image(src: &str, target: &str) -> Result<()> {
|
||||
@@ -22,3 +25,16 @@ pub fn ensure_clean_dir(dir: &str) -> Result<()> {
|
||||
}
|
||||
Ok(std::fs::create_dir_all(path)?)
|
||||
}
|
||||
|
||||
pub fn getprop(prop: &str) -> Result<String> {
|
||||
let output = Command::new("getprop")
|
||||
.arg(prop)
|
||||
.stdout(Stdio::piped())
|
||||
.output()?;
|
||||
let output = String::from_utf8_lossy(&output.stdout);
|
||||
Ok(output.trim().to_string())
|
||||
}
|
||||
|
||||
pub fn is_safe_mode() -> Result<bool> {
|
||||
Ok(getprop("persist.sys.safemode")?.eq("1") || getprop("ro.sys.safemode")?.eq("1"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user