feat(youtube-music): bypass-certificate-checks patch (#1810)

Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
morpheus133 2023-04-01 02:23:08 +02:00 committed by oSumAtrIX
parent f48e794eeb
commit ef8f26fb97
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
3 changed files with 86 additions and 0 deletions

View file

@ -0,0 +1,35 @@
package app.revanced.patches.music.misc.androidauto.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility(
[Package(
"com.google.android.apps.youtube.music",
arrayOf(
"5.14.53",
"5.16.51",
"5.17.51",
"5.21.52",
"5.22.54",
"5.23.50",
"5.25.51",
"5.25.52",
"5.26.52",
"5.27.51",
"5.28.52",
"5.29.52",
"5.31.50",
"5.34.51",
"5.36.51",
"5.38.53",
"5.39.52",
"5.40.51",
"5.41.50",
"5.48.52"
)
)]
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class BypassCertificateChecksCompatibility

View file

@ -0,0 +1,10 @@
package app.revanced.patches.music.misc.androidauto.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.music.misc.androidauto.patch.BypassCertificateChecksPatch
object CheckCertificateFingerprint : MethodFingerprint(
"Z",
strings = listOf("No match") // Unique in combination with boolean return type
)

View file

@ -0,0 +1,41 @@
package app.revanced.patches.music.misc.androidauto.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.misc.androidauto.annotations.BypassCertificateChecksCompatibility
import app.revanced.patches.music.misc.androidauto.fingerprints.CheckCertificateFingerprint
@Patch
@Name("bypass-certificate-checks")
@Description("Bypasses certificate checks which prevent YouTube Music from working on Android Auto.")
@BypassCertificateChecksCompatibility
@Version("0.0.1")
class BypassCertificateChecksPatch : BytecodePatch(
listOf(
CheckCertificateFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
CheckCertificateFingerprint.result?.let { result ->
val noMatchIndex = result.scanResult.stringsScanResult!!.matches.first().index
result.mutableMethod.apply {
val isPartnerIndex = noMatchIndex + 2
replaceInstruction(isPartnerIndex, "const/4 p1, 0x1")
addInstruction(isPartnerIndex + 1, "return p1")
}
} ?: return CheckCertificateFingerprint.toErrorResult()
return PatchResultSuccess()
}
}