From 2954ba78d21d77308404961f79234bbec606d42e Mon Sep 17 00:00:00 2001 From: Temm Date: Sat, 30 Mar 2024 23:08:34 +0100 Subject: [PATCH] fix(Tumblr): Restore compatibility with latest versions (#2955) --- .../fingerprints/ShowGiftMessagePopupFingerprint.kt | 7 +++++-- .../tumblr/featureflags/OverrideFeatureFlagsPatch.kt | 9 ++++++--- .../fingerprints/GetFeatureValueFingerprint.kt | 6 +++++- .../patches/tumblr/live/DisableTumblrLivePatch.kt | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/fingerprints/ShowGiftMessagePopupFingerprint.kt b/src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/fingerprints/ShowGiftMessagePopupFingerprint.kt index c65cd029..dc5a168a 100644 --- a/src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/fingerprints/ShowGiftMessagePopupFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tumblr/annoyances/popups/fingerprints/ShowGiftMessagePopupFingerprint.kt @@ -1,9 +1,12 @@ package app.revanced.patches.tumblr.annoyances.popups.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags // This method is responsible for loading and displaying the visual Layout of the Gift Message Popup. internal object ShowGiftMessagePopupFingerprint : MethodFingerprint( - strings = listOf("activity", "anchorView"), - customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("GiftMessagePopup;") } + strings = listOf("activity", "anchorView", "textMessage"), + returnType = "V", + accessFlags = AccessFlags.FINAL or AccessFlags.PUBLIC ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tumblr/featureflags/OverrideFeatureFlagsPatch.kt b/src/main/kotlin/app/revanced/patches/tumblr/featureflags/OverrideFeatureFlagsPatch.kt index 267ab358..94367009 100644 --- a/src/main/kotlin/app/revanced/patches/tumblr/featureflags/OverrideFeatureFlagsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/tumblr/featureflags/OverrideFeatureFlagsPatch.kt @@ -28,6 +28,9 @@ object OverrideFeatureFlagsPatch : BytecodePatch( internal lateinit var addOverride: (name: String, value: String) -> Unit private set override fun execute(context: BytecodeContext) = GetFeatureValueFingerprint.result?.let { + val configurationClass = it.method.definingClass + val featureClass = it.method.parameterTypes[0].toString() + // The method we want to inject into does not have enough registers, so we inject a helper method // and inject more instructions into it later, see addOverride. // This is not in an integration since the unused variable would get compiled away and the method would @@ -35,7 +38,7 @@ object OverrideFeatureFlagsPatch : BytecodePatch( val helperMethod = ImmutableMethod( it.method.definingClass, "getValueOverride", - listOf(ImmutableMethodParameter("Lcom/tumblr/configuration/Feature;", null, "feature")), + listOf(ImmutableMethodParameter(featureClass, null, "feature")), "Ljava/lang/String;", AccessFlags.PUBLIC or AccessFlags.FINAL, null, @@ -50,7 +53,7 @@ object OverrideFeatureFlagsPatch : BytecodePatch( 0, """ # toString() the enum value - invoke-virtual {p1}, Lcom/tumblr/configuration/Feature;->toString()Ljava/lang/String; + invoke-virtual {p1}, $featureClass->toString()Ljava/lang/String; move-result-object v0 # !!! If you add more instructions above this line, update helperInsertIndex below! @@ -75,7 +78,7 @@ object OverrideFeatureFlagsPatch : BytecodePatch( getFeatureIndex, """ # Call the Helper Method with the Feature - invoke-virtual {p0, p1}, Lcom/tumblr/configuration/Configuration;->getValueOverride(Lcom/tumblr/configuration/Feature;)Ljava/lang/String; + invoke-virtual {p0, p1}, $configurationClass->getValueOverride($featureClass)Ljava/lang/String; move-result-object v0 # If it returned null, skip if-eqz v0, :is_null diff --git a/src/main/kotlin/app/revanced/patches/tumblr/featureflags/fingerprints/GetFeatureValueFingerprint.kt b/src/main/kotlin/app/revanced/patches/tumblr/featureflags/fingerprints/GetFeatureValueFingerprint.kt index d0274125..0088c3aa 100644 --- a/src/main/kotlin/app/revanced/patches/tumblr/featureflags/fingerprints/GetFeatureValueFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/tumblr/featureflags/fingerprints/GetFeatureValueFingerprint.kt @@ -1,6 +1,8 @@ package app.revanced.patches.tumblr.featureflags.fingerprints +import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode // This fingerprint targets the method to get the value of a Feature in the class "com.tumblr.configuration.Feature". @@ -19,5 +21,7 @@ internal object GetFeatureValueFingerprint : MethodFingerprint( Opcode.INVOKE_STATIC, Opcode.MOVE_RESULT ), - customFingerprint = { method, _ -> method.definingClass == "Lcom/tumblr/configuration/Configuration;" } + returnType = "Ljava/lang/String;", + parameters = listOf("L", "Z"), + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL ) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tumblr/live/DisableTumblrLivePatch.kt b/src/main/kotlin/app/revanced/patches/tumblr/live/DisableTumblrLivePatch.kt index 8cbdaca6..f5b53133 100644 --- a/src/main/kotlin/app/revanced/patches/tumblr/live/DisableTumblrLivePatch.kt +++ b/src/main/kotlin/app/revanced/patches/tumblr/live/DisableTumblrLivePatch.kt @@ -8,11 +8,11 @@ import app.revanced.patches.tumblr.featureflags.OverrideFeatureFlagsPatch import app.revanced.patches.tumblr.timelinefilter.TimelineFilterPatch @Patch( - name = "Disable Tumblr Live", description = "Disable the Tumblr Live tab button and dashboard carousel.", dependencies = [OverrideFeatureFlagsPatch::class, TimelineFilterPatch::class], compatiblePackages = [CompatiblePackage("com.tumblr")], ) +@Deprecated("Tumblr Live was removed and is no longer served in the feed, making this patch useless.") @Suppress("unused") object DisableTumblrLivePatch : BytecodePatch(emptySet()) { override fun execute(context: BytecodeContext) {