feat(music/settings) when installing for the first time, a reboot dialog is shown

This commit is contained in:
inotia00
2023-09-05 12:26:24 +09:00
parent c5a68bf714
commit 5fda8e2c99
7 changed files with 26 additions and 8 deletions

View File

@ -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"
)
}
}