mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-19 22:38:28 +00:00
Refactor sepolicy.rules resolve app
This commit is contained in:
parent
362eea741f
commit
84e1bd7bc3
@ -10,7 +10,7 @@ import com.topjohnwu.magisk.ui.home.HomeViewModel
|
||||
import com.topjohnwu.magisk.view.MagiskDialog
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class EnvFixDialog(private val vm: HomeViewModel) : DialogEvent() {
|
||||
class EnvFixDialog(private val vm: HomeViewModel, private val code: Int) : DialogEvent() {
|
||||
|
||||
override fun build(dialog: MagiskDialog) {
|
||||
dialog.apply {
|
||||
@ -38,8 +38,10 @@ class EnvFixDialog(private val vm: HomeViewModel) : DialogEvent() {
|
||||
}
|
||||
}
|
||||
|
||||
if (Info.env.versionCode != BuildConfig.VERSION_CODE ||
|
||||
if (code == 2 || // No rules block, module policy not loaded
|
||||
Info.env.versionCode != BuildConfig.VERSION_CODE ||
|
||||
Info.env.versionString != BuildConfig.VERSION_NAME) {
|
||||
dialog.setMessage(R.string.env_full_fix_msg)
|
||||
dialog.setButton(MagiskDialog.ButtonType.POSITIVE) {
|
||||
text = android.R.string.ok
|
||||
onClick {
|
||||
|
@ -135,8 +135,9 @@ class HomeViewModel(
|
||||
private suspend fun ensureEnv() {
|
||||
if (magiskState == State.INVALID || checkedEnv) return
|
||||
val cmd = "env_check ${Info.env.versionString} ${Info.env.versionCode}"
|
||||
if (!Shell.cmd(cmd).await().isSuccess) {
|
||||
EnvFixDialog(this).publish()
|
||||
val code = Shell.cmd(cmd).await().code
|
||||
if (code != 0) {
|
||||
EnvFixDialog(this, code).publish()
|
||||
}
|
||||
checkedEnv = true
|
||||
}
|
||||
|
@ -13,8 +13,11 @@ env_check() {
|
||||
if [ "$2" -ge 25000 ]; then
|
||||
[ -f "$MAGISKBIN/magiskpolicy" ] || return 1
|
||||
fi
|
||||
grep -xqF "MAGISK_VER='$1'" "$MAGISKBIN/util_functions.sh" || return 1
|
||||
grep -xqF "MAGISK_VER_CODE=$2" "$MAGISKBIN/util_functions.sh" || return 1
|
||||
if [ "$2" -ge 25210 ]; then
|
||||
[ -b "$MAGISKTMP/block/rules" ] || return 2
|
||||
fi
|
||||
grep -xqF "MAGISK_VER='$1'" "$MAGISKBIN/util_functions.sh" || return 3
|
||||
grep -xqF "MAGISK_VER_CODE=$2" "$MAGISKBIN/util_functions.sh" || return 3
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -41,7 +44,7 @@ fix_env() {
|
||||
rm -rf $MAGISKBIN/*
|
||||
mkdir -p $MAGISKBIN 2>/dev/null
|
||||
chmod 700 $NVBASE
|
||||
rm $1/stub.apk
|
||||
rm $1/stub.apk 2>/dev/null
|
||||
cp_readlink $1 $MAGISKBIN
|
||||
rm -rf $1
|
||||
chown -R 0:0 $MAGISKBIN
|
||||
|
@ -219,6 +219,7 @@
|
||||
<string name="setup_fail">Setup failed</string>
|
||||
<string name="env_fix_title">Requires Additional Setup</string>
|
||||
<string name="env_fix_msg">Your device needs additional setup for Magisk to work properly. Do you want to proceed and reboot?</string>
|
||||
<string name="env_full_fix_msg">Your device needs reflash Magisk to work properly. Please reinstall Magisk within app, recovery mode cannot get correct device info.</string>
|
||||
<string name="setup_msg">Running environment setup…</string>
|
||||
<string name="authenticate">Authenticate</string>
|
||||
<string name="unsupport_magisk_title">Unsupported Magisk Version</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user