Skip to content

Commit

Permalink
fix(youtube/video-speed): add compatibility annotation (ReVanced#2156)
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed May 14, 2023
1 parent 6f45b32 commit ffa2e5d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.

}

}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit ffa2e5d

Please sign in to comment.