CN106445598A - Plug-in loading method and Plug-in loading device - Google Patents

Plug-in loading method and Plug-in loading device Download PDF

Info

Publication number
CN106445598A
CN106445598A CN201610862823.4A CN201610862823A CN106445598A CN 106445598 A CN106445598 A CN 106445598A CN 201610862823 A CN201610862823 A CN 201610862823A CN 106445598 A CN106445598 A CN 106445598A
Authority
CN
China
Prior art keywords
plug
interface
target
unit
ibinder
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201610862823.4A
Other languages
Chinese (zh)
Inventor
张炅轩
宋照春
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Qihoo Technology Co Ltd, Qizhi Software Beijing Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201610862823.4A priority Critical patent/CN106445598A/en
Publication of CN106445598A publication Critical patent/CN106445598A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons

Abstract

The invention provides a plug-in loading method and a plug-in loading device. The method comprises the following steps: when a host program receives a request for loading a plug-in, calling a plug-in loading method to load a target plug-in; in a process of loading the target plug-in, creating an entrance type object of the target plug-in; and by use of an entrance type object, calling a specified method in the entrance type to cache an object of an interface of the target plug-in. Because the object of the interface of the target plug-in can be used for acquiring an IBinder object, when an external caller needs to acquire the IBinder object of the target plug-in, the cached object of the interface of the target plug-in can be directly acquired, and is used for acquiring the IBinder object, and then communication can be performed by use of the acquired IBinder object and the target plug-in.

Description

