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
anddea committed Mar 30, 2024
1 parent 66fae7d commit 4575e86
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 36 deletions.
4 changes: 0 additions & 4 deletions api/revanced-patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,6 @@ public final class app/revanced/patches/music/misc/backgroundplay/BackgroundPlay
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/music/misc/backgroundplay/fingerprints/BackgroundPlaybackParentFingerprint : app/revanced/patcher/fingerprint/MethodFingerprint {
public static final field INSTANCE Lapp/revanced/patches/music/misc/backgroundplay/fingerprints/BackgroundPlaybackParentFingerprint;
}

public final class app/revanced/patches/music/misc/bitrate/BitrateDefaultValuePatch : app/revanced/patcher/patch/ResourcePatch {
public static final field INSTANCE Lapp/revanced/patches/music/misc/bitrate/BitrateDefaultValuePatch;
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package app.revanced.patches.music.misc.backgroundplay

import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.music.layout.minimizedplayback.fingerprints.KidsMinimizedPlaybackPolicyControllerFingerprint
import app.revanced.patches.music.misc.backgroundplay.fingerprints.BackgroundPlaybackParentFingerprint
import app.revanced.util.exception

Expand All @@ -16,25 +17,23 @@ import app.revanced.util.exception
)
@Suppress("unused")
object BackgroundPlayPatch : BytecodePatch(
setOf(BackgroundPlaybackParentFingerprint)
setOf(
KidsMinimizedPlaybackPolicyControllerFingerprint,
BackgroundPlaybackParentFingerprint,
),
) {
override fun execute(context: BytecodeContext) {
KidsMinimizedPlaybackPolicyControllerFingerprint.result?.mutableMethod?.addInstruction(
0,
"return-void",
) ?: throw KidsMinimizedPlaybackPolicyControllerFingerprint.exception

BackgroundPlaybackParentFingerprint.result?.let {
with(
context
.toMethodWalker(it.method)
.nextMethod(it.scanResult.patternScanResult!!.startIndex, true)
.getMethod() as MutableMethod
) {
addInstructions(
0, """
const/4 v0, 0x1
return v0
"""
)
}
} ?: throw BackgroundPlaybackParentFingerprint.exception

BackgroundPlaybackParentFingerprint.result?.mutableMethod?.addInstructions(
0,
"""
const/4 v0, 0x1
return v0
""",
) ?: throw BackgroundPlaybackParentFingerprint.exception
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode

object BackgroundPlaybackParentFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = emptyList(),
opcodes = listOf(
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT,
Opcode.IF_NEZ,
internal object BackgroundPlaybackParentFingerprint : MethodFingerprint(
"Z",
AccessFlags.PUBLIC or AccessFlags.STATIC,
listOf("L"),
listOf(
Opcode.CONST_4,
Opcode.GOTO,
Opcode.NOP
Opcode.IF_EQZ,
Opcode.IGET,
Opcode.AND_INT_LIT16,
Opcode.IF_EQZ,
Opcode.IGET_OBJECT,
Opcode.IF_NEZ,
Opcode.SGET_OBJECT,
Opcode.IGET,
),
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/WatchFragment;") }
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package app.revanced.patches.music.layout.minimizedplayback.fingerprints

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

internal object KidsMinimizedPlaybackPolicyControllerFingerprint : MethodFingerprint(
"V",
AccessFlags.PUBLIC or AccessFlags.FINAL,
listOf("I", "L", "Z"),
listOf(
Opcode.IGET,
Opcode.IF_NE,
Opcode.IGET_OBJECT,
Opcode.IF_NE,
Opcode.IGET_BOOLEAN,
Opcode.IF_EQ,
Opcode.GOTO,
Opcode.RETURN_VOID,
Opcode.SGET_OBJECT,
Opcode.CONST_4,
Opcode.IF_NE,
Opcode.IPUT_BOOLEAN,
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ object VideoLengthFingerprint : MethodFingerprint(
Opcode.MOVE_RESULT_WIDE,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_WIDE,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT
null, // Opcode.CONST_4 or Opcode.INVOKE_VIRTUAL
null, // Opcode.INVOKE_VIRTUAL or Opcode.MOVE_RESULT
null, // Opcode.MOVE_RESULT or Opcode.CONST_4
Opcode.IF_EQ
)
)

0 comments on commit 4575e86

Please sign in to comment.