public abstract class

Instrument

extends Object
java.lang.Object
   ↳ org.probedroid.Instrument

Class Overview

The entry point of ProbeDroid which defines the callbacks indicating the change of app life cycle and also provides the interfaces for analysts to register the instrumentation gadgets for interested methods. Analysts should inherit this class as the main class of their analysis package.

 public class MyInstrument extends Instrument {
 
     @Override
     public void onApplicationStart() {
         // Do some initialization.
 
         // Register the instrumentation gadgets.
         String nameClass = "java.lang.StringBuilder";
         String nameMethod = "toString";
         String signatureMethod = "()Ljava/lang/String;";
         BundleStringBuilder bundleBuilder = new BundleStringBuilder(false, true);
         instrumentMethod(false, nameClass, nameMethod, signatureMethod,
                 bundleBuilder);
     }
 
     @Override
     public void onApplicationStop() {
         // Do some finalization.
     }
 }
 

Summary

Public Constructors
Instrument()
Public Methods
void instrumentMethod(boolean isStatic, String nameClass, String nameMethod, String signatureMethod, MethodBundle bundle)
Let analysts to register instrument gadget for the interested method.
abstract void onApplicationStart()
The callback indicating that the instrumented app is just launched.
abstract void onApplicationStop()
The callback indicating that the instrumented app is just terminated.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Instrument ()

Public Methods

public void instrumentMethod (boolean isStatic, String nameClass, String nameMethod, String signatureMethod, MethodBundle bundle)

Let analysts to register instrument gadget for the interested method. Currently, the abstract method or native method is not supported yet.

Parameters
isStatic The flag indicating whether the target method is static or not.
nameClass The name of the class defining the target method.
nameMethod The target method name.
signatureMethod The target method signature representing the data types of arguments and return value.
bundle The instrument gadget for the target method.
Throws
ClassNotFoundException The class defining the target method cannot be found.
NoSuchMethodException The target method cannot be resolved (Probably due to wrong signature).
IllegalArgumentException Illegal arguments passed to this method (Probably null String or MethodBundle).

public abstract void onApplicationStart ()

The callback indicating that the instrumented app is just launched. Analysts should override this method for initialization. Like registering the instrumentation gadgets or creating the custom profiling utilities.

public abstract void onApplicationStop ()

The callback indicating that the instrumented app is just terminated. Analysts should override this method for finalization. Like dumping the profiled information to the external storage.