Add a method LoadedApk::WriteToArchive.

Test: Manually.

Change-Id: I61717204e58ca2bbfba9a52c7aecf27882a853f8
diff --git a/tools/aapt2/LoadedApk.h b/tools/aapt2/LoadedApk.h
index 0cc2d22..f8878d1 100644
--- a/tools/aapt2/LoadedApk.h
+++ b/tools/aapt2/LoadedApk.h
@@ -19,12 +19,11 @@
 
 #include "androidfw/StringPiece.h"
 
-#include "io/ZipArchive.h"
 #include "ResourceTable.h"
+#include "flatten/Archive.h"
+#include "io/ZipArchive.h"
 #include "unflatten/BinaryResourceParser.h"
 
-using android::StringPiece;
-
 namespace aapt {
 
 /** Info about an APK loaded in memory. */
@@ -42,8 +41,14 @@
 
   const Source& GetSource() { return source_; }
 
-  static std::unique_ptr<LoadedApk> LoadApkFromPath(
-      IAaptContext* context, const StringPiece& path);
+  /**
+   * 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, IArchiveWriter* writer);
+
+  static std::unique_ptr<LoadedApk> LoadApkFromPath(IAaptContext* context,
+                                                    const android::StringPiece& path);
 
  private:
   Source source_;