use of com.android.tools.build.bundletool.model.AndroidManifest.ANDROID_NAMESPACE_URI in project bundletool by google.
the class ResourceAnalyzerTest method attributeWithCompiledItem_refToUnknownResourceInBase_ignored.
@Test
public void attributeWithCompiledItem_refToUnknownResourceInBase_ignored() throws Exception {
XmlNode manifest = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlNode(xmlElement("application", xmlResourceReferenceAttribute(ANDROID_NAMESPACE_URI, "name", /* attrResourceId= */
0x999999, /* valueResourceId= */
0x12345678)))))).getManifestRoot().getProto();
ResourceTable resourceTable = resourceTable(pkg(0x12, "com.test.app.feature", type(0x34, "string", entry(0x5678, "name", value("hello", DEFAULT_CONFIG)))));
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.setManifest(manifest)).addModule("feature", builder -> builder.setManifest(androidManifest("com.test.app.feature")).setResourceTable(resourceTable)).build();
ImmutableSet<ResourceId> resourceIds = new ResourceAnalyzer(appBundle).findAllAppResourcesReachableFromBaseManifest();
assertThat(resourceIds).isEmpty();
}
use of com.android.tools.build.bundletool.model.AndroidManifest.ANDROID_NAMESPACE_URI in project bundletool by google.
the class ResourceAnalyzerTest method attributeWithCompiledItem_ref_resolved.
@Test
public void attributeWithCompiledItem_ref_resolved() throws Exception {
XmlNode manifest = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlNode(xmlElement("application", xmlResourceReferenceAttribute(ANDROID_NAMESPACE_URI, "name", /* attrResourceId= */
0x999999, /* valueResourceId= */
0x12345678)))))).getManifestRoot().getProto();
ResourceTable resourceTable = resourceTable(pkg(0x12, "com.test.app", type(0x34, "string", entry(0x5678, "name", value("hello", DEFAULT_CONFIG)))));
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.setManifest(manifest).setResourceTable(resourceTable)).build();
ImmutableSet<ResourceId> resourceIds = new ResourceAnalyzer(appBundle).findAllAppResourcesReachableFromBaseManifest();
assertThat(resourceIds).containsExactly(ResourceId.create(0x12345678));
}
use of com.android.tools.build.bundletool.model.AndroidManifest.ANDROID_NAMESPACE_URI in project bundletool by google.
the class ResourceAnalyzerTest method customManifest_filteredRefs_resolved.
@Test
public void customManifest_filteredRefs_resolved() throws Exception {
XmlNode baseManifest = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlNode(xmlElement("application", ImmutableList.of(xmlResourceReferenceAttribute(ANDROID_NAMESPACE_URI, "name", /* attrResourceId= */
0x999998, /* valueResourceId= */
0x87654321), xmlResourceReferenceAttribute(ANDROID_NAMESPACE_URI, "name2", /* attrResourceId= */
0x999999, /* valueResourceId= */
0x12345678))))))).getManifestRoot().getProto();
AndroidManifest customManifest = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlNode(xmlElement("application", xmlResourceReferenceAttribute(ANDROID_NAMESPACE_URI, "name2", /* attrResourceId= */
0x999999, /* valueResourceId= */
0x12345678))))));
ResourceTable resourceTable = resourceTable(pkg(0x12, "com.test.app", type(0x34, "string", entry(0x5678, "name", value("hello", DEFAULT_CONFIG)))), pkg(0x87, "com.test.app", type(0x65, "string", entry(0x4321, "name2", value("world", DEFAULT_CONFIG)))));
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.setManifest(baseManifest).setResourceTable(resourceTable)).build();
ImmutableSet<ResourceId> resourceIds = new ResourceAnalyzer(appBundle).findAllAppResourcesReachableFromManifest(customManifest);
assertThat(resourceIds).containsExactly(ResourceId.create(0x12345678));
}
use of com.android.tools.build.bundletool.model.AndroidManifest.ANDROID_NAMESPACE_URI in project bundletool by google.
the class ResourceAnalyzerTest method transitive_compoundValue_style.
@Test
public void transitive_compoundValue_style() throws Exception {
// AndroidManifest
// --> 0x7f010001 (app_theme) --> 0x7f010002 (parent_theme) --> 0x7f020001 (string)
// |-> 0x7f020002 (string)
// |-> 0x7f020003 (string)
XmlNode manifest = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlNode(xmlElement("application", xmlResourceReferenceAttribute(ANDROID_NAMESPACE_URI, "theme", /* attrResourceId= */
0x999999, /* valueResourceId= */
0x7f010001)))))).getManifestRoot().getProto();
ResourceTable resourceTable = resourceTable(pkg(0x7f, "com.test.app", type(0x01, "theme", entry(0x0001, "app_theme", compoundValueStyleWithResourceReferences(/* parentId= */
0x7f010002, /* referencedResourceIds= */
new int[] { 0x7f020002, 0x7f020003 })), entry(0x0002, "parent_theme", compoundValueStyleWithResourceReferences(/* parentId= */
null, /* referencedResourceIds= */
new int[] { 0x7f020001 }))), type(0x02, "string", entry(0x0001, "parent_theme_str", value("hello", DEFAULT_CONFIG)), entry(0x0002, "app_theme_str1", value("hello", DEFAULT_CONFIG)), entry(0x0003, "app_theme_str2", value("hello", DEFAULT_CONFIG)), entry(0x0099, "not_referenced", value("", DEFAULT_CONFIG)))));
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.setManifest(manifest).setResourceTable(resourceTable)).build();
ImmutableSet<ResourceId> resourceIds = new ResourceAnalyzer(appBundle).findAllAppResourcesReachableFromBaseManifest();
assertThat(resourceIds).containsExactly(ResourceId.create(0x7f010001), ResourceId.create(0x7f010002), ResourceId.create(0x7f020001), ResourceId.create(0x7f020002), ResourceId.create(0x7f020003));
}
use of com.android.tools.build.bundletool.model.AndroidManifest.ANDROID_NAMESPACE_URI in project bundletool by google.
the class ResourceAnalyzerTest method transitive_item_xmlFileWithResourceReference.
@Test
public void transitive_item_xmlFileWithResourceReference() throws Exception {
// AndroidManifest --> 0x7f010001 (xml file) --> 0x7f020002 (string)
XmlNode manifest = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlNode(xmlElement("application", xmlResourceReferenceAttribute(NO_NAMESPACE_URI, "attr_pointing_to_xml", /* attrResourceId= */
0x999999, /* valueResourceId= */
0x7f010001)))))).getManifestRoot().getProto();
XmlNode embeddedXmlFile = AndroidManifest.create(xmlNode(xmlElement("root", xmlResourceReferenceAttribute(ANDROID_NAMESPACE_URI, "name", /* attrResourceId= */
0x999999, /* valueResourceId= */
0x7f020002)))).getManifestRoot().getProto();
ResourceTable resourceTable = resourceTable(pkg(0x7f, "com.test.app", type(0x01, "file", entry(0x0001, "xml_file", fileReference("res/xml/embedded.xml", FileReference.Type.PROTO_XML, DEFAULT_CONFIG))), type(0x02, "string", entry(0x0002, "name_str", value("hello", DEFAULT_CONFIG)), entry(0x0099, "not_referenced", value("", DEFAULT_CONFIG)))));
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.setManifest(manifest).setResourceTable(resourceTable).addFile("res/xml/embedded.xml", embeddedXmlFile.toByteArray())).build();
ImmutableSet<ResourceId> resourceIds = new ResourceAnalyzer(appBundle).findAllAppResourcesReachableFromBaseManifest();
assertThat(resourceIds).containsExactly(ResourceId.create(0x7f010001), ResourceId.create(0x7f020002));
}
Aggregations