AAPT support for feature splits

This change allows the developer to add a base package for
which to build a feature split. The generated resource types
will begin after the base APK's defined types so as not
to collide or override resources.

Multiple features can be generated by first choosing an
arbitrary order for the features. Then for each feature,
the base APK and any preceding features are specified
with the --feature-of flags.

So with a base APK 'A' and features, 'B', and 'C',
'B' would be built with

aapt package [...] --feature-of A [...]

and 'C' would be built with

aapt package [...] --feature-of A --feature-of B [...]

Change-Id: I1be66e3f8df9a737b21c71f8a93685376c7e6780
diff --git a/tools/aapt/ResourceTable.h b/tools/aapt/ResourceTable.h
index a73993c..d4f47ef 100644
--- a/tools/aapt/ResourceTable.h
+++ b/tools/aapt/ResourceTable.h
@@ -74,11 +74,23 @@
 class ResourceTable : public ResTable::Accessor
 {
 public:
+    // The type of package to build.
+    enum PackageType {
+        App,
+        System,
+        SharedLibrary,
+        AppFeature
+    };
+
     class Package;
     class Type;
     class Entry;
 
-    ResourceTable(Bundle* bundle, const String16& assetsPackage);
+    ResourceTable(Bundle* bundle, const String16& assetsPackage, PackageType type);
+
+    const String16& getAssetsPackage() const {
+        return mAssetsPackage;
+    }
 
     status_t addIncludedResources(Bundle* bundle, const sp<AaptAssets>& assets);
 
@@ -448,7 +460,7 @@
 
     class Package : public RefBase {
     public:
-        Package(const String16& name, ssize_t includedId=-1);
+        Package(const String16& name, size_t packageId);
         virtual ~Package() { }
 
         String16 getName() const { return mName; }
@@ -456,7 +468,7 @@
                          const SourcePos& pos,
                          bool doSetIndex = false);
 
-        ssize_t getAssignedId() const { return mIncludedId; }
+        size_t getAssignedId() const { return mPackageId; }
 
         const ResStringPool& getTypeStrings() const { return mTypeStrings; }
         uint32_t indexOfTypeString(const String16& s) const { return mTypeStringsMapping.valueFor(s); }
@@ -479,7 +491,7 @@
                             DefaultKeyedVector<String16, uint32_t>* mappings);
 
         const String16 mName;
-        const ssize_t mIncludedId;
+        const size_t mPackageId;
         DefaultKeyedVector<String16, sp<Type> > mTypes;
         Vector<sp<Type> > mOrderedTypes;
         sp<AaptFile> mTypeStringsData;
@@ -512,13 +524,11 @@
 
 
     String16 mAssetsPackage;
+    PackageType mPackageType;
     sp<AaptAssets> mAssets;
+    uint32_t mTypeIdOffset;
     DefaultKeyedVector<String16, sp<Package> > mPackages;
     Vector<sp<Package> > mOrderedPackages;
-    uint32_t mNextPackageId;
-    bool mHaveAppPackage;
-    bool mIsAppPackage;
-    bool mIsSharedLibrary;
     size_t mNumLocal;
     SourcePos mCurrentXmlPos;
     Bundle* mBundle;