summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/aapt/Command.cpp6
-rw-r--r--tools/aapt/ResourceTable.cpp8
-rw-r--r--tools/aapt2/format/binary/TableFlattener.cpp18
-rw-r--r--tools/aapt2/format/binary/TableFlattener_test.cpp48
4 files changed, 66 insertions, 14 deletions
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index fecc7b3cbf37..d02fd83df6af 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -1028,7 +1028,6 @@ int doDump(Bundle* bundle)
// These permissions are required by services implementing services
// the system binds to (IME, Accessibility, PrintServices, etc.)
bool hasBindDeviceAdminPermission = false;
- bool hasBindInputMethodPermission = false;
bool hasBindAccessibilityServicePermission = false;
bool hasBindPrintServicePermission = false;
bool hasBindNfcServicePermission = false;
@@ -1757,7 +1756,6 @@ int doDump(Bundle* bundle)
hasMetaHostPaymentCategory = false;
hasMetaOffHostPaymentCategory = false;
hasBindDeviceAdminPermission = false;
- hasBindInputMethodPermission = false;
hasBindAccessibilityServicePermission = false;
hasBindPrintServicePermission = false;
hasBindNfcServicePermission = false;
@@ -1871,9 +1869,7 @@ int doDump(Bundle* bundle)
String8 permission = AaptXml::getAttribute(tree, PERMISSION_ATTR,
&error);
if (error == "") {
- if (permission == "android.permission.BIND_INPUT_METHOD") {
- hasBindInputMethodPermission = true;
- } else if (permission ==
+ if (permission ==
"android.permission.BIND_ACCESSIBILITY_SERVICE") {
hasBindAccessibilityServicePermission = true;
} else if (permission ==
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index b9de11b0026b..47750fc11a6e 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -2970,14 +2970,6 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<const ResourceFilter>&
}
e->setNameIndex(keyStrings.add(e->getName(), true));
- // If this entry has no values for other configs,
- // and is the default config, then it is special. Otherwise
- // we want to add it with the config info.
- ConfigDescription* valueConfig = NULL;
- if (N != 1 || config == nullConfig) {
- valueConfig = &config;
- }
-
status_t err = e->prepareFlatten(&valueStrings, this,
&configTypeName, &config);
if (err != NO_ERROR) {
diff --git a/tools/aapt2/format/binary/TableFlattener.cpp b/tools/aapt2/format/binary/TableFlattener.cpp
index cd07b1ebbf92..46a846bce35f 100644
--- a/tools/aapt2/format/binary/TableFlattener.cpp
+++ b/tools/aapt2/format/binary/TableFlattener.cpp
@@ -641,7 +641,23 @@ class PackageFlattener {
local_key_index = (uint32_t)key_pool_.MakeRef(entry.name).index();
} else {
// resource isn't exempt from collapse, add it as obfuscated value
- local_key_index = (uint32_t)key_pool_.MakeRef(obfuscated_resource_name).index();
+ if (entry.overlayable_item) {
+ // if the resource name of the specific entry is obfuscated and this
+ // entry is in the overlayable list, the overlay can't work on this
+ // overlayable at runtime because the name has been obfuscated in
+ // resources.arsc during flatten operation.
+ const OverlayableItem& item = entry.overlayable_item.value();
+ context_->GetDiagnostics()->Warn(android::DiagMessage(item.overlayable->source)
+ << "The resource name of overlayable entry "
+ << resource_name.to_string() << "'"
+ << " shouldn't be obfuscated in resources.arsc");
+
+ local_key_index = (uint32_t)key_pool_.MakeRef(entry.name).index();
+ } else {
+ // TODO(b/228192695): output the entry.name and Resource id to make
+ // de-obfuscated possible.
+ local_key_index = (uint32_t)key_pool_.MakeRef(obfuscated_resource_name).index();
+ }
}
// Group values by configuration.
for (auto& config_value : entry.values) {
diff --git a/tools/aapt2/format/binary/TableFlattener_test.cpp b/tools/aapt2/format/binary/TableFlattener_test.cpp
index 1dd2468b5868..e48fca61fef8 100644
--- a/tools/aapt2/format/binary/TableFlattener_test.cpp
+++ b/tools/aapt2/format/binary/TableFlattener_test.cpp
@@ -878,4 +878,52 @@ TEST_F(TableFlattenerTest, FlattenCustomResourceTypes) {
Res_value::TYPE_STRING, (uint32_t)*idx, 0u));
}
+TEST_F(TableFlattenerTest, FlattenTypeEntryWithNameCollapseNotInExemption) {
+ OverlayableItem overlayable_item(std::make_shared<Overlayable>("TestName", "overlay://theme"));
+ overlayable_item.policies |= PolicyFlags::PUBLIC;
+
+ std::string name = "com.app.test:color/overlayable_color";
+ std::unique_ptr<ResourceTable> table =
+ test::ResourceTableBuilder()
+ .AddValue("com.app.test:color/overlayable_color", ResourceId(0x7f010000),
+ util::make_unique<BinaryPrimitive>(uint8_t(Res_value::TYPE_INT_COLOR_ARGB8),
+ 0xffaabbcc))
+ .SetOverlayable(name, overlayable_item)
+ .Build();
+
+ TableFlattenerOptions options;
+ options.collapse_key_stringpool = true;
+
+ ResTable res_table;
+ EXPECT_THAT(Flatten(context_.get(), options, table.get(), &res_table), testing::IsTrue());
+ EXPECT_THAT(Exists(&res_table, "com.app.test:color/overlayable_color", ResourceId(0x7f010000), {},
+ Res_value::TYPE_INT_COLOR_ARGB8, 0xffaabbcc, 0u),
+ testing::IsTrue());
+}
+
+TEST_F(TableFlattenerTest, FlattenTypeEntryWithNameCollapseInExemption) {
+ OverlayableItem overlayable_item(std::make_shared<Overlayable>("TestName", "overlay://theme"));
+ overlayable_item.policies |= PolicyFlags::PUBLIC;
+
+ std::string name = "com.app.test:color/overlayable_color";
+ std::unique_ptr<ResourceTable> table =
+ test::ResourceTableBuilder()
+ .AddValue("com.app.test:color/overlayable_color", ResourceId(0x7f010000),
+ util::make_unique<BinaryPrimitive>(uint8_t(Res_value::TYPE_INT_COLOR_ARGB8),
+ 0xffaabbcc))
+ .SetOverlayable(name, overlayable_item)
+ .Build();
+
+ TableFlattenerOptions options;
+ options.collapse_key_stringpool = true;
+ options.name_collapse_exemptions.insert(
+ ResourceName({}, ResourceType::kColor, "overlayable_color"));
+
+ ResTable res_table;
+ EXPECT_THAT(Flatten(context_.get(), options, table.get(), &res_table), testing::IsTrue());
+ EXPECT_THAT(Exists(&res_table, "com.app.test:color/overlayable_color", ResourceId(0x7f010000), {},
+ Res_value::TYPE_INT_COLOR_ARGB8, 0xffaabbcc, 0u),
+ testing::IsTrue());
+}
+
} // namespace aapt