Android's default kernel scheduler often makes suboptimal decisions — small cores end up doing heavy work while big cores sit idle. This "small cores working, big cores watching" problem leads to:
- High CPU load on efficiency cores while performance cores remain underutilized
- Excessive heat due to inefficient workload distribution
- Poor performance as tasks don't migrate to idle high-performance cores
- Scheduler resets that override manual affinity settings
Thread Affinity Manager solves these issues by letting you pin specific threads to your preferred CPU cores. Using a loop-based configuration system, it continuously enforces your affinity rules, ensuring threads with the same name always run on designated cores — regardless of what the kernel scheduler decides.
A powerful Android application for monitoring and managing thread CPU affinity. Requires Root access.
Optimized for ZTE, Nubia, and RedMagic devices.
The app automatically detects your CPU configuration by reading the maximum frequency of each core, then intelligently groups cores into categories (Small/Medium/Large). This means it works with various CPU architectures:
- Snapdragon 8 Gen2/Gen3 (1+4+3 or 1+3+4 layout)
- Snapdragon 8 Gen1 (1+3+4 layout)
- Snapdragon 888/870 (1+3+4 layout)
- MediaTek Dimensity series
- Other ARM big.LITTLE architectures
While the app works on most rooted Android devices, the CPU boost configurations are specifically tuned for:
- ZTE series
- Nubia series
- RedMagic gaming phones (RedMagic 8 Pro, 9 Pro, etc.)
The boost parameters target Nubia's kernel (e.g., cpufreq_ctrl, walt scheduler), but core affinity features work universally.
- Real-time Thread Monitoring: View all threads of target application with CPU usage
- CPU Affinity Configuration: Bind specific threads to designated CPU cores
- Floating Window Monitor: Always-on-top overlay showing CPU frequencies, loads, and thread status
- System Thread Management: Configure affinity for system processes (surfaceflinger, system_server)
- Configuration Persistence: Save and auto-apply affinity settings
- Automatic CPU boost configuration (disable EAS, core_ctl, etc.)
- Aggressive frequency scaling parameters
- Scheduler parameter tuning to prevent affinity reset
The CPU boost commands are located in FloatingWindowService.java → applyAffinityInBackground() method. These commands are executed every 10 seconds to prevent the system from resetting the settings.
- Minimized/Maximized floating window modes
- Adjustable transparency (5 levels)
- Draggable window position
- Color-coded CPU core indicators (small/medium/large cores)
- Android Studio or Gradle CLI
- Android SDK 34+
- NDK 25.x or higher
- CMake 3.22.1+
- Android 8.0+ (API 26+)
- Root access (Magisk recommended)
- Overlay permission
- Create
local.propertieswith SDK/NDK paths:
sdk.dir=C\:\\Users\\YourName\\AppData\\Local\\Android\\Sdk
ndk.dir=C\:\\Users\\YourName\\AppData\\Local\\Android\\Sdk\\ndk\\25.2.9519653- Build via command line:
cd ThreadAffinityManager
./gradlew assembleDebug- APK output:
app/build/outputs/apk/debug/app-debug.apk
- Install APK on rooted device
- Grant overlay permission when prompted
- Select target application from the app list
- Tap "Start Floating Monitor" to launch overlay
- Click on any thread in the floating window to configure its CPU affinity
- Configuration is auto-saved and applied every 10 seconds
| English | 中文 |
|---|---|
![]() |
![]() |
| Floating Monitor | Thread Affinity Selection |
|---|---|
![]() |
![]() |
- Floating Monitor: Shows CPU frequencies, loads, and thread list with CPU usage
- Thread Affinity: Click any thread to select which CPU cores it should run on
# Start monitoring for specific package
am start -a com.threadaffinity.QUICK_START -e package com.example.app- Tap header: Drag to move window
- α button: Cycle through transparency levels
- − button: Minimize to compact view
- × button: Close and exit app
The app automatically detects your CPU layout. Example for Snapdragon 8 Gen2:
| Cores | Type | Mask |
|---|---|---|
| 0-2 | Small (Efficiency) | 0x07 |
| 3-6 | Medium (Performance) | 0x78 |
| 7 | Large (Prime) | 0x80 |
For other CPUs, the app reads /sys/devices/system/cpu/cpuX/cpufreq/cpuinfo_max_freq and groups cores by their maximum frequency automatically.
Configurations are stored as JSON files in the app's internal storage.
{
"packageName": "com.example.game",
"appName": "Example Game",
"timestamp": 1704067200000,
"threadAffinities": {
"GameThread": 64,
"RenderThread": 128,
"AudioTrack": 56
}
}{
"packageName": "_system_global_",
"appName": "System Global",
"threadAffinities": {
"surfaceflinger": 224,
"RenderEngine": 224,
"InputDispatcher": 48
}
}| Value | Binary | Cores |
|---|---|---|
| 7 (0x07) | 00000111 | 0,1,2 (Small) |
| 56 (0x38) | 00111000 | 3,4,5 (Medium) |
| 120 (0x78) | 01111000 | 3,4,5,6 (Medium) |
| 64 (0x40) | 01000000 | 6 |
| 128 (0x80) | 10000000 | 7 (Large) |
| 192 (0xC0) | 11000000 | 6,7 (Large) |
| 224 (0xE0) | 11100000 | 5,6,7 |
| 255 (0xFF) | 11111111 | All cores |
ThreadAffinityManager/
├── app/src/main/
│ ├── java/.../
│ │ ├── MainActivity.java # Main UI
│ │ ├── NativeHelper.java # JNI interface
│ │ ├── QuickStartActivity.java # ADB quick start
│ │ ├── service/
│ │ │ └── FloatingWindowService.java # Floating window
│ │ ├── model/
│ │ │ ├── AppConfig.java # Configuration model
│ │ │ └── ThreadInfo.java # Thread data model
│ │ └── util/
│ │ ├── ConfigManager.java # Config persistence
│ │ ├── RootHelper.java # Root command execution
│ │ └── ProcessHelper.java # Process utilities
│ ├── cpp/
│ │ └── native-lib.cpp # Native implementation
│ └── res/layout/
│ └── layout_floating_window.xml
└── configs/ # Example configurations
- Check if root access is granted
- Some ROMs may override affinity settings
- Try disabling system performance managers
- Reduce monitoring frequency in settings
- Minimize floating window when not needed
- Check logcat for errors:
adb logcat -s FloatingWindowService:* NativeHelper:* RootHelper:*If this project helps you, consider supporting the development:
| Alipay | |
|---|---|
![]() |
![]() |
Your support is greatly appreciated! ☕
MIT License
- Uses JNI for native thread affinity operations
- Inspired by various CPU tuning tools in the Android community





