Move copy_sepolicy_rules to manager

We don’t need it when patch boot
This commit is contained in:
vvb2060 2020-12-19 13:58:53 -08:00 committed by topjohnwu
parent eee7f097e3
commit 984f32f994
2 changed files with 12 additions and 6 deletions

View File

@ -10,6 +10,7 @@ import androidx.core.os.postDelayed
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.core.Config
import com.topjohnwu.magisk.core.Info
import com.topjohnwu.magisk.core.utils.MediaStoreUtils
import com.topjohnwu.magisk.core.utils.MediaStoreUtils.inputStream
import com.topjohnwu.magisk.core.utils.MediaStoreUtils.outputStream
@ -339,6 +340,13 @@ abstract class MagiskInstallImpl : KoinComponent {
return true
}
private fun copySepolicyRules(): Boolean {
if (Info.remote.magisk.versionCode >= 21100) return true
// Copy existing rules for migration
"copy_sepolicy_rules".sh()
return true
}
private fun flashBoot(): Boolean {
if (!"direct_install $installDir $srcBoot".sh().isSuccess)
return false
@ -373,10 +381,11 @@ abstract class MagiskInstallImpl : KoinComponent {
protected fun doPatchFile(patchFile: Uri) = extractZip() && handleFile(patchFile)
protected fun direct() = findImage() && extractZip() && patchBoot() && flashBoot()
protected fun direct() = findImage() && extractZip() && patchBoot() &&
copySepolicyRules() && flashBoot()
protected suspend fun secondSlot() =
findSecondaryImage() && extractZip() && patchBoot() && flashBoot() && postOTA()
protected suspend fun secondSlot() = findSecondaryImage() && extractZip() &&
patchBoot() && copySepolicyRules() && flashBoot() && postOTA()
protected fun fixEnv(zip: Uri): Boolean {
installDir = SuFile("/data/adb/magisk")

View File

@ -185,8 +185,5 @@ ui_print "- Repacking boot image"
# Sign chromeos boot
$CHROMEOS && sign_chromeos
# Copy existing rules for migration
$BOOTMODE && copy_sepolicy_rules
# Reset any error code
true