Skip to content

Commit 44936e7

Browse files
fix(Change package name): Prevent applying the patch to known incompatible apps (ReVanced#3943)
1 parent fbc6ab6 commit 44936e7

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

patches/src/main/kotlin/app/revanced/patches/all/misc/packagename/ChangePackageNamePatch.kt

+24-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import app.revanced.patcher.patch.Option
44
import app.revanced.patcher.patch.resourcePatch
55
import app.revanced.patcher.patch.stringOption
66
import org.w3c.dom.Element
7+
import java.util.logging.Logger
78

89
lateinit var packageNameOption: Option<String>
910

@@ -41,18 +42,38 @@ val changePackageNamePatch = resourcePatch(
4142
it == "Default" || it!!.matches(Regex("^[a-z]\\w*(\\.[a-z]\\w*)+\$"))
4243
}
4344

45+
/**
46+
* Apps that are confirmed to not work correctly with this patch.
47+
* This is not an exhaustive list, and is only the apps with
48+
* ReVanced specific patches and are confirmed incompatible with this patch.
49+
*/
50+
val incompatibleAppPackages = setOf(
51+
// Cannot login, settings menu is broken.
52+
"com.reddit.frontpage",
53+
54+
// Patches and installs but crashes on launch.
55+
"com.duolingo",
56+
"com.twitter.android",
57+
"tv.twitch.android.app",
58+
)
59+
4460
finalize {
4561
document("AndroidManifest.xml").use { document ->
62+
val manifest = document.getElementsByTagName("manifest").item(0) as Element
63+
val originalPackageName = manifest.getAttribute("package")
4664

47-
val replacementPackageName = packageNameOption.value
65+
if (incompatibleAppPackages.contains(originalPackageName)) {
66+
return@finalize Logger.getLogger(this::class.java.name).severe(
67+
"'$originalPackageName' does not work correctly with \"Change package name\"")
68+
}
4869

49-
val manifest = document.getElementsByTagName("manifest").item(0) as Element
70+
val replacementPackageName = packageNameOption.value
5071
manifest.setAttribute(
5172
"package",
5273
if (replacementPackageName != packageNameOption.default) {
5374
replacementPackageName
5475
} else {
55-
"${manifest.getAttribute("package")}.revanced"
76+
"${originalPackageName}.revanced"
5677
},
5778
)
5879
}

0 commit comments

Comments
 (0)