fix(YouTube Music - Change start page): Start page not changing in YT Music 8.02.53+ https://github.com/inotia00/ReVanced_Extended/issues/2719

This commit is contained in:
inotia00
2025-01-22 13:30:55 +09:00
parent 7484173618
commit e0839ca768

View File

@ -2,7 +2,6 @@ package app.revanced.patches.music.general.startpage
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.music.utils.extension.Constants.GENERAL_CLASS_DESCRIPTOR
@ -11,10 +10,13 @@ import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.ResourceUtils.updatePatchStatus
import app.revanced.patches.music.utils.settings.addPreferenceWithIntent
import app.revanced.patches.music.utils.settings.settingsPatch
import app.revanced.util.fingerprint.matchOrThrow
import app.revanced.util.fingerprint.methodOrThrow
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
import app.revanced.util.indexOfFirstStringInstructionOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
@Suppress("unused")
val changeStartPagePatch = bytecodePatch(
@ -28,17 +30,19 @@ val changeStartPagePatch = bytecodePatch(
execute {
coldStartUpFingerprint.methodOrThrow().apply {
val targetIndex = indexOfFirstStringInstructionOrThrow(DEFAULT_BROWSE_ID) + 1
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
val defaultBrowseIdIndex = indexOfFirstStringInstructionOrThrow(DEFAULT_BROWSE_ID)
val browseIdIndex = indexOfFirstInstructionReversedOrThrow(defaultBrowseIdIndex) {
opcode == Opcode.IGET_OBJECT &&
getReference<FieldReference>()?.type == "Ljava/lang/String;"
}
val browseIdRegister = getInstruction<TwoRegisterInstruction>(browseIdIndex).registerA
addInstructions(
targetIndex + 1, """
invoke-static {v$targetRegister}, $GENERAL_CLASS_DESCRIPTOR->changeStartPage(Ljava/lang/String;)Ljava/lang/String;
move-result-object v$targetRegister
return-object v$targetRegister
browseIdIndex + 1, """
invoke-static {v$browseIdRegister}, $GENERAL_CLASS_DESCRIPTOR->changeStartPage(Ljava/lang/String;)Ljava/lang/String;
move-result-object v$browseIdRegister
"""
)
removeInstruction(targetIndex)
}
addPreferenceWithIntent(