diff --git a/libs/androidfw/Android.bp b/libs/androidfw/Android.bp
index 8a379d5..779c4b7 100644
--- a/libs/androidfw/Android.bp
+++ b/libs/androidfw/Android.bp
@@ -61,6 +61,7 @@
         "AssetManager2.cpp",
         "AssetsProvider.cpp",
         "AttributeResolution.cpp",
+        "BigBuffer.cpp",
         "ChunkIterator.cpp",
         "ConfigDescription.cpp",
         "Idmap.cpp",
@@ -73,6 +74,7 @@
         "ResourceTypes.cpp",
         "ResourceUtils.cpp",
         "StreamingZipInflater.cpp",
+        "StringPool.cpp",
         "TypeWrappers.cpp",
         "Util.cpp",
         "ZipFileRO.cpp",
@@ -162,6 +164,7 @@
         "tests/AssetManager2_test.cpp",
         "tests/AttributeFinder_test.cpp",
         "tests/AttributeResolution_test.cpp",
+        "tests/BigBuffer_test.cpp",
         "tests/ByteBucketArray_test.cpp",
         "tests/Config_test.cpp",
         "tests/ConfigDescription_test.cpp",
@@ -174,6 +177,7 @@
         "tests/ResTable_test.cpp",
         "tests/Split_test.cpp",
         "tests/StringPiece_test.cpp",
+        "tests/StringPool_test.cpp",
         "tests/Theme_test.cpp",
         "tests/TypeWrappers_test.cpp",
         "tests/ZipUtils_test.cpp",
diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp
index 136fc6c..39c7d19 100644
--- a/libs/androidfw/AssetManager2.cpp
+++ b/libs/androidfw/AssetManager2.cpp
@@ -601,6 +601,10 @@
     return base::unexpected(result.error());
   }
 
