mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
feat(music/settings) when installing for the first time, a reboot dialog is shown
This commit is contained in:
@ -3,23 +3,37 @@ package app.revanced.util.bytecode
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.util.integrations.Constants.MUSIC_UTILS_PATH
|
||||
import app.revanced.util.integrations.Constants.UTILS_PATH
|
||||
|
||||
internal object BytecodeHelper {
|
||||
|
||||
internal fun BytecodeContext.injectInit(
|
||||
methods: String,
|
||||
descriptor: String
|
||||
descriptor: String,
|
||||
isYouTube: Boolean
|
||||
) {
|
||||
this.classes.forEach { classDef ->
|
||||
val activityClass =
|
||||
if (isYouTube)
|
||||
"/WatchWhileActivity;"
|
||||
else
|
||||
"/MusicActivity;"
|
||||
|
||||
val integrationPath =
|
||||
if (isYouTube)
|
||||
UTILS_PATH
|
||||
else
|
||||
MUSIC_UTILS_PATH
|
||||
|
||||
classes.forEach { classDef ->
|
||||
classDef.methods.forEach { method ->
|
||||
if (classDef.type.endsWith("/WatchWhileActivity;") && method.name == "onCreate") {
|
||||
if (classDef.type.endsWith(activityClass) && method.name == "onCreate") {
|
||||
val hookMethod =
|
||||
this.proxy(classDef).mutableClass.methods.first { it.name == "onCreate" }
|
||||
|
||||
hookMethod.addInstruction(
|
||||
2,
|
||||
"invoke-static/range {p0 .. p0}, $UTILS_PATH/$methods;->$descriptor(Landroid/content/Context;)V"
|
||||
"invoke-static/range {p0 .. p0}, $integrationPath/$methods;->$descriptor(Landroid/content/Context;)V"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user