refactor: YouTube Music patches

This commit is contained in:
epicsampler 2022-04-28 15:50:43 +00:00 committed by oSumAtrIX
parent a6aeca31bd
commit 8ea34036e5
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
3 changed files with 22 additions and 11 deletions

View File

@ -3,8 +3,9 @@ package app.revanced.patches
import app.revanced.patcher.patch.Patch
import app.revanced.patches.music.audio.EnableAudioOnlyPatch
import app.revanced.patches.music.layout.RemoveUpgradeTabPatch
import app.revanced.patches.music.layout.RemoveTastebuilderPatch
import app.revanced.patches.music.layout.RemoveTasteBuilderPatch
import app.revanced.patches.music.premium.BackgroundPlayPatch
import app.revanced.patches.music.audio.CodecsUnlockPatch
import app.revanced.patches.youtube.ad.HomeAdsPatch
import app.revanced.patches.youtube.ad.HomePromoPatch
import app.revanced.patches.youtube.ad.VideoAdsPatch
@ -34,7 +35,7 @@ object Index {
::EnableSeekbarTappingPatch,
::EnableAudioOnlyPatch,
::RemoveUpgradeTabPatch,
::RemoveTastebuilderPatch,
::RemoveTasteBuilderPatch,
::BackgroundPlayPatch,
::CodecsUnlockPatch
)

View File

@ -1,4 +1,4 @@
package app.revanced.patches
package app.revanced.patches.music.audio
import app.revanced.patcher.PatcherData
import app.revanced.patcher.extensions.or
@ -22,7 +22,7 @@ private val packageMetadata = listOf(
private val patchMetadata = PatchMetadata(
"codecs-unlock",
"Audio codecs unlock patch",
"Patch to unlock more audio codecs",
"Enables more audio codecs. Usually results in better audio quality but may depend on song and device.",
packageMetadata,
"0.0.1"
)

View File

@ -20,18 +20,18 @@ private val compatiblePackages = listOf(
)
)
class RemoveTastebuilderPatch : Patch(
class RemoveTasteBuilderPatch : Patch(
PatchMetadata(
"tastebuilder-remover",
"Remove Tastebuilder Patch",
"Remove the tastebuilder from the Home screen.",
"tasteBuilder-remover",
"Remove TasteBuilder Patch",
"Removes the \"Tell us which artists you like\" card from the Home screen. The same functionality can be triggered from the settings anyway.",
compatiblePackages,
"0.0.1"
),
listOf(
MethodSignature(
MethodSignatureMetadata(
"tastebuilder-constructor",
"taste-builder-constructor",
MethodMetadata("Lkyu;", "<init>"),
PatternScanMethod.Fuzzy(2), // FIXME: Test this threshold and find the best value.
compatiblePackages,
@ -53,6 +53,14 @@ class RemoveTastebuilderPatch : Patch(
Opcode.CONST_4,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.CONST,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST,
Opcode.IPUT_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT
)
)
@ -62,7 +70,9 @@ class RemoveTastebuilderPatch : Patch(
val result = signatures.first().result!!
val implementation = result.method.implementation!!
val register = (implementation.instructions[result.scanData.endIndex] as Instruction22c).registerA
val insertIndex = result.scanData.endIndex - 8
val register = (implementation.instructions[insertIndex] as Instruction22c).registerA
val instructionList =
"""
@ -71,7 +81,7 @@ class RemoveTastebuilderPatch : Patch(
""".trimIndent().toInstructions().toMutableList()
implementation.addInstructions(
result.scanData.endIndex,
insertIndex,
instructionList
)