feat(twitch): 15.4.1 support (#2462)

This commit is contained in:
LisoUseInAIKyrios 2023-06-21 22:04:00 +04:00 committed by GitHub
parent becb033dc9
commit 826ed49c7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 52 additions and 91 deletions

View File

@ -3,20 +3,7 @@ package app.revanced.patches.twitch.ad.audio.annotations
import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility([Package("tv.twitch.android.app", arrayOf("15.4.1"))])
[
Package(
"tv.twitch.android.app", arrayOf(
"14.3.3",
"14.4.0",
"14.5.0",
"14.5.2",
"14.6.0",
"14.6.1"
)
)
]
)
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)
internal annotation class AudioAdsCompatibility internal annotation class AudioAdsCompatibility

View File

@ -3,20 +3,7 @@ package app.revanced.patches.twitch.ad.embedded.annotations
import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility([Package("tv.twitch.android.app", arrayOf("15.4.1"))])
[
Package(
"tv.twitch.android.app", arrayOf(
"14.3.3",
"14.4.0",
"14.5.0",
"14.5.2",
"14.6.0",
"14.6.1"
)
)
]
)
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)
internal annotation class EmbeddedAdsCompatibility internal annotation class EmbeddedAdsCompatibility

View File

@ -3,20 +3,7 @@ package app.revanced.patches.twitch.ad.video.annotations
import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility([Package("tv.twitch.android.app", arrayOf("15.4.1"))])
[
Package(
"tv.twitch.android.app", arrayOf(
"14.3.3",
"14.4.0",
"14.5.0",
"14.5.2",
"14.6.0",
"14.6.1"
)
)
]
)
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)
internal annotation class VideoAdsCompatibility internal annotation class VideoAdsCompatibility

View File

@ -1,15 +1,12 @@
package app.revanced.patches.twitch.ad.video.fingerprints package app.revanced.patches.twitch.ad.video.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object CheckAdEligibilityLambdaFingerprint : MethodFingerprint( object CheckAdEligibilityLambdaFingerprint : MethodFingerprint(
"L", returnType = "Lio/reactivex/Single;",
AccessFlags.PRIVATE or AccessFlags.FINAL or AccessFlags.STATIC, parameters = listOf("L"),
listOf("L", "L", "L"),
customFingerprint = { method, _ -> customFingerprint = { method, _ ->
method.definingClass.endsWith("AdEligibilityFetcher;") && method.definingClass.endsWith("/AdEligibilityFetcher;")
method.name.contains("shouldRequestAd") && method.name == "shouldRequestAd"
} }
) )

View File

@ -1,10 +1,11 @@
package app.revanced.patches.twitch.ad.video.fingerprints package app.revanced.patches.twitch.ad.video.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object ContentConfigShowAdsFingerprint : MethodFingerprint( object ContentConfigShowAdsFingerprint : MethodFingerprint(
returnType = "Z",
parameters = listOf(),
customFingerprint = { method, _ -> customFingerprint = { method, _ ->
method.definingClass.endsWith("ContentConfigData;") && method.name == "getShowAds" method.definingClass.endsWith("/ContentConfigData;") && method.name == "getShowAds"
} }
) )

View File

