mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-27 12:15:50 +01:00
fix(Change package name): Prevent applying the patch to known incompatible apps (#3943)
This commit is contained in:
parent
fbc6ab6a35
commit
44936e71e8
@ -4,6 +4,7 @@ import app.revanced.patcher.patch.Option
|
|||||||
import app.revanced.patcher.patch.resourcePatch
|
import app.revanced.patcher.patch.resourcePatch
|
||||||
import app.revanced.patcher.patch.stringOption
|
import app.revanced.patcher.patch.stringOption
|
||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
|
import java.util.logging.Logger
|
||||||
|
|
||||||
lateinit var packageNameOption: Option<String>
|
lateinit var packageNameOption: Option<String>
|
||||||
|
|
||||||
@ -41,18 +42,38 @@ val changePackageNamePatch = resourcePatch(
|
|||||||
it == "Default" || it!!.matches(Regex("^[a-z]\\w*(\\.[a-z]\\w*)+\$"))
|
it == "Default" || it!!.matches(Regex("^[a-z]\\w*(\\.[a-z]\\w*)+\$"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apps that are confirmed to not work correctly with this patch.
|
||||||
|
* This is not an exhaustive list, and is only the apps with
|
||||||
|
* ReVanced specific patches and are confirmed incompatible with this patch.
|
||||||
|
*/
|
||||||
|
val incompatibleAppPackages = setOf(
|
||||||
|
// Cannot login, settings menu is broken.
|
||||||
|
"com.reddit.frontpage",
|
||||||
|
|
||||||
|
// Patches and installs but crashes on launch.
|
||||||
|
"com.duolingo",
|
||||||
|
"com.twitter.android",
|
||||||
|
"tv.twitch.android.app",
|
||||||
|
)
|
||||||
|
|
||||||
finalize {
|
finalize {
|
||||||
document("AndroidManifest.xml").use { document ->
|
document("AndroidManifest.xml").use { document ->
|
||||||
|
val manifest = document.getElementsByTagName("manifest").item(0) as Element
|
||||||
|
val originalPackageName = manifest.getAttribute("package")
|
||||||
|
|
||||||
|
if (incompatibleAppPackages.contains(originalPackageName)) {
|
||||||
|
return@finalize Logger.getLogger(this::class.java.name).severe(
|
||||||
|
"'$originalPackageName' does not work correctly with \"Change package name\"")
|
||||||
|
}
|
||||||
|
|
||||||
val replacementPackageName = packageNameOption.value
|
val replacementPackageName = packageNameOption.value
|
||||||
|
|
||||||
val manifest = document.getElementsByTagName("manifest").item(0) as Element
|
|
||||||
manifest.setAttribute(
|
manifest.setAttribute(
|
||||||
"package",
|
"package",
|
||||||
if (replacementPackageName != packageNameOption.default) {
|
if (replacementPackageName != packageNameOption.default) {
|
||||||
replacementPackageName
|
replacementPackageName
|
||||||
} else {
|
} else {
|
||||||
"${manifest.getAttribute("package")}.revanced"
|
"${originalPackageName}.revanced"
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user