PreEmptive Protection™ DashO™ can inject checks into Android applications or libraries to detect if they are being run on an emulator. The Emulator Checks and Responses are configured on the Checks - Emulator screen or by adding code annotations.
Emulator Check
To detect if an application is being run on an emulator, place an EmulatorCheck on one or more methods in your application. DashO adds code that performs several runtime checks that determine if it is being run on an emulator. This Check can be configured as described in the Overview.
An application can contain multiple uses of EmulatorCheck
with various configurations. Using more than one Check or mixing the Responses will hamper attackers.
private static boolean emulatorFlag;
@EmulatorCheck(action="@emulatorFlag")
public void onCreate(Bundle check){
}
@EmulatorCheck(response=ResponseType.Hang)
private int computeResult(){
}
Note: The Emulator Check for Android requires access to the application's context; it expects a
getApplicationContext()
method to exist on the class where it is being injected. Classes extendingandroid.context.Context
, likeandroid.app.Activity
,android.app.Application
,android.app.Service
, etc. will inheritgetApplicationContext()
, and require no additional changes. Otherwise, you will need to add agetApplicationContext()
method and make sure it returns a properContext
.
Emulator Response
The EmulatorResponse annotation interacts with the EmulatorCheck. This Response can be configured as described in the Overview.
private static boolean emulatorFlag;
@EmulatorCheck(action="@emulatorFlag")
public void onCreate(Bundle state){
}
@EmulatorResponse(source="@emulatorFlag", response=ResponseType.Exit, probability=0.05f)
private int computeResult(){
}
@EmulatorResponse(source="@emulatorFlag", response=ResponseType.Error, probability=0.1f)
private FileInputStream readInput(){
}