Skip to content

Commit

Permalink
feat(youtube-music): bypass-certificate-checks patch (ReVanced#1810)
Browse files Browse the repository at this point in the history
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
  • Loading branch information
morpheus133 and oSumAtrIX committed Apr 16, 2023
1 parent f48e794 commit ef8f26f
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
@@ -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()
}
}

0 comments on commit ef8f26f

Please sign in to comment.