From 96a55c504922316ce8ecf824c2c3f7599294341a Mon Sep 17 00:00:00 2001 From: inotia00 Date: Mon, 30 Jan 2023 10:46:54 +0900 Subject: [PATCH] remove `custom-video-buffer` patch https://github.com/inotia00/ReVanced_Extended/issues/198 --- .../fingerprints/MaxBufferFingerprint.kt | 18 ----- .../fingerprints/PlaybackBufferFingerprint.kt | 23 ------ .../fingerprints/ReBufferFingerprint.kt | 23 ------ .../patch/CustomVideoBufferBytecodePatch.kt | 73 ------------------- .../resource/patch/CustomVideoBufferPatch.kt | 48 ------------ .../youtube/settings/host/values/strings.xml | 8 -- .../youtube/settings/xml/revanced_prefs.xml | 9 --- 7 files changed, 202 deletions(-) delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/fingerprints/MaxBufferFingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/fingerprints/PlaybackBufferFingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/fingerprints/ReBufferFingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/patch/CustomVideoBufferBytecodePatch.kt delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/resource/patch/CustomVideoBufferPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/fingerprints/MaxBufferFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/fingerprints/MaxBufferFingerprint.kt deleted file mode 100644 index c4427b718..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/fingerprints/MaxBufferFingerprint.kt +++ /dev/null @@ -1,18 +0,0 @@ -package app.revanced.patches.youtube.misc.customvideobuffer.bytecode.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags -import org.jf.dexlib2.Opcode - -object MaxBufferFingerprint : MethodFingerprint( - returnType = "Z", - access = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf("J", "J", "F"), - opcodes = listOf( - Opcode.IGET_BOOLEAN, - Opcode.CONST_WIDE_16, - Opcode.IF_EQZ, - Opcode.INVOKE_VIRTUAL - ) -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/fingerprints/PlaybackBufferFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/fingerprints/PlaybackBufferFingerprint.kt deleted file mode 100644 index fe70e94c0..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/fingerprints/PlaybackBufferFingerprint.kt +++ /dev/null @@ -1,23 +0,0 @@ -package app.revanced.patches.youtube.misc.customvideobuffer.bytecode.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags -import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction -import org.jf.dexlib2.Opcode - -object PlaybackBufferFingerprint : MethodFingerprint( - returnType = "I", - access = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf(), - opcodes = listOf( - Opcode.IF_LEZ, - Opcode.RETURN - ), - customFingerprint = { - it.definingClass == "Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;" - && it.implementation!!.instructions.any { instruction -> - ((instruction as? NarrowLiteralInstruction)?.narrowLiteral == 1600) - } - } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/fingerprints/ReBufferFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/fingerprints/ReBufferFingerprint.kt deleted file mode 100644 index 3e5f13938..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/fingerprints/ReBufferFingerprint.kt +++ /dev/null @@ -1,23 +0,0 @@ -package app.revanced.patches.youtube.misc.customvideobuffer.bytecode.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import org.jf.dexlib2.AccessFlags -import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction -import org.jf.dexlib2.Opcode - -object ReBufferFingerprint : MethodFingerprint( - returnType = "I", - access = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf(), - opcodes = listOf( - Opcode.IF_LEZ, - Opcode.RETURN - ), - customFingerprint = { - it.definingClass == "Lcom/google/android/libraries/youtube/innertube/model/media/PlayerConfigModel;" - && it.implementation!!.instructions.any { instruction -> - ((instruction as? NarrowLiteralInstruction)?.narrowLiteral == 5000) - } - } -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/patch/CustomVideoBufferBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/patch/CustomVideoBufferBytecodePatch.kt deleted file mode 100644 index 731b9c8bb..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/bytecode/patch/CustomVideoBufferBytecodePatch.kt +++ /dev/null @@ -1,73 +0,0 @@ -package app.revanced.patches.youtube.misc.customvideobuffer.bytecode.patch - -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.data.toMethodWalker -import app.revanced.patcher.extensions.addInstructions -import app.revanced.patcher.extensions.instruction -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.youtube.misc.customvideobuffer.bytecode.fingerprints.* -import app.revanced.shared.annotation.YouTubeCompatibility -import app.revanced.shared.extensions.toErrorResult -import app.revanced.shared.util.integrations.Constants.MISC_PATH -import org.jf.dexlib2.iface.instruction.OneRegisterInstruction - -@Name("custom-video-buffer-bytecode-patch") -@YouTubeCompatibility -@Version("0.0.1") -class CustomVideoBufferBytecodePatch : BytecodePatch( - listOf( - MaxBufferFingerprint, - PlaybackBufferFingerprint, - ReBufferFingerprint - ) -) { - override fun execute(context: BytecodeContext): PatchResult { - - MaxBufferFingerprint.result?.injectMaxBuffer(context) ?: return MaxBufferFingerprint.toErrorResult() - - arrayOf( - PlaybackBufferFingerprint to "setPlaybackBuffer", - ReBufferFingerprint to "setReBuffer" - ).map { (fingerprint, name) -> - fingerprint.result?.mutableMethod?.insertOverride(name) ?: return fingerprint.toErrorResult() - } - - return PatchResultSuccess() - } - - private companion object { - const val INTEGRATIONS_BUFFER_CLASS_DESCRIPTOR = - "$MISC_PATH/CustomVideoBufferPatch;" - } - - private fun MethodFingerprintResult.injectMaxBuffer( - context: BytecodeContext - ) { - val insertMethod = context.toMethodWalker(this.method) - .nextMethod(this.scanResult.patternScanResult!!.endIndex, true) - .getMethod() as MutableMethod - - insertMethod.insertOverride("setMaxBuffer") - } - - private fun MutableMethod.insertOverride( - descriptor: String - ) { - val index = this.implementation!!.instructions.size - 1 - 2 - val register = (this.instruction(index) as OneRegisterInstruction).registerA - - this.addInstructions( - index, - """ - invoke-static {}, $INTEGRATIONS_BUFFER_CLASS_DESCRIPTOR->$descriptor()I - move-result v$register - """ - ) - } -} diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/resource/patch/CustomVideoBufferPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/resource/patch/CustomVideoBufferPatch.kt deleted file mode 100644 index cca0123b6..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/customvideobuffer/resource/patch/CustomVideoBufferPatch.kt +++ /dev/null @@ -1,48 +0,0 @@ -package app.revanced.patches.youtube.misc.customvideobuffer.resource.patch - -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -import app.revanced.patcher.annotation.Version -import app.revanced.patcher.data.ResourceContext -import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.patch.PatchResult -import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.ResourcePatch -import app.revanced.patches.youtube.misc.customvideobuffer.bytecode.patch.CustomVideoBufferBytecodePatch -import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch -import app.revanced.shared.annotation.YouTubeCompatibility -import app.revanced.shared.util.resources.ResourceHelper - -@Patch -@Name("custom-video-buffer") -@Description("Lets you change the buffers of videos.") -@DependsOn( - [ - CustomVideoBufferBytecodePatch::class, - SettingsPatch::class - ] -) -@YouTubeCompatibility -@Version("0.0.1") -class CustomVideoBufferPatch : ResourcePatch { - override fun execute(context: ResourceContext): PatchResult { - - /* - add settings - */ - ResourceHelper.addSettings( - context, - "PREFERENCE_CATEGORY: REVANCED_SETTINGS", - "PREFERENCE: MISC_SETTINGS", - "SETTINGS: CUSTOM_VIDEO_BUFFER" - ) - - ResourceHelper.patchSuccess( - context, - "custom-video-buffer" - ) - - return PatchResultSuccess() - } -} \ No newline at end of file diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml index 06a7975fc..8a115b893 100644 --- a/src/main/resources/youtube/settings/host/values/strings.xml +++ b/src/main/resources/youtube/settings/host/values/strings.xml @@ -163,14 +163,6 @@ Is it ready to submit?" Hide web search panels Type the hex code of the seekbar color to use in dark mode Custom seekbar color value - The maximum duration of media that the player will attempt to buffer - Maximum buffer size - The duration of media that must be buffered for playback to start or resume following a user action such as seeking - Playback start buffer size - The duration of media that must be buffered for playback to resume after a rebuffer - Rebuffer size - Video buffer size related settings - Video buffer settings Select default video resolution on Cellular Network Default video quality Cellular Select default video resolution on Wi-Fi Network diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 6701bd6e4..2c04d96ed 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -279,14 +279,6 @@ - - @@ -416,7 +408,6 @@ -