+  if (type_idx == 0x1c) {
+    LOG(ERROR) << base::StringPrintf("foobar first result %s", result->package_name->c_str());
+  }
+
   bool overlaid = false;
   if (!stop_at_first_match && !ignore_configuration && !apk_assets_[result->cookie]->IsLoader()) {
     for (const auto& id_map : package_group.overlays_) {
diff --git a/libs/androidfw/BigBuffer.cpp b/libs/androidfw/BigBuffer.cpp
new file mode 100644
index 0000000..bedfc49
--- /dev/null
+++ b/libs/androidfw/BigBuffer.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <androidfw/BigBuffer.h>
+
+#include <algorithm>
+#include <memory>
+#include <vector>
+
+#include "android-base/logging.h"
+
+namespace android {
+
+void* BigBuffer::NextBlockImpl(size_t size) {
+  if (!blocks_.empty()) {
+    Block& block = blocks_.back();
+    if (block.block_size_ - block.size >= size) {
+      void* out_buffer = block.buffer.get() + block.size;
+      block.size += size;
+      size_ += size;
+      return out_buffer;
+    }
+  }
+
+  const size_t actual_size = std::max(block_size_, size);
+
+  Block block = {};
+
+  // Zero-allocate the block's buffer.
+  block.buffer = std::unique_ptr<uint8_t[]>(new uint8_t[actual_size]());
+  CHECK(block.buffer);
+
+  block.size = size;
+  block.block_size_ = actual_size;
+
+  blocks_.push_back(std::move(block));
+  size_ += size;
+  return blocks_.back().buffer.get();
+}
+
+void* BigBuffer::NextBlock(size_t* out_size) {
+  if (!blocks_.empty()) {
+    Block& block = blocks_.back();
+    if (block.size != block.block_size_) {
+      void* out_buffer = block.buffer.get() + block.size;
+      size_t size = block.block_size_ - block.size;
+      block.size = block.block_size_;
+      size_ += size;
+      *out_size = size;
+      return out_buffer;
+    }
+  }
+
+  // Zero-allocate the block's buffer.
+  Block block = {};
+  block.buffer = std::unique_ptr<uint8_t[]>(new uint8_t[block_size_]());
+  CHECK(block.buffer);
+  block.size = block_size_;
+  block.block_size_ = block_size_;
+  blocks_.push_back(std::move(block));
+  size_ += block_size_;
+  *out_size = block_size_;
+  return blocks_.back().buffer.get();
+}
+
+std::string BigBuffer::to_string() const {
+  std::string result;
+  for (const Block& block : blocks_) {
+    result.append(block.buffer.get(), block.buffer.get() + block.size);
+  }
+  return result;
+}
+
+}  // namespace android
diff --git a/libs/androidfw/StringPool.cpp b/libs/androidfw/StringPool.cpp
new file mode 100644
index 0000000..b59e906
--- /dev/null
+++ b/libs/androidfw/StringPool.cpp
@@ -0,0 +1,508 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <androidfw/BigBuffer.h>
+#include <androidfw/StringPool.h>
+
+#include <algorithm>
+#include <memory>
+#include <string>
+
+#include "android-base/logging.h"
+#include "androidfw/ResourceTypes.h"
+#include "androidfw/StringPiece.h"
+#include "androidfw/Util.h"
+
+using ::android::StringPiece;
+
+namespace android {
+
+StringPool::Ref::Ref() : entry_(nullptr) {
+}
+
+StringPool::Ref::Ref(const StringPool::Ref& rhs) : entry_(rhs.entry_) {
+  if (entry_ != nullptr) {
+    entry_->ref_++;
+  }
+}
+
+StringPool::Ref::Ref(StringPool::Entry* entry) : entry_(entry) {
+  if (entry_ != nullptr) {
+    entry_->ref_++;
+  }
+}
+
+StringPool::Ref::~Ref() {
+  if (entry_ != nullptr) {
+    entry_->ref_--;
+  }
+}
+
+StringPool::Ref& StringPool::Ref::operator=(const StringPool::Ref& rhs) {
+  if (rhs.entry_ != nullptr) {
+    rhs.entry_->ref_++;
+  }
+
+  if (entry_ != nullptr) {
+    entry_->ref_--;
+  }
+  entry_ = rhs.entry_;
+  return *this;
+}
+
+bool StringPool::Ref::operator==(const Ref& rhs) const {
+  return entry_->value == rhs.entry_->value;
+}
+
+bool StringPool::Ref::operator!=(const Ref& rhs) const {
+  return entry_->value != rhs.entry_->value;
+}
+
+const std::string* StringPool::Ref::operator->() const {
+  return &entry_->value;
+}
+
+const std::string& StringPool::Ref::operator*() const {
+  return entry_->value;
+}
+
+size_t StringPool::Ref::index() const {
+  // Account for the styles, which *always* come first.
+  return entry_->pool_->styles_.size() + entry_->index_;
+}
+
+const StringPool::Context& StringPool::Ref::GetContext() const {
+  return entry_->context;
+}
+
+StringPool::StyleRef::StyleRef() : entry_(nullptr) {
+}
+
+StringPool::StyleRef::StyleRef(const StringPool::StyleRef& rhs) : entry_(rhs.entry_) {
+  if (entry_ != nullptr) {
+    entry_->ref_++;
+  }
+}
+
+StringPool::StyleRef::StyleRef(StringPool::StyleEntry* entry) : entry_(entry) {
+  if (entry_ != nullptr) {
+    entry_->ref_++;
+  }
+}
+
+StringPool::StyleRef::~StyleRef() {
+  if (entry_ != nullptr) {
+    entry_->ref_--;
+  }
+}
+
+StringPool::StyleRef& StringPool::StyleRef::operator=(const StringPool::StyleRef& rhs) {
+  if (rhs.entry_ != nullptr) {
+    rhs.entry_->ref_++;
+  }
+
+  if (entry_ != nullptr) {
+    entry_->ref_--;
+  }
+  entry_ = rhs.entry_;
+  return *this;
+}
+
+bool StringPool::StyleRef::operator==(const StyleRef& rhs) const {
+  if (entry_->value != rhs.entry_->value) {
+    return false;
+  }
+
+  if (entry_->spans.size() != rhs.entry_->spans.size()) {
+    return false;
+  }
+
+  auto rhs_iter = rhs.entry_->spans.begin();
+  for (const Span& span : entry_->spans) {
+    const Span& rhs_span = *rhs_iter;
+    if (span.first_char != rhs_span.first_char || span.last_char != rhs_span.last_char ||
+        span.name != rhs_span.name) {
+      return false;
+    }
+  }
+  return true;
+}
+
+bool StringPool::StyleRef::operator!=(const StyleRef& rhs) const {
+  return !operator==(rhs);
+}
+
+const StringPool::StyleEntry* StringPool::StyleRef::operator->() const {
+  return entry_;
+}
+
+const StringPool::StyleEntry& StringPool::StyleRef::operator*() const {
+  return *entry_;
+}
+
+size_t StringPool::StyleRef::index() const {
+  return entry_->index_;
+}
+
+const StringPool::Context& StringPool::StyleRef::GetContext() const {
+  return entry_->context;
+}
+
+StringPool::Ref StringPool::MakeRef(const StringPiece& str) {
+  return MakeRefImpl(str, Context{}, true);
+}
+
+StringPool::Ref StringPool::MakeRef(const StringPiece& str, const Context& context) {
+  return MakeRefImpl(str, context, true);
+}
+
+StringPool::Ref StringPool::MakeRefImpl(const StringPiece& str, const Context& context,
+                                        bool unique) {
+  if (unique) {
+    auto range = indexed_strings_.equal_range(str);
+    for (auto iter = range.first; iter != range.second; ++iter) {
+      if (context.priority == iter->second->context.priority) {
+        return Ref(iter->second);
+      }
+    }
+  }
+
+  std::unique_ptr<Entry> entry(new Entry());
+  entry->value = str.to_string();
+  entry->context = context;
+  entry->index_ = strings_.size();
+  entry->ref_ = 0;
+  entry->pool_ = this;
+
+  Entry* borrow = entry.get();
+  strings_.emplace_back(std::move(entry));
+  indexed_strings_.insert(std::make_pair(StringPiece(borrow->value), borrow));
+  return Ref(borrow);
+}
+
+StringPool::Ref StringPool::MakeRef(const Ref& ref) {
+  if (ref.entry_->pool_ == this) {
+    return ref;
+  }
+  return MakeRef(ref.entry_->value, ref.entry_->context);
+}
+
+StringPool::StyleRef StringPool::MakeRef(const StyleString& str) {
+  return MakeRef(str, Context{});
+}
+
+StringPool::StyleRef StringPool::MakeRef(const StyleString& str, const Context& context) {
+  std::unique_ptr<StyleEntry> entry(new StyleEntry());
+  entry->value = str.str;
+  entry->context = context;
+  entry->index_ = styles_.size();
+  entry->ref_ = 0;
+  for (const android::Span& span : str.spans) {
+    entry->spans.emplace_back(Span{MakeRef(span.name), span.first_char, span.last_char});
+  }
+
+  StyleEntry* borrow = entry.get();
+  styles_.emplace_back(std::move(entry));
+  return StyleRef(borrow);
+}
+
+StringPool::StyleRef StringPool::MakeRef(const StyleRef& ref) {
+  std::unique_ptr<StyleEntry> entry(new StyleEntry());
+  entry->value = ref.entry_->value;
+  entry->context = ref.entry_->context;
+  entry->index_ = styles_.size();
+  entry->ref_ = 0;
+  for (const Span& span : ref.entry_->spans) {
+    entry->spans.emplace_back(Span{MakeRef(*span.name), span.first_char, span.last_char});
+  }
+
+  StyleEntry* borrow = entry.get();
+  styles_.emplace_back(std::move(entry));
+  return StyleRef(borrow);
+}
+
+void StringPool::ReAssignIndices() {
+  // Assign the style indices.
+  const size_t style_len = styles_.size();
+  for (size_t index = 0; index < style_len; index++) {
+    styles_[index]->index_ = index;
+  }
+
+  // Assign the string indices.
+  const size_t string_len = strings_.size();
+  for (size_t index = 0; index < string_len; index++) {
+    strings_[index]->index_ = index;
+  }
+}
+
+void StringPool::Merge(StringPool&& pool) {
+  // First, change the owning pool for the incoming strings.
+  for (std::unique_ptr<Entry>& entry : pool.strings_) {
+    entry->pool_ = this;
+  }
+
+  // Now move the styles, strings, and indices over.
+  std::move(pool.styles_.begin(), pool.styles_.end(), std::back_inserter(styles_));
+  pool.styles_.clear();
+  std::move(pool.strings_.begin(), pool.strings_.end(), std::back_inserter(strings_));
+  pool.strings_.clear();
+  indexed_strings_.insert(pool.indexed_strings_.begin(), pool.indexed_strings_.end());
+  pool.indexed_strings_.clear();
+
+  ReAssignIndices();
+}
+
+void StringPool::HintWillAdd(size_t string_count, size_t style_count) {
+  strings_.reserve(strings_.size() + string_count);
+  styles_.reserve(styles_.size() + style_count);
+}
+
+void StringPool::Prune() {
+  const auto iter_end = indexed_strings_.end();
+  auto index_iter = indexed_strings_.begin();
+  while (index_iter != iter_end) {
+    if (index_iter->second->ref_ <= 0) {
+      index_iter = indexed_strings_.erase(index_iter);
+    } else {
+      ++index_iter;
+    }
+  }
+
+  auto end_iter2 =
+      std::remove_if(strings_.begin(), strings_.end(),
+                     [](const std::unique_ptr<Entry>& entry) -> bool { return entry->ref_ <= 0; });
+  auto end_iter3 = std::remove_if(
+      styles_.begin(), styles_.end(),
+      [](const std::unique_ptr<StyleEntry>& entry) -> bool { return entry->ref_ <= 0; });
+
+  // Remove the entries at the end or else we'll be accessing a deleted string from the StyleEntry.
+  strings_.erase(end_iter2, strings_.end());
+  styles_.erase(end_iter3, styles_.end());
+
+  ReAssignIndices();
+}
+
+template <typename E>
+static void SortEntries(
+    std::vector<std::unique_ptr<E>>& entries,
+    const std::function<int(const StringPool::Context&, const StringPool::Context&)>& cmp) {
+  using UEntry = std::unique_ptr<E>;
+
+  if (cmp != nullptr) {
+    std::sort(entries.begin(), entries.end(), [&cmp](const UEntry& a, const UEntry& b) -> bool {
+      int r = cmp(a->context, b->context);
+      if (r == 0) {
+        r = a->value.compare(b->value);
+      }
+      return r < 0;
+    });
+  } else {
+    std::sort(entries.begin(), entries.end(),
+              [](const UEntry& a, const UEntry& b) -> bool { return a->value < b->value; });
+  }
+}
+
+void StringPool::Sort(const std::function<int(const Context&, const Context&)>& cmp) {
+  SortEntries(styles_, cmp);
+  SortEntries(strings_, cmp);
+  ReAssignIndices();
+}
+
+template <typename T>
+static T* EncodeLength(T* data, size_t length) {
+  static_assert(std::is_integral<T>::value, "wat.");
+
+  constexpr size_t kMask = 1 << ((sizeof(T) * 8) - 1);
+  constexpr size_t kMaxSize = kMask - 1;
+  if (length > kMaxSize) {
+    *data++ = kMask | (kMaxSize & (length >> (sizeof(T) * 8)));
+  }
+  *data++ = length;
+  return data;
+}
+
+/**
+ * Returns the maximum possible string length that can be successfully encoded
+ * using 2 units of the specified T.
+ *    EncodeLengthMax<char> -> maximum unit length of 0x7FFF
+ *    EncodeLengthMax<char16_t> -> maximum unit length of 0x7FFFFFFF
+ **/
+template <typename T>
+static size_t EncodeLengthMax() {
+  static_assert(std::is_integral<T>::value, "wat.");
+
+  constexpr size_t kMask = 1 << ((sizeof(T) * 8 * 2) - 1);
+  constexpr size_t max = kMask - 1;
+  return max;
+}
+
+/**
+ * Returns the number of units (1 or 2) needed to encode the string length
+ * before writing the string.
+ */
+template <typename T>
+static size_t EncodedLengthUnits(size_t length) {
+  static_assert(std::is_integral<T>::value, "wat.");
+
+  constexpr size_t kMask = 1 << ((sizeof(T) * 8) - 1);
+  constexpr size_t kMaxSize = kMask - 1;
+  return length > kMaxSize ? 2 : 1;
+}
+
+const std::string kStringTooLarge = "STRING_TOO_LARGE";
+
+static bool EncodeString(const std::string& str, const bool utf8, BigBuffer* out,
+                         IDiagnostics* diag) {
+  if (utf8) {
+    const std::string& encoded = util::Utf8ToModifiedUtf8(str);
+    const ssize_t utf16_length =
+        utf8_to_utf16_length(reinterpret_cast<const uint8_t*>(encoded.data()), encoded.size());
+    CHECK(utf16_length >= 0);
+
+    // Make sure the lengths to be encoded do not exceed the maximum length that
+    // can be encoded using chars
+    if ((((size_t)encoded.size()) > EncodeLengthMax<char>()) ||
+        (((size_t)utf16_length) > EncodeLengthMax<char>())) {
+      diag->Error(DiagMessage() << "string too large to encode using UTF-8 "
+                                << "written instead as '" << kStringTooLarge << "'");
+
+      EncodeString(kStringTooLarge, utf8, out, diag);
+      return false;
+    }
+
+    const size_t total_size = EncodedLengthUnits<char>(utf16_length) +
+                              EncodedLengthUnits<char>(encoded.size()) + encoded.size() + 1;
+
+    char* data = out->NextBlock<char>(total_size);
+
+    // First encode the UTF16 string length.
+    data = EncodeLength(data, utf16_length);
+
+    // Now encode the size of the real UTF8 string.
+    data = EncodeLength(data, encoded.size());
+    strncpy(data, encoded.data(), encoded.size());
+
+  } else {
+    const std::u16string encoded = util::Utf8ToUtf16(str);
+    const ssize_t utf16_length = encoded.size();
+
+    // Make sure the length to be encoded does not exceed the maximum possible
+    // length that can be encoded
+    if (((size_t)utf16_length) > EncodeLengthMax<char16_t>()) {
+      diag->Error(DiagMessage() << "string too large to encode using UTF-16 "
+                                << "written instead as '" << kStringTooLarge << "'");
+
+      EncodeString(kStringTooLarge, utf8, out, diag);
+      return false;
+    }
+
+    // Total number of 16-bit words to write.
+    const size_t total_size = EncodedLengthUnits<char16_t>(utf16_length) + encoded.size() + 1;
+
+    char16_t* data = out->NextBlock<char16_t>(total_size);
+
+    // Encode the actual UTF16 string length.
+    data = EncodeLength(data, utf16_length);
+    const size_t byte_length = encoded.size() * sizeof(char16_t);
+
+    // NOTE: For some reason, strncpy16(data, entry->value.data(),
+    // entry->value.size()) truncates the string.
+    memcpy(data, encoded.data(), byte_length);
+
+    // The null-terminating character is already here due to the block of data
+    // being set to 0s on allocation.
+  }
+
+  return true;
+}
+
+bool StringPool::Flatten(BigBuffer* out, const StringPool& pool, bool utf8, IDiagnostics* diag) {
+  bool no_error = true;
+  const size_t start_index = out->size();
+  android::ResStringPool_header* header = out->NextBlock<android::ResStringPool_header>();
+  header->header.type = util::HostToDevice16(android::RES_STRING_POOL_TYPE);
+  header->header.headerSize = util::HostToDevice16(sizeof(*header));
+  header->stringCount = util::HostToDevice32(pool.size());
+  header->styleCount = util::HostToDevice32(pool.styles_.size());
+  if (utf8) {
+    header->flags |= android::ResStringPool_header::UTF8_FLAG;
+  }
+
+  uint32_t* indices = pool.size() != 0 ? out->NextBlock<uint32_t>(pool.size()) : nullptr;
+  uint32_t* style_indices =
+      pool.styles_.size() != 0 ? out->NextBlock<uint32_t>(pool.styles_.size()) : nullptr;
+
+  const size_t before_strings_index = out->size();
+  header->stringsStart = before_strings_index - start_index;
+
+  // Styles always come first.
+  for (const std::unique_ptr<StyleEntry>& entry : pool.styles_) {
+    *indices++ = out->size() - before_strings_index;
+    no_error = EncodeString(entry->value, utf8, out, diag) && no_error;
+  }
+
+  for (const std::unique_ptr<Entry>& entry : pool.strings_) {
+    *indices++ = out->size() - before_strings_index;
+    no_error = EncodeString(entry->value, utf8, out, diag) && no_error;
+  }
+
+  out->Align4();
+
+  if (style_indices != nullptr) {
+    const size_t before_styles_index = out->size();
+    header->stylesStart = util::HostToDevice32(before_styles_index - start_index);
+
+    for (const std::unique_ptr<StyleEntry>& entry : pool.styles_) {
+      *style_indices++ = out->size() - before_styles_index;
+
+      if (!entry->spans.empty()) {
+        android::ResStringPool_span* span =
+            out->NextBlock<android::ResStringPool_span>(entry->spans.size());
+        for (const Span& s : entry->spans) {
+          span->name.index = util::HostToDevice32(s.name.index());
+          span->firstChar = util::HostToDevice32(s.first_char);
+          span->lastChar = util::HostToDevice32(s.last_char);
+          span++;
+        }
+      }
+
+      uint32_t* spanEnd = out->NextBlock<uint32_t>();
+      *spanEnd = android::ResStringPool_span::END;
+    }
+
+    // The error checking code in the platform looks for an entire
+    // ResStringPool_span structure worth of 0xFFFFFFFF at the end
+    // of the style block, so fill in the remaining 2 32bit words
+    // with 0xFFFFFFFF.
+    const size_t padding_length =
+        sizeof(android::ResStringPool_span) - sizeof(android::ResStringPool_span::name);
+    uint8_t* padding = out->NextBlock<uint8_t>(padding_length);
+    memset(padding, 0xff, padding_length);
+    out->Align4();
+  }
+  header->header.size = util::HostToDevice32(out->size() - start_index);
+  return no_error;
+}
+
+bool StringPool::FlattenUtf8(BigBuffer* out, const StringPool& pool, IDiagnostics* diag) {
+  return Flatten(out, pool, true, diag);
+}
+
+bool StringPool::FlattenUtf16(BigBuffer* out, const StringPool& pool, IDiagnostics* diag) {
+  return Flatten(out, pool, false, diag);
+}
+
+}  // namespace android
diff --git a/libs/androidfw/Util.cpp b/libs/androidfw/Util.cpp
index 59c9d64..be9edc4 100644
--- a/libs/androidfw/Util.cpp
+++ b/libs/androidfw/Util.cpp
@@ -68,6 +68,107 @@
   return utf8;
 }
 
+std::string Utf8ToModifiedUtf8(const std::string& utf8) {
+  // Java uses Modified UTF-8 which only supports the 1, 2, and 3 byte formats of UTF-8. To encode
+  // 4 byte UTF-8 codepoints, Modified UTF-8 allows the use of surrogate pairs in the same format
+  // of CESU-8 surrogate pairs. Calculate the size of the utf8 string with all 4 byte UTF-8
+  // codepoints replaced with 2 3 byte surrogate pairs
+  size_t modified_size = 0;
+  const size_t size = utf8.size();
+  for (size_t i = 0; i < size; i++) {
+    if (((uint8_t)utf8[i] >> 4) == 0xF) {
+      modified_size += 6;
+      i += 3;
+    } else {
+      modified_size++;
+    }
+  }
+
+  // Early out if no 4 byte codepoints are found
+  if (size == modified_size) {
+    return utf8;
+  }
+
+  std::string output;
+  output.reserve(modified_size);
+  for (size_t i = 0; i < size; i++) {
+    if (((uint8_t)utf8[i] >> 4) == 0xF) {
+      int32_t codepoint = utf32_from_utf8_at(utf8.data(), size, i, nullptr);
+
+      // Calculate the high and low surrogates as UTF-16 would
+      int32_t high = ((codepoint - 0x10000) / 0x400) + 0xD800;
+      int32_t low = ((codepoint - 0x10000) % 0x400) + 0xDC00;
+
+      // Encode each surrogate in UTF-8
+      output.push_back((char)(0xE4 | ((high >> 12) & 0xF)));
+      output.push_back((char)(0x80 | ((high >> 6) & 0x3F)));
+      output.push_back((char)(0x80 | (high & 0x3F)));
+      output.push_back((char)(0xE4 | ((low >> 12) & 0xF)));
+      output.push_back((char)(0x80 | ((low >> 6) & 0x3F)));
+      output.push_back((char)(0x80 | (low & 0x3F)));
+      i += 3;
+    } else {
+      output.push_back(utf8[i]);
+    }
+  }
+
+  return output;
+}
+
+std::string ModifiedUtf8ToUtf8(const std::string& modified_utf8) {
+  // The UTF-8 representation will have a byte length less than or equal to the Modified UTF-8
+  // representation.
+  std::string output;
+  output.reserve(modified_utf8.size());
+
+  size_t index = 0;
+  const size_t modified_size = modified_utf8.size();
+  while (index < modified_size) {
+    size_t next_index;
+    int32_t high_surrogate =
+        utf32_from_utf8_at(modified_utf8.data(), modified_size, index, &next_index);
+    if (high_surrogate < 0) {
+      return {};
+    }
+
+    // Check that the first codepoint is within the high surrogate range
+    if (high_surrogate >= 0xD800 && high_surrogate <= 0xDB7F) {
+      int32_t low_surrogate =
+          utf32_from_utf8_at(modified_utf8.data(), modified_size, next_index, &next_index);
+      if (low_surrogate < 0) {
+        return {};
+      }
+
+      // Check that the second codepoint is within the low surrogate range
+      if (low_surrogate >= 0xDC00 && low_surrogate <= 0xDFFF) {
+        const char32_t codepoint =
+            (char32_t)(((high_surrogate - 0xD800) * 0x400) + (low_surrogate - 0xDC00) + 0x10000);
+
+        // The decoded codepoint should represent a 4 byte, UTF-8 character
+        const size_t utf8_length = (size_t)utf32_to_utf8_length(&codepoint, 1);
+        if (utf8_length != 4) {
+          return {};
+        }
+
+        // Encode the UTF-8 representation of the codepoint into the string
+        char* start = &output[output.size()];
+        output.resize(output.size() + utf8_length);
+        utf32_to_utf8((char32_t*)&codepoint, 1, start, utf8_length + 1);
+
+        index = next_index;
+        continue;
+      }
+    }
+
+    // Append non-surrogate pairs to the output string
+    for (size_t i = index; i < next_index; i++) {
+      output.push_back(modified_utf8[i]);
+    }
+    index = next_index;
+  }
+  return output;
+}
+
 static std::vector<std::string> SplitAndTransform(
     const StringPiece& str, char sep, const std::function<char(char)>& f) {
   std::vector<std::string> parts;
@@ -90,6 +191,29 @@
   return SplitAndTransform(str, sep, ::tolower);
 }
 
+std::unique_ptr<uint8_t[]> Copy(const BigBuffer& buffer) {
+  std::unique_ptr<uint8_t[]> data = std::unique_ptr<uint8_t[]>(new uint8_t[buffer.size()]);
+  uint8_t* p = data.get();
+  for (const auto& block : buffer) {
+    memcpy(p, block.buffer.get(), block.size);
+    p += block.size;
+  }
+  return data;
+}
+
+StringPiece16 GetString16(const android::ResStringPool& pool, size_t idx) {
+  if (auto str = pool.stringAt(idx); str.ok()) {
+    return *str;
+  }
+  return StringPiece16();
+}
+
+std::string GetString(const android::ResStringPool& pool, size_t idx) {
+  if (auto str = pool.string8At(idx); str.ok()) {
+    return ModifiedUtf8ToUtf8(str->to_string());
+  }
+  return Utf16ToUtf8(GetString16(pool, idx));
+}
 
 } // namespace util
 } // namespace android
