AAPT2: Split APK by ABI.

Added a FilterChain that can apply multiple filter steps to an APK file
as it is being written to disk. The first filter applied is by ABI. If
a library in the APK does not match the filter it is skipped.

Added an AbiFilter that keeps files that are either not native libs or
are for the set of wanted ABIs

Test: ran unit tests locally
Test: ran against an APK with ARM and x68 libs and diffed the results

Change-Id: I3fb901d3de3513e85f2a2763a8e4487a28ed4881
diff --git a/tools/aapt2/LoadedApk.h b/tools/aapt2/LoadedApk.h
index 59eb816..8aa9674 100644
--- a/tools/aapt2/LoadedApk.h
+++ b/tools/aapt2/LoadedApk.h
@@ -20,6 +20,7 @@
 #include "androidfw/StringPiece.h"
 
 #include "ResourceTable.h"
+#include "filter/Filter.h"
 #include "flatten/Archive.h"
 #include "flatten/TableFlattener.h"
 #include "io/ZipArchive.h"
@@ -49,6 +50,14 @@
   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);
+
   static std::unique_ptr<LoadedApk> LoadApkFromPath(IAaptContext* context,
                                                     const android::StringPiece& path);