How mmrlapp/mmrl works
Project Type and Purpose
• This is a full-stack, multi-module Android application (“MMRL”) whose primary function is to help users manage and install Android modules (Magisk, KernelSU, APatch) both online and locally. It also embeds a WebUI for advanced module management and exposes native platform capabilities via AIDL/JNI.
File-Structure Overview
• Top-level Gradle modules:
• app – the Android application entry point; ties everything together.
• datastore – wrapper around Jetpack DataStore for user preferences.
• ext – Kotlin extension library shared by other modules.
• platform – platform-level module: AIDL interfaces + JNI/C++ code to invoke root operations.
• hidden-api – generated Android hidden APIs for direct system calls.
• ui – reusable Compose UI components.
• webui – assets and Kotlin server layer to serve the in-app WebUI.
• Build-logic folder contains custom Gradle convention plugins (Hilt, Room, Compose).
README Highlights
• MVVM architecture with Compose.
• Hilt for DI.
• Room for on-device DB (AppDatabase + DAOs under app/src/**/database).
• DataStore for key-value preferences.
• AIDL/JNI bridge for root-level operations.
• Embedded WebUI served from assets, communicating via JavaScript interfaces.
a. Presentation Layer
– Android Activities & Composables (app/ui packages)
– ViewModels (app/viewmodel)
b. Domain Layer
– Repositories (app/repository + datastore/repository)
c. Data Layer
– Room Database (app → AppDatabase, DAOs, Entities)
– Jetpack DataStore (datastore module)
– Remote Network Services (app/network + retrofit/HTTP clients)
d. Platform Layer
– AIDL interfaces & Bindings (platform/src/main/aidl → com.dergoogler.mmrl.platform.content)
– JNI/C++ layer (platform/src/main/jni)
– Hidden-API stubs (hidden-api module)
e. WebUI Layer
– Static assets (webui/src/main/assets/webui)
– Embedded HTTP server in WebView (WebUIAssetLoader → handlers)
– JS ↔ Kotlin bridge (WebUIClient & JS interfaces)
Relationships & Interactions
• UI → ViewModel: Compose UI injects ViewModels via Hilt.
• ViewModel → Repository: Business logic obtains data from repositories.
• Repository → DataSources:
• Local: Room DB (Entity/DAO) & DataStore (key-value).
• Remote: HTTP via Network.kt and Moshi serialization.
• Platform: AIDL service calls through ServiceManager and JNI code.
• Services (DownloadService, ModuleService, RepositoryService) run in the background and talk to repositories and platform.
• WebUI: WebView requests asset URLs → WebUIAssetLoader → passes requests to path handlers → some handlers forward to platform/ServiceManager or file APIs.
Architectural Patterns & Design Principles
• MVVM: clear separation of UI, state (ViewModel), and data.
• Repository Pattern: abstracts data sources.
• Layered Modules: each Gradle module has a single responsibility.
• DI with Hilt: modules injected into consumers.
• AIDL + JNI Bridge: exposes native OS operations through strong-typed interfaces.
Technologies & Frameworks
• Kotlin + Coroutines
• Jetpack Compose (UI)
• Hilt (DI)
• Room (SQLite ORM)
• DataStore (Preferences)
• Retrofit/Moshi (Network & JSON)
• AIDL & JNI (Platform integration)
• WebView + embedded HTTP server (WebUI)
Essential Elements
– Module boundaries (app, ui, datastore, platform, hidden-api, webui, ext)
– MVVM flow (UI → ViewModel → Repository → DataSource)
– Platform bridge (AIDL → JNI → root operations)
– WebUI asset server and JS interfaces
– Background services and notification utilities
– Database schemas (AppDatabase) and key DataStore serializers