Tone down our DTB patching
- Do not attempt to patch DTB anywhere outside of boot images as they are no longer essential. This makes Magisk installation to only modify strictly boot/recovery partitions again. - The only required patch for DTB is to strip verity out of partitions
This commit is contained in:
parent
02dc1172be
commit
85755e3022
@ -5,7 +5,6 @@ import android.content.Context
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import com.topjohnwu.magisk.BuildConfig
|
import com.topjohnwu.magisk.BuildConfig
|
||||||
import com.topjohnwu.magisk.R
|
import com.topjohnwu.magisk.R
|
||||||
import com.topjohnwu.magisk.core.tasks.patchDTB
|
|
||||||
import com.topjohnwu.magisk.core.utils.Utils
|
import com.topjohnwu.magisk.core.utils.Utils
|
||||||
import com.topjohnwu.magisk.core.view.Notifications
|
import com.topjohnwu.magisk.core.view.Notifications
|
||||||
import com.topjohnwu.magisk.core.view.Shortcuts
|
import com.topjohnwu.magisk.core.view.Shortcuts
|
||||||
@ -48,9 +47,6 @@ open class SplashActivity : Activity() {
|
|||||||
Utils.scheduleUpdateCheck(this)
|
Utils.scheduleUpdateCheck(this)
|
||||||
Shortcuts.setup(this)
|
Shortcuts.setup(this)
|
||||||
|
|
||||||
// Patch DTB partitions if needed
|
|
||||||
patchDTB(this)
|
|
||||||
|
|
||||||
// Pre-fetch network stuffs
|
// Pre-fetch network stuffs
|
||||||
get<GithubRawServices>()
|
get<GithubRawServices>()
|
||||||
|
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
package com.topjohnwu.magisk.core.tasks
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.ContextWrapper
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.IntentFilter
|
|
||||||
import com.topjohnwu.magisk.core.Const
|
|
||||||
import com.topjohnwu.magisk.core.Info
|
|
||||||
import com.topjohnwu.magisk.core.base.BaseReceiver
|
|
||||||
import com.topjohnwu.magisk.core.view.Notifications
|
|
||||||
import com.topjohnwu.superuser.Shell
|
|
||||||
import timber.log.Timber
|
|
||||||
|
|
||||||
private const val DTB_PATCH_RESULT = "dtb_result"
|
|
||||||
private const val DTB_PATCH_ACTION = "com.topjohnwu.magisk.DTBO_PATCH"
|
|
||||||
|
|
||||||
private class DTBPatchReceiver : BaseReceiver() {
|
|
||||||
override fun onReceive(context: ContextWrapper, intent: Intent?) {
|
|
||||||
intent?.also {
|
|
||||||
val result = it.getIntExtra(DTB_PATCH_RESULT, 1)
|
|
||||||
Timber.d("result=[$result]")
|
|
||||||
if (result == 0)
|
|
||||||
Notifications.dtboPatched(context)
|
|
||||||
}
|
|
||||||
context.unregisterReceiver(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun patchDTB(context: Context) {
|
|
||||||
if (Info.isNewReboot) {
|
|
||||||
val c = context.applicationContext
|
|
||||||
c.registerReceiver(DTBPatchReceiver(), IntentFilter(DTB_PATCH_ACTION))
|
|
||||||
val broadcastCmd = "am broadcast --user ${Const.USER_ID} -p ${c.packageName} " +
|
|
||||||
"-a $DTB_PATCH_ACTION --ei $DTB_PATCH_RESULT \$result"
|
|
||||||
Shell.su("mm_patch_dtb '$broadcastCmd'").submit()
|
|
||||||
}
|
|
||||||
}
|
|
@ -287,10 +287,7 @@ abstract class MagiskInstallImpl : FlashResultListener {
|
|||||||
private fun flashBoot(): Boolean {
|
private fun flashBoot(): Boolean {
|
||||||
if (!"direct_install $installDir $srcBoot".sh().isSuccess)
|
if (!"direct_install $installDir $srcBoot".sh().isSuccess)
|
||||||
return false
|
return false
|
||||||
arrayOf(
|
arrayOf("run_migrations").sh()
|
||||||
"(KEEPVERITY=${Info.keepVerity} patch_dtb_partitions)",
|
|
||||||
"run_migrations"
|
|
||||||
).sh()
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,32 +85,6 @@ object Notifications {
|
|||||||
mgr.notify(Const.ID.APK_UPDATE_NOTIFICATION_ID, builder.build())
|
mgr.notify(Const.ID.APK_UPDATE_NOTIFICATION_ID, builder.build())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun dtboPatched(context: Context) {
|
|
||||||
val intent = context.intent<GeneralReceiver>()
|
|
||||||
.setAction(Const.Key.BROADCAST_REBOOT)
|
|
||||||
val pendingIntent = PendingIntent.getBroadcast(context,
|
|
||||||
Const.ID.DTBO_NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
|
||||||
|
|
||||||
val builder = updateBuilder(
|
|
||||||
context
|
|
||||||
)
|
|
||||||
.setContentTitle(context.getString(R.string.dtbo_patched_title))
|
|
||||||
.setContentText(context.getString(R.string.dtbo_patched_reboot))
|
|
||||||
|
|
||||||
if (SDK_INT >= 23) {
|
|
||||||
val action = Notification.Action.Builder(
|
|
||||||
context.getBitmap(R.drawable.ic_refresh).toIcon(),
|
|
||||||
context.getString(R.string.reboot), pendingIntent).build()
|
|
||||||
builder.addAction(action)
|
|
||||||
} else {
|
|
||||||
builder.addAction(
|
|
||||||
R.drawable.ic_refresh,
|
|
||||||
context.getString(R.string.reboot), pendingIntent)
|
|
||||||
}
|
|
||||||
|
|
||||||
mgr.notify(Const.ID.DTBO_NOTIFICATION_ID, builder.build())
|
|
||||||
}
|
|
||||||
|
|
||||||
fun progress(context: Context, title: CharSequence): Notification.Builder {
|
fun progress(context: Context, title: CharSequence): Notification.Builder {
|
||||||
val builder = if (SDK_INT >= 26) {
|
val builder = if (SDK_INT >= 26) {
|
||||||
Notification.Builder(context, PROGRESS_NOTIFICATION_CHANNEL)
|
Notification.Builder(context, PROGRESS_NOTIFICATION_CHANNEL)
|
||||||
|
@ -34,29 +34,6 @@ direct_install() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
mm_patch_dtb() {
|
|
||||||
(local result=1
|
|
||||||
local PATCHED=$TMPDIR/dt.patched
|
|
||||||
for name in dtb dtbo; do
|
|
||||||
local IMAGE=`find_block $name$SLOT`
|
|
||||||
if [ ! -z $IMAGE ]; then
|
|
||||||
if $MAGISKBIN/magiskboot dtb $IMAGE patch $PATCHED; then
|
|
||||||
result=0
|
|
||||||
if [ ! -z $SHA1 ]; then
|
|
||||||
# Backup stuffs
|
|
||||||
mkdir /data/magisk_backup_${SHA1} 2>/dev/null
|
|
||||||
cat $IMAGE | gzip -9 > /data/magisk_backup_${SHA1}/${name}.img.gz
|
|
||||||
fi
|
|
||||||
cat $PATCHED /dev/zero > $IMAGE
|
|
||||||
rm -f $PATCHED
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
# Run broadcast command passed from app
|
|
||||||
eval $1
|
|
||||||
)& >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
restore_imgs() {
|
restore_imgs() {
|
||||||
[ -z $SHA1 ] && return 1
|
[ -z $SHA1 ] && return 1
|
||||||
local BACKUPDIR=/data/magisk_backup_$SHA1
|
local BACKUPDIR=/data/magisk_backup_$SHA1
|
||||||
|
@ -117,11 +117,6 @@ case $((STATUS & 3)) in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ $((STATUS & 8)) -ne 0 ]; then
|
|
||||||
# Possibly using 2SI, export env var
|
|
||||||
export TWOSTAGEINIT=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# Ramdisk Patches
|
# Ramdisk Patches
|
||||||
##################
|
##################
|
||||||
|
@ -420,27 +420,6 @@ flash_image() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
patch_dtb_partitions() {
|
|
||||||
local result=1
|
|
||||||
cd $MAGISKBIN
|
|
||||||
for name in dtb dtbo dtbs; do
|
|
||||||
local IMAGE=`find_block $name$SLOT`
|
|
||||||
if [ ! -z $IMAGE ]; then
|
|
||||||
ui_print "- $name image: $IMAGE"
|
|
||||||
if ./magiskboot dtb $IMAGE patch dt.patched; then
|
|
||||||
result=0
|
|
||||||
ui_print "- Backing up stock $name image"
|
|
||||||
cat $IMAGE > stock_${name}.img
|
|
||||||
ui_print "- Flashing patched $name"
|
|
||||||
cat dt.patched /dev/zero > $IMAGE
|
|
||||||
rm -f dt.patched
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
cd /
|
|
||||||
return $result
|
|
||||||
}
|
|
||||||
|
|
||||||
# Common installation script for flash_script.sh and addon.d.sh
|
# Common installation script for flash_script.sh and addon.d.sh
|
||||||
install_magisk() {
|
install_magisk() {
|
||||||
cd $MAGISKBIN
|
cd $MAGISKBIN
|
||||||
@ -478,7 +457,6 @@ install_magisk() {
|
|||||||
./magiskboot cleanup
|
./magiskboot cleanup
|
||||||
rm -f new-boot.img
|
rm -f new-boot.img
|
||||||
|
|
||||||
patch_dtb_partitions
|
|
||||||
run_migrations
|
run_migrations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user