diff --git a/src/main/kotlin/app/revanced/patches/shared/litho/LithoFilterPatch.kt b/src/main/kotlin/app/revanced/patches/shared/litho/LithoFilterPatch.kt index 44f846c435..58beb75ffa 100644 --- a/src/main/kotlin/app/revanced/patches/shared/litho/LithoFilterPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/litho/LithoFilterPatch.kt @@ -11,14 +11,17 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patches.shared.integrations.Constants.COMPONENTS_PATH +import app.revanced.patches.shared.litho.fingerprints.BufferUpbFeatureFlagFingerprint import app.revanced.patches.shared.litho.fingerprints.ByteBufferFingerprint import app.revanced.patches.shared.litho.fingerprints.EmptyComponentsFingerprint import app.revanced.patches.shared.litho.fingerprints.PathBuilderFingerprint +import app.revanced.patches.shared.litho.fingerprints.PathUpbFeatureFlagFingerprint import app.revanced.util.findMethodsOrThrow import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.indexOfFirstInstructionReversedOrThrow import app.revanced.util.indexOfFirstStringInstructionOrThrow +import app.revanced.util.injectLiteralInstructionBooleanCall import app.revanced.util.resultOrThrow import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.Opcode @@ -38,6 +41,8 @@ object LithoFilterPatch : BytecodePatch( setOf( ByteBufferFingerprint, EmptyComponentsFingerprint, + BufferUpbFeatureFlagFingerprint, + PathUpbFeatureFlagFingerprint, ) ), Closeable { private const val INTEGRATIONS_LITHO_FILER_CLASS_DESCRIPTOR = @@ -156,6 +161,28 @@ object LithoFilterPatch : BytecodePatch( } } + // region A/B test of new Litho native code. + + // Turn off native code that handles litho component names. If this feature is on then nearly + // all litho components have a null name and identifier/path filtering is completely broken. + + if (BufferUpbFeatureFlagFingerprint.result != null && + PathUpbFeatureFlagFingerprint.result != null) { + mapOf( + BufferUpbFeatureFlagFingerprint to 45419603, + PathUpbFeatureFlagFingerprint to 45631264, + ).forEach { (fingerprint, literalValue) -> + fingerprint.result?.let { + fingerprint.injectLiteralInstructionBooleanCall( + literalValue, + "0x0" + ) + } + } + } + + // endregion + // Create a new method to get the filter array to avoid register conflicts. // This fixes an issue with Integrations compiled with Android Gradle Plugin 8.3.0+. // https://github.com/ReVanced/revanced-patches/issues/2818 diff --git a/src/main/kotlin/app/revanced/patches/shared/litho/fingerprints/BufferUpbFeatureFlagFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/litho/fingerprints/BufferUpbFeatureFlagFingerprint.kt new file mode 100644 index 0000000000..2c4dedd9f4 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/litho/fingerprints/BufferUpbFeatureFlagFingerprint.kt @@ -0,0 +1,12 @@ +package app.revanced.patches.shared.litho.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.util.fingerprint.LiteralValueFingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +internal object BufferUpbFeatureFlagFingerprint : LiteralValueFingerprint( + returnType = "L", + accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, + parameters = listOf("L"), + literalSupplier = { 45419603 }, +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/litho/fingerprints/PathUpbFeatureFlagFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/litho/fingerprints/PathUpbFeatureFlagFingerprint.kt new file mode 100644 index 0000000000..676f85a829 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/litho/fingerprints/PathUpbFeatureFlagFingerprint.kt @@ -0,0 +1,12 @@ +package app.revanced.patches.shared.litho.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.util.fingerprint.LiteralValueFingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +internal object PathUpbFeatureFlagFingerprint : LiteralValueFingerprint( + returnType = "Z", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = emptyList(), + literalSupplier = { 45631264 }, +) \ No newline at end of file