File Activation — Xml Autocom

<autocom version="1"> <activation mode="full"/> </autocom> vendor/x/autocom/Android.bp

// AutocompletionManagerService.java private void parseActivationFile() XmlPullParser parser = ...; String engineId = parser.getAttributeValue(null, "id"); String condition = parser.getAttributeValue(null, "condition"); if ("online".equals(condition) && hasNetwork()) enableEngine(engineId); File Activation Xml Autocom

# In device.mk PRODUCT_PACKAGES += autocom_activation.xml PRODUCT_COPY_FILES += \ vendor/x/autocom/autocom_activation.xml:$(TARGET_COPY_OUT_VENDOR)/etc/autocom/config.xml Then in code (C++/Java): String engineId = parser.getAttributeValue(null

// Schema validation SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = factory.newSchema(new File("autocom_schema.xsd")); Validator validator = schema.newValidator(); validator.validate(new StreamSource("autocom_activation.xml")); Typical schema ( autocom_schema.xsd ): String condition = parser.getAttributeValue(null

<?xml version="1.0"?> <catalog prefer="public"> <public publicId="-//My/DTD/Autocom 1.0//EN" uri="autocom.dtd"/> <uri name="http://myapp.com/autocom-config" uri="autocom-schema.xsd"/> </catalog> Then in Eclipse: Preferences → XML → XML Catalog → Add → points to this file → autocompletion for custom XML tags. 6. Security & Validation (Deep) Activation XML files must be validated to prevent injection:

bool isAutocomActive() FILE* f = fopen("/vendor/etc/autocom/autocom_activation.xml", "r"); if (!f) return false; // Parse <activation mode="full"> fclose(f); return true;