Bug 1320310 - Post-process Gradle-produced Android manifest. r=sebastian

Layer on the hacks!  This:

1) Reinstates the <activity-alias android:name=".App"> that we have in
   the moz.build produced Android manifest.  I found no way to do this
   using placeholders or the manifest merger.

2) Culls manifest entries provided by
   com.google.android.gms.measurement.  We know they're not necessary,
   since they're not present in the existing Fennec Android manifest.

These are strictly workarounds to avoid doing the real work of fixing
the issues.  To fix 1), we'd need to migrate all existing users with
homescreen shortcuts to .App.  This could be difficult, especially if
partners have deployed packages out of our update control.  To fix 2),
we'll need to upgrade our Google Play Services to at least version
9.0.0 and then use the finer-grained AAR dependencies to not build
with the measurement split at all.

MozReview-Commit-ID: 21CaZ2KMeIa

--HG--
extra : rebase_source : c9aff7c414c13843c4e54267c95941fa35bc1001
This commit is contained in:
Nick Alexander 2017-04-11 20:49:05 -07:00
Родитель 046d04f0c2
Коммит 84711dd47a
1 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -452,3 +452,37 @@ android.applicationVariants.all { variant ->
// Bug 1353055 - Strip 'vars' debugging information to agree with moz.build.
apply from: "${topsrcdir}/mobile/android/gradle/debug_level.gradle"
android.applicationVariants.all configureVariantDebugLevel
// Bug 1320310 - Hack up the manifest produced by Gradle to match that produced
// by moz.build.
import groovy.xml.XmlUtil
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
output.processManifest.doLast {
[output.processManifest.manifestOutputFile,
output.processManifest.instantRunManifestOutputFile,
].each({ File manifestOutFile ->
if (manifestOutFile.exists()) {
def contents = manifestOutFile.getText('UTF-8')
// A non-validating, non-namespace aware XML processor.
def xml = new XmlSlurper(false, false).parseText(contents)
// First, reinstate our <activity-alias android:name=".App">.
xml.depthFirst()
.findAll { it.name() == 'activity-alias' && it.'@android:name' == 'org.mozilla.gecko.App' }
.each { it.'@android:name' = '.App' }
// Second, cull all manifest entries provided by com.google.android.gms.measurement.
xml.depthFirst()
.findAll { it.'@android:name'.text().contains('AppMeasurement') }
.each { it.replaceNode {} }
manifestOutFile.write(XmlUtil.serialize(xml), 'UTF-8')
}
})
}
}
}