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