How xmir64/shadow works
Main Components
• Host Application: This is the container (or “host”) that integrates the plugin framework.
• Plugin Framework SDK: It includes multiple submodules such as:
– Core Modules (e.g., “core”, “common”, “runtime”): These handle fundamental functionalities like shadowing the standard Android components (Activity, Service, etc.), classloading, and resource management.
– Loader/Manager Modules (e.g., “loader”, “manager”, “activity-container”): Responsible for dynamically loading the plugin APKs, managing the plugin lifecycle, and delegating calls.
– Gradle Plugin & Transform Kit: Used at build time to instrument and package plugins by rewriting or transforming bytecode (e.g., “gradle-plugin”, “transform-kit”, “transform”). These components integrate with the build system, ensuring that plugin code and the framework co-evolve.
• Plugin APKs/Modules: Actual plugins (which are essentially independent APKs) that are loaded by the host. They include both plugin-specific code and parts of the plugin framework.
• Test & Sample Projects: “projects/sample” (demonstration host and plugin implementations) and “projects/test” which contain automated tests to validate compatibility with different Android configurations and dynamic behaviors.
• Code-Generation/Configuration Tools: Tools such as the code-generator and various gradle scripts (under “buildScripts”, “gradle”, etc.) that help set up, package, or configure the plugins and host.
Representing Relationships and Interactions
• That the Host Application includes a minimal “shadow” layer (around 15KB) that delegates to the Plugin Manager.
• How the Gradle Plugin/Transform Kit hooks into the build process: they transform the plugin APK code and incorporate parts of the shadow framework into the plugin packages.
• That the Plugin Loader is responsible for bridging Android’s classloader, resource, and component (Activity, Service, etc.) models between the host and the plugin.
• How test projects simulate and validate these interactions.
Architectural Patterns and Design Principles
• Minimal host impact – indicate that the host application integrates only a small “shadow” stub, relying on runtime delegation.
• Separation of concerns – group the SDK into modules (e.g., core functionality, classloading, resource management, and transformation) to emphasize modularity.
• Build-time instrumentation – show that the Gradle Plugin and Transformation tools are crucial in preparing plugins for runtime dynamic loading.
Relevant Technologies and Frameworks
• The framework is written partly in Kotlin (notably in “core.loader” and “core.transform”), so include that as a note.
• The Android platform and its standard component lifecycle are central.
• Gradle and associated build scripts are the backbone of packaging and dependency management.
Additional Elements
• That each component carries clear labels that capture both its name and its role.
• On potential external dependencies (for example, Gradle configurations, testing environments) as smaller “side” components if relevant.
Happy diagramming!