AAPT2: Add a APK filtering.

Allow resource files to be removed from the final artifact based on the
density and locale configuration in the config file. The APK is split
along the density, locale and ABI axis. Each split is generated from the
original APK without modifying the original. The new resource table is
written back to the file system with unneeded assets etc removed.

Test: Unit tests
Test: Manually run optimize command against an APK and inspect results
Test: Installed split searchlite APK (after resigning) and ran on N6

Change-Id: If73597dcfd88c02d2616518585d0e25a5c6a84d1
diff --git a/tools/aapt2/LoadedApk.h b/tools/aapt2/LoadedApk.h
index 8aa9674..dacd0c2 100644
--- a/tools/aapt2/LoadedApk.h
+++ b/tools/aapt2/LoadedApk.h
@@ -47,16 +47,17 @@
    * Writes the APK on disk at the given path, while also removing the resource
    * files that are not referenced in the resource table.
    */
-  bool WriteToArchive(IAaptContext* context, const TableFlattenerOptions& options,
-                      IArchiveWriter* writer);
+  virtual bool WriteToArchive(IAaptContext* context, const TableFlattenerOptions& options,
+                              IArchiveWriter* writer);
 
   /**
    * Writes the APK on disk at the given path, while also removing the resource
    * files that are not referenced in the resource table. The provided filter
    * chain is applied to each entry in the APK file.
    */
-  bool WriteToArchive(IAaptContext* context, const TableFlattenerOptions& options,
-                      FilterChain* filters, IArchiveWriter* writer);
+  virtual bool WriteToArchive(IAaptContext* context, ResourceTable* split_table,
+                              const TableFlattenerOptions& options, FilterChain* filters,
+                              IArchiveWriter* writer);
 
   static std::unique_ptr<LoadedApk> LoadApkFromPath(IAaptContext* context,
                                                     const android::StringPiece& path);