Overview of plug-in design (Android)
First, Module Partitioning
- Basic modules include: initialization interface, plug-in loading interface, plug-in update interface, and buried point interface.
A) Initialize the interface: perform some necessary initialization work.
b) Plug-in loading interface: Includes verification of plug-ins and loading plug-in work.
c) Plug-in Update interface: Update the specified plug-in with server-side communication.
- Marketing module: Relies on the basic module, realizes the concrete business logic.
interface Components Figure 1
Plug-in Activity Figure 2
SDK Load sequence Diagram 3
Second, Specific Design
- Plug-in information planning
Focus on the plug-in loading mechanism, updates, security protection and subsequent version compatibility issues, need to consider the point there, plug-in information to write the location, plug-in information field planning, field names and information encryption method.
1) plugin Information write location
Add a file to the jar including plug-in information
Write plug-in information into the ZIP file format
2) plugin information to prevent tampering
In asymmetric encryption, the server encrypts the plug-in information with the private key, and the client decrypts the public key
|
Field name |
Field meaning |
is optional |
|
|
Pluginname |
Plug-in Name |
Whether |
|
|
Pluginver |
Plugin version |
Whether |
|
|
Targetlibver |
The corresponding LIB version |
Is |
Mainly for the compatibility of plugins and Lib |
|
Minlibver |
Required Lib minimum version |
Whether |
|
Entry |
Plug-in Entry point |
Is |
Follow-up if you implement the entry point configuration required for self-booting |
|
DexMD5 |
Plugin for Dex MD5 |
Whether |
Prevent Dex from being tampered with |
|
Extra |
Additional Information key value pairs |
Is |
|
- Plug-in verification process
Plugin Check Flowchart 4
- Plug-in loading process
See Figure 3
2. Plugin update process
Initiate a plug-in update request as soon as the SDK is tuned (it is recommended that updates be made in another process to prevent running logic problems, resulting in no updates). Request plug-in application of the basic information, plug-in information, so that the server can follow certain conditions, issued plug-ins (later can be added grayscale update).