Plug-in loading method and device
Technical field
The present invention relates to field of computer technology, particularly a kind of plug-in loading method and device.
Background technology
IBinder is the basic interface of remote object, is the core of the lightweight remote procedure call mechanism designing for high-performance Heart part, the far call (i.e. striding course calls) of Android is through what IBinder realized.But it is applied not only to remotely Call, it is also possible to call in process.This interface definition agreement mutual with remote object.
The main API (Application Program Interface, application programming interfaces) of IBinder is Transact (), other method corresponding with it is Binder.onTransact ().First method is used for local terminal to far-end IBinder object sends and calls, and second method can respond calling of receiving for the remote object of local terminal. The API of IBinder is that synchronization performs, and such as transact () is until the Binder.onTransact () method of the other side is adjusted Just return after completing.Call when occurring in process such beyond doubt, and when between process, with the help of IPC, be also Same effect.
In correlation technique, the mode of Service can be used to obtain IBinder object, its advantage is can be fully sharp By the characteristic of Service and IBinder, but shortcoming is also evident from:
1) the method is asynchronous operation, after each bindService completes, it is necessary to wait onServiceConnection Just can do next step after readjustment, this is accomplished by the content etc. remembeing to operate last time when readjustment, develops very loaded down with trivial details, and holds Error-prone;
2) Service hole is limited, either the scheme of original mobile phone bodyguard, or DroidPlugin, plug-in unit to be used Service is accomplished by applying for multiple " hole position ", once cheats position deficiency, then there will be collapse, confuses the serious problems such as Service;
3) the function scene of mobile phone bodyguard is more, and between this plug-in unit, the mode of communication is through commonly used, it is clear that exploitation is got over Light weight, if efficiency is higher, but simple is used Service scheme, also cannot meet this point.
In other correlation techniques, Socket communication (or similar type) can be used to carry out " simulation " synchronizing process, specifically Way is to set up two Socket, is responsible for sending message for one, is responsible for for one receiving message.Wherein sending message side, sending out Starting after outbound message to read caching, entering blocked state with this, recipient is then forwarded to sender after receiving message, now blocks State disappears, and reads message.The advantage of this scheme is to accomplish that synchronization is carried out, and transmission medium (is two to enter more flexibly after all entirely System).But, its shortcoming is also more obvious with Service than simple:
(1) need to set up two Socket to communicate, operate extremely loaded down with trivial details;
(2) once recipient's process surprisingly terminates, and cannot immediately know that situation as sender, and time-out can only be waited to terminate After could continue, be rejected but has a problem in that time-out has both been likely to be process, it is also possible to be to make mistakes;
(3) channel uses binary system, writes very not directly perceived;
(4) Socket communication too late IBinder in efficiency;
(5) there is certain potential safety hazard in Socket communication.
In sum, inventor's discovery urgently provides a kind of quick, side of synchronously acquisition plug-in unit IBinder object Case.
Content of the invention
In view of the above problems, it is proposed that the present invention in case provide one overcome the problems referred to above or at least in part solve on State the plug-in loading method of problem and corresponding device.
According to an aspect of of the present present invention, provide a kind of plug-in loading method, including:
When host program receives the request loading plug-in unit, call plug-in loading method and target plug-in is loaded;
During loaded targets plug-in unit, create the object of the entrance class of target plug-in;
Utilize the object of described entrance class, call interface right of designation method caching of target plug-in unit in described entrance class As.
Alternatively, the object of the interface of target plug-in is used for obtaining IBinder object, and described method also includes:
When external call side needs the IBinder object obtaining target plug-in, call in predefined predefined class Designation method;
Utilize the designation method in described predefined class, the designation method from described entrance class obtains target plug-in The object of interface;
Designation method in the object of the interface of invocation target plug-in unit obtains IBinder object.
Alternatively, after the designation method in the object of the interface of invocation target plug-in unit obtains IBinder object, described Method also includes:
The IBinder object obtaining is utilized to carry out communicating with described target plug-in.
Alternatively, the entrance class of described target plug-in is Entry class.
Alternatively, the interface of described target plug-in is IPlugin interface, and the object of described IPlugin interface is mPlugin Object.
Alternatively, described method also includes:
Utilizing the object of described entrance class, reflection obtains the designation method in described entrance class.
Alternatively, when external call side needs the IBinder object obtaining target plug-in, call predefined predetermined Designation method in justice class, including:
When external call side needs the IBinder object obtaining target plug-in, it is judged that described external call side place is worked as Whether front process is same process with the recipient place target process of the IBinder object that will return described target plug-in;
If so, the designation method in predefined predefined class is then directly invoked.
Alternatively, described method also includes:
If the reception of described external call side place current process and the IBinder object that described target plug-in will be returned Side's place target process is not same process, then obtained the interface of host program by the Provider in described target process Object;
By the designation method in the object of the interface of host program, call the designated parties in predefined predefined class Method.
Alternatively, described target process is Resident Process.
Alternatively, the interface of described host program is IpluginHost interface.
Alternatively, the designation method in the object of the interface of invocation target plug-in unit obtains IBinder object, including:
Designation method in the object of the interface of invocation target plug-in unit;
Return corresponding IBinder object according to module name.
Alternatively, when host program receives the instruction loading plug-in unit, call plug-in loading method and target plug-in is entered Row loads, including:
Plug-in unit load events is split as at least one independent load phase, and wherein, each load phase is corresponding different Plug-in content;
When host program receives the instruction loading plug-in unit, determine the corresponding target load phase of described request;
Load the corresponding plug-in content of described target load phase.
Alternatively, at least one load phase described includes at least one following:
The acquisition of plugin information, the loading of plug-in resource, the loading of plug-in code.
According to another aspect of the present invention, additionally provide a kind of plug-in unit charger, including:
Load-on module, is suitable to, when host program receives the instruction loading plug-in unit, call plug-in loading method to target Plug-in unit loads;
Creation module, is suitable to during loaded targets plug-in unit, creates the object of the entrance class of target plug-in;
Cache module, is suitable to utilize the object of described entrance class, calls the designation method caching of target in described entrance class The object of the interface of plug-in unit.
Alternatively, the object of the interface of target plug-in is used for obtaining IBinder object, and described device also includes:
Calling module, is suitable to, when external call side needs the IBinder object obtaining target plug-in, call pre-defined Predefined class in designation method;
First acquisition module, is suitable to utilize the designation method in described predefined class, the designated parties from described entrance class Method obtains the object of the interface of target plug-in;
Second acquisition module, the designation method in the object of the interface being suitable to invocation target plug-in unit obtains IBinder object.
Alternatively, described device also includes:
Communication module, the designation method being suitable in the object of the interface of described second acquisition module invocation target plug-in unit obtains After taking IBinder object, the IBinder object obtaining is utilized to carry out communicating with described target plug-in.
Alternatively, the entrance class of described target plug-in is Entry class.
Alternatively, the interface of described target plug-in is IPlugin interface, and the object of described IPlugin interface is mPlugin Object.
Alternatively, described device also includes:
3rd acquisition module, is suitable to utilize the object of described entrance class, and reflection obtains the designation method in described entrance class.
Alternatively, described calling module is further adapted for:
When external call side needs the IBinder object obtaining target plug-in, it is judged that described external call side place is worked as Whether front process is same process with the recipient place target process of the IBinder object that will return described target plug-in;
If so, the designation method in predefined predefined class is then directly invoked.
Alternatively, described calling module is further adapted for:
If the reception of described external call side place current process and the IBinder object that described target plug-in will be returned Side's place target process is not same process, then obtained the interface of host program by the Provider in described target process Object;
By the designation method in the object of the interface of host program, call the designated parties in predefined predefined class Method.
Alternatively, described target process is Resident Process.
Alternatively, the interface of described host program is IpluginHost interface.
Alternatively, described second acquisition module is further adapted for:
Designation method in the object of the interface of invocation target plug-in unit;
Return corresponding IBinder object according to module name.
Alternatively, described load-on module is further adapted for:
Plug-in unit load events is split as at least one independent load phase, and wherein, each load phase is corresponding different Plug-in content;
When host program receives the instruction loading plug-in unit, determine the corresponding target load phase of described request;
Load the corresponding plug-in content of described target load phase.
Alternatively, at least one load phase described includes at least one following:
The acquisition of plugin information, the loading of plug-in resource, the loading of plug-in code.
The technical scheme that the embodiment of the present invention provides, when host program receives the request loading plug-in unit, calls plug-in unit Target plug-in is loaded by loading method, can create entrance class right of target plug-in during loaded targets plug-in unit As, and utilize the object of entrance class, the object of the interface of the designation method caching of target plug-in unit in the class of call entry.Due to this mesh The object of the interface of mark plug-in unit can be used in obtaining IBinder object, thus when external call side needs to obtain target plug-in During IBinder object, can directly obtain the object of the interface of the target plug-in of caching, and utilize the interface of this target plug-in Object obtains IBinder object, and then the IBinder object of acquisition can be utilized to communicate with target plug-in.Thus may be used See, the embodiment of the present invention can make full use of the logic of android system realize quick in plug-in unit, synchronously obtain IBinder object, it is achieved the communication in process or between process.
Described above is only the general introduction of technical solution of the present invention, in order to better understand the technological means of the present invention, And can be practiced according to the content of specification, and in order to allow above and other objects of the present invention, the feature and advantage can Become apparent, below the detailed description of the invention especially exemplified by the present invention.
According to below in conjunction with the detailed description to the specific embodiment of the invention for the accompanying drawing, those skilled in the art will be brighter Above-mentioned and other purposes, the advantages and features of the present invention.
Brief description
By reading the detailed description of hereafter preferred embodiment, various other advantage and benefit common for this area Technical staff will be clear from understanding.Accompanying drawing is only used for illustrating the purpose of preferred embodiment, and is not considered as to the present invention Restriction.And it in whole accompanying drawing, is denoted by the same reference numerals identical parts.In the accompanying drawings:
Fig. 1 shows the flow chart of plug-in loading method according to an embodiment of the invention;
Fig. 2 shows the structural representation of plug-in unit charger according to an embodiment of the invention;And
Fig. 3 shows the structural representation of plug-in unit charger in accordance with another embodiment 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 disclosure Exemplary embodiment, it being understood, however, that may be realized in various forms the disclosure and should be by embodiments set forth here Limited.On the contrary, these embodiments are provided to be able to be best understood from the disclosure, and can be by the scope of the present disclosure Complete conveys to those skilled in the art.
For solving above-mentioned technical problem, embodiments provide a kind of plug-in loading method.Fig. 1 shows according to this Invent the flow chart of the plug-in loading method of an embodiment.As it is shown in figure 1, the method at least comprises the following steps S102 to step S106.
Step S102, when host program receives the request loading plug-in unit, calls plug-in loading method to target plug-in Load.
Step S104, during loaded targets plug-in unit, creates the object of the entrance class of target plug-in.
Step S106, utilizes the object of entrance class, the interface of the designation method caching of target plug-in unit in the class of call entry Object.
The technical scheme that the embodiment of the present invention provides, when host program receives the request loading plug-in unit, calls plug-in unit Target plug-in is loaded by loading method, can create entrance class right of target plug-in during loaded targets plug-in unit As, and utilize the object of entrance class, the object of the interface of the designation method caching of target plug-in unit in the class of call entry.Due to this mesh The object of the interface of mark plug-in unit can be used in obtaining IBinder object, thus when external call side needs to obtain target plug-in During IBinder object, can directly obtain the object of the interface of the target plug-in of caching, and utilize the interface of this target plug-in Object obtains IBinder object, and then the IBinder object of acquisition can be utilized to communicate with target plug-in.Thus may be used See, the embodiment of the present invention can make full use of the logic of android system realize quick in plug-in unit, synchronously obtain IBinder object, it is achieved the communication in process or between process.
In above step S102 when host program receives the request loading plug-in unit, call plug-in loading method to target Plug-in unit loads, and embodiments provides a kind of optional scheme, i.e. plug-in unit load events is split as independent extremely A few load phase, wherein, the corresponding different plug-in content of each load phase;Load plug-in unit when host program receives During instruction, determine the corresponding target load phase of request;And then the corresponding plug-in content of loaded targets load phase.Here, extremely A few load phase can include the acquisition (i.e. Info) of plugin information, the loading (i.e. Res) of plug-in resource, plug-in code Load (i.e. Dex).In actual applications, Info is minimum unit, to load Res, then must first load Info;To load Dex, then first must load Info and Res successively.For example, the external world calls load and carries out plug-in unit loading, and TYPE represents and to add Be downloaded to which stage (Info, Res and Dex).Call loadInfo simultaneously and first carry out the loading of Info.LoadInfo success and TYPE is Info, represents only for loading Info, returns;LoadRes success and TYPE are Res, represent only for load Info and Res, returns;LoadDex success and TYPE are Dex, and expression need to all load, and directly returns.
In the alternative embodiment of the present invention, when the object of the interface of target plug-in is used for obtaining IBinder object, then When external call side needs the IBinder object obtaining target plug-in, call the designated parties in predefined predefined class Method, and then utilize the designation method in predefined class, obtains interface right of target plug-in in the designation method from entrance class As such that it is able to the designation method in the object of the interface of invocation target plug-in unit obtains IBinder object.
Further, after the designation method in the object of the interface of invocation target plug-in unit obtains IBinder object, can To utilize the IBinder object obtaining to carry out communicating with target plug-in, realize corresponding function or task.
The entrance class of plug-in unit mentioned above can be Entry class.The entrance of plug-in unit can also as Activity, This five big entrance of Service, Provider, Receiver and Application.But, Entry is to be called the earliest in plug-in unit , it is similar to the Dalvik.main of Android, is the place of whole plug-in unit entrance the earliest, be suited for use in initializing, Cache interfaces etc. operate.
Further, the object that the designation method create method in Entry class of calling carrys out the interface of cache plug-in, this is inserted The interface of part finally returns host program, is scheduling by host program, it is achieved the linkage between host program and plug-in unit.This In, the interface of plug-in unit can be IPlugin interface, and the object of IPlugin interface can be mPlugin object.IPlugin interface In can state the information such as the host of plug-in unit, name, description, author, version, and the resource such as UI toolbar, menu, and can To be added as required or to delete.
Utilize the object of entrance class in above step S104, connecing of the designation method caching of target plug-in unit in the class of call entry Before the object of mouth, the embodiment of the present invention can also utilize the object of entrance class, and reflection obtains the designation method in entrance class.
Further, mentioned above, when external call side needs the IBinder object obtaining target plug-in, call pre- Designation method in the predefined class first defining, embodiments provides a kind of optional scheme, in this scenario, when outward Portion's called side need obtain target plug-in IBinder object when, it can be determined that external call side place current process with will Whether the recipient place target process of the IBinder object returning target plug-in is same process;If so, then directly invoke pre- Designation method in the predefined class first defining;Otherwise, if it is not, then obtain host program by the Provider in target process The object of interface, and then by the designation method in the object of the interface of host program, call in predefined predefined class Designation method.
For example, predefined predefined class is PluginFactory class, and such is the external entrance class for plug-in unit, Such designation method is query, defines this query method for quick obtaining IBinder object.Optional reality in the present invention Executing in example, target process can be Resident Process.Additionally, the interface of host program can be IPluginHost interface, here There is provided necessary host's function or resource to plug-in unit, such as the connecting object etc. of file object, database.So, each is inserted Part can be accessed resource or the function of host program by Host parameter.
Designation method in the object of the interface of invocation target plug-in unit mentioned above obtains IBinder object, the present invention Embodiment provides a kind of optional scheme, i.e. the designation method in the object of the interface of invocation target plug-in unit, and then according to Module name returns corresponding IBinder object.
In the alternative embodiment of the present invention, after the object of the entrance class that step S102 creates plug-in unit, can also determine Designation method in justice entrance class returns the designated value (e.g., null etc.) representing that loading is failed.Thus, in utilizing predefined class Designation method, when the designation method from entrance class obtains the object of interface of target plug-in, if the finger from entrance class Determine method does not gets the object of the interface of target plug-in, and return this designated value, it is determined that plug-in unit loads unsuccessfully.
In one embodiment, Main Client is " host program " part, and Plugin is " inside plug-in unit " part, Android System is then " system API ", and API is the calling interface that operating system leaves application program for here, should Operating system is made to go to perform order or the action of application program by program by the API of call operation system.At Main PluginFactory, PluginLoader class defined in Client, changes Entry class in Plugin, is described in detail below Obtain the process of the IBinder object of plug-in unit.
First it is PluginFactory class.Such is unique external entrance class for plug-in unit.Here because only using Query, therefore only list the method:
query:Quick obtaining IBinder.Searching target process, searching corresponding plug-in unit loading etc. are complete all in this method Become.Detailed directions and flow process have narration later.
Next to that PluginLoader class.Such is mainly responsible for the loading section of plug-in unit:
load:Load a plug-in unit.
query:Called by PluginFactory, once find process and plug-in unit, then the method will directly invoke previously The IPlugin.query method having cached uses.
Followed by Entry class.Such is the entrance class of all plug-in units, only a method:
create:The entrance of plug-in unit.Its return value is just the IPlugin object used in the present invention.If returning null, then Indication plug unit loads unsuccessfully.
Meanwhile, the flow process of some plug-in initialization also can embody in this method.
IPlugin interface is one of core classes, and it is the entrance obtaining IBinder object, is present in plug-in unit.
query:As plug-in unit side, the method need to be realized, and return corresponding IBinder object according to module name, For the external world.
The acquisition plug-in unit of the present invention will be discussed in detail in terms of IBinder being installed and uses IBinder two below The method of IBinder object realize process.
First, IBinder is installed.When loading plug-in unit every time, the embodiment of the present invention all can be attempted caching IPlugin class, And this type of exists as the acquisition class of IBinder just, this process is described below.
Use PluginLoader.load method to load plug-in unit, during loading plug-in unit, need to create entering of plug-in unit The object of mouth class (i.e. Entry class), this object and method are required to be created by reflection and called, specifically include following two Step 101 and 102:
101:Reflection obtains the description of Entry.create method;
102:Call the method to describe, cache mPlugin object.
Specific code is as follows:
In embodiments of the present invention, for convenience's sake, it is stipulated that the full name of all of plug-in unit entrance class follows following rule Then:" com.qihoo360.plugin. "+plug-in unit name+" .Entry ".Entrance class as shaken plug-in unit is entirely entitled: com.qihoo360.plugin.shakeoff.Entry.It is of course also possible to by AndroidManifest.xml Meta-data comes the position of self-defined Entry class.
Additionally, in mobile phone bodyguard's product, IPlugin is become AIDL (Android Interface Definition Language, Android IDL) class, so can make full use of some characteristics of AIDL.So far, IPlugin pair As just caching completes and standby at any time.
Secondly, IBinder is used.Before introducing, first define some terms:
Called side:Refer to the one end needing to use IBinder, mainly call one end of PluginFactory.query;
Recipient:Refer to return one end of IBinder, one end that mainly IPlugin.query end is processed;
Target process:Finger debit place process.Recipient can be a process with called side, it is also possible to striding course goes Call.
When external plug-in needs to use IBinder, need through several steps 201 to 205:
201:First determining whether whether target process is current process, in other words, whether called side and recipient require one In individual process, if so, then continue executing with 202;Otherwise, if it is not, then continue executing with 203.
202:Obtain IBinder object.
203:Judge whether target process is Resident Process.If so, striding course is then needed to go to call in Resident Process Query method.
204:There is a Provider in Resident Process, obtain IPluginHost (being also IBinder) object, then Do next step operation again.
205:Utilizing AIDL to call IPluginHost.queryPluginBinder method, what it still called is PluginFactory, only the target process of current transmission is " current ".
Specific code is as follows:
Hereinafter will stress step 202,204 and 205.
In fact, embodiments provide " one process " and " striding course " two schemes.If " one process " side If case, it is only necessary to 202 steps, other steps all can be omitted." striding course " scheme then needs to consider a variety of situation, Therefore still need to above-mentioned in steps.
In step 202., PluginFactory.query method is first defined.The method is used for obtaining or loading plug-in unit, And call the interface that its IPlugin provides, step following 301 to 307:
301-302:Attempt obtaining or load plug-in unit Dex, returning qualified PluginLoader object;
303-305:By the query () method in PluginLoader object, attempt taking from Entry The object of IPlugin, calls its query method, to obtain IBinder object.
306-307:IPlugin in plug-in unit calls its query method, obtains IBinder object and return to Extraneous.
Specific code is as follows:
Wherein mPlugins field is used for recording all of plugin information, and whether tube insert is not loaded, no longer superfluous here State.
The query method of PluginLoader class is exactly from just now when loading plug-in unit, takes IPlugin from Entry In call its query method, specific code is as follows:
In step 204 and 205, it is possible to achieve striding course obtains IBinder object.Striding course obtains and is characterized by:
Obtain this AIDL object of IPluginHost by Provider;
Call PluginFactory.query () method by IPluginHost.query () method.
Wherein, the acquisition of IPluginHost can be obtained by SyncServiceManager.getService.One After denier takes IPluginHost object, PluginFactory.query method can be directly invoked, and then call Entry.create method obtains the object (that is, mPlugin object) of the interface of plug-in unit, afterwards, calls the interface of plug-in unit Query method in object obtains IBinder object.
Additionally, the embodiment of the present invention can also define IPlugin and plug-in initialization.As card i/f definition side, fixed Justice has only to make carbon copies IPlugin.query method for the IPlugin object that the external world accesses, and returns this object in Entry class ?.Here, can also do the certain operations of plug-in initialization, and once operation failure, then can return null, this will accuse Telling the external world, plug-in unit loads unsuccessfully.
Specific code is as follows:
If the external world wants to obtain the AIDL of IAccountManager, only need to so call:
Wherein first parameter is plug-in unit name, and second is module name.The IBinder object taken needs reconvert to become After IAccountManager.
To sum up introducing, the embodiment of the present invention can be accomplished:
(1) have only to obtain AIDL by PluginFactory.query method, there is no excess step;
(2) have only to define IPlugin.query and arrange return value just to define AIDL, also without unnecessary step Suddenly;
(3) current process is not only supported, can be (certainly, to be not limited solely to reside, also in striding course to Resident Process Can at UI, individually etc.)
(4) in the create method of Entry class, initialization operation extra a bit can also be done, facilitate plug-in unit to do next Step operation.Its thing done and Application can form complementation.
Further, designation method in the object of the interface of invocation target plug-in unit above obtain IBinder object it After, it is possible to use the IBinder object of acquisition carries out communicating with target plug-in, realizes corresponding function or task.
The far call (i.e. striding course calls) of Android is through what IBinder realized, and IBinder is remotely right The basic interface of elephant, is the core of the lightweight remote procedure call mechanism designing for high-performance.But it is applied not only to remotely Call, call in being also used for process.This interface definition agreement mutual with remote object.Must not be directly realized by this connect Mouthful, and should derive from from Binder.The main API of IBinder is transact (), and other method corresponding with it is Binder.onTransact().First method makes caller send to the IBinder object of far-end to call, second Method enables the remote object of called side to respond calling of receiving.The API of IBinder is that synchronization performs, such as Transact () is until the Binder.onTransact () method call of the other side just returns after completing.Call generation in process When such beyond doubt, and when between process, with the help of IPC, be also same effect.
The data being sent by transact () are Parcel, and Parcel is a kind of general buffering area, except there being data Also with some, the metadata of its content is described outward.Metadata, thus can be in buffering for managing quoting of IBinder object District preserves these when moving to another process from a process and quotes.This ensures that there when an IBinder is written to Parcel is simultaneously sent in another process, if another process postbacks original entering quoting of same IBinder Journey, then this original process just can receive quoting of that IBinder sending.This mechanism make IBinder and Binder manages as unique identifier between process.
System is that each process safeguards a thread pool depositing exchange threads.These exchange threads be used for sending with charge free all from The IPC that other process is sent calls.For example, when an IPC is dealt into process B from process A, in A, that sends thread (this calling Individual should not be in thread pool) be just blocked in transact () and suffer.One of exchange threads pond in process B thread connects Having received this to call, it calls Binder.onTransact (), to return as result with a Parcel after completing.Then That thread waiting in process A is continued executing with after receiving the Parcel of return.In fact, another process has been seen It similarly is a thread of current process, but be not that current process creates.
Recursive call between Binder mechanism also support process.For example, process A performs the IBinder's of oneself The Binder of transact () calling process B, and process B uses transact () in its Binder.onTransact () To process A initiate call, then process A wait it send while calling return, also can use Binder.onTransact The transact () of () response process B.The result that Binder causes in a word makes calling of striding course and calling no in process What difference.
The plug-in loading method providing based on each embodiment above, based on same inventive concept, the embodiment of the present invention is also Provide a kind of plug-in unit charger.
Fig. 2 shows the structural representation of plug-in unit charger according to an embodiment of the invention.As in figure 2 it is shown, should Device at least can include load-on module the 210th, creation module 220 and cache module 230.
Now introduce the company between each composition of the plug-in unit charger of the embodiment of the present invention or the function of device and each several part Connect relation:
Load-on module 210, is suitable to, when host program receives the instruction loading plug-in unit, call plug-in loading method to mesh Mark plug-in unit loads;
Creation module 220, is coupled with load-on module 210, is suitable to during loaded targets plug-in unit, creates target and inserts The object of the entrance class of part;
Cache module 230, is coupled with creation module 220, is suitable to utilize the object of described entrance class, calls described entrance The object of the interface of the designation method caching of target plug-in unit in class.
In an embodiment of the present invention, as it is shown on figure 3, the device that figure 2 above is shown can also include:
Calling module 240, is coupled with cache module 230, is suitable to the object of interface of target plug-in for obtaining IBinder object, when external call side needs the IBinder object obtaining target plug-in, calls predefined predefined Designation method in class;
First acquisition module 250, is coupled with calling module 240, is suitable to utilize the designation method in described predefined class, Designation method from described entrance class obtains the object of the interface of target plug-in;
Second acquisition module 260, is coupled with the first acquisition module 250, is suitable to the object of the interface of invocation target plug-in unit In designation method obtain IBinder object.
In an embodiment of the present invention, as it is shown on figure 3, the device that figure 2 above is shown can also include:
Communication module 270, is coupled with the second acquisition module 260, is suitable in described second acquisition module 260 invocation target After designation method in the object of the interface of plug-in unit obtains IBinder object, the IBinder object obtaining is utilized to carry out and institute State target plug-in to communicate.
In an embodiment of the present invention, the entrance class of described target plug-in is Entry class.
In an embodiment of the present invention, the interface of described target plug-in is IPlugin interface, described IPlugin interface Object is mPlugin object.
In an embodiment of the present invention, as it is shown on figure 3, the device that figure 2 above is shown can also include:
3rd acquisition module 280, is coupled with creation module the 220th, cache module 230, is suitable to utilize described entrance class Object, reflection obtains the designation method in described entrance class.
In an embodiment of the present invention, above-mentioned calling module 240 is further adapted for:
When external call side needs the IBinder object obtaining plug-in unit, it is judged that described external call side place is when advance Whether journey is same process with the recipient place target process of the IBinder object that will return described target plug-in;
If so, the designation method in predefined predefined class is then directly invoked.
In an embodiment of the present invention, above-mentioned calling module 240 is further adapted for:
If the reception of described external call side place current process and the IBinder object that described target plug-in will be returned Side's place target process is not same process, then obtained the interface of host program by the Provider in described target process Object;
By the designation method in the object of the interface of host program, call the designated parties in predefined predefined class Method.
In an embodiment of the present invention, described target process is Resident Process.
In an embodiment of the present invention, the interface of described host program is IPluginHost interface.
In an embodiment of the present invention, above-mentioned second acquisition module 260 is further adapted for:
Designation method in the object of the interface of invocation target plug-in unit;
Return corresponding IBinder object according to module name.
In an embodiment of the present invention, above-mentioned load-on module 210 is further adapted for:
Plug-in unit load events is split as at least one independent load phase, and wherein, each load phase is corresponding different Plug-in content;
When host program receives the instruction loading plug-in unit, determine the corresponding target load phase of described request;
Load the corresponding plug-in content of described target load phase.
In an embodiment of the present invention, at least one load phase described includes at least one following:
The acquisition of plugin information, the loading of plug-in resource, the loading of plug-in code.
According to the combination of any one preferred embodiment above-mentioned or multiple preferred embodiment, the embodiment of the present invention can reach Following beneficial effect:
The technical scheme that the embodiment of the present invention provides, when host program receives the request loading plug-in unit, calls plug-in unit Target plug-in is loaded by loading method, can create entrance class right of target plug-in during loaded targets plug-in unit As, and utilize the object of entrance class, the object of the interface of the designation method caching of target plug-in unit in the class of call entry.Due to this mesh The object of the interface of mark plug-in unit can be used in obtaining IBinder object, thus when external call side needs to obtain target plug-in During IBinder object, can directly obtain the object of the interface of the target plug-in of caching, and utilize the interface of this target plug-in Object obtains IBinder object, and then the IBinder object of acquisition can be utilized to communicate with target plug-in.Thus may be used See, the embodiment of the present invention can make full use of the logic of android system realize quick in plug-in unit, synchronously obtain IBinder object, it is achieved the communication in process or between process.
In specification mentioned herein, illustrate a large amount of detail.It is to be appreciated, however, that the enforcement of the present invention Example can be put into practice in the case of not having these details.In some instances, it is not 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 to understand one or more of each inventive aspect, exist Above in the description of the exemplary embodiment of the present invention, each feature of the present invention is grouped together into single enforcement sometimes In example, figure or descriptions thereof.But, the method for the disclosure should be construed to reflect following intention:I.e. required guarantor The application claims protecting more feature than the feature being expressly recited in each claim.More precisely, it is such as following Claims reflected as, inventive aspect is all features less than single embodiment disclosed above.Therefore, The claims following detailed description of the invention are thus expressly incorporated in this detailed description of the invention, wherein each claim itself All independent embodiments as the present invention.
Those skilled in the art are appreciated that and can carry out the module in the equipment in embodiment adaptively Change and they are arranged in one or more equipment different from this embodiment.Can be the module in embodiment or list Unit or assembly are combined into a module or unit or assembly, and can put them in addition multiple submodule or subelement or Sub-component.In addition at least some in such feature and/or process or unit excludes each other, can use any Combination is to all features disclosed in this specification (including adjoint claim, summary and accompanying drawing) and so disclosed appoints Where all processes or the unit of method or equipment is combined.Unless expressly stated otherwise, this specification (includes adjoint power Profit requires, summary and accompanying drawing) disclosed in each feature the alternative features providing identical, equivalent or similar purpose can be carried out generation Replace.
Although additionally, it will be appreciated by those of skill in the art that some embodiments described herein include other embodiments In some included feature rather than further feature, but the combination of the feature of different embodiment means to be in the present invention's Within the scope of and form different embodiments.For example, in detail in the claims, embodiment required for protection one of arbitrarily Can mode use in any combination.
The all parts embodiment of the present invention can realize with hardware, or to run on one or more processor Software module realize, or with combinations thereof realize.It will be understood by those of skill in the art that and can use in practice Microprocessor or digital signal processor (DSP) realize some in plug-in unit charger according to embodiments of the present invention or The some or all functions of the whole parts of person.The present invention is also implemented as performing method as described herein Point or whole equipment or device program (for example, computer program and computer program).Such realize this Bright program can store on a computer-readable medium, or can have the form of one or more signal.Such Signal can be downloaded from internet website and obtain, or provides on carrier signal, or provides with any other form.
The present invention will be described rather than limits the invention to it should be noted above-described embodiment, and ability Field technique personnel can design alternative embodiment without departing from the scope of the appended claims.In the claims, Any reference symbol that should not will be located between bracket is configured to limitations on claims.Word "comprising" does not excludes the presence of not Arrange element in the claims or step.Word "a" or "an" before being positioned at element does not excludes the presence of multiple such Element.The present invention can come in fact by means of the hardware including some different elements and by means of properly programmed computer Existing.If in the unit claim listing 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.These word explanations can be run after fame Claim.
So far, although those skilled in the art will appreciate that detailed the multiple of the present invention of illustrate and describing show herein Example embodiment, but, without departing from the spirit and scope of the present invention, still can be direct according to present disclosure Determine or derive other variations or modifications of many meeting the principle of the invention.Therefore, the scope of the present invention is it is understood that and recognize It is set to and cover other variations or modifications all these.
The embodiment of the present invention additionally provides A1, a kind of plug-in loading method, including:
When host program receives the request loading plug-in unit, call plug-in loading method and target plug-in is loaded;
During loaded targets plug-in unit, create the object of the entrance class of target plug-in;
Utilize the object of described entrance class, call interface right of designation method caching of target plug-in unit in described entrance class As.
A2, the method according to A1, wherein, the object of the interface of target plug-in is used for obtaining IBinder object, described Method also includes:
When external call side needs the IBinder object obtaining target plug-in, call in predefined predefined class Designation method;
Utilize the designation method in described predefined class, the designation method from described entrance class obtains target plug-in The object of interface;
Designation method in the object of the interface of invocation target plug-in unit obtains IBinder object.
A3, the method according to A2, wherein, the designation method in the object of the interface of invocation target plug-in unit obtains After IBinder object, described method also includes:
The IBinder object obtaining is utilized to carry out communicating with described target plug-in.
A4, the method according to according to any one of A1-A3, wherein, the entrance class of described target plug-in is Entry class.
A5, the method according to according to any one of A1-A4, wherein, the interface of described target plug-in is IPlugin interface, The object of described IPlugin interface is mPlugin object.
A6, the method according to according to any one of A1-A5, wherein, also include:
Utilizing the object of described entrance class, reflection obtains the designation method in described entrance class.
A7, the method according to according to any one of A2-A6, wherein, when external call side needs to obtain target plug-in During IBinder object, call the designation method in predefined predefined class, including:
When external call side needs the IBinder object obtaining target plug-in, it is judged that described external call side place is worked as Whether front process is same process with the recipient place target process of the IBinder object that will return described target plug-in;
If so, the designation method in predefined predefined class is then directly invoked.
A8, the method according to A7, wherein, also include:
If the reception of described external call side place current process and the IBinder object that described target plug-in will be returned Side's place target process is not same process, then obtained the interface of host program by the Provider in described target process Object;
By the designation method in the object of the interface of host program, call the designated parties in predefined predefined class Method.
A9, the method according to A8, wherein, described target process is Resident Process.
A10, the method according to A8 or A9, wherein, the interface of described host program is IPluginHost interface.
A11, the method according to according to any one of A1-A10, wherein, finger in the object of the interface of invocation target plug-in unit Method of determining obtains IBinder object, including:
Designation method in the object of the interface of invocation target plug-in unit;
Return corresponding IBinder object according to module name.
A12, the method according to according to any one of A1-A11, wherein, when host program receives the instruction of loading plug-in unit When, call plug-in loading method and target plug-in is loaded, including:
Plug-in unit load events is split as at least one independent load phase, and wherein, each load phase is corresponding different Plug-in content;
When host program receives the instruction loading plug-in unit, determine the corresponding target load phase of described request;
Load the corresponding plug-in content of described target load phase.
A13, the method according to A12, wherein, at least one load phase described includes at least one following:
The acquisition of plugin information, the loading of plug-in resource, the loading of plug-in code.
The embodiment of the present invention additionally provides B14, a kind of plug-in unit charger, including:
Load-on module, is suitable to, when host program receives the instruction loading plug-in unit, call plug-in loading method to target Plug-in unit loads;
Creation module, is suitable to during loaded targets plug-in unit, creates the object of the entrance class of target plug-in;
Cache module, is suitable to utilize the object of described entrance class, calls the designation method caching of target in described entrance class The object of the interface of plug-in unit.
B15, the device according to B14, wherein, the object of the interface of target plug-in is used for obtaining IBinder object, institute State device also to include:
Calling module, is suitable to, when external call side needs the IBinder object obtaining target plug-in, call pre-defined Predefined class in designation method;
First acquisition module, is suitable to utilize the designation method in described predefined class, the designated parties from described entrance class Method obtains the object of the interface of target plug-in;
Second acquisition module, the designation method in the object of the interface being suitable to invocation target plug-in unit obtains IBinder object.
B16, the device according to B15, wherein, also include:
Communication module, the designation method being suitable in the object of the interface of described second acquisition module invocation target plug-in unit obtains After taking IBinder object, the IBinder object obtaining is utilized to carry out communicating with described target plug-in.
B17, the device according to according to any one of B14-B16, wherein, the entrance class of described target plug-in is Entry class.
B18, the device according to according to any one of B14-B17, wherein, the interface of described target plug-in is that IPlugin connects Mouthful, the object of described IPlugin interface is mPlugin object.
B19, the device according to according to any one of B14-B18, wherein, also include:
3rd acquisition module, is suitable to utilize the object of described entrance class, and reflection obtains the designation method in described entrance class.
B20, the device according to according to any one of B15-B19, wherein, described calling module is further adapted for:
When external call side needs the IBinder object obtaining target plug-in, it is judged that described external call side place is worked as Whether front process is same process with the recipient place target process of the IBinder object that will return described target plug-in;
If so, the designation method in predefined predefined class is then directly invoked.
B21, the device according to B20, wherein, described calling module is further adapted for:
If the reception of described external call side place current process and the IBinder object that described target plug-in will be returned Side's place target process is not same process, then obtained the interface of host program by the Provider in described target process Object;
By the designation method in the object of the interface of host program, call the designated parties in predefined predefined class Method.
B22, the device according to B21, wherein, described target process is Resident Process.
B23, the device according to B21 or B22, wherein, the interface of described host program is IPluginHost interface.
B24, the device according to according to any one of B14-B23, wherein, described second acquisition module is further adapted for:
Designation method in the object of the interface of invocation target plug-in unit;
Return corresponding IBinder object according to module name.
B25, the device according to according to any one of B14-B24, wherein, described load-on module is further adapted for:
Plug-in unit load events is split as at least one independent load phase, and wherein, each load phase is corresponding different Plug-in content;
When host program receives the instruction loading plug-in unit, determine the corresponding target load phase of described request;
Load the corresponding plug-in content of described target load phase.
B26, the device according to B25, wherein, at least one load phase described includes at least one following:
The acquisition of plugin information, the loading of plug-in resource, the loading of plug-in code.

Claims (10)

1. a plug-in loading method, including:
When host program receives the request loading plug-in unit, call plug-in loading method and target plug-in is loaded;
During loaded targets plug-in unit, create the object of the entrance class of target plug-in;
Utilize the object of described entrance class, call the object of the interface of designation method caching of target plug-in unit in described entrance class.
2. method according to claim 1, wherein, the object of the interface of target plug-in is used for obtaining IBinder object, institute Method of stating also includes:
When external call side needs the IBinder object obtaining target plug-in, call the finger in predefined predefined class Determine method;
Utilize the designation method in described predefined class, the designation method from described entrance class obtains the interface of target plug-in Object;
Designation method in the object of the interface of invocation target plug-in unit obtains IBinder object.
3. method according to claim 2, wherein, the designation method in the object of the interface of invocation target plug-in unit obtains After IBinder object, described method also includes:
The IBinder object obtaining is utilized to carry out communicating with described target plug-in.
4. the method according to according to any one of claim 1-3, wherein, the entrance class of described target plug-in is Entry class.
5. the method according to according to any one of claim 1-4, wherein, the interface of described target plug-in is IPlugin interface, The object of described IPlugin interface is mPlugin object.
6. the method according to according to any one of claim 1-5, wherein, also includes:
Utilizing the object of described entrance class, reflection obtains the designation method in described entrance class.
7. the method according to according to any one of claim 2-6, wherein, when external call side needs to obtain target plug-in During IBinder object, call the designation method in predefined predefined class, including:
When external call side needs the IBinder object obtaining target plug-in, it is judged that described external call side place is when advance Whether journey is same process with the recipient place target process of the IBinder object that will return described target plug-in;
If so, the designation method in predefined predefined class is then directly invoked.
8. method according to claim 7, wherein, also includes:
If the recipient institute of described external call side place current process and the IBinder object that described target plug-in will be returned It is not same process at target process, then obtained interface right of host program by the Provider in described target process As;
By the designation method in the object of the interface of host program, call the designation method in predefined predefined class.
9. method according to claim 8, wherein, described target process is Resident Process.
10. a plug-in unit charger, including:
Load-on module, is suitable to, when host program receives the instruction loading plug-in unit, call plug-in loading method to target plug-in Load;
Creation module, is suitable to during loaded targets plug-in unit, creates the object of the entrance class of target plug-in;
Cache module, is suitable to utilize the object of described entrance class, calls the designation method caching of target plug-in unit in described entrance class The object of interface.
CN201610862823.4A 2016-09-28 2016-09-28 Plug-in loading method and Plug-in loading device Pending CN106445598A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610862823.4A CN106445598A (en) 2016-09-28 2016-09-28 Plug-in loading method and Plug-in loading device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610862823.4A CN106445598A (en) 2016-09-28 2016-09-28 Plug-in loading method and Plug-in loading device

Publications (1)

Publication Number Publication Date
CN106445598A true CN106445598A (en) 2017-02-22

Family

ID=58170969

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610862823.4A Pending CN106445598A (en) 2016-09-28 2016-09-28 Plug-in loading method and Plug-in loading device

Country Status (1)

Country Link
CN (1) CN106445598A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108845842A (en) * 2018-04-18 2018-11-20 北京奇虎科技有限公司 It is multiplexed the method and device of view
CN109240758A (en) * 2018-07-25 2019-01-18 武汉精测电子集团股份有限公司 A kind of method and microkernel architecture for supporting card i/f synchronous asynchronous unified call
CN111766992A (en) * 2020-05-29 2020-10-13 维沃移动通信有限公司 Information display method and device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1968154A (en) * 2006-09-15 2007-05-23 华为技术有限公司 System and method for service expansion using plug
US20140325198A1 (en) * 2013-04-24 2014-10-30 Asmedia Technology Inc. Electronic device and loading method of control program
CN104731625A (en) * 2015-03-27 2015-06-24 北京奇虎科技有限公司 Method, device and mobile terminal for loading plugin

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1968154A (en) * 2006-09-15 2007-05-23 华为技术有限公司 System and method for service expansion using plug
US20140325198A1 (en) * 2013-04-24 2014-10-30 Asmedia Technology Inc. Electronic device and loading method of control program
CN104731625A (en) * 2015-03-27 2015-06-24 北京奇虎科技有限公司 Method, device and mobile terminal for loading plugin

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
邱继东: "手机快讯系统的研究与实现", 《中国优秀硕士学位论文全文数据库(电子期刊)》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108845842A (en) * 2018-04-18 2018-11-20 北京奇虎科技有限公司 It is multiplexed the method and device of view
CN109240758A (en) * 2018-07-25 2019-01-18 武汉精测电子集团股份有限公司 A kind of method and microkernel architecture for supporting card i/f synchronous asynchronous unified call
CN111766992A (en) * 2020-05-29 2020-10-13 维沃移动通信有限公司 Information display method and device, electronic equipment and storage medium
CN111766992B (en) * 2020-05-29 2022-04-22 维沃移动通信有限公司 Information display method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN104410615B (en) Method, client, server and the system to access to shared data
CN108346028B (en) Business approval processing method, device and system
CN102819461B (en) Desktop synchronous method, device, equipment and system
CN110326255A (en) Manage messaging protocol communication
CN106030528B (en) Agent data service
WO2011082995A1 (en) Automatically synchronizing new contacts across multiple social networking sites
CN104094234A (en) Virtual channel for embedded process communication
CN104580451A (en) Method and system for achieving account number synchronization among multiple platforms, and electronic device
CN103118140A (en) Method, system and device for sharing file with other users out of relationship circle
CN109634607A (en) A kind of method and device of Code automatic build
WO2014026169A2 (en) Application development system and method for object models and datagraphs in client-side and server-side applications
CN104348919A (en) Method and device for downloading file and browser
CN104410680A (en) Method, client terminal, server and system of sharing file/file folder
CN106445598A (en) Plug-in loading method and Plug-in loading device
CN106161531A (en) A kind of method that data are uploaded and device thereof
CN104125303A (en) Data read-and-write requesting method, client end and data read-and-write requesting system
CN108600377A (en) A kind of pause method of file download, device, terminal and storage medium
CN104410679B (en) Share extracting method, client, server and the system of file/folder
CN105607944B (en) A kind of method and device of sharing application environment
CN106598662A (en) Application loading method and device based on android
CN104504113B (en) Mobile terminal browser carries out the method, apparatus and mobile terminal of information processing
CN105138274A (en) Resource obtaining method of cloud disk and resource obtaining device of cloud disk
CN104506616A (en) Method, device and system for sending information by browser client side
CN104378393A (en) Resource sharing method and corresponding device
CN106791650A (en) The method for previewing of video, device and intelligent terminal

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20170222

RJ01 Rejection of invention patent application after publication