AAPT2: Sort artifacts based on the Play Store rules.

Sort output artifacts so that the updated versionCode manifest entry
will allow correct handling of updates from Play Store. The most
important dimension is Android SDK version. It is important that a split
based on min SDK version will allow a user to get a new APK if they
upgrade the OS on their device to support a new split.

ABI splits need to also be taken into consideration as it is possible
for a device to run in ARM emulation mode and installing an ARM APK over
a x86 APK could cause performance regressions.

The XML file format was updated to give each of the configuration groups
have their own section of the XML file. This allows the sort order to be
determined by a groups ordering. Artifacts can now be added to the
configuration file in an arbitrary order. Since this will be the common
case for developers, it will help reduce errors from inserting a new
artifact in the wrong spot.

The implementation follows the rules outlined at:
https://developer.android.com/google/play/publishing/multiple-apks.html

Test: Unit tests
Test: Manual process XML configuration

Change-Id: I0face862c6d6b9d3cd2d99088afe5b9491be0120
9 files changed