From 1967547c3748d92ff571b42f638909bed4726aef Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 24 Mar 2024 16:07:03 +0100 Subject: [PATCH 01/11] fix(YouTube): Fix video playback by switching to ReVanced GmsCore vendor --- .../misc/gms/BaseGmsCoreSupportPatch.kt | 42 ++++++++++++------- .../gms/BaseGmsCoreSupportResourcePatch.kt | 3 +- .../misc/fix/playback/ClientSpoofPatch.kt | 3 +- .../misc/fix/playback/SpoofSignaturePatch.kt | 13 +----- 4 files changed, 32 insertions(+), 29 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 5c118db6ac..87e10ad823 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 @@ -53,15 +53,15 @@ 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, - integrationsPatchDependency + integrationsPatchDependency, ) + dependencies, compatiblePackages = compatiblePackages, fingerprints = setOf(GmsCoreSupportFingerprint, mainActivityOnCreateFingerprint) + fingerprints, - requiresIntegrations = true + requiresIntegrations = true, ) { init { // Manually register all options of the resource patch so that they are visible in the patch API. @@ -77,7 +77,7 @@ abstract class BaseGmsCoreSupportPatch( val transformations = arrayOf( ::commonTransform, ::contentUrisTransform, - packageNameTransform(fromPackageName, packageName) + packageNameTransform(fromPackageName, packageName), ) context.transformStringReferences transform@{ string -> transformations.forEach { transform -> @@ -96,7 +96,7 @@ abstract class BaseGmsCoreSupportPatch( // Check the availability of GmsCore. mainActivityOnCreateFingerprint.result?.mutableMethod?.addInstruction( 1, // Hack to not disturb other patches (such as the integrations patch). - "invoke-static {}, Lapp/revanced/integrations/youtube/patches/GmsCoreSupport;->checkAvailability()V" + "invoke-static {}, Lapp/revanced/integrations/youtube/patches/GmsCoreSupport;->checkAvailability()V", ) ?: throw mainActivityOnCreateFingerprint.exception // Change the vendor of GmsCore in ReVanced Integrations. @@ -130,8 +130,8 @@ abstract class BaseGmsCoreSupportPatch( BuilderInstruction21c( Opcode.CONST_STRING, instruction.registerA, - ImmutableStringReference(transformedString) - ) + ImmutableStringReference(transformedString), + ), ) } } @@ -145,7 +145,8 @@ abstract class BaseGmsCoreSupportPatch( "com.google.android.gms", in PERMISSIONS, in ACTIONS, - in AUTHORITIES -> referencedString.replace("com.google", gmsCoreVendor!!) + in AUTHORITIES, + -> referencedString.replace("com.google", gmsCoreVendor!!) // No vendor prefix for whatever reason... "subscribedfeeds" -> "$gmsCoreVendor.subscribedfeeds" @@ -161,7 +162,7 @@ abstract class BaseGmsCoreSupportPatch( if (str.startsWith(uriPrefix)) { return str.replace( uriPrefix, - "content://${authority.replace("com.google", gmsCoreVendor!!)}" + "content://${authority.replace("com.google", gmsCoreVendor!!)}", ) } } @@ -174,13 +175,13 @@ abstract class BaseGmsCoreSupportPatch( } return null - } private fun packageNameTransform(fromPackageName: String, toPackageName: String): (String) -> String? = { string -> when (string) { "$fromPackageName.SuggestionsProvider", - "$fromPackageName.fileprovider" -> string.replace(fromPackageName, toPackageName) + "$fromPackageName.fileprovider", + -> string.replace(fromPackageName, toPackageName) else -> null } @@ -273,6 +274,9 @@ abstract class BaseGmsCoreSupportPatch( // fido "com.google.android.gms.fido.fido2.privileged.START", + // gass + "com.google.android.gms.gass.START", + // games "com.google.android.gms.games.service.START", "com.google.android.gms.games.PLAY_GAMES_UPGRADE", @@ -292,8 +296,18 @@ abstract class BaseGmsCoreSupportPatch( // misc "com.google.android.gms.gmscompliance.service.START", "com.google.android.gms.oss.licenses.service.START", + "com.google.android.gms.tapandpay.service.BIND", + "com.google.android.gms.measurement.START", + "com.google.android.gms.languageprofile.service.START", + "com.google.android.gms.clearcut.service.START", + "com.google.android.gms.icing.LIGHTWEIGHT_INDEX_SERVICE", + + // potoken + "com.google.android.gms.potokens.service.START", + + // droidguard/ safetynet + "com.google.android.gms.droidguard.service.START", "com.google.android.gms.safetynet.service.START", - "com.google.android.gms.tapandpay.service.BIND" ) /** @@ -314,9 +328,9 @@ abstract class BaseGmsCoreSupportPatch( "com.google.android.gms.fonts", // phenotype - "com.google.android.gms.phenotype" + "com.google.android.gms.phenotype", ) } // endregion -} \ No newline at end of file +} 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 e42f33608f..cb8abbf588 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 @@ -27,10 +27,9 @@ abstract class BaseGmsCoreSupportResourcePatch( internal val gmsCoreVendorOption = stringPatchOption( key = "gmsCoreVendor", - default = "com.mgoogle", + default = "app.revanced", values = mapOf( - "Vanced" to "com.mgoogle", "ReVanced" to "app.revanced", ), title = "GmsCore Vendor", diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/ClientSpoofPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/ClientSpoofPatch.kt index 57572996a6..aeb1788d74 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/ClientSpoofPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/ClientSpoofPatch.kt @@ -18,8 +18,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference @Patch( name = "Client spoof", - description = "Adds options to spoof the client to allow video playback.", - dependencies = [SpoofSignaturePatch::class], + description = "Spoofs the client to allow video playback.", compatiblePackages = [ CompatiblePackage("com.google.android.youtube"), ], diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt index 5a00c7918e..4e9a7833c4 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt @@ -13,21 +13,11 @@ import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen.Sorting import app.revanced.patches.shared.misc.settings.preference.SwitchPreference import app.revanced.patches.youtube.misc.fix.playback.fingerprints.* -import app.revanced.patches.youtube.misc.fix.playback.fingerprints.ParamsMapPutFingerprint -import app.revanced.patches.youtube.misc.fix.playback.fingerprints.PlayerResponseModelImplGeneralFingerprint -import app.revanced.patches.youtube.misc.fix.playback.fingerprints.PlayerResponseModelImplLiveStreamFingerprint -import app.revanced.patches.youtube.misc.fix.playback.fingerprints.PlayerResponseModelImplRecommendedLevelFingerprint -import app.revanced.patches.youtube.misc.fix.playback.fingerprints.ScrubbedPreviewLayoutFingerprint -import app.revanced.patches.youtube.misc.fix.playback.fingerprints.StoryboardRendererDecoderRecommendedLevelFingerprint -import app.revanced.patches.youtube.misc.fix.playback.fingerprints.StoryboardRendererDecoderSpecFingerprint -import app.revanced.patches.youtube.misc.fix.playback.fingerprints.StoryboardRendererSpecFingerprint -import app.revanced.patches.youtube.misc.fix.playback.fingerprints.StoryboardThumbnailFingerprint -import app.revanced.patches.youtube.misc.fix.playback.fingerprints.StoryboardThumbnailParentFingerprint import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.video.information.VideoInformationPatch import app.revanced.patches.youtube.video.playerresponse.PlayerResponseMethodHookPatch -import app.revanced.util.* +import app.revanced.util.exception import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction @@ -43,6 +33,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction AddResourcesPatch::class, ], ) +@Deprecated("This patch will be removed in the future.") object SpoofSignaturePatch : BytecodePatch( setOf( PlayerResponseModelImplGeneralFingerprint, From 6ad0152495ba518c883656d66eb466c04e4f4b85 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 24 Mar 2024 23:52:24 +0400 Subject: [PATCH 02/11] fix: Silently migrate obsolete Gms patch option, temporarily use a different 'gms not installed' toast message --- .../misc/gms/BaseGmsCoreSupportResourcePatch.kt | 12 ++++++++++++ src/main/resources/addresources/values/strings.xml | 4 ++++ 2 files changed, 16 insertions(+) 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 cb8abbf588..abe6ae21d2 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 @@ -9,6 +9,8 @@ import app.revanced.patches.all.misc.resources.AddResourcesPatch import org.w3c.dom.Element import org.w3c.dom.Node +private const val OBSOLETE_VANCED_MICROG_PATCH_OPTION_VALUE = "com.mgoogle" + /** * Abstract resource patch that allows Google apps to run without root and under a different package name * by using GmsCore instead of Google Play Services. @@ -42,6 +44,16 @@ abstract class BaseGmsCoreSupportResourcePatch( override fun execute(context: ResourceContext) { AddResourcesPatch(BaseGmsCoreSupportResourcePatch::class) + // Ignore old Vanced MicroG options, if the patch options are from an old Manager/CLI installation. + // This could be done in the option validation, but that shows + // a warning message the user might interpret as something went wrong. + // So instead silently use the updated default value. + // TODO: Remove this temporary logic (and also revert the `gms_core_not_running_warning` string change) + if (gmsCoreVendorOption.value == OBSOLETE_VANCED_MICROG_PATCH_OPTION_VALUE) { + gmsCoreVendorOption.value = gmsCoreVendorOption.default + // If there was patch logging, it would be useful here. + } + context.patchManifest() context.addSpoofingMetadata() } diff --git a/src/main/resources/addresources/values/strings.xml b/src/main/resources/addresources/values/strings.xml index c473143626..cc5bebf4a4 100644 --- a/src/main/resources/addresources/values/strings.xml +++ b/src/main/resources/addresources/values/strings.xml @@ -13,7 +13,11 @@ Import failed: %s + + GmsCore is outdated. Please update it. + GmsCore is failing to run. Please follow the \"Don\'t kill my app\" guide for GmsCore. From a3fdde319a508fcbfca257554e00271b197b54b4 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Mon, 25 Mar 2024 00:49:57 +0400 Subject: [PATCH 03/11] Comments --- .../patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 abe6ae21d2..ce85961e9b 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 @@ -48,7 +48,8 @@ abstract class BaseGmsCoreSupportResourcePatch( // This could be done in the option validation, but that shows // a warning message the user might interpret as something went wrong. // So instead silently use the updated default value. - // TODO: Remove this temporary logic (and also revert the `gms_core_not_running_warning` string change) + // TODO: Remove this temporary logic after Manager improves handling of changed default options. + // (and also revert the `gms_core_not_running_warning` string change) if (gmsCoreVendorOption.value == OBSOLETE_VANCED_MICROG_PATCH_OPTION_VALUE) { gmsCoreVendorOption.value = gmsCoreVendorOption.default // If there was patch logging, it would be useful here. From d801e68d1fb122e39af637f5dd86a4b3577e45fc Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Mon, 25 Mar 2024 02:40:35 +0400 Subject: [PATCH 04/11] Revert string change. --- src/main/resources/addresources/values/strings.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/resources/addresources/values/strings.xml b/src/main/resources/addresources/values/strings.xml index cc5bebf4a4..c473143626 100644 --- a/src/main/resources/addresources/values/strings.xml +++ b/src/main/resources/addresources/values/strings.xml @@ -13,11 +13,7 @@ Import failed: %s - - GmsCore is outdated. Please update it. - GmsCore is failing to run. Please follow the \"Don\'t kill my app\" guide for GmsCore. From a82e99ed06fa2ec587ad0574668f48f349355024 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 24 Mar 2024 23:38:57 +0100 Subject: [PATCH 05/11] Adjust comment --- .../shared/misc/gms/BaseGmsCoreSupportResourcePatch.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) 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 ce85961e9b..103e7fb0b9 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 @@ -44,15 +44,11 @@ abstract class BaseGmsCoreSupportResourcePatch( override fun execute(context: ResourceContext) { AddResourcesPatch(BaseGmsCoreSupportResourcePatch::class) - // Ignore old Vanced MicroG options, if the patch options are from an old Manager/CLI installation. - // This could be done in the option validation, but that shows - // a warning message the user might interpret as something went wrong. - // So instead silently use the updated default value. - // TODO: Remove this temporary logic after Manager improves handling of changed default options. - // (and also revert the `gms_core_not_running_warning` string change) + // TODO: Remove this, once ReVanced Manager supports falling back to default patch option values, + // once a patch option value has been removed from a patch. + // The vendor Vanced is known to break with ReVanced. Fall back to ReVanced as the vendor. if (gmsCoreVendorOption.value == OBSOLETE_VANCED_MICROG_PATCH_OPTION_VALUE) { gmsCoreVendorOption.value = gmsCoreVendorOption.default - // If there was patch logging, it would be useful here. } context.patchManifest() From 72f2175320507cfe09c48f3c17b68d9780181ef9 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 24 Mar 2024 23:39:35 +0100 Subject: [PATCH 06/11] Use delegated properties --- .../shared/misc/gms/BaseGmsCoreSupportResourcePatch.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 103e7fb0b9..baa44a3760 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 @@ -39,7 +39,7 @@ abstract class BaseGmsCoreSupportResourcePatch( required = true, ) { it!!.matches(Regex("^[a-z]\\w*(\\.[a-z]\\w*)+\$")) } - protected val gmsCoreVendor by gmsCoreVendorOption + protected var gmsCoreVendor by gmsCoreVendorOption override fun execute(context: ResourceContext) { AddResourcesPatch(BaseGmsCoreSupportResourcePatch::class) @@ -47,8 +47,8 @@ abstract class BaseGmsCoreSupportResourcePatch( // TODO: Remove this, once ReVanced Manager supports falling back to default patch option values, // once a patch option value has been removed from a patch. // The vendor Vanced is known to break with ReVanced. Fall back to ReVanced as the vendor. - if (gmsCoreVendorOption.value == OBSOLETE_VANCED_MICROG_PATCH_OPTION_VALUE) { - gmsCoreVendorOption.value = gmsCoreVendorOption.default + if (gmsCoreVendor == OBSOLETE_VANCED_MICROG_PATCH_OPTION_VALUE) { + gmsCoreVendor = gmsCoreVendorOption.default } context.patchManifest() From b0177deb6e0defaed4fec847ccfd31eb9cfbfd88 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 24 Mar 2024 23:41:29 +0100 Subject: [PATCH 07/11] Log fallback --- .../shared/misc/gms/BaseGmsCoreSupportResourcePatch.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 baa44a3760..090fd205c6 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 @@ -8,6 +8,7 @@ import app.revanced.patches.all.misc.packagename.ChangePackageNamePatch import app.revanced.patches.all.misc.resources.AddResourcesPatch import org.w3c.dom.Element import org.w3c.dom.Node +import java.util.logging.Logger private const val OBSOLETE_VANCED_MICROG_PATCH_OPTION_VALUE = "com.mgoogle" @@ -46,8 +47,11 @@ abstract class BaseGmsCoreSupportResourcePatch( // TODO: Remove this, once ReVanced Manager supports falling back to default patch option values, // once a patch option value has been removed from a patch. - // The vendor Vanced is known to break with ReVanced. Fall back to ReVanced as the vendor. if (gmsCoreVendor == OBSOLETE_VANCED_MICROG_PATCH_OPTION_VALUE) { + Logger.getLogger(name).info( + "Vanced MicroG is incompatible with ReVanced. Falling back to ReVanced GmsCore.", + ) + gmsCoreVendor = gmsCoreVendorOption.default } From 3bda3f29725c4c4fe1b5d7c035c8f754fb9d8678 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 24 Mar 2024 23:46:38 +0100 Subject: [PATCH 08/11] Improve robustness --- .../shared/misc/gms/BaseGmsCoreSupportResourcePatch.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 090fd205c6..3e85ac7626 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 @@ -10,8 +10,6 @@ import org.w3c.dom.Element import org.w3c.dom.Node import java.util.logging.Logger -private const val OBSOLETE_VANCED_MICROG_PATCH_OPTION_VALUE = "com.mgoogle" - /** * Abstract resource patch that allows Google apps to run without root and under a different package name * by using GmsCore instead of Google Play Services. @@ -27,6 +25,10 @@ abstract class BaseGmsCoreSupportResourcePatch( private val spoofedPackageSignature: String, dependencies: Set = setOf(), ) : ResourcePatch(dependencies = setOf(ChangePackageNamePatch::class, AddResourcesPatch::class) + dependencies) { + private companion object { + private const val VANCED_VENDOR = "com.mgoogle" + private const val PACKAGE_NAME_REGEX_PATTERN = "^[a-z]\\w*(\\.[a-z]\\w*)+\$" + } internal val gmsCoreVendorOption = stringPatchOption( key = "gmsCoreVendor", @@ -38,7 +40,7 @@ abstract class BaseGmsCoreSupportResourcePatch( title = "GmsCore Vendor", description = "The group id of the GmsCore vendor.", required = true, - ) { it!!.matches(Regex("^[a-z]\\w*(\\.[a-z]\\w*)+\$")) } + ) { it!!.matches(Regex(PACKAGE_NAME_REGEX_PATTERN)) } protected var gmsCoreVendor by gmsCoreVendorOption @@ -47,7 +49,7 @@ abstract class BaseGmsCoreSupportResourcePatch( // TODO: Remove this, once ReVanced Manager supports falling back to default patch option values, // once a patch option value has been removed from a patch. - if (gmsCoreVendor == OBSOLETE_VANCED_MICROG_PATCH_OPTION_VALUE) { + if (gmsCoreVendor!!.lowercase().startsWith(VANCED_VENDOR)) { Logger.getLogger(name).info( "Vanced MicroG is incompatible with ReVanced. Falling back to ReVanced GmsCore.", ) From 4a96fcd1c72fe3bf487f03f574ae702addc324fc Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 24 Mar 2024 23:48:26 +0100 Subject: [PATCH 09/11] refactor [skip ci] --- .../misc/gms/BaseGmsCoreSupportResourcePatch.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 3e85ac7626..173cc52be0 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 @@ -25,10 +25,8 @@ abstract class BaseGmsCoreSupportResourcePatch( private val spoofedPackageSignature: String, dependencies: Set = setOf(), ) : ResourcePatch(dependencies = setOf(ChangePackageNamePatch::class, AddResourcesPatch::class) + dependencies) { - private companion object { - private const val VANCED_VENDOR = "com.mgoogle" - private const val PACKAGE_NAME_REGEX_PATTERN = "^[a-z]\\w*(\\.[a-z]\\w*)+\$" - } + private val logger = Logger.getLogger(name) + internal val gmsCoreVendorOption = stringPatchOption( key = "gmsCoreVendor", @@ -50,9 +48,7 @@ abstract class BaseGmsCoreSupportResourcePatch( // TODO: Remove this, once ReVanced Manager supports falling back to default patch option values, // once a patch option value has been removed from a patch. if (gmsCoreVendor!!.lowercase().startsWith(VANCED_VENDOR)) { - Logger.getLogger(name).info( - "Vanced MicroG is incompatible with ReVanced. Falling back to ReVanced GmsCore.", - ) + logger.info("Vanced MicroG is incompatible with ReVanced. Falling back to ReVanced GmsCore.") gmsCoreVendor = gmsCoreVendorOption.default } @@ -131,4 +127,9 @@ abstract class BaseGmsCoreSupportResourcePatch( ), ) } + + private companion object { + private const val VANCED_VENDOR = "com.mgoogle" + private const val PACKAGE_NAME_REGEX_PATTERN = "^[a-z]\\w*(\\.[a-z]\\w*)+\$" + } } From 2bfbde8554e0e83837230b593ace704b1b6bb69a Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 25 Mar 2024 23:38:07 +0100 Subject: [PATCH 10/11] Change option key In order to force a one time migration to the default option value, change the option key. Also, the new option key name makes more sense. --- .../music/misc/gms/GmsCoreSupportPatch.kt | 10 +++--- .../gms/BaseGmsCoreSupportResourcePatch.kt | 31 ++++++------------- .../youtube/misc/gms/GmsCoreSupportPatch.kt | 20 ++++++------ .../misc/gms/GmsCoreSupportResourcePatch.kt | 9 +++--- 4 files changed, 29 insertions(+), 41 deletions(-) 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 5bb8e2a454..65d9053960 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 @@ -2,12 +2,12 @@ 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.gmsCoreVendorOption +import app.revanced.patches.music.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorGroupIdOption import app.revanced.patches.music.misc.gms.fingerprints.* -import app.revanced.patches.music.misc.integrations.fingerprints.ApplicationInitFingerprint import app.revanced.patches.music.misc.integrations.IntegrationsPatch -import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch +import app.revanced.patches.music.misc.integrations.fingerprints.ApplicationInitFingerprint import app.revanced.patches.shared.fingerprints.CastContextFetchFingerprint +import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch @Suppress("unused") object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( @@ -32,7 +32,7 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( CastDynamiteModuleV2Fingerprint, CastContextFetchFingerprint, PrimeMethodFingerprint, - ) + ), ) { - override val gmsCoreVendor by gmsCoreVendorOption + override val gmsCoreVendor by gmsCoreVendorGroupIdOption } 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 173cc52be0..b89da3b708 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 @@ -8,7 +8,6 @@ import app.revanced.patches.all.misc.packagename.ChangePackageNamePatch import app.revanced.patches.all.misc.resources.AddResourcesPatch import org.w3c.dom.Element import org.w3c.dom.Node -import java.util.logging.Logger /** * Abstract resource patch that allows Google apps to run without root and under a different package name @@ -25,34 +24,24 @@ abstract class BaseGmsCoreSupportResourcePatch( private val spoofedPackageSignature: String, dependencies: Set = setOf(), ) : ResourcePatch(dependencies = setOf(ChangePackageNamePatch::class, AddResourcesPatch::class) + dependencies) { - private val logger = Logger.getLogger(name) - - internal val gmsCoreVendorOption = + internal val gmsCoreVendorGroupIdOption = stringPatchOption( - key = "gmsCoreVendor", + key = "gmsCoreVendorGroupId", default = "app.revanced", values = mapOf( "ReVanced" to "app.revanced", ), - title = "GmsCore Vendor", - description = "The group id of the GmsCore vendor.", + title = "GmsCore vendor group ID", + description = "The vendor's group ID for GmsCore.", required = true, ) { it!!.matches(Regex(PACKAGE_NAME_REGEX_PATTERN)) } - protected var gmsCoreVendor by gmsCoreVendorOption + protected val gmsCoreVendorGroupId by gmsCoreVendorGroupIdOption override fun execute(context: ResourceContext) { AddResourcesPatch(BaseGmsCoreSupportResourcePatch::class) - // TODO: Remove this, once ReVanced Manager supports falling back to default patch option values, - // once a patch option value has been removed from a patch. - if (gmsCoreVendor!!.lowercase().startsWith(VANCED_VENDOR)) { - logger.info("Vanced MicroG is incompatible with ReVanced. Falling back to ReVanced GmsCore.") - - gmsCoreVendor = gmsCoreVendorOption.default - } - context.patchManifest() context.addSpoofingMetadata() } @@ -80,12 +69,12 @@ abstract class BaseGmsCoreSupportResourcePatch( // Spoof package name and signature. applicationNode.adoptChild("meta-data") { - setAttribute("android:name", "$gmsCoreVendor.android.gms.SPOOFED_PACKAGE_NAME") + setAttribute("android:name", "$gmsCoreVendorGroupId.android.gms.SPOOFED_PACKAGE_NAME") setAttribute("android:value", fromPackageName) } applicationNode.adoptChild("meta-data") { - setAttribute("android:name", "$gmsCoreVendor.android.gms.SPOOFED_PACKAGE_SIGNATURE") + setAttribute("android:name", "$gmsCoreVendorGroupId.android.gms.SPOOFED_PACKAGE_SIGNATURE") setAttribute("android:value", spoofedPackageSignature) } @@ -93,7 +82,7 @@ abstract class BaseGmsCoreSupportResourcePatch( applicationNode.adoptChild("meta-data") { // TODO: The name of this metadata should be dynamic. setAttribute("android:name", "app.revanced.MICROG_PACKAGE_NAME") - setAttribute("android:value", "$gmsCoreVendor.android.gms") + setAttribute("android:value", "$gmsCoreVendorGroupId.android.gms") } } } @@ -120,10 +109,10 @@ abstract class BaseGmsCoreSupportResourcePatch( "$packageName.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION", ).replace( "com.google.android.c2dm", - "$gmsCoreVendor.android.c2dm", + "$gmsCoreVendorGroupId.android.c2dm", ).replace( "", - "", + "", ), ) } 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 21899ec20d..ff29023516 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 @@ -6,12 +6,11 @@ import app.revanced.patches.youtube.layout.buttons.cast.HideCastButtonPatch import app.revanced.patches.youtube.misc.fix.playback.ClientSpoofPatch 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.gmsCoreVendorOption +import app.revanced.patches.youtube.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorGroupIdOption import app.revanced.patches.youtube.misc.gms.fingerprints.* import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch import app.revanced.patches.youtube.shared.fingerprints.HomeActivityFingerprint - @Suppress("unused") object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( fromPackageName = YOUTUBE_PACKAGE_NAME, @@ -22,18 +21,19 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( GooglePlayUtilityFingerprint, CastDynamiteModuleFingerprint, CastDynamiteModuleV2Fingerprint, - CastContextFetchFingerprint + CastContextFetchFingerprint, ), mainActivityOnCreateFingerprint = HomeActivityFingerprint, integrationsPatchDependency = IntegrationsPatch::class, dependencies = setOf( HideCastButtonPatch::class, - ClientSpoofPatch::class + ClientSpoofPatch::class, ), gmsCoreSupportResourcePatch = GmsCoreSupportResourcePatch, compatiblePackages = setOf( CompatiblePackage( - "com.google.android.youtube", setOf( + "com.google.android.youtube", + setOf( "18.48.39", "18.49.37", "19.01.34", @@ -44,9 +44,9 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( "19.06.39", "19.07.40", "19.08.36", - "19.09.37" - ) - ) + "19.09.37", + ), + ), ), fingerprints = setOf( ServiceCheckFingerprint, @@ -55,7 +55,7 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( CastDynamiteModuleV2Fingerprint, CastContextFetchFingerprint, PrimeMethodFingerprint, - ) + ), ) { - override val gmsCoreVendor by gmsCoreVendorOption + override val gmsCoreVendor by gmsCoreVendorGroupIdOption } diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch.kt index 151e1b6c60..730d921a49 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch.kt @@ -8,12 +8,11 @@ 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.settings.SettingsPatch - object GmsCoreSupportResourcePatch : BaseGmsCoreSupportResourcePatch( fromPackageName = YOUTUBE_PACKAGE_NAME, toPackageName = REVANCED_YOUTUBE_PACKAGE_NAME, spoofedPackageSignature = "24bb24c05e47e0aefa68a58a766179d9b613a600", - dependencies = setOf(SettingsPatch::class, AddResourcesPatch::class) + dependencies = setOf(SettingsPatch::class, AddResourcesPatch::class), ) { override fun execute(context: ResourceContext) { AddResourcesPatch(this::class) @@ -22,9 +21,9 @@ object GmsCoreSupportResourcePatch : BaseGmsCoreSupportResourcePatch( IntentPreference( "microg_settings", intent = IntentPreference.Intent("", "org.microg.gms.ui.SettingsActivity") { - "$gmsCoreVendor.android.gms" - } - ) + "$gmsCoreVendorGroupId.android.gms" + }, + ), ) super.execute(context) From 1310f366eeee7da00b96633983c51cb688c99164 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 25 Mar 2024 23:45:08 +0100 Subject: [PATCH 11/11] fix api --- api/revanced-patches.api | 1 + .../patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch.kt | 3 +++ 2 files changed, 4 insertions(+) diff --git a/api/revanced-patches.api b/api/revanced-patches.api index a705775734..cda2f84226 100644 --- a/api/revanced-patches.api +++ b/api/revanced-patches.api @@ -615,6 +615,7 @@ public abstract class app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportRes public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V protected final fun getGmsCoreVendor ()Ljava/lang/String; + protected final fun getGmsCoreVendorGroupId ()Ljava/lang/String; } public abstract class app/revanced/patches/shared/misc/integrations/BaseIntegrationsPatch : app/revanced/patcher/patch/BytecodePatch { 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 b89da3b708..eef039f740 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 @@ -39,6 +39,9 @@ abstract class BaseGmsCoreSupportResourcePatch( protected val gmsCoreVendorGroupId by gmsCoreVendorGroupIdOption + @Deprecated("Use gmsCoreVendorGroupId instead.", ReplaceWith("gmsCoreVendorGroupId")) + protected val gmsCoreVendor by gmsCoreVendorGroupIdOption + override fun execute(context: ResourceContext) { AddResourcesPatch(BaseGmsCoreSupportResourcePatch::class)