From 58e93da4f8fee437b63cfff7b61586084b3a339f Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Thu, 13 Jun 2024 00:33:41 +0900 Subject: [PATCH] feat(YouTube Music): add support version `7.05.52` --- .../BackgroundPlaybackPatch.kt | 19 +++++++++++------ .../music/utils/compatibility/Constants.kt | 11 +++++----- .../fingerprints/InitFingerprint.kt | 21 ++++++++----------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch.kt index 46ff66cc0..54e45489c 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/backgroundplayback/BackgroundPlaybackPatch.kt @@ -75,8 +75,18 @@ object BackgroundPlaybackPatch : BaseBytecodePatch( } // don't play podcast videos - PodCastConfigFingerprint.resultOrThrow().let { - it.mutableMethod.apply { + // enable by default from YouTube Music 7.05.52+ + + val podCastConfigFingerprintResult = PodCastConfigFingerprint.result + val dataSavingSettingsFragmentFingerprintResult = + DataSavingSettingsFragmentFingerprint.result + + val isPatchingOldVersion = + podCastConfigFingerprintResult != null + && dataSavingSettingsFragmentFingerprintResult != null + + if (isPatchingOldVersion) { + podCastConfigFingerprintResult!!.mutableMethod.apply { val insertIndex = implementation!!.instructions.size - 1 val targetRegister = getInstruction(insertIndex).registerA @@ -85,11 +95,8 @@ object BackgroundPlaybackPatch : BaseBytecodePatch( "const/4 v$targetRegister, 0x1" ) } - } - // don't play podcast videos - DataSavingSettingsFragmentFingerprint.resultOrThrow().let { - it.mutableMethod.apply { + dataSavingSettingsFragmentFingerprintResult!!.mutableMethod.apply { val insertIndex = getStringInstructionIndex("pref_key_dont_play_nma_video") + 4 val targetRegister = getInstruction(insertIndex).registerD 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 3575ee57c..eef518937 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 @@ -7,11 +7,12 @@ object Constants { Patch.CompatiblePackage( "com.google.android.apps.youtube.music", setOf( - "6.29.58", // Latest version that supports the 'Restore old player layout' setting. - "6.33.52", // Latest version with the legacy code of YouTube Music. - "6.42.55", // Latest version that supports Android 7.0 - "6.51.53", // Latest version of YouTube Music 6.xx.xx - "7.04.51", // Latest version supported by the RVX patch. + "6.29.58", // This is the latest version that supports the 'Restore old player layout' setting. + "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.04.51", // This was the latest version that was supported by the previous patch. + "7.05.52", // This is the latest version supported by the RVX patch. ) ) ) diff --git a/src/main/kotlin/app/revanced/patches/music/utils/integrations/fingerprints/InitFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/utils/integrations/fingerprints/InitFingerprint.kt index 2417b6030..40ae8ca68 100644 --- a/src/main/kotlin/app/revanced/patches/music/utils/integrations/fingerprints/InitFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/music/utils/integrations/fingerprints/InitFingerprint.kt @@ -1,25 +1,22 @@ package app.revanced.patches.music.utils.integrations.fingerprints -import app.revanced.patches.music.utils.integrations.fingerprints.InitFingerprint.indexOfGetProcessNameInstruction import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstruction import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.iface.Method import com.android.tools.smali.dexlib2.iface.reference.MethodReference internal object InitFingerprint : IntegrationsFingerprint( returnType = "V", parameters = emptyList(), strings = listOf("activity"), - customFingerprint = { methodDef, _ -> - methodDef.name == "onCreate" - && indexOfGetProcessNameInstruction(methodDef) >= 0 - } -) { - fun indexOfGetProcessNameInstruction(methodDef: Method) = + customFingerprint = handler@{ methodDef, _ -> + if (methodDef.name != "onCreate") + return@handler false + methodDef.indexOfFirstInstruction { - opcode == Opcode.INVOKE_STATIC - && getReference()?.name == "getProcessName" - } -} \ No newline at end of file + opcode == Opcode.INVOKE_VIRTUAL + && getReference()?.name == "getRunningAppProcesses" + } >= 0 + } +) \ No newline at end of file