diff options
author | Ryan Mitchell <rtmitchell@google.com> | 2019-12-12 10:23:54 -0800 |
---|---|---|
committer | Ryan Mitchell <rtmitchell@google.com> | 2019-12-12 10:55:33 -0800 |
commit | df9e732962f0c9e3b16113413f9143a4a7d426a9 (patch) | |
tree | 511912e930337ce12e33ce1b371dd1362142cf15 /libs/androidfw/Idmap.cpp | |
parent | 809e21fc286f7bffdb6dd835b9931adb7748ba08 (diff) |
Add tests for layout overlaying
Add tests to ensure that findViewbyId retrieves the correct view when
an id is overlaid in a RRO.
Also fixes a bug that made strings hardcoded in the overlays.xml
file unable to be retrieved from the string pool.
Bug: 135943783
Test: atest OverlayDeviceTests
Change-Id: I2bf03f151cb696d28f6bb9018eb319af29ba48f4
Diffstat (limited to 'libs/androidfw/Idmap.cpp')
-rw-r--r-- | libs/androidfw/Idmap.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libs/androidfw/Idmap.cpp b/libs/androidfw/Idmap.cpp index 773353d32d51..6aac4479c3a1 100644 --- a/libs/androidfw/Idmap.cpp +++ b/libs/androidfw/Idmap.cpp @@ -53,7 +53,7 @@ OverlayStringPool::~OverlayStringPool() { const char16_t* OverlayStringPool::stringAt(size_t idx, size_t* outLen) const { const size_t offset = dtohl(data_header_->string_pool_index_offset); - if (idmap_string_pool_ != nullptr && idx >= size() && idx >= offset) { + if (idmap_string_pool_ != nullptr && idx >= ResStringPool::size() && idx >= offset) { return idmap_string_pool_->stringAt(idx - offset, outLen); } @@ -62,13 +62,17 @@ const char16_t* OverlayStringPool::stringAt(size_t idx, size_t* outLen) const { const char* OverlayStringPool::string8At(size_t idx, size_t* outLen) const { const size_t offset = dtohl(data_header_->string_pool_index_offset); - if (idmap_string_pool_ != nullptr && idx >= size() && idx >= offset) { + if (idmap_string_pool_ != nullptr && idx >= ResStringPool::size() && idx >= offset) { return idmap_string_pool_->string8At(idx - offset, outLen); } return ResStringPool::string8At(idx, outLen); } +size_t OverlayStringPool::size() const { + return ResStringPool::size() + (idmap_string_pool_ != nullptr ? idmap_string_pool_->size() : 0U); +} + OverlayDynamicRefTable::OverlayDynamicRefTable(const Idmap_data_header* data_header, const Idmap_overlay_entry* entries, uint8_t target_assigned_package_id) |