diff --git a/libs/androidfw/include/androidfw/BigBuffer.h b/libs/androidfw/include/androidfw/BigBuffer.h
new file mode 100644
index 0000000..b99a4ed
--- /dev/null
+++ b/libs/androidfw/include/androidfw/BigBuffer.h
@@ -0,0 +1,192 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ANDROID_BIG_BUFFER_H
+#define _ANDROID_BIG_BUFFER_H
+
+#include <cstring>
+#include <memory>
+#include <string>
+#include <type_traits>
+#include <vector>
+
+#include "android-base/logging.h"
+#include "android-base/macros.h"
+
+namespace android {
+
+/**
+ * Inspired by protobuf's ZeroCopyOutputStream, offers blocks of memory
+ * in which to write without knowing the full size of the entire payload.
+ * This is essentially a list of memory blocks. As one fills up, another
+ * block is allocated and appended to the end of the list.
+ */
+class BigBuffer {
+ public:
+  /**
+   * A contiguous block of allocated memory.
+   */
+  struct Block {
+    /**
+     * Pointer to the memory.
+     */
+    std::unique_ptr<uint8_t[]> buffer;
+
+    /**
+     * Size of memory that is currently occupied. The actual
+     * allocation may be larger.
+     */
+    size_t size;
+
+   private:
+    friend class BigBuffer;
+
+    /**
+     * The size of the memory block allocation.
+     */
+    size_t block_size_;
+  };
+
+  typedef std::vector<Block>::const_iterator const_iterator;
+
+  /**
+   * Create a BigBuffer with block allocation sizes
+   * of block_size.
+   */
+  explicit BigBuffer(size_t block_size);
+
+  BigBuffer(BigBuffer&& rhs) noexcept;
+
+  /**
+   * Number of occupied bytes in all the allocated blocks.
+   */
+  size_t size() const;
+
+  /**
+   * Returns a pointer to an array of T, where T is
+   * a POD type. The elements are zero-initialized.
+   */
+  template <typename T>
+  T* NextBlock(size_t count = 1);
+
+  /**
+   * Returns the next block available and puts the size in out_count.
+   * This is useful for grabbing blocks where the size doesn't matter.
+   * Use BackUp() to give back any bytes that were not used.
+   */
+  void* NextBlock(size_t* out_count);
+
+  /**
+   * Backs up count bytes. This must only be called after NextBlock()
+   * and can not be larger than sizeof(T) * count of the last NextBlock()
+   * call.
+   */
+  void BackUp(size_t count);
+
+  /**
+   * Moves the specified BigBuffer into this one. When this method
+   * returns, buffer is empty.
+   */
+  void AppendBuffer(BigBuffer&& buffer);
+
+  /**
+   * Pads the block with 'bytes' bytes of zero values.
+   */
+  void Pad(size_t bytes);
+
+  /**
+   * Pads the block so that it aligns on a 4 byte boundary.
+   */
+  void Align4();
+
+  size_t block_size() const;
+
+  const_iterator begin() const;
+  const_iterator end() const;
+
+  std::string to_string() const;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(BigBuffer);
+
+  /**
+   * Returns a pointer to a buffer of the requested size.
+   * The buffer is zero-initialized.
+   */
+  void* NextBlockImpl(size_t size);
+
+  size_t block_size_;
+  size_t size_;
+  std::vector<Block> blocks_;
+};
+
+inline BigBuffer::BigBuffer(size_t block_size) : block_size_(block_size), size_(0) {
+}
+
+inline BigBuffer::BigBuffer(BigBuffer&& rhs) noexcept
+    : block_size_(rhs.block_size_), size_(rhs.size_), blocks_(std::move(rhs.blocks_)) {
+}
+
+inline size_t BigBuffer::size() const {
+  return size_;
+}
+
+inline size_t BigBuffer::block_size() const {
+  return block_size_;
+}
+
+template <typename T>
+inline T* BigBuffer::NextBlock(size_t count) {
+  static_assert(std::is_standard_layout<T>::value, "T must be standard_layout type");
+  CHECK(count != 0);
+  return reinterpret_cast<T*>(NextBlockImpl(sizeof(T) * count));
+}
+
+inline void BigBuffer::BackUp(size_t count) {
+  Block& block = blocks_.back();
+  block.size -= count;
+  size_ -= count;
+}
+
+inline void BigBuffer::AppendBuffer(BigBuffer&& buffer) {
+  std::move(buffer.blocks_.begin(), buffer.blocks_.end(), std::back_inserter(blocks_));
+  size_ += buffer.size_;
+  buffer.blocks_.clear();
+  buffer.size_ = 0;
+}
+
+inline void BigBuffer::Pad(size_t bytes) {
+  NextBlock<char>(bytes);
+}
+
+inline void BigBuffer::Align4() {
+  const size_t unaligned = size_ % 4;
+  if (unaligned != 0) {
+    Pad(4 - unaligned);
+  }
+}
+
+inline BigBuffer::const_iterator BigBuffer::begin() const {
+  return blocks_.begin();
+}
+
+inline BigBuffer::const_iterator BigBuffer::end() const {
+  return blocks_.end();
+}
+
+}  // namespace android
+
+#endif  // _ANDROID_BIG_BUFFER_H
diff --git a/libs/androidfw/include/androidfw/IDiagnostics.h b/libs/androidfw/include/androidfw/IDiagnostics.h
new file mode 100644
index 0000000..273b05a
--- /dev/null
+++ b/libs/androidfw/include/androidfw/IDiagnostics.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ANDROID_DIAGNOSTICS_H
+#define _ANDROID_DIAGNOSTICS_H
+
+#include <sstream>
+#include <string>
+
+#include "Source.h"
+#include "android-base/macros.h"
+#include "androidfw/StringPiece.h"
+
+namespace android {
+
+struct DiagMessageActual {
+  Source source;
+  std::string message;
+};
+
+struct DiagMessage {
+ public:
+  DiagMessage() = default;
+
+  explicit DiagMessage(const android::StringPiece& src) : source_(src) {
+  }
+
+  explicit DiagMessage(const Source& src) : source_(src) {
+  }
+
+  explicit DiagMessage(size_t line) : source_(Source().WithLine(line)) {
+  }
+
+  template <typename T>
+  DiagMessage& operator<<(const T& value) {
+    message_ << value;
+    return *this;
+  }
+
+  DiagMessageActual Build() const {
+    return DiagMessageActual{source_, message_.str()};
+  }
+
+ private:
+  Source source_;
+  std::stringstream message_;
+};
+
+template <>
+inline DiagMessage& DiagMessage::operator<<(const ::std::u16string& value) {
+  message_ << android::StringPiece16(value);
+  return *this;
+}
+
+struct IDiagnostics {
+  virtual ~IDiagnostics() = default;
+
+  enum class Level { Note, Warn, Error };
+
+  virtual void Log(Level level, DiagMessageActual& actualMsg) = 0;
+
+  virtual void Error(const DiagMessage& message) {
+    DiagMessageActual actual = message.Build();
+    Log(Level::Error, actual);
+  }
+
+  virtual void Warn(const DiagMessage& message) {
+    DiagMessageActual actual = message.Build();
+    Log(Level::Warn, actual);
+  }
+
+  virtual void Note(const DiagMessage& message) {
+    DiagMessageActual actual = message.Build();
+    Log(Level::Note, actual);
+  }
+};
+
+class SourcePathDiagnostics : public IDiagnostics {
+ public:
+  SourcePathDiagnostics(const Source& src, IDiagnostics* diag) : source_(src), diag_(diag) {
+  }
+
+  void Log(Level level, DiagMessageActual& actual_msg) override {
+    actual_msg.source.path = source_.path;
+    diag_->Log(level, actual_msg);
+    if (level == Level::Error) {
+      error = true;
+    }
+  }
+
+  bool HadError() {
+    return error;
+  }
+
+ private:
+  Source source_;
+  IDiagnostics* diag_;
+  bool error = false;
+
+  DISALLOW_COPY_AND_ASSIGN(SourcePathDiagnostics);
+};
+
+class NoOpDiagnostics : public IDiagnostics {
+ public:
+  NoOpDiagnostics() = default;
+
+  void Log(Level level, DiagMessageActual& actual_msg) override {
+    (void)level;
+    (void)actual_msg;
+  }
+
+  DISALLOW_COPY_AND_ASSIGN(NoOpDiagnostics);
+};
+
+}  // namespace android
+
+#endif /* _ANDROID_DIAGNOSTICS_H */
diff --git a/libs/androidfw/include/androidfw/Source.h b/libs/androidfw/include/androidfw/Source.h
new file mode 100644
index 0000000..0421a91
--- /dev/null
+++ b/libs/androidfw/include/androidfw/Source.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ANDROID_SOURCE_H
+#define _ANDROID_SOURCE_H
+
+#include <optional>
+#include <ostream>
+#include <string>
+
+#include "android-base/stringprintf.h"
+#include "androidfw/StringPiece.h"
+
+namespace android {
+
+// Represents a file on disk. Used for logging and showing errors.
+struct Source {
+  std::string path;
+  std::optional<size_t> line;
+  std::optional<std::string> archive;
+
+  Source() = default;
+
+  inline Source(const android::StringPiece& path) : path(path.to_string()) {  // NOLINT(implicit)
+  }
+
+  inline Source(const android::StringPiece& path, const android::StringPiece& archive)
+      : path(path.to_string()), archive(archive.to_string()) {
+  }
+
+  inline Source(const android::StringPiece& path, size_t line)
+      : path(path.to_string()), line(line) {
+  }
+
+  inline Source WithLine(size_t line) const {
+    return Source(path, line);
+  }
+
+  std::string to_string() const {
+    std::string s = path;
+    if (archive) {
+      s = ::android::base::StringPrintf("%s@%s", archive.value().c_str(), s.c_str());
+    }
+    if (line) {
+      s = ::android::base::StringPrintf("%s:%zd", s.c_str(), line.value());
+    }
+    return s;
+  }
+};
+
+//
+// Implementations
+//
+
+inline ::std::ostream& operator<<(::std::ostream& out, const Source& source) {
+  return out << source.to_string();
+}
+
+inline bool operator==(const Source& lhs, const Source& rhs) {
+  return lhs.path == rhs.path && lhs.line == rhs.line;
+}
+
+inline bool operator<(const Source& lhs, const Source& rhs) {
+  int cmp = lhs.path.compare(rhs.path);
+  if (cmp < 0) return true;
+  if (cmp > 0) return false;
+  if (lhs.line) {
+    if (rhs.line) {
+      return lhs.line.value() < rhs.line.value();
+    }
+    return false;
+  }
+  return bool(rhs.line);
+}
+
+}  // namespace android
+
+#endif  // _ANDROID_SOURCE_H
diff --git a/libs/androidfw/include/androidfw/StringPool.h b/libs/androidfw/include/androidfw/StringPool.h
new file mode 100644
index 0000000..25174d8
--- /dev/null
+++ b/libs/androidfw/include/androidfw/StringPool.h
@@ -0,0 +1,228 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ANDROID_STRING_POOL_H
+#define _ANDROID_STRING_POOL_H
+
+#include <functional>
+#include <memory>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include "BigBuffer.h"
+#include "IDiagnostics.h"
+#include "android-base/macros.h"
+#include "androidfw/ConfigDescription.h"
+#include "androidfw/StringPiece.h"
+
+namespace android {
+
+struct Span {
+  std::string name;
+  uint32_t first_char;
+  uint32_t last_char;
+
+  bool operator==(const Span& right) const {
+    return name == right.name && first_char == right.first_char && last_char == right.last_char;
+  }
+};
+
+struct StyleString {
+  std::string str;
+  std::vector<Span> spans;
+};
+
+// A StringPool for storing the value of String and StyledString resources.
+// Styles and Strings are stored separately, since the runtime variant of this
+// class -- ResStringPool -- requires that styled strings *always* appear first, since their
+// style data is stored as an array indexed by the same indices as the main string pool array.
+// Otherwise, the style data array would have to be sparse and take up more space.
+class StringPool {
+ public:
+  using size_type = size_t;
+
+  class Context {
+   public:
+    enum : uint32_t {
+      kHighPriority = 1u,
+      kNormalPriority = 0x7fffffffu,
+      kLowPriority = 0xffffffffu,
+    };
+    uint32_t priority = kNormalPriority;
+    android::ConfigDescription config;
+
+    Context() = default;
+    Context(uint32_t p, const android::ConfigDescription& c) : priority(p), config(c) {
+    }
+    explicit Context(uint32_t p) : priority(p) {
+    }
+    explicit Context(const android::ConfigDescription& c) : priority(kNormalPriority), config(c) {
+    }
+  };
+
+  class Entry;
+
+  class Ref {
+   public:
+    Ref();
+    Ref(const Ref&);
+    ~Ref();
+
+    Ref& operator=(const Ref& rhs);
+    bool operator==(const Ref& rhs) const;
+    bool operator!=(const Ref& rhs) const;
+    const std::string* operator->() const;
+    const std::string& operator*() const;
+
+    size_t index() const;
+    const Context& GetContext() const;
+
+   private:
+    friend class StringPool;
+
+    explicit Ref(Entry* entry);
+
+    Entry* entry_;
+  };
+
+  class StyleEntry;
+
+  class StyleRef {
+   public:
+    StyleRef();
+    StyleRef(const StyleRef&);
+    ~StyleRef();
+
+    StyleRef& operator=(const StyleRef& rhs);
+    bool operator==(const StyleRef& rhs) const;
+    bool operator!=(const StyleRef& rhs) const;
+    const StyleEntry* operator->() const;
+    const StyleEntry& operator*() const;
+
+    size_t index() const;
+    const Context& GetContext() const;
+
+   private:
+    friend class StringPool;
+
+    explicit StyleRef(StyleEntry* entry);
+
+    StyleEntry* entry_;
+  };
+
+  class Entry {
+   public:
+    std::string value;
+    Context context;
+
+   private:
+    friend class StringPool;
+    friend class Ref;
+
+    size_t index_;
+    int ref_;
+    const StringPool* pool_;
+  };
+
+  struct Span {
+    Ref name;
+    uint32_t first_char;
+    uint32_t last_char;
+  };
+
+  class StyleEntry {
+   public:
+    std::string value;
+    Context context;
+    std::vector<Span> spans;
+
+   private:
+    friend class StringPool;
+    friend class StyleRef;
+
+    size_t index_;
+    int ref_;
+  };
+
+  static bool FlattenUtf8(BigBuffer* out, const StringPool& pool, IDiagnostics* diag);
+  static bool FlattenUtf16(BigBuffer* out, const StringPool& pool, IDiagnostics* diag);
+
+  StringPool() = default;
+  StringPool(StringPool&&) = default;
+  StringPool& operator=(StringPool&&) = default;
+
+  // Adds a string to the pool, unless it already exists. Returns a reference to the string in the
+  // pool.
+  Ref MakeRef(const android::StringPiece& str);
+
+  // Adds a string to the pool, unless it already exists, with a context object that can be used
+  // when sorting the string pool. Returns a reference to the string in the pool.
+  Ref MakeRef(const android::StringPiece& str, const Context& context);
+
+  // Adds a string from another string pool. Returns a reference to the string in the string pool.
+  Ref MakeRef(const Ref& ref);
+
+  // Adds a style to the string pool and returns a reference to it.
+  StyleRef MakeRef(const StyleString& str);
+
+  // Adds a style to the string pool with a context object that can be used when sorting the string
+  // pool. Returns a reference to the style in the string pool.
+  StyleRef MakeRef(const StyleString& str, const Context& context);
+
+  // Adds a style from another string pool. Returns a reference to the style in the string pool.
+  StyleRef MakeRef(const StyleRef& ref);
+
+  // Moves pool into this one without coalescing strings. When this function returns, pool will be
+  // empty.
+  void Merge(StringPool&& pool);
+
+  inline const std::vector<std::unique_ptr<Entry>>& strings() const {
+    return strings_;
+  }
+
+  // Returns the number of strings in the table.
+  inline size_t size() const {
+    return styles_.size() + strings_.size();
+  }
+
+  // Reserves space for strings and styles as an optimization.
+  void HintWillAdd(size_t string_count, size_t style_count);
+
+  // Sorts the strings according to their Context using some comparison function.
+  // Equal Contexts are further sorted by string value, lexicographically.
+  // If no comparison function is provided, values are only sorted lexicographically.
+  void Sort(const std::function<int(const Context&, const Context&)>& cmp = nullptr);
+
+  // Removes any strings that have no references.
+  void Prune();
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(StringPool);
+
+  static bool Flatten(BigBuffer* out, const StringPool& pool, bool utf8, IDiagnostics* diag);
+
+  Ref MakeRefImpl(const android::StringPiece& str, const Context& context, bool unique);
+  void ReAssignIndices();
+
+  std::vector<std::unique_ptr<Entry>> strings_;
+  std::vector<std::unique_ptr<StyleEntry>> styles_;
+  std::unordered_multimap<android::StringPiece, Entry*> indexed_strings_;
+};
+
+}  // namespace android
+
+#endif  // _ANDROID_STRING_POOL_H
diff --git a/libs/androidfw/include/androidfw/Util.h b/libs/androidfw/include/androidfw/Util.h
index c59b5b6..1bbc7f5 100644
--- a/libs/androidfw/include/androidfw/Util.h
+++ b/libs/androidfw/include/androidfw/Util.h
@@ -17,15 +17,18 @@
 #ifndef UTIL_H_
 #define UTIL_H_
 
