Commit 241f2656 authored by topjohnwu's avatar topjohnwu

Prepare for public release

parent e973d495
package com.topjohnwu.magisk.core package com.topjohnwu.magisk.core
import android.os.Process import android.os.Process
import com.topjohnwu.magisk.BuildConfig
object Const { object Const {
...@@ -26,9 +25,10 @@ object Const { ...@@ -26,9 +25,10 @@ object Const {
const val MIN_VERSION = "v19.0" const val MIN_VERSION = "v19.0"
const val MIN_VERCODE = 19000 const val MIN_VERCODE = 19000
fun atLeast_20_2() = Info.env.magiskVersionCode >= 20200 fun atLeast_20_2() = Info.env.magiskVersionCode >= 20200 || isCanary()
fun atLeast_20_4() = Info.env.magiskVersionCode >= 20400 fun atLeast_20_4() = Info.env.magiskVersionCode >= 20400 || isCanary()
fun atLeastCanary() = Info.env.magiskVersionCode > BuildConfig.LATEST_MAGISK / 100 * 100 fun atLeast_21_0() = Info.env.magiskVersionCode >= 21000 || isCanary()
fun isCanary() = Info.env.magiskVersionCode % 100 != 0
} }
object ID { object ID {
......
...@@ -67,7 +67,7 @@ class SuRequestHandler( ...@@ -67,7 +67,7 @@ class SuRequestHandler(
private suspend fun init(intent: Intent) = withContext(Dispatchers.IO) { private suspend fun init(intent: Intent) = withContext(Dispatchers.IO) {
try { try {
val uid: Int val uid: Int
if (Const.Version.atLeastCanary()) { if (Const.Version.atLeast_21_0()) {
val name = intent.getStringExtra("fifo") ?: throw SuRequestError() val name = intent.getStringExtra("fifo") ?: throw SuRequestError()
uid = intent.getIntExtra("uid", -1).also { if (it < 0) throw SuRequestError() } uid = intent.getIntExtra("uid", -1).also { if (it < 0) throw SuRequestError() }
output = DataOutputStream(FileOutputStream(name).buffered()) output = DataOutputStream(FileOutputStream(name).buffered())
......
...@@ -25,7 +25,7 @@ class RootInit : Shell.Initializer() { ...@@ -25,7 +25,7 @@ class RootInit : Shell.Initializer() {
} else { } else {
add("export MAGISKTMP=/sbin/.magisk") add("export MAGISKTMP=/sbin/.magisk")
} }
if (Const.Version.atLeastCanary()) { if (Const.Version.atLeast_21_0()) {
add("export ASH_STANDALONE=1") add("export ASH_STANDALONE=1")
add("[ -x /data/adb/magisk/busybox ] && exec /data/adb/magisk/busybox sh") add("[ -x /data/adb/magisk/busybox ] && exec /data/adb/magisk/busybox sh")
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment