|
| 1 | +# AppControlX Project Context |
| 2 | + |
| 3 | +## Project Overview |
| 4 | +AppControlX adalah Android app untuk mengontrol aplikasi menggunakan Root atau Shizuku. App ini bisa freeze/unfreeze apps, manage battery optimization, dan batch operations. |
| 5 | + |
| 6 | +## Tech Stack |
| 7 | +- **Language**: Kotlin 1.9 |
| 8 | +- **Min SDK**: 29 (Android 10) |
| 9 | +- **Target SDK**: 34 (Android 14) |
| 10 | +- **Architecture**: MVVM + Repository Pattern |
| 11 | +- **DI**: Hilt 2.50 |
| 12 | +- **Database**: Room 2.6 |
| 13 | +- **Preferences**: DataStore |
| 14 | +- **Async**: Coroutines + Flow |
| 15 | +- **Root**: libsu by topjohnwu |
| 16 | +- **Shizuku**: Shizuku-API by RikkaApps |
| 17 | +- **Logging**: Timber |
| 18 | +- **Crash Reporting**: Firebase Crashlytics |
| 19 | +- **CI/CD**: GitHub Actions |
| 20 | + |
| 21 | +## Project Structure |
| 22 | +``` |
| 23 | +app/src/main/java/com/appcontrolx/ |
| 24 | +├── data/ |
| 25 | +│ ├── local/ # Room Database, DataStore |
| 26 | +│ └── repository/ # Data repositories |
| 27 | +├── di/ # Hilt modules (AppModule, DatabaseModule) |
| 28 | +├── executor/ # Command execution (RootExecutor, ShizukuExecutor) |
| 29 | +├── model/ # Data classes (AppInfo, ExecutionMode) |
| 30 | +├── presentation/ |
| 31 | +│ └── viewmodel/ # ViewModels |
| 32 | +├── rollback/ # State management & rollback |
| 33 | +├── service/ # Business logic (AppFetcher, BatteryPolicyManager, PermissionBridge) |
| 34 | +├── ui/ # Activities, Fragments, Adapters |
| 35 | +├── utils/ # Helpers (Constants, SafetyValidator) |
| 36 | +└── worker/ # WorkManager workers |
| 37 | +``` |
| 38 | + |
| 39 | +## Key Files |
| 40 | +- `App.kt` - Application class dengan Hilt, Timber, Crashlytics init |
| 41 | +- `PermissionBridge.kt` - Deteksi execution mode (Root/Shizuku/None) |
| 42 | +- `RootExecutor.kt` - Execute shell commands dengan security validation |
| 43 | +- `BatteryPolicyManager.kt` - Manage app freeze, background restriction |
| 44 | +- `SafetyValidator.kt` - Protect critical system apps |
| 45 | +- `AppRepository.kt` - Central data access layer |
| 46 | +- `AppListViewModel.kt` - UI state management |
| 47 | + |
| 48 | +## Coding Standards |
| 49 | +1. Gunakan Kotlin idioms (scope functions, null safety, etc.) |
| 50 | +2. Follow MVVM pattern - logic di ViewModel, UI di Fragment |
| 51 | +3. Inject dependencies via Hilt, jangan manual instantiation |
| 52 | +4. Gunakan Flow untuk reactive data |
| 53 | +5. Log dengan Timber, bukan Log.d |
| 54 | +6. Handle errors dengan Result<T> |
| 55 | +7. Validate package names sebelum execute commands |
| 56 | +8. Protect critical system apps (SafetyValidator) |
| 57 | + |
| 58 | +## Security Rules |
| 59 | +- NEVER execute arbitrary shell commands |
| 60 | +- ALWAYS validate package names dengan regex |
| 61 | +- ALWAYS check SafetyValidator sebelum actions |
| 62 | +- Block dangerous commands (rm -rf, reboot, format, etc.) |
| 63 | +- Use command whitelist di RootExecutor |
| 64 | + |
| 65 | +## UI Guidelines |
| 66 | +- Material 3 design |
| 67 | +- ViewBinding untuk views |
| 68 | +- Card-based layouts |
| 69 | +- Status badges untuk app states |
| 70 | +- Haptic feedback untuk selections |
| 71 | +- Accessibility support (content descriptions) |
| 72 | + |
| 73 | +## Testing |
| 74 | +- Unit tests di `app/src/test/` |
| 75 | +- Use Mockito untuk mocking |
| 76 | +- Use Turbine untuk Flow testing |
| 77 | +- Target 50%+ code coverage |
| 78 | + |
| 79 | +## Build Commands |
| 80 | +```bash |
| 81 | +./gradlew assembleDebug # Debug build |
| 82 | +./gradlew assembleRelease # Release build (minified) |
| 83 | +./gradlew test # Run unit tests |
| 84 | +./gradlew lint # Run lint checks |
| 85 | +``` |
| 86 | + |
| 87 | +## Common Issues |
| 88 | +1. Root access gagal → Check Shell.getShell() dipanggil dulu |
| 89 | +2. Type mismatch Result<String> vs Result<Unit> → Use .map { } |
| 90 | +3. NPE di Fragment → Use safe binding access pattern |
| 91 | +4. Mode tidak persist → Check Constants.PREFS_EXECUTION_MODE |
| 92 | + |
| 93 | +## GitHub Repository |
| 94 | +https://github.com/risunCode/AppControl-X |
0 commit comments