+#include <android-base/macros.h>
+#include <util/map_ptr.h>
+
 #include <cstdlib>
 #include <memory>
 #include <sstream>
 #include <vector>
 
-#include <android-base/macros.h>
-#include <util/map_ptr.h>
-
+#include "androidfw/BigBuffer.h"
+#include "androidfw/ResourceTypes.h"
 #include "androidfw/StringPiece.h"
+#include "utils/ByteOrder.h"
 
 #ifdef __ANDROID__
 #define ANDROID_LOG(x) LOG(x)
@@ -125,6 +128,28 @@
 // Converts a UTF-16 string to a UTF-8 string.
 std::string Utf16ToUtf8(const StringPiece16& utf16);
 
+// Converts a UTF8 string into Modified UTF8
+std::string Utf8ToModifiedUtf8(const std::string& utf8);
+
+// Converts a Modified UTF8 string into a UTF8 string
+std::string ModifiedUtf8ToUtf8(const std::string& modified_utf8);
+
+inline uint16_t HostToDevice16(uint16_t value) {
+  return htods(value);
+}
+
+inline uint32_t HostToDevice32(uint32_t value) {
+  return htodl(value);
+}
+
+inline uint16_t DeviceToHost16(uint16_t value) {
+  return dtohs(value);
+}
+
+inline uint32_t DeviceToHost32(uint32_t value) {
+  return dtohl(value);
+}
+
 std::vector<std::string> SplitAndLowercase(const android::StringPiece& str, char sep);
 
 template <typename T>