@ -3,6 +3,8 @@ package app.revanced.patches.twitch.ad.video.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object GetReadyToShowAdFingerprint : MethodFingerprint( object GetReadyToShowAdFingerprint : MethodFingerprint(
returnType = "Ltv/twitch/android/core/mvp/presenter/StateAndAction;",
parameters = listOf("L", "L"),
customFingerprint = { method, _ -> customFingerprint = { method, _ ->
method.definingClass.endsWith("/StreamDisplayAdsPresenter;") && method.name == "getReadyToShowAdOrAbort" method.definingClass.endsWith("/StreamDisplayAdsPresenter;") && method.name == "getReadyToShowAdOrAbort"
} }

View File

@ -1,5 +1,6 @@
package app.revanced.patches.twitch.ad.video.patch package app.revanced.patches.twitch.ad.video.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version import app.revanced.patcher.annotation.Version
@ -86,7 +87,7 @@ class VideoAdsPatch : AbstractAdPatch(
) )
// Pretend our player is ineligible for all ads // Pretend our player is ineligible for all ads
with(CheckAdEligibilityLambdaFingerprint.result!!) { CheckAdEligibilityLambdaFingerprint.result?.apply {
mutableMethod.addInstructionsWithLabels( mutableMethod.addInstructionsWithLabels(
0, 0,
""" """
@ -98,9 +99,9 @@ class VideoAdsPatch : AbstractAdPatch(
""", """,
ExternalLabel(skipLabelName, mutableMethod.getInstruction(0)) ExternalLabel(skipLabelName, mutableMethod.getInstruction(0))
) )
} } ?: return CheckAdEligibilityLambdaFingerprint.toErrorResult()
with(GetReadyToShowAdFingerprint.result!!) { GetReadyToShowAdFingerprint.result?.apply {
val adFormatDeclined = "Ltv/twitch/android/shared/display/ads/theatre/StreamDisplayAdsPresenter\$Action\$AdFormatDeclined;" val adFormatDeclined = "Ltv/twitch/android/shared/display/ads/theatre/StreamDisplayAdsPresenter\$Action\$AdFormatDeclined;"
mutableMethod.addInstructionsWithLabels( mutableMethod.addInstructionsWithLabels(
0, 0,
@ -113,10 +114,10 @@ class VideoAdsPatch : AbstractAdPatch(
""", """,
ExternalLabel(skipLabelName, mutableMethod.getInstruction(0)) ExternalLabel(skipLabelName, mutableMethod.getInstruction(0))
) )
} } ?: return GetReadyToShowAdFingerprint.toErrorResult()
// Spoof showAds JSON field // Spoof showAds JSON field
with(ContentConfigShowAdsFingerprint.result!!) { ContentConfigShowAdsFingerprint.result?.apply {
mutableMethod.addInstructions(0, """ mutableMethod.addInstructions(0, """
${createConditionInstructions()} ${createConditionInstructions()}
const/4 v0, 0 const/4 v0, 0
@ -124,7 +125,7 @@ class VideoAdsPatch : AbstractAdPatch(
return v0 return v0
""" """
) )
} } ?: return ContentConfigShowAdsFingerprint.toErrorResult()
SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences( SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences(
SwitchPreference( SwitchPreference(

View File

@ -3,7 +3,7 @@ package app.revanced.patches.twitch.chat.antidelete.annotations
import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package import app.revanced.patcher.annotation.Package
@Compatibility([Package("tv.twitch.android.app")]) @Compatibility([Package("tv.twitch.android.app", arrayOf("15.4.1"))])
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)
internal annotation class ShowDeletedMessagesCompatibility internal annotation class ShowDeletedMessagesCompatibility

View File

@ -1,5 +1,6 @@
package app.revanced.patches.twitch.chat.antidelete.patch package app.revanced.patches.twitch.chat.antidelete.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version import app.revanced.patcher.annotation.Version
@ -44,7 +45,7 @@ class ShowDeletedMessagesPatch : BytecodePatch(
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
// Spoiler mode: Force set hasModAccess member to true in constructor // Spoiler mode: Force set hasModAccess member to true in constructor
DeletedMessageClickableSpanCtorFingerprint.result!!.mutableMethod.apply { DeletedMessageClickableSpanCtorFingerprint.result?.mutableMethod?.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
implementation!!.instructions.lastIndex, /* place in front of return-void */ implementation!!.instructions.lastIndex, /* place in front of return-void */
""" """
@ -54,14 +55,14 @@ class ShowDeletedMessagesPatch : BytecodePatch(
""", """,
ExternalLabel("no_spoiler", getInstruction(implementation!!.instructions.lastIndex)) ExternalLabel("no_spoiler", getInstruction(implementation!!.instructions.lastIndex))
) )
} } ?: return DeletedMessageClickableSpanCtorFingerprint.toErrorResult()
// Spoiler mode: Disable setHasModAccess setter // Spoiler mode: Disable setHasModAccess setter
SetHasModAccessFingerprint.result!!.mutableMethod.addInstruction(0, "return-void") SetHasModAccessFingerprint.result?.mutableMethod?.addInstruction(0, "return-void")
?: return SetHasModAccessFingerprint.toErrorResult()
// Cross-out mode: Reformat span of deleted message // Cross-out mode: Reformat span of deleted message
ChatUtilCreateDeletedSpanFingerprint.result!!.mutableMethod.apply { ChatUtilCreateDeletedSpanFingerprint.result?.mutableMethod?.apply {
addInstructionsWithLabels( addInstructionsWithLabels(
0, 0,
""" """
@ -72,7 +73,7 @@ class ShowDeletedMessagesPatch : BytecodePatch(
""", """,
ExternalLabel("no_reformat", getInstruction(0)) ExternalLabel("no_reformat", getInstruction(0))
) )
} } ?: return ChatUtilCreateDeletedSpanFingerprint.toErrorResult()
SettingsPatch.PreferenceScreen.CHAT.GENERAL.addPreferences( SettingsPatch.PreferenceScreen.CHAT.GENERAL.addPreferences(
ListPreference( ListPreference(

View File

@ -3,6 +3,6 @@ package app.revanced.patches.twitch.chat.autoclaim.annotations
import app.revanced.patcher.annotation.Compatibility import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package import app.revanced.patcher.annotation.Package
@Compatibility([Package("tv.twitch.android.app")]) @Compatibility([Package("tv.twitch.android.app", arrayOf("15.4.1"))])
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)
internal annotation class AutoClaimChannelPointsCompatibility internal annotation class AutoClaimChannelPointsCompatibility

View File

@ -65,6 +65,7 @@ class AutoClaimChannelPointPatch : BytecodePatch(
ExternalLabel("auto_claim", getInstruction(lastIndex)) ExternalLabel("auto_claim", getInstruction(lastIndex))
) )
} ?: return CommunityPointsButtonViewDelegateFingerprint.toErrorResult() } ?: return CommunityPointsButtonViewDelegateFingerprint.toErrorResult()
return PatchResultSuccess() return PatchResultSuccess()
} }
} }

View File

@ -1,10 +1,9 @@
package app.revanced.patches.twitch.debug.fingerprints package app.revanced.patches.twitch.debug.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object IsDebugConfigEnabledFingerprint : MethodFingerprint( object IsDebugConfigEnabledFingerprint : MethodFingerprint(
customFingerprint = { methodDef, _ -> customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("BuildConfigUtil;") && methodDef.name == "isDebugConfigEnabled" methodDef.definingClass.endsWith("/BuildConfigUtil;") && methodDef.name == "isDebugConfigEnabled"
} }
) )

View File

@ -1,10 +1,9 @@
package app.revanced.patches.twitch.debug.fingerprints package app.revanced.patches.twitch.debug.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object IsOmVerificationEnabledFingerprint : MethodFingerprint( object IsOmVerificationEnabledFingerprint : MethodFingerprint(
customFingerprint = { methodDef, _ -> customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("BuildConfigUtil;") && methodDef.name == "isOmVerificationEnabled" methodDef.definingClass.endsWith("/BuildConfigUtil;") && methodDef.name == "isOmVerificationEnabled"
} }
) )

