diff --git a/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/BlockRequestPatch.java b/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/BlockRequestPatch.java index cd67891ef..7e90cfce9 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/BlockRequestPatch.java +++ b/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/BlockRequestPatch.java @@ -106,18 +106,4 @@ public class BlockRequestPatch { return initPlaybackRequestUri; } - - /** - * Injection point. - * Skip response encryption in OnesiePlayerRequest. - */ - public static boolean skipResponseEncryption(boolean original) { - Logger.printDebug(() -> "response Encryption: " + original); - - if (BLOCK_REQUEST) { - return false; - } - - return original; - } } diff --git a/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/SpoofStreamingDataPatch.java b/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/SpoofStreamingDataPatch.java index aaab9e096..299ff96d9 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/SpoofStreamingDataPatch.java +++ b/extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/SpoofStreamingDataPatch.java @@ -62,6 +62,18 @@ public class SpoofStreamingDataPatch extends BlockRequestPatch { return false; } + /** + * Injection point. + * Skip response encryption in OnesiePlayerRequest. + */ + public static boolean skipResponseEncryption(boolean original) { + if (!SPOOF_STREAMING_DATA) { + return original; + } + + return false; + } + /** * Injection point. */ diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/BlockRequestPatch.kt b/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/BlockRequestPatch.kt index a2716d3e8..d99160c4b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/BlockRequestPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/BlockRequestPatch.kt @@ -4,12 +4,10 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.bytecodePatch import app.revanced.patches.shared.extension.Constants.SPOOF_PATH -import app.revanced.util.fingerprint.injectLiteralInstructionBooleanCall import app.revanced.util.fingerprint.methodOrThrow -import app.revanced.util.fingerprint.resolvable import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction -const val EXTENSION_CLASS_DESCRIPTOR = +private const val EXTENSION_CLASS_DESCRIPTOR = "$SPOOF_PATH/BlockRequestPatch;" val blockRequestPatch = bytecodePatch( @@ -51,16 +49,5 @@ val blockRequestPatch = bytecodePatch( } // endregion - - // region Skip response encryption in OnesiePlayerRequest - - if (onesieEncryptionFeatureFlagFingerprint.resolvable()) { - onesieEncryptionFeatureFlagFingerprint.injectLiteralInstructionBooleanCall( - ONESIE_ENCRYPTION_FEATURE_FLAG, - "$EXTENSION_CLASS_DESCRIPTOR->skipResponseEncryption(Z)Z" - ) - } - - // endregion } } \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/Fingerprints.kt index 587992c6d..c011e0420 100644 --- a/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/shared/spoof/blockrequest/Fingerprints.kt @@ -40,14 +40,3 @@ internal fun indexOfUriToStringInstruction(method: Method) = opcode == Opcode.INVOKE_VIRTUAL && getReference().toString() == "Landroid/net/Uri;->toString()Ljava/lang/String;" } - -// Feature flag that turns on Platypus programming language code compiled to native C++. -// This code appears to replace the player config after the streams are loaded. -// Flag is present in YouTube 19.34, but is missing Platypus stream replacement code until 19.43. -// Flag and Platypus code is also present in newer versions of YouTube Music. -internal const val ONESIE_ENCRYPTION_FEATURE_FLAG = 45645570L - -internal val onesieEncryptionFeatureFlagFingerprint = legacyFingerprint( - name = "onesieEncryptionFeatureFlagFingerprint", - literals = listOf(ONESIE_ENCRYPTION_FEATURE_FLAG), -) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/utils/fix/streamingdata/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/utils/fix/streamingdata/Fingerprints.kt index c5ff68e76..978104994 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/utils/fix/streamingdata/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/utils/fix/streamingdata/Fingerprints.kt @@ -135,4 +135,15 @@ internal val hlsCurrentTimeFingerprint = legacyFingerprint( literals = listOf(HLS_CURRENT_TIME_FEATURE_FLAG), ) +// Feature flag that turns on Platypus programming language code compiled to native C++. +// This code appears to replace the player config after the streams are loaded. +// Flag is present in YouTube 19.34, but is missing Platypus stream replacement code until 19.43. +// Flag and Platypus code is also present in newer versions of YouTube Music. +internal const val ONESIE_ENCRYPTION_FEATURE_FLAG = 45645570L + +internal val onesieEncryptionFeatureFlagFingerprint = legacyFingerprint( + name = "onesieEncryptionFeatureFlagFingerprint", + literals = listOf(ONESIE_ENCRYPTION_FEATURE_FLAG), +) + diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/utils/fix/streamingdata/SpoofStreamingDataPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/utils/fix/streamingdata/SpoofStreamingDataPatch.kt index 8954d9933..4c5579b1f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/utils/fix/streamingdata/SpoofStreamingDataPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/utils/fix/streamingdata/SpoofStreamingDataPatch.kt @@ -18,6 +18,8 @@ import app.revanced.patches.shared.spoof.useragent.baseSpoofUserAgentPatch import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE import app.revanced.patches.youtube.utils.compatibility.Constants.YOUTUBE_PACKAGE_NAME import app.revanced.patches.youtube.utils.patch.PatchList.SPOOF_STREAMING_DATA +import app.revanced.patches.youtube.utils.playservice.is_19_34_or_greater +import app.revanced.patches.youtube.utils.playservice.versionCheckPatch import app.revanced.patches.youtube.utils.request.buildRequestPatch import app.revanced.patches.youtube.utils.request.hookBuildRequest import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference @@ -54,6 +56,7 @@ val spoofStreamingDataPatch = bytecodePatch( baseSpoofUserAgentPatch(YOUTUBE_PACKAGE_NAME), blockRequestPatch, buildRequestPatch, + versionCheckPatch, ) execute { @@ -317,6 +320,17 @@ val spoofStreamingDataPatch = bytecodePatch( // endregion + // region Skip response encryption in OnesiePlayerRequest + + if (is_19_34_or_greater) { + onesieEncryptionFeatureFlagFingerprint.injectLiteralInstructionBooleanCall( + ONESIE_ENCRYPTION_FEATURE_FLAG, + "$EXTENSION_CLASS_DESCRIPTOR->skipResponseEncryption(Z)Z" + ) + } + + // endregion + findMethodOrThrow("$PATCHES_PATH/PatchStatus;") { name == "SpoofStreamingData" }.replaceInstruction(