Update all hardcode paths in app and script

This commit is contained in:
topjohnwu
2020-04-05 01:27:07 -07:00
parent 47d18bb896
commit 93aedcfeb7
5 changed files with 38 additions and 27 deletions

View File

@@ -6,7 +6,8 @@ import java.io.File
object Const {
// Paths
const val MAGISK_PATH = "/sbin/.magisk/modules"
lateinit var MAGISKTMP: String
val MAGISK_PATH get() = "$MAGISKTMP/modules"
var MAGISK_DISABLE_FILE = File("xxx")
const val TMP_FOLDER_PATH = "/dev/tmp"
const val MAGISK_LOG = "/cache/magisk.log"
@@ -25,8 +26,8 @@ object Const {
object Version {
const val MIN_VERSION = "v19.0"
const val MIN_VERCODE = 19000
const val CONNECT_MODE = 20100
const val PROVIDER_CONNECT = 20102
const val PROVIDER_CONNECT = 20200
const val DYNAMIC_PATH = 20400
}
object ID {

View File

@@ -62,7 +62,7 @@ class Module(path: String) : BaseModule() {
companion object {
private const val PERSIST = "/sbin/.magisk/mirror/persist/magisk"
private val PERSIST get() = "${Const.MAGISKTMP}/mirror/persist/magisk"
@WorkerThread
fun loadModules(): List<Module> {

View File

@@ -18,22 +18,20 @@ class RootInit : Shell.Initializer() {
fun init(context: Context, shell: Shell): Boolean {
val job = shell.newJob()
if (Info.env.magiskVersionCode >= Const.Version.DYNAMIC_PATH)
job.add("MAGISKTMP=$(magisk --path)/.magisk")
else
job.add("MAGISKTMP=/sbin/.magisk")
job.add(context.rawResource(R.raw.manager))
if (shell.isRoot) {
job.add(context.rawResource(R.raw.util_functions))
.add("SHA1=`grep_prop SHA1 /sbin/.magisk/config`")
Const.MAGISK_DISABLE_FILE = SuFile("/cache/.disable_magisk")
}
job.add(
"export BOOTMODE=true",
"mount_partitions",
"get_flags",
"run_migrations"
).exec()
job.add("mm_init").exec()
fun getvar(name: String) = ShellUtils.fastCmd(shell, "echo \$$name").toBoolean()
Const.MAGISKTMP = ShellUtils.fastCmd(shell, "echo \$MAGISKTMP")
Info.keepVerity = getvar("KEEPVERITY")
Info.keepEnc = getvar("KEEPFORCEENCRYPT")
Info.isSAR = getvar("SYSTEM_ROOT")