Skip to content

Commit

Permalink
fix(YouTube - GmsCore support): Check for availability earlier to pre…
Browse files Browse the repository at this point in the history
…vent crashing without any notice
  • Loading branch information
oSumAtrIX committed Dec 11, 2023
1 parent b288e45 commit f221a62
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions api/revanced-patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,10 @@ public final class app/revanced/patches/serviceportalbund/detection/root/RootDet
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/shared/fingerprints/HomeActivityFingerprint : app/revanced/patches/shared/integrations/AbstractIntegrationsPatch$IntegrationsFingerprint {
public static final field INSTANCE Lapp/revanced/patches/shared/fingerprints/HomeActivityFingerprint;
}

public abstract class app/revanced/patches/shared/integrations/AbstractIntegrationsPatch : app/revanced/patcher/patch/BytecodePatch {
public fun <init> (Ljava/lang/String;Ljava/util/Set;)V
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import app.revanced.patches.youtube.misc.gms.Constants.REVANCED_YOUTUBE_PACKAGE_
import app.revanced.patches.youtube.misc.gms.Constants.YOUTUBE_PACKAGE_NAME
import app.revanced.patches.youtube.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorOption
import app.revanced.patches.youtube.misc.gms.fingerprints.*
import app.revanced.patches.youtube.shared.fingerprints.WatchWhileActivityFingerprint
import app.revanced.util.exception


Expand Down Expand Up @@ -50,17 +49,17 @@ object GmsCoreSupportPatch : AbstractGmsCoreSupportPatch(
CastDynamiteModuleV2Fingerprint,
CastContextFetchFingerprint,
PrimeMethodFingerprint,
WatchWhileActivityFingerprint
HomeActivityFingerprint,
)
) {
override val gmsCoreVendor by gmsCoreVendorOption

override fun execute(context: BytecodeContext) {
// Check the availability of GmsCore.
WatchWhileActivityFingerprint.result?.mutableMethod?.addInstruction(
HomeActivityFingerprint.result?.mutableMethod?.addInstruction(
0,
"invoke-static {}, Lapp/revanced/integrations/patches/GmsCoreSupport;->checkAvailability()V"
) ?: throw WatchWhileActivityFingerprint.exception
) ?: throw HomeActivityFingerprint.exception

super.execute(context)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package app.revanced.patches.youtube.misc.gms.fingerprints

import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint

object HomeActivityFingerprint : IntegrationsFingerprint(
customFingerprint = { methodDef, classDef ->
methodDef.name == "onCreate" && classDef.type.endsWith("Shell_HomeActivity;")
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ object IntegrationsPatch : AbstractIntegrationsPatch(
EmbeddedPlayerFingerprint,
APIPlayerServiceFingerprint,
),
)
)

0 comments on commit f221a62

Please sign in to comment.