Skip to content

Commit 96e73ea

Browse files
committed
feat(duolingo/music): Refactor FullSongsPatch for constructor retrieval
- Replace the constructor retrieval method with a more explicit approach using MethodUtil. - Ensure compatibility with the latest structure of the musicCourseFingerprint class. - Maintain functionality to unlock licensed songs by modifying the access field. No breaking changes introduced.
1 parent a5ce75a commit 96e73ea

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

patches/src/main/kotlin/app/revanced/patches/duolingo/music/FullSongsPatch.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
44
import app.revanced.patcher.extensions.InstructionExtensions.instructions
55
import app.revanced.patcher.patch.bytecodePatch
66
import app.revanced.patches.duolingo.shared.Utils.fieldFromToString
7-
import app.revanced.util.constructor
7+
import com.android.tools.smali.dexlib2.AccessFlags
8+
import com.android.tools.smali.dexlib2.util.MethodUtil
89

910
@Suppress("unused")
10-
val UnlockFullSongsPatch = bytecodePatch(
11+
val unlockFullSongsPatch = bytecodePatch(
1112
name = "Unlock licensed songs",
1213
description = "Allows playing the full version of licensed music instead of the 30-second preview."
1314
) {
@@ -16,7 +17,7 @@ val UnlockFullSongsPatch = bytecodePatch(
1617
execute {
1718
musicCourseFingerprint.classDef.apply {
1819
val accessField = this.fieldFromToString("licensedMusicAccess")
19-
val constructor = this.constructor()
20+
val constructor = this.methods.first { MethodUtil.isConstructor(it) }
2021
constructor.addInstructions(
2122
constructor.instructions.count() - 1,
2223
"""

0 commit comments

Comments
 (0)