DashO can inject checks that detect active debugging or an environment that appears to allow debugging. Use a Debugging Check when you need to detect an attached debugger. Use a Debug Enabled Check when you need to detect a debuggable application or environment.
| Check | Primary signal | Important behavior |
|---|---|---|
| Debugging Check | An active debugger | On non-Android platforms, a debugger attached after application startup might not be detected. |
| Debug Enabled Check | A debuggable application or environment | On Android, the check triggers when USB debugging is enabled. Many emulators enable it by default. |
Before you begin
- Decide whether you need to detect active debugging, a debug-enabled environment, or both.
- For a Debug Enabled Check on Android, inject the check into a class that provides
getApplicationContext(). Classes that extendandroid.content.Context, includingActivity,Application, andService, inherit this method. - If the target class does not provide
getApplicationContext(), add a method that returns the appropriate AndroidContext.
Configure an active debugging check
Configure the check under Checks > Debug in DashO, or add a DebuggingCheck annotation to one or more methods:
private static boolean debuggingFlag;
@DebuggingCheck(action="@debuggingFlag")
public void onCreate(Bundle check){
}
@DebuggingCheck(response=ResponseType.Hang)
private int computeResult(){
}The first check writes the result to debuggingFlag. The second check performs the configured response immediately when DashO detects an active debugger.
Note: On non-Android platforms, a debugger attached after the application starts might not be detected correctly.
Configure a separate debugging response
To separate detection from the response, configure the DebuggingCheck action to write its result to a Boolean field. Then configure one or more DebuggingResponse annotations to read that field through their source setting.
private static boolean debuggingFlag;
@DebuggingCheck(action="@debuggingFlag")
public void onCreate(Bundle state){
}
@DebuggingResponse(source="@debuggingFlag", response=ResponseType.Exit, probability=0.05f)
private int computeResult(){
}
@DebuggingResponse(source="@debuggingFlag", response=ResponseType.Error, probability=0.1f)
private FileInputStream readInput(){
}
Both responses use the result stored in debuggingFlag, but they run in different methods and use different response types and probabilities.
Configure a debug-enabled check
Configure the check on Checks > Debug in DashO, or add a DebugEnabledCheck annotation:
private static boolean debuggingFlag;
@DebugEnabledCheck(action="@debuggingFlag")
public void onCreate(Bundle check){
}
@DebugEnabledCheck(response=ResponseType.Hang)
private int computeResult(){
}The first check writes the result to debugEnabledFlag. The second check performs the configured response immediately when DashO detects a debug-enabled environment.
Configure a separate debug-enabled response
To separate detection from the response, configure one or more DebugEnabledResponse annotations that use the value stored by the DebugEnabledCheck:
private static boolean debuggingFlag;
@DebugEnabledCheck(action="@debuggingFlag")
public void onCreate(Bundle state){
}
@DebugEnabledResponse(source="@debuggingFlag", response=ResponseType.Exit,
probability=0.05f)
private int computeResult(){
}
@DebugEnabledResponse(source="@debuggingFlag", response=ResponseType.Error,
probability=0.1f)
private FileInputStream readInput(){
}Both responses read the value stored in debugEnabledFlag. The response runs when the value is true and according to the configured probability.