|
|
@ -38,8 +38,8 @@ class InstallerInitializer : Shell.Initializer() {
|
|
|
|
const val ERROR_NO_PATH = 1
|
|
|
|
const val ERROR_NO_PATH = 1
|
|
|
|
const val ERROR_NO_SU = 2
|
|
|
|
const val ERROR_NO_SU = 2
|
|
|
|
const val ERROR_OTHER = 3
|
|
|
|
const val ERROR_OTHER = 3
|
|
|
|
|
|
|
|
private var tries = 0
|
|
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
|
|
|
val errorNotification: NotificationType?
|
|
|
|
val errorNotification: NotificationType?
|
|
|
|
get() {
|
|
|
|
get() {
|
|
|
|
val hasRoot = Shell.isAppGrantedRoot()
|
|
|
|
val hasRoot = Shell.isAppGrantedRoot()
|
|
|
@ -56,7 +56,6 @@ class InstallerInitializer : Shell.Initializer() {
|
|
|
|
return NotificationType.NO_ROOT
|
|
|
|
return NotificationType.NO_ROOT
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
|
|
|
fun peekMagiskPath(): String? {
|
|
|
|
fun peekMagiskPath(): String? {
|
|
|
|
return mgskPth
|
|
|
|
return mgskPth
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -74,23 +73,18 @@ class InstallerInitializer : Shell.Initializer() {
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* For read/write only "/data/adb/modules" should be used
|
|
|
|
* For read/write only "/data/adb/modules" should be used
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@JvmStatic
|
|
|
|
|
|
|
|
fun peekModulesPath(): String? {
|
|
|
|
fun peekModulesPath(): String? {
|
|
|
|
return if (mgskPth == null) null else "$mgskPth/.magisk/modules"
|
|
|
|
return if (mgskPth == null) null else "$mgskPth/.magisk/modules"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
|
|
|
fun peekMagiskVersion(): Int {
|
|
|
|
fun peekMagiskVersion(): Int {
|
|
|
|
return mgskVerCode
|
|
|
|
return mgskVerCode
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
|
|
|
fun peekHasRamdisk(): Boolean {
|
|
|
|
fun peekHasRamdisk(): Boolean {
|
|
|
|
return hsRmdsk
|
|
|
|
return hsRmdsk
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
|
|
|
@JvmOverloads
|
|
|
|
|
|
|
|
fun tryGetMagiskPathAsync(callback: Callback, forceCheck: Boolean = false) {
|
|
|
|
fun tryGetMagiskPathAsync(callback: Callback, forceCheck: Boolean = false) {
|
|
|
|
val mgskPth = mgskPth
|
|
|
|
val mgskPth = mgskPth
|
|
|
|
val thread: Thread = object : Thread("Magisk GetPath Thread") {
|
|
|
|
val thread: Thread = object : Thread("Magisk GetPath Thread") {
|
|
|
@ -135,6 +129,7 @@ class InstallerInitializer : Shell.Initializer() {
|
|
|
|
var hsRmdsk = hsRmdsk
|
|
|
|
var hsRmdsk = hsRmdsk
|
|
|
|
if (mgskPth != null && !forceCheck) return mgskPth
|
|
|
|
if (mgskPth != null && !forceCheck) return mgskPth
|
|
|
|
val output = ArrayList<String>()
|
|
|
|
val output = ArrayList<String>()
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (!Shell.cmd(
|
|
|
|
if (!Shell.cmd(
|
|
|
|
"if grep ' / ' /proc/mounts | grep -q '/dev/root' &> /dev/null; " +
|
|
|
|
"if grep ' / ' /proc/mounts | grep -q '/dev/root' &> /dev/null; " +
|
|
|
|
"then echo true; else echo false; fi", "magisk -V", "magisk --path"
|
|
|
|
"then echo true; else echo false; fi", "magisk -V", "magisk --path"
|
|
|
@ -168,6 +163,14 @@ class InstallerInitializer : Shell.Initializer() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Companion.mgskVerCode = mgskVerCode
|
|
|
|
Companion.mgskVerCode = mgskVerCode
|
|
|
|
return mgskPth
|
|
|
|
return mgskPth
|
|
|
|
|
|
|
|
} catch (ignored: Exception) {
|
|
|
|
|
|
|
|
if (tries < 5) {
|
|
|
|
|
|
|
|
tries++
|
|
|
|
|
|
|
|
return tryGetMagiskPath(true)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return null
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|