Manually trigger broadcast tests if necessary
This commit is contained in:
parent
a18c552ddf
commit
71136d7347
@ -22,8 +22,9 @@ object Const {
|
|||||||
const val MANAGER_CONFIGS = ".tmp.magisk.config"
|
const val MANAGER_CONFIGS = ".tmp.magisk.config"
|
||||||
val USER_ID = Process.myUid() / 100000
|
val USER_ID = Process.myUid() / 100000
|
||||||
|
|
||||||
object MagiskVersion {
|
object Version {
|
||||||
const val MIN_SUPPORT = 18000
|
const val MIN_SUPPORT = 18000
|
||||||
|
const val CONNECT_MODE = 20002
|
||||||
}
|
}
|
||||||
|
|
||||||
object ID {
|
object ID {
|
||||||
|
@ -20,13 +20,17 @@ object Info {
|
|||||||
val str = ShellUtils.fastCmd("magisk -v").split(":".toRegex())[0]
|
val str = ShellUtils.fastCmd("magisk -v").split(":".toRegex())[0]
|
||||||
val code = ShellUtils.fastCmd("magisk -V").toInt()
|
val code = ShellUtils.fastCmd("magisk -V").toInt()
|
||||||
val hide = Shell.su("magiskhide --status").exec().isSuccess
|
val hide = Shell.su("magiskhide --status").exec().isSuccess
|
||||||
Env(code, str, hide)
|
var mode = Int.MAX_VALUE
|
||||||
|
if (code >= Const.Version.CONNECT_MODE)
|
||||||
|
mode = Shell.su("magisk --connect-mode").exec().code
|
||||||
|
Env(code, str, hide, mode)
|
||||||
}.getOrElse { Env() }
|
}.getOrElse { Env() }
|
||||||
|
|
||||||
class Env(
|
class Env(
|
||||||
val magiskVersionCode: Int = -1,
|
val magiskVersionCode: Int = -1,
|
||||||
val magiskVersionString: String = "",
|
val magiskVersionString: String = "",
|
||||||
hide: Boolean = false
|
hide: Boolean = false,
|
||||||
|
var connectionMode: Int = Int.MAX_VALUE
|
||||||
) {
|
) {
|
||||||
val magiskHide get() = Config.magiskHide
|
val magiskHide get() = Config.magiskHide
|
||||||
|
|
||||||
|
@ -79,6 +79,8 @@ open class GeneralReceiver : BaseReceiver() {
|
|||||||
NOTIFY -> SuLogger.handleNotify(context, intent)
|
NOTIFY -> SuLogger.handleNotify(context, intent)
|
||||||
TEST -> {
|
TEST -> {
|
||||||
val mode = intent.getIntExtra("mode", 1 shl 1)
|
val mode = intent.getIntExtra("mode", 1 shl 1)
|
||||||
|
if (mode > Info.env.connectionMode)
|
||||||
|
Info.env.connectionMode = mode
|
||||||
Shell.su("magisk --connect-mode $mode").submit()
|
Shell.su("magisk --connect-mode $mode").submit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ open class SplashActivity : Activity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
Shell.getShell {
|
Shell.getShell {
|
||||||
if (Info.env.magiskVersionCode > 0 && Info.env.magiskVersionCode < Const.MagiskVersion.MIN_SUPPORT) {
|
if (Info.env.magiskVersionCode > 0 && Info.env.magiskVersionCode < Const.Version.MIN_SUPPORT) {
|
||||||
AlertDialog.Builder(this)
|
AlertDialog.Builder(this)
|
||||||
.setTitle(R.string.unsupport_magisk_title)
|
.setTitle(R.string.unsupport_magisk_title)
|
||||||
.setMessage(R.string.unsupport_magisk_message)
|
.setMessage(R.string.unsupport_magisk_message)
|
||||||
|
@ -17,6 +17,9 @@ class RootInit : Shell.Initializer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun init(context: Context, shell: Shell): Boolean {
|
fun init(context: Context, shell: Shell): Boolean {
|
||||||
|
// Invalidate env state if shell is recreated
|
||||||
|
Info.envRef.invalidate()
|
||||||
|
|
||||||
val job = shell.newJob()
|
val job = shell.newJob()
|
||||||
if (shell.isRoot) {
|
if (shell.isRoot) {
|
||||||
job.add(context.rawResource(R.raw.util_functions))
|
job.add(context.rawResource(R.raw.util_functions))
|
||||||
@ -35,6 +38,12 @@ class RootInit : Shell.Initializer() {
|
|||||||
Info.keepVerity = ShellUtils.fastCmd("echo \$KEEPVERITY").toBoolean()
|
Info.keepVerity = ShellUtils.fastCmd("echo \$KEEPVERITY").toBoolean()
|
||||||
Info.keepEnc = ShellUtils.fastCmd("echo \$KEEPFORCEENCRYPT").toBoolean()
|
Info.keepEnc = ShellUtils.fastCmd("echo \$KEEPFORCEENCRYPT").toBoolean()
|
||||||
Info.recovery = ShellUtils.fastCmd("echo \$RECOVERYMODE").toBoolean()
|
Info.recovery = ShellUtils.fastCmd("echo \$RECOVERYMODE").toBoolean()
|
||||||
|
|
||||||
|
if (Info.env.connectionMode == 0) {
|
||||||
|
// Manually trigger broadcast test
|
||||||
|
Shell.su("magisk --broadcast-test").exec()
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user