mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-12-12 20:33:55 +01:00
feat(Duolingo - Enable debug menu): Support latest app target (#6163)
This commit is contained in:
committed by
GitHub
parent
7283b93cea
commit
08baa19b4a
@@ -1,26 +1,35 @@
|
|||||||
package app.revanced.patches.duolingo.debug
|
package app.revanced.patches.duolingo.debug
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.patch.bytecodePatch
|
import app.revanced.patcher.patch.bytecodePatch
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
import app.revanced.util.returnEarly
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
val enableDebugMenuPatch = bytecodePatch(
|
val enableDebugMenuPatch = bytecodePatch(
|
||||||
name = "Enable debug menu",
|
name = "Enable debug menu",
|
||||||
use = false,
|
use = false
|
||||||
) {
|
) {
|
||||||
compatibleWith("com.duolingo"("5.158.4"))
|
compatibleWith("com.duolingo")
|
||||||
|
|
||||||
execute {
|
execute {
|
||||||
initializeBuildConfigProviderFingerprint.method.apply {
|
// It seems all categories are allowed on release. Force this on anyway.
|
||||||
val insertIndex = initializeBuildConfigProviderFingerprint.patternMatch!!.startIndex
|
debugCategoryAllowOnReleaseBuildsFingerprint.method.returnEarly(true)
|
||||||
val register = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
|
||||||
|
|
||||||
addInstructions(
|
// Change build config debug build flag.
|
||||||
insertIndex,
|
buildConfigProviderConstructorFingerprint.match(
|
||||||
"const/4 v$register, 0x1",
|
buildConfigProviderToStringFingerprint.classDef
|
||||||
|
).let {
|
||||||
|
val index = it.patternMatch!!.startIndex
|
||||||
|
|
||||||
|
it.method.apply {
|
||||||
|
val register = getInstruction<OneRegisterInstruction>(index).registerA
|
||||||
|
addInstruction(
|
||||||
|
index + 1,
|
||||||
|
"const/4 v$register, 0x1"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,16 +4,25 @@ import app.revanced.patcher.fingerprint
|
|||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
|
||||||
/**
|
internal val debugCategoryAllowOnReleaseBuildsFingerprint = fingerprint {
|
||||||
* The `BuildConfigProvider` class has two booleans:
|
returns("Z")
|
||||||
*
|
parameters()
|
||||||
* - `isChina`: (usually) compares "play" with "china"...except for builds in China
|
custom { method, classDef ->
|
||||||
* - `isDebug`: compares "release" with "debug" <-- we want to force this to `true`
|
method.name == "getAllowOnReleaseBuilds" && classDef.type == "Lcom/duolingo/debug/DebugCategory;"
|
||||||
*/
|
}
|
||||||
|
}
|
||||||
internal val initializeBuildConfigProviderFingerprint = fingerprint {
|
|
||||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
|
internal val buildConfigProviderConstructorFingerprint = fingerprint {
|
||||||
returns("V")
|
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
|
||||||
opcodes(Opcode.IPUT_BOOLEAN)
|
parameters()
|
||||||
strings("debug", "release", "china")
|
opcodes(Opcode.CONST_4)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal val buildConfigProviderToStringFingerprint = fingerprint {
|
||||||
|
parameters()
|
||||||
|
returns("Ljava/lang/String;")
|
||||||
|
strings("BuildConfigProvider(") // Partial string match.
|
||||||
|
custom { method, _ ->
|
||||||
|
method.name == "toString"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user