fix(GmsCore support): Rename MicroG GmsCore specific strings as well and rename app specific strings correctly

This commit is contained in:
oSumAtrIX 2026-02-16 02:08:19 +01:00
parent 450454019d
commit c2ac1f04a0
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4

View file

@ -88,7 +88,8 @@ fun gmsCoreSupportPatch(
}
implementation.instructions.forEachIndexed insnLoop@{ index, instruction ->
val string = ((instruction as? Instruction21c)?.reference as? StringReference)?.string
val string =
((instruction as? Instruction21c)?.reference as? StringReference)?.string
?: return@insnLoop
// Apply transformation.
@ -232,35 +233,39 @@ fun gmsCoreSupportResourcePatch(
execute {
addResources("shared", "misc.gms.gmsCoreSupportResourcePatch")
val toPackageName = setOrGetFallbackPackageName(toPackageName)
document("AndroidManifest.xml").use { document ->
document.getElementsByTagName("permission").asSequence().forEach { node ->
val nameElement = node.attributes.getNamedItem("android:name")
nameElement.textContent = toPackageName + nameElement.textContent
node.attributes.getNamedItem("android:name").apply {
APP_PERMISSIONS += textContent
textContent = "$toPackageName.$textContent"
}
}
document.getElementsByTagName("uses-permission").asSequence().forEach { node ->
val nameElement = node.attributes.getNamedItem("android:name")
if (nameElement.textContent in GMS_PERMISSIONS) {
nameElement.textContent.replace("com.google", gmsCoreVendorGroupId)
node.attributes.getNamedItem("android:name").apply {
if (textContent in GMS_PERMISSIONS) {
textContent.replace("com.google", gmsCoreVendorGroupId)
} else if (textContent in APP_PERMISSIONS) {
textContent = "$toPackageName.$textContent"
}
}
}
document.getElementsByTagName("provider").asSequence().forEach { node ->
val providerElement = node.attributes.getNamedItem("android:authorities")
providerElement.textContent = providerElement.textContent.split(";")
node.attributes.getNamedItem("android:authorities").apply {
textContent = textContent.split(";")
.joinToString(";") { authority ->
if (authority.startsWith("com.google")) {
authority.replace("com.google", gmsCoreVendorGroupId)
} else {
"$gmsCoreVendorGroupId.$authority"
APP_AUTHORITIES += authority
"$toPackageName.$authority"
}
}
}
document.getNode("manifest")
.attributes.getNamedItem("package").textContent =
setOrGetFallbackPackageName(toPackageName)
.attributes.getNamedItem("package").textContent = toPackageName
document.getNode("queries").appendChild(
document.createElement("package").apply {
@ -336,7 +341,7 @@ private object Constants {
)
val GMS_AUTHORITIES = setOf(
"google.android.gms.fileprovider",
"com.google.android.gms.fileprovider",
"com.google.android.gms.auth.accounts",
"com.google.android.gms.chimera",
"com.google.android.gms.fonts",
@ -346,7 +351,11 @@ private object Constants {
"subscribedfeeds",
)
val APP_PERMISSIONS = mutableSetOf<String>()
val APP_PERMISSIONS = mutableSetOf(
"org.microg.gms.STATUS_BROADCAST",
"org.microg.gms.EXTENDED_ACCESS",
"org.microg.gms.PROVISION"
)
val APP_AUTHORITIES = mutableSetOf<String>()
}