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

View File

@ -3,6 +3,7 @@ package app.revanced.patches.youtube.misc.microg
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
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.StringResource
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.MicroGResourceHelper
@Patch(dependencies = [SettingsPatch::class])
@Patch(
dependencies = [
SettingsPatch::class,
ChangePackageNamePatch::class
]
)
object MicroGResourcePatch : ResourcePatch() {
override fun execute(context: ResourceContext) {
SettingsPatch.addPreference(
@ -25,13 +31,16 @@ object MicroGResourcePatch : ResourcePatch() {
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
MicroGResourceHelper.patchManifest(
context,
PACKAGE_NAME,
REVANCED_PACKAGE_NAME,
packageName,
REVANCED_APP_NAME
)