How pangu-immortal/magicwx works
Project type and purpose
• MagicWX is a native Android application embedding an ONNX-based AI model for on-device inference.
• It has no server-side components; it focuses on UI, background Services, model loading, and Xposed integration.
Main components
a. Android UI Layer
• Activities/Fragments under app/src/main/java (not shown in tree but implied)
• XML layouts and resource files in app/src/main/res
b. On-Device Inference Engine
• ONNX Runtime library (added via Gradle)
• Assets folder containing model.onnx and vocab.json
c. Background Services & API Hooks
• Android Services for auto-start, keep-alive, and pull-up functionality
• Xposed module integration (hooking system APIs)
d. Android Framework & System
• AndroidManifest.xml declaring components and permissions
• Interaction with Android OS (PackageManager, ActivityManager, Accessibility, Broadcast receivers)
e. Build & Packaging
• Gradle build scripts (app/build.gradle, settings.gradle)
• ProGuard rules (proguard-rules.pro)
• ABI splits for 32-bit/64-bit architectures
Relationships and data flow
• User → UI Layer: user input triggers UI events
• UI Layer → Inference Engine: passes text or features to ONNX Runtime
• Inference Engine (Assets + ONNX Runtime) → Output: model returns results to UI
• UI/Service → Android System: requests for background tasks, auto-start, pop-up windows
• Xposed Hooks intercept OS calls to bypass restrictions (app install/uninstall, process restart)
Architectural patterns & design principles
• Separation of Concerns: UI vs. inference vs. system hooks
• Modularizing inference code so it’s isolated in a ModelManager class
• Services for long-running background jobs
• Use of Android’s asset management for large files