From 787dd5990e66fe4b4ef8db9ca7e8841d2ff27fee Mon Sep 17 00:00:00 2001 From: 0xrxL <127248639+0xrxL@users.noreply.github.com> Date: Wed, 4 Dec 2024 04:01:38 +0100 Subject: [PATCH] fix: remove chimera reference and disable advertising id (#97) * ci: workflow to ping Discord users when patches are released (#72) * init: Workflow to notify discord users of releases * Rename workflow * chore (Background playback): Shorten description * Revert "chore (Background playback): Shorten description" This reverts commit 10661b870f0c9c670c5d522f9b2ca7cc82d32772. * Change message contents * Remove chimera ref * feat: remove patch option `DisableGmsServiceBroker` * feat: revert `Cast service v2 disabler` * feat(Hide ads): disable advertising id --------- Co-authored-by: KobeW50 <84587632+KobeW50@users.noreply.github.com> Co-authored-by: inotia00 <108592928+inotia00@users.noreply.github.com> --- .../patches/shared/ads/BaseAdsPatch.kt | 37 ++++++++++++++++--- .../fingerprints/AdvertisingIdFingerprint.kt | 13 +++++++ .../ads/fingerprints/SSLGuardFingerprint.kt | 11 ++++++ .../shared/gms/BaseGmsCoreSupportPatch.kt | 18 ++++----- .../gms/BaseGmsCoreSupportResourcePatch.kt | 12 ------ .../CastDynamiteModuleFingerprint.kt | 7 ++++ .../CastDynamiteModuleV2Fingerprint.kt | 7 ++++ .../GmsServiceBrokerFingerprint.kt | 8 ---- 8 files changed, 76 insertions(+), 37 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/shared/ads/fingerprints/AdvertisingIdFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/shared/ads/fingerprints/SSLGuardFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/shared/gms/fingerprints/CastDynamiteModuleFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/shared/gms/fingerprints/CastDynamiteModuleV2Fingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/patches/shared/gms/fingerprints/GmsServiceBrokerFingerprint.kt diff --git a/src/main/kotlin/app/revanced/patches/shared/ads/BaseAdsPatch.kt b/src/main/kotlin/app/revanced/patches/shared/ads/BaseAdsPatch.kt index 931751c760..eb17f9a543 100644 --- a/src/main/kotlin/app/revanced/patches/shared/ads/BaseAdsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/ads/BaseAdsPatch.kt @@ -9,7 +9,9 @@ import app.revanced.patcher.fingerprint.MethodFingerprintResult import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.PatchException import app.revanced.patcher.util.smali.ExternalLabel +import app.revanced.patches.shared.ads.fingerprints.AdvertisingIdFingerprint import app.revanced.patches.shared.ads.fingerprints.MusicAdsFingerprint +import app.revanced.patches.shared.ads.fingerprints.SSLGuardFingerprint import app.revanced.patches.shared.ads.fingerprints.VideoAdsFingerprint import app.revanced.patches.shared.integrations.Constants.PATCHES_PATH import app.revanced.util.getReference @@ -29,7 +31,9 @@ abstract class BaseAdsPatch( ) : BytecodePatch( setOf( MusicAdsFingerprint, - VideoAdsFingerprint + VideoAdsFingerprint, + AdvertisingIdFingerprint, + SSLGuardFingerprint, ) ) { private companion object { @@ -58,15 +62,36 @@ abstract class BaseAdsPatch( } } - VideoAdsFingerprint.resultOrThrow().let { + setOf( + VideoAdsFingerprint, + SSLGuardFingerprint, + ).forEach { fingerprint -> + fingerprint.resultOrThrow().let { + it.mutableMethod.apply { + addInstructionsWithLabels( + 0, """ + invoke-static {}, $classDescriptor->$methodDescriptor()Z + move-result v0 + if-nez v0, :show_ads + return-void + """, ExternalLabel("show_ads", getInstruction(0)) + ) + } + } + } + + AdvertisingIdFingerprint.resultOrThrow().let { it.mutableMethod.apply { + val insertIndex = it.scanResult.stringsScanResult!!.matches.first().index + val insertRegister = getInstruction(insertIndex).registerA + addInstructionsWithLabels( - 0, """ + insertIndex, """ invoke-static {}, $classDescriptor->$methodDescriptor()Z - move-result v0 - if-nez v0, :show_ads + move-result v$insertRegister + if-nez v$insertRegister, :enable_id return-void - """, ExternalLabel("show_ads", getInstruction(0)) + """, ExternalLabel("enable_id", getInstruction(insertIndex)) ) } } diff --git a/src/main/kotlin/app/revanced/patches/shared/ads/fingerprints/AdvertisingIdFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/ads/fingerprints/AdvertisingIdFingerprint.kt new file mode 100644 index 0000000000..5c7ccf7e79 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/ads/fingerprints/AdvertisingIdFingerprint.kt @@ -0,0 +1,13 @@ +package app.revanced.patches.shared.ads.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.util.MethodUtil + +internal object AdvertisingIdFingerprint : MethodFingerprint( + returnType = "V", + strings = listOf("a."), + customFingerprint = { methodDef, classDef -> + MethodUtil.isConstructor(methodDef) && + classDef.fields.find { it.type == "Lcom/google/android/libraries/youtube/innertube/model/ads/InstreamAd;" } != null + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/ads/fingerprints/SSLGuardFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/ads/fingerprints/SSLGuardFingerprint.kt new file mode 100644 index 0000000000..408b738e08 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/ads/fingerprints/SSLGuardFingerprint.kt @@ -0,0 +1,11 @@ +package app.revanced.patches.shared.ads.fingerprints + +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.MethodFingerprint +import com.android.tools.smali.dexlib2.AccessFlags + +internal object SSLGuardFingerprint : MethodFingerprint( + returnType = "V", + accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, + strings = listOf("Cannot initialize SslGuardSocketFactory will null"), +) \ No newline at end of file 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 f0cf5fd317..a8f8f86213 100644 --- a/src/main/kotlin/app/revanced/patches/shared/gms/BaseGmsCoreSupportPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/gms/BaseGmsCoreSupportPatch.kt @@ -15,9 +15,10 @@ import app.revanced.patches.shared.gms.BaseGmsCoreSupportPatch.Constants.PERMISS import app.revanced.patches.shared.gms.BaseGmsCoreSupportResourcePatch.Companion.ORIGINAL_PACKAGE_NAME_YOUTUBE import app.revanced.patches.shared.gms.BaseGmsCoreSupportResourcePatch.Companion.ORIGINAL_PACKAGE_NAME_YOUTUBE_MUSIC import app.revanced.patches.shared.gms.fingerprints.CastContextFetchFingerprint +import app.revanced.patches.shared.gms.fingerprints.CastDynamiteModuleFingerprint +import app.revanced.patches.shared.gms.fingerprints.CastDynamiteModuleV2Fingerprint import app.revanced.patches.shared.gms.fingerprints.CertificateFingerprint import app.revanced.patches.shared.gms.fingerprints.GmsCoreSupportFingerprint -import app.revanced.patches.shared.gms.fingerprints.GmsServiceBrokerFingerprint import app.revanced.patches.shared.gms.fingerprints.GooglePlayUtilityFingerprint import app.revanced.patches.shared.gms.fingerprints.PrimesApiFingerprint import app.revanced.patches.shared.gms.fingerprints.PrimesBackgroundInitializationFingerprint @@ -71,8 +72,9 @@ abstract class BaseGmsCoreSupportPatch( fingerprints = setOf( // Google Play Services. CastContextFetchFingerprint, + CastDynamiteModuleFingerprint, + CastDynamiteModuleV2Fingerprint, GmsCoreSupportFingerprint, - GmsServiceBrokerFingerprint, GooglePlayUtilityFingerprint, PrimesApiFingerprint, PrimesBackgroundInitializationFingerprint, @@ -93,7 +95,6 @@ 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" @@ -132,7 +133,6 @@ abstract class BaseGmsCoreSupportPatch( override fun execute(context: BytecodeContext) { gmsCoreVendor = getStringPatchOption("GmsCoreVendorGroupId") checkGmsCore = getBooleanPatchOption("CheckGmsCore") - disableGmsServiceBroker = getBooleanPatchOption("DisableGmsServiceBroker") packageNameYouTube = getStringPatchOption("PackageNameYouTube") packageNameYouTubeMusic = getStringPatchOption("PackageNameYouTubeMusic") @@ -156,12 +156,11 @@ abstract class BaseGmsCoreSupportPatch( // Return these methods early to prevent the app from crashing. val returnEarly = mutableListOf( CastContextFetchFingerprint, + CastDynamiteModuleFingerprint, + CastDynamiteModuleV2Fingerprint, GooglePlayUtilityFingerprint, ServiceCheckFingerprint ) - if (disableGmsServiceBroker) { - returnEarly += GmsServiceBrokerFingerprint - } returnEarly.returnEarly() transformPrimeMethod() @@ -431,11 +430,9 @@ abstract class BaseGmsCoreSupportPatch( "com.google.android.gms.feedback.internal.IFeedbackService", // cast + "com.google.android.gms.cast.firstparty.START", "com.google.android.gms.cast.service.BIND_CAST_DEVICE_CONTROLLER_SERVICE", - // chimera - "com.google.android.gms.chimera", - // fonts "com.google.android.gms.fonts", @@ -455,7 +452,6 @@ abstract class BaseGmsCoreSupportPatch( "com.google.android.gms.icing.LIGHTWEIGHT_INDEX_SERVICE", "com.google.android.gms.icing.INDEX_SERVICE", "com.google.android.gms.mdm.services.START", - "com.google.android.gms.clearcut.service.START", // potoken "com.google.android.gms.potokens.service.START", 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 87773c31d0..faef16be70 100644 --- a/src/main/kotlin/app/revanced/patches/shared/gms/BaseGmsCoreSupportResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/gms/BaseGmsCoreSupportResourcePatch.kt @@ -52,18 +52,6 @@ abstract class BaseGmsCoreSupportResourcePatch( 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, diff --git a/src/main/kotlin/app/revanced/patches/shared/gms/fingerprints/CastDynamiteModuleFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/gms/fingerprints/CastDynamiteModuleFingerprint.kt new file mode 100644 index 0000000000..b109574dc2 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/gms/fingerprints/CastDynamiteModuleFingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.shared.gms.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint + +internal object CastDynamiteModuleFingerprint : MethodFingerprint( + strings = listOf("com.google.android.gms.cast.framework.internal.CastDynamiteModuleImpl") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/gms/fingerprints/CastDynamiteModuleV2Fingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/gms/fingerprints/CastDynamiteModuleV2Fingerprint.kt new file mode 100644 index 0000000000..a00275974f --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/shared/gms/fingerprints/CastDynamiteModuleV2Fingerprint.kt @@ -0,0 +1,7 @@ +package app.revanced.patches.shared.gms.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint + +internal object CastDynamiteModuleV2Fingerprint : MethodFingerprint( + strings = listOf("Failed to load module via V2: ") +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/shared/gms/fingerprints/GmsServiceBrokerFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/gms/fingerprints/GmsServiceBrokerFingerprint.kt deleted file mode 100644 index 853480b7e5..0000000000 --- a/src/main/kotlin/app/revanced/patches/shared/gms/fingerprints/GmsServiceBrokerFingerprint.kt +++ /dev/null @@ -1,8 +0,0 @@ -package app.revanced.patches.shared.gms.fingerprints - -import app.revanced.patcher.fingerprint.MethodFingerprint - -internal object GmsServiceBrokerFingerprint : MethodFingerprint( - returnType = "V", - strings = listOf("mServiceBroker is null, client disconnected") -) \ No newline at end of file