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 dab8900
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 @@ -1423,6 +1423,10 @@ public final class app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourceP
public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V
}

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

public final class app/revanced/patches/youtube/misc/integrations/IntegrationsPatch : app/revanced/patches/shared/integrations/AbstractIntegrationsPatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/misc/integrations/IntegrationsPatch;
}
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 dab8900

Please sign in to comment.