mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-04 08:34:27 +02:00
chore: replace with a fingerprint that supports a wider range of versions
This commit is contained in:
parent
e88c190460
commit
6360f97e54
@ -12,7 +12,7 @@ import app.revanced.patches.music.misc.backgroundplayback.fingerprints.PodCastCo
|
|||||||
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.getWalkerMethod
|
import app.revanced.util.getWalkerMethod
|
||||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||||
import app.revanced.util.indexOfFirstStringInstructionOrThrow
|
import app.revanced.util.indexOfFirstStringInstructionOrThrow
|
||||||
import app.revanced.util.patch.BaseBytecodePatch
|
import app.revanced.util.patch.BaseBytecodePatch
|
||||||
import app.revanced.util.resultOrThrow
|
import app.revanced.util.resultOrThrow
|
||||||
@ -52,8 +52,8 @@ object BackgroundPlaybackPatch : BaseBytecodePatch(
|
|||||||
// don't play music video
|
// don't play music video
|
||||||
MusicBrowserServiceFingerprint.resultOrThrow().let {
|
MusicBrowserServiceFingerprint.resultOrThrow().let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
val stringIndex = MusicBrowserServiceFingerprint.indexOfMBSInstruction(this)
|
val stringIndex = it.scanResult.stringsScanResult!!.matches.first().index
|
||||||
val targetIndex = indexOfFirstInstructionReversedOrThrow(stringIndex) {
|
val targetIndex = indexOfFirstInstructionOrThrow(stringIndex) {
|
||||||
val reference = getReference<MethodReference>()
|
val reference = getReference<MethodReference>()
|
||||||
opcode == Opcode.INVOKE_VIRTUAL &&
|
opcode == Opcode.INVOKE_VIRTUAL &&
|
||||||
reference?.returnType == "Z" &&
|
reference?.returnType == "Z" &&
|
||||||
|
@ -2,28 +2,14 @@ package app.revanced.patches.music.misc.backgroundplayback.fingerprints
|
|||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
import app.revanced.patches.music.misc.backgroundplayback.fingerprints.MusicBrowserServiceFingerprint.indexOfMBSInstruction
|
|
||||||
import app.revanced.util.getReference
|
|
||||||
import app.revanced.util.indexOfFirstInstruction
|
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
|
||||||
import com.android.tools.smali.dexlib2.iface.Method
|
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.StringReference
|
|
||||||
|
|
||||||
internal object MusicBrowserServiceFingerprint : MethodFingerprint(
|
internal object MusicBrowserServiceFingerprint : MethodFingerprint(
|
||||||
returnType = "L",
|
returnType = "L",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
parameters = listOf("Ljava/lang/String;", "Landroid/os/Bundle;"),
|
parameters = listOf("Ljava/lang/String;", "Landroid/os/Bundle;"),
|
||||||
customFingerprint = custom@{ methodDef, _ ->
|
strings = listOf("android.service.media.extra.RECENT"),
|
||||||
if (!methodDef.definingClass.endsWith("/MusicBrowserService;"))
|
customFingerprint = { methodDef, _ ->
|
||||||
return@custom false
|
methodDef.definingClass.endsWith("/MusicBrowserService;")
|
||||||
|
},
|
||||||
indexOfMBSInstruction(methodDef) >= 0
|
)
|
||||||
}
|
|
||||||
) {
|
|
||||||
fun indexOfMBSInstruction(methodDef: Method) =
|
|
||||||
methodDef.indexOfFirstInstruction {
|
|
||||||
opcode == Opcode.CONST_STRING &&
|
|
||||||
getReference<StringReference>()?.string?.startsWith("MBS: Return empty root for client: %s") == true
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,7 +8,6 @@ import app.revanced.patches.shared.mapping.ResourceMappingPatch.getId
|
|||||||
import app.revanced.patches.shared.mapping.ResourceType.BOOL
|
import app.revanced.patches.shared.mapping.ResourceType.BOOL
|
||||||
import app.revanced.patches.shared.mapping.ResourceType.COLOR
|
import app.revanced.patches.shared.mapping.ResourceType.COLOR
|
||||||
import app.revanced.patches.shared.mapping.ResourceType.DIMEN
|
import app.revanced.patches.shared.mapping.ResourceType.DIMEN
|
||||||
import app.revanced.patches.shared.mapping.ResourceType.DRAWABLE
|
|
||||||
import app.revanced.patches.shared.mapping.ResourceType.ID
|
import app.revanced.patches.shared.mapping.ResourceType.ID
|
||||||
import app.revanced.patches.shared.mapping.ResourceType.LAYOUT
|
import app.revanced.patches.shared.mapping.ResourceType.LAYOUT
|
||||||
import app.revanced.patches.shared.mapping.ResourceType.STRING
|
import app.revanced.patches.shared.mapping.ResourceType.STRING
|
||||||
|
@ -9,6 +9,7 @@ import com.android.tools.smali.dexlib2.AccessFlags
|
|||||||
* It appears this hook may no longer be needed as one of the constructor parameters is the already hooked
|
* It appears this hook may no longer be needed as one of the constructor parameters is the already hooked
|
||||||
* [EmbeddedPlayerControlsOverlayFingerprint]
|
* [EmbeddedPlayerControlsOverlayFingerprint]
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Fingerprint is obsolete and will be deleted soon")
|
||||||
internal object APIPlayerServiceFingerprint : IntegrationsFingerprint(
|
internal object APIPlayerServiceFingerprint : IntegrationsFingerprint(
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||||
customFingerprint = { methodDef, _ -> methodDef.definingClass == "Lcom/google/android/apps/youtube/embeddedplayer/service/service/jar/ApiPlayerService;" },
|
customFingerprint = { methodDef, _ -> methodDef.definingClass == "Lcom/google/android/apps/youtube/embeddedplayer/service/service/jar/ApiPlayerService;" },
|
||||||
|
@ -10,6 +10,7 @@ import com.android.tools.smali.dexlib2.AccessFlags
|
|||||||
* Note: this fingerprint may no longer be needed, as it appears
|
* Note: this fingerprint may no longer be needed, as it appears
|
||||||
* [RemoteEmbedFragmentFingerprint] may be set before this hook is called.
|
* [RemoteEmbedFragmentFingerprint] may be set before this hook is called.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Fingerprint is obsolete and will be deleted soon")
|
||||||
internal object EmbeddedPlayerControlsOverlayFingerprint : IntegrationsFingerprint(
|
internal object EmbeddedPlayerControlsOverlayFingerprint : IntegrationsFingerprint(
|
||||||
accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR,
|
accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR,
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
|
@ -10,6 +10,7 @@ import com.android.tools.smali.dexlib2.AccessFlags
|
|||||||
* Note: this fingerprint may or may not be needed, as
|
* Note: this fingerprint may or may not be needed, as
|
||||||
* [RemoteEmbedFragmentFingerprint] might be set before this is called.
|
* [RemoteEmbedFragmentFingerprint] might be set before this is called.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Fingerprint is obsolete and will be deleted soon")
|
||||||
internal object EmbeddedPlayerFingerprint : IntegrationsFingerprint(
|
internal object EmbeddedPlayerFingerprint : IntegrationsFingerprint(
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||||
returnType = "L",
|
returnType = "L",
|
||||||
|
@ -7,6 +7,7 @@ import com.android.tools.smali.dexlib2.AccessFlags
|
|||||||
/**
|
/**
|
||||||
* For embedded playback. Likely covers Google Play store and other Google products.
|
* For embedded playback. Likely covers Google Play store and other Google products.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Fingerprint is obsolete and will be deleted soon")
|
||||||
internal object RemoteEmbedFragmentFingerprint : IntegrationsFingerprint(
|
internal object RemoteEmbedFragmentFingerprint : IntegrationsFingerprint(
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
|
@ -7,6 +7,7 @@ import com.android.tools.smali.dexlib2.AccessFlags
|
|||||||
/**
|
/**
|
||||||
* For embedded playback inside 3rd party android app (such as 3rd party Reddit apps).
|
* For embedded playback inside 3rd party android app (such as 3rd party Reddit apps).
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Fingerprint is obsolete and will be deleted soon")
|
||||||
internal object RemoteEmbeddedPlayerFingerprint : IntegrationsFingerprint(
|
internal object RemoteEmbeddedPlayerFingerprint : IntegrationsFingerprint(
|
||||||
accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR,
|
accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR,
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
|
@ -56,8 +56,7 @@ object NavigationBarHookPatch : BytecodePatch(
|
|||||||
private lateinit var navigationTabCreatedCallback: MutableMethod
|
private lateinit var navigationTabCreatedCallback: MutableMethod
|
||||||
|
|
||||||
private lateinit var bottomBarContainerMethod: MutableMethod
|
private lateinit var bottomBarContainerMethod: MutableMethod
|
||||||
private var bottomBarContainerIndex = 0
|
private var bottomBarContainerOffset = 0
|
||||||
private var bottomBarContainerRegister = 0
|
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
fun MutableMethod.addHook(hook: Hook, insertPredicate: Instruction.() -> Boolean) {
|
fun MutableMethod.addHook(hook: Hook, insertPredicate: Instruction.() -> Boolean) {
|
||||||
@ -131,13 +130,8 @@ object NavigationBarHookPatch : BytecodePatch(
|
|||||||
"onBackPressed"
|
"onBackPressed"
|
||||||
)
|
)
|
||||||
|
|
||||||
InitializeBottomBarContainerFingerprint.resultOrThrow().mutableMethod.apply {
|
bottomBarContainerMethod =
|
||||||
bottomBarContainerMethod = this
|
InitializeBottomBarContainerFingerprint.resultOrThrow().mutableMethod
|
||||||
bottomBarContainerIndex =
|
|
||||||
InitializeBottomBarContainerFingerprint.indexOfLayoutChangeListenerInstruction(this)
|
|
||||||
bottomBarContainerRegister =
|
|
||||||
getInstruction<FiveRegisterInstruction>(bottomBarContainerIndex).registerC
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val hookNavigationButtonCreated: (String) -> Unit by lazy {
|
val hookNavigationButtonCreated: (String) -> Unit by lazy {
|
||||||
@ -152,11 +146,19 @@ object NavigationBarHookPatch : BytecodePatch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addBottomBarContainerHook(descriptor: String) =
|
fun addBottomBarContainerHook(descriptor: String) {
|
||||||
bottomBarContainerMethod.addInstruction(
|
bottomBarContainerMethod.apply {
|
||||||
bottomBarContainerIndex,
|
val layoutChangeListenerIndex =
|
||||||
"invoke-static { v$bottomBarContainerRegister }, $descriptor"
|
InitializeBottomBarContainerFingerprint.indexOfLayoutChangeListenerInstruction(this)
|
||||||
)
|
val bottomBarContainerRegister =
|
||||||
|
getInstruction<FiveRegisterInstruction>(layoutChangeListenerIndex).registerC
|
||||||
|
|
||||||
|
addInstruction(
|
||||||
|
layoutChangeListenerIndex + bottomBarContainerOffset--,
|
||||||
|
"invoke-static { v$bottomBarContainerRegister }, $descriptor"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private enum class Hook(val methodName: String, val parameters: String) {
|
private enum class Hook(val methodName: String, val parameters: String) {
|
||||||
SET_LAST_APP_NAVIGATION_ENUM("setLastAppNavigationEnum", "Ljava/lang/Enum;"),
|
SET_LAST_APP_NAVIGATION_ENUM("setLastAppNavigationEnum", "Ljava/lang/Enum;"),
|
||||||
|
@ -2,20 +2,26 @@ package app.revanced.patches.youtube.utils.playertype.fingerprint
|
|||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import app.revanced.util.getReference
|
||||||
|
import app.revanced.util.indexOfFirstInstruction
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||||
|
|
||||||
internal object VideoStateFingerprint : MethodFingerprint(
|
internal object VideoStateFingerprint : MethodFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
parameters = listOf("L"),
|
parameters = listOf("Lcom/google/android/libraries/youtube/player/features/overlay/controls/ControlsState;"),
|
||||||
opcodes = listOf(
|
opcodes = listOf(
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.CONST_4,
|
Opcode.CONST_4,
|
||||||
Opcode.IF_EQZ,
|
Opcode.IF_EQZ,
|
||||||
Opcode.IF_EQZ,
|
Opcode.IF_EQZ,
|
||||||
Opcode.IGET_OBJECT, // obfuscated parameter field name
|
Opcode.IGET_OBJECT, // obfuscated parameter field name
|
||||||
)
|
),
|
||||||
|
customFingerprint = { methodDef, _ ->
|
||||||
|
methodDef.indexOfFirstInstruction {
|
||||||
|
opcode == Opcode.IGET_OBJECT &&
|
||||||
|
getReference<FieldReference>()?.definingClass == methodDef.parameterTypes.firstOrNull()
|
||||||
|
} >= 0
|
||||||
|
}
|
||||||
)
|
)
|
Loading…
x
Reference in New Issue
Block a user