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

This commit is contained in:
inotia00 2024-09-19 20:21:09 +09:00
parent d776786867
commit 0f0a48b1d4
4 changed files with 12 additions and 4 deletions

View File

@ -7,7 +7,7 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchException
import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.IntegrationsFingerprint.IRegisterResolver
import app.revanced.patches.shared.integrations.Constants.INTEGRATIONS_UTILS_CLASS_DESCRIPTOR
import app.revanced.util.resultOrThrow
import app.revanced.util.deprecatedOrResultOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.Method
@ -53,7 +53,7 @@ abstract class BaseIntegrationsPatch(
) {
fun invoke(integrationsDescriptor: String) {
resultOrThrow().mutableMethod.let { method ->
deprecatedOrResultOrThrow()?.mutableMethod?.let { method ->
val insertIndex = insertIndexResolver(method)
val contextRegister = contextRegisterResolver(method)

View File

@ -8,7 +8,9 @@ import com.android.tools.smali.dexlib2.Opcode
internal object ShortsToolBarFingerprint : MethodFingerprint(
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
parameters = listOf("Z", "L", "L"),
opcodes = listOf(Opcode.IPUT_BOOLEAN),
strings = listOf("Null topBarButtons")
strings = listOf("Null topBarButtons"),
customFingerprint = { methodDef, _ ->
methodDef.parameterTypes.firstOrNull() == "Z"
}
)

View File

@ -8,7 +8,10 @@ import app.revanced.patches.shared.integrations.BaseIntegrationsPatch.Integratio
* In 2023 supported was ended and is no longer available,
* but this may still be used by older apps:
* https://developers.google.com/youtube/android/player
*
* Deprecated in YouTube v19.38.xx+.
*/
@Deprecated("Fingerprint is obsolete and will be deleted soon")
internal object StandalonePlayerActivityFingerprint : IntegrationsFingerprint(
customFingerprint = { methodDef, _ ->
methodDef.definingClass == "Lcom/google/android/youtube/api/StandalonePlayerActivity;"

View File

@ -33,6 +33,9 @@ import com.android.tools.smali.dexlib2.util.MethodUtil
const val REGISTER_TEMPLATE_REPLACEMENT: String = "REGISTER_INDEX"
fun MethodFingerprint.deprecatedOrResultOrThrow() =
if (javaClass.annotations[0].toString().contains("Deprecated")) result else resultOrThrow()
fun MethodFingerprint.resultOrThrow() = result ?: throw exception
/**