mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-04 00:24:34 +02:00
fix(YouTube Music/Disable Cairo splash animation): some versions are recognized as unpatchable even though they can be patched
This commit is contained in:
parent
8c149d3c99
commit
577f49b01c
@ -1,19 +1,35 @@
|
||||
package app.revanced.patches.music.misc.splash
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.music.misc.splash.fingerprints.CairoSplashAnimationConfigFingerprint
|
||||
import app.revanced.patches.music.utils.integrations.Constants.MISC_PATH
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MainActivityLaunchAnimation
|
||||
import app.revanced.patches.music.utils.settings.CategoryType
|
||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||
import app.revanced.util.indexOfFirstWideLiteralInstructionValueOrThrow
|
||||
import app.revanced.util.injectLiteralInstructionBooleanCall
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
@Patch(
|
||||
name = "Disable Cairo splash animation",
|
||||
description = "Adds an option to disable Cairo splash animation.",
|
||||
dependencies = [SettingsPatch::class],
|
||||
dependencies = [
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
],
|
||||
compatiblePackages = [
|
||||
CompatiblePackage(
|
||||
"com.google.android.apps.youtube.music",
|
||||
@ -28,22 +44,53 @@ import app.revanced.util.injectLiteralInstructionBooleanCall
|
||||
object CairoSplashAnimationPatch : BytecodePatch(
|
||||
setOf(CairoSplashAnimationConfigFingerprint)
|
||||
) {
|
||||
private const val INTEGRATIONS_METHOD_DESCRIPTOR =
|
||||
"$MISC_PATH/CairoSplashAnimationPatch;->disableCairoSplashAnimation(Z)Z"
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
CairoSplashAnimationConfigFingerprint.result?.let {
|
||||
if (!SettingsPatch.upward0706) {
|
||||
println("WARNING: This patch is not supported in this version. Use YouTube Music 7.06.54 or later.")
|
||||
return
|
||||
} else if (!SettingsPatch.upward0720) {
|
||||
CairoSplashAnimationConfigFingerprint.injectLiteralInstructionBooleanCall(
|
||||
45635386,
|
||||
"$MISC_PATH/CairoSplashAnimationPatch;->disableCairoSplashAnimation(Z)Z"
|
||||
)
|
||||
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.MISC,
|
||||
"revanced_disable_cairo_splash_animation",
|
||||
"false"
|
||||
INTEGRATIONS_METHOD_DESCRIPTOR
|
||||
)
|
||||
} else {
|
||||
CairoSplashAnimationConfigFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val literalIndex = indexOfFirstWideLiteralInstructionValueOrThrow(
|
||||
MainActivityLaunchAnimation
|
||||
)
|
||||
val insertIndex = indexOfFirstInstructionReversedOrThrow(literalIndex) {
|
||||
opcode == Opcode.INVOKE_VIRTUAL &&
|
||||
getReference<MethodReference>()?.name == "setContentView"
|
||||
} + 1
|
||||
val viewStubFindViewByIdIndex = indexOfFirstInstructionOrThrow(literalIndex) {
|
||||
val reference = getReference<MethodReference>()
|
||||
opcode == Opcode.INVOKE_VIRTUAL &&
|
||||
reference?.name == "findViewById" &&
|
||||
reference.definingClass != "Landroid/view/View;"
|
||||
}
|
||||
val freeRegister = getInstruction<FiveRegisterInstruction>(viewStubFindViewByIdIndex).registerD
|
||||
val jumpIndex = indexOfFirstInstructionReversedOrThrow(viewStubFindViewByIdIndex, Opcode.IGET_OBJECT)
|
||||
|
||||
addInstructionsWithLabels(
|
||||
insertIndex, """
|
||||
const/4 v$freeRegister, 0x1
|
||||
invoke-static {v$freeRegister}, $INTEGRATIONS_METHOD_DESCRIPTOR
|
||||
move-result v$freeRegister
|
||||
if-eqz v$freeRegister, :skip
|
||||
""", ExternalLabel("skip", getInstruction(jumpIndex))
|
||||
)
|
||||
}
|
||||
}
|
||||
?: println("WARNING: This patch is not supported in this version. Use YouTube Music 7.06.54 or later.")
|
||||
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.MISC,
|
||||
"revanced_disable_cairo_splash_animation",
|
||||
"false"
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,25 @@
|
||||
package app.revanced.patches.music.misc.splash.fingerprints
|
||||
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MainActivityLaunchAnimation
|
||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.util.indexOfFirstWideLiteralInstructionValue
|
||||
|
||||
/**
|
||||
* This fingerprint is compatible with YouTube Music v7.06.53+
|
||||
*/
|
||||
internal object CairoSplashAnimationConfigFingerprint : LiteralValueFingerprint(
|
||||
literalSupplier = { 45635386 }
|
||||
internal object CairoSplashAnimationConfigFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
customFingerprint = handler@{ methodDef, _ ->
|
||||
if (methodDef.definingClass != "Lcom/google/android/apps/youtube/music/activities/MusicActivity;")
|
||||
return@handler false
|
||||
if (methodDef.name != "onCreate")
|
||||
return@handler false
|
||||
|
||||
if (SettingsPatch.upward0720) {
|
||||
methodDef.indexOfFirstWideLiteralInstructionValue(MainActivityLaunchAnimation) >= 0
|
||||
} else {
|
||||
methodDef.indexOfFirstWideLiteralInstructionValue(45635386) >= 0
|
||||
}
|
||||
}
|
||||
)
|
@ -33,6 +33,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
var InterstitialsContainer = -1L
|
||||
var IsTablet = -1L
|
||||
var LikeDislikeContainer = -1L
|
||||
var MainActivityLaunchAnimation = -1L
|
||||
var MenuEntry = -1L
|
||||
var MiniPlayerDefaultText = -1L
|
||||
var MiniPlayerMdxPlaying = -1L
|
||||
@ -79,6 +80,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
InterstitialsContainer = getId(ID, "interstitials_container")
|
||||
IsTablet = getId(BOOL, "is_tablet")
|
||||
LikeDislikeContainer = getId(ID, "like_dislike_container")
|
||||
MainActivityLaunchAnimation = getId(LAYOUT, "main_activity_launch_animation")
|
||||
MenuEntry = getId(LAYOUT, "menu_entry")
|
||||
MiniPlayerDefaultText = getId(STRING, "mini_player_default_text")
|
||||
MiniPlayerMdxPlaying = getId(STRING, "mini_player_mdx_playing")
|
||||
|
@ -41,7 +41,9 @@ object SettingsPatch : BaseResourcePatch(
|
||||
internal var upward0627 = false
|
||||
internal var upward0636 = false
|
||||
internal var upward0642 = false
|
||||
internal var upward0706 = false
|
||||
internal var upward0718 = false
|
||||
internal var upward0720 = false
|
||||
|
||||
override fun execute(context: ResourceContext) {
|
||||
|
||||
@ -137,7 +139,9 @@ object SettingsPatch : BaseResourcePatch(
|
||||
upward0627 = 234412000 <= playServicesVersion
|
||||
upward0636 = 240399000 <= playServicesVersion
|
||||
upward0642 = 240999000 <= playServicesVersion
|
||||
upward0706 = 242499000 <= playServicesVersion
|
||||
upward0718 = 243699000 <= playServicesVersion
|
||||
upward0720 = 243899000 <= playServicesVersion
|
||||
|
||||
break
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user