Skip to content

Commit

Permalink
feat(YouTube - Vanced MicroG support): Allow changing package name
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Nov 16, 2023
1 parent ede2d67 commit 0c7490c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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
)

Expand Down

0 comments on commit 0c7490c

Please sign in to comment.