From 2be738b75c4678f5df90f5216bd383f4841f54d9 Mon Sep 17 00:00:00 2001 From: inotia00 Date: Tue, 28 Mar 2023 21:46:55 +0900 Subject: [PATCH] add `certificate-spoof` patch: fix Android Auto connection issue with MicroG builds --- .../CertificateCheckFingerprint.kt | 9 +++++ .../patch/AndroidAutoCertificatePatch.kt | 35 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/music/misc/androidauto/fingerprints/CertificateCheckFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/AndroidAutoCertificatePatch.kt diff --git a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/fingerprints/CertificateCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/fingerprints/CertificateCheckFingerprint.kt new file mode 100644 index 000000000..d0d23129d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/fingerprints/CertificateCheckFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.music.misc.androidauto.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint + +object CertificateCheckFingerprint : MethodFingerprint( + returnType = "Z", + parameters = listOf("L"), + strings = listOf("X509") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/AndroidAutoCertificatePatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/AndroidAutoCertificatePatch.kt new file mode 100644 index 000000000..eb08cb903 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/misc/androidauto/patch/AndroidAutoCertificatePatch.kt @@ -0,0 +1,35 @@ +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.addInstructions +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.fingerprints.CertificateCheckFingerprint +import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility + +@Patch +@Name("certificate-spoof") +@Description("Spoofs the YouTube Music certificate for Android Auto.") +@YouTubeMusicCompatibility +@Version("0.0.1") +class AndroidAutoCertificatePatch : BytecodePatch( + listOf(CertificateCheckFingerprint) +) { + override fun execute(context: BytecodeContext): PatchResult { + + CertificateCheckFingerprint.result?.mutableMethod?.addInstructions( + 0, """ + const/4 v0, 0x1 + return v0 + """ + ) ?: return CertificateCheckFingerprint.toErrorResult() + + return PatchResultSuccess() + } +}