diff options
author | corysmith <corysmith@google.com> | 2018-04-19 10:23:15 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-04-19 10:29:04 -0700 |
commit | 6fcfc537398dd6d1836ef5cd32686d3b74ed088c (patch) | |
tree | 2cd168d4b133f062f64e248b967ee729f5d25f91 /src/tools/android/java/com/google/devtools/build/android/xml | |
parent | 736b955ce19c7c1d82de18b3bece5d0f09dc66d4 (diff) |
Update ApkSubject to use the AndroidCompiledDataDeserializer for proto apks.
Minor fixes to the AndroidCompiledDataDeserializer
RELNOTES: None
PiperOrigin-RevId: 193535766
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/xml')
2 files changed, 9 insertions, 15 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java index 32147cd49c..98aedd3145 100644 --- a/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java +++ b/src/tools/android/java/com/google/devtools/build/android/xml/SimpleXmlResourceValue.java @@ -279,7 +279,7 @@ public class SimpleXmlResourceValue implements XmlResourceValue { stringValue = Integer.toString(item.getPrim().getData()); } else { throw new IllegalArgumentException( - String.format("'%s' is not a valid resource type.", resourceType)); + String.format("'%s' with value %s is not a simple resource type.", resourceType, proto)); } return of( diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java b/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java index 72707cf87d..3f56cf726e 100644 --- a/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java +++ b/src/tools/android/java/com/google/devtools/build/android/xml/StyleableXmlResourceValue.java @@ -18,10 +18,10 @@ import com.android.aapt.Resources.Value; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Iterables; +import com.google.devtools.build.android.AndroidCompiledDataDeserializer.ReferenceResolver; import com.google.devtools.build.android.AndroidDataWritingVisitor; import com.google.devtools.build.android.AndroidDataWritingVisitor.ValuesResourceDefinition; import com.google.devtools.build.android.AndroidResourceSymbolSink; @@ -165,23 +165,17 @@ public class StyleableXmlResourceValue implements XmlResourceValue { Iterables.transform(proto.getReferencesList(), DATA_KEY_TO_FULLY_QUALIFIED_NAME))); } - public static XmlResourceValue from( - Value proto, Map<String, Boolean> qualifiedReferenceInlineStatus) { + public static XmlResourceValue from(Value proto, ReferenceResolver packageResolver) { Map<FullyQualifiedName, Boolean> attributes = new HashMap<>(); Styleable styleable = proto.getCompoundValue().getStyleable(); for (Styleable.Entry entry : styleable.getEntryList()) { - final FullyQualifiedName reference = - FullyQualifiedName.fromReference(entry.getAttr().getName()); - final String qualifiedReference = reference.asQualifiedReference(); - Preconditions.checkArgument( - qualifiedReferenceInlineStatus.containsKey(qualifiedReference), - "Styleable reference %s is not in %s", - qualifiedReference, - qualifiedReferenceInlineStatus.keySet()); - - attributes.put(reference, qualifiedReferenceInlineStatus.get(qualifiedReference)); - qualifiedReferenceInlineStatus.put(qualifiedReference, false); + final FullyQualifiedName reference = packageResolver.parse(entry.getAttr().getName()); + final boolean shouldInline = packageResolver.shouldInline(reference); + attributes.put(reference, shouldInline); + if (shouldInline) { + packageResolver.markInlined(reference); + } } return of(ImmutableMap.copyOf(attributes)); |