chore: replace with a fingerprint that supports a wider range of versions

This commit is contained in:
inotia00
2024-10-03 22:39:30 +09:00
parent e88c190460
commit 6360f97e54
10 changed files with 40 additions and 42 deletions

View File

@ -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
* [EmbeddedPlayerControlsOverlayFingerprint]
*/
@Deprecated("Fingerprint is obsolete and will be deleted soon")
internal object APIPlayerServiceFingerprint : IntegrationsFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
customFingerprint = { methodDef, _ -> methodDef.definingClass == "Lcom/google/android/apps/youtube/embeddedplayer/service/service/jar/ApiPlayerService;" },

View File

@ -10,6 +10,7 @@ import com.android.tools.smali.dexlib2.AccessFlags
* Note: this fingerprint may no longer be needed, as it appears
* [RemoteEmbedFragmentFingerprint] may be set before this hook is called.
*/
@Deprecated("Fingerprint is obsolete and will be deleted soon")
internal object EmbeddedPlayerControlsOverlayFingerprint : IntegrationsFingerprint(
accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR,
returnType = "V",

View File

@ -10,6 +10,7 @@ import com.android.tools.smali.dexlib2.AccessFlags
* Note: this fingerprint may or may not be needed, as
* [RemoteEmbedFragmentFingerprint] might be set before this is called.
*/
@Deprecated("Fingerprint is obsolete and will be deleted soon")
internal object EmbeddedPlayerFingerprint : IntegrationsFingerprint(
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
returnType = "L",

View File

@ -7,6 +7,7 @@ import com.android.tools.smali.dexlib2.AccessFlags
/**
* 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(
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
returnType = "V",

View File

@ -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).
*/
@Deprecated("Fingerprint is obsolete and will be deleted soon")
internal object RemoteEmbeddedPlayerFingerprint : IntegrationsFingerprint(
accessFlags = AccessFlags.PRIVATE or AccessFlags.CONSTRUCTOR,
returnType = "V",

View File

@ -56,8 +56,7 @@ object NavigationBarHookPatch : BytecodePatch(
private lateinit var navigationTabCreatedCallback: MutableMethod
private lateinit var bottomBarContainerMethod: MutableMethod
private var bottomBarContainerIndex = 0
private var bottomBarContainerRegister = 0
private var bottomBarContainerOffset = 0
override fun execute(context: BytecodeContext) {
fun MutableMethod.addHook(hook: Hook, insertPredicate: Instruction.() -> Boolean) {
@ -131,13 +130,8 @@ object NavigationBarHookPatch : BytecodePatch(
"onBackPressed"
)
InitializeBottomBarContainerFingerprint.resultOrThrow().mutableMethod.apply {
bottomBarContainerMethod = this
bottomBarContainerIndex =
InitializeBottomBarContainerFingerprint.indexOfLayoutChangeListenerInstruction(this)
bottomBarContainerRegister =
getInstruction<FiveRegisterInstruction>(bottomBarContainerIndex).registerC
}
bottomBarContainerMethod =
InitializeBottomBarContainerFingerprint.resultOrThrow().mutableMethod
}
val hookNavigationButtonCreated: (String) -> Unit by lazy {
@ -152,11 +146,19 @@ object NavigationBarHookPatch : BytecodePatch(
}
}
fun addBottomBarContainerHook(descriptor: String) =
bottomBarContainerMethod.addInstruction(
bottomBarContainerIndex,
"invoke-static { v$bottomBarContainerRegister }, $descriptor"
)
fun addBottomBarContainerHook(descriptor: String) {
bottomBarContainerMethod.apply {
val layoutChangeListenerIndex =
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) {
SET_LAST_APP_NAVIGATION_ENUM("setLastAppNavigationEnum", "Ljava/lang/Enum;"),

View File

@ -2,20 +2,26 @@ package app.revanced.patches.youtube.utils.playertype.fingerprint
import app.revanced.patcher.extensions.or
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.Opcode
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
internal object VideoStateFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),
parameters = listOf("Lcom/google/android/libraries/youtube/player/features/overlay/controls/ControlsState;"),
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.IGET_OBJECT,
Opcode.CONST_4,
Opcode.IF_EQZ,
Opcode.IF_EQZ,
Opcode.IGET_OBJECT, // obfuscated parameter field name
)
),
customFingerprint = { methodDef, _ ->
methodDef.indexOfFirstInstruction {
opcode == Opcode.IGET_OBJECT &&
getReference<FieldReference>()?.definingClass == methodDef.parameterTypes.firstOrNull()
} >= 0
}
)