From acf38cafae5eb9896b43f3a6cbd808ac273cd081 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 6 Aug 2024 02:01:44 +0200 Subject: [PATCH] fix(Google Photos - GmsCore support): Fix by checking first if a method exists before trying to patch it --- .../shared/misc/gms/BaseGmsCoreSupportPatch.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportPatch.kt b/src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportPatch.kt index 9f773b03ab..188f309b7a 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportPatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportPatch.kt @@ -56,7 +56,7 @@ abstract class BaseGmsCoreSupportPatch( ) : BytecodePatch( name = "GmsCore support", description = "Allows patched Google apps to run without root and under a different package name " + - "by using GmsCore instead of Google Play Services.", + "by using GmsCore instead of Google Play Services.", dependencies = setOf( ChangePackageNamePatch::class, gmsCoreSupportResourcePatch::class, @@ -100,7 +100,13 @@ abstract class BaseGmsCoreSupportPatch( primeMethodFingerprint?.let { transformPrimeMethod(packageName) } // Return these methods early to prevent the app from crashing. - (earlyReturnFingerprints + ServiceCheckFingerprint + CastDynamiteModuleFingerprint).returnEarly() + earlyReturnFingerprints.returnEarly() + ServiceCheckFingerprint.returnEarly() + // Not all apps have CastDynamiteModule, so we need to check if it's present. + if (CastDynamiteModuleFingerprint.result != null) { + CastDynamiteModuleFingerprint.returnEarly() + } + // Google Play Utility is not present in all apps, so we need to check if it's present. if (GooglePlayUtilityFingerprint.result != null) { GooglePlayUtilityFingerprint.returnEarly() } @@ -109,7 +115,7 @@ abstract class BaseGmsCoreSupportPatch( mainActivityOnCreateFingerprint.result?.mutableMethod?.addInstructions( 0, "invoke-static/range { p0 .. p0 }, Lapp/revanced/integrations/shared/GmsCoreSupport;->" + - "checkGmsCore(Landroid/app/Activity;)V", + "checkGmsCore(Landroid/app/Activity;)V", ) ?: throw mainActivityOnCreateFingerprint.exception // Change the vendor of GmsCore in ReVanced Integrations.