AAPT2: Remove resources that define locales but no default values.

According to our docs:
https://developer.android.com/guide/topics/resources/localization.html#defaults-r-important

Some resources *require* that there is a default definition. So far,
the pain is felt when doing translations for strings that have been
renamed, etc.

This CL strips out resources that don't have a default value and define
a resource for a locale. This is conservative, but should be expanded
to other configuration properties moving forward.

Bug: 36572857
Test: make aapt2_tests
Change-Id: Ife94a1f8a2ee221f8532ffa856541a9c8c4e7143
diff --git a/tools/aapt2/ResourceTable.h b/tools/aapt2/ResourceTable.h
index 374fe1e..8534eaa 100644
--- a/tools/aapt2/ResourceTable.h
+++ b/tools/aapt2/ResourceTable.h
@@ -104,13 +104,26 @@
   explicit ResourceEntry(const android::StringPiece& name) : name(name.to_string()) {}
 
   ResourceConfigValue* FindValue(const ConfigDescription& config);
+
   ResourceConfigValue* FindValue(const ConfigDescription& config,
                                  const android::StringPiece& product);
+
   ResourceConfigValue* FindOrCreateValue(const ConfigDescription& config,
                                          const android::StringPiece& product);
   std::vector<ResourceConfigValue*> FindAllValues(const ConfigDescription& config);
-  std::vector<ResourceConfigValue*> FindValuesIf(
-      const std::function<bool(ResourceConfigValue*)>& f);
+
+  template <typename Func>
+  std::vector<ResourceConfigValue*> FindValuesIf(Func f) {
+    std::vector<ResourceConfigValue*> results;
+    for (auto& config_value : values) {
+      if (f(config_value.get())) {
+        results.push_back(config_value.get());
+      }
+    }
+    return results;
+  }
+
+  bool HasDefaultValue() const;
 
  private:
   DISALLOW_COPY_AND_ASSIGN(ResourceEntry);