/** * Record a {@link com.android.manifmerger.Actions.AttributeRecord} action for an attribute of * an xml element. * @param attribute the attribute in question. * @param attributeRecord the record of the action. */ synchronized void recordAttributeAction( @NonNull XmlAttribute attribute, @NonNull Actions.AttributeRecord attributeRecord) { List<Actions.AttributeRecord> attributeRecords = getAttributeRecords(attribute); attributeRecords.add(attributeRecord); }
/** * Returns the record for an attribute creation event. The attribute is "created" when it is * added for the first time into the resulting merged xml document. */ @Nullable synchronized Actions.AttributeRecord getAttributeCreationRecord( @NonNull XmlAttribute attribute) { for (Actions.AttributeRecord attributeRecord : getAttributeRecords(attribute)) { if (attributeRecord.getActionType() == Actions.ActionType.ADDED) { return attributeRecord; } } return null; }
/** * Records when a default value that should be merged was rejected due to a tools:replace * annotation. * * @param attribute the attribute which default value was ignored. * @param implicitAttributeOwner the element owning the implicit default value. */ synchronized void recordImplicitRejection( @NonNull XmlAttribute attribute, @NonNull XmlElement implicitAttributeOwner) { List<Actions.AttributeRecord> attributeRecords = getAttributeRecords(attribute); Actions.AttributeRecord attributeRecord = new Actions.AttributeRecord( Actions.ActionType.REJECTED, new SourceFilePosition( implicitAttributeOwner.getDocument().getSourceFile(), implicitAttributeOwner.getPosition()), attribute.getOriginalId(), null, /* reason */ AttributeOperationType.REPLACE ); attributeRecords.add(attributeRecord); }