AgeBot is an automated black-box testing framework for detecting aging-related bugs in Android applications using resource-aware reinforcement learning and other strategies.
- ✨ Features
- 🏗️ Architecture
- 📦 Prerequisites
- 🚀 Installation
- ⚙️ Configuration
- 🎯 Usage
- 🧮 Supported Algorithms
- 📊 Analysis Tools
- 📱 Tested Applications
- 📧 Contact
-
Multiple Testing Strategies: Supports various algorithms for aging related bugs detection:
- Resource-aware Reinforcement Learning
- State Coverage-based Reinforcement Learning
- Random Exploration
- Ablation experiment variants
-
Comprehensive Resource Monitoring: Tracks various Android system resources including:
- Views, ViewRootImpl, AppContexts, Activities
- Assets, AssetManagers
- Local/Proxy Binders
- Memory (Java Heap, Native Heap, and RSS)
- File Descriptors, Database Connections
- Wake Locks, Sockets
- CPU
-
Automated Setup: Automatic APK installation, permission handling, and login automation
-
Multi-Device Parallel Testing: Support for parallel testing across multiple devices
AgeBot/
├── agent/ # Agent implementations
│ ├── Q.py # State coverage Q-Learning agent (supports multiple exploration modes)
│ ├── Random.py # Random exploration agent
│ ├── ResourceQLearning.py # Resource-sensitive Q-Learning agent
│ └── global_data.py # Global configuration and state variables
├── env/ # Testing environment implementations
│ ├── aut_env.py # Android application testing environment (Gymnasium-based)
│ └── mock_env.py # Mock environment for testing
├── apk/ # APK management and analysis tools
│ ├── apk.py # APK installation and component extraction
│ └── apktool/ # APK decompilation tool
├── resources/ # Resource monitoring utilities
│ └── resource.py # Resource data collection and analysis
├── tools/ # Experiment analysis tools
│ ├── RQ1_effectiveness.py # RQ1: Effectiveness analysis
│ ├── RQ2_efficiency.py # RQ2: Efficiency analysis
│ ├── RQ3_precision.py # RQ3: Precision analysis
│ ├── RQ4_ablation.py # RQ4: Ablation experiment analysis
│ └── RQ5_characterization.py # RQ5: Characterization analysis
├── result/ # Test results storage directory
├── logs/ # Log storage directory
├── main.py # Main entry point (CLI interface)
├── utils.py # Utility functions and logging system
├── appium_manager.py # Appium process manager
└── requirement.txt # Python dependencies
- Python: 3.7 or higher
- Android Debug Bridge (ADB): Installed and accessible in system PATH
- Appium Server: Version 2.0+
- Node.js: Required for running Appium
- Android Devices/Emulators:
- Rooted devices or Android 7.0+ emulators
- USB Debugging enabled
git clone https://github.com/GIST-NJU/AgeBot.git
cd AgeBotpip install -r requirement.txtEnsure ADB is in your system PATH and accessible from command line:
adb versionnpm install -g appium
appium driver install uiautomator2- Enable USB Debugging on your Android device(s)
- For emulators, use Android Virtual Devices (AVD)
Place the APK files to be tested in the apk/ directory.
Edit agent/global_data.py to specify the applications you want to test:
apps = {
"app_name": "apk/path/to/app.apk",
# Add more applications here
}
N = 1 # Number of parallel devices- Single Device Mode: Default port 4723
- Multi-Device Mode: Ports 4723, 4725, 4727, ... (incremental ports)
Configure ports in agent/global_data.py:
ports = [4723, 4725, 4727] # Configure based on number of devicesCreate a config.json file in the project root:
{
"wechat_sendkey": "your_sendkey_here",
"other_settings": {
"debug": false,
"max_retries": 3
}
}Or set environment variable:
export WECHAT_SENDKEY="your_sendkey_here"# Test a single application with default algorithm
python main.py --app newpipe --algo q_res --duration 3600
# Test with all algorithms
python main.py --app newpipe --algo all --duration 3600
# Specify multiple algorithms
python main.py --app newpipe --algo random,q_res --duration 3600| Argument | Description | Default |
|---|---|---|
--app |
Application name to test (must be defined in global_data.py) | Required |
--algo |
Testing algorithm (use all to run all algorithms) |
q_res |
--duration |
Duration of each test run in seconds | 3600 |
--rounds |
Number of rounds per algorithm | 1 |
--device |
Specify device name | Auto-detected |
--port |
Appium port | 4723 |
- Connect one rooted Android device or start one emulator
- Run the test:
python main.py --app newpipe --algo q_res_v2 --duration 3600- Connect multiple devices or start multiple emulators
- Configure
global_data.py:N = 3 # Number of devices ports = [4723, 4725, 4727]
- Run parallel tests:
python main.py --app all --algo all --duration 3600 --rounds 3| Algorithm | Description |
|---|---|
random |
Random exploration (baseline comparison) |
q_res_v2 |
Resource-aware Q-Learning |
q_cov |
State coverage Q-Learning (maximize state space exploration) |
| Algorithm | Description |
|---|---|
agebot_r |
Removes smoothing, normalization and scaling from resource sensitivity reward |
agebot_b |
Removes bug reward component |
agebot_e |
Fixed ε-greedy (no decay) |
The tools/ directory contains experiment analysis scripts:
| File | Function |
|---|---|
RQ1_effectiveness.py |
Analyze effectiveness of each algorithm in detecting resource leaks |
RQ2_efficiency.py |
Analyze testing efficiency (time, state coverage rate) |
RQ3_precision.py |
Analyze detection precision and false positive rate |
RQ4_ablation.py |
Ablation experiment results analysis |
RQ5_characterization.py |
Resource leak characterization analysis |
The framework has been tested on 26 real-world open-source Android applications. The table below shows the details of each application under test.
| Name | Category | Ver. | #Ins. | #Stars | #LOC | #Act. |
|---|---|---|---|---|---|---|
| Squircle CE | Development | 2025.1.3 | 10K+ | 1.6K+ | 192,527 | 1 |
| Easter Eggs | Development | 3.3.0 | 50K+ | 979 | 32,771 | 44 |
| Gadgetbridge | Development | 0.84.0 | 10K+ | 4.4K+ | 221,736 | 87 |
| SelfPrivacy | Multimedia | 0.12.2 | 100+ | 12 | 6,043 | 2 |
| Souvenirs | Multimedia | 2.9.5 | 500+ | 14 | 9,206 | 4 |
| Tuner | Multimedia | 1.56 | 1M+ | 186 | 9,502 | 3 |
| Recurring Expense Tracker | Finance Manager | 0.19.5 | 1K+ | 326 | 24,601 | 4 |
| Money Manager Ex | Finance Manager | 1.8.1 | 10K+ | 1.9K+ | 41,537 | 41 |
| oinkoin | Finance Manager | 1.2.1 | 1K+ | 328 | 39,893 | 2 |
| Butterfly | Note | 2.2.3 | 5K+ | 1.5K+ | 6,043 | 5 |
| Saber | Note | 1.29.5 | 10K+ | 4K+ | 71,434 | 3 |
| NeuroLab | Sports & Health | 1.0.0 | 10K+ | 163 | 8,284 | 15 |
| Broccoli | Sports & Health | 1.4.3 | 1K+ | 3.3K+ | 9,452 | 6 |
| Food You | Sports & Health | 3.1.0 | 3.3K+ | 185 | 78,894 | 4 |
| Praktika Vortaro | Translation & Dictionary | 0.26 | 5K+ | 8 | 3,503 | 5 |
| PReVo | Translation & Dictionary | 0.27 | 10K+ | 36 | 4,365 | 5 |
| Spell4Wiki | Translation & Dictionary | 3.3 | 10K+ | 27 | 53,587 | 16 |
| News Reader | News | 1.0.10 | 10K+ | 21 | 7,358 | 7 |
| AntennaPod | News | 3.6.0 | 1M+ | 7.3K+ | 23,793 | 12 |
| taz | News | 1.9.3 | 100K+ | 44 | 43,892 | 13 |
| bilimiao | Internet | 2.4.6 | 10K+ | 2.5K+ | 151,911 | 9 |
| RedReader | Internet | 1.24.1 | 100K+ | 2.1K+ | 62,750 | 23 |
| NewPipe | Internet | 0.27.4 | 5M+ | 35.3K+ | 57,363 | 12 |
| Privacy Browser | Browser | 3.19.3 | 5K+ | N/A | 236,260 | 11 |
| DuckDuckGo | Browser | 5.248.0 | 50M+ | 4.4K+ | 3,690 | 95 |
| Firefox | Browser | 139.0.3 | 100M+ | 10.2K+ | 1,189,903 | 20 |
| FairEmail | 1.2310 | 1M+ | 4.1K+ | 1,322,763 | 23 | |
| K-9 Mail | 9.0b3 | 5M+ | 12.6K+ | 162,720 | 26 | |
| Delta Chat | 2.35.0 | 500K+ | 1.5K+ | 124,811 | 38 |
Note:
- #Ins. and #Stars denote the number of installs on Google Play and the number of stars on GitHub, respectively.
- #LOC and #Act. represent the number of code lines and Activities, respectively (K=1,000, M=1,000,000).
- Applications marked as
no need to logininglobal_data.pycan be tested without login automation.
For questions or support, please open an issue on GitHub.
Note: This tool is for research and testing purposes only. Always ensure you have permission to test applications and follow responsible disclosure practices when reporting bugs.