Skip to content

Commit

Permalink
fix(YouTube - Theme): Fix 19.25 - 19.45 patch error
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Jan 22, 2025
1 parent f4febac commit 5b47a5f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 13 deletions.
1 change: 1 addition & 0 deletions patches/api/patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,7 @@ public final class app/revanced/patches/youtube/misc/playservice/VersionCheckPat
public static final fun is_19_43_or_greater ()Z
public static final fun is_19_46_or_greater ()Z
public static final fun is_19_47_or_greater ()Z
public static final fun is_19_49_or_greater ()Z
}

public final class app/revanced/patches/youtube/misc/privacy/RemoveTrackingQueryParameterPatchKt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.shared.misc.settings.preference.TextPreference
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.misc.playertype.playerTypeHookPatch
import app.revanced.patches.youtube.misc.playservice.is_19_23_or_greater
import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater
import app.revanced.patches.youtube.misc.playservice.is_19_43_or_greater
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.patches.youtube.shared.mainActivityFingerprint
Expand All @@ -30,7 +29,7 @@ private val swipeControlsResourcePatch = resourcePatch {
execute {
addResources("youtube", "interaction.swipecontrols.swipeControlsResourcePatch")

if (is_19_25_or_greater) {
if (is_19_43_or_greater) {
PreferenceScreen.SWIPE_CONTROLS.addPreferences(
SwitchPreference("revanced_swipe_change_video")
)
Expand Down Expand Up @@ -114,7 +113,7 @@ val swipeControlsPatch = bytecodePatch(

// region patch to enable/disable swipe to change video.

if (is_19_23_or_greater) {
if (is_19_43_or_greater) {
swipeChangeVideoFingerprint.method.insertFeatureFlagBooleanOverride(
SWIPE_CHANGE_VIDEO_FEATURE_FLAG,
"$EXTENSION_CLASS_DESCRIPTOR->allowSwipeChangeVideo(Z)Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,23 @@ internal val lithoLinearGradientFingerprint = fingerprint {
}

/**
* 29.25 - 19.50
* 19.49+
*/
internal val playerLinearGradientLegacyFingerprint = fingerprint {
internal val playerLinearGradientFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC)
parameters("I", "I", "I", "I", "Landroid/content/Context;", "I")
returns("Landroid/graphics/LinearGradient;")
opcodes(
Opcode.FILLED_NEW_ARRAY,
Opcode.MOVE_RESULT_OBJECT
)
literal { ytYoutubeMagentaColorId }
}

/**
* 19.46 - 19.47
*/
internal val playerLinearGradientLegacy1946Fingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
parameters("I", "I", "I", "I")
returns("V")
Expand All @@ -57,12 +71,11 @@ internal val playerLinearGradientLegacyFingerprint = fingerprint {
}

/**
* 20.03+
* 19.25 - 19.45
*/
internal val playerLinearGradientFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC)
parameters("I", "I", "I", "I", "Landroid/content/Context;", "I")
returns("Landroid/graphics/LinearGradient;")
internal val playerLinearGradientLegacy1925Fingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
parameters("Landroid/content/Context;")
opcodes(
Opcode.FILLED_NEW_ARRAY,
Opcode.MOVE_RESULT_OBJECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import app.revanced.patches.youtube.layout.theme.lithoColorOverrideHook
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.misc.playservice.is_19_25_or_greater
import app.revanced.patches.youtube.misc.playservice.is_19_46_or_greater
import app.revanced.patches.youtube.misc.playservice.is_19_49_or_greater
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.patches.youtube.shared.mainActivityOnCreateFingerprint
Expand Down Expand Up @@ -188,6 +189,7 @@ val seekbarColorPatch = bytecodePatch(
sharedExtensionPatch,
lithoColorHookPatch,
seekbarColorResourcePatch,
versionCheckPatch
)

execute {
Expand Down Expand Up @@ -240,8 +242,16 @@ val seekbarColorPatch = bytecodePatch(
"invoke-static/range { p4 .. p5 }, $EXTENSION_CLASS_DESCRIPTOR->setLinearGradient([I[F)V"
)

// TODO: add 20.03 support
playerLinearGradientLegacyFingerprint.let {
val playerFingerprint =
if (is_19_49_or_greater) {
playerLinearGradientFingerprint
} else if (is_19_46_or_greater) {
playerLinearGradientLegacy1946Fingerprint
} else {
playerLinearGradientLegacy1925Fingerprint
}

playerFingerprint.let {
it.method.apply {
val index = it.patternMatch!!.endIndex
val register = getInstruction<OneRegisterInstruction>(index).registerA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ var is_19_46_or_greater = false
private set
var is_19_47_or_greater = false
private set
var is_19_49_or_greater = false
private set

val versionCheckPatch = resourcePatch(
description = "Uses the Play Store service version to find the major/minor version of the YouTube target app.",
Expand Down Expand Up @@ -74,5 +76,6 @@ val versionCheckPatch = resourcePatch(
is_19_43_or_greater = 244405000 <= playStoreServicesVersion
is_19_46_or_greater = 244705000 <= playStoreServicesVersion
is_19_47_or_greater = 244799000 <= playStoreServicesVersion
is_19_49_or_greater = 245005000 <= playStoreServicesVersion
}
}

0 comments on commit 5b47a5f

Please sign in to comment.