View File

@ -1,10 +1,9 @@
package app.revanced.patches.twitch.debug.fingerprints package app.revanced.patches.twitch.debug.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object ShouldShowDebugOptionsFingerprint : MethodFingerprint( object ShouldShowDebugOptionsFingerprint : MethodFingerprint(
customFingerprint = { methodDef, _ -> customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("BuildConfigUtil;") && methodDef.name == "shouldShowDebugOptions" methodDef.definingClass.endsWith("/BuildConfigUtil;") && methodDef.name == "shouldShowDebugOptions"
} }
) )

View File

@ -1,5 +1,6 @@
package app.revanced.patches.twitch.debug.patch package app.revanced.patches.twitch.debug.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version import app.revanced.patcher.annotation.Version
@ -38,8 +39,7 @@ class DebugModePatch : BytecodePatch(
IsOmVerificationEnabledFingerprint, IsOmVerificationEnabledFingerprint,
ShouldShowDebugOptionsFingerprint ShouldShowDebugOptionsFingerprint
).forEach { ).forEach {
with(it.result!!) { it.result?.mutableMethod?.apply {
with(mutableMethod) {
addInstructions( addInstructions(
0, 0,
""" """
@ -48,8 +48,7 @@ class DebugModePatch : BytecodePatch(
return v0 return v0
""" """
) )
} } ?: return it.toErrorResult()
}
} }
SettingsPatch.PreferenceScreen.MISC.OTHER.addPreferences( SettingsPatch.PreferenceScreen.MISC.OTHER.addPreferences(

View File

@ -1,5 +1,6 @@
package app.revanced.patches.twitch.misc.settings.bytecode.patch package app.revanced.patches.twitch.misc.settings.bytecode.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version import app.revanced.patcher.annotation.Version
@ -45,7 +46,7 @@ class SettingsPatch : BytecodePatch(
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
// Hook onCreate to handle fragment creation // Hook onCreate to handle fragment creation
with(SettingsActivityOnCreateFingerprint.result!!) { SettingsActivityOnCreateFingerprint.result?.apply {
val insertIndex = mutableMethod.implementation!!.instructions.size - 2 val insertIndex = mutableMethod.implementation!!.instructions.size - 2
mutableMethod.addInstructionsWithLabels( mutableMethod.addInstructionsWithLabels(
insertIndex, insertIndex,
@ -57,20 +58,20 @@ class SettingsPatch : BytecodePatch(
""", """,
ExternalLabel("no_rv_settings_init", mutableMethod.getInstruction(insertIndex)) ExternalLabel("no_rv_settings_init", mutableMethod.getInstruction(insertIndex))
) )
} } ?: return SettingsActivityOnCreateFingerprint.toErrorResult()
// Create new menu item for settings menu // Create new menu item for settings menu
with(SettingsMenuItemEnumFingerprint.result!!) { SettingsMenuItemEnumFingerprint.result?.apply {
injectMenuItem( injectMenuItem(
REVANCED_SETTINGS_MENU_ITEM_NAME, REVANCED_SETTINGS_MENU_ITEM_NAME,
REVANCED_SETTINGS_MENU_ITEM_ID, REVANCED_SETTINGS_MENU_ITEM_ID,
REVANCED_SETTINGS_MENU_ITEM_TITLE_RES, REVANCED_SETTINGS_MENU_ITEM_TITLE_RES,
REVANCED_SETTINGS_MENU_ITEM_ICON_RES REVANCED_SETTINGS_MENU_ITEM_ICON_RES
) )
} } ?: return SettingsMenuItemEnumFingerprint.toErrorResult()
// Intercept settings menu creation and add new menu item // Intercept settings menu creation and add new menu item
with(MenuGroupsUpdatedFingerprint.result!!) { MenuGroupsUpdatedFingerprint.result?.apply {
mutableMethod.addInstructions( mutableMethod.addInstructions(
0, 0,
""" """
@ -79,10 +80,10 @@ class SettingsPatch : BytecodePatch(
move-result-object p1 move-result-object p1
""" """
) )
} } ?: return MenuGroupsUpdatedFingerprint.toErrorResult()
// Intercept onclick events for the settings menu // Intercept onclick events for the settings menu
with(MenuGroupsOnClickFingerprint.result!!) { MenuGroupsOnClickFingerprint.result?.apply {
val insertIndex = 0 val insertIndex = 0
mutableMethod.addInstructionsWithLabels( mutableMethod.addInstructionsWithLabels(
insertIndex, insertIndex,
@ -96,7 +97,7 @@ class SettingsPatch : BytecodePatch(
""", """,
ExternalLabel("no_rv_settings_onclick", mutableMethod.getInstruction(insertIndex)) ExternalLabel("no_rv_settings_onclick", mutableMethod.getInstruction(insertIndex))
) )
} } ?: return MenuGroupsOnClickFingerprint.toErrorResult()
addString("revanced_settings", "ReVanced Settings", false) addString("revanced_settings", "ReVanced Settings", false)
addString("revanced_reboot_message", "Twitch needs to restart to apply your changes. Restart now?", false) addString("revanced_reboot_message", "Twitch needs to restart to apply your changes. Restart now?", false)