/** * shorten recursively all attributes that are package dependent of the passed nodes and all * its child nodes. * @param packageName the manifest package name. * @param xmlElement the xml element to process recursively. */ private static void extractFcqns(@NonNull String packageName, @NonNull XmlElement xmlElement) { for (XmlAttribute xmlAttribute : xmlElement.getAttributes()) { if (xmlAttribute.getModel() !=null && xmlAttribute.getModel().isPackageDependent()) { String value = xmlAttribute.getValue(); if (value.startsWith(packageName) && value.charAt(packageName.length()) == '.') { xmlAttribute.getXml().setValue(value.substring(packageName.length())); } } } for (XmlElement child : xmlElement.getMergeableElements()) { extractFcqns(packageName, child); } }
/** * Validates all {@link com.android.manifmerger.XmlElement} attributes belonging to the * {@link com.android.SdkConstants#ANDROID_URI} namespace. * * @param xmlElement xml element to check the attributes from. * @param mergingReport report for errors and warnings. */ private static void validateAndroidAttributes(@NonNull XmlElement xmlElement, @NonNull MergingReport.Builder mergingReport) { for (XmlAttribute xmlAttribute : xmlElement.getAttributes()) { if (xmlAttribute.getModel() != null) { AttributeModel.Validator onWriteValidator = xmlAttribute.getModel() .getOnWriteValidator(); if (onWriteValidator != null) { onWriteValidator.validates( mergingReport, xmlAttribute, xmlAttribute.getValue()); } } } } }
/** * Validate attributes part of the {@link com.android.SdkConstants#ANDROID_URI} * @param mergingReport report to log warnings and errors. * @param xmlElement xml element to check its attributes. */ private static void validateAndroidAttributes(@NonNull MergingReport.Builder mergingReport, @NonNull XmlElement xmlElement) { for (XmlAttribute xmlAttribute : xmlElement.getAttributes()) { AttributeModel model = xmlAttribute.getModel(); if (model != null && model.getOnReadValidator() != null) { model.getOnReadValidator().validates( mergingReport, xmlAttribute, xmlAttribute.getValue()); } } }