Class AndroidEntryPointManager

java.lang.Object
com.ibm.wala.dalvik.util.AndroidEntryPointManager
All Implemented Interfaces:
Serializable

public final class AndroidEntryPointManager extends Object implements Serializable
Model configuration and Global list of entrypoints.

See the single settings for further description.

Author:
Tobias Blaschke <code@tobiasblaschke.de>
See Also:
  • Field Details

  • Method Details

    • EPContainAny

      public static boolean EPContainAny(AndroidComponent compo)
      Determines if any EntryPoint extends the specified component.
    • reset

      public static void reset()
    • getComponents

      public static Set<TypeReference> getComponents()
    • doFlatComponents

      public boolean doFlatComponents()
      Controlls the initialization of Components.

      See setDoFlatComponents(boolean).

    • setDoFlatComponents

      public boolean setDoFlatComponents(boolean flatComponents)
      Controlls the initialization of Components.

      If flatComponents is active an Instance of each Component of the application is generated in the AndroidModelClass. Whenever the model requires a new instance of a component this "globalone" is used.

      This resembles the seldomly used Flat-Setting of the start of components in Android. Activating this generates a more conservative model.

      The default is to deactivate this behavior.

      Returns:
      previous setting
    • getInstantiationBehavior

      public IInstantiationBehavior getInstantiationBehavior(IClassHierarchy cha)
      Controls the instantiation of variables in the model.

      See setInstantiationBehavior(IInstantiationBehavior).

      Parameters:
      cha - Optional parameter given to the IInstantiationBehavior
      Returns:
      DefaultInstantiationBehavior if no other behavior has been set
    • setInstantiationBehavior

      public IInstantiationBehavior setInstantiationBehavior(IInstantiationBehavior instantiation)
      Controls the instantiation of variables in the model.

      Controlls on which occasions a new instance to a given type shall be generated and when to reuse an existing instance.

      This also changes the parameters to the later model.

      The default is DefaultInstantiationBehavior.

      See setDoFlatComponents(boolean) for more instantiation settings that affect components

      Returns:
      the previous IInstantiationBehavior
      See Also:
    • getProgressMonitor

      public MonitorUtil.IProgressMonitor getProgressMonitor()
      Can be used to indicate the progress or to cancel operations.
      Returns:
      a NullProgressMonitor or the one set before.
    • setProgressMonitor

      public MonitorUtil.IProgressMonitor setProgressMonitor(MonitorUtil.IProgressMonitor monitor)
      Set the monitor returned by getProgressMonitor().
    • getDoBootSequence

      public boolean getDoBootSequence()
      Whether to generate a global android environment.

      See the setDoBootSequence(boolean) documentation.

      Returns:
      the setting, defaults to true
    • setDoBootSequence

      public boolean setDoBootSequence(boolean doBootSequence)
      Whether to generate a global android environment.

      Inserts some code ath the start of the model to attach some Android-context. This is mainly interesting for inter-application communication.

      It's possible to analyze android-applications without creating these structures and save some memory. In this case some calls to the OS (like getting the Activity-manager or so) will not be able to be resolved.

      It is to be noted that the generated information is far from beeing complete.

      The default is to insert the code.

      Returns:
      the previous setting of doBootSequence
    • makeModelBehavior

      public AbstractAndroidModel makeModelBehavior(VolatileMethodSummary body, TypeSafeInstructionFactory insts, SSAValueManager paramManager, Iterable<? extends Entrypoint> entryPoints)
      What special handling to insert into the model.

      At given points in the model (called labels) special code is inserted into it (like loops). This setting controls what code is inserted there.

      Returns:
      An object that handles "events" that occur while generating the model.
      Throws:
      IllegalStateException - if initialization fails
      See Also:
    • getModelBehavior

      public Class<? extends AbstractAndroidModel> getModelBehavior()
      The behavior set using setModelBehavior(Class).

      Use makeModelBehavior(com.ibm.wala.ipa.summaries.VolatileMethodSummary, com.ibm.wala.core.util.ssa.TypeSafeInstructionFactory, com.ibm.wala.core.util.ssa.SSAValueManager, java.lang.Iterable<? extends com.ibm.wala.ipa.callgraph.Entrypoint>) to retrieve an instance of this class.

      If no class was set it returns null, makeModelBehavior will generate a LoopAndroidModel by default.

      Returns:
      null or the class set using setModelBehavior
    • setModelBehavior

      public void setModelBehavior(Class<? extends AbstractAndroidModel> abstractAndroidModel)
      Set the class instantiated by makeModelBehavior.
      Throws:
      IllegalArgumentException - if the abstractAndroidModel is null
    • setPackage

      public void setPackage(String pack)
      Set the package of the analyzed application.

      Setting the package of the application is completely optional. However if you do it it helps determining whether an Intent has an internal target.

      If a AndroidManifest.xml is read this getts set automaticly.

      Parameters:
      pack - The package of the analyzed application
      Throws:
      IllegalArgumentException - if the package has already been set and the value of the packages differ. Or if the given package is null.
    • getPackage

      public String getPackage()
      Return the package of the analyzed app.

      This only returns a value other than null if the package has explicitly been set using setPackage (which is for example called when reading in the Manifest).

      If you didn't read the manifest you can still try and retrieve the package name using guessPackage().

      See: setPackage(String)

      Returns:
      The package or null if it was indeterminable.
      See Also:
    • guessPackage

      public String guessPackage()
      Get the package of the analyzed app.

      If the package has been set using setPackage() return this value. Else try and determine the package based on the first entrypoint.

      Returns:
      The package or null if it was indeterminable.
      See Also:
    • registerIntent

      public void registerIntent(Intent intent)
      Set more information to an Intent.

      You can call this method multiple times on the same Intent as long as you don't lower the associated information. So if you only want to change a specific value of it it is more safe to retrieve the Intent first and union it yourself before registering it.

      Parameters:
      intent - An Intent with more or the same information as known to the system before.
      Throws:
      IllegalArgumentException - if you lower the information on an already registered Intent or the information is incompatible.
      See Also:
    • registerIntentForce

      public void registerIntentForce(Intent intent)
      Set intent possibly overwriting more specific information.

      If you are sure that you want to override an existing registered Intent with information that is possibly incompatible with the information originally set.

    • setOverride

      public void setOverride(Intent from, Intent to)
      Override target of an Intent (or add an alias).

      Use this for example to add an internal target to an implicit Intent, add an alias to an Intent, resolve a System-name to an internal Intent, do weird stuff...

      None of the Intents have to be registered before. However if the source is registered you may not lower information on it.

      Currently only one target to an Intent is supported! If you want to emulate multiple Targets you may have to add a synthetic class and register it as an Intent. If the target is not set to Internal multiple targets may implicitly emulated. See the Documentation for these targets for detail.

      If you only intend to make an Intent known see registerIntent(Intent).

      Parameters:
      from - the Intent to override
      to - the new Intent to resolve once 'from' is seen
      Throws:
      IllegalArgumentException - if you override an Intent with itself
      See Also:
    • setOverrides

      public void setOverrides(Map<Intent,Intent> overrides)
      Set multiple overrides at the same time.

      See setOverride(Intent, Intent).

    • setOverrideForce

      public void setOverrideForce(Intent from, Intent to)
      Just throw in the override.

      See setOverride(Intent, Intent).

    • getIntent

      public Intent getIntent(Intent intent)
      Get Intent with applied overrides.

      If there are no overrides or the Intent is not registered return it as is.

      See setOverride(Intent, Intent). See registerIntent(Intent).

      Parameters:
      intent - The intent to resolve
      Returns:
      where to resolve it to or the given intent if no information is available

      TODO: TODO: Malicious Intent-Table could cause endless loops

    • existsIntentFor

      public boolean existsIntentFor(TypeName clazz)
      Searches Intent specifications for the occurrence of clazz.
      Returns:
      the intent is registered or there exists an override.
    • addCallSeen

      public void addCallSeen(CallSiteReference from, Intent intent)
      DO NOT CALL! - This is for IntentContextSelector.

      Add information that an Intent was called to the later summary. This is for information-purpose only and does not change any behavior.

      Intents are added as seen - without any resolved overrides.

    • getSeen

      public Map<CallSiteReference,Intent> getSeen()
      Return all Sites, that start Components based on Intents.
    • setAllowIntentRerouting

      public boolean setAllowIntentRerouting(boolean allow)
      Controll modification of an Intents target after construction.

      After an Intent has been constructed its target may be changed using functions like setAction or setComponent. This setting controlls the behavior of the model on occurrence of such a function:

      If set to false the Intent will be marked as unresolvable.

      If set to true the first occurrence of such a function changes the target of the Intent unless:

      * The Intent was explicit and the new action is not: The call gets ignored * The Intent was explicit and the new target is explicit: It becomes unresolvable * It's the second occurrence of such a function: It becomes unresolvable * It was resolvable: It becomes unresolvable

      The default is to activate this behavior.

      Parameters:
      allow - Allow rerouting as described
      Returns:
      previous setting
    • isAllowIntentRerouting

      public boolean isAllowIntentRerouting()
      Controll modification of an Intents target after construction.

      See: setAllowIntentRerouting(boolean).

      Returns:
      the set behavior or true, the default