Skip to content

Commit 2954ba7

Browse files
authored
fix(Tumblr): Restore compatibility with latest versions (ReVanced#2955)
1 parent 912a77a commit 2954ba7

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package app.revanced.patches.tumblr.annoyances.popups.fingerprints
22

3+
import app.revanced.patcher.extensions.or
34
import app.revanced.patcher.fingerprint.MethodFingerprint
5+
import com.android.tools.smali.dexlib2.AccessFlags
46

57
// This method is responsible for loading and displaying the visual Layout of the Gift Message Popup.
68
internal object ShowGiftMessagePopupFingerprint : MethodFingerprint(
7-
strings = listOf("activity", "anchorView"),
8-
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("GiftMessagePopup;") }
9+
strings = listOf("activity", "anchorView", "textMessage"),
10+
returnType = "V",
11+
accessFlags = AccessFlags.FINAL or AccessFlags.PUBLIC
912
)

src/main/kotlin/app/revanced/patches/tumblr/featureflags/OverrideFeatureFlagsPatch.kt

+6-3
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ object OverrideFeatureFlagsPatch : BytecodePatch(
2828
internal lateinit var addOverride: (name: String, value: String) -> Unit private set
2929

3030
override fun execute(context: BytecodeContext) = GetFeatureValueFingerprint.result?.let {
31+
val configurationClass = it.method.definingClass
32+
val featureClass = it.method.parameterTypes[0].toString()
33+
3134
// The method we want to inject into does not have enough registers, so we inject a helper method
3235
// and inject more instructions into it later, see addOverride.
3336
// This is not in an integration since the unused variable would get compiled away and the method would
3437
// get compiled to only have one register, which is not enough for our later injected instructions.
3538
val helperMethod = ImmutableMethod(
3639
it.method.definingClass,
3740
"getValueOverride",
38-
listOf(ImmutableMethodParameter("Lcom/tumblr/configuration/Feature;", null, "feature")),
41+
listOf(ImmutableMethodParameter(featureClass, null, "feature")),
3942
"Ljava/lang/String;",
4043
AccessFlags.PUBLIC or AccessFlags.FINAL,
4144
null,
@@ -50,7 +53,7 @@ object OverrideFeatureFlagsPatch : BytecodePatch(
5053
0,
5154
"""
5255
# toString() the enum value
53-
invoke-virtual {p1}, Lcom/tumblr/configuration/Feature;->toString()Ljava/lang/String;
56+
invoke-virtual {p1}, $featureClass->toString()Ljava/lang/String;
5457
move-result-object v0
5558
5659
# !!! If you add more instructions above this line, update helperInsertIndex below!
@@ -75,7 +78,7 @@ object OverrideFeatureFlagsPatch : BytecodePatch(
7578
getFeatureIndex,
7679
"""
7780
# Call the Helper Method with the Feature
78-
invoke-virtual {p0, p1}, Lcom/tumblr/configuration/Configuration;->getValueOverride(Lcom/tumblr/configuration/Feature;)Ljava/lang/String;
81+
invoke-virtual {p0, p1}, $configurationClass->getValueOverride($featureClass)Ljava/lang/String;
7982
move-result-object v0
8083
# If it returned null, skip
8184
if-eqz v0, :is_null

src/main/kotlin/app/revanced/patches/tumblr/featureflags/fingerprints/GetFeatureValueFingerprint.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package app.revanced.patches.tumblr.featureflags.fingerprints
22

3+
import app.revanced.patcher.extensions.or
34
import app.revanced.patcher.fingerprint.MethodFingerprint
5+
import com.android.tools.smali.dexlib2.AccessFlags
46
import com.android.tools.smali.dexlib2.Opcode
57

68
// 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(
1921
Opcode.INVOKE_STATIC,
2022
Opcode.MOVE_RESULT
2123
),
22-
customFingerprint = { method, _ -> method.definingClass == "Lcom/tumblr/configuration/Configuration;" }
24+
returnType = "Ljava/lang/String;",
25+
parameters = listOf("L", "Z"),
26+
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL
2327
)

src/main/kotlin/app/revanced/patches/tumblr/live/DisableTumblrLivePatch.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import app.revanced.patches.tumblr.featureflags.OverrideFeatureFlagsPatch
88
import app.revanced.patches.tumblr.timelinefilter.TimelineFilterPatch
99

1010
@Patch(
11-
name = "Disable Tumblr Live",
1211
description = "Disable the Tumblr Live tab button and dashboard carousel.",
1312
dependencies = [OverrideFeatureFlagsPatch::class, TimelineFilterPatch::class],
1413
compatiblePackages = [CompatiblePackage("com.tumblr")],
1514
)
15+
@Deprecated("Tumblr Live was removed and is no longer served in the feed, making this patch useless.")
1616
@Suppress("unused")
1717
object DisableTumblrLivePatch : BytecodePatch(emptySet()) {
1818
override fun execute(context: BytecodeContext) {

0 commit comments

Comments
 (0)