From 19a8677c7371428a07a2c628d7ae9fd8d1b4d86c Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Sun, 20 Oct 2024 20:53:52 +0900 Subject: [PATCH] feat(YouTube/YT - GmsCore support): add patch option `Disable GmsService Broker` https://github.com/inotia00/ReVanced_Extended/issues/2442#issuecomment-2424694043 --- .../patches/shared/gms/BaseGmsCoreSupportPatch.kt | 11 ++++++++--- .../shared/gms/BaseGmsCoreSupportResourcePatch.kt | 13 +++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/shared/gms/BaseGmsCoreSupportPatch.kt b/src/main/kotlin/app/revanced/patches/shared/gms/BaseGmsCoreSupportPatch.kt index c3adcd3b2..f0cf5fd31 100644 --- a/src/main/kotlin/app/revanced/patches/shared/gms/BaseGmsCoreSupportPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/gms/BaseGmsCoreSupportPatch.kt @@ -93,6 +93,7 @@ abstract class BaseGmsCoreSupportPatch( var gmsCoreVendor = "app.revanced" var checkGmsCore = true + var disableGmsServiceBroker = false var packageNameYouTube = "com.google.android.youtube" var packageNameYouTubeMusic = "com.google.android.apps.youtube.music" @@ -131,6 +132,7 @@ abstract class BaseGmsCoreSupportPatch( override fun execute(context: BytecodeContext) { gmsCoreVendor = getStringPatchOption("GmsCoreVendorGroupId") checkGmsCore = getBooleanPatchOption("CheckGmsCore") + disableGmsServiceBroker = getBooleanPatchOption("DisableGmsServiceBroker") packageNameYouTube = getStringPatchOption("PackageNameYouTube") packageNameYouTubeMusic = getStringPatchOption("PackageNameYouTubeMusic") @@ -152,12 +154,15 @@ abstract class BaseGmsCoreSupportPatch( } // Return these methods early to prevent the app from crashing. - listOf( + val returnEarly = mutableListOf( CastContextFetchFingerprint, - GmsServiceBrokerFingerprint, GooglePlayUtilityFingerprint, ServiceCheckFingerprint - ).returnEarly() + ) + if (disableGmsServiceBroker) { + returnEarly += GmsServiceBrokerFingerprint + } + returnEarly.returnEarly() transformPrimeMethod() diff --git a/src/main/kotlin/app/revanced/patches/shared/gms/BaseGmsCoreSupportResourcePatch.kt b/src/main/kotlin/app/revanced/patches/shared/gms/BaseGmsCoreSupportResourcePatch.kt index 3ebd6a7b1..87773c31d 100644 --- a/src/main/kotlin/app/revanced/patches/shared/gms/BaseGmsCoreSupportResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/gms/BaseGmsCoreSupportResourcePatch.kt @@ -51,6 +51,19 @@ abstract class BaseGmsCoreSupportResourcePatch( """.trimIndentMultiline(), required = true, ) + + private val DisableGmsServiceBroker by booleanPatchOption( + key = "DisableGmsServiceBroker", + default = false, + title = "Disable GmsService Broker", + description = """ + Disabling GmsServiceBroker will somewhat improve crashes caused by unimplemented GmsCore services. + + For YouTube, the 'Spoof streaming data' setting is required. + """.trimIndentMultiline(), + required = true, + ) + internal val PackageNameYouTube = stringPatchOption( key = "PackageNameYouTube", default = DEFAULT_PACKAGE_NAME_YOUTUBE,