Move StringPool to libandroidfw
Test: verified affected tests pass
Bug: 232940948
Change-Id: I22089893d7e5013f759c39ce190bec07fa6435db
diff --git a/tools/aapt2/io/BigBufferStream.h b/tools/aapt2/io/BigBufferStream.h
index 8b5c8b8..63a5e57 100644
--- a/tools/aapt2/io/BigBufferStream.h
+++ b/tools/aapt2/io/BigBufferStream.h
@@ -17,15 +17,15 @@
#ifndef AAPT_IO_BIGBUFFERSTREAM_H
#define AAPT_IO_BIGBUFFERSTREAM_H
+#include "androidfw/BigBuffer.h"
#include "io/Io.h"
-#include "util/BigBuffer.h"
namespace aapt {
namespace io {
class BigBufferInputStream : public KnownSizeInputStream {
public:
- inline explicit BigBufferInputStream(const BigBuffer* buffer)
+ inline explicit BigBufferInputStream(const android::BigBuffer* buffer)
: buffer_(buffer), iter_(buffer->begin()) {
}
virtual ~BigBufferInputStream() = default;
@@ -47,15 +47,15 @@
private:
DISALLOW_COPY_AND_ASSIGN(BigBufferInputStream);
- const BigBuffer* buffer_;
- BigBuffer::const_iterator iter_;
+ const android::BigBuffer* buffer_;
+ android::BigBuffer::const_iterator iter_;
size_t offset_ = 0;
size_t bytes_read_ = 0;
};
class BigBufferOutputStream : public OutputStream {
public:
- inline explicit BigBufferOutputStream(BigBuffer* buffer) : buffer_(buffer) {
+ inline explicit BigBufferOutputStream(android::BigBuffer* buffer) : buffer_(buffer) {
}
virtual ~BigBufferOutputStream() = default;
@@ -70,7 +70,7 @@
private:
DISALLOW_COPY_AND_ASSIGN(BigBufferOutputStream);
- BigBuffer* buffer_;
+ android::BigBuffer* buffer_;
};
} // namespace io
diff --git a/tools/aapt2/io/File.h b/tools/aapt2/io/File.h
index 565aad6..422658a 100644
--- a/tools/aapt2/io/File.h
+++ b/tools/aapt2/io/File.h
@@ -22,8 +22,7 @@
#include <vector>
#include "android-base/macros.h"
-
-#include "Source.h"
+#include "androidfw/Source.h"
#include "io/Data.h"
#include "util/Files.h"
#include "util/Util.h"
@@ -49,7 +48,7 @@
// Returns the source of this file. This is for presentation to the user and
// may not be a valid file system path (for example, it may contain a '@' sign to separate
// the files within a ZIP archive from the path to the containing ZIP archive.
- virtual const Source& GetSource() const = 0;
+ virtual const android::Source& GetSource() const = 0;
IFile* CreateFileSegment(size_t offset, size_t len);
@@ -76,7 +75,7 @@
std::unique_ptr<IData> OpenAsData() override;
std::unique_ptr<io::InputStream> OpenInputStream() override;
- const Source& GetSource() const override {
+ const android::Source& GetSource() const override {
return file_->GetSource();
}
diff --git a/tools/aapt2/io/FileSystem.cpp b/tools/aapt2/io/FileSystem.cpp
index fc2e45e..3f071af 100644
--- a/tools/aapt2/io/FileSystem.cpp
+++ b/tools/aapt2/io/FileSystem.cpp
@@ -19,13 +19,12 @@
#include <dirent.h>
#include "android-base/errors.h"
+#include "androidfw/Source.h"
#include "androidfw/StringPiece.h"
-#include "utils/FileMap.h"
-#include "Source.h"
#include "io/FileStream.h"
#include "util/Files.h"
-
#include "util/Util.h"
+#include "utils/FileMap.h"
using ::android::StringPiece;
using ::android::base::SystemErrorCodeToString;
@@ -33,7 +32,8 @@
namespace aapt {
namespace io {
-RegularFile::RegularFile(const Source& source) : source_(source) {}
+RegularFile::RegularFile(const android::Source& source) : source_(source) {
+}
std::unique_ptr<IData> RegularFile::OpenAsData() {
android::FileMap map;
@@ -50,7 +50,7 @@
return util::make_unique<FileInputStream>(source_.path);
}
-const Source& RegularFile::GetSource() const {
+const android::Source& RegularFile::GetSource() const {
return source_;
}
@@ -118,7 +118,7 @@
}
IFile* FileCollection::InsertFile(const StringPiece& path) {
- return (files_[path.to_string()] = util::make_unique<RegularFile>(Source(path))).get();
+ return (files_[path.to_string()] = util::make_unique<RegularFile>(android::Source(path))).get();
}
IFile* FileCollection::FindFile(const StringPiece& path) {
diff --git a/tools/aapt2/io/FileSystem.h b/tools/aapt2/io/FileSystem.h
index 04c6fa1..bc03b9b 100644
--- a/tools/aapt2/io/FileSystem.h
+++ b/tools/aapt2/io/FileSystem.h
@@ -27,16 +27,16 @@
// A regular file from the file system. Uses mmap to open the data.
class RegularFile : public IFile {
public:
- explicit RegularFile(const Source& source);
+ explicit RegularFile(const android::Source& source);
std::unique_ptr<IData> OpenAsData() override;
std::unique_ptr<io::InputStream> OpenInputStream() override;
- const Source& GetSource() const override;
+ const android::Source& GetSource() const override;
private:
DISALLOW_COPY_AND_ASSIGN(RegularFile);
- Source source_;
+ android::Source source_;
};
class FileCollection;
diff --git a/tools/aapt2/io/Util.cpp b/tools/aapt2/io/Util.cpp
index bb925c9..afe54d4 100644
--- a/tools/aapt2/io/Util.cpp
+++ b/tools/aapt2/io/Util.cpp
@@ -30,12 +30,14 @@
uint32_t compression_flags, IArchiveWriter* writer) {
TRACE_CALL();
if (context->IsVerbose()) {
- context->GetDiagnostics()->Note(DiagMessage() << "writing " << out_path << " to archive");
+ context->GetDiagnostics()->Note(android::DiagMessage()
+ << "writing " << out_path << " to archive");
}
if (!writer->WriteFile(out_path, compression_flags, in)) {
- context->GetDiagnostics()->Error(DiagMessage() << "failed to write " << out_path
- << " to archive: " << writer->GetError());
+ context->GetDiagnostics()->Error(android::DiagMessage()
+ << "failed to write " << out_path
+ << " to archive: " << writer->GetError());
return false;
}
return true;
@@ -46,7 +48,8 @@
TRACE_CALL();
std::unique_ptr<io::IData> data = file->OpenAsData();
if (!data) {
- context->GetDiagnostics()->Error(DiagMessage(file->GetSource()) << "failed to open file");
+ context->GetDiagnostics()->Error(android::DiagMessage(file->GetSource())
+ << "failed to open file");
return false;
}
return CopyInputStreamToArchive(context, data.get(), out_path, compression_flags, writer);
@@ -63,7 +66,8 @@
IArchiveWriter* writer) {
TRACE_CALL();
if (context->IsVerbose()) {
- context->GetDiagnostics()->Note(DiagMessage() << "writing " << out_path << " to archive");
+ context->GetDiagnostics()->Note(android::DiagMessage()
+ << "writing " << out_path << " to archive");
}
if (writer->StartEntry(out_path, compression_flags)) {
@@ -72,8 +76,8 @@
// Wrap our IArchiveWriter with an adaptor that implements the ZeroCopyOutputStream interface.
::google::protobuf::io::CopyingOutputStreamAdaptor adaptor(writer);
if (!proto_msg->SerializeToZeroCopyStream(&adaptor)) {
- context->GetDiagnostics()->Error(DiagMessage() << "failed to write " << out_path
- << " to archive");
+ context->GetDiagnostics()->Error(android::DiagMessage()
+ << "failed to write " << out_path << " to archive");
return false;
}
}
@@ -82,8 +86,8 @@
return true;
}
}
- context->GetDiagnostics()->Error(DiagMessage() << "failed to write " << out_path
- << " to archive: " << writer->GetError());
+ context->GetDiagnostics()->Error(android::DiagMessage() << "failed to write " << out_path
+ << " to archive: " << writer->GetError());
return false;
}
diff --git a/tools/aapt2/io/ZipArchive.cpp b/tools/aapt2/io/ZipArchive.cpp
index 4380586..400269c 100644
--- a/tools/aapt2/io/ZipArchive.cpp
+++ b/tools/aapt2/io/ZipArchive.cpp
@@ -16,22 +16,21 @@
#include "io/ZipArchive.h"
-#include "utils/FileMap.h"
-#include "ziparchive/zip_archive.h"
-
-#include "Source.h"
+#include "androidfw/Source.h"
#include "trace/TraceBuffer.h"
#include "util/Files.h"
#include "util/Util.h"
+#include "utils/FileMap.h"
+#include "ziparchive/zip_archive.h"
using ::android::StringPiece;
namespace aapt {
namespace io {
-ZipFile::ZipFile(ZipArchiveHandle handle, const ZipEntry& entry,
- const Source& source)
- : zip_handle_(handle), zip_entry_(entry), source_(source) {}
+ZipFile::ZipFile(ZipArchiveHandle handle, const ZipEntry& entry, const android::Source& source)
+ : zip_handle_(handle), zip_entry_(entry), source_(source) {
+}
std::unique_ptr<IData> ZipFile::OpenAsData() {
// The file will fail to be mmaped if it is empty
@@ -68,7 +67,7 @@
return OpenAsData();
}
-const Source& ZipFile::GetSource() const {
+const android::Source& ZipFile::GetSource() const {
return source_;
}
@@ -131,8 +130,8 @@
continue;
}
- std::unique_ptr<IFile> file = util::make_unique<ZipFile>(collection->handle_, zip_data,
- Source(zip_entry_path, path.to_string()));
+ std::unique_ptr<IFile> file = util::make_unique<ZipFile>(
+ collection->handle_, zip_data, android::Source(zip_entry_path, path.to_string()));
collection->files_by_name_[zip_entry_path] = file.get();
collection->files_.push_back(std::move(file));
}
diff --git a/tools/aapt2/io/ZipArchive.h b/tools/aapt2/io/ZipArchive.h
index b283e57..78c9c21 100644
--- a/tools/aapt2/io/ZipArchive.h
+++ b/tools/aapt2/io/ZipArchive.h
@@ -32,17 +32,17 @@
// and copied into memory when opened. Otherwise it is mmapped from the ZIP archive.
class ZipFile : public IFile {
public:
- ZipFile(::ZipArchiveHandle handle, const ::ZipEntry& entry, const Source& source);
+ ZipFile(::ZipArchiveHandle handle, const ::ZipEntry& entry, const android::Source& source);
std::unique_ptr<IData> OpenAsData() override;
std::unique_ptr<io::InputStream> OpenInputStream() override;
- const Source& GetSource() const override;
+ const android::Source& GetSource() const override;
bool WasCompressed() override;
private:
::ZipArchiveHandle zip_handle_;
::ZipEntry zip_entry_;
- Source source_;
+ android::Source source_;
};
class ZipFileCollection;