From ffa2e5d7eb0b90bb5c7a6854bab4caf9f810d917 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Mon, 15 May 2023 03:07:36 +0400 Subject: [PATCH] fix(youtube/video-speed): add compatibility annotation (#2156) --- .../speed/{VideoSpeeds.kt => VideoSpeed.kt} | 6 +++-- ...tibility.kt => VideoSpeedCompatibility.kt} | 4 ++-- .../CustomPlaybackSpeedCompatibility.kt | 24 ------------------- .../custom/patch/CustomVideoSpeedPatch.kt | 8 +++---- .../patch/RememberPlaybackSpeedPatch.kt | 3 --- 5 files changed, 10 insertions(+), 35 deletions(-) rename src/main/kotlin/app/revanced/patches/youtube/video/speed/{VideoSpeeds.kt => VideoSpeed.kt} (92%) rename src/main/kotlin/app/revanced/patches/youtube/video/speed/{remember/annotation/RememberPlaybackSpeedCompatibility.kt => VideoSpeedCompatibility.kt} (64%) delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/annotations/CustomPlaybackSpeedCompatibility.kt diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeeds.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeed.kt similarity index 92% rename from src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeeds.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeed.kt index 7bd25ff9..a079bd0f 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeeds.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeed.kt @@ -16,10 +16,12 @@ import app.revanced.patches.youtube.video.speed.remember.patch.RememberPlaybackS @Name("video-speed") @Description("Adds custom video speeds and ability to remember the playback speed you chose in the video playback speed flyout.") @DependsOn([CustomVideoSpeedPatch::class, RememberPlaybackSpeedPatch::class]) +@VideoSpeedCompatibility @Version("0.0.1") -class VideoSpeeds : BytecodePatch() { +class VideoSpeed : BytecodePatch() { + override fun execute(context: BytecodeContext): PatchResult { return PatchResultSuccess() // All patches this patch depends on succeed. - } + } diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/annotation/RememberPlaybackSpeedCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeedCompatibility.kt similarity index 64% rename from src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/annotation/RememberPlaybackSpeedCompatibility.kt rename to src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeedCompatibility.kt index 5a6c1bfc..cdcebb23 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/annotation/RememberPlaybackSpeedCompatibility.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/VideoSpeedCompatibility.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.video.speed.remember.annotation +package app.revanced.patches.youtube.video.speed import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Package @@ -7,4 +7,4 @@ import app.revanced.patcher.annotation.Package [Package("com.google.android.youtube", arrayOf("18.08.37", "18.15.40", "18.16.37"))] ) @Target(AnnotationTarget.CLASS) -internal annotation class RememberPlaybackSpeedCompatibility +internal annotation class VideoSpeedCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/annotations/CustomPlaybackSpeedCompatibility.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/annotations/CustomPlaybackSpeedCompatibility.kt deleted file mode 100644 index 520d10c4..00000000 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/annotations/CustomPlaybackSpeedCompatibility.kt +++ /dev/null @@ -1,24 +0,0 @@ -package app.revanced.patches.youtube.video.speed.custom.annotations - -import app.revanced.patcher.annotation.Compatibility -import app.revanced.patcher.annotation.Package - -@Compatibility( - [Package( - "com.google.android.youtube", arrayOf( - "17.49.37", - "18.03.36", - "18.03.42", - "18.04.35", - "18.04.41", - "18.05.32", - "18.05.35", - "18.05.40", - "18.08.37", - "18.15.40", - "18.16.37" - ) - )] -) -@Target(AnnotationTarget.CLASS) -internal annotation class CustomPlaybackSpeedCompatibility diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomVideoSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomVideoSpeedPatch.kt index 698fb589..020104b6 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomVideoSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/custom/patch/CustomVideoSpeedPatch.kt @@ -13,7 +13,6 @@ import app.revanced.patches.shared.settings.preference.impl.StringResource import app.revanced.patches.shared.settings.preference.impl.TextPreference import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch -import app.revanced.patches.youtube.video.speed.custom.annotations.CustomPlaybackSpeedCompatibility import app.revanced.patches.youtube.video.speed.custom.fingerprints.SpeedArrayGeneratorFingerprint import app.revanced.patches.youtube.video.speed.custom.fingerprints.SpeedLimiterFingerprint import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction @@ -25,7 +24,6 @@ import org.jf.dexlib2.iface.reference.MethodReference @Name("custom-video-speed") @Description("Adds custom video speed options.") @DependsOn([IntegrationsPatch::class]) -@CustomPlaybackSpeedCompatibility @Version("0.0.1") class CustomVideoSpeedPatch : BytecodePatch( listOf( @@ -98,10 +96,12 @@ class CustomVideoSpeedPatch : BytecodePatch( val limiterMethod = SpeedLimiterFingerprint.result?.mutableMethod!! val limiterMethodImpl = limiterMethod.implementation!! + val lowerLimitConst = 0.25f.toRawBits() + val upperLimitConst = 2.0f.toRawBits() val (limiterMinConstIndex, limiterMinConst) = limiterMethodImpl.instructions.withIndex() - .first { (it.value as? NarrowLiteralInstruction)?.narrowLiteral == 0.25f.toRawBits() } + .first { (it.value as? NarrowLiteralInstruction)?.narrowLiteral == lowerLimitConst } val (limiterMaxConstIndex, limiterMaxConst) = limiterMethodImpl.instructions.withIndex() - .first { (it.value as? NarrowLiteralInstruction)?.narrowLiteral == 2.0f.toRawBits() } + .first { (it.value as? NarrowLiteralInstruction)?.narrowLiteral == upperLimitConst } val limiterMinConstDestination = (limiterMinConst as OneRegisterInstruction).registerA val limiterMaxConstDestination = (limiterMaxConst as OneRegisterInstruction).registerA diff --git a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt index dab6f961..ae8c781e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/video/speed/remember/patch/RememberPlaybackSpeedPatch.kt @@ -11,7 +11,6 @@ import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.settings.preference.impl.ArrayResource import app.revanced.patches.shared.settings.preference.impl.ListPreference @@ -22,13 +21,11 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch import app.revanced.patches.youtube.video.information.patch.VideoInformationPatch import app.revanced.patches.youtube.video.information.patch.VideoInformationPatch.Companion.reference import app.revanced.patches.youtube.video.speed.custom.patch.CustomVideoSpeedPatch -import app.revanced.patches.youtube.video.speed.remember.annotation.RememberPlaybackSpeedCompatibility import app.revanced.patches.youtube.video.speed.remember.fingerprint.InitializePlaybackSpeedValuesFingerprint @Name("remember-playback-speed") @Description("Adds the ability to remember the playback speed you chose in the video playback speed flyout.") @DependsOn([IntegrationsPatch::class, SettingsPatch::class, VideoInformationPatch::class, CustomVideoSpeedPatch::class]) -@RememberPlaybackSpeedCompatibility @Version("0.0.1") class RememberPlaybackSpeedPatch : BytecodePatch( listOf(