AAPT2: Support static lib referencing static lib

When a static library A references static library B,
and app C references both A and B, we get the following symbol merging,
symbols from library B get imported twice.

We must only check that symbol references to library B are valid
when building library A. We should only merge all the symbols
when building final app C.

Change-Id: I23cba33b0901dcbb5328d9c9dfaa6a979c073c36
diff --git a/tools/aapt2/ResourceTable.h b/tools/aapt2/ResourceTable.h
index 94bacd8..706f56a 100644
--- a/tools/aapt2/ResourceTable.h
+++ b/tools/aapt2/ResourceTable.h
@@ -143,11 +143,21 @@
     bool addResource(const ResourceNameRef& name, const ConfigDescription& config,
                      const SourceLine& source, std::unique_ptr<Value> value);
 
+    /**
+     * Same as addResource, but doesn't verify the validity of the name. This is used
+     * when loading resources from an existing binary resource table that may have mangled
+     * names.
+     */
+    bool addResourceAllowMangled(const ResourceNameRef& name, const ConfigDescription& config,
+                                 const SourceLine& source, std::unique_ptr<Value> value);
+
     bool addResource(const ResourceNameRef& name, const ResourceId resId,
                      const ConfigDescription& config, const SourceLine& source,
                      std::unique_ptr<Value> value);
 
     bool markPublic(const ResourceNameRef& name, const ResourceId resId, const SourceLine& source);
+    bool markPublicAllowMangled(const ResourceNameRef& name, const ResourceId resId,
+                                const SourceLine& source);
 
     /*
      * Merges the resources from `other` into this table, mangling the names of the resources
@@ -176,6 +186,12 @@
     std::unique_ptr<ResourceEntry>& findOrCreateEntry(std::unique_ptr<ResourceTableType>& type,
                                                       const StringPiece16& name);
 
+    bool addResourceImpl(const ResourceNameRef& name, const ResourceId resId,
+                         const ConfigDescription& config, const SourceLine& source,
+                         std::unique_ptr<Value> value, const char16_t* validChars);
+    bool markPublicImpl(const ResourceNameRef& name, const ResourceId resId,
+                        const SourceLine& source, const char16_t* validChars);
+
     std::u16string mPackage;
     size_t mPackageId;