Class ApkManifestHelper


public class ApkManifestHelper extends ApkXmlResourceHelper
This helper class facilitates access to the data contained in an Android APK Manifest. In particular, the readAttributeXxx methods allow easy retrieval of attribute values by tag names, throughout the entire document.
  • Constructor Details

    • ApkManifestHelper

      public ApkManifestHelper(IApkUnit apk)
      This convenience constructor can be used to create a helper from an APK unit. A Manifest XML unit must exist under the APK unit.
      Parameters:
      apk - APK unit
    • ApkManifestHelper

      public ApkManifestHelper(IXmlUnit xml)
      Create a manifest helper around the provided manifest unit.
      Parameters:
      xml - manifest XML unit
    • ApkManifestHelper

      public ApkManifestHelper(Document doc)
      Create a manifest helper around the provided low-level XML document object.
      Parameters:
      doc - manifest XML document
  • Method Details

    • canParse

      public static boolean canParse(IApkUnit apk)
      Determine whether an APK unit has a manifest XML unit.
      Parameters:
      apk - APK unit
      Returns:
      true if a manifest can be parsed
    • prepare

      protected void prepare(Document doc)
      This implementation checks that the input XML resource is an actual Android Manifest.
      Overrides:
      prepare in class ApkXmlResourceHelper
      Parameters:
      doc - XML document
    • getXmlManifestElement

      public Element getXmlManifestElement()
      This low-level method offers access to the org.w3c.dom.Element holding the Manifest root. Use this method to retrieve any tag or attribute stored in the manifest.
      Returns:
      the manifest root element
    • getPackageName

      public String getPackageName()
      Get the manifest package name.
      Returns:
      the package name, or null if none is declared
    • getPermissions

      public List<String> getPermissions()
      Get permissions requested by the application.
      Returns:
      requested permission names
    • hasApplication

      public boolean hasApplication()
      Determine whether the manifest declares an application element.
      Returns:
      true if an application element exists
    • getApplicationName

      public String getApplicationName()
      Get the application class name.
      Returns:
      the application class name, or null if none is declared
    • getApplicationComponentFactory

      public String getApplicationComponentFactory()
      Get the application component factory class name.
      Returns:
      the component factory class name, or null if none is declared
    • isDebuggable

      public boolean isDebuggable()
      Determine whether the application is marked debuggable.
      Returns:
      true if the manifest declares a debuggable application
    • getApplicationAttribute

      public String getApplicationAttribute(String attributeName)
      Get an attribute value from the application element.
      Parameters:
      attributeName - simple attribute name
      Returns:
      the attribute value, or null if none exists
    • getApplicationDescription

      public ApkManifestHelper.ApplicationDescription getApplicationDescription()
      Build an application description.
      Returns:
      null if the manifest does not have an Application element
    • getIntendedSystemType

      public ApkManifestHelper.AndroidSystemType getIntendedSystemType()
      Infer the intended Android system type.
      Returns:
      the intended Android system type
    • getActivities

      public List<String> getActivities()
      Get activity class names.
      Returns:
      activity class names
    • getServices

      public List<String> getServices()
      Get service class names.
      Returns:
      service class names
    • getReceivers

      public List<String> getReceivers()
      Get receiver class names.
      Returns:
      receiver class names
    • getProviders

      public List<String> getProviders()
      Get provider class names.
      Returns:
      provider class names
    • getMainActivity

      public String getMainActivity()
      Get the main activity class name.
      Returns:
      the main activity class name, or null if none was found
    • getEndPointDescriptions

      public List<ApkManifestHelper.EndPointDescription> getEndPointDescriptions()
      Get descriptions for all endpoint types.
      Returns:
      endpoint descriptions
    • getActivityDescriptions

      public List<ApkManifestHelper.ActivityDescription> getActivityDescriptions()
      Get activity descriptions.
      Returns:
      activity descriptions
    • getServiceDescriptions

      public List<ApkManifestHelper.ServiceDescription> getServiceDescriptions()
      Get service descriptions.
      Returns:
      service descriptions
    • getReceiverDescriptions

      public List<ApkManifestHelper.ReceiverDescription> getReceiverDescriptions()
      Get receiver descriptions.
      Returns:
      receiver descriptions
    • getProviderDescriptions

      public List<ApkManifestHelper.ProviderDescription> getProviderDescriptions()
      Get provider descriptions.
      Returns:
      provider descriptions
    • getSdkVersion

      public int[] getSdkVersion()
      Retrieve the minimal and target Android version numbers to run the app.
      Returns:
      a tuple (minSdkVersion, targetSdkVersion)