@@ -136,6 +161,18 @@
   return ((size_t)data & 0x3U) == 0;
 }
 
+// Helper method to extract a UTF-16 string from a StringPool. If the string is stored as UTF-8,
+// the conversion to UTF-16 happens within ResStringPool.
+android::StringPiece16 GetString16(const android::ResStringPool& pool, size_t idx);
+
+// Helper method to extract a UTF-8 string from a StringPool. If the string is stored as UTF-16,
+// the conversion from UTF-16 to UTF-8 does not happen in ResStringPool and is done by this method,
+// which maintains no state or cache. This means we must return an std::string copy.
+std::string GetString(const android::ResStringPool& pool, size_t idx);
+
+// Copies the entire BigBuffer into a single buffer.
+std::unique_ptr<uint8_t[]> Copy(const android::BigBuffer& buffer);
+
 }  // namespace util
 }  // namespace android
 
diff --git a/libs/androidfw/tests/BigBuffer_test.cpp b/libs/androidfw/tests/BigBuffer_test.cpp
new file mode 100644
index 0000000..382d21e
--- /dev/null
+++ b/libs/androidfw/tests/BigBuffer_test.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "androidfw/BigBuffer.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using ::testing::NotNull;
+
+namespace android {
+
+TEST(BigBufferTest, AllocateSingleBlock) {
+  BigBuffer buffer(4);
+
+  EXPECT_THAT(buffer.NextBlock<char>(2), NotNull());
+  EXPECT_EQ(2u, buffer.size());
+}
+
+TEST(BigBufferTest, ReturnSameBlockIfNextAllocationFits) {
+  BigBuffer buffer(16);
+
+  char* b1 = buffer.NextBlock<char>(8);
+  EXPECT_THAT(b1, NotNull());
+
+  char* b2 = buffer.NextBlock<char>(4);
+  EXPECT_THAT(b2, NotNull());
+
+  EXPECT_EQ(b1 + 8, b2);
+}
+
+TEST(BigBufferTest, AllocateExactSizeBlockIfLargerThanBlockSize) {
+  BigBuffer buffer(16);
+
+  EXPECT_THAT(buffer.NextBlock<char>(32), NotNull());
+  EXPECT_EQ(32u, buffer.size());
+}
+
+TEST(BigBufferTest, AppendAndMoveBlock) {
+  BigBuffer buffer(16);
+
+  uint32_t* b1 = buffer.NextBlock<uint32_t>();
+  ASSERT_THAT(b1, NotNull());
+  *b1 = 33;
+
+  {
+    BigBuffer buffer2(16);
+    b1 = buffer2.NextBlock<uint32_t>();
+    ASSERT_THAT(b1, NotNull());
+    *b1 = 44;
+
+    buffer.AppendBuffer(std::move(buffer2));
+    EXPECT_EQ(0u, buffer2.size());  // NOLINT
+    EXPECT_EQ(buffer2.begin(), buffer2.end());
+  }
+
+  EXPECT_EQ(2 * sizeof(uint32_t), buffer.size());
+
+  auto b = buffer.begin();
+  ASSERT_NE(b, buffer.end());
+  ASSERT_EQ(sizeof(uint32_t), b->size);
+  ASSERT_EQ(33u, *reinterpret_cast<uint32_t*>(b->buffer.get()));
+  ++b;
+
+  ASSERT_NE(b, buffer.end());
+  ASSERT_EQ(sizeof(uint32_t), b->size);
+  ASSERT_EQ(44u, *reinterpret_cast<uint32_t*>(b->buffer.get()));
+  ++b;
+
+  ASSERT_EQ(b, buffer.end());
+}
+
+TEST(BigBufferTest, PadAndAlignProperly) {
+  BigBuffer buffer(16);
+
+  ASSERT_THAT(buffer.NextBlock<char>(2), NotNull());
+  ASSERT_EQ(2u, buffer.size());
+  buffer.Pad(2);
+  ASSERT_EQ(4u, buffer.size());
+  buffer.Align4();
+  ASSERT_EQ(4u, buffer.size());
+  buffer.Pad(2);
+  ASSERT_EQ(6u, buffer.size());
+  buffer.Align4();
+  ASSERT_EQ(8u, buffer.size());
+}
+
+}  // namespace android
diff --git a/libs/androidfw/tests/StringPool_test.cpp b/libs/androidfw/tests/StringPool_test.cpp
new file mode 100644
index 0000000..047d457
--- /dev/null
+++ b/libs/androidfw/tests/StringPool_test.cpp
@@ -0,0 +1,388 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "androidfw/StringPool.h"
+
+#include <string>
+
+#include "androidfw/IDiagnostics.h"
+#include "androidfw/StringPiece.h"
+#include "androidfw/Util.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using ::android::StringPiece;
+using ::android::StringPiece16;
+using ::testing::Eq;
+using ::testing::Ne;
+using ::testing::NotNull;
+using ::testing::Pointee;
+
+namespace android {
+
+TEST(StringPoolTest, InsertOneString) {
+  StringPool pool;
+
+  StringPool::Ref ref = pool.MakeRef("wut");
+  EXPECT_THAT(*ref, Eq("wut"));
+}
+
+TEST(StringPoolTest, InsertTwoUniqueStrings) {
+  StringPool pool;
+
+  StringPool::Ref ref_a = pool.MakeRef("wut");
+  StringPool::Ref ref_b = pool.MakeRef("hey");
+
+  EXPECT_THAT(*ref_a, Eq("wut"));
+  EXPECT_THAT(*ref_b, Eq("hey"));
+}
+
+TEST(StringPoolTest, DoNotInsertNewDuplicateString) {
+  StringPool pool;
+
+  StringPool::Ref ref_a = pool.MakeRef("wut");
+  StringPool::Ref ref_b = pool.MakeRef("wut");
+
+  EXPECT_THAT(*ref_a, Eq("wut"));
+  EXPECT_THAT(*ref_b, Eq("wut"));
+  EXPECT_THAT(pool.size(), Eq(1u));
+}
+
+TEST(StringPoolTest, DoNotDedupeSameStringDifferentPriority) {
+  StringPool pool;
+
+  StringPool::Ref ref_a = pool.MakeRef("wut", StringPool::Context(0x81010001));
+  StringPool::Ref ref_b = pool.MakeRef("wut", StringPool::Context(0x81010002));
+
+  EXPECT_THAT(*ref_a, Eq("wut"));
+  EXPECT_THAT(*ref_b, Eq("wut"));
+  EXPECT_THAT(pool.size(), Eq(2u));
+}
+
+TEST(StringPoolTest, MaintainInsertionOrderIndex) {
+  StringPool pool;
+
+  StringPool::Ref ref_a = pool.MakeRef("z");
+  StringPool::Ref ref_b = pool.MakeRef("a");
+  StringPool::Ref ref_c = pool.MakeRef("m");
+
+  EXPECT_THAT(ref_a.index(), Eq(0u));
+  EXPECT_THAT(ref_b.index(), Eq(1u));
+  EXPECT_THAT(ref_c.index(), Eq(2u));
+}
+
+TEST(StringPoolTest, PruneStringsWithNoReferences) {
+  StringPool pool;
+
+  StringPool::Ref ref_a = pool.MakeRef("foo");
+
+  {
+    StringPool::Ref ref_b = pool.MakeRef("wut");
+    EXPECT_THAT(*ref_b, Eq("wut"));
+    EXPECT_THAT(pool.size(), Eq(2u));
+    pool.Prune();
+    EXPECT_THAT(pool.size(), Eq(2u));
+  }
+  EXPECT_THAT(pool.size(), Eq(2u));
+
+  {
+    StringPool::Ref ref_c = pool.MakeRef("bar");
+    EXPECT_THAT(pool.size(), Eq(3u));
+
+    pool.Prune();
+    EXPECT_THAT(pool.size(), Eq(2u));
+  }
+  EXPECT_THAT(pool.size(), Eq(2u));
+
+  pool.Prune();
+  EXPECT_THAT(pool.size(), Eq(1u));
+}
+
+TEST(StringPoolTest, SortAndMaintainIndexesInStringReferences) {
+  StringPool pool;
+
+  StringPool::Ref ref_a = pool.MakeRef("z");
+  StringPool::Ref ref_b = pool.MakeRef("a");
+  StringPool::Ref ref_c = pool.MakeRef("m");
+
+  EXPECT_THAT(*ref_a, Eq("z"));
+  EXPECT_THAT(ref_a.index(), Eq(0u));
+
+  EXPECT_THAT(*ref_b, Eq("a"));
+  EXPECT_THAT(ref_b.index(), Eq(1u));
+
+  EXPECT_THAT(*ref_c, Eq("m"));
+  EXPECT_THAT(ref_c.index(), Eq(2u));
+
+  pool.Sort();
+
+  EXPECT_THAT(*ref_a, Eq("z"));
+  EXPECT_THAT(ref_a.index(), Eq(2u));
+
+  EXPECT_THAT(*ref_b, Eq("a"));
+  EXPECT_THAT(ref_b.index(), Eq(0u));
+
+  EXPECT_THAT(*ref_c, Eq("m"));
+  EXPECT_THAT(ref_c.index(), Eq(1u));
+}
+
+TEST(StringPoolTest, SortAndStillDedupe) {
+  StringPool pool;
+
+  StringPool::Ref ref_a = pool.MakeRef("z");
+  StringPool::Ref ref_b = pool.MakeRef("a");
+  StringPool::Ref ref_c = pool.MakeRef("m");
+
+  pool.Sort();
+
+  StringPool::Ref ref_d = pool.MakeRef("z");
+  StringPool::Ref ref_e = pool.MakeRef("a");
+  StringPool::Ref ref_f = pool.MakeRef("m");
+
+  EXPECT_THAT(ref_d.index(), Eq(ref_a.index()));
+  EXPECT_THAT(ref_e.index(), Eq(ref_b.index()));
+  EXPECT_THAT(ref_f.index(), Eq(ref_c.index()));
+}
+
+TEST(StringPoolTest, AddStyles) {
+  StringPool pool;
+
+  StringPool::StyleRef ref = pool.MakeRef(StyleString{{"android"}, {Span{{"b"}, 2, 6}}});
+  EXPECT_THAT(ref.index(), Eq(0u));
+  EXPECT_THAT(ref->value, Eq("android"));
+  ASSERT_THAT(ref->spans.size(), Eq(1u));
+
+  const StringPool::Span& span = ref->spans.front();
+  EXPECT_THAT(*span.name, Eq("b"));
+  EXPECT_THAT(span.first_char, Eq(2u));
+  EXPECT_THAT(span.last_char, Eq(6u));
+}
+
+TEST(StringPoolTest, DoNotDedupeStyleWithSameStringAsNonStyle) {
+  StringPool pool;
+
+  StringPool::Ref ref = pool.MakeRef("android");
+
+  StyleString str{{"android"}, {}};
+  StringPool::StyleRef style_ref = pool.MakeRef(StyleString{{"android"}, {}});
+
+  EXPECT_THAT(ref.index(), Ne(style_ref.index()));
+}
+
+TEST(StringPoolTest, StylesAndStringsAreSeparateAfterSorting) {
+  StringPool pool;
+
+  StringPool::StyleRef ref_a = pool.MakeRef(StyleString{{"beta"}, {}});
+  StringPool::Ref ref_b = pool.MakeRef("alpha");
+  StringPool::StyleRef ref_c = pool.MakeRef(StyleString{{"alpha"}, {}});
+
+  EXPECT_THAT(ref_b.index(), Ne(ref_c.index()));
+
+  pool.Sort();
+
+  EXPECT_THAT(ref_c.index(), Eq(0u));
+  EXPECT_THAT(ref_a.index(), Eq(1u));
+  EXPECT_THAT(ref_b.index(), Eq(2u));
+}
+
+TEST(StringPoolTest, FlattenEmptyStringPoolUtf8) {
+  using namespace android;  // For NO_ERROR on Windows.
+  NoOpDiagnostics diag;
+
+  StringPool pool;
+  BigBuffer buffer(1024);
+  StringPool::FlattenUtf8(&buffer, pool, &diag);
+
+  std::unique_ptr<uint8_t[]> data = android::util::Copy(buffer);
+  ResStringPool test;
+  ASSERT_THAT(test.setTo(data.get(), buffer.size()), Eq(NO_ERROR));
+}
+
+TEST(StringPoolTest, FlattenOddCharactersUtf16) {
+  using namespace android;  // For NO_ERROR on Windows.
+  NoOpDiagnostics diag;
+
+  StringPool pool;
+  pool.MakeRef("\u093f");
+  BigBuffer buffer(1024);
+  StringPool::FlattenUtf16(&buffer, pool, &diag);
+
+  std::unique_ptr<uint8_t[]> data = android::util::Copy(buffer);
+  ResStringPool test;
+  ASSERT_EQ(test.setTo(data.get(), buffer.size()), NO_ERROR);
+  auto str = test.stringAt(0);
+  ASSERT_TRUE(str.has_value());
+  EXPECT_THAT(str->size(), Eq(1u));
+  EXPECT_THAT(str->data(), Pointee(Eq(u'\u093f')));
+  EXPECT_THAT(str->data()[1], Eq(0u));
+}
+
+constexpr const char* sLongString =
+    "バッテリーを長持ちさせるため、バッテリーセーバーは端末のパフォーマンスを抑"
+    "え、バイブレーション、位置情報サービス、大半のバックグラウンドデータを制限"
+    "します。メール、SMSや、同期を使 "
+    "用するその他のアプリは、起動しても更新されないことがあります。バッテリーセ"
+    "ーバーは端末の充電中は自動的にOFFになります。";
+
+TEST(StringPoolTest, Flatten) {
+  using namespace android;  // For NO_ERROR on Windows.
+  NoOpDiagnostics diag;
+
+  StringPool pool;
+
+  StringPool::Ref ref_a = pool.MakeRef("hello");
+  StringPool::Ref ref_b = pool.MakeRef("goodbye");
+  StringPool::Ref ref_c = pool.MakeRef(sLongString);
+  StringPool::Ref ref_d = pool.MakeRef("");
+  StringPool::StyleRef ref_e =
+      pool.MakeRef(StyleString{{"style"}, {Span{{"b"}, 0, 1}, Span{{"i"}, 2, 3}}});
+
+  // Styles are always first.
+  EXPECT_THAT(ref_e.index(), Eq(0u));
+
+  EXPECT_THAT(ref_a.index(), Eq(1u));
+  EXPECT_THAT(ref_b.index(), Eq(2u));
+  EXPECT_THAT(ref_c.index(), Eq(3u));
+  EXPECT_THAT(ref_d.index(), Eq(4u));
+
+  BigBuffer buffers[2] = {BigBuffer(1024), BigBuffer(1024)};
+  StringPool::FlattenUtf8(&buffers[0], pool, &diag);
+  StringPool::FlattenUtf16(&buffers[1], pool, &diag);
+
+  // Test both UTF-8 and UTF-16 buffers.
+  for (const BigBuffer& buffer : buffers) {
+    std::unique_ptr<uint8_t[]> data = android::util::Copy(buffer);
+
+    ResStringPool test;
+    ASSERT_EQ(test.setTo(data.get(), buffer.size()), NO_ERROR);
+
+    EXPECT_THAT(android::util::GetString(test, 1), Eq("hello"));
+    EXPECT_THAT(android::util::GetString16(test, 1), Eq(u"hello"));
+
+    EXPECT_THAT(android::util::GetString(test, 2), Eq("goodbye"));
+    EXPECT_THAT(android::util::GetString16(test, 2), Eq(u"goodbye"));
+
+    EXPECT_THAT(android::util::GetString(test, 3), Eq(sLongString));
+    EXPECT_THAT(android::util::GetString16(test, 3), Eq(util::Utf8ToUtf16(sLongString)));
+
+    EXPECT_TRUE(test.stringAt(4).has_value() || test.string8At(4).has_value());
+
+    EXPECT_THAT(android::util::GetString(test, 0), Eq("style"));
+    EXPECT_THAT(android::util::GetString16(test, 0), Eq(u"style"));
+
+    auto span_result = test.styleAt(0);
+    ASSERT_TRUE(span_result.has_value());
+
+    const ResStringPool_span* span = span_result->unsafe_ptr();
+    EXPECT_THAT(android::util::GetString(test, span->name.index), Eq("b"));
+    EXPECT_THAT(android::util::GetString16(test, span->name.index), Eq(u"b"));
+    EXPECT_THAT(span->firstChar, Eq(0u));
+    EXPECT_THAT(span->lastChar, Eq(1u));
+    span++;
+
+    ASSERT_THAT(span->name.index, Ne(ResStringPool_span::END));
+    EXPECT_THAT(android::util::GetString(test, span->name.index), Eq("i"));
+    EXPECT_THAT(android::util::GetString16(test, span->name.index), Eq(u"i"));
+    EXPECT_THAT(span->firstChar, Eq(2u));
+    EXPECT_THAT(span->lastChar, Eq(3u));
+    span++;
+
+    EXPECT_THAT(span->name.index, Eq(ResStringPool_span::END));
+  }
+}
+
+TEST(StringPoolTest, ModifiedUTF8) {
+  using namespace android;  // For NO_ERROR on Windows.
+  NoOpDiagnostics diag;
+  StringPool pool;
+  StringPool::Ref ref_a = pool.MakeRef("\xF0\x90\x90\x80");          // 𐐀 (U+10400)
+  StringPool::Ref ref_b = pool.MakeRef("foo \xF0\x90\x90\xB7 bar");  // 𐐷 (U+10437)
+  StringPool::Ref ref_c = pool.MakeRef("\xF0\x90\x90\x80\xF0\x90\x90\xB7");
+
+  BigBuffer buffer(1024);
+  StringPool::FlattenUtf8(&buffer, pool, &diag);
+  std::unique_ptr<uint8_t[]> data = android::util::Copy(buffer);
+
+  // Check that the codepoints are encoded using two three-byte surrogate pairs
+  ResStringPool test;
+  ASSERT_EQ(test.setTo(data.get(), buffer.size()), NO_ERROR);
+  auto str = test.string8At(0);
+  ASSERT_TRUE(str.has_value());
+  EXPECT_THAT(str->to_string(), Eq("\xED\xA0\x81\xED\xB0\x80"));
+
+  str = test.string8At(1);
+  ASSERT_TRUE(str.has_value());
+  EXPECT_THAT(str->to_string(), Eq("foo \xED\xA0\x81\xED\xB0\xB7 bar"));
+
+  str = test.string8At(2);
+  ASSERT_TRUE(str.has_value());
+  EXPECT_THAT(str->to_string(), Eq("\xED\xA0\x81\xED\xB0\x80\xED\xA0\x81\xED\xB0\xB7"));
+
+  // Check that retrieving the strings returns the original UTF-8 character bytes
+  EXPECT_THAT(android::util::GetString(test, 0), Eq("\xF0\x90\x90\x80"));
+  EXPECT_THAT(android::util::GetString(test, 1), Eq("foo \xF0\x90\x90\xB7 bar"));
+  EXPECT_THAT(android::util::GetString(test, 2), Eq("\xF0\x90\x90\x80\xF0\x90\x90\xB7"));
+}
+
+TEST(StringPoolTest, MaxEncodingLength) {
+  NoOpDiagnostics diag;
+  using namespace android;  // For NO_ERROR on Windows.
+  ResStringPool test;
+
+  StringPool pool;
+  pool.MakeRef("aaaaaaaaaa");
+  BigBuffer buffers[2] = {BigBuffer(1024), BigBuffer(1024)};
+
+  // Make sure a UTF-8 string under the maximum length does not produce an error
+  EXPECT_THAT(StringPool::FlattenUtf8(&buffers[0], pool, &diag), Eq(true));
+  std::unique_ptr<uint8_t[]> data = android::util::Copy(buffers[0]);
+  test.setTo(data.get(), buffers[0].size());
+  EXPECT_THAT(android::util::GetString(test, 0), Eq("aaaaaaaaaa"));
+
+  // Make sure a UTF-16 string under the maximum length does not produce an error
+  EXPECT_THAT(StringPool::FlattenUtf16(&buffers[1], pool, &diag), Eq(true));
+  data = android::util::Copy(buffers[1]);
+  test.setTo(data.get(), buffers[1].size());
+  EXPECT_THAT(android::util::GetString16(test, 0), Eq(u"aaaaaaaaaa"));
+
+  StringPool pool2;
+  std::string longStr(50000, 'a');
+  pool2.MakeRef("this fits1");
+  pool2.MakeRef(longStr);
+  pool2.MakeRef("this fits2");
+  BigBuffer buffers2[2] = {BigBuffer(1024), BigBuffer(1024)};
+
+  // Make sure a string that exceeds the maximum length of UTF-8 produces an
+  // error and writes a shorter error string instead
+  EXPECT_THAT(StringPool::FlattenUtf8(&buffers2[0], pool2, &diag), Eq(false));
+  data = android::util::Copy(buffers2[0]);
+  test.setTo(data.get(), buffers2[0].size());
+  EXPECT_THAT(android::util::GetString(test, 0), "this fits1");
+  EXPECT_THAT(android::util::GetString(test, 1), "STRING_TOO_LARGE");
+  EXPECT_THAT(android::util::GetString(test, 2), "this fits2");
+
+  // Make sure a string that a string that exceeds the maximum length of UTF-8
+  // but not UTF-16 does not error for UTF-16
+  StringPool pool3;
+  std::u16string longStr16(50000, 'a');
+  pool3.MakeRef(longStr);
+  EXPECT_THAT(StringPool::FlattenUtf16(&buffers2[1], pool3, &diag), Eq(true));
+  data = android::util::Copy(buffers2[1]);
+  test.setTo(data.get(), buffers2[1].size());
+  EXPECT_THAT(android::util::GetString16(test, 0), Eq(longStr16));
+}
+
+}  // namespace android
