From 24528e0a6eec17ce0a3c52f8862585933615ad28 Mon Sep 17 00:00:00 2001 From: xob0t <32616886+xob0t@users.noreply.github.com> Date: Sat, 20 Jul 2024 06:58:47 +0300 Subject: [PATCH] feat(Google Photos): Add `GmsCore support` patch (#3414) Co-authored-by: benjy3gg Co-authored-by: oSumAtrIX --- api/revanced-patches.api | 12 ++++++ .../all/misc/resources/AddResourcesPatch.kt | 5 ++- .../misc/gms/GmsCoreSupportPatch.kt | 3 -- .../fingerprints/ServiceCheckFingerprint.kt | 12 ------ .../StartActivityInitFingerprint.kt | 2 +- .../googlephotos/misc/gms/Constants.kt | 6 +++ .../misc/gms/GmsCoreSupportPatch.kt | 21 ++++++++++ .../misc/gms/GmsCoreSupportResourcePatch.kt | 11 ++++++ .../PhotosActivityOnCreateFingerprint.kt | 9 +++++ .../misc/integrations/IntegrationsPatch.kt | 10 +++++ .../HomeActivityInitFingerprint.kt | 37 ++++++++++++++++++ .../music/misc/gms/GmsCoreSupportPatch.kt | 8 ++-- .../fingerprints/ServiceCheckFingerprint.kt | 12 ------ .../misc/gms/BaseGmsCoreSupportPatch.kt | 12 ++++-- .../gms/BaseGmsCoreSupportResourcePatch.kt | 38 +++++++++---------- .../CastDynamiteModuleFingerprint.kt | 2 +- .../fingerprints/ServiceCheckFingerprint.kt | 6 +-- .../youtube/misc/gms/GmsCoreSupportPatch.kt | 6 --- .../CastDynamiteModuleFingerprint.kt | 8 ---- 19 files changed, 143 insertions(+), 77 deletions(-) delete mode 100644 src/main/kotlin/app/revanced/patches/googlenews/misc/gms/fingerprints/ServiceCheckFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/Constants.kt create mode 100644 src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/GmsCoreSupportPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/GmsCoreSupportResourcePatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/fingerprints/PhotosActivityOnCreateFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/googlephotos/misc/integrations/IntegrationsPatch.kt create mode 100644 src/main/kotlin/app/revanced/patches/googlephotos/misc/integrations/fingerprints/HomeActivityInitFingerprint.kt delete mode 100644 src/main/kotlin/app/revanced/patches/music/misc/gms/fingerprints/ServiceCheckFingerprint.kt rename src/main/kotlin/app/revanced/patches/{music => shared}/misc/gms/fingerprints/CastDynamiteModuleFingerprint.kt (79%) rename src/main/kotlin/app/revanced/patches/{youtube => shared}/misc/gms/fingerprints/ServiceCheckFingerprint.kt (66%) delete mode 100644 src/main/kotlin/app/revanced/patches/youtube/misc/gms/fingerprints/CastDynamiteModuleFingerprint.kt diff --git a/api/revanced-patches.api b/api/revanced-patches.api index e71ae0017..a93bca3da 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -235,6 +235,18 @@ public final class app/revanced/patches/googlenews/misc/integrations/Integration public static final field INSTANCE Lapp/revanced/patches/googlenews/misc/integrations/IntegrationsPatch; } +public final class app/revanced/patches/googlephotos/misc/gms/GmsCoreSupportPatch : app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportPatch { + public static final field INSTANCE Lapp/revanced/patches/googlephotos/misc/gms/GmsCoreSupportPatch; +} + +public final class app/revanced/patches/googlephotos/misc/gms/GmsCoreSupportResourcePatch : app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch { + public static final field INSTANCE Lapp/revanced/patches/googlephotos/misc/gms/GmsCoreSupportResourcePatch; +} + +public final class app/revanced/patches/googlephotos/misc/integrations/IntegrationsPatch : app/revanced/patches/shared/misc/integrations/BaseIntegrationsPatch { + public static final field INSTANCE Lapp/revanced/patches/googlephotos/misc/integrations/IntegrationsPatch; +} + public final class app/revanced/patches/googlerecorder/restrictions/RemoveDeviceRestrictions : app/revanced/patcher/patch/BytecodePatch { public static final field INSTANCE Lapp/revanced/patches/googlerecorder/restrictions/RemoveDeviceRestrictions; public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V diff --git a/src/main/kotlin/app/revanced/patches/all/misc/resources/AddResourcesPatch.kt b/src/main/kotlin/app/revanced/patches/all/misc/resources/AddResourcesPatch.kt index 09707c727..38c479b30 100644 --- a/src/main/kotlin/app/revanced/patches/all/misc/resources/AddResourcesPatch.kt +++ b/src/main/kotlin/app/revanced/patches/all/misc/resources/AddResourcesPatch.kt @@ -347,7 +347,10 @@ object AddResourcesPatch : ResourcePatch(), MutableMap\n\n") + } } context.xmlEditor[targetFile.path].let { editor -> diff --git a/src/main/kotlin/app/revanced/patches/googlenews/misc/gms/GmsCoreSupportPatch.kt b/src/main/kotlin/app/revanced/patches/googlenews/misc/gms/GmsCoreSupportPatch.kt index e0e239d6a..c2a81ab9b 100644 --- a/src/main/kotlin/app/revanced/patches/googlenews/misc/gms/GmsCoreSupportPatch.kt +++ b/src/main/kotlin/app/revanced/patches/googlenews/misc/gms/GmsCoreSupportPatch.kt @@ -4,7 +4,6 @@ import app.revanced.patches.googlenews.misc.gms.Constants.MAGAZINES_PACKAGE_NAME import app.revanced.patches.googlenews.misc.gms.Constants.REVANCED_MAGAZINES_PACKAGE_NAME import app.revanced.patches.googlenews.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorGroupIdOption import app.revanced.patches.googlenews.misc.gms.fingerprints.MagazinesActivityOnCreateFingerprint -import app.revanced.patches.googlenews.misc.gms.fingerprints.ServiceCheckFingerprint import app.revanced.patches.googlenews.misc.integrations.IntegrationsPatch import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch @@ -13,14 +12,12 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( fromPackageName = MAGAZINES_PACKAGE_NAME, toPackageName = REVANCED_MAGAZINES_PACKAGE_NAME, primeMethodFingerprint = null, - earlyReturnFingerprints = setOf(ServiceCheckFingerprint), mainActivityOnCreateFingerprint = MagazinesActivityOnCreateFingerprint, integrationsPatchDependency = IntegrationsPatch::class, gmsCoreSupportResourcePatch = GmsCoreSupportResourcePatch, // Remove version constraint, // once https://github.com/ReVanced/revanced-patches/pull/3111#issuecomment-2240877277 is resolved. compatiblePackages = setOf(CompatiblePackage(MAGAZINES_PACKAGE_NAME, setOf("5.108.0.644447823"))), - fingerprints = setOf(ServiceCheckFingerprint), ) { override val gmsCoreVendorGroupId by gmsCoreVendorGroupIdOption } diff --git a/src/main/kotlin/app/revanced/patches/googlenews/misc/gms/fingerprints/ServiceCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/googlenews/misc/gms/fingerprints/ServiceCheckFingerprint.kt deleted file mode 100644 index b8228f7ef..000000000 --- a/src/main/kotlin/app/revanced/patches/googlenews/misc/gms/fingerprints/ServiceCheckFingerprint.kt +++ /dev/null @@ -1,12 +0,0 @@ -package app.revanced.patches.googlenews.misc.gms.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.MethodFingerprint -import com.android.tools.smali.dexlib2.AccessFlags - -internal object ServiceCheckFingerprint : MethodFingerprint( - returnType = "V", - accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, - parameters = listOf("L", "I"), - strings = listOf("Google Play Services not available", "GooglePlayServices not available due to error "), -) diff --git a/src/main/kotlin/app/revanced/patches/googlenews/misc/integrations/fingerprints/StartActivityInitFingerprint.kt b/src/main/kotlin/app/revanced/patches/googlenews/misc/integrations/fingerprints/StartActivityInitFingerprint.kt index d69070665..b71636793 100644 --- a/src/main/kotlin/app/revanced/patches/googlenews/misc/integrations/fingerprints/StartActivityInitFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/googlenews/misc/integrations/fingerprints/StartActivityInitFingerprint.kt @@ -26,7 +26,7 @@ internal object StartActivityInitFingerprint : IntegrationsFingerprint( getReference()?.name == "getApplicationContext" } - getApplicationContextIndex + 2 // Below the move-result-object instruction + getApplicationContextIndex + 2 // Below the move-result-object instruction. }, contextRegisterResolver = { method -> val moveResultInstruction = method.implementation!!.instructions.elementAt(getApplicationContextIndex + 1) diff --git a/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/Constants.kt b/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/Constants.kt new file mode 100644 index 000000000..f0311bcde --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/Constants.kt @@ -0,0 +1,6 @@ +package app.revanced.patches.googlephotos.misc.gms + +internal object Constants { + const val PHOTOS_PACKAGE_NAME = "com.google.android.apps.photos" + const val REVANCED_PHOTOS_PACKAGE_NAME = "app.revanced.android.photos" +} diff --git a/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/GmsCoreSupportPatch.kt b/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/GmsCoreSupportPatch.kt new file mode 100644 index 000000000..8aa775853 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/GmsCoreSupportPatch.kt @@ -0,0 +1,21 @@ +package app.revanced.patches.googlephotos.misc.gms + +import app.revanced.patches.googlephotos.misc.gms.Constants.PHOTOS_PACKAGE_NAME +import app.revanced.patches.googlephotos.misc.gms.Constants.REVANCED_PHOTOS_PACKAGE_NAME +import app.revanced.patches.googlephotos.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorGroupIdOption +import app.revanced.patches.googlephotos.misc.gms.fingerprints.PhotosActivityOnCreateFingerprint +import app.revanced.patches.googlephotos.misc.integrations.IntegrationsPatch +import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch + +@Suppress("unused") +object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( + fromPackageName = PHOTOS_PACKAGE_NAME, + toPackageName = REVANCED_PHOTOS_PACKAGE_NAME, + primeMethodFingerprint = null, + mainActivityOnCreateFingerprint = PhotosActivityOnCreateFingerprint, + integrationsPatchDependency = IntegrationsPatch::class, + gmsCoreSupportResourcePatch = GmsCoreSupportResourcePatch, + compatiblePackages = setOf(CompatiblePackage(PHOTOS_PACKAGE_NAME)), +) { + override val gmsCoreVendorGroupId by gmsCoreVendorGroupIdOption +} diff --git a/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/GmsCoreSupportResourcePatch.kt b/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/GmsCoreSupportResourcePatch.kt new file mode 100644 index 000000000..bd7f1d115 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/GmsCoreSupportResourcePatch.kt @@ -0,0 +1,11 @@ +package app.revanced.patches.googlephotos.misc.gms + +import app.revanced.patches.googlephotos.misc.gms.Constants.PHOTOS_PACKAGE_NAME +import app.revanced.patches.googlephotos.misc.gms.Constants.REVANCED_PHOTOS_PACKAGE_NAME +import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportResourcePatch + +object GmsCoreSupportResourcePatch : BaseGmsCoreSupportResourcePatch( + fromPackageName = PHOTOS_PACKAGE_NAME, + toPackageName = REVANCED_PHOTOS_PACKAGE_NAME, + spoofedPackageSignature = "24bb24c05e47e0aefa68a58a766179d9b613a600", +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/fingerprints/PhotosActivityOnCreateFingerprint.kt b/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/fingerprints/PhotosActivityOnCreateFingerprint.kt new file mode 100644 index 000000000..b5f306166 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/googlephotos/misc/gms/fingerprints/PhotosActivityOnCreateFingerprint.kt @@ -0,0 +1,9 @@ +package app.revanced.patches.googlephotos.misc.gms.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint + +internal object PhotosActivityOnCreateFingerprint : MethodFingerprint( + customFingerprint = { methodDef, classDef -> + methodDef.name == "onCreate" && classDef.endsWith("/HomeActivity;") + }, +) diff --git a/src/main/kotlin/app/revanced/patches/googlephotos/misc/integrations/IntegrationsPatch.kt b/src/main/kotlin/app/revanced/patches/googlephotos/misc/integrations/IntegrationsPatch.kt new file mode 100644 index 000000000..35d0d241d --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/googlephotos/misc/integrations/IntegrationsPatch.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.googlephotos.misc.integrations + +import app.revanced.patcher.patch.annotation.Patch +import app.revanced.patches.googlephotos.misc.integrations.fingerprints.HomeActivityInitFingerprint +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch + +@Patch(requiresIntegrations = true) +object IntegrationsPatch : BaseIntegrationsPatch( + setOf(HomeActivityInitFingerprint), +) diff --git a/src/main/kotlin/app/revanced/patches/googlephotos/misc/integrations/fingerprints/HomeActivityInitFingerprint.kt b/src/main/kotlin/app/revanced/patches/googlephotos/misc/integrations/fingerprints/HomeActivityInitFingerprint.kt new file mode 100644 index 000000000..1fb7bf440 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/googlephotos/misc/integrations/fingerprints/HomeActivityInitFingerprint.kt @@ -0,0 +1,37 @@ +package app.revanced.patches.googlephotos.misc.integrations.fingerprints + +import app.revanced.patches.googlephotos.misc.integrations.fingerprints.HomeActivityInitFingerprint.getApplicationContextIndex +import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.IntegrationsFingerprint +import app.revanced.util.getReference +import app.revanced.util.indexOfFirstInstructionOrThrow +import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction +import com.android.tools.smali.dexlib2.iface.reference.MethodReference + +internal object HomeActivityInitFingerprint : IntegrationsFingerprint( + opcodes = listOf( + Opcode.CONST_STRING, + Opcode.INVOKE_STATIC, + Opcode.MOVE_RESULT_OBJECT, + Opcode.IF_NEZ, + Opcode.INVOKE_VIRTUAL, // Calls getApplicationContext(). + Opcode.MOVE_RESULT_OBJECT, + ), + insertIndexResolver = { method -> + getApplicationContextIndex = method.indexOfFirstInstructionOrThrow { + getReference()?.name == "getApplicationContext" + } + + getApplicationContextIndex + 2 // Below the move-result-object instruction. + }, + contextRegisterResolver = { method -> + val moveResultInstruction = method.implementation!!.instructions.elementAt(getApplicationContextIndex + 1) + as OneRegisterInstruction + moveResultInstruction.registerA + }, + customFingerprint = { methodDef, classDef -> + methodDef.name == "onCreate" && classDef.endsWith("/HomeActivity;") + }, +) { + private var getApplicationContextIndex = -1 +} diff --git a/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt index db41381bb..035d069c5 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt @@ -3,7 +3,9 @@ package app.revanced.patches.music.misc.gms import app.revanced.patches.music.misc.gms.Constants.MUSIC_PACKAGE_NAME import app.revanced.patches.music.misc.gms.Constants.REVANCED_MUSIC_PACKAGE_NAME import app.revanced.patches.music.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorGroupIdOption -import app.revanced.patches.music.misc.gms.fingerprints.* +import app.revanced.patches.music.misc.gms.fingerprints.CastDynamiteModuleV2Fingerprint +import app.revanced.patches.music.misc.gms.fingerprints.MusicActivityOnCreateFingerprint +import app.revanced.patches.music.misc.gms.fingerprints.PrimeMethodFingerprint import app.revanced.patches.music.misc.integrations.IntegrationsPatch import app.revanced.patches.shared.fingerprints.CastContextFetchFingerprint import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch @@ -14,8 +16,6 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( toPackageName = REVANCED_MUSIC_PACKAGE_NAME, primeMethodFingerprint = PrimeMethodFingerprint, earlyReturnFingerprints = setOf( - ServiceCheckFingerprint, - CastDynamiteModuleFingerprint, CastDynamiteModuleV2Fingerprint, CastContextFetchFingerprint, ), @@ -35,8 +35,6 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( ), ), fingerprints = setOf( - ServiceCheckFingerprint, - CastDynamiteModuleFingerprint, CastDynamiteModuleV2Fingerprint, CastContextFetchFingerprint, PrimeMethodFingerprint, diff --git a/src/main/kotlin/app/revanced/patches/music/misc/gms/fingerprints/ServiceCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/gms/fingerprints/ServiceCheckFingerprint.kt deleted file mode 100644 index 536048502..000000000 --- a/src/main/kotlin/app/revanced/patches/music/misc/gms/fingerprints/ServiceCheckFingerprint.kt +++ /dev/null @@ -1,12 +0,0 @@ -package app.revanced.patches.music.misc.gms.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.MethodFingerprint -import com.android.tools.smali.dexlib2.AccessFlags - -internal object ServiceCheckFingerprint : MethodFingerprint( - "V", - AccessFlags.PUBLIC or AccessFlags.STATIC, - listOf("L", "I"), - strings = listOf("Google Play Services not available"), -) 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 9eb35018a..9f773b03a 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 @@ -11,9 +11,11 @@ import app.revanced.patches.all.misc.packagename.ChangePackageNamePatch import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch.Constants.ACTIONS import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch.Constants.AUTHORITIES import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch.Constants.PERMISSIONS +import app.revanced.patches.shared.misc.gms.fingerprints.CastDynamiteModuleFingerprint import app.revanced.patches.shared.misc.gms.fingerprints.GmsCoreSupportFingerprint import app.revanced.patches.shared.misc.gms.fingerprints.GmsCoreSupportFingerprint.GET_GMS_CORE_VENDOR_GROUP_ID_METHOD_NAME import app.revanced.patches.shared.misc.gms.fingerprints.GooglePlayUtilityFingerprint +import app.revanced.patches.shared.misc.gms.fingerprints.ServiceCheckFingerprint import app.revanced.util.exception import app.revanced.util.getReference import app.revanced.util.returnEarly @@ -44,7 +46,7 @@ abstract class BaseGmsCoreSupportPatch( private val fromPackageName: String, private val toPackageName: String, private val primeMethodFingerprint: MethodFingerprint?, - private val earlyReturnFingerprints: Set, + private val earlyReturnFingerprints: Set = setOf(), private val mainActivityOnCreateFingerprint: MethodFingerprint, private val integrationsPatchDependency: PatchClass, gmsCoreSupportResourcePatch: BaseGmsCoreSupportResourcePatch, @@ -54,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, @@ -64,6 +66,8 @@ abstract class BaseGmsCoreSupportPatch( fingerprints = setOf( GmsCoreSupportFingerprint, GooglePlayUtilityFingerprint, + ServiceCheckFingerprint, + CastDynamiteModuleFingerprint, mainActivityOnCreateFingerprint, ) + fingerprints, requiresIntegrations = true, @@ -96,7 +100,7 @@ abstract class BaseGmsCoreSupportPatch( primeMethodFingerprint?.let { transformPrimeMethod(packageName) } // Return these methods early to prevent the app from crashing. - earlyReturnFingerprints.returnEarly() + (earlyReturnFingerprints + ServiceCheckFingerprint + CastDynamiteModuleFingerprint).returnEarly() if (GooglePlayUtilityFingerprint.result != null) { GooglePlayUtilityFingerprint.returnEarly() } @@ -105,7 +109,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. diff --git a/src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch.kt b/src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch.kt index f77a6d361..d36c1b1e5 100644 --- a/src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch.kt @@ -96,27 +96,23 @@ abstract class BaseGmsCoreSupportResourcePatch( private fun ResourceContext.patchManifest() { val packageName = ChangePackageNamePatch.setOrGetFallbackPackageName(toPackageName) - val manifest = this.get("AndroidManifest.xml").readText() - this.get("AndroidManifest.xml").writeText( - manifest.replace( - "package=\"$fromPackageName", - "package=\"$packageName", - ).replace( - "android:authorities=\"$fromPackageName", - "android:authorities=\"$packageName", - ).replace( - "$fromPackageName.permission.C2D_MESSAGE", - "$packageName.permission.C2D_MESSAGE", - ).replace( - "$fromPackageName.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION", - "$packageName.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION", - ).replace( - "com.google.android.c2dm", - "$gmsCoreVendorGroupId.android.c2dm", - ).replace( - "", - "", - ), + val transformations = mapOf( + "package=\"$fromPackageName" to "package=\"$packageName", + "android:authorities=\"$fromPackageName" to "android:authorities=\"$packageName", + "$fromPackageName.permission.C2D_MESSAGE" to "$packageName.permission.C2D_MESSAGE", + "$fromPackageName.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION" to "$packageName.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION", + "com.google.android.c2dm" to "$packageName.android.c2dm", + "com.google.android.libraries.photos.api.mars" to "$packageName.android.apps.photos.api.mars", + "" to "", + ) + + get("AndroidManifest.xml", false).writeText( + transformations.entries.fold(get("AndroidManifest.xml", false).readText()) { acc, (from, to) -> + acc.replace( + from, + to + ) + } ) } diff --git a/src/main/kotlin/app/revanced/patches/music/misc/gms/fingerprints/CastDynamiteModuleFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/misc/gms/fingerprints/CastDynamiteModuleFingerprint.kt similarity index 79% rename from src/main/kotlin/app/revanced/patches/music/misc/gms/fingerprints/CastDynamiteModuleFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/misc/gms/fingerprints/CastDynamiteModuleFingerprint.kt index c1c8ec8cc..7773e378d 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/gms/fingerprints/CastDynamiteModuleFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/gms/fingerprints/CastDynamiteModuleFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.music.misc.gms.fingerprints +package app.revanced.patches.shared.misc.gms.fingerprints import app.revanced.patcher.fingerprint.MethodFingerprint diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/fingerprints/ServiceCheckFingerprint.kt b/src/main/kotlin/app/revanced/patches/shared/misc/gms/fingerprints/ServiceCheckFingerprint.kt similarity index 66% rename from src/main/kotlin/app/revanced/patches/youtube/misc/gms/fingerprints/ServiceCheckFingerprint.kt rename to src/main/kotlin/app/revanced/patches/shared/misc/gms/fingerprints/ServiceCheckFingerprint.kt index f48de5b41..49f187162 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/fingerprints/ServiceCheckFingerprint.kt +++ b/src/main/kotlin/app/revanced/patches/shared/misc/gms/fingerprints/ServiceCheckFingerprint.kt @@ -1,4 +1,4 @@ -package app.revanced.patches.youtube.misc.gms.fingerprints +package app.revanced.patches.shared.misc.gms.fingerprints import app.revanced.patcher.extensions.or import app.revanced.patcher.fingerprint.MethodFingerprint @@ -8,5 +8,5 @@ internal object ServiceCheckFingerprint : MethodFingerprint( returnType = "V", accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, parameters = listOf("L", "I"), - strings = listOf("Google Play Services not available", "GooglePlayServices not available due to error ") -) \ No newline at end of file + strings = listOf("Google Play Services not available") +) diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt index c2255025f..e74a3d11e 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt @@ -7,10 +7,8 @@ import app.revanced.patches.youtube.misc.fix.playback.SpoofClientPatch import app.revanced.patches.youtube.misc.gms.Constants.REVANCED_YOUTUBE_PACKAGE_NAME import app.revanced.patches.youtube.misc.gms.Constants.YOUTUBE_PACKAGE_NAME import app.revanced.patches.youtube.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorGroupIdOption -import app.revanced.patches.youtube.misc.gms.fingerprints.CastDynamiteModuleFingerprint import app.revanced.patches.youtube.misc.gms.fingerprints.CastDynamiteModuleV2Fingerprint import app.revanced.patches.youtube.misc.gms.fingerprints.PrimeMethodFingerprint -import app.revanced.patches.youtube.misc.gms.fingerprints.ServiceCheckFingerprint import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.shared.fingerprints.MainActivityOnCreateFingerprint @@ -20,8 +18,6 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( toPackageName = REVANCED_YOUTUBE_PACKAGE_NAME, primeMethodFingerprint = PrimeMethodFingerprint, earlyReturnFingerprints = setOf( - ServiceCheckFingerprint, - CastDynamiteModuleFingerprint, CastDynamiteModuleV2Fingerprint, CastContextFetchFingerprint, ), @@ -63,8 +59,6 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( ), ), fingerprints = setOf( - ServiceCheckFingerprint, - CastDynamiteModuleFingerprint, CastDynamiteModuleV2Fingerprint, CastContextFetchFingerprint, PrimeMethodFingerprint, diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/fingerprints/CastDynamiteModuleFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/fingerprints/CastDynamiteModuleFingerprint.kt deleted file mode 100644 index 783c093c6..000000000 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/fingerprints/CastDynamiteModuleFingerprint.kt +++ /dev/null @@ -1,8 +0,0 @@ -package app.revanced.patches.youtube.misc.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