diff --git a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/annotations/BypassCertificateChecksCompatibility.kt b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/annotations/BypassCertificateChecksCompatibility.kt new file mode 100644 index 000000000..dbbd31992 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/annotations/BypassCertificateChecksCompatibility.kt @@ -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 diff --git a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/fingerprints/CheckCertificateFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/fingerprints/CheckCertificateFingerprint.kt new file mode 100644 index 000000000..f0a261588 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/fingerprints/CheckCertificateFingerprint.kt @@ -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 +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/BypassCertificateChecksPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/BypassCertificateChecksPatch.kt new file mode 100644 index 000000000..db5af5baf --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/BypassCertificateChecksPatch.kt @@ -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() + } +}