fix(YouTube/Disable splash animation): does not work on YouTube v19.17.41+ https://github.com/inotia00/ReVanced_Extended/issues/2073

This commit is contained in:
inotia00 2024-05-28 00:10:28 +09:00
parent d01ca1ad5f
commit bc0860bba7
3 changed files with 57 additions and 13 deletions

View File

@ -4,16 +4,17 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patches.youtube.general.splashanimation.fingerprints.SplashAnimationFingerprint import app.revanced.patches.youtube.general.splashanimation.fingerprints.SplashAnimationFingerprint
import app.revanced.patches.youtube.general.splashanimation.fingerprints.StartUpResourceIdFingerprint
import app.revanced.patches.youtube.general.splashanimation.fingerprints.StartUpResourceIdParentFingerprint
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.DarkSplashAnimation
import app.revanced.patches.youtube.utils.settings.SettingsPatch import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.getTargetIndexWithReferenceReversed
import app.revanced.util.getWideLiteralInstructionIndex
import app.revanced.util.patch.BaseBytecodePatch import app.revanced.util.patch.BaseBytecodePatch
import app.revanced.util.resultOrThrow import app.revanced.util.resultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@Suppress("unused") @Suppress("unused")
object SplashAnimationPatch : BaseBytecodePatch( object SplashAnimationPatch : BaseBytecodePatch(
@ -24,22 +25,37 @@ object SplashAnimationPatch : BaseBytecodePatch(
SharedResourceIdPatch::class SharedResourceIdPatch::class
), ),
compatiblePackages = COMPATIBLE_PACKAGE, compatiblePackages = COMPATIBLE_PACKAGE,
fingerprints = setOf(SplashAnimationFingerprint) fingerprints = setOf(
SplashAnimationFingerprint,
StartUpResourceIdParentFingerprint
)
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
StartUpResourceIdFingerprint.resolve(context, StartUpResourceIdParentFingerprint.resultOrThrow().classDef)
val startUpResourceIdMethod = StartUpResourceIdFingerprint.resultOrThrow().mutableMethod
val startUpResourceIdMethodCall = startUpResourceIdMethod.definingClass + "->" + startUpResourceIdMethod.name + "(I)Z"
SplashAnimationFingerprint.resultOrThrow().let { SplashAnimationFingerprint.resultOrThrow().let {
it.mutableMethod.apply { it.mutableMethod.apply {
val constIndex = getWideLiteralInstructionIndex(DarkSplashAnimation) for (index in implementation!!.instructions.size - 1 downTo 0) {
val targetIndex = getTargetIndexWithReferenceReversed(constIndex, "(I)Z") + 2 val instruction = getInstruction(index)
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex - 1).registerA if (instruction.opcode != Opcode.INVOKE_STATIC)
continue
addInstructions( if ((instruction as ReferenceInstruction).reference.toString() != startUpResourceIdMethodCall)
targetIndex, """ continue
invoke-static {v$targetRegister}, $GENERAL_CLASS_DESCRIPTOR->disableSplashAnimation(Z)Z
move-result v$targetRegister val register = getInstruction<OneRegisterInstruction>(index + 1).registerA
"""
) addInstructions(
index + 2, """
invoke-static {v$register}, $GENERAL_CLASS_DESCRIPTOR->disableSplashAnimation(Z)Z
move-result v$register
"""
)
}
} }
} }

View File

@ -0,0 +1,16 @@
package app.revanced.patches.youtube.general.splashanimation.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.util.containsWideLiteralInstructionIndex
import com.android.tools.smali.dexlib2.AccessFlags
internal object StartUpResourceIdFingerprint : MethodFingerprint(
returnType = "Z",
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
parameters = listOf("I"),
customFingerprint = { methodDef, _ ->
methodDef.containsWideLiteralInstructionIndex(3)
&& methodDef.containsWideLiteralInstructionIndex(4)
}
)

View File

@ -0,0 +1,12 @@
package app.revanced.patches.youtube.general.splashanimation.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
internal object StartUpResourceIdParentFingerprint : MethodFingerprint(
returnType = "Z",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL or AccessFlags.DECLARED_SYNCHRONIZED,
parameters = listOf("I", "I"),
strings = listOf("early type", "final type")
)