summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Aurimas Liutikas <aurimas@google.com> 2018-11-15 15:48:28 -0800
committer Aurimas Liutikas <aurimas@google.com> 2018-11-16 10:50:34 -0800
commitd42a670ee59618e98078079b554f2652035eb1e2 (patch)
tree831f5ac01b3f9386ca6a61e2f1e16479ad229afd
parent10113a7c36838cb7da6b36e7f4800d6cfae6178d (diff)
Add style value to ResolvedBag in AssetManager2.
Bug: 117176857 Test: updated AssetManager2Test.MergesStylesWithParentFromSingleApkAssets Change-Id: I2b79eea8e43431a932756b267b91eb4423c968a5
-rw-r--r--libs/androidfw/AssetManager2.cpp3
-rw-r--r--libs/androidfw/AttributeResolution.cpp4
-rw-r--r--libs/androidfw/include/androidfw/AssetManager2.h3
-rw-r--r--libs/androidfw/tests/AssetManager2_test.cpp6
4 files changed, 14 insertions, 2 deletions
diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp
index 9e6948878b1d..85e72cccc703 100644
--- a/libs/androidfw/AssetManager2.cpp
+++ b/libs/androidfw/AssetManager2.cpp
@@ -637,6 +637,7 @@ const ResolvedBag* AssetManager2::GetBag(uint32_t resid, std::vector<uint32_t>&
new_entry->key = new_key;
new_entry->key_pool = nullptr;
new_entry->type_pool = nullptr;
+ new_entry->style = resid;
new_entry->value.copyFrom_dtoh(map_entry->value);
status_t err = entry.dynamic_ref_table->lookupResourceValue(&new_entry->value);
if (err != NO_ERROR) {
@@ -695,6 +696,7 @@ const ResolvedBag* AssetManager2::GetBag(uint32_t resid, std::vector<uint32_t>&
new_entry->key_pool = nullptr;
new_entry->type_pool = nullptr;
new_entry->value.copyFrom_dtoh(map_entry->value);
+ new_entry->style = resid;
status_t err = entry.dynamic_ref_table->lookupResourceValue(&new_entry->value);
if (err != NO_ERROR) {
LOG(ERROR) << base::StringPrintf(
@@ -731,6 +733,7 @@ const ResolvedBag* AssetManager2::GetBag(uint32_t resid, std::vector<uint32_t>&
new_entry->key_pool = nullptr;
new_entry->type_pool = nullptr;
new_entry->value.copyFrom_dtoh(map_entry->value);
+ new_entry->style = resid;
status_t err = entry.dynamic_ref_table->lookupResourceValue(&new_entry->value);
if (err != NO_ERROR) {
LOG(ERROR) << base::StringPrintf("Failed to resolve value t=0x%02x d=0x%08x for key 0x%08x.",
diff --git a/libs/androidfw/AttributeResolution.cpp b/libs/androidfw/AttributeResolution.cpp
index f912af4f7190..57e3491895e6 100644
--- a/libs/androidfw/AttributeResolution.cpp
+++ b/libs/androidfw/AttributeResolution.cpp
@@ -310,7 +310,8 @@ void ApplyStyle(Theme* theme, ResXMLParser* xml_parser, uint32_t def_style_attr,
type_set_flags = style_flags;
value = entry->value;
if (kDebugStyles) {
- ALOGI("-> From style: type=0x%x, data=0x%08x", value.dataType, value.data);
+ ALOGI("-> From style: type=0x%x, data=0x%08x, style=0x%08x", value.dataType, value.data,
+ entry->style);
}
}
}
@@ -388,7 +389,6 @@ void ApplyStyle(Theme* theme, ResXMLParser* xml_parser, uint32_t def_style_attr,
// out_indices must NOT be nullptr.
out_indices[indices_idx] = ii;
}
-
out_values += STYLE_NUM_ENTRIES;
}
diff --git a/libs/androidfw/include/androidfw/AssetManager2.h b/libs/androidfw/include/androidfw/AssetManager2.h
index 5312b062473a..0d492984d41d 100644
--- a/libs/androidfw/include/androidfw/AssetManager2.h
+++ b/libs/androidfw/include/androidfw/AssetManager2.h
@@ -49,6 +49,9 @@ struct ResolvedBag {
Res_value value;
+ // The resource ID of the origin style associated with the given entry.
+ uint32_t style;
+
// Which ApkAssets this entry came from.
ApkAssetsCookie cookie;
diff --git a/libs/androidfw/tests/AssetManager2_test.cpp b/libs/androidfw/tests/AssetManager2_test.cpp
index f1cc569f7d4e..5449a54d08de 100644
--- a/libs/androidfw/tests/AssetManager2_test.cpp
+++ b/libs/androidfw/tests/AssetManager2_test.cpp
@@ -298,11 +298,13 @@ TEST_F(AssetManager2Test, MergesStylesWithParentFromSingleApkAssets) {
EXPECT_EQ(Res_value::TYPE_INT_DEC, bag_two->entries[0].value.dataType);
EXPECT_EQ(1u, bag_two->entries[0].value.data);
EXPECT_EQ(0, bag_two->entries[0].cookie);
+ EXPECT_EQ(app::R::style::StyleOne, bag_two->entries[0].style);
// attr_two should be overridden from StyleOne by StyleTwo.
EXPECT_EQ(app::R::attr::attr_two, bag_two->entries[1].key);
EXPECT_EQ(Res_value::TYPE_STRING, bag_two->entries[1].value.dataType);
EXPECT_EQ(0, bag_two->entries[1].cookie);
+ EXPECT_EQ(app::R::style::StyleTwo, bag_two->entries[1].style);
EXPECT_EQ(std::string("string"), GetStringFromPool(assetmanager.GetStringPoolForCookie(0),
bag_two->entries[1].value.data));
@@ -312,21 +314,25 @@ TEST_F(AssetManager2Test, MergesStylesWithParentFromSingleApkAssets) {
EXPECT_EQ(Res_value::TYPE_ATTRIBUTE, bag_two->entries[2].value.dataType);
EXPECT_EQ(app::R::attr::attr_indirect, bag_two->entries[2].value.data);
EXPECT_EQ(0, bag_two->entries[2].cookie);
+ EXPECT_EQ(app::R::style::StyleTwo, bag_two->entries[2].style);
EXPECT_EQ(app::R::attr::attr_five, bag_two->entries[3].key);
EXPECT_EQ(Res_value::TYPE_REFERENCE, bag_two->entries[3].value.dataType);
EXPECT_EQ(app::R::string::string_one, bag_two->entries[3].value.data);
EXPECT_EQ(0, bag_two->entries[3].cookie);
+ EXPECT_EQ(app::R::style::StyleTwo, bag_two->entries[3].style);
EXPECT_EQ(app::R::attr::attr_indirect, bag_two->entries[4].key);
EXPECT_EQ(Res_value::TYPE_INT_DEC, bag_two->entries[4].value.dataType);
EXPECT_EQ(3u, bag_two->entries[4].value.data);
EXPECT_EQ(0, bag_two->entries[4].cookie);
+ EXPECT_EQ(app::R::style::StyleTwo, bag_two->entries[4].style);
EXPECT_EQ(app::R::attr::attr_empty, bag_two->entries[5].key);
EXPECT_EQ(Res_value::TYPE_NULL, bag_two->entries[5].value.dataType);
EXPECT_EQ(Res_value::DATA_NULL_EMPTY, bag_two->entries[5].value.data);
EXPECT_EQ(0, bag_two->entries[5].cookie);
+ EXPECT_EQ(app::R::style::StyleTwo, bag_two->entries[5].style);
}
TEST_F(AssetManager2Test, MergeStylesCircularDependency) {