Skip to content

Commit

Permalink
fix(YT Music): Support latest versions
Browse files Browse the repository at this point in the history
  • Loading branch information
YT-Advanced committed Apr 1, 2024
1 parent 81811d0 commit 26dc7d8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,35 @@ import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c

object BackgroundPlaybackParentFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = emptyList(),
accessFlags = AccessFlags.PUBLIC or AccessFlags.PUBLIC,
parameters = listOf("L"),
opcodes = listOf(
Opcode.INVOKE_STATIC,
Opcode.INVOKE_STATIC, // target method
Opcode.MOVE_RESULT,
Opcode.IF_NEZ,
Opcode.CONST_4,
Opcode.GOTO,
Opcode.NOP
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT
),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/WatchFragment;") }
customFingerprint = custom@{ methodDef, _ ->
if (methodDef.name != "handleVideoStageEvent")
return@custom false

val instructions = methodDef.implementation?.instructions!!

for (instruction in instructions) {
if (instruction.opcode != Opcode.INVOKE_STATIC)
continue

val invokeInstruction = instruction as Instruction35c

if (invokeInstruction?.reference.toString() == "Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;")
return@custom true
}
return@custom false
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
Expand All @@ -19,7 +20,7 @@ import app.revanced.util.getWideLiteralInstructionIndex
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.Reference

@Patch(
Expand All @@ -40,17 +41,25 @@ object HideGetPremiumPatch : BytecodePatch(

HideGetPremiumFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex
val register = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
val insertIndex = it.scanResult.patternScanResult!!.endIndex

val setVisibilityInstruction = getInstruction<FiveRegisterInstruction>(insertIndex)
val getPremiumViewRegister = setVisibilityInstruction.registerC
val visibilityRegister = setVisibilityInstruction.registerD

replaceInstruction(
insertIndex,
"const/16 v$visibilityRegister, 0x8",
)

addInstruction(
insertIndex + 1,
"const/4 v$register, 0x0"
"invoke-virtual {v$getPremiumViewRegister, v$visibilityRegister}, " +
"Landroid/view/View;->setVisibility(I)V",
)
}
} ?: throw HideGetPremiumFingerprint.exception


AccountMenuFooterFingerprint.result?.let {
it.mutableMethod.apply {
val targetIndex = getWideLiteralInstructionIndex(PrivacyTosFooter) + 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ object HideGetPremiumFingerprint : MethodFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = emptyList(),
opcodes = listOf(
Opcode.IGET_BOOLEAN,
Opcode.CONST_4,
Opcode.IF_EQZ,
Opcode.IGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_STATIC
Opcode.IF_NEZ,
Opcode.CONST_16,
Opcode.INVOKE_VIRTUAL
),
strings = listOf("FEmusic_history")
strings = listOf("FEmusic_history", "FEmusic_offline")
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ object VideoLengthFingerprint : MethodFingerprint(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_WIDE,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_WIDE,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT
Opcode.MOVE_RESULT_WIDE
)
)

0 comments on commit 26dc7d8

Please sign in to comment.