mirror of
https://github.com/topjohnwu/Magisk.git
synced 2026-01-15 06:14:04 -08:00
Properly detect advanced device info
This commit is contained in:
@@ -24,12 +24,15 @@ object Info {
|
||||
@JvmStatic
|
||||
var stub: DynAPK.Data? = null // Stub
|
||||
|
||||
@JvmStatic
|
||||
var keepVerity = false
|
||||
@JvmStatic
|
||||
var keepEnc = false
|
||||
@JvmStatic
|
||||
var recovery = false
|
||||
// Toggle-able options
|
||||
@JvmStatic var keepVerity = false
|
||||
@JvmStatic var keepEnc = false
|
||||
@JvmStatic var recovery = false
|
||||
|
||||
// Immutable device state
|
||||
@JvmStatic var isSAR = false
|
||||
@JvmStatic var isAB = false
|
||||
@JvmStatic var ramdisk = false
|
||||
|
||||
val isConnected by lazy {
|
||||
KObservableField(false).also { field ->
|
||||
|
||||
@@ -26,17 +26,20 @@ class RootInit : Shell.Initializer() {
|
||||
}
|
||||
|
||||
job.add(
|
||||
"export BOOTMODE=true",
|
||||
"mount_partitions",
|
||||
"get_flags",
|
||||
"run_migrations",
|
||||
"export BOOTMODE=true"
|
||||
"run_migrations"
|
||||
).exec()
|
||||
|
||||
fun getvar(name: String) = ShellUtils.fastCmd(shell, "echo \$$name").toBoolean()
|
||||
|
||||
Info.keepVerity = getvar("KEEPVERITY")
|
||||
Info.keepEnc = getvar("KEEPFORCEENCRYPT")
|
||||
Info.isSAR = getvar("SYSTEM_ROOT")
|
||||
Info.ramdisk = shell.newJob().add("check_boot_ramdisk").exec().isSuccess
|
||||
Info.recovery = getvar("RECOVERYMODE")
|
||||
Info.isAB = getvar("ISAB")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -38,10 +38,8 @@ import com.topjohnwu.magisk.core.utils.Utils
|
||||
import com.topjohnwu.magisk.core.utils.currentLocale
|
||||
import com.topjohnwu.magisk.utils.DynamicClassLoader
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import com.topjohnwu.superuser.ShellUtils
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.lang.reflect.Array as JArray
|
||||
|
||||
val packageName: String get() = get<Context>().packageName
|
||||
@@ -320,20 +318,6 @@ fun Context.hasPermissions(vararg permissions: String) = permissions.all {
|
||||
ContextCompat.checkSelfPermission(this, it) == PERMISSION_GRANTED
|
||||
}
|
||||
|
||||
private val securityLevelFormatter get() = SimpleDateFormat("yyyy-MM-dd",
|
||||
currentLocale
|
||||
)
|
||||
|
||||
val isSAR
|
||||
get() = ShellUtils
|
||||
.fastCmd("grep_prop ro.build.system_root_image")
|
||||
.let { it.isNotEmpty() && it.toBoolean() }
|
||||
|
||||
val isAB
|
||||
get() = ShellUtils
|
||||
.fastCmd("grep_prop ro.build.ab_update")
|
||||
.let { it.isNotEmpty() && it.toBoolean() }
|
||||
|
||||
fun Activity.hideKeyboard() {
|
||||
val view = currentFocus ?: return
|
||||
getSystemService<InputMethodManager>()
|
||||
|
||||
Reference in New Issue
Block a user