Class BaseProcessManifest<A extends IActivity,S extends IService,C extends IContentProvider,B extends IBroadcastReceiver>

java.lang.Object
soot.jimple.infoflow.android.manifest.BaseProcessManifest<A,S,C,B>
All Implemented Interfaces:
Closeable, AutoCloseable, IManifestHandler<A,S,C,B>
Direct Known Subclasses:
ProcessManifest

public abstract class BaseProcessManifest<A extends IActivity,S extends IService,C extends IContentProvider,B extends IBroadcastReceiver> extends Object implements IManifestHandler<A,S,C,B>
This class provides easy access to all data of an AppManifest.
Nodes and attributes of a parsed manifest can be changed. A new byte compressed manifest considering the changes can be generated.
Author:
Steven Arzt, Stefan Haas, Mario Schlipf
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • handle

      protected void handle(InputStream manifestIS) throws IOException
      Initialises the BaseProcessManifest by parsing the manifest provided by the given InputStream.
      Parameters:
      manifestIS - InputStream for an AppManifest.
      Throws:
      IOException - if an I/O error occurs.
      XmlPullParserException - can occur due to a malformed manifest.
    • getAXml

      public AXmlHandler getAXml()
      Returns the handler which parsed and holds the manifest's data.
      Returns:
      Android XML handler
    • getManifest

      public AXmlNode getManifest()
      The unique manifest node of the AppManifest.
      Returns:
      manifest node
    • getApplication

      public IAndroidApplication getApplication()
      Description copied from interface: IManifestHandler
      Gets the Android application object
      Specified by:
      getApplication in interface IManifestHandler<A extends IActivity,S extends IService,C extends IContentProvider,B extends IBroadcastReceiver>
      Returns:
      The Android application object
    • getContentProviders

      public IComponentContainer<C> getContentProviders()
      Description copied from interface: IManifestHandler
      Returns all content providers in the Android app
      Specified by:
      getContentProviders in interface IManifestHandler<A extends IActivity,S extends IService,C extends IContentProvider,B extends IBroadcastReceiver>
      Returns:
      list with all providers
    • getServices

      public IComponentContainer<S> getServices()
      Description copied from interface: IManifestHandler
      Returns all services providers in the Android app
      Specified by:
      getServices in interface IManifestHandler<A extends IActivity,S extends IService,C extends IContentProvider,B extends IBroadcastReceiver>
      Returns:
      list with all services
    • getComponentType

      public ComponentType getComponentType(String className)
      Gets the type of the component identified by the given class name
      Parameters:
      className - The class name for which to get the component type
      Returns:
      The component type of the given class if this class has been registered as a component in the manifest file, otherwise null
    • getActivities

      public IComponentContainer<A> getActivities()
      Description copied from interface: IManifestHandler
      Returns all activities in the Android app
      Specified by:
      getActivities in interface IManifestHandler<A extends IActivity,S extends IService,C extends IContentProvider,B extends IBroadcastReceiver>
      Returns:
      list with all activities
    • getAliasActivities

      public List<AXmlNode> getAliasActivities()
      Returns a list containing all nodes with tag activity-alias
      Returns:
      list with all alias activities
    • getBroadcastReceivers

      public IComponentContainer<B> getBroadcastReceivers()
      Description copied from interface: IManifestHandler
      Returns all broadcast receivers providers in the Android app
      Specified by:
      getBroadcastReceivers in interface IManifestHandler<A extends IActivity,S extends IService,C extends IContentProvider,B extends IBroadcastReceiver>
      Returns:
      list with all receivers
    • getProvider

      public AXmlNode getProvider(String name)
      Returns the provider which has the given name.
      Parameters:
      name - the provider's name
      Returns:
      provider with name
    • getService

      public AXmlNode getService(String name)
      Returns the service which has the given name.
      Parameters:
      name - the service's name
      Returns:
      service with name
    • getActivity

      public AXmlNode getActivity(String name)
      Returns the activity which has the given name.
      Parameters:
      name - the activitie's name
      Returns:
      activitiy with name
    • getAliasActivity

      public AXmlNode getAliasActivity(String name)
      Returns the alias analysis which has the given name
      Parameters:
      name - the alias activity's name
      Returns:
      alias activity with name
    • getReceiver

      public AXmlNode getReceiver(String name)
      Returns the receiver which has the given name.
      Parameters:
      name - the receiver's name
      Returns:
      receiver with name
    • getNodeWithName

      protected AXmlNode getNodeWithName(List<AXmlNode> list, String name)
      Iterates over list and checks which node has the given name.
      Parameters:
      list - contains nodes.
      name - the node's name.
      Returns:
      node with name.
    • getAliasActivityTarget

      public AXmlNode getAliasActivityTarget(AXmlNode aliasActivity)
      Returns the target activity specified in the targetActivity attribute of the alias activity
      Parameters:
      aliasActivity -
      Returns:
      activity
    • isAliasActivity

      public static boolean isAliasActivity(AXmlNode activity)
      Returns whether the given activity is an alias activity or not
      Parameters:
      activity -
      Returns:
      True if the activity is an alias activity, False otherwise
    • getAllActivities

      public ArrayList<AXmlNode> getAllActivities()
    • getOutput

      public byte[] getOutput()
      Returns the Manifest as a compressed android xml byte array. This will consider all changes made to the manifest and application nodes respectively to their child nodes.
      Returns:
      byte compressed AppManifest
      See Also:
    • getPackageName

      public String getPackageName()
      Gets the application's package name
      Specified by:
      getPackageName in interface IManifestHandler<A extends IActivity,S extends IService,C extends IContentProvider,B extends IBroadcastReceiver>
      Returns:
      The package name of the application
    • getVersionCode

      public int getVersionCode()
      Gets the version code of the application. This code is used to compare versions for updates.
      Returns:
      The version code of the application
    • getVersionName

      public String getVersionName()
      Gets the application's version name as it is displayed to the user
      Returns:
      The application#s version name as in pretty print
    • getMinSdkVersion

      public int getMinSdkVersion()
      Gets the minimum SDK version on which this application is supposed to run
      Returns:
      The minimum SDK version on which this application is supposed to run
    • getTargetSdkVersion

      public int getTargetSdkVersion()
      Gets the target SDK version for which this application was developed
      Returns:
      The target SDK version for which this application was developed
    • getPermissions

      public Set<String> getPermissions()
      Gets the permissions this application requests
      Returns:
      The permissions requested by this application
    • getIntentFilter

      public Set<String> getIntentFilter()
      * Gets the intent-filter components this application used
      Returns:
      the intent filter used by this application
    • getHardware

      public Set<String> getHardware()
      Gets the hardware components this application requests
      Returns:
      the hardware requested by this application
    • addPermission

      public void addPermission(String permissionName)
      Adds a new permission to the manifest.
      Parameters:
      permissionName - complete permission name e.g. "android.permission.INTERNET"
    • addProvider

      public void addProvider(AXmlNode node)
      Adds a new provider to the manifest
      Parameters:
      node - provider represented as an AXmlNode
    • addReceiver

      public void addReceiver(AXmlNode node)
      Adds a new receiver to the manifest
      Parameters:
      node - receiver represented as an AXmlNode
    • addActivity

      public void addActivity(AXmlNode node)
      Adds a new activity to the manifest
      Parameters:
      node - activity represented as an AXmlNode
    • addService

      public void addService(AXmlNode node)
      Adds a new service to the manifest
      Parameters:
      node - service represented as an AXmlNode
    • close

      public void close()
      Closes this apk file and all resources associated with it
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • getLaunchableActivityNodes

      public Set<AXmlNode> getLaunchableActivityNodes()
      Returns all activity nodes that are "launchable", i.e. that are called when the user clicks on the button in the launcher.
      Returns:
      all launchable activity nodes
    • expandClassName

      public String expandClassName(String className)
      Generates a full class name from a short class name by appending the globally-defined package when necessary
      Parameters:
      className - The class name to expand
      Returns:
      The expanded class name for the given short name
    • getArscParser

      public ARSCFileParser getArscParser()
      Gets the Android resource parser
      Returns:
      The Android resource parser
    • createComponentFactory

      protected abstract BaseProcessManifest.IComponentFactory<A,S,C,B> createComponentFactory()
      Creates a factory that can instantiate data objects for Android components
      Returns:
      The new factory