Skip to content

Commit

Permalink
fix(music/exclusive audio playback): not compatible with latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
inotia00 committed Sep 5, 2023
1 parent bc8338a commit a1fa3a2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 39 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package app.revanced.patches.music.misc.exclusiveaudio.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags

object MusicBrowserServiceFingerprint : MethodFingerprint(
returnType = "L",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("Ljava/lang/String;", "Landroid/os/Bundle;"),
strings = listOf("MBS: Return empty root for client: %s, isFullMediaBrowserEnabled: %b, is client browsable: %b, isRedAccount: %b"),
customFingerprint = { methodDef, _ ->
methodDef.definingClass.endsWith("/MusicBrowserService;")
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,55 @@ import app.revanced.extensions.exception
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.misc.exclusiveaudio.fingerprints.AudioOnlyEnablerFingerprint
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.music.misc.exclusiveaudio.fingerprints.MusicBrowserServiceFingerprint
import app.revanced.patches.music.utils.annotations.MusicCompatibility
import app.revanced.util.bytecode.getStringIndex
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction

@Patch
@Name("Exclusive audio playback")
@Description("Enables the option to play music without video.")
@MusicCompatibility
class ExclusiveAudioPatch : BytecodePatch(
listOf(AudioOnlyEnablerFingerprint)
listOf(MusicBrowserServiceFingerprint)
) {
override fun execute(context: BytecodeContext) {

AudioOnlyEnablerFingerprint.result?.mutableMethod?.let {
it.replaceInstruction(it.implementation!!.instructions.count() - 1, "const/4 v0, 0x1")
it.addInstruction("return v0")
} ?: throw AudioOnlyEnablerFingerprint.exception
MusicBrowserServiceFingerprint.result?.let {
it.mutableMethod.apply {
val targetIndex =
getStringIndex("MBS: Return empty root for client: %s, isFullMediaBrowserEnabled: %b, is client browsable: %b, isRedAccount: %b")

for (index in targetIndex downTo 0) {
if (getInstruction(index).opcode != Opcode.INVOKE_VIRTUAL) continue

val targetReference = getInstruction<ReferenceInstruction>(index).reference

if (!targetReference.toString().endsWith("()Z")) continue

with(
context
.toMethodWalker(it.method)
.nextMethod(index, true)
.getMethod() as MutableMethod
) {
addInstructions(
0, """
const/4 v0, 0x1
return v0
"""
)
}
break
}
}
} ?: throw MusicBrowserServiceFingerprint.exception

}
}

0 comments on commit a1fa3a2

Please sign in to comment.