Filter unneeded assets from additional resource directories

This change ensures that assets that are not needed for the
preferred density are stripped from additional directories
specified by the -S flag

For simplicity, the logic for deciding which assets are not
needed is still applied per directory, rather than globally,
which may still result in some unneeded assets being included
in the final output.

Bug: 12604267
Change-Id: Ic1378570c2d9cd1c854c507e784233818c19efca
diff --git a/tools/aapt/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp
index d8e113a..f11e9c2 100644
--- a/tools/aapt/AaptAssets.cpp
+++ b/tools/aapt/AaptAssets.cpp
@@ -2140,6 +2140,9 @@
                     current->setFullResPaths(mFullResPaths);
                 }
                 count = current->slurpResourceTree(bundle, String8(res));
+                if (i > 0 && count > 0) {
+                  count = current->filter(bundle);
+                }
 
                 if (count < 0) {
                     totalCount = count;