AAPT2: Implement density stripping and initial Split support
When a preferred density is supplied, the closest matching densities
will be selected, the rest stripped from the APK.
Split support will be enabled in a later CL. Command line support is still
needed, but the foundation is ready.
Bug:25958912
Change-Id: I56d599806b4ec4ffa24e17aad48d47130ca05c08
diff --git a/tools/aapt2/link/TableMerger.cpp b/tools/aapt2/link/TableMerger.cpp
index 2ecd5b0..5f11745 100644
--- a/tools/aapt2/link/TableMerger.cpp
+++ b/tools/aapt2/link/TableMerger.cpp
@@ -98,8 +98,7 @@
return false;
}
- mFilesToMerge[ResourceKeyRef(name, config)] = FileToMerge{
- f, oldFile->getSource(), util::utf16ToUtf8(*newFile->path) };
+ newFile->file = f;
return true;
};
@@ -198,10 +197,6 @@
for (auto& srcValue : srcEntry->values) {
ResourceConfigValue* dstValue = dstEntry->findValue(srcValue->config,
srcValue->product);
-
- const bool stripConfig = mOptions.filter ?
- !mOptions.filter->match(srcValue->config) : false;
-
if (dstValue) {
const int collisionResult = ResourceTable::resolveValueCollision(
dstValue->value.get(), srcValue->value.get());
@@ -227,10 +222,6 @@
}
- if (stripConfig) {
- continue;
- }
-
if (!dstValue) {
// Force create the entry if we didn't have it.
dstValue = dstEntry->findOrCreateValue(srcValue->config, srcValue->product);
@@ -286,6 +277,7 @@
std::unique_ptr<FileReference> fileRef = util::make_unique<FileReference>(
table.stringPool.makeRef(path));
fileRef->setSource(fileDesc.source);
+ fileRef->file = file;
ResourceTablePackage* pkg = table.createPackage(fileDesc.name.package, 0x0);
pkg->findOrCreateType(fileDesc.name.type)
@@ -293,15 +285,8 @@
->findOrCreateValue(fileDesc.config, {})
->value = std::move(fileRef);
- auto callback = [&](const ResourceNameRef& name, const ConfigDescription& config,
- FileReference* newFile, FileReference* oldFile) -> bool {
- mFilesToMerge[ResourceKeyRef(name, config)] = FileToMerge{
- file, oldFile->getSource(), util::utf16ToUtf8(*newFile->path) };
- return true;
- };
-
return doMerge(file->getSource(), &table, pkg,
- false /* mangle */, overlay /* overlay */, true /* allow new */, callback);
+ false /* mangle */, overlay /* overlay */, true /* allow new */, {});
}
bool TableMerger::mergeFile(const ResourceFile& fileDesc, io::IFile* file) {