Class AndroidModel
- java.lang.Object
-
- com.ibm.wala.dalvik.ipa.callgraph.androidModel.AndroidModel
-
- All Implemented Interfaces:
IClassHierarchyDweller
- Direct Known Subclasses:
ExternalModel
,IntentModel
,MicroModel
,MiniModel
,SystemServiceModel
,UnknownTargetModel
public class AndroidModel extends Object implements IClassHierarchyDweller
The model to be executed at application start. This method models the lifecycle of an Android Application. By doing so it calls all AndroidEntryPoints set in the AnalysisOptions.Between the calls to the AndroidEntryPoints special behavior is inserted. You can change that behavior by implementing an AbstractAndroidModel or set one of the existing ones in the AnalysisOptions. Additionally care of how types are instantiated is taken. You can change this behavior by setting the IInstanciationBehavior in the AnalysisOptions. Smaller Models exist: * MiniModel calls all components of a specific type (for example all Activities) * MicroModel calls a single specific component * ExternalModel doesn't call anything but fiddles with the data on its own All these Models are added to a synthetic AndroidModelClass.
-
-
Field Summary
Fields Modifier and Type Field Description protected VolatileMethodSummary
body
protected boolean
built
protected AnalysisCache
cache
protected IClassHierarchy
cha
protected static boolean
doBoot
protected IClass
klass
protected SummarizedMethod
model
MethodReference
mRef
protected AnalysisOptions
options
protected AnalysisScope
scope
-
Constructor Summary
Constructors Constructor Description AndroidModel(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
build(Atom name)
Generates the model on a sub-set of Entrypoints.protected void
build(Atom name, Collection<? extends AndroidEntryPoint> entrypoints)
Generate the SummarizedMethod for the model (in this.model).IClassHierarchy
getClassHierarchy()
IClass
getDeclaringClass()
The class the Method representing this Model resides in.Descriptor
getDescriptor()
SummarizedMethod
getMethod()
Building the SummarizedMethod is delayed upon the first class to this method.SummarizedMethod
getMethodAs(MethodReference asMethod, TypeReference caller, IntentStarters.StartInfo info, CGNode callerNd)
Get method of the Model in an other Signature.IMethod
getMethodEncap()
Creates an "encapsulated" version of the model.Atom
getName()
TypeName
getReturnType()
boolean
isStatic()
protected boolean
selectEntryPoint(AndroidEntryPoint ep)
Overridden by models to restraint Entrypoints.String
toString()
-
-
-
Field Detail
-
mRef
public MethodReference mRef
-
cha
protected IClassHierarchy cha
-
options
protected AnalysisOptions options
-
cache
protected AnalysisCache cache
-
scope
protected final AnalysisScope scope
-
body
protected VolatileMethodSummary body
-
doBoot
protected static boolean doBoot
-
klass
protected IClass klass
-
built
protected boolean built
-
model
protected SummarizedMethod model
-
-
Constructor Detail
-
AndroidModel
public AndroidModel(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache)
-
-
Method Detail
-
build
protected void build(Atom name) throws CancelException
Generates the model on a sub-set of Entrypoints. AsksselectEntryPoint(AndroidEntryPoint)
for each EntryPoint known to the AndroidEntryPointManager, if the EntryPoint should be included in the model. Then calls#build(Atom, Iterable extends Entrypoint>)
on these.- Parameters:
name
- The name the generated method will be known as- Throws:
CancelException
-
getName
public Atom getName()
-
isStatic
public boolean isStatic()
-
getReturnType
public TypeName getReturnType()
-
getDescriptor
public Descriptor getDescriptor() throws CancelException
- Throws:
CancelException
-
build
protected void build(Atom name, Collection<? extends AndroidEntryPoint> entrypoints) throws CancelException
Generate the SummarizedMethod for the model (in this.model). The actual generated model depends on the on the properties of this overloaded class. Most generated methods should reside in the AndroidModelClass and take AndroidComponents as well as some parameters (these marked REUSE) to the EntryPoints of the components. UsegetMethod()
to retrieve the method generated here or getMethodAs to get a version which is wrapped to another signature.- Parameters:
name
- The name the generated method will be known asentrypoints
- The functions to call additionally to boot-code and XXX- Throws:
CancelException
-
getMethod
public SummarizedMethod getMethod() throws CancelException
Building the SummarizedMethod is delayed upon the first class to this method.- Returns:
- the method for this model as generated by build()
- Throws:
CancelException
-
getDeclaringClass
public IClass getDeclaringClass()
The class the Method representing this Model resides in. Most likely the AndroidModelClass.
-
selectEntryPoint
protected boolean selectEntryPoint(AndroidEntryPoint ep)
Overridden by models to restraint Entrypoints. For each entrypoint this method is queried if it should be part of the model.- Parameters:
ep
- The EntryPoint in question- Returns:
- if the given EntryPoint shall be part of the model
-
getMethodAs
public SummarizedMethod getMethodAs(MethodReference asMethod, TypeReference caller, IntentStarters.StartInfo info, CGNode callerNd) throws CancelException
Get method of the Model in an other Signature. Generates a new Method that wraps the model so it can be called using the given Signature. Flags control the behavior of that wrapper. Arguments to the wrapping function are "connected through" to the model based on their type only, so if there are multiple Arguments of the same type this may yield to unexpected connections. This method is called by the IntentCoentextInterpreter.- Parameters:
asMethod
- The signature to generateflags
- Control the behavior of the wrapper, may be nullcaller
- The class of the caller; only needed depending on the flagsinfo
- The IntentSterter usedcallerNd
- CGNoodle of the caller - may be null- Returns:
- A wrapper that calls the model
- Throws:
CancelException
- See Also:
IntentContextInterpreter
,IntentStarters
-
getMethodEncap
public IMethod getMethodEncap() throws CancelException
Creates an "encapsulated" version of the model. The generated method will take no parameters. New instances for REUSE-Parameters will be created. This variant is useful for the start of an analysis.- Throws:
CancelException
-
getClassHierarchy
public IClassHierarchy getClassHierarchy()
- Specified by:
getClassHierarchy
in interfaceIClassHierarchyDweller
-
-