Skip to content

Commit

Permalink
fix: remove chimera reference and disable advertising id (inotia00#97)
Browse files Browse the repository at this point in the history
* ci: workflow to ping Discord users when patches are released (inotia00#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 10661b8.

* 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 <[email protected]>
Co-authored-by: inotia00 <[email protected]>
  • Loading branch information
3 people authored Dec 4, 2024
1 parent 9982245 commit 787dd59
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 37 deletions.
37 changes: 31 additions & 6 deletions src/main/kotlin/app/revanced/patches/shared/ads/BaseAdsPatch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,7 +31,9 @@ abstract class BaseAdsPatch(
) : BytecodePatch(
setOf(
MusicAdsFingerprint,
VideoAdsFingerprint
VideoAdsFingerprint,
AdvertisingIdFingerprint,
SSLGuardFingerprint,
)
) {
private companion object {
Expand Down Expand Up @@ -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<OneRegisterInstruction>(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))
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
)
Original file line number Diff line number Diff line change
@@ -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"),
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -71,8 +72,9 @@ abstract class BaseGmsCoreSupportPatch(
fingerprints = setOf(
// Google Play Services.
CastContextFetchFingerprint,
CastDynamiteModuleFingerprint,
CastDynamiteModuleV2Fingerprint,
GmsCoreSupportFingerprint,
GmsServiceBrokerFingerprint,
GooglePlayUtilityFingerprint,
PrimesApiFingerprint,
PrimesBackgroundInitializationFingerprint,
Expand All @@ -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"

Expand Down Expand Up @@ -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")

Expand All @@ -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()
Expand Down Expand Up @@ -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",

Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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")
)
Original file line number Diff line number Diff line change
@@ -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: ")
)

This file was deleted.

0 comments on commit 787dd59

Please sign in to comment.