feat(YouTube - Vanced MicroG support): Allow changing package name

This commit is contained in:
oSumAtrIX 2023-11-16 20:31:55 +01:00
parent ede2d67b92
commit 0c7490cbaf
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
2 changed files with 18 additions and 5 deletions

View file

@ -4,6 +4,7 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.all.misc.packagename.ChangePackageNamePatch
import app.revanced.patches.shared.fingerprints.WatchWhileActivityFingerprint import app.revanced.patches.shared.fingerprints.WatchWhileActivityFingerprint
import app.revanced.patches.youtube.layout.buttons.cast.HideCastButtonPatch import app.revanced.patches.youtube.layout.buttons.cast.HideCastButtonPatch
import app.revanced.patches.youtube.misc.fix.playback.ClientSpoofPatch import app.revanced.patches.youtube.misc.fix.playback.ClientSpoofPatch
@ -16,6 +17,7 @@ import app.revanced.util.microg.MicroGBytecodeHelper
name = "Vanced MicroG support", name = "Vanced MicroG support",
description = "Allows YouTube to run without root and under a different package name with Vanced MicroG.", description = "Allows YouTube to run without root and under a different package name with Vanced MicroG.",
dependencies = [ dependencies = [
ChangePackageNamePatch::class,
MicroGResourcePatch::class, MicroGResourcePatch::class,
HideCastButtonPatch::class, HideCastButtonPatch::class,
ClientSpoofPatch::class ClientSpoofPatch::class
@ -50,18 +52,20 @@ object MicroGBytecodePatch : BytecodePatch(
) )
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
val packageName = ChangePackageNamePatch.setOrGetFallbackPackageName(REVANCED_PACKAGE_NAME)
// apply common microG patch // apply common microG patch
MicroGBytecodeHelper.patchBytecode( MicroGBytecodeHelper.patchBytecode(
context, arrayOf( context, arrayOf(
MicroGBytecodeHelper.packageNameTransform( MicroGBytecodeHelper.packageNameTransform(
PACKAGE_NAME, PACKAGE_NAME,
REVANCED_PACKAGE_NAME packageName
) )
), ),
MicroGBytecodeHelper.PrimeMethodTransformationData( MicroGBytecodeHelper.PrimeMethodTransformationData(
PrimeFingerprint, PrimeFingerprint,
PACKAGE_NAME, PACKAGE_NAME,
REVANCED_PACKAGE_NAME packageName
), ),
listOf( listOf(
ServiceCheckFingerprint, ServiceCheckFingerprint,

View file

@ -3,6 +3,7 @@ package app.revanced.patches.youtube.misc.microg
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.all.misc.packagename.ChangePackageNamePatch
import app.revanced.patches.shared.settings.preference.impl.Preference import app.revanced.patches.shared.settings.preference.impl.Preference
import app.revanced.patches.shared.settings.preference.impl.StringResource import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.youtube.misc.microg.shared.Constants.PACKAGE_NAME import app.revanced.patches.youtube.misc.microg.shared.Constants.PACKAGE_NAME
@ -15,7 +16,12 @@ import app.revanced.util.microg.Constants.MICROG_VENDOR
import app.revanced.util.microg.MicroGManifestHelper import app.revanced.util.microg.MicroGManifestHelper
import app.revanced.util.microg.MicroGResourceHelper import app.revanced.util.microg.MicroGResourceHelper
@Patch(dependencies = [SettingsPatch::class]) @Patch(
dependencies = [
SettingsPatch::class,
ChangePackageNamePatch::class
]
)
object MicroGResourcePatch : ResourcePatch() { object MicroGResourcePatch : ResourcePatch() {
override fun execute(context: ResourceContext) { override fun execute(context: ResourceContext) {
SettingsPatch.addPreference( SettingsPatch.addPreference(
@ -25,13 +31,16 @@ object MicroGResourcePatch : ResourcePatch() {
Preference.Intent("$MICROG_VENDOR.android.gms", "", "org.microg.gms.ui.SettingsActivity") Preference.Intent("$MICROG_VENDOR.android.gms", "", "org.microg.gms.ui.SettingsActivity")
) )
) )
SettingsPatch.renameIntentsTargetPackage(REVANCED_PACKAGE_NAME)
val packageName = ChangePackageNamePatch.setOrGetFallbackPackageName(REVANCED_PACKAGE_NAME)
SettingsPatch.renameIntentsTargetPackage(packageName)
// update manifest // update manifest
MicroGResourceHelper.patchManifest( MicroGResourceHelper.patchManifest(
context, context,
PACKAGE_NAME, PACKAGE_NAME,
REVANCED_PACKAGE_NAME, packageName,
REVANCED_APP_NAME REVANCED_APP_NAME
) )