Summary of the invention
In view of the above problems, it is proposed that the present invention is to provide one to overcome the problems referred to above or at least partly
Ground solves the one of the problems referred to above.
According to one aspect of the present invention, it is provided that a kind of assembly management method in Android program,
The method includes:
Reserved one or more assemblies in the configuration file of described Android program, for reserved each
Assembly one process of statement;
The configuration file of the plug-in unit of described Android program is stated this plug-in unit to be used realize specific
The content of the assembly of function;
When described plug-in unit needs to run the described assembly realizing specific function, stated from reserved assembly
Process in find an available process;
The content of the described assembly realizing specific function is delivered to corresponding similar of the available process that found
In type assembly;
Start described available process so that same type component corresponding to described available process is transported in this process
OK.
Alternatively, before the described available process of described startup, the method farther includes:
Obtain and load the Class object of the described assembly realizing specific function.
Alternatively, described acquisition load the Class object of the described assembly realizing specific function and refer to:
The content of the described assembly realizing specific function is obtained from the configuration file of described plug-in unit;
Self-defined ClassLoader method;
Obtained according to the content of the described assembly realizing specific function by described self-defined ClassLoader method
Take and load the Class object of the described assembly realizing specific function.
Alternatively, described reserved one or more assemblies in the configuration file of described Android program,
Include for reserved one process of each assembly statement:
Utilize<service>label in the AndroidManifest.xml file of described Android program pre-
Stay one or more Service assembly, for reserved each Service assembly one process of statement;
And/or,
Utilize in the AndroidManifest.xml file of described Android program<provider>label
Reserved one or more ContentProvider assemblies, for reserved each ContentProvider assembly sound
A bright process.
Alternatively, what the described content by the described assembly realizing specific function was delivered to be found can use into
The same type component that journey is corresponding refers to:
The content of the described assembly realizing specific function is encapsulated in ComponentName apoplexy due to endogenous wind;
The available process being delivered to be found by this ComponentName class by Intent method is corresponding
With in type component.
Alternatively, when the described assembly realizing specific function is Service assembly, can described in described startup
By process so that same type component corresponding to described available process is run in this process and referred to:
Described available process is started so that described available process is corresponding by context.startService method
Service assembly run in this process.
Alternatively, the method farther includes:
In the configuration file of described Android program, real time record updates each of described Android program
The progress information of process.
Alternatively, one or more during described progress information includes following information:
Assembly name corresponding to process numbering, process status, the process initiation/time of amendment state, process,
The ID mark of process, process are run the quantity of each assembly.
Alternatively, described from the process that reserved assembly is stated, find an available process before,
The method farther includes:
Travel through all processes of described Android program, according to the progress information of each process, it may be judged whether
There is the process having distributed to the described assembly realizing specific function;
It is then, directly makes the described assembly realizing specific function run in this process, no longer perform described
The operation of an available process is found from the process that reserved assembly is stated.
Alternatively, described an available process is found to include from the process that reserved assembly is stated:
Travel through the process that all reserved assemblies are stated, according to the progress information of each process, it may be judged whether
There is idle process;
If there is an idle process, then using this idle process as available process;
If there is multiple idle processes, then select the process started the most the earliest as available process.
Alternatively, described an available process is found to wrap further from the process that reserved assembly is stated
Include:
If there is no idle process, then force to reclaim the process that the reserved assembly started the earliest is stated,
Re-create this process as available process.
Alternatively, the process that all reserved assemblies of described traversal are stated, believe according to the process of each process
Breath, it may be judged whether there is idle process and include:
Travel through the process that all reserved assemblies are stated, it may be judged whether exist and be in entering of inactive state
Journey, is then to force to reclaim this process, re-creates this process as described idle process;
Otherwise judge whether to be in the process of halted state, be then to force to reclaim this process, again create
Build this process as described idle process;
Otherwise judge whether placed in a suspend state and distance startup last time has exceeded entering of appointment time
Journey, is then to force to reclaim this process, re-creates this process as described idle process;
Otherwise judge whether to be in starting state and distance used Activity assembly, Service last time
Assembly, ContentProvide assembly r and Binder assembly have exceeded appointment the process of time the most, are then
Force to reclaim this process, re-create this process as described idle process.
According to another aspect of the present invention, it is provided that the assembly management device in a kind of Android program,
This device includes:
Dispensing unit, is suitable to reserved one or more assemblies in the configuration file of described Android program,
For reserved each assembly one process of statement;And be suitable to the joining of plug-in unit in described Android program
Put the content of the assembly realizing specific function stating in file that this plug-in unit is to be used;
Search unit, be suitable to when described plug-in unit needs to run the described assembly realizing specific function, from advance
The process that the assembly stayed is stated finds an available process;
Start unit, be suitable to be delivered to the content of the described assembly realizing specific function to be found is available
In the same type component that process is corresponding;And be suitable to start described available process so that described available process
Corresponding same type component is run in this process.
Alternatively, described start unit, it is further adapted for obtaining and loading the described group realizing specific function
The Class object of part.
Alternatively, described start unit, be suitable to from the configuration file of described plug-in unit, obtain described realization spy
Determine the content of the assembly of function;And be suitable to self-defined ClassLoader method;By described self-defined
ClassLoader method is according to the content obtaining of the described assembly realizing specific function and loads described realization
The Class object of the assembly of specific function.
Alternatively, described dispensing unit, be suitable to utilize described Android program
One or more Service assembly reserved by<service>label in AndroidManifest.xml file, for
Reserved each Service assembly one process of statement;And/or, be suitable to utilize described Android program
AndroidManifest.xml file in<provider>label is reserved one or more
ContentProvider assembly, for reserved each ContentProvider assembly one process of statement.
Alternatively, described start unit, be suitable to be encapsulated in the content of the described assembly realizing specific function
ComponentName apoplexy due to endogenous wind;By Intent method, this ComponentName class is delivered to institute again
In the same type component that the available process that finds is corresponding.
Alternatively, when the described assembly realizing specific function is Service assembly,
Described start unit, is suitable to start described available process by context.startService method, makes
The Service assembly obtaining described available process corresponding runs in this process.
Alternatively, described dispensing unit, it is further adapted in the configuration file of described Android program
Real time record updates the progress information of each process of described Android program.
Alternatively, one or more during described progress information includes following information:
Assembly name corresponding to process numbering, process status, the process initiation/time of amendment state, process,
The ID mark of process, process are run the quantity of each assembly.
Alternatively, described lookup unit, it is further adapted for traveling through all processes of described Android program,
Progress information according to each process, it may be judged whether exist and distribute to the described assembly realizing specific function
Process;It is then, directly notifies described start unit, no longer stated from reserved assembly described in execution
Process finds the operation of an available process;
Described start unit, is suitable to make the described assembly realizing specific function run in this process.
Alternatively, described lookup unit, be suitable to travel through the process that all reserved assemblies are stated, according to
The progress information of each process, it may be judged whether there is idle process;If there is an idle process, then will
This idle process is as available process;If there is multiple idle processes, then select to start the most the earliest
Process is as available process.
Alternatively, described lookup unit, being further adapted for when there is not idle process, forcing to reclaim
The process that the reserved assembly early started is stated, re-creates this process as available process.
Alternatively, described lookup unit, be suitable to travel through the process that all reserved assemblies are stated, it is judged that
Existence is in the process of inactive state, is then to force to reclaim this process, re-creates this process and make
For described idle process;Otherwise judge whether to be in the process of halted state, be then to force to reclaim to be somebody's turn to do
Process, re-creates this process as described idle process;Otherwise judge whether placed in a suspend state
And distance startup last time has exceeded appointment the process of time, it is then to force to reclaim this process, re-creates this
Process is as described idle process;Otherwise judge whether to be in starting state and distance used last time
Activity assembly, Service assembly, ContentProvider assembly and Binder assembly have exceeded finger the most
The process fixed time, is then to force to reclaim this process, re-creates this process as described idle process.
From the foregoing, the technical scheme that the present invention provides is by the configuration file to Android program
Pre-set, reserved one or more assemblies, and state a process for reserved each assembly, when inserting
When part needs to run the assembly realizing specific function, it is not necessary to reconfigure Android program, directly from advance
The process that the assembly stayed is stated finds an available process, the content of the assembly of specific function will be realized
Passing in the same type component that available process is corresponding, this is with type component operation in available process i.e.
Complete the operation of the assembly realizing specific function in plug-in unit, it is achieved that do not upgrade in Android mastery routine
On the premise of, plug-in unit freely customizing assembly, owing to mastery routine is without upgrading, and the activity extended
Assembly is easy to again the packaged pin function module that is processed into, therefore, when upgrading, under only needing every time
Carry corresponding pin function module.This has just been truly realized and has minimized installation, is greatly saved flow,
It is not required to again consume in a large number the resource of terminal, has not only saved flow but also can Effec-tive Function so that Android program
Function Extension more facilitation, high efficiency, meet application demand.
Described above is only the general introduction of technical solution of the present invention, in order to better understand the skill of the present invention
Art means, and can being practiced according to the content of description, and in order to allow, the present invention's is above and other
Objects, features and advantages can become apparent, below especially exemplified by the detailed description of the invention of the present invention.
Detailed description of the invention
It is more fully described the exemplary embodiment of the disclosure below with reference to accompanying drawings.Although accompanying drawing shows
The exemplary embodiment of the disclosure, it being understood, however, that may be realized in various forms the disclosure and not
Should be limited by embodiments set forth here.On the contrary, it is provided that these embodiments are able to more thoroughly
Understand the disclosure, and complete for the scope of the present disclosure can be conveyed to those skilled in the art.
Fig. 1 shows the assembly management side in a kind of Android program
The flow chart of method.As it is shown in figure 1, the method includes:
Step S110, in the configuration file of Android program, reserved one or more assemblies, are reserved
Each assembly statement one process.
Step S120, states the reality that this plug-in unit is to be used in the configuration file of the plug-in unit of Android program
The content of the assembly of existing specific function.
Step S130, when plug-in unit needs to run the assembly realizing specific function, from reserved assembly institute sound
Bright process finds an available process.
Step S140, the available process being delivered to the content realizing the assembly of specific function be found is corresponding
Same type component in.
Step S150, starts available process so that same type component corresponding to this available process is in this process
Middle operation.
Visible, the method shown in Fig. 1 is by pre-setting the configuration file of Android program, in advance
Stay one or more assembly, and state a process for reserved each assembly, when plug-in unit needs operation real
When showing the assembly of specific function, it is not necessary to reconfigure Android program, directly from reserved assembly institute sound
Bright process finds an available process, pass to the content realizing the assembly of specific function to can use into
In the same type component that journey is corresponding, this i.e. completes in plug-in unit with type component operation in available process
Realize the operation of the assembly of specific function, it is achieved that on the premise of Android mastery routine is not upgraded, insert
Part freely customizing assembly, owing to mastery routine is without upgrading, and the moving component extended is easy to
The packaged pin function module that is processed into, therefore, when upgrading, only need to download corresponding inserting every time
Part functional module.This has just been truly realized and has minimized installation, is greatly saved flow, is not required to again big
Amount consumes the resource of terminal, has not only saved flow but also can Effec-tive Function so that the function of Android program expands
Open up more facilitation, high efficiency, meet application demand.
In an embodiment of the present invention, Android program can be certain mastery routine, i.e. host program, as
360 mobile phone bodyguards etc.;Plug-in unit may refer to applets, as " antitheft " in 360 mobile phone bodyguards is inserted
Part, " start accelerate " plug-in unit, " calendar " plug-in unit etc., wherein realize " antitheft " function assembly,
The assembly realizing " start is accelerated " function, the assembly realizing " calendar " function are and realize specific function
Assembly.
AndroidManifest.xml is the core configuration file of Android program, is positioned at whole project
Root, states assembly used in Android program, including the class that realizes of each of which, energy
Processed data and startup position etc..Service and ContentProvider is all Android program
Common Component, Service assembly is not long playing mutual with user on android system backstage
Assembly, ContentProvider assembly is the assembly providing data content for Android program.At this
In a bright embodiment, step S110 of method shown in Fig. 1 is in the configuration file of Android program
Reserved one or more assemblies, include for reserved one process of each assembly statement: utilize described
<service>label in the AndroidManifest.xml file of Android program is reserved one or more
Service assembly, states a process for reserved each Service assembly, i.e. with the form of Service
Represent multiple assemblies reserved in Android program;And/or, utilize described Android program
In AndroidManifest.xml file<provider>label is reserved one or more
ContentProvider assembly, states a process for reserved each ContentProvider assembly, i.e.
Multiple processes reserved in Android program are represented with the form of ContentProvider.
Accordingly, step S120 of method shown in Fig. 1 is in the configuration file of the plug-in unit of Android program
State that the content of the assembly realizing specific function that this plug-in unit is to be used may is that and utilize described Android
<service>label in the AndroidManifest.xml file of the plug-in unit of program states that this plug-in unit to make
The content of the Service assembly realizing specific function;And/or, utilize described Android program
In the AndroidManifest.xml file of plug-in unit<provider>label states that this plug-in unit is to be used
Realize the content of the ContentProvider assembly of specific function.
Such as, in the configuration file of Android program, reserved one or more Service assemblies, i.e. exist
Stating<service>tag attributes in the AndroidManifest.xml file of Android program, code is such as
Shown in lower:
Wherein, android:name states the full name realizing Service subclass for Android program;
Android:process states the process name that Service runs;Android:exported states and calls
The authority of this Service.It will be seen that this example is at the AndroidManifest.xml of Android program
File is provided with three different<service>labels, has i.e. reserved three Service assemblies:
com.qihoo360.mobilesafe.loader.s.ServiceN1、com.qihoo360.mobilesafe.loader.
S.Service0 and com.qihoo360.mobilesafe.loader.s.Service1, three Service assemblies
The process stated respectively is: default process (UI process), loader0 process and loader1 process.In advance
The registration staying assembly is fairly simple, it is only necessary to write the most former in AndroidManifest.xml in code
Assembly, when application program or plug-in unit start by Application.onCreate method call.
Additionally, state the reality that this plug-in unit is to be used in the configuration file of the plug-in unit of Android program
The content of the Service assembly of existing specific function, i.e. at the AndroidManifest.xml file of this plug-in unit
Middle statement<service>tag attributes, code is as follows:
<service android:name=" com.qihoo360.mobilesafe.barcode.BarcodeService "/>
It will be seen that this example states Service group in the AndroidManifest.xml file of plug-in unit
Part: com.qihoo360.mobilesafe.barcode.BarcodeService, i.e. statement plug-in unit is to be used
Realize the content of the Service assembly of bar code function.When plug-in unit needs to run this BarcodeService group
During part, the process stated from reserved assembly (ServiceN1, Service0 and Service1) is (silent
Recognize process, loader0 process and loader1 process) in find an available process.If wherein loader1
Process is available process, then the content of BarcodeService assembly is delivered to found loader1 and enters
In the same type component Service1 assembly that journey is corresponding, start loader1 process so that Service1 assembly
This process is run.
In one embodiment of the invention, step S140 of method shown in Fig. 1 will realize specific function
The content of the assembly same type component that is delivered to the available process that found corresponding include: first by described
The content of the assembly realizing specific function is encapsulated in ComponentName apoplexy due to endogenous wind;Again by calling Intent
This ComponentName class is delivered in the same type component that the available process that found is corresponding by method.
Wherein, the Information encapsulation of Android assembly can be got up by ComponentName class, can for definition
See this assembly;Intent method is for realizing the communication between Android assembly.Further, specific when realizing
When the assembly of function is Service assembly, step S150 of method shown in Fig. 1 starts available process, makes
The same type component that process must be can use corresponding is run in this process and is referred to: by calling
Context.startService method starts available process so that the Service assembly that can use process corresponding exists
This process is run.
Specifically, the above-mentioned content by BarcodeService assembly is delivered to found loader1 process
The corresponding process in Service1 assembly is: the content of BarcodeService assembly be encapsulated in
ComponentName apoplexy due to endogenous wind, by calling Intent method by this packaged ComponentName
Class passes to Service1 assembly so that Service1 assembly is provided with the assembly realizing bar code function
Content;Again by calling context.startService method startup loader1 process so that Service1
Assembly runs in loader1 process, i.e. can realize the bar code function needed for plug-in unit.
Need to load this instance object in view of before carrying out instantiation operation in android system
Class object, therefore, in one embodiment of the invention, step S150 of method shown in Fig. 1 exists
Before starting available process, farther include: obtain and load the Class of the assembly realizing specific function
Object.This process includes: obtain the content of the assembly realizing specific function from the configuration file of plug-in unit;
Self-defined ClassLoader method;Specific merit is realized according to described by this self-defined ClassLoader method
Can the content obtaining of assembly and load the Class object of the described assembly realizing specific function.
Specifically, before above-mentioned startup loader1 process, example above farther includes: from
The AndroidManifest.xml file of plug-in unit obtains the content of BarcodeService assembly;Self-defined
ClassLoader method replaces the ClassLoader method of android system standard, redefines
FindClass method in ClassLoader method, this findClass method can basis
The content of BarcodeService assembly performs invoke method and gets this BarcodeService assembly
Class object, self-defined ClassLoader method loads this Class object, for the startup of subsequent processes
Ready.
In one embodiment of the invention, the method shown in Fig. 1 is the most further in Android program
In configuration file, real time record updates the progress information of each process of this Android program, including reserved group
The progress information of the process that part is corresponding, also includes the progress information of other processes normally created.Wherein,
It is one or more that progress information includes in following information:
(1) process numbering: for the numbering being attached in process name, as above in example, the volume of process loader0
Number it is 0, numbered the 1 of process loader1, by that analogy.
(2) process status: from the point of view of the life cycle according to a process, including unallocated state, divides
Join inactive state, starting state, halted state and halted state;Upon power-up of the system, can pass through
Application.attachBaseContext method initializes the above-mentioned information of each process, the process shape of process
State is unallocated state;When a process is assigned to run object, Application. can be passed through
OnCreate method initializes other information of this process, and is set to have distributed not actuated by process status
State.
(3) time of process initiation/amendment state.
(4) the assembly name that process is corresponding: the assembly name run in process.
(5) the ID mark of process: being the identity of each process, process one starts system will be automatic
Distributing to one unique ID of process, after process stops, ID is recovered in the system, in android system
Typically the most recovered process ID will not be reassigned to new process, newly generated ID is typically than it
Front is big.
(6) process runs the quantity of each assembly: include process is run Activity assembly quantity,
Process is run the quantity of Service assembly, process are run ContentProvider assembly quantity and
Process is run the quantity etc. of Service-Binder;Such as, process creates a Service, needs
To revise progress information when calling Service.onCreate method, would indicate that operation Service in process
The variable of quantity add 1;In process, destroy a Service, need calling Service.onDestroy
Revise progress information during method, would indicate that the variable of the quantity running Service in process subtracts 1;Service
When binding or unbind, similar, would indicate that the variable of the quantity running Service-Binder in process adds 1
Or subtract 1;The like.
On the basis of the configuration file of Android program records above-mentioned information, in a reality of the present invention
Execute in example, when the plug-in unit in an Android program needs to run the assembly realizing specific function, figure
Step S130 of method shown in 1 find from the process that reserved assembly is stated an available process it
Before, farther include: all processes (ALL object) of traversal Android program, according to each process
Progress information, according to the content of the assembly realizing specific function, it may be judged whether exist distribute to realize
The process of the assembly of specific function;It is then, directly makes the assembly realizing specific function run in this process,
No longer perform to find the operation of an available process from the process that reserved assembly is stated.Wherein, root
Progress information according to each process, it may be judged whether the process that there is the assembly distributing to realize specific function can
To be: if the assembly name of assembly name corresponding to process assembly that realizes specific function with this is identical,
Then without reallocation, the assembly realizing specific function is directly made to run in this process.
Wherein, the source of plug-in unit specifically described herein may is that and prestores in cloud server and Android
The plug-in unit list of multiple plugin informations that program is adaptive.Additionally, cloud server have collected various the most in advance
The operating system features information being likely to occur and the plugin information of correspondence, in order to by by operating system
Platform information and these characteristic informations collected in advance carry out matching ratio relatively, find and believe with operating system platform
The characteristic information of breath coupling, the plug-in unit corresponding with described characteristic information is inserting of applicable current operation system
Part.Subsequently, it is thus achieved that after the plug-in unit that described operating system is adaptive, server can be by plug-in download address
Return to plug-in unit loading system.Such as, server can return the configuration structure of plug-in unit, which includes
URL node, this URL node is the download address of this plug-in unit.
If there is not the group distributing to realize specific function in the process that all reserved assemblies are stated
The process of part, then continue to find an available process from the process that reserved assembly is stated.At this
In a bright embodiment, the process that step S130 of method shown in Fig. 1 is stated from reserved assembly
In find an available process to include: travel through the process that all reserved assemblies are stated, according to each process
Progress information, it may be judged whether there is idle process;If there is an idle process, then this is left unused
Process is as available process;If there is multiple idle processes, then the process started the most the earliest is selected to make
For available process.
Fig. 2 shows a kind of method judging whether idle process
Flow chart, this flow chart will be explained in above-mentioned traveling through the process that all reserved assemblies are stated,
Progress information according to each process, it may be judged whether there is the process of idle process.As in figure 2 it is shown, the party
Method includes:
Step S210, travels through the process that all reserved assemblies are stated, it may be judged whether exists to be in and does not opens
The process of dynamic state, is then to perform step S220, otherwise performs step S230.
In this step, the process being in inactive state includes being in unallocated state and having distributed not actuated
The process of state, is the process that priority is minimum, and therefore this process can be as idle process.
Step S220, forces to reclaim this process, re-creates this process as idle process.
The purpose of this step is to ensure that process pure interior, if collection process does not just start, and may
Operation object before the most still remaining in process, it is possible that various unexpected problem, as
Resource Manager (resource management) conflict etc..
Step S230, it may be judged whether there is the process being in halted state, is then to perform step S220,
Otherwise perform step S240.
In this step, if process is in halted state, can determine whether that the operation object in this process stops
Running, therefore this process can be as idle process.
Step S240, it may be judged whether exist placed in a suspend state and distance startup last time has exceeded the appointment time
Process, be then execution step S220, otherwise perform step S250.
In this step, if placed in a suspend state and distance startup last time has exceeded the appointment time to process, can
Judge that the operation object in this process does not reruns, and therefore this process can conduct for some reason
Idle process.
Step S250, it may be judged whether exist be in starting state and distance last time use Activity assembly,
Service assembly, ContentProvider assembly and Binder assembly have exceeded appointment the process of time the most,
It is then to perform step S220, otherwise performs step S260.
In this step, although process is in starting state, if but therein three big assemblies have stopped fortune the most
Row exceedes the appointment time, can determine whether that the operation object in this process is the most critically important.The priority of this process is relatively
Low, therefore can be as idle process.
Step S260, forces to reclaim the process that the reserved assembly started the earliest is stated, re-creates this
Process is as idle process.
In this step, through above-mentioned judge process, know all processes all in running status, according to entering
The life cycle of journey speculates, the reserved process started the earliest is most possibly close to halted state, therefore
Force to reclaim the reserved process started the earliest, re-create this process as idle process.
Visible, the method shown in Fig. 2 judges according to the classification of the assembly run in process status and process
The priority of process, finds the process that priority under current context is minimum, forces reclaim and re-create this
Process is as idle process.
Herein, the source of plug-in unit may is that and prestores in cloud server and Android program adaptation
The plug-in unit list of multiple plug-in versions, cloud server have collected the various operation being likely to occur the most in advance
System features information and the plug-in version of correspondence, in order to by by operating system platform information and these
The characteristic information collected in advance carries out matching ratio relatively, finds the feature with operating system platform information matches to believe
Breath, the plug-in unit corresponding with described characteristic information is the plug-in unit of applicable current operation system.Now, when this
Ground client sends plug-in unit to cloud server and obtains request, then receives cloud server and arranges according to plug-in unit
That table returns and that Android program is adaptive plug-in version.Further, described operating system is being obtained
After adaptive plug-in unit, plug-in download address can be returned to plug-in unit loading system by cloud server.Example
As, server can return the configuration structure of plug-in unit, which includes URL node, this URL node
It is the download address of this plug-in unit.Additionally, cloud server is also by plug-in unit name, each plug-in version of plug-in unit
Minimum interface version and the highest interface version that can use return to plug-in unit loading system, in order to after being used for
Continuous loading work.
Fig. 3 shows the assembly management dress in a kind of Android program
The schematic diagram put.As it is shown on figure 3, the assembly management device 300 in this Android program includes:
Dispensing unit 310, is suitable to reserved one or more assemblies in the configuration file of Android program,
For reserved each assembly one process of statement;And it is civilian to be suitable to the configuration at the plug-in unit of Android program
Part is stated the content of the assembly realizing specific function that this plug-in unit is to be used.
Search unit 320, be suitable to when plug-in unit needs to run the assembly realizing specific function, from reserved
The process that assembly is stated finds an available process.
Start unit 330, be suitable to that the content of the assembly by realizing specific function is delivered to be found is available
In the same type component that process is corresponding;And be suitable to start available process so that corresponding same of available process
Type component is run in this process.
Visible, the device shown in Fig. 3 is cooperated by each unit, the configuration to Android program
Pre-setting of file, reserved one or more assemblies, and state a process for reserved each assembly,
When plug-in unit needs to run the assembly realizing specific function, it is not necessary to reconfigure Android program, directly
From the process that reserved assembly is stated, find an available process, the assembly of specific function will be realized
Content passes in the same type component that available process is corresponding, and this is with type component fortune in available process
Row i.e. completes in plug-in unit the operation of the assembly realizing specific function, it is achieved that in Android mastery routine not
On the premise of upgrading, plug-in unit freely customizing assembly, owing to mastery routine is without upgrading, and extended
Moving component is easy to again the packaged pin function module that is processed into, therefore, when upgrading, only every time
Corresponding pin function module need to be downloaded.This has just been truly realized and has minimized installation, is greatly saved
Flow, is not required to again consume in a large number the resource of terminal, has not only saved flow but also can Effec-tive Function so that Android
The more facilitation of the Function Extension of program, high efficiency, meet application demand.
In one embodiment of the invention, the dispensing unit 310 of Fig. 3 shown device is suitable to utilize
<service>label in the AndroidManifest.xml file of Android program is reserved one or more
Service assembly, for reserved each Service assembly one process of statement;And/or, utilize described
In the AndroidManifest.xml file of Android program<provider>label is reserved one or more
ContentProvider assembly, for reserved each ContentProvider assembly one process of statement.Right
Ying Di, dispensing unit 310 is suitable to utilize the AndroidManifest.xml of the plug-in unit of described Android program
The Service assembly realizing specific function that this plug-in unit is to be used stated by<service>label in file
Content;And/or, utilize in the AndroidManifest.xml file of plug-in unit of described Android program
's<provider>the ContentProvider group realizing specific function that this plug-in unit is to be used stated by label
The content of part.Specific embodiment describes in detail the most, does not repeats them here.
In one embodiment of the invention, the dispensing unit 310 of Fig. 3 shown device is also further adapted for
In the configuration file of Android program, real time record updates the process of each process of this Android program
Information, including the progress information of process corresponding to reserved assembly, also includes other processes normally created
Progress information.Wherein, one or more during progress information includes following information: process numbering, process
Assembly name, the ID mark of process that state, the process initiation/time of amendment state, process are corresponding and enter
Running the quantity of each assembly in journey, the implication of each information describes in detail the most, does not repeats them here.
On the basis of the configuration file of Android program records above-mentioned information, in a reality of the present invention
Execute in example, when the plug-in unit in an Android program needs to run the assembly realizing specific function, figure
3 shown devices search unit 320 find from the process that reserved assembly is stated one can use into
Before journey, it is further adapted for traveling through all processes of Android program, according to the progress information of each process,
Judge whether to distribute to realize the process of the assembly of specific function;Being then, directly notice starts single
Unit 330, no longer performs to find the operation of an available process from the process that reserved assembly is stated;
Start unit 330, is suitable to make the assembly realizing specific function run in this process.Wherein, list is searched
Unit 320 is according to the progress information of each process, it may be judged whether there is the assembly distributing to realize specific function
Process may is that if assembly name corresponding to process realizes the assembly of assembly of specific function with this
Name is identical, then without reallocation, directly make the assembly realizing specific function run in this process.
If there is not the group distributing to realize specific function in the process that all reserved assemblies are stated
The process of part, then continue to find an available process from the process that reserved assembly is stated.At this
In a bright embodiment, the unit 320 of searching of Fig. 3 shown device is suitable to travel through all reserved assemblies
The process stated, according to the progress information of each process, it may be judged whether there is idle process;If there is
One idle process, then using this idle process as available process;If there is multiple idle processes, then
Select the process started the most the earliest as available process;Further, search unit 320, be suitable to work as
When there is not idle process, force to reclaim the process that the reserved assembly started the earliest is stated, again create
Build this process as available process.
Wherein, search unit 320 to be suitable to travel through the process that all reserved assemblies are stated, according to respectively entering
The progress information of journey, it may be judged whether there is the process of idle process particularly as follows: search unit 320, be suitable to
Travel through the process that all reserved assemblies are stated, it may be judged whether there is the process being in inactive state,
It is then to force to reclaim this process, re-creates this process as described idle process;Otherwise judge whether to deposit
It is being in the process of halted state, is being then to force to reclaim this process, re-creates this process as the described spare time
Put process;Otherwise judge whether placed in a suspend state and distance startup last time has exceeded the appointment time
Process, is then to force to reclaim this process, re-creates this process as described idle process;Otherwise judge
Whether existence be in starting state and distance used last time Activity assembly, Service assembly,
ContentProvider assembly and Binder assembly have exceeded appointment the process of time the most, are, force to reclaim
This process, re-creates this process as described idle process.
Visible, search unit 320 according to the classification of assembly run in process status and process judge into
The importance of journey, finds the most unessential process under current context, forces reclaim and re-create this process
As idle process.
In one embodiment of the invention, the start unit 330 of Fig. 3 shown device is suitable to first by described
The content of the assembly realizing specific function is encapsulated in ComponentName apoplexy due to endogenous wind;Again by calling Intent
This ComponentName class is delivered in the same type component that the available process that found is corresponding by method.
Further, when the assembly realizing specific function is Service assembly, start unit 330 is suitable to by calling
Context.startService method starts available process so that the Service assembly that can use process corresponding exists
This process is run.
Need to load this instance object in view of before carrying out instantiation operation in android system
Class object, therefore, in one embodiment of the invention, the start unit 330 of Fig. 3 shown device
Before starting available process, it is further adapted for obtaining and loading the Class of the assembly realizing specific function
Object.This process includes: start unit 330 obtains from the configuration file of plug-in unit and realizes specific function
The content of assembly;Self-defined ClassLoader method;By this self-defined ClassLoader method according to institute
State the content obtaining of the assembly realizing specific function and load the Class of the described assembly realizing specific function
Object.
In sum, pre-by the configuration file to Android program of technical scheme that the present invention provides
First arrange, reserved one or more assemblies, and state a process for reserved each assembly, work as plug-in unit
When needing to run the assembly realizing specific function, it is not necessary to reconfigure Android program, directly from reserved
The process stated of assembly in find an available process, the content that will realize the assembly of specific function passes
Passing in the same type component that available process is corresponding, this is the completeest with type component operation in available process
Become plug-in unit realizes the operation of the assembly of specific function, it is achieved that do not upgrade in Android mastery routine
Under premise, plug-in unit freely customizing assembly, owing to mastery routine is without upgrading, and the activity group extended
Part is easy to again the packaged pin function module that is processed into, and therefore, when upgrading, only needs to download every time
Corresponding pin function module.This has just been truly realized and has minimized installation, is greatly saved flow,
It is not required to again consume in a large number the resource of terminal, has not only saved flow but also can Effec-tive Function so that Android program
Function Extension more facilitation, high efficiency, meet application demand, one is entered for Android exploitation
Step development has great importance;Further, pin function module is the invention enables can to realize with standardization,
The most just the high in the clouds that can simplify application dissemination system realizes, the beneficially money between different application
Source is shared.As long as constructing the framework implementing the present invention between different application, can be by downloading
Some common pin function modules realize same function, it is clear that significantly reduce the labor of developer
Dynamic, also simplify the complexity of the program resource of server.
It should be understood that
Algorithm and display be not solid with any certain computer, virtual bench or miscellaneous equipment provided herein
Have relevant.Various fexible units can also be used together with based on teaching in this.As described above,
Construct the structure required by this kind of device to be apparent from.Additionally, the present invention is also not for any specific
Programming language.It is understood that, it is possible to use various programming languages realize the content of invention described herein,
And the description done language-specific above is the preferred forms in order to disclose the present invention.
In description mentioned herein, illustrate a large amount of detail.It is to be appreciated, however, that this
Inventive embodiment can be put into practice in the case of not having these details.In some instances, not
It is shown specifically known method, structure and technology, in order to do not obscure the understanding of this description.
Similarly, it will be appreciated that in order to simplify the disclosure and help understand in each inventive aspect one
Or multiple, above in the description of the exemplary embodiment of the present invention, each feature of the present invention is sometimes
It is grouped together in single embodiment, figure or descriptions thereof.But, should be by the disclosure
Method be construed to reflect an intention that i.e. the present invention for required protection require ratio in each claim
The middle more feature of feature be expressly recited.More precisely, as the following claims reflect
As, inventive aspect is all features less than single embodiment disclosed above.Therefore, it then follows
Claims of detailed description of the invention are thus expressly incorporated in this detailed description of the invention, the most each right
Requirement itself is all as the independent embodiment of the present invention.
Those skilled in the art are appreciated that and can carry out the module in the equipment in embodiment certainly
Change adaptively and they are arranged in one or more equipment different from this embodiment.Permissible
Module in embodiment or unit or assembly are combined into a module or unit or assembly, and in addition may be used
To put them into multiple submodule or subelement or sub-component.Except such feature and/or process or
Outside at least some in unit excludes each other, can use any combination that (this specification is included companion
With claim, summary and accompanying drawing) disclosed in all features and so disclosed any method or
All processes of person's equipment or unit are combined.Unless expressly stated otherwise, this specification (includes companion
With claim, summary and accompanying drawing) disclosed in each feature can by provide identical, equivalent or phase
Replace like the alternative features of purpose.
Although additionally, it will be appreciated by those of skill in the art that embodiments more described herein include it
Some feature included in its embodiment rather than further feature, but the group of the feature of different embodiment
Close and mean to be within the scope of the present invention and formed different embodiments.Such as, in following power
In profit claim, one of arbitrarily can mode making in any combination of embodiment required for protection
With.
The all parts embodiment of the present invention can realize with hardware, or to process at one or more
The software module run on device realizes, or realizes with combinations thereof.Those skilled in the art should
Understand, microprocessor or digital signal processor (DSP) can be used in practice to realize basis
A kind of some or all parts in assembly management device in the Android program of the embodiment of the present invention
Some or all functions.The present invention be also implemented as perform method as described herein one
Equipment or device program (such as, computer program and computer program) partly or completely.
The program of such present invention of realization can store on a computer-readable medium, or can have one
Or the form of multiple signals.Such signal can be downloaded from internet website and obtain, or carrying
There is provided on body signal, or provide with any other form.
The present invention will be described rather than limits the invention to it should be noted above-described embodiment,
And those skilled in the art can design replacement in fact without departing from the scope of the appended claims
Execute example.In the claims, should not will be located in any reference marks between bracket to be configured to right is wanted
The restriction asked.Word " comprises " and does not excludes the presence of the element or step not arranged in the claims.It is positioned at unit
Word "a" or "an" before part does not excludes the presence of multiple such element.The present invention can be by means of
Include the hardware of some different elements and realize by means of properly programmed computer.Listing
If in the unit claim of equipment for drying, several in these devices can be by same hardware branch
Specifically embody.Word first, second and third use do not indicate that any order.Can be by this
A little word explanations are title.
The invention discloses a kind of assembly management method in A1, Android program, wherein, the method
Including:
Reserved one or more assemblies in the configuration file of described Android program, for reserved each
Assembly one process of statement;
The configuration file of the plug-in unit of described Android program is stated this plug-in unit to be used realize specific
The content of the assembly of function;
When described plug-in unit needs to run the described assembly realizing specific function, stated from reserved assembly
Process in find an available process;
The content of the described assembly realizing specific function is delivered to corresponding similar of the available process that found
In type assembly;
Start described available process so that same type component corresponding to described available process is transported in this process
OK.
A2, method as described in A1, wherein, before the described available process of described startup, the method
Farther include:
Obtain and load the Class object of the described assembly realizing specific function.
A3, method as described in A2, wherein, described acquisition also loads the described group realizing specific function
The Class object of part refers to:
The content of the described assembly realizing specific function is obtained from the configuration file of described plug-in unit;
Self-defined ClassLoader method;
Obtained according to the content of the described assembly realizing specific function by described self-defined ClassLoader method
Take and load the Class object of the described assembly realizing specific function.
A4, method as described in A1, wherein, described in the configuration file of described Android program
Reserved one or more assemblies, include for reserved one process of each assembly statement:
Utilize<service>label in the AndroidManifest.xml file of described Android program pre-
Stay one or more Service assembly, for reserved each Service assembly one process of statement;
And/or,
Utilize in the AndroidManifest.xml file of described Android program<provider>label
Reserved one or more ContentProvider assemblies, for reserved each ContentProvider assembly sound
A bright process.
A5, method as described in A1, wherein, the described content by the described assembly realizing specific function
It is delivered in the same type component that the available process that found is corresponding refer to:
The content of the described assembly realizing specific function is encapsulated in ComponentName apoplexy due to endogenous wind;
The available process being delivered to be found by this ComponentName class by Intent method is corresponding
With in type component.
A6, method as described in A5, wherein, when the described assembly realizing specific function is Service
During assembly, the described available process of described startup so that same type component corresponding to described available process is at this
Process is run and refers to:
Described available process is started so that described available process is corresponding by context.startService method
Service assembly run in this process.
A7, method as described in A1, wherein, the method farther includes:
In the configuration file of described Android program, real time record updates each of described Android program
The progress information of process.
A8, method as described in A7, wherein, described progress information include in following information or
Multiple:
Assembly name corresponding to process numbering, process status, the process initiation/time of amendment state, process,
The ID mark of process, process are run the quantity of each assembly.
A9, method as described in A8, wherein, look for from the process that reserved assembly is stated described
Before an available process, the method farther includes:
Travel through all processes of described Android program, according to the progress information of each process, it may be judged whether
There is the process having distributed to the described assembly realizing specific function;
It is then, directly makes the described assembly realizing specific function run in this process, no longer perform described
The operation of an available process is found from the process that reserved assembly is stated.
A10, method as described in A9, wherein, described find from the process that reserved assembly is stated
One available process includes:
Travel through the process that all reserved assemblies are stated, according to the progress information of each process, it may be judged whether
There is idle process;
If there is an idle process, then using this idle process as available process;
If there is multiple idle processes, then select the process started the most the earliest as available process.
A11, method as described in A10, wherein, described look for from the process that reserved assembly is stated
Farther include to an available process:
If there is no idle process, then force to reclaim the process that the reserved assembly started the earliest is stated,
Re-create this process as available process.
A12, method as described in A10, wherein, what all reserved assemblies of described traversal were stated enters
Journey, according to the progress information of each process, it may be judged whether there is idle process and includes:
Travel through the process that all reserved assemblies are stated, it may be judged whether exist and be in entering of inactive state
Journey, is then to force to reclaim this process, re-creates this process as described idle process;
Otherwise judge whether to be in the process of halted state, be then to force to reclaim this process, again create
Build this process as described idle process;
Otherwise judge whether placed in a suspend state and distance startup last time has exceeded entering of appointment time
Journey, is then to force to reclaim this process, re-creates this process as described idle process;
Otherwise judge whether to be in starting state and distance used Activity assembly, Service last time
Assembly, ContentProvider assembly and Binder assembly have exceeded appointment the process of time the most, are the strongest
System reclaims this process, re-creates this process as described idle process.
The invention also discloses the assembly management device in B13, a kind of Android program, wherein, be somebody's turn to do
Device includes:
Dispensing unit, is suitable to reserved one or more assemblies in the configuration file of described Android program,
For reserved each assembly one process of statement;And be suitable to the joining of plug-in unit in described Android program
Put the content of the assembly realizing specific function stating in file that this plug-in unit is to be used;
Search unit, be suitable to when described plug-in unit needs to run the described assembly realizing specific function, from advance
The process that the assembly stayed is stated finds an available process;
Start unit, be suitable to be delivered to the content of the described assembly realizing specific function to be found is available
In the same type component that process is corresponding;And be suitable to start described available process so that described available process
Corresponding same type component is run in this process.
B14, device as described in B13, wherein,
Described start unit, is further adapted for obtaining and loading the Class of the described assembly realizing specific function
Object.
B15, device as described in B14, wherein,
Described start unit, is suitable to obtain the described specific function that realizes from the configuration file of described plug-in unit
The content of assembly;And be suitable to self-defined ClassLoader method;By described self-defined ClassLoader
Method is according to the content obtaining of the described assembly realizing specific function and loads the described group realizing specific function
The Class object of part.
B16, device as described in B13, wherein,
Described dispensing unit, is suitable to utilize the AndroidManifest.xml file of described Android program
In<service>label reserve one or more Service assembly, for reserved each Service assembly
State a process;And/or, be suitable to utilize the AndroidManifest.xml of described Android program
In file<provider>one or more ContentProvider assembly reserved by label, for reserved every
Individual ContentProvider assembly one process of statement.
B17, device as described in B13, wherein,
Described start unit, is suitable to be encapsulated in the content of the described assembly realizing specific function
ComponentName apoplexy due to endogenous wind;By Intent method, this ComponentName class is delivered to institute again
In the same type component that the available process that finds is corresponding.
B18, device as described in B17, wherein, when the described assembly realizing specific function is Service
During assembly,
Described start unit, is suitable to start described available process by context.startService method, makes
The Service assembly obtaining described available process corresponding runs in this process.
B19, device as described in B13, wherein,
Described dispensing unit, is further adapted for real time record in the configuration file of described Android program
Update the progress information of each process of described Android program.
B20, device as described in B19, wherein, described progress information includes one in following information
Or multiple:
Assembly name corresponding to process numbering, process status, the process initiation/time of amendment state, process,
The ID mark of process, process are run the quantity of each assembly.
B21, device as described in B20, wherein,
Described lookup unit, is further adapted for traveling through all processes of described Android program, according to respectively
The progress information of process, it may be judged whether there is the process distributing to the described assembly realizing specific function;
It is then, directly notifies described start unit, no longer perform described from the process that reserved assembly is stated
Find the operation of an available process;
Described start unit, is suitable to make the described assembly realizing specific function run in this process.
B22, device as described in B21, wherein,
Described lookup unit, is suitable to travel through the process that all reserved assemblies are stated, according to each process
Progress information, it may be judged whether there is idle process;If there is an idle process, then by this leave unused into
Cheng Zuowei can use process;If there is multiple idle processes, then select the process conduct started the most the earliest
Available process.
B23, device as described in B22, wherein,
Described lookup unit, is further adapted for when there is not idle process, forces recovery to start the earliest
The process that reserved assembly is stated, re-creates this process as available process.
B24, device as described in B22, wherein,
Described lookup unit, is suitable to travel through the process that all reserved assemblies are stated, it may be judged whether exist
It is in the process of inactive state, is then to force to reclaim this process, re-creates this process as the described spare time
Put process;Otherwise judge whether to be in the process of halted state, be then to force to reclaim this process, weight
This process newly created is as described idle process;Otherwise judge whether placed in a suspend state and apart from upper
Secondary startup has exceeded appointment the process of time, is then to force to reclaim this process, re-creates this process conduct
Described idle process;Otherwise judge whether to be in starting state and distance used Activity group last time
Part, Service assembly, ContentProvider assembly and Binder assembly have exceeded entering of appointment time the most
Journey, is then to force to reclaim this process, re-creates this process as described idle process.