You've already forked ReZygisk
mirror of
https://github.com/PerformanC/ReZygisk.git
synced 2025-09-06 06:37:01 +00:00
add: support for APatch reset su path (#26)
This commit allows proper root detection when using multiple root solutions. Co-authored-by: Admire <43035036+Admirepowered@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
4b7178f1ea
commit
f1fe6b4435
@@ -1,5 +1,6 @@
|
|||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
use std::io::{self, BufRead, BufReader};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use crate::constants::MIN_APATCH_VERSION;
|
use crate::constants::MIN_APATCH_VERSION;
|
||||||
|
|
||||||
@@ -8,6 +9,7 @@ pub enum Version {
|
|||||||
TooOld,
|
TooOld,
|
||||||
Abnormal,
|
Abnormal,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_version(output: &str) -> i32 {
|
fn parse_version(output: &str) -> i32 {
|
||||||
let mut version: Option<i32> = None;
|
let mut version: Option<i32> = None;
|
||||||
for line in output.lines() {
|
for line in output.lines() {
|
||||||
@@ -21,7 +23,29 @@ fn parse_version(output: &str) -> i32 {
|
|||||||
version.unwrap_or_default()
|
version.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn read_su_path() -> Result<String, io::Error> {
|
||||||
|
let file = File::open("/data/adb/ap/su_path")?;
|
||||||
|
let mut reader = BufReader::new(file);
|
||||||
|
let mut su_path = String::new();
|
||||||
|
reader.read_line(&mut su_path)?;
|
||||||
|
Ok(su_path.trim().to_string())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_apatch() -> Option<Version> {
|
pub fn get_apatch() -> Option<Version> {
|
||||||
|
let default_su_path = String::from("/system/bin/su");
|
||||||
|
let su_path = read_su_path().ok()?;
|
||||||
|
|
||||||
|
let output = Command::new(&su_path)
|
||||||
|
.arg("-v")
|
||||||
|
.stdout(Stdio::piped())
|
||||||
|
.stderr(Stdio::null())
|
||||||
|
.output()
|
||||||
|
.ok()?;
|
||||||
|
let stdout = String::from_utf8(output.stdout).ok()?;
|
||||||
|
if !stdout.contains("APatch") {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let output1 = Command::new("/data/adb/apd")
|
let output1 = Command::new("/data/adb/apd")
|
||||||
.arg("-V")
|
.arg("-V")
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
@@ -29,13 +53,17 @@ pub fn get_apatch() -> Option<Version> {
|
|||||||
.output()
|
.output()
|
||||||
.ok()?;
|
.ok()?;
|
||||||
let stdout1 = String::from_utf8(output1.stdout).ok()?;
|
let stdout1 = String::from_utf8(output1.stdout).ok()?;
|
||||||
let version = parse_version(&stdout1);
|
if su_path == default_su_path {
|
||||||
const MAX_OLD_VERSION: i32 = MIN_APATCH_VERSION - 1;
|
let version = parse_version(&stdout1);
|
||||||
match version {
|
const MAX_OLD_VERSION: i32 = MIN_APATCH_VERSION - 1;
|
||||||
0 => Some(Version::Abnormal),
|
match version {
|
||||||
v if v >= MIN_APATCH_VERSION && v <= 999999 => Some(Version::Supported),
|
0 => Some(Version::Abnormal),
|
||||||
v if v >= 1 && v <= MAX_OLD_VERSION => Some(Version::TooOld),
|
v if v >= MIN_APATCH_VERSION && v <= 999999 => Some(Version::Supported),
|
||||||
_ => None,
|
v if v >= 1 && v <= MAX_OLD_VERSION => Some(Version::TooOld),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user