Skip to content

Commit 0bd0c82

Browse files
authored
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.
1 parent cbae138 commit 0bd0c82

File tree

8 files changed

+71
-60
lines changed

8 files changed

+71
-60
lines changed

api/revanced-patches.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ public abstract class app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportRes
636636
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
637637
public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V
638638
protected final fun getGmsCoreVendor ()Ljava/lang/String;
639+
protected final fun getGmsCoreVendorGroupId ()Ljava/lang/String;
639640
}
640641

641642
public abstract class app/revanced/patches/shared/misc/integrations/BaseIntegrationsPatch : app/revanced/patcher/patch/BytecodePatch {

src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package app.revanced.patches.music.misc.gms
22

33
import app.revanced.patches.music.misc.gms.Constants.MUSIC_PACKAGE_NAME
44
import app.revanced.patches.music.misc.gms.Constants.REVANCED_MUSIC_PACKAGE_NAME
5-
import app.revanced.patches.music.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorOption
5+
import app.revanced.patches.music.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorGroupIdOption
66
import app.revanced.patches.music.misc.gms.fingerprints.*
7-
import app.revanced.patches.music.misc.integrations.fingerprints.ApplicationInitFingerprint
87
import app.revanced.patches.music.misc.integrations.IntegrationsPatch
9-
import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch
8+
import app.revanced.patches.music.misc.integrations.fingerprints.ApplicationInitFingerprint
109
import app.revanced.patches.shared.fingerprints.CastContextFetchFingerprint
10+
import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch
1111

1212
@Suppress("unused")
1313
object GmsCoreSupportPatch : BaseGmsCoreSupportPatch(
@@ -32,7 +32,7 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch(
3232
CastDynamiteModuleV2Fingerprint,
3333
CastContextFetchFingerprint,
3434
PrimeMethodFingerprint,
35-
)
35+
),
3636
) {
37-
override val gmsCoreVendor by gmsCoreVendorOption
37+
override val gmsCoreVendor by gmsCoreVendorGroupIdOption
3838
}

src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportPatch.kt

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ abstract class BaseGmsCoreSupportPatch(
5353
) : BytecodePatch(
5454
name = "GmsCore support",
5555
description = "Allows patched Google apps to run without root and under a different package name " +
56-
"by using GmsCore instead of Google Play Services.",
56+
"by using GmsCore instead of Google Play Services.",
5757
dependencies = setOf(
5858
ChangePackageNamePatch::class,
5959
gmsCoreSupportResourcePatch::class,
60-
integrationsPatchDependency
60+
integrationsPatchDependency,
6161
) + dependencies,
6262
compatiblePackages = compatiblePackages,
6363
fingerprints = setOf(GmsCoreSupportFingerprint, mainActivityOnCreateFingerprint) + fingerprints,
64-
requiresIntegrations = true
64+
requiresIntegrations = true,
6565
) {
6666
init {
6767
// Manually register all options of the resource patch so that they are visible in the patch API.
@@ -77,7 +77,7 @@ abstract class BaseGmsCoreSupportPatch(
7777
val transformations = arrayOf(
7878
::commonTransform,
7979
::contentUrisTransform,
80-
packageNameTransform(fromPackageName, packageName)
80+
packageNameTransform(fromPackageName, packageName),
8181
)
8282
context.transformStringReferences transform@{ string ->
8383
transformations.forEach { transform ->
@@ -96,7 +96,7 @@ abstract class BaseGmsCoreSupportPatch(
9696
// Check the availability of GmsCore.
9797
mainActivityOnCreateFingerprint.result?.mutableMethod?.addInstruction(
9898
1, // Hack to not disturb other patches (such as the integrations patch).
99-
"invoke-static {}, Lapp/revanced/integrations/youtube/patches/GmsCoreSupport;->checkAvailability()V"
99+
"invoke-static {}, Lapp/revanced/integrations/youtube/patches/GmsCoreSupport;->checkAvailability()V",
100100
) ?: throw mainActivityOnCreateFingerprint.exception
101101

102102
// Change the vendor of GmsCore in ReVanced Integrations.
@@ -130,8 +130,8 @@ abstract class BaseGmsCoreSupportPatch(
130130
BuilderInstruction21c(
131131
Opcode.CONST_STRING,
132132
instruction.registerA,
133-
ImmutableStringReference(transformedString)
134-
)
133+
ImmutableStringReference(transformedString),
134+
),
135135
)
136136
}
137137
}
@@ -145,7 +145,8 @@ abstract class BaseGmsCoreSupportPatch(
145145
"com.google.android.gms",
146146
in PERMISSIONS,
147147
in ACTIONS,
148-
in AUTHORITIES -> referencedString.replace("com.google", gmsCoreVendor!!)
148+
in AUTHORITIES,
149+
-> referencedString.replace("com.google", gmsCoreVendor!!)
149150

150151
// No vendor prefix for whatever reason...
151152
"subscribedfeeds" -> "$gmsCoreVendor.subscribedfeeds"
@@ -161,7 +162,7 @@ abstract class BaseGmsCoreSupportPatch(
161162
if (str.startsWith(uriPrefix)) {
162163
return str.replace(
163164
uriPrefix,
164-
"content://${authority.replace("com.google", gmsCoreVendor!!)}"
165+
"content://${authority.replace("com.google", gmsCoreVendor!!)}",
165166
)
166167
}
167168
}
@@ -174,13 +175,13 @@ abstract class BaseGmsCoreSupportPatch(
174175
}
175176

176177
return null
177-
178178
}
179179

180180
private fun packageNameTransform(fromPackageName: String, toPackageName: String): (String) -> String? = { string ->
181181
when (string) {
182182
"$fromPackageName.SuggestionsProvider",
183-
"$fromPackageName.fileprovider" -> string.replace(fromPackageName, toPackageName)
183+
"$fromPackageName.fileprovider",
184+
-> string.replace(fromPackageName, toPackageName)
184185

185186
else -> null
186187
}
@@ -273,6 +274,9 @@ abstract class BaseGmsCoreSupportPatch(
273274
// fido
274275
"com.google.android.gms.fido.fido2.privileged.START",
275276

277+
// gass
278+
"com.google.android.gms.gass.START",
279+
276280
// games
277281
"com.google.android.gms.games.service.START",
278282
"com.google.android.gms.games.PLAY_GAMES_UPGRADE",
@@ -292,8 +296,18 @@ abstract class BaseGmsCoreSupportPatch(
292296
// misc
293297
"com.google.android.gms.gmscompliance.service.START",
294298
"com.google.android.gms.oss.licenses.service.START",
299+
"com.google.android.gms.tapandpay.service.BIND",
300+
"com.google.android.gms.measurement.START",
301+
"com.google.android.gms.languageprofile.service.START",
302+
"com.google.android.gms.clearcut.service.START",
303+
"com.google.android.gms.icing.LIGHTWEIGHT_INDEX_SERVICE",
304+
305+
// potoken
306+
"com.google.android.gms.potokens.service.START",
307+
308+
// droidguard/ safetynet
309+
"com.google.android.gms.droidguard.service.START",
295310
"com.google.android.gms.safetynet.service.START",
296-
"com.google.android.gms.tapandpay.service.BIND"
297311
)
298312

299313
/**
@@ -314,9 +328,9 @@ abstract class BaseGmsCoreSupportPatch(
314328
"com.google.android.gms.fonts",
315329

316330
// phenotype
317-
"com.google.android.gms.phenotype"
331+
"com.google.android.gms.phenotype",
318332
)
319333
}
320334

321335
// endregion
322-
}
336+
}

src/main/kotlin/app/revanced/patches/shared/misc/gms/BaseGmsCoreSupportResourcePatch.kt

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,23 @@ abstract class BaseGmsCoreSupportResourcePatch(
2424
private val spoofedPackageSignature: String,
2525
dependencies: Set<PatchClass> = setOf(),
2626
) : ResourcePatch(dependencies = setOf(ChangePackageNamePatch::class, AddResourcesPatch::class) + dependencies) {
27-
internal val gmsCoreVendorOption =
27+
internal val gmsCoreVendorGroupIdOption =
2828
stringPatchOption(
29-
key = "gmsCoreVendor",
30-
default = "com.mgoogle",
29+
key = "gmsCoreVendorGroupId",
30+
default = "app.revanced",
3131
values =
3232
mapOf(
33-
"Vanced" to "com.mgoogle",
3433
"ReVanced" to "app.revanced",
3534
),
36-
title = "GmsCore Vendor",
37-
description = "The group id of the GmsCore vendor.",
35+
title = "GmsCore vendor group ID",
36+
description = "The vendor's group ID for GmsCore.",
3837
required = true,
39-
) { it!!.matches(Regex("^[a-z]\\w*(\\.[a-z]\\w*)+\$")) }
38+
) { it!!.matches(Regex(PACKAGE_NAME_REGEX_PATTERN)) }
4039

41-
protected val gmsCoreVendor by gmsCoreVendorOption
40+
protected val gmsCoreVendorGroupId by gmsCoreVendorGroupIdOption
41+
42+
@Deprecated("Use gmsCoreVendorGroupId instead.", ReplaceWith("gmsCoreVendorGroupId"))
43+
protected val gmsCoreVendor by gmsCoreVendorGroupIdOption
4244

4345
override fun execute(context: ResourceContext) {
4446
AddResourcesPatch(BaseGmsCoreSupportResourcePatch::class)
@@ -70,20 +72,20 @@ abstract class BaseGmsCoreSupportResourcePatch(
7072

7173
// Spoof package name and signature.
7274
applicationNode.adoptChild("meta-data") {
73-
setAttribute("android:name", "$gmsCoreVendor.android.gms.SPOOFED_PACKAGE_NAME")
75+
setAttribute("android:name", "$gmsCoreVendorGroupId.android.gms.SPOOFED_PACKAGE_NAME")
7476
setAttribute("android:value", fromPackageName)
7577
}
7678

7779
applicationNode.adoptChild("meta-data") {
78-
setAttribute("android:name", "$gmsCoreVendor.android.gms.SPOOFED_PACKAGE_SIGNATURE")
80+
setAttribute("android:name", "$gmsCoreVendorGroupId.android.gms.SPOOFED_PACKAGE_SIGNATURE")
7981
setAttribute("android:value", spoofedPackageSignature)
8082
}
8183

8284
// GmsCore presence detection in ReVanced Integrations.
8385
applicationNode.adoptChild("meta-data") {
8486
// TODO: The name of this metadata should be dynamic.
8587
setAttribute("android:name", "app.revanced.MICROG_PACKAGE_NAME")
86-
setAttribute("android:value", "$gmsCoreVendor.android.gms")
88+
setAttribute("android:value", "$gmsCoreVendorGroupId.android.gms")
8789
}
8890
}
8991
}
@@ -110,11 +112,16 @@ abstract class BaseGmsCoreSupportResourcePatch(
110112
"$packageName.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION",
111113
).replace(
112114
"com.google.android.c2dm",
113-
"$gmsCoreVendor.android.c2dm",
115+
"$gmsCoreVendorGroupId.android.c2dm",
114116
).replace(
115117
"</queries>",
116-
"<package android:name=\"$gmsCoreVendor.android.gms\"/></queries>",
118+
"<package android:name=\"$gmsCoreVendorGroupId.android.gms\"/></queries>",
117119
),
118120
)
119121
}
122+
123+
private companion object {
124+
private const val VANCED_VENDOR = "com.mgoogle"
125+
private const val PACKAGE_NAME_REGEX_PATTERN = "^[a-z]\\w*(\\.[a-z]\\w*)+\$"
126+
}
120127
}

src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/ClientSpoofPatch.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
1818

1919
@Patch(
2020
name = "Client spoof",
21-
description = "Adds options to spoof the client to allow video playback.",
22-
dependencies = [SpoofSignaturePatch::class],
21+
description = "Spoofs the client to allow video playback.",
2322
compatiblePackages = [
2423
CompatiblePackage("com.google.android.youtube"),
2524
],

src/main/kotlin/app/revanced/patches/youtube/misc/fix/playback/SpoofSignaturePatch.kt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,11 @@ import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen
1313
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen.Sorting
1414
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
1515
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.*
16-
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.ParamsMapPutFingerprint
17-
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.PlayerResponseModelImplGeneralFingerprint
18-
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.PlayerResponseModelImplLiveStreamFingerprint
19-
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.PlayerResponseModelImplRecommendedLevelFingerprint
20-
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.ScrubbedPreviewLayoutFingerprint
21-
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.StoryboardRendererDecoderRecommendedLevelFingerprint
22-
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.StoryboardRendererDecoderSpecFingerprint
23-
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.StoryboardRendererSpecFingerprint
24-
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.StoryboardThumbnailFingerprint
25-
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.StoryboardThumbnailParentFingerprint
2616
import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch
2717
import app.revanced.patches.youtube.misc.settings.SettingsPatch
2818
import app.revanced.patches.youtube.video.information.VideoInformationPatch
2919
import app.revanced.patches.youtube.video.playerresponse.PlayerResponseMethodHookPatch
30-
import app.revanced.util.*
20+
import app.revanced.util.exception
3121
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
3222
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
3323
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
@@ -43,6 +33,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
4333
AddResourcesPatch::class,
4434
],
4535
)
36+
@Deprecated("This patch will be removed in the future.")
4637
object SpoofSignaturePatch : BytecodePatch(
4738
setOf(
4839
PlayerResponseModelImplGeneralFingerprint,

src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportPatch.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import app.revanced.patches.youtube.layout.buttons.cast.HideCastButtonPatch
66
import app.revanced.patches.youtube.misc.fix.playback.ClientSpoofPatch
77
import app.revanced.patches.youtube.misc.gms.Constants.REVANCED_YOUTUBE_PACKAGE_NAME
88
import app.revanced.patches.youtube.misc.gms.Constants.YOUTUBE_PACKAGE_NAME
9-
import app.revanced.patches.youtube.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorOption
9+
import app.revanced.patches.youtube.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorGroupIdOption
1010
import app.revanced.patches.youtube.misc.gms.fingerprints.*
1111
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
1212
import app.revanced.patches.youtube.shared.fingerprints.HomeActivityFingerprint
1313

14-
1514
@Suppress("unused")
1615
object GmsCoreSupportPatch : BaseGmsCoreSupportPatch(
1716
fromPackageName = YOUTUBE_PACKAGE_NAME,
@@ -22,18 +21,19 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch(
2221
GooglePlayUtilityFingerprint,
2322
CastDynamiteModuleFingerprint,
2423
CastDynamiteModuleV2Fingerprint,
25-
CastContextFetchFingerprint
24+
CastContextFetchFingerprint,
2625
),
2726
mainActivityOnCreateFingerprint = HomeActivityFingerprint,
2827
integrationsPatchDependency = IntegrationsPatch::class,
2928
dependencies = setOf(
3029
HideCastButtonPatch::class,
31-
ClientSpoofPatch::class
30+
ClientSpoofPatch::class,
3231
),
3332
gmsCoreSupportResourcePatch = GmsCoreSupportResourcePatch,
3433
compatiblePackages = setOf(
3534
CompatiblePackage(
36-
"com.google.android.youtube", setOf(
35+
"com.google.android.youtube",
36+
setOf(
3737
"18.48.39",
3838
"18.49.37",
3939
"19.01.34",
@@ -44,9 +44,9 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch(
4444
"19.06.39",
4545
"19.07.40",
4646
"19.08.36",
47-
"19.09.37"
48-
)
49-
)
47+
"19.09.37",
48+
),
49+
),
5050
),
5151
fingerprints = setOf(
5252
ServiceCheckFingerprint,
@@ -55,7 +55,7 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch(
5555
CastDynamiteModuleV2Fingerprint,
5656
CastContextFetchFingerprint,
5757
PrimeMethodFingerprint,
58-
)
58+
),
5959
) {
60-
override val gmsCoreVendor by gmsCoreVendorOption
60+
override val gmsCoreVendor by gmsCoreVendorGroupIdOption
6161
}

src/main/kotlin/app/revanced/patches/youtube/misc/gms/GmsCoreSupportResourcePatch.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ import app.revanced.patches.youtube.misc.gms.Constants.REVANCED_YOUTUBE_PACKAGE_
88
import app.revanced.patches.youtube.misc.gms.Constants.YOUTUBE_PACKAGE_NAME
99
import app.revanced.patches.youtube.misc.settings.SettingsPatch
1010

11-
1211
object GmsCoreSupportResourcePatch : BaseGmsCoreSupportResourcePatch(
1312
fromPackageName = YOUTUBE_PACKAGE_NAME,
1413
toPackageName = REVANCED_YOUTUBE_PACKAGE_NAME,
1514
spoofedPackageSignature = "24bb24c05e47e0aefa68a58a766179d9b613a600",
16-
dependencies = setOf(SettingsPatch::class, AddResourcesPatch::class)
15+
dependencies = setOf(SettingsPatch::class, AddResourcesPatch::class),
1716
) {
1817
override fun execute(context: ResourceContext) {
1918
AddResourcesPatch(this::class)
@@ -22,9 +21,9 @@ object GmsCoreSupportResourcePatch : BaseGmsCoreSupportResourcePatch(
2221
IntentPreference(
2322
"microg_settings",
2423
intent = IntentPreference.Intent("", "org.microg.gms.ui.SettingsActivity") {
25-
"$gmsCoreVendor.android.gms"
26-
}
27-
)
24+
"$gmsCoreVendorGroupId.android.gms"
25+
},
26+
),
2827
)
2928

3029
super.execute(context)

0 commit comments

Comments
 (0)