fix(YouTube): Fix video playback by switching to ReVanced GmsCore vendor (#2907)
The previous vendor did not update GmsCore, resulting in missing features required for playback, specifically PoToken, which was added to requests recently. Because the PoToken was missing, playback failed.
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
+20
-13
@@ -24,21 +24,23 @@ abstract class BaseGmsCoreSupportResourcePatch(
|
||||
private val spoofedPackageSignature: String,
|
||||
dependencies: Set<PatchClass> = setOf(),
|
||||
) : ResourcePatch(dependencies = setOf(ChangePackageNamePatch::class, AddResourcesPatch::class) + dependencies) {
|
||||
internal val gmsCoreVendorOption =
|
||||
internal val gmsCoreVendorGroupIdOption =
|
||||
stringPatchOption(
|
||||
key = "gmsCoreVendor",
|
||||
default = "com.mgoogle",
|
||||
key = "gmsCoreVendorGroupId",
|
||||
default = "app.revanced",
|
||||
values =
|
||||
mapOf(
|
||||
"Vanced" to "com.mgoogle",
|
||||
"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("^[a-z]\\w*(\\.[a-z]\\w*)+\$")) }
|
||||
) { it!!.matches(Regex(PACKAGE_NAME_REGEX_PATTERN)) }
|
||||
|
||||
protected val gmsCoreVendor by gmsCoreVendorOption
|
||||
protected val gmsCoreVendorGroupId by gmsCoreVendorGroupIdOption
|
||||
|
||||
@Deprecated("Use gmsCoreVendorGroupId instead.", ReplaceWith("gmsCoreVendorGroupId"))
|
||||
protected val gmsCoreVendor by gmsCoreVendorGroupIdOption
|
||||
|
||||
override fun execute(context: ResourceContext) {
|
||||
AddResourcesPatch(BaseGmsCoreSupportResourcePatch::class)
|
||||
@@ -70,12 +72,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)
|
||||
}
|
||||
|
||||
@@ -83,7 +85,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")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,11 +112,16 @@ abstract class BaseGmsCoreSupportResourcePatch(
|
||||
"$packageName.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION",
|
||||
).replace(
|
||||
"com.google.android.c2dm",
|
||||
"$gmsCoreVendor.android.c2dm",
|
||||
"$gmsCoreVendorGroupId.android.c2dm",
|
||||
).replace(
|
||||
"</queries>",
|
||||
"<package android:name=\"$gmsCoreVendor.android.gms\"/></queries>",
|
||||
"<package android:name=\"$gmsCoreVendorGroupId.android.gms\"/></queries>",
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val VANCED_VENDOR = "com.mgoogle"
|
||||
private const val PACKAGE_NAME_REGEX_PATTERN = "^[a-z]\\w*(\\.[a-z]\\w*)+\$"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user