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;
|
use subprocess::Exec;
|
||||||
|
|
||||||
pub fn mount_image(src: &str, target: &str) -> Result<()> {
|
pub fn mount_image(src: &str, target: &str) -> Result<()> {
|
||||||
@@ -21,4 +24,17 @@ pub fn ensure_clean_dir(dir: &str) -> Result<()> {
|
|||||||
std::fs::remove_dir_all(path)?;
|
std::fs::remove_dir_all(path)?;
|
||||||
}
|
}
|
||||||
Ok(std::fs::create_dir_all(path)?)
|
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