Summary of the invention
For solving above-mentioned technical problem, the present invention provides a kind of terminal unit, plug-in unit load operating device and plug-in unit load operating method, and loading of plug-in can be utilized to download the flow of installation kit to save user, promotes download and the installation of application program.
Technical scheme provided by the invention is as follows:
According to an aspect of the present invention, it is provided that a kind of terminal unit, including: memorizer, touching display screen and processor,
Reservoir host's application program in described memorizer;
Open the initialization operation of the described host application after described host application on described touching display screen in response to user, described processor performs loading of plug-in installation kit and the running environment based on the set information described host application of amendment of described plug-in unit installation kit makes described host application point to the operation of described plug-in unit installation kit;
In response to the execution of described host application, described processor performs to run in described running environment after the modification the operation of the plug-in unit installation kit of described sensing.
Preferably, described processor execution loading of plug-in installation kit the running environment based on the set information described host application of amendment of described plug-in unit installation kit make the operation that described host application points to described plug-in unit installation kit include:
Described processor loading of plug-in installation kit, obtains the set information of described plug-in unit installation kit;
Obtain the set information of described host application;
Based on the set information of described plug-in unit installation kit, the set information of described host application is replaced amendment, agency's amendment and contextual modifications so that described host application points to described plug-in unit installation kit.
According to another aspect of the present invention, it is provided that a kind of plug-in unit load operating device, including:
First processing module, the running environment revising described host application for the initialization in response to host application, loading of plug-in installation kit the set information based on described plug-in unit installation kit makes described host application point to described plug-in unit installation kit;
Second processing module, for the execution in response to described host application, runs the plug-in unit installation kit of described sensing in the described first amended described running environment of processing module.
Preferably, described first processing module includes:
Load and obtain submodule, for loading of plug-in installation kit, obtaining the set information of described plug-in unit installation kit;
Hosted information obtains submodule, for obtaining the set information of described host application;
Amendment submodule, for based on described loading and the set information obtaining the plug-in unit installation kit that submodule obtains, the set information that described hosted information obtains the host application that submodule obtains is replaced amendment, agency's amendment and contextual modifications so that described host application points to described plug-in unit installation kit.
Preferably, described amendment submodule includes:
First amendment submodule, for being obtained the installation kit information of described host application by reflex mechanism, by reflex mechanism, the Classloader quoted in the installation kit information of described host application, Resource TOC path and Resource Properties are replaced with the Classloader of described plug-in unit installation kit, local path and Resource Properties respectively.
Preferably, described amendment submodule includes:
Second amendment submodule, for being obtained the package manager of described host application by reflex mechanism, carries out dynamic proxy to the associated member's method in the package manager of described host application so that returning the relevant information of described plug-in unit installation kit.
Preferably, described amendment submodule includes:
3rd amendment submodule, for generating the new context of described host application, the quoting resource of wherein said new context points to described plug-in unit installation kit, by reflex mechanism, quoting of the former context in the installation kit information of described host application is replaced with described new context, and trigger the initialization opportunity of new context.
According to another aspect of the present invention, it is provided that a kind of plug-in unit load operating method, including:
The running environment revising described host application in response to the initialization of host application, loading of plug-in installation kit the set information based on described plug-in unit installation kit makes described host application point to described plug-in unit installation kit;
In response to the execution of described host application, described running environment after the modification is run the plug-in unit installation kit of described sensing.
Preferably, described loading of plug-in installation kit the running environment based on the set information described host application of amendment of described plug-in unit installation kit make the described host application described plug-in unit installation kit of sensing include:
Loading of plug-in installation kit, obtains the set information of described plug-in unit installation kit;
Obtain the set information of described host application;
Based on the set information of described plug-in unit installation kit, the set information of described host application is replaced amendment, agency's amendment and contextual modifications so that described host application points to described plug-in unit installation kit.
Preferably, the described set information based on described plug-in unit installation kit, the set information of described host application is replaced amendment and includes:
The installation kit information of described host application is obtained by reflex mechanism;
By reflex mechanism, the Classloader quoted in the installation kit information of described host application, Resource TOC path and Resource Properties are replaced with the Classloader of described plug-in unit installation kit, local path and Resource Properties respectively.
Preferably, the Classloader of described plug-in unit installation kit, local path and Resource Properties obtain after loading of plug-in installation kit.
Preferably, the described set information based on described plug-in unit installation kit, the set information of described host application is acted on behalf of amendment and includes:
The package manager of described host application is obtained by reflex mechanism;
Associated member's method in the package manager of described host application is carried out dynamic proxy so that returning the relevant information of described plug-in unit installation kit.
Preferably, the described set information based on described plug-in unit installation kit, the set information of described host application is carried out contextual modifications and includes:
Generating the new context of described host application, the quoting resource of wherein said new context points to described plug-in unit installation kit;
By reflex mechanism, quoting of the former context in the installation kit information of described host application is replaced with described new context, and trigger the initialization opportunity of new context.
It appeared that, the technical scheme of the embodiment of the present invention, when host application initializes, first loading of plug-in installation kit, and the running environment based on the set information described host application of amendment of described plug-in unit installation kit makes described host application point to described plug-in unit installation kit, described running environment after the modification thus in the execution process of host application, can be run the plug-in unit installation kit of described sensing.By above-mentioned process, it is smaller that the installation kit volume of host application installed at mobile terminal just can do, the application function provided the user realizes such as through running the plug-in unit loaded, thus being greatly saved user to download the flow of installation kit, attract more users to download and set up applications, promote download and the installation of application program.
Further, the Classloader quoted in the installation kit information of described host application, Resource TOC path and Resource Properties can be replaced with the Classloader of described plug-in unit installation kit, local path and Resource Properties by reflex mechanism by the embodiment of the present invention respectively;Associated member's method in the package manager of described host application is carried out dynamic proxy so that returning the relevant information of described plug-in unit installation kit;By reflex mechanism, quoting of the former context in the installation kit information of described host application is replaced with new context.Therefore the technical scheme of the embodiment of the present invention realizes dynamically changing the running environment of host application, makes the sensing plug-in application that host application is complete, realizes loading and the operation of plug-in unit installation kit from the code without amendment plug-in unit installation kit.
Detailed description of the invention
It is more fully described the preferred implementation of the disclosure below with reference to accompanying drawings.Although accompanying drawing shows the preferred implementation of the disclosure, however, it is to be appreciated that may be realized in various forms the disclosure and should do not limited by embodiments set forth herein.On the contrary, it is provided that these embodiments are to make the disclosure more thorough and complete, and the scope of the present disclosure can intactly convey to those skilled in the art.
Before introducing the embodiment of the present invention, first introduce some concepts related in the embodiment of the present invention, to help the understanding to scheme.
Host application (abbreviation host program) described in the embodiment of the present invention is the software environment that software is depended on for existence, for instance: A needs to operate in B, and B is exactly host program.
Class described in the embodiment of the present invention is the carrier of the attribute of encapsulated object and behavior, and a class entity in turn with same alike result and behavior is referred to as class;To as if example during class abstract out one, in computer programming language such as Java language, the attribute of object exists with the form of member variable, and the method for object exists with the form of member method.Java language use member method corresponding to the behavior of class object.One member method can have parameter, this parameter can be object can also be the variable of basic data type, member method has return value and does not return the selection of any value simultaneously, and wherein the return value of member method can be result of calculation can also be other numerical value wanted and objects.Classloader is a class for loading classes file, and its effect is exactly operationally loading classes.Classloader is generally responsible for the class file in load document system, network or other sources.
Reflection described in the embodiment of the present invention refers to reflex mechanism, for instance Java reflex mechanism.Java reflex mechanism is in running status, for any one class, can both know all properties and the method for this class;For any one object, its any one method can both be called;The function of the method for this dynamic acquisition information and dynamic call object is the reflex mechanism of Java language.Utilize Java reflex mechanism, all description information (what such as often access includes the building method of class, member variable and method etc.) of class can be accessed when program is run, it is achieved the execution process of multi channel program.
Dynamic proxy described in the embodiment of the present invention, it is use reflex mechanism dynamic creation to form when program is run, it is possible to by specifying Classloader ClassLoader object and a group interface interface to create dynamic proxy class for proxy class (Proxy class).In fact, namely in running status, the agency of dynamic creation outgoing interface realizes class, and its reflex mechanism remained by Java creates.An effect intercepted can be played, thus running the logic of succedaneum when user calls such member method.
Embodiment of the present invention technical scheme is discussed in detail below in conjunction with accompanying drawing.
The embodiment of the present invention provides a kind of terminal unit, and loading of plug-in can be utilized to download the flow of installation kit to save user, promotes download and the installation of application program.
Fig. 1 is the schematic block diagram of a kind of terminal unit according to an embodiment of the invention.
As it is shown in figure 1, terminal unit 10 may include that memorizer 11, touching display screen 12 and processor 13.
Memorizer 11 stores reservoir host's application program;
In response to user's initialization operation opening the described host application after described host application on touching display screen 12, processor 13 performs loading of plug-in installation kit and the set information based on described plug-in unit installation kit is revised the running environment of described host application and made described host application point to the operation of described plug-in unit installation kit;
In response to the execution of described host application, processor 13 performs to run in described running environment after the modification the operation of the plug-in unit installation kit of described sensing.
Wherein, processor 13 performs loading of plug-in installation kit and the running environment based on the set information described host application of amendment of described plug-in unit installation kit makes the operation that described host application points to described plug-in unit installation kit include: described processor 13 loading of plug-in installation kit, obtains the set information of described plug-in unit installation kit;Obtain the set information of described host application;Based on the set information of described plug-in unit installation kit, the set information of described host application is replaced amendment, agency's amendment and contextual modifications so that described host application points to described plug-in unit installation kit.
Processor 13 in terminal unit 10, can as an independent apparatus structure, this independent apparatus structure is properly termed as plug-in unit load operating device, and this plug-in unit load operating device can include multiple submodule, hereafter will this plug-in unit load operating apparatus structure be described in detail.
Fig. 2 is the schematic block diagram of a kind of plug-in unit load operating device according to an embodiment of the invention.
As in figure 2 it is shown, may include that first processing module the 21, second processing module 22 in plug-in unit load operating device 20.
First processing module 21, the running environment revising described host application for the initialization in response to host application, loading of plug-in installation kit the set information based on described plug-in unit installation kit makes described host application point to described plug-in unit installation kit.
First processing module 21 when host application initializes, first loading of plug-in installation kit, obtain the set information of described plug-in unit installation kit;Obtain the set information of described host application;Based on the set information of described plug-in unit installation kit, the set information of described host application is replaced amendment, agency's amendment and contextual modifications so that described host application points to described plug-in unit installation kit.
Second processing module 22, for the execution in response to described host application, runs the plug-in unit installation kit of described sensing in the described first amended described running environment of processing module 21.
It appeared that, the technical scheme of the embodiment of the present invention, when host application initializes, first loading of plug-in installation kit, and the running environment based on the set information described host application of amendment of described plug-in unit installation kit makes described host application point to described plug-in unit installation kit, described running environment after the modification thus in the execution process of host application, can be run the plug-in unit installation kit of described sensing.By above-mentioned process, it is smaller that the installation kit volume of host application installed at mobile terminal just can do, the application function provided the user realizes such as through running the plug-in unit loaded, thus being greatly saved user to download the flow of installation kit, attract more users to download and set up applications, promote download and the installation of application program.
Fig. 3 is another schematic block diagram of a kind of plug-in unit load operating device according to an embodiment of the invention.
As it is shown on figure 3, may include that first processing module the 21, second processing module 22 in plug-in unit load operating device 20, the function of these two modules can referring to described by Fig. 2, repeating no more herein.
Further, described first processing module 21 may include that loading and obtains submodule 211, hosted information acquisition submodule 212, amendment submodule 213.
Load and obtain submodule 211, for loading of plug-in installation kit, obtaining the set information of described plug-in unit installation kit.
Hosted information obtains submodule 212, for obtaining the set information of described host application.
Amendment submodule 213, for based on described loading and the set information obtaining the plug-in unit installation kit that submodule 211 obtains, the set information that described hosted information obtains the host application that submodule 212 obtains is replaced amendment, agency's amendment and contextual modifications so that described host application points to described plug-in unit installation kit.
Wherein, described amendment submodule 213 may include that the first amendment submodule 2131.
First amendment submodule 2131, for being obtained the installation kit information of described host application by reflex mechanism, by reflex mechanism, the Classloader quoted in the installation kit information of described host application, Resource TOC path and Resource Properties are replaced with the Classloader of described plug-in unit installation kit, local path and Resource Properties respectively.
Reflex mechanism is in running status, for any one class, can both know all properties and the method for this class;For any one object, its any one method can both be called.Utilize reflex mechanism, all description information (what such as often access includes the building method of class, member variable and method etc.) of class can be accessed when program is run, it is achieved the execution process of multi channel program.
Wherein, described amendment submodule 213 may include that the second amendment submodule 2132.
Second amendment submodule 2132, for being obtained the package manager of described host application by reflex mechanism, carries out dynamic proxy to the associated member's method in the package manager of described host application so that returning the relevant information of described plug-in unit installation kit.
Described dynamic proxy, is exactly be created that the agency of interface realizes class dynamically in fact in running status.
Wherein, described amendment submodule 213 may include that the 3rd amendment submodule 2133.
3rd amendment submodule 2133, for generating the new context of described host application, the quoting resource of wherein said new context points to described plug-in unit installation kit, by reflex mechanism, quoting of the former context in the installation kit information of described host application is replaced with new context, and trigger the initialization opportunity of new context.
It appeared that, the technical scheme of the embodiment of the present invention, described host application is made to point in the process of described plug-in unit installation kit in the running environment revising described host application, based on the set information of described plug-in unit installation kit, the set information of described host application can be replaced amendment, agency's amendment and entrusts amendment so that described host application points to described plug-in unit installation kit.Including: by reflex mechanism, the Classloader quoted in the installation kit information of described host application, Resource TOC path and Resource Properties are replaced with the Classloader of described plug-in unit installation kit, local path and Resource Properties respectively;Associated member's method in the package manager of described host application is carried out dynamic proxy so that returning the relevant information of described plug-in unit installation kit;By reflex mechanism, quoting of the former context in the installation kit information of described host application is replaced with new context.Therefore the technical scheme of the embodiment of the present invention realizes dynamically changing the running environment of host application, makes the sensing plug-in application that host application is complete, realizes loading and the operation of plug-in unit installation kit from the code without amendment plug-in unit installation kit.
Fig. 4 is the indicative flowchart of a kind of plug-in unit load operating method according to an embodiment of the invention.
As shown in Figure 4, in step 401, the running environment that plug-in unit load operating device revises described host application in response to the initialization of host application, loading of plug-in installation kit the set information based on described plug-in unit installation kit makes described host application point to described plug-in unit installation kit.
Above-mentioned plug-in unit load operating device, it is possible to run in host application, controls loading and the operation of plug-in unit.
This step may include that loading of plug-in installation kit, obtain the set information of described plug-in unit installation kit;Obtain the set information of described host application;Based on the set information of described plug-in unit installation kit, the set information of described host application is replaced amendment, agency's amendment and contextual modifications so that described host application points to described plug-in unit installation kit.
In step 402, plug-in unit load operating device, in response to the execution of described host application, runs the plug-in unit installation kit of described sensing in described running environment after the modification.
It appeared that, the technical scheme of the embodiment of the present invention, when host application initializes, first loading of plug-in installation kit, and the running environment based on the set information described host application of amendment of described plug-in unit installation kit makes described host application point to described plug-in unit installation kit, described running environment after the modification thus in the execution process of host application, can be run the plug-in unit installation kit of described sensing.By above-mentioned process, it is smaller that the installation kit volume of host application installed at mobile terminal just can do, the application function provided the user realizes such as through running the plug-in unit loaded, thus being greatly saved user to download the flow of installation kit, attract more users to download and set up applications, promote download and the installation of application program.
Fig. 5 is another indicative flowchart of a kind of plug-in unit load operating method according to an embodiment of the invention.
Fig. 5 describe in more detail the technical scheme of the embodiment of the present invention relative to Fig. 4.
The plug-in unit load operating device of the embodiment of the present invention can perform operation in host application.
As it is shown in figure 5, in step 501, plug-in unit load operating device when host application initializes, first loading of plug-in installation kit Apk, obtain the set information of described plug-in unit installation kit.
In this step, the set information of the plug-in unit installation kit of acquisition such as can include the Classloader (ClassLoader) of plug-in unit Apk, local path and Resource Properties etc..
In step 502, plug-in unit load operating device obtains the installation kit information of described host application by reflex mechanism.
In this step, reflection obtains the installation kit information (PackageInfo) of host application.Installation kit information such as can include Classloader, Resource TOC path and the Resource Properties quoted in installation kit information.
Reflex mechanism is in running status, for any one class, can both know all properties and the method for this class;For any one object, its any one method can both be called.Utilize reflex mechanism, all description information (what such as often access includes the building method of class, member variable and method etc.) of class can be accessed when program is run, it is achieved the execution process of multi channel program.Therefore, step 502 can be passed through reflex mechanism and obtain the installation kit information (PackageInfo) of host application.Reflection described in this step obtains, and in fact namely refers to be got certain member property in the example of class by reflex mechanism.
It should be noted that, step 501 and step 502 do not have the ordering relation of certainty, herein simply for the convenience of description.
In step 503, the Classloader quoted in the installation kit information of described host application, Resource TOC path and Resource Properties are replaced with the Classloader of described plug-in unit installation kit, local path and Resource Properties by reflex mechanism by plug-in unit load operating device respectively.
In this step, the Classloader that Classloader is plug-in unit Apk quoted in the installation kit information of host application is replaced in reflection, the local path that Resource TOC path is plug-in unit Apk in the installation kit information of host application is replaced in reflection, and the Resource Properties that Resource Properties is plug-in unit in the installation kit information of host application is replaced in reflection.
Reflection described in this step is replaced, and in fact refers to certain member property being replaced by an instantiation new same attribute out in the example of class by reflex mechanism.
Therefore, in above-mentioned steps 502 and 503, it can be the privately owned member property " installation kit information " (mPackageInfo) first passing through context (Application) object that reflex mechanism obtains host application, then again by reflex mechanism, the Classloader (" mClassLoader ") quoted in this installation kit information is replaced to the Classloader of plug-in unit Apk, the Resource TOC local path (" mResDir ") quoted in installation kit information is replaced to the local path of plug-in unit Apk, the resource (" mResources ") quoted in installation kit information is replaced to the resource of plug-in unit Apk.
In step 504, plug-in unit load operating device obtains the package manager of described host application by reflex mechanism.
In this step, it is possible to reflection obtain host application package manager (PackageManager), in package manager, wherein comprise associated member's method.
In step 505, the associated member's method in the package manager of described host application is carried out dynamic proxy so that returning the relevant information of described plug-in unit installation kit by plug-in unit load operating device.
In this step, the associated member's method in the package manager of host application is carried out dynamic proxy, make associated member's method return the relevant information of plug-in unit Apk.
Dynamic proxy in this step, is exactly be created that the agency of interface realizes class dynamically in fact in running status, and its reflex mechanism remained by Java creates.An effect intercepted can be played, thus running the logic of succedaneum when user calls such member method.
Such as, in this step, the package manager (PackageManager) of host application is carried out dynamic proxy, act on behalf of its member method (" getActivityInfo ", " getPackageInfo ", " queryIntentActivities "), make the member method of package manager return return value corresponding to plug-in unit Apk.
In step 506, plug-in unit load operating device generates the new quoting resource of described host application and points to the context Application of plug-in unit installation kit.
Replacing and after dynamic proxy operation through a series of reflection of above-mentioned steps, this step generates and obtains new context Application (entrusting class also referred to as context Application), and all quoting resources in new context both point to plug-in unit Apk.
In step 507, plug-in unit load operating device passes through reflex mechanism by the new context all replacing with described generation of quoting of the former context in the installation kit information of described host application, and triggers the initialization opportunity of new context.
In this step, reflection is replaced quoting of all former context Application in host application installation kit information and has all been replaced to new context Application, is namely all directed to the new context generated.
Because the new context generated needs to trigger it as system initializes flow process, so the method for the triggering of the embodiment of the present invention is to be called the initialization entry method (" attach () ") of new context Application by reflex mechanism, then initialized by host application.
This step is because replacing quoting of all former Application in host application installation kit information by reflecting, the whole context making host application is quoted and has all been replaced to new context, so new context has just become the real context Application that system is approved, and all quoting resources in this new context both point to plug-in unit Apk, just uninstalled plug-in unit Apk successfully can be behaved so host application is follow-up.
In step 508, plug-in unit load operating device, in host application execution process, runs the plug-in unit installation kit pointed by described new context according to described new context.
It appeared that, by above-mentioned process, the embodiment of the present invention realizes dynamically changing the running environment of host application, so that the sensing plug-in unit installation kit that host application is complete, then is no need for the code of amendment plug-in unit installation kit and realizes loading and the operation of plug-in unit installation kit.
Illustrate below in conjunction with an Application Example:
After the installation kit of application program provider one application A of exploitation and plug-in unit Apk bag (such as about 6M), the installation kit (such as about 100K) of a Mini application program B is designed again for it, the installation kit that outside can provide Mini application program B is downloaded for user and installs, this installation kit can only include the icon resource of application A, brand promotion resource, the essential informations such as server domain name, (now Mini application program B is host application) dynamic load again is corresponding as the Mini application program B of user's opening installation plug-in unit Apk bag A also runs, thus normal presentation goes out the true content of application A.
It appeared that, above-mentioned process is be the same with the application A directly opening a 6M in effect, but said process is unaware for a user, the simply installation kit size of user's perception only has 100K, than original 6M reduction in bulk 60 times, it is greatly saved user and downloads the flow of installation kit so that user is more willing to download and install, such that it is able to be greatly promoted outside download and the installation of application program.
It should be noted that embodiment of the present invention technical scheme go for any Android Android application, meanwhile, other operating system platforms can also reference implementation, its principle is identical.
Above describe in detail according to technical scheme by reference to accompanying drawing.
Additionally, the method according to the invention is also implemented as a kind of computer program, this computer program includes the computer program code instruction of the above steps limited in the said method for performing the present invention.Or, the method according to the invention is also implemented as a kind of computer program, this computer program includes computer-readable medium, and storage has the computer program of the above-mentioned functions limited in the said method for performing the present invention on the computer-readable medium.Those skilled in the art will also understand is that, may be implemented as electronic hardware, computer software or both combinations in conjunction with the various illustrative logical blocks described by disclosure herein, module, circuit and algorithm steps.
Flow chart and block diagram in accompanying drawing show the architectural framework in the cards of system and method for the multiple embodiments according to the present invention, function and operation.In this, flow chart or each square frame in block diagram can represent a part for a module, program segment or code, and a part for described module, program segment or code comprises the executable instruction of one or more logic function for realizing regulation.It should also be noted that at some as in the realization replaced, in square frame, the function of institute's labelling can also occur with the order being different from accompanying drawing institute's labelling.Such as, two continuous print square frames can essentially perform substantially in parallel, and they can also perform sometimes in the opposite order, and this determines according to involved function.It will also be noted that, the combination of the square frame in each square frame in block diagram and/or flow chart and block diagram and/or flow chart, can realize by the special hardware based system of the function or operation that perform regulation, or can realize with the combination of specialized hardware Yu computer instruction.
Being described above various embodiments of the present invention, described above is illustrative of, and non-exclusive, and it is also not necessarily limited to disclosed each embodiment.When not necessarily departing from the scope and spirit of illustrated each embodiment, many modifications and changes will be apparent from for those skilled in the art.The selection of term used herein, it is intended to explain the principle of each embodiment, practical application or the improvement to the technology in market best, or make other those of ordinary skill of the art be understood that each embodiment disclosed herein.