Summary of the invention
For the deficiencies in the prior art, it is an object of the invention to provide a kind of multipad plug-in unit
Implementation method.
For achieving the above object, the technical solution used in the present invention is as follows: a kind of multipad plug-in unit
Implementation method, said method comprising the steps of:
S1, in desktop main program add DroidPlugin framework;
S2, in the onCreate method of the Application of main program initialize DroidPlugin module,
Now DroidPlugin can be to IActivityManager, the IPackageManager in the process of main program
And the module that WIFI, Notification, Windows are correlated with is replaced so that host process and system
The bottom-up information stream of ActivityManagerService and PackageManagerService can be
Monitoring in DroidPlugin module;
S3, by the mounting means of InstallPackage method simulation system in DroidPlugin,
During in the installation kit of tripartite's application program, resource decompresses and copies to the privately owned catalogue of main program, and by this application
Program information joins in the list of main program installation procedure, now, and main program installation procedure list bag
Containing the original installation procedure of system plus the program installed by DroidPlugin;When main program needs to start
Simulate arbitrary Activity, Service, Provider, Broadcast group in the application program of installation
During part, it is only necessary to the mode specified according to android system starts, if desired for starting Activity circle
Face, it is only necessary to send to system in a program and start Intent, the incoming third party application of parameter true
Parameter;
Information flow in S4, main program process monitoring step S3, dishes out the side of startup really to system in program
Intercepting before formula, now installing in step S2 manages by whether bag name judges this assembly started
Belong to the application program that plug-in unitization is installed, if it is, Starting mode is replaced, newly-built one
Intent, replaces with the object of startup the assembly started in DroidPlugin, and starts real
Intent object, is included in this new Intent;
S5, android system resolve after receiving new Intent, find that this Intent starts
To as if during the most chartered assembly of DroidPlugin, system is that this assembly initializes, and
Finally again Intent being transferred back in main program, main program is receiving the Intent that the system that passes through processes
Afterwards, the true Intent object that starts being stored in before is taken out, and utilizes the mode of reflection, to third party
Application program initializes, and finally opens assembly in third party application, reaches not install the most permissible
Open the purpose of third party application, to realize the plug-in unit of application program.
Further, described method also comprises the steps:
S6, the management discharging the proceeding internal memory of plug-in applications, enter plug-in applications running
Row monitoring, monitors startup and the destruction of its Activity, and records the Activity quantity in current process,
When Activity starts, quantity+1, when Activity destroys, quantity-1, when the quantity safeguarded is 0
Time, kill the process of correspondence.
Further, the management that the described proceeding internal memory to plug-in applications discharges to realize step as follows:
In ActivityThread process, mInstrumentation object is used the Proxy in JAVA
Acting on behalf of principle to link up with, the life cycle of Activity passes through agent advertisement control module;
When mInstrumentation calls onActivityCreate, record pid process now
Number, record the class name of current Activity in the array with Pid as key simultaneously, and travel through current
Array, finds other Pid, if this process be not belonging to multipad independent after account service into
Journey, then call the killProcess that android system provides, kill other process;
When mInstrumentation calls onActivityDestory, represent that Activity is by system
Destroy, now find the corresponding Activity array with Pid as Key, by corresponding A ctivity class name
Remove, if now the quantity of this array is 0, and if this process to be not belonging to multipad independent
Account service processes after change, then the method calling the killProcess that android system provides, kill
This process dead, does not operates.
Relative to prior art, technical solutions according to the invention utilize DroidPlugin to increase income module, build
The framework opening third party application that found a set of dynamic load, that exempt from installation, and on this basis, from
Three aspects realize: first, to the desktop theme shop originally belonged within multipad and account
Number service module carry out decoupling process, independently go out this function of two pieces, and generate an independent application journey
Preface part, had the most both reduced the degree of coupling of intermodule, reduced again multipad inclusion size, and
And Google's system can be evaded thoroughly for engineering 65536 side operator quantitative limitation problem;Second, pass through
Dynamically management and load independent third party's application program, it is provided that all kinds of the most convenient and professional information to user,
As clicked on desktop widget weather icon, skip installation process and open ink marks weather, click on desktop news
Widget, skips installation process and opens today's tops etc.;3rd, the proceeding internal memory pipe to multipad
Reason, it is achieved opening any number of plug-in applications, the running memory of multipad is excessive all without having
Growth.
In order to be fully understood from the purpose of the present invention, feature and effect, below with reference to accompanying drawing to the present invention's
The technique effect of design, concrete structure and generation is described further.
Specific embodiment
As it is shown in figure 1, the implementation method of a kind of multipad plug-in unit, described method includes following step
Rapid:
S101: add DroidPlugin framework in desktop main program;
S102: initialize DroidPlugin mould in the onCreate method of the Application of main program
Block, now DroidPlugin can to the IActivityManager in the process of main program,
IPackageManager and WIFI, the module that Notification, Windows are relevant are replaced, phase
Pass module specifically includes: IAudioService, IClipboard, IContentService,
IGraphicStats、IInputMethodManager、IMediaRouterService、IMountService、
INotificationManager、ISearchManager、ISessionManager、IWifiManager、
IWindowManager) so that host process and system ActivityManagerService and
The bottom-up information stream of PackageManagerService can monitor in DroidPlugin module;
S103: by the mounting means of InstallPackage method simulation system in DroidPlugin,
During in the installation kit of third party application, resource decompresses and copies to the privately owned catalogue of main program, and should by this
Join in the list of main program installation procedure with program information, now, main program installation procedure list
Comprise the original installation procedure of system plus the program installed by DroidPlugin;When main program needs to open
Arbitrary Activity, Service, Provider, Broadcast in the dynamic application program having simulated installation
During assembly, it is only necessary to the mode specified according to android system starts, if desired for starting an Activity
Interface, it is only necessary to send to system in a program and start Intent, the incoming third party application of parameter true
Real parameter;
S104: the information flow in main program process monitoring step S103, dishes out to system in program and opens really
Intercepting before flowing mode, the now management of installing in step S102 judges the group of this time startup by bag name
Whether part belongs to the application program that plug-in unitization is installed, if it is, enter step S105;If it is not, then enter
Enter step S106;
S105: be replaced Starting mode, a newly-built Intent, replace with startup by the object of startup
Assembly in DroidPlugin, and start Intent object real, it is included in this new Intent
In, enter step S107;
S106: system will attempt starting the assembly of third party application, but third party application
The most oriented system registry of assembly, now system will report an error, and the process of main program will Crash;
S107:Android system resolves after receiving new Intent, finds that this Intent opens
Dynamic to as if during the most chartered assembly of DroidPlugin, system is that this assembly initializes,
And finally again Intent being transferred back in main program, main program is receiving what the system that passes through processed
After Intent, the true Intent object that starts being stored in before is taken out, and utilizes the mode of reflection, right
Third party application initializes, and finally opens assembly in third party application, reaches not install
Just can open the purpose of third party application, to realize the plug-in unit of application program.
S108: the management to the proceeding internal memory release of plug-in applications, to plug-in applications running
It is monitored, monitors startup and the destruction of its Activity, and record the Activity number in current process
Amount, when Activity starts, quantity+1, when Activity destroys, quantity-1, when the number safeguarded
When amount is 0, kill the process of correspondence.
The management that the described proceeding internal memory to plug-in applications discharges to realize step as follows:
S801: in ActivityThread process, uses in JAVA mInstrumentation object
Proxy act on behalf of principle and link up with, the life cycle of Activity passes through agent advertisement control module;
S802: when calling onActivityCreate in mInstrumentation, record pid now
Process number, records the class name of current Activity in the array with Pid as key simultaneously, and travels through and work as
Front array, finds other Pid, if this process is not belonging to the account clothes after multipad independent
Business process, then call the killProcess that android system provides, kill other process;
When S803:mInstrumentation calls onActivityDestory, represent Activity
Destroyed by system, now find the corresponding Activity array with Pid as Key, by corresponding A ctivity
Class name removes, if now the quantity of this array is 0, and if this process be not belonging to multipad
Account service processes after independent, then the method calling the killProcess that android system provides,
Kill this process, do not operate.
The management that the proceeding internal memory of plug-in applications is discharged by above-mentioned steps maintains in multipad
The normal use of the stable and plug-in unit deposited, why using Activity as criterion, is because Activity
As unique visible Andorid assembly, it is directly and user occurs mutual place, and plug-in application journey
The main purpose of sequence is the information in order to provide correspondence user needs when, time no, it is necessary to
Clean out the memory headroom that it is shared, be not required to such as Service assembly at running background.Reclaiming
During internal memory, need to judge whether this process is the account service out of multipad independent
Process, if it is, should not reclaim.
The present invention utilizes DroidPlugin project of increasing income, it is possible to achieve APP is exempted from installation and opens, and it is fixed
The agent framework of complete set, can act on behalf of all of Activity, Service, ContentProvider
And Broadcast assembly, this is also the basis that application program can be run in android system, logical
Cross its agency, can individually run the Activity in third party application, Service,
ContentProvider or Broadcast assembly, and without to system registry or installation.Basis at it
On, multipad structure is transformed, desktop theme shop and account service is carried out full decoupled,
They are packaged into an independent application program.Mutual with multipad before being different from, they
Binding service is utilized to interact.Set up management module, manage adding of other third party application
Carry and open, such as ink marks, today's tops etc..Owing to multipad to manage each plug-in applications
Work, be equivalent to different application programs and be required for operating in multipad, need to each insert
Part application program carries out Memory recycle, and scheme is according to actually used situation, to plug-in applications
Activity starts with the opportunity destroyed as basis, by entering the Activity quantity of plug-in applications
Row monitoring, when reaching quantity and being 0, destroys the process of corresponding plug-in applications.
For theme shop and the account service of former multipad, after it can be separated, become independent
Application program, particularly as follows: former desktop APP is transformed, separate theme shop and account service.Main
The theme of subject-trader storekeeper's desktop to be provided and browsing and downloading of wallpaper, the AIDL service of one striding course of definition,
Comprise the interactive function of they and desktop, serviced by this, can be as not decoupling before and using before
Function, difference is that function has been placed into, in another independent application file, passing through DroidPlugin
Individually call wherein certain Activity, Service, Provider and Broadcast etc..Because
The function of plug-in applications operates in independent process, and relative to before, the bug of crash does not interferes with
To host process, thus decrease the probability of multipad collapse, and owing to function the most independently becomes to answer
Existing by program, therefore the decreasing value of the inclusion size of multipad is the most considerable, also solves simultaneously
Android system application program method quantity can not restricted problem more than 65536.
If the function described in the present embodiment realizes and as independent product pin using the form of SFU software functional unit
When selling or use, a calculating device-readable can be stored in and take in storage medium.Based on such understanding,
Part or the part of this technical scheme that prior art is contributed by the embodiment of the present invention can be produced with software
The form of product embodies, and this software product is stored in a storage medium, including some instructions in order to make
One calculates equipment (can be personal computer, server, mobile computing device or the network equipment etc.)
Perform all or part of step of method described in each embodiment of the present invention.And aforesaid storage medium includes:
USB flash disk, portable hard drive, read-only storage (ROM, Read-Only Memory), random access memory (RAM,
Random Access Memory), the various media that can store program code such as magnetic disc or CD.This
In specification, each embodiment uses the mode gone forward one by one to describe, and what each embodiment stressed is and other
The difference of embodiment, between each embodiment, same or similar part sees mutually.
Described above to the disclosed embodiments, makes professional and technical personnel in the field be capable of or uses this
Invention.Multiple amendment to these embodiments will be apparent from for those skilled in the art,
Generic principles defined herein can without departing from the spirit or scope of the present invention, at other
Embodiment realizes.Therefore, the present invention is not intended to be limited to the embodiments shown herein, and is intended to
Meet the widest scope consistent with principles disclosed herein and features of novelty.