diff --git a/src/main/kotlin/app/revanced/patches/music/misc/splash/CairoSplashAnimationPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/splash/CairoSplashAnimationPatch.kt index f10ee61f9..49dfa7873 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/splash/CairoSplashAnimationPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/splash/CairoSplashAnimationPatch.kt @@ -2,6 +2,7 @@ package app.revanced.patches.music.misc.splash import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import app.revanced.patches.music.misc.splash.fingerprints.CairoSplashAnimationConfigFingerprint @@ -18,7 +19,8 @@ import app.revanced.util.literalInstructionBooleanHook CompatiblePackage( "com.google.android.apps.youtube.music", [ - "7.08.52", + "7.08.54", + "7.12.51", ] ) ] @@ -29,16 +31,19 @@ object CairoSplashAnimationPatch : BytecodePatch( ) { override fun execute(context: BytecodeContext) { - CairoSplashAnimationConfigFingerprint.literalInstructionBooleanHook( - 45635386, - "$MISC_PATH/CairoSplashAnimationPatch;->enableCairoSplashAnimation()Z" - ) + CairoSplashAnimationConfigFingerprint.result?.let { + CairoSplashAnimationConfigFingerprint.literalInstructionBooleanHook( + 45635386, + "$MISC_PATH/CairoSplashAnimationPatch;->enableCairoSplashAnimation()Z" + ) - SettingsPatch.addSwitchPreference( - CategoryType.MISC, - "revanced_enable_cairo_splash_animation", - "false" - ) + SettingsPatch.addSwitchPreference( + CategoryType.MISC, + "revanced_enable_cairo_splash_animation", + "false" + ) + + } ?: throw PatchException("WARNING: This patch is not supported in this version. Use YouTube Music 7.08.54 or later.") } } diff --git a/src/main/kotlin/app/revanced/patches/music/navigation/components/NavigationBarComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/music/navigation/components/NavigationBarComponentsPatch.kt index ae412cf8f..adcd24adf 100644 --- a/src/main/kotlin/app/revanced/patches/music/navigation/components/NavigationBarComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/navigation/components/NavigationBarComponentsPatch.kt @@ -10,17 +10,22 @@ import app.revanced.patches.music.navigation.components.fingerprints.TabLayoutTe import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.music.utils.integrations.Constants.NAVIGATION_CLASS_DESCRIPTOR import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch +import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.ColorGrey 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.getTargetIndexOrThrow import app.revanced.util.getTargetIndexWithMethodReferenceNameOrThrow import app.revanced.util.getWideLiteralInstructionIndex +import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.patch.BaseBytecodePatch 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.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c +import com.android.tools.smali.dexlib2.iface.reference.MethodReference @Suppress("DEPRECATION", "SpellCheckingInspection", "unused") object NavigationBarComponentsPatch : BaseBytecodePatch( @@ -44,18 +49,20 @@ object NavigationBarComponentsPatch : BaseBytecodePatch( /** * Enable black navigation bar */ - TabLayoutFingerprint.resultOrThrow().let { - it.mutableMethod.apply { - val targetIndex = it.scanResult.patternScanResult!!.endIndex - val targetRegister = getInstruction(targetIndex).registerA - - addInstructions( - targetIndex + 1, """ - invoke-static {}, $NAVIGATION_CLASS_DESCRIPTOR->enableBlackNavigationBar()I - move-result v$targetRegister - """ - ) + TabLayoutFingerprint.resultOrThrow().mutableMethod.apply { + val constIndex = getWideLiteralInstructionIndex(ColorGrey) + val insertIndex = indexOfFirstInstructionOrThrow(constIndex) { + opcode == Opcode.INVOKE_VIRTUAL + && getReference()?.name == "setBackgroundColor" } + val insertRegister = getInstruction(insertIndex).registerD + + addInstructions( + insertIndex, """ + invoke-static {}, $NAVIGATION_CLASS_DESCRIPTOR->enableBlackNavigationBar()I + move-result v$insertRegister + """ + ) } /** diff --git a/src/main/kotlin/app/revanced/patches/music/navigation/components/fingerprints/TabLayoutFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/navigation/components/fingerprints/TabLayoutFingerprint.kt index 30ff0ee68..e5144deee 100644 --- a/src/main/kotlin/app/revanced/patches/music/navigation/components/fingerprints/TabLayoutFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/navigation/components/fingerprints/TabLayoutFingerprint.kt @@ -4,17 +4,12 @@ import app.revanced.patcher.extensions.or import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.ColorGrey import app.revanced.util.fingerprint.LiteralValueFingerprint import com.android.tools.smali.dexlib2.AccessFlags -import com.android.tools.smali.dexlib2.Opcode internal object TabLayoutFingerprint : LiteralValueFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, parameters = emptyList(), - opcodes = listOf( - Opcode.CONST, - Opcode.INVOKE_STATIC, - Opcode.MOVE_RESULT - ), + strings = listOf("FEmusic_radio_builder"), literalSupplier = { ColorGrey } ) diff --git a/src/main/kotlin/app/revanced/patches/music/utils/compatibility/Constants.kt b/src/main/kotlin/app/revanced/patches/music/utils/compatibility/Constants.kt index 0298102b4..adfd51adb 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/compatibility/Constants.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/compatibility/Constants.kt @@ -11,8 +11,8 @@ object Constants { "6.33.52", // This is the latest version with the legacy code of YouTube Music. "6.42.55", // This is the latest version that supports Android 7.0 "6.51.53", // This is the latest version of YouTube Music 6.xx.xx - "7.08.54", // This was the latest version that was supported by the previous patch. - "7.10.52", // This is the latest version supported by the RVX patch. + "7.11.51", // This was the latest version that was supported by the previous patch. + "7.12.51", // This is the latest version supported by the RVX patch. ) ) ) diff --git a/src/main/kotlin/app/revanced/patches/shared/mainactivity/BaseMainActivityResolvePatch.kt b/src/main/kotlin/app/revanced/patches/shared/mainactivity/BaseMainActivityResolvePatch.kt index e6a08478d..02e3c8135 100644 --- a/src/main/kotlin/app/revanced/patches/shared/mainactivity/BaseMainActivityResolvePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/mainactivity/BaseMainActivityResolvePatch.kt @@ -61,7 +61,7 @@ abstract class BaseMainActivityResolvePatch( fun injectOnCreateMethodCall(classDescriptor: String, methodDescriptor: String) = onCreateMethod.injectMethodCall(classDescriptor, methodDescriptor) - private fun getMethod(methodDescriptor: String) = + internal fun getMethod(methodDescriptor: String) = mainActivityMutableClass.methods.find { method -> method.name == methodDescriptor } ?: throw PatchException("Could not find $methodDescriptor")