public class ManifestHelper
extends java.lang.Object
| Constructor and Description |
|---|
ManifestHelper(org.w3c.dom.Document androidManifest,
org.gradle.api.logging.Logger logger)
Constructor for class.
|
ManifestHelper(java.lang.String androidManifestPath,
org.gradle.api.logging.Logger logger)
Constructor for class.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addElement(org.w3c.dom.Element parent,
org.w3c.dom.Element child)
Adds an
Element to the xml file. |
void |
applyManifestChanges()
Commits the changes to the AndroidManifest.xml on
androidManifestPath and reopens
it. |
void |
commitManifestChanges()
Commits the changes to the AndroidManifest.xml on
androidManifestPath. |
void |
commitManifestChanges(org.w3c.dom.Document newAndroidManifest)
Commits the changes to the AndroidManifest.xml on
androidManifestPath. |
org.w3c.dom.Attr |
createAttribute(java.lang.String name,
java.lang.String value)
Creates an
Attr to the xml file. |
org.w3c.dom.Element |
createElement(java.lang.String name)
Creates an
Element to the xml file. |
org.w3c.dom.Element |
createMetricSenderServiceElement()
Creates an
Element to the xml file, with the required values for the MetricSender
Service. |
org.w3c.dom.Element |
createTraceSenderServiceElement()
Creates an
Element to the xml file, with the required values for the TraceSender
Service. |
org.w3c.dom.Document |
getAndroidManifest()
Gets the
androidManifest. |
java.lang.String |
getAndroidManifestPath()
Gets the path of the AndroidManifest document.
|
org.w3c.dom.Element |
getApplicationElement()
Gets the application
Element from the androidManifest. |
java.lang.String |
getApplicationName()
Gets the Application name attribute to the given value.
|
java.lang.String |
getPackageName()
Gets the package name from the android manifest file.
|
java.util.List<java.lang.String> |
getPermissions()
Gets the list of permissions from the AndroidManifest.xml file.
|
boolean |
isApplicationNamePresent()
Checks if the application name attribute is presented in the
androidManifest or not. |
void |
setDefaultApplicationName()
Adds an Application name attribute with the given value.
|
public ManifestHelper(@NonNull
org.w3c.dom.Document androidManifest,
@NonNull
org.gradle.api.logging.Logger logger)
androidManifest - the AndroidManifest parsed as a Document to work with.logger - for providing the logging functions.public ManifestHelper(@NonNull
java.lang.String androidManifestPath,
@NonNull
org.gradle.api.logging.Logger logger)
throws java.io.IOException,
org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException
androidManifestPath - the androidManifestPath of the AndroidManifest.xml.logger - for providing the logging functions.java.io.IOException - if any IO errors occur.org.xml.sax.SAXException - if any parse errors occur.javax.xml.parsers.ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies
the configuration requested.public boolean isApplicationNamePresent()
androidManifest or not.true if the application name attribute is present, false otherwise.@NonNull public java.lang.String getPackageName()
null when not found.@Nullable public org.w3c.dom.Element getApplicationElement()
Element from the androidManifest.public void addElement(@NonNull
org.w3c.dom.Element parent,
@NonNull
org.w3c.dom.Element child)
Element to the xml file.parent - the parent Element of the Element to add.child - the child Element to add.@NonNull
public org.w3c.dom.Element createElement(@NonNull
java.lang.String name)
Element to the xml file.name - the name of the Element which will be created.@NonNull
public org.w3c.dom.Attr createAttribute(@NonNull
java.lang.String name,
@NonNull
java.lang.String value)
Attr to the xml file.name - the name of the Attr which will be created.value - the value of the given Attr which will be created.public void setDefaultApplicationName()
@NonNull public java.lang.String getApplicationName()
@NonNull public org.w3c.dom.Element createMetricSenderServiceElement()
Element to the xml file, with the required values for the MetricSender
Service.@NonNull public org.w3c.dom.Element createTraceSenderServiceElement()
Element to the xml file, with the required values for the TraceSender
Service.@NonNull public java.util.List<java.lang.String> getPermissions()
public void applyManifestChanges()
throws javax.xml.transform.TransformerException,
java.io.IOException,
org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException
androidManifestPath and reopens
it.javax.xml.transform.TransformerException - if an unrecoverable error occurs during the course of
the transformation.java.io.IOException - if the path is null.org.xml.sax.SAXException - if any parse errors occur.javax.xml.parsers.ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies
the configuration requested.public void commitManifestChanges()
throws javax.xml.transform.TransformerException,
java.io.IOException
androidManifestPath.javax.xml.transform.TransformerException - if an unrecoverable error occurs during the course of the
transformation.java.io.IOException - if the path is null.public void commitManifestChanges(@NonNull
org.w3c.dom.Document newAndroidManifest)
throws javax.xml.transform.TransformerException,
java.io.IOException
androidManifestPath.newAndroidManifest - the new document.javax.xml.transform.TransformerException - if an unrecoverable error occurs during the course of the
transformation.java.io.IOException - if the path is null.@NonNull public org.w3c.dom.Document getAndroidManifest()
androidManifest.@Nullable public java.lang.String getAndroidManifestPath()
null when ManifestHelper(Document, Logger)
constructor was used.