CN106933636B - Method and device for starting plug-in service and terminal equipment - Google Patents

Method and device for starting plug-in service and terminal equipment Download PDF

Info

Publication number
CN106933636B
CN106933636B CN201710157645.XA CN201710157645A CN106933636B CN 106933636 B CN106933636 B CN 106933636B CN 201710157645 A CN201710157645 A CN 201710157645A CN 106933636 B CN106933636 B CN 106933636B
Authority
CN
China
Prior art keywords
service
target service
management component
target
plug
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.)
Active
Application number
CN201710157645.XA
Other languages
Chinese (zh)
Other versions
CN106933636A (en
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
Original Assignee
Beijing Qihoo Technology 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 filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201710157645.XA priority Critical patent/CN106933636B/en
Publication of CN106933636A publication Critical patent/CN106933636A/en
Application granted granted Critical
Publication of CN106933636B publication Critical patent/CN106933636B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the invention discloses a method and a device for starting a plug-in service and terminal equipment. The method comprises the following steps: receiving service starting request information of a client through a Binder object of a service management component; starting the target service in the process of the service management component according to the service starting request information; the service management component manages all services in the process where the service management component is located, and the service management component and the client run in different processes. The embodiment of the invention manages all services in the process of the server by setting the service management component for each process of the server, and can realize the starting of the target service when the target service and the client run in different processes, so that when the service provided by the plug-in is started, a service pit does not need to be preset in the android manifest.

Description

Method and device for starting plug-in service and terminal equipment
Technical Field
The invention belongs to the technical field of computers, and particularly relates to a method and a device for starting a plug-in service and terminal equipment.
Background
The plug-in is a program written by an application program interface following a certain specification, and the method for using the service provided by the plug-in by the Android system at present comprises the following steps: start Service (Start Service), Stop Service (Stop Service), Bind Service (Bind Service), and Unbind Service (unbound Service). The service provided by using the plug-in the Android system is mainly realized by adopting two schemes: one is through writing a service intermediary in the main program, utilize this service intermediary to call the plug-in through the reflection mechanism, its concrete implementation method is: declaring the service intermediary in an android manifest.xml file of a main program, and writing the service intermediary in the main program, wherein all functions of the service intermediary are realized by calling functions inside a plug-in through a reflection mechanism; the other is that some service pit bits are preset in the main program, and the service provided by the plug-in is loaded by using the service pit bits, and the specific implementation method is as follows: firstly, declaring a plurality of virtual service registration information, namely service pit positions, in an android manifest.
Although both of the above two existing solutions can implement the use of the service provided by the plug-in, in the specific implementation process, we find that both of the above two existing solutions have certain limitations: in the first scheme, a main program must be upgraded first to upgrade the service provided by the plug-in, the upgraded service can be used only after the main program is upgraded, and additional processing of upgrading the main program is required; in the second scheme, because the number of preset service pit bits is limited, and the service is resident in the background, the life cycle is long, so that the preset service pit bits are used up quickly, and if the preset pit bits are too many, the starting speed is affected, and when a third party or the third party obtains the information of the main program application through the Binder, the information may be too much, and the transactionTooLarge exception may occur.
Disclosure of Invention
The embodiment of the invention aims to solve the technical problem that: a method, a device and a terminal device for starting a plug-in service are provided, which can start the service provided by the plug-in without setting pit positions and performing extra processing.
To solve the above technical problem, according to an aspect of an embodiment of the present invention, there is provided a method for starting a plug-in service, including:
receiving service starting request information of a client through a Binder object of a service management component;
starting the target service in the process of the service management component according to the service starting request information;
the service management component manages all services in the process where the service management component is located, and the service management component and the client run in different processes.
In another embodiment of the foregoing method according to the present invention, the receiving, by a Binder object of a service management component, service initiation request information of a client includes:
and calling a startService function of an AIDL interface object of the service management component according to the service starting request information.
In another embodiment of the foregoing method according to the present invention, the starting a target service in a process in which the service management component is located according to the start service request information includes:
accessing a startService function of the service management component core class through an internal class object inheriting the AIDL interface in the service management component; wherein a core class of the service management component implements the AIDL interface.
In another embodiment of the foregoing method according to the present invention, the starting a target service in a process in which the service management component is located according to the start service request information includes:
detecting whether target service installation information is stored in the service management component or not according to the service starting request information;
if target service installation information is stored in the service management component, acquiring the target service installation information;
and if the target service installation information is not stored in the service management component, creating the target service installation information.
In another embodiment of the foregoing method according to the present invention, the creating target service installation information includes:
detecting whether a plug-in for providing target service is stored in the service management component or not according to the service starting request information;
if a plug-in providing the target service is stored in the service management component, acquiring a ServiceInfo object of the target service from the plug-in;
if the plug-in providing the target service is not stored in the service management component, acquiring a ServiceInfo object of the target service from an installation package of the plug-in providing the target service;
and creating target service installation information based on the starting service request information and the ServiceInfo object of the target service.
In another embodiment of the foregoing method according to the present invention, after the creating the target service installation information, the method further includes:
and saving the target service installation information in the service management component.
In another embodiment of the foregoing method according to the present invention, after the creating the target service installation information, the method further includes:
installing a target service based on the target service installation information.
In another embodiment based on the foregoing method of the present invention, after the obtaining the target service installation information, the method further includes:
detecting whether a target service is stored in the service management component or not according to the target service installation information;
if the target service is stored in the service management component, calling an onStartCommand function of the target service;
and if the target service is not stored in the service management component, installing the target service based on the target service installation information.
In another embodiment of the foregoing method according to the present invention, the installing the target service based on the target service installation information includes:
acquiring a Context object of a plug-in providing target service;
creating a target service by using a Context object of a plug-in providing the target service based on the target service installation information;
initializing the target service.
In another embodiment of the foregoing method according to the present invention, the creating a target service using a Context object of a plug-in providing the target service based on the target service installation information includes:
acquiring a class loader of a plug-in providing target service from a Context object of the plug-in;
acquiring a full class name of a target service from the target service installation information;
based on the full class name of the target service, acquiring a system class object of the target service by utilizing a class loader of the plug-in through a reflection mechanism;
and calling the newInstance of the system class of the target service through a reflection mechanism to call a constructor to create the target service.
In another embodiment of the foregoing method according to the present invention, the initializing the target service includes:
calling a function of attachBaseContext of the target service through a reflection mechanism;
invoking an onCreate function of the target service.
In another embodiment of the foregoing method according to the present invention, after installing the target service based on the target service installation information, the method further includes:
saving the target service in the service management component.
In another embodiment of the foregoing method according to the present invention, after installing the target service based on the target service installation information, the method further includes:
the onStartCommand function of the target service is invoked.
According to another aspect of the embodiments of the present invention, there is provided an apparatus for initiating a plug-in service, including:
the receiving unit is used for receiving the service starting request information of the client through the Binder object of the service management component;
the execution unit is used for starting the target service in the process of the service management component according to the service starting request information;
the service management component manages all services in the process where the service management component is located, and the service management component and the client run in different processes.
In another embodiment of the foregoing apparatus according to the present invention, the receiving unit is specifically configured to invoke a startService function of an aid l interface object of the service management component according to the start service request information.
In another embodiment of the foregoing apparatus according to the present invention, the executing unit is specifically configured to access a startService function of the core class of the service management component through an internal class object that inherits the AIDL interface in the service management component; wherein a core class of the service management component implements the AIDL interface.
In another embodiment of the above apparatus according to the present invention, the execution unit includes:
the first detection module is used for detecting whether target service installation information is stored in the service management assembly or not according to the service starting request information;
the acquisition module is used for responding to the fact that target service installation information is stored in the service management assembly according to the detection result of the first detection module and acquiring the target service installation information;
and the creating module is used for responding to that target service installation information is not stored in the service management assembly according to the detection result of the first detection module and creating the target service installation information.
In another embodiment of the above apparatus according to the present invention, the creating module is specifically configured to:
detecting whether a plug-in for providing target service is stored in the service management component or not according to the service starting request information;
if a plug-in providing the target service is stored in the service management component, acquiring a ServiceInfo object of the target service from the plug-in;
if the plug-in providing the target service is not stored in the service management component, acquiring a ServiceInfo object of the target service from an installation package of the plug-in providing the target service;
and creating target service installation information based on the starting service request information and the ServiceInfo object of the target service.
In another embodiment of the above apparatus according to the present invention, the execution unit further includes:
and the first storage module is used for storing the target service installation information in the service management component.
In another embodiment of the above apparatus according to the present invention, the execution unit further includes:
an installation module for installing a target service based on the target service installation information after the creation module creates the target service installation information.
In another embodiment of the above apparatus according to the present invention, the execution unit further includes:
the second detection module is used for detecting whether the target service is stored in the service management assembly or not according to the target service installation information;
the execution module is used for responding to the storage of the target service in the service management component according to the detection result of the second detection module and calling the onStartCommand function of the target service;
the installation module is further configured to respond to that no target service is stored in the service management component according to the detection result of the second detection module, and install the target service based on the target service installation information.
In another embodiment of the above apparatus according to the present invention, the installation module is specifically configured to:
acquiring a Context object of a plug-in providing target service;
creating a target service by using a Context object of a plug-in providing the target service based on the target service installation information;
initializing the target service.
In another embodiment based on the foregoing apparatus of the present invention, the installation module creates the target service by using a Context object of a plug-in providing the target service based on the target service installation information, and is specifically configured to:
acquiring a class loader of a plug-in providing target service from a Context object of the plug-in;
acquiring a full class name of a target service from the target service installation information;
based on the full class name of the target service, acquiring a system class object of the target service by utilizing a class loader of the plug-in through a reflection mechanism;
and calling the newInstance of the system class of the target service through a reflection mechanism to call a constructor to create the target service.
In another embodiment based on the foregoing apparatus of the present invention, the installation module initializes the target service, specifically configured to:
calling a function of attachBaseContext of the target service through a reflection mechanism;
invoking an onCreate function of the target service.
In another embodiment of the above apparatus according to the present invention, the execution unit further includes:
and the second storage module is used for storing the target service in the service management component.
In another embodiment of the foregoing apparatus according to the present invention, the executing module is further configured to call an onStartCommand function of the target service after the installing module installs the target service based on the target service installation information.
According to still another aspect of the embodiments of the present invention, there is provided a terminal device, including: a processor and a memory; wherein,
the memory is used for storing the program of the method for starting the plug-in service in any embodiment;
the processor is configured to execute the program of the method of launching a plug-in service stored in the memory.
Based on the method, the apparatus and the terminal device for starting the plug-in service provided by the above embodiments of the present invention, by setting a service management component for each process of the server, managing all services in the process, after receiving the service initiation request information of the client through the Binder object of the service management component, starting the target service in the process of the service management component according to the starting service request information, when the target service and the client run in different processes, the starting of the target service can be realized, since the embodiment of the present invention manages all services in a process by the service management component provided in each process, therefore, the service provided by the plug-in can be started without presetting a service pit in the android manifest.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description, serve to explain the principles of the invention.
The invention will be more clearly understood from the following detailed description, taken with reference to the accompanying drawings, in which:
FIG. 1 is a flow diagram of one embodiment of a method for initiating a plug-in service according to an embodiment of the present invention.
FIG. 2 is a flow diagram of another embodiment of a method for initiating a plug-in service according to an embodiment of the present invention.
FIG. 3 is a flow diagram of yet another embodiment of a method for initiating a plug-in service according to an embodiment of the present invention.
FIG. 4 is a flow diagram of yet another embodiment of a method for initiating a plug-in service according to an embodiment of the present invention.
FIG. 5 is a block diagram of one embodiment of an apparatus to initiate a plug-in service in accordance with an embodiment of the present invention.
FIG. 6 is a block diagram of another embodiment of an apparatus for initiating a plug-in service according to an embodiment of the present invention.
Fig. 7 is a block diagram of another embodiment of an apparatus for initiating a plug-in service according to an embodiment of the present invention.
Fig. 8 is a block diagram of a partial structure of a mobile phone related to a terminal device provided in an embodiment of the present invention.
Detailed Description
Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that: the relative arrangement of the components, the numerical expressions, and numerical values set forth in these embodiments do not limit the scope of the present invention unless specifically stated otherwise.
Meanwhile, it should be understood that the sizes of the respective portions shown in the drawings are not drawn in an actual proportional relationship for the convenience of description.
The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.
Techniques, methods, and apparatus known to those of ordinary skill in the relevant art may not be discussed in detail but are intended to be part of the specification where appropriate.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, further discussion thereof is not required in subsequent figures.
FIG. 1 is a flow diagram of one embodiment of a method for initiating a plug-in service according to an embodiment of the present invention. As shown in fig. 1, the method of this embodiment includes:
s102, receiving the service starting request information of the client through the Binder object of the service management component.
And S104, starting the target service in the process of the service management component according to the service starting request information.
The target Service is a Service provided by the plug-in, for example, a background Service of an Android system, and a process in which the Service is located is usually specified in an Android process in a < Service > tag in an Android manifest. The client is a party calling the service, the party implementing the service is a server, for example, the cleaning plug-in calls the backup service in the backup plug-in to make a backup before cleaning, the party cleaning the plug-in is the client, the party providing the backup service is the server, and the client and the server operate in different processes. Each process of the server is provided with a service management component, and all services in the process of the server are managed through the service management component.
In a particular embodiment, initiating the service request message may include: an Intent object, a Context object, and a Messenger object. The Android system is responsible for finding a corresponding component according to the description of the Intent, transmitting the Intent to the called component and completing calling of the component. Context is information that describes an application environment through which resources and classes of an application can be obtained, including some application-level operations. Messenger is a unique identifier passed by the client to tag the client and can also be used as a messaging service with the client.
In a specific implementation, operation S102 may call a startService function of an aid l interface object of the service management component according to the service request starting information, and operation S104 may access the startService function of a core class of the service management component to start the target service through an internal class object that inherits the aid l interface in the service management component, where the core class of the service management component implements the aid l interface.
In a specific embodiment, the IPluginServiceServer interface object is an aid interface object of the service management component, the IPluginServiceServer interface is a core interface of the service management component, the Pluginserviceserver class is a core class of the service management component, and is a specific implementation of the IPluginServiceServer interface, and the service management component implements service scheduling, providing and the like of the service end together with the core class through the core interface. Because the IPluginServiceServer interface object is the Proxy of the Binder object, the IPluignServiceServer-stub class needs to be realized in the process of the target service, the IPluignServiceServer-stub class is the internal class of the PluginServiceServer class, inherits the IPluginServiceServer interface, realizes the basic function, and finally jumps to the PluginServiceServer class for corresponding processing; wherein the IPluginServiceServer interface declares a startService function, the internal class IPluignServiceServer.Stub defines the startService function, and the PluginServiceServer class realizes the startService function.
Wherein, realize IPluignServiceServer.stub class in the service management assembly, and the operation initialized to it includes: creating or obtaining a PluginServiceServer object, creating or obtaining a PluginServiceServer. Firstly, detecting whether a PluginServiceServer object is stored in a service management component; if the PluginServiceServer object is stored in the service management component, acquiring the PluginServiceServer object; otherwise, if the PluginServiceServer object is not stored in the service management component, the PluginServiceServer object is created; then, detecting whether a PluginServiceServer.stub object is stored in the service management component; if the PluginServiceServer.stub object is stored in the service management component, acquiring the PluginServiceServer.stub object; otherwise, if the PluginServiceServer.stub object is not stored in the service management component, creating the PluginServiceServer.stub object; and finally, calling any method in the PluginServiceServer. stub, and jumping to the PluginServiceServer.
Specifically, creating the PluginServiceServer object may be implemented by calling the FetchServiceServer function of the IPluginHost interface or the IPluginClient interface to obtain the IPluginServiceServer interface object. Examples of specific codes thereof are as follows:
Figure BDA0001247588790000111
wherein the IPluginHost interface is an interface of a resident process, the IPluginClient interface is an interface of other processes except the resident process, the class of the mServiceMgr object is PluginServiceService, and the mServiceMgr object obtains the IPluginServiceServer through calling a getService function.
Creating a plugin service server. Examples of specific codes thereof are as follows:
Figure BDA0001247588790000112
Figure BDA0001247588790000121
in one specific embodiment, an example of specific code of the startService function is as follows:
Figure BDA0001247588790000122
Figure BDA0001247588790000131
the method includes that an Intent object is firstly copied in a function, if a client and a target service are in the same process, once the Intent object is modified by the target service, the client is also modified correspondingly, so that unpredictable problems occur, and therefore, an Intent object needs to be firstly copied in the function to perform various operations, so that the problems are prevented. An example of specific code to replicate an Intent object is as follows:
private Intent cloneIntentLocked(Intent intent){
return new Intent(intent);
}
the function then obtains a ServiceRecord object through a retrievevierviceLocked function based on the Intent object, wherein the ServiceRecord object records installation information of the target service, and wherein the obtaining of the plug-in information may be involved in the process of obtaining the ServiceRecord object. And if the target service is not installed, trying to install the target service through the installserviceifneedledlocked function. Finally, the onStartCommand function of the target service is called, and the full class name ComponentName of the target service is directly returned, which indicates that the target service has been successfully started.
The method for starting the plugin service provided by the embodiment of the invention comprises the steps of setting a service management component for each process of a server, managing all services in the process of the server, starting a target service in the process of the service management component according to the starting service request information after receiving the starting service request information of a client through a Binder object of the service management component, and starting the target service when the target service and the client run in different processes.
FIG. 2 is a flow diagram of another embodiment of a method for initiating a plug-in service according to an embodiment of the present invention. As shown in fig. 2, the method of this embodiment includes:
s202, receiving the service starting request information of the client through the Binder object of the service management component.
S204, detecting whether target service installation information is stored in the service management component or not according to the service starting request information.
If the target service installation information is stored in the service management component, operation S206 is performed; otherwise, if the target service installation information is not stored in the service management component, operation S208 is performed.
S206, acquiring target service installation information.
S208, target service installation information is created.
In a specific implementation, operation S208 may first detect whether a plug-in providing a target service is stored in the service management component according to the service start request information, obtain a ServiceInfo object of the target service from the plug-in if the plug-in providing the target service is stored in the service management component, otherwise, obtain the ServiceInfo object of the target service from an installation package of the plug-in providing the target service if the plug-in providing the target service is not stored in the service management component, and finally create target service installation information based on the service start request information and the obtained ServiceInfo object of the target service.
Further, after operation S208, the method for starting the plug-in service of this embodiment further includes: in operation S210, a target service is installed based on the target service installation information.
In a specific implementation, after the operation S208, the method may further include: and storing the target service installation information in the service management component so that the target service installation information can be directly acquired from the service management component when the target service is started next time.
In an embodiment, in operations S204 to S208, first, a ServiceRecord object matching with a full class name ComponentName of a target service and an Intent object in a start service request message is found in a ServiceRecord cache table of a service management component, where the ServiceRecord cache table records installation information of all installed services in a process where the service management component is located, the ServiceRecord object is target service installation information, if the ServiceRecord object is found in the ServiceRecord cache table of the service management component, the ServiceRecord object is obtained to indicate that the target service is already installed, and if the ServiceRecord object is not found in the ServiceRecord cache table of the service management component, the ServiceRecord object is created to indicate that the target service is not already installed; then obtaining a plug-in name from the full class name ComponentName of the target service, judging whether the plug-in exists in the service management component or not through a plug-in framework corresponding to the plug-in name, if the plug-in exists in the service management component, using the service provided by the plug-in name, obtaining a ServiceInfo object of the target service from the plug-in, for example, obtaining the ServiceInfo object of the target service from a componentList object preset in the plug-in, wherein the componentList object stores a PackageInfo object of the plug-in, if the plug-in does not exist in the service management component, downloading the plug-in, and obtaining the ServiceInfo object of the target service from an installation package of the plug-in; and finally, creating a ServiceRecord object of the target service based on the starting service request information and the ServiceInfo object of the target service, and storing the ServiceRecord object into a ServiceRecord cache table and an Intent. Examples of specific code for the above-described operations are as follows:
Figure BDA0001247588790000151
Figure BDA0001247588790000161
wherein the ServiceRecord class includes: the name is used for recording the full class name of the service and is packaged by a ComponentName object of the system, wherein the Key of the ComponentName object is the name of the plugin, and the Value is the full class name; the plugin is used for recording the name of the plugin to which the service belongs, namely, the result of name.getpackageaname (), and is represented by a character string; className, which is used to record the class full name of the service, i.e. the result of name. intent is used to record some filtering conditions in the service, such as Action, IntentFilter, etc., for facilitating later reading and screening; serviceInfo, which is used to record service information described in android manifest.xml of the plug-in, and is a serviceInfo object of the system; the service is used for recording a service object, is created after the service is successfully installed and is a core field; startrequest, to record if the service has been started and to call onStartCommand, used when unbinding and stopping the service.
FIG. 3 is a flow diagram of yet another embodiment of a method for initiating a plug-in service according to an embodiment of the present invention. As shown in fig. 3, the method of this embodiment includes:
s302, receiving the service starting request information of the client through the Binder object of the service management component.
S304, detecting whether the target service installation information is stored in the service management component according to the start service request information.
If the target service installation information is stored in the service management component, operation S306 is performed; otherwise, if the target service installation information is not stored in the service management component, operation S308 is performed.
S308, target service installation information is created.
S306, acquiring target service installation information.
S310, detecting whether the target service is stored in the service management component according to the target service installation information.
If the target service is stored in the service management component, perform operation 314; otherwise, if the target service is not stored in the service management component, operation S312 is performed.
S312, the target service is installed based on the target service installation information.
S314, call onstartCommand function of the target service.
Further, after operation S308, operation S312 is also performed, an operation of installing the target service based on the target service installation information.
In a specific implementation, after operation S308, the method may further include: and storing the target service installation information in the service management component so that the target service installation information can be directly acquired from the service management component when the target service is started next time.
Further, after operation S312, operation S314 of calling the onStartCommand function of the target service is also performed.
In a specific implementation, after operation S312, the method may further include: the operation of the target service is preserved in the service management component so that the target service can be directly obtained from the service management component when the target service is started next time.
In an embodiment, in operations S310 to S314, it is first determined whether a corresponding service exists in the service management component according to the obtained ServiceRecord object, where the ServiceRecord cache table records not only installation information of all installed services in a process where the service management component is located, but also installation information of all services to be installed in a process where the service management component is located, if a corresponding service exists in the service management component, it indicates that the service has been successfully installed before, an onStartCommand function may be directly called, and if a corresponding service does not exist in the service management component, it indicates that the service has not been successfully installed before, it is necessary to start to attempt to install the service. Examples of specific codes thereof are as follows:
Figure BDA0001247588790000181
FIG. 4 is a flow diagram of yet another embodiment of a method for initiating a plug-in service according to an embodiment of the present invention. As shown in fig. 4, the embodiment provides a method of installing a target service based on target service installation information, the method including:
s402, obtaining a Context object of the plug-in providing the target service.
S404, creating the target service by using the Context object of the plug-in providing the target service based on the target service installation information.
S406, initializing the target service.
In a specific implementation, operation S404 may include: the method comprises the steps of obtaining a class loader of a plug-in from a Context object of the plug-in providing a target service, obtaining a full class name of the target service from target service installation information, obtaining a system class object of the target service by utilizing the class loader of the plug-in through a reflection mechanism based on the full class name of the target service, and calling a newInstance of the system class of the target service through the reflection mechanism to call a constructor to create the target service.
In a specific implementation, operation S406 may include: calling a function of attachBaseContext of the target service through a reflection mechanism; and invoking the onCreate function of the target service.
After the target service is installed, the operation of the target service is saved in the service management component, specifically, the initialized target service is saved in the service management component, so that the initialized target service can be directly obtained from the service management component when the target service is started next time.
In a specific embodiment, operations 402 to 406 first obtain a Context object of the plug-in providing the target service to obtain a ClassLoader object therethrough and to serve the obtained object as BaseContext of the target service, and then obtain the ClassLoader object of the plug-in providing the target service from the Context object of the plug-in providing the target service to create the target service through a reflection mechanism, and then create the target service through the reflection mechanism; the method specifically comprises the following three steps: acquiring a full Class Name of a target service from a Name field in the ServiceInfo of a ServiceRecord object of the target service, acquiring a Class object of the target service, namely a system Class object, by utilizing a ClassLoader object of a plug-in through a reflection mechanism, and calling a newInstance of a system Class of the target service through the reflection mechanism to call a constructor to create the target service; and then calling a function of attachBaseContext of the target service through a reflection mechanism, and finally calling an onCreate function of the target service to realize the initialization of the target service. Examples of specific codes thereof are as follows:
Figure BDA0001247588790000191
Figure BDA0001247588790000201
examples of specific codes of the attachBaseContext function are as follows:
Figure BDA0001247588790000202
Figure BDA0001247588790000211
in this function, the parameter ContextWrapper is the target service, the parent class of which is the ContextWrapper class of the system, and the parameter Context is the Context object of the previously-obtained plug-in.
FIG. 5 is a block diagram of one embodiment of an apparatus to initiate a plug-in service in accordance with an embodiment of the present invention. As shown in fig. 5, the apparatus of this embodiment includes: a receiving unit 510 and an executing unit 520. Wherein:
a receiving unit 510, configured to receive service initiation request information of a client through a Binder object of a service management component.
The executing unit 520 is configured to start the target service in the process where the service management component is located according to the start service request information.
The service management component manages all services in the process where the service management component is located, and the service management component and the client run in different processes.
In a specific implementation, the receiving unit 510 may be specifically configured to invoke a startService function of an aid l interface object of the service management component according to the service request initiating information, and the executing unit 520 may be specifically configured to initiate the target service by accessing, by an internal class object inheriting the aid l interface in the service management component, the startService function of a core class of the service management component, where the core class of the service management component implements the aid l interface.
The device for starting the plug-in service provided by the embodiment of the invention manages all services in the process of the service end by setting the service management component for each process of the service end, starts the target service in the process of the service management component according to the starting service request information after receiving the starting service request information of the client through the Binder object of the service management component, and can realize the starting of the target service when the target service and the client run in different processes.
FIG. 6 is a block diagram of another embodiment of an apparatus for initiating a plug-in service according to an embodiment of the present invention. As shown in fig. 6, compared to the embodiment of fig. 5, in this embodiment, the execution unit 620 of the device that starts the plug-in service further includes: a first detection module 621, an acquisition module 622, and a creation module 623. Wherein:
the first detecting module 621 is configured to detect whether target service installation information is stored in the service management component according to the service start request information.
An obtaining module 622, configured to, according to the detection result of the first detecting module 621, respond to that the target service installation information is stored in the service management component, and obtain the target service installation information.
A creating module 623, configured to create the target service installation information in response to that the target service installation information is not stored in the service management component according to the detection result of the first detecting module 621.
In a specific implementation, the creating module 623 may specifically be configured to: firstly, detecting whether a plug-in providing a target service is stored in a service management component or not according to starting service request information, if the plug-in providing the target service is stored in the service management component, acquiring a ServiceInfo object of the target service from the plug-in, if the plug-in providing the target service is not stored in the service management component, acquiring the ServiceInfo object of the target service from an installation package of the plug-in providing the target service, and finally creating target service installation information based on the starting service request information and the acquired ServiceInfo object of the target service.
Further, as shown in fig. 6, the execution unit 620 further includes: an installation module 624 for installing the target service based on the target service installation information after the target service installation information is created by the creation module 623.
In a specific implementation, the execution unit 620 may further include: the first storage module is used for storing the target service installation information in the service management component so as to directly acquire the target service installation information from the service management component when the target service is started next time.
Fig. 7 is a block diagram of another embodiment of an apparatus for initiating a plug-in service according to an embodiment of the present invention. As shown in fig. 7, compared to the embodiment of fig. 6, in this embodiment, the execution unit 720 of the device for starting the plug-in service further includes: a second detection module 725, and an execution module 726. Wherein:
the second detecting module 725 is configured to detect whether the target service is stored in the service management component according to the target service installation information.
An executing module 726, configured to, according to the detection result of the second detecting module 725, in response to that the target service is stored in the service management component, invoke an onStartCommand function of the target service.
The installing module 724 is further configured to, according to the detection result of the second detecting module 725, in response to that the target service is not stored in the service management component, install the target service based on the target service installation information.
In a specific implementation, the installation module 724 may specifically be configured to: the method comprises the steps of obtaining a Context object of a plug-in providing a target service, creating the target service by using the Context object of the plug-in providing the target service based on target service installation information, and initializing the target service.
Specifically, the installation module 724 creates the target service by using a Context object of the plug-in providing the target service based on the target service installation information, and is specifically configured to: the method comprises the steps of obtaining a class loader of a plug-in from a Context object of the plug-in providing a target service, obtaining a full class name of the target service from target service installation information, obtaining a system class object of the target service by utilizing the class loader of the plug-in through a reflection mechanism based on the full class name of the target service, and calling a newInstance of the system class of the target service through the reflection mechanism to call a constructor to create the target service.
Specifically, the installation module 724 initializes the target service, specifically for: calling a function of attachBaseContext of the target service through a reflection mechanism, and calling an onCreate function of the target service.
Further, the execution unit 720 further includes: and the second storage module is used for storing the target service in the service management component so as to directly obtain the target service from the service management component when the target service is started next time.
Specifically, after the installation module 724 initializes the target service, the second storage module is configured to store the initialized target service, so that the initialized target service can be directly obtained from the service management component when the target service is started next time.
Further, the executing module 726 is further configured to invoke the onStartCommand function of the target service after the installing module 724 installs the target service based on the target service installation information.
In addition, a terminal device is further provided in the embodiment of the present invention, as shown in fig. 8, for convenience of description, only a part related to the embodiment of the present invention is shown, and details of the specific technology are not disclosed, please refer to the method part in the embodiment of the present invention. The terminal device may be any terminal device including a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of Sales), a vehicle-mounted computer, and the like, taking the terminal device as the mobile phone as an example:
fig. 8 is a block diagram of a partial structure of a mobile phone related to a terminal device provided in an embodiment of the present invention. Referring to fig. 8, the handset includes: radio Frequency (RF) circuitry 810, memory 820, input unit 830, display unit 840, sensor 850, audio circuitry 860, wireless-fidelity (Wi-Fi) module 870, processor 880, and power supply 890. Those skilled in the art will appreciate that the handset configuration shown in fig. 8 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
The following describes each component of the mobile phone in detail with reference to fig. 8:
the RF circuit 810 may be used for receiving and transmitting signals during information transmission and reception or during a call, and in particular, for processing downlink information of a base station after receiving the downlink information to the processor 880; in addition, the data for designing uplink is transmitted to the base station. In general, RF circuit 810 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like. In addition, the RF circuit 810 may also communicate with networks and other devices via wireless communication. The wireless communication may use any communication standard or protocol, including but not limited to global system for Mobile communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), and the like.
The memory 820 may be used to store software programs and modules, and the processor 880 executes various functional applications and data processing of the cellular phone by operating the software programs and modules stored in the memory 820. The memory 820 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. Further, the memory 820 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
The input unit 830 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the cellular phone. Specifically, the input unit 830 may include a touch panel 831 and other input devices 832. The touch panel 831, also referred to as a touch screen, can collect touch operations performed by a user on or near the touch panel 831 (e.g., operations performed by the user on the touch panel 831 or near the touch panel 831 using any suitable object or accessory such as a finger, a stylus, etc.) and drive the corresponding connection device according to a preset program. Alternatively, the touch panel 831 may include two portions, i.e., a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts it to touch point coordinates, and sends the touch point coordinates to the processor 880, and can receive and execute commands from the processor 880. In addition, the touch panel 831 may be implemented by various types such as a resistive type, a capacitive type, an infrared ray, and a surface acoustic wave. The input unit 830 may include other input devices 832 in addition to the touch panel 831. In particular, other input devices 832 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 840 may be used to display information input by the user or information provided to the user and various menus of the cellular phone. The display unit 840 may include a display panel 841, and the display panel 841 may be optionally configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like. Further, touch panel 831 can overlay display panel 841, and when touch panel 831 detects a touch operation thereon or nearby, communicate to processor 880 to determine the type of touch event, and processor 880 can then provide a corresponding visual output on display panel 841 based on the type of touch event. Although in fig. 8, the touch panel 831 and the display panel 841 are two separate components to implement the input and output functions of the mobile phone, in some embodiments, the touch panel 831 and the display panel 841 may be integrated to implement the input and output functions of the mobile phone.
The handset may also include at least one sensor 850, such as light sensors, motion sensors, and other sensors. Specifically, the light sensor may include an ambient light sensor that adjusts the brightness of the display panel 841 according to the brightness of ambient light, and a proximity sensor that turns off the display panel 841 and/or the backlight when the mobile phone is moved to the ear. As one of the motion sensors, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when stationary, and can be used for applications of recognizing the posture of a mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured on the mobile phone, further description is omitted here.
Audio circuitry 860, speaker 861, microphone 862 may provide an audio interface between the user and the handset. The audio circuit 860 can transmit the electrical signal converted from the received audio data to the speaker 861, and the electrical signal is converted into a sound signal by the speaker 861 and output; on the other hand, the microphone 862 converts collected sound signals into electrical signals, which are received by the audio circuit 860 and converted into audio data, which are then processed by the audio data output processor 880 and transmitted to, for example, another cellular phone via the RF circuit 810, or output to the memory 820 for further processing.
WiFi belongs to short-distance wireless transmission technology, and the mobile phone can help a user to send and receive e-mails, browse webpages, access streaming media and the like through the WiFi module 870, and provides wireless broadband Internet access for the user. Although fig. 8 shows WiFi module 870, it is understood that it does not belong to the essential constitution of the handset, and may be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 880 is a control center of the mobile phone, connects various parts of the entire mobile phone using various interfaces and lines, and performs various functions of the mobile phone and processes data by operating or executing software programs and/or modules stored in the memory 820 and calling data stored in the memory 820, thereby integrally monitoring the mobile phone. Optionally, processor 880 may include one or more processing units; preferably, the processor 880 may integrate an application processor, which mainly handles operating systems, user interfaces, applications, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into processor 880.
The handset also includes a power supply 890 (e.g., a battery) for powering the various components, which may preferably be logically coupled to the processor 880 via a power management system to manage charging, discharging, and power consumption.
Although not shown, the mobile phone may further include a camera, a bluetooth module, etc., which are not described herein.
In this embodiment of the present invention, the processor 880 included in the terminal device further has the following functions:
receiving service starting request information of a client through a Binder object of a service management component;
starting the target service in the process of the service management component according to the service starting request information;
the service management component manages all services in the process where the service management component is located, and the service management component and the client run in different processes.
The embodiment of the invention provides the following technical scheme:
1. a method of launching a plug-in service, comprising:
receiving service starting request information of a client through a Binder object of a service management component;
starting the target service in the process of the service management component according to the service starting request information;
the service management component manages all services in the process where the service management component is located, and the service management component and the client run in different processes.
2. The method according to 1, where receiving, by a Binder object of a service management component, service initiation request information of a client includes:
and calling a startService function of an AIDL interface object of the service management component according to the service starting request information.
3. The method according to 2, where the starting of the target service in the process in which the service management component is located according to the start service request information includes:
accessing a startService function of the service management component core class through an internal class object inheriting the AIDL interface in the service management component; wherein a core class of the service management component implements the AIDL interface.
4. The method according to any one of claims 1 to 3, wherein the starting of the target service in the process in which the service management component is located according to the start service request information includes:
detecting whether target service installation information is stored in the service management component or not according to the service starting request information;
if target service installation information is stored in the service management component, acquiring the target service installation information;
and if the target service installation information is not stored in the service management component, creating the target service installation information.
5. The method of 4, the creating target service installation information comprising:
detecting whether a plug-in for providing target service is stored in the service management component or not according to the service starting request information;
if a plug-in providing the target service is stored in the service management component, acquiring a ServiceInfo object of the target service from the plug-in;
if the plug-in providing the target service is not stored in the service management component, acquiring a ServiceInfo object of the target service from an installation package of the plug-in providing the target service;
and creating target service installation information based on the starting service request information and the ServiceInfo object of the target service.
6. The method according to 4 or 5, further comprising, after the creating the target service installation information:
and saving the target service installation information in the service management component.
7. The method according to any one of claims 4 to 6, further comprising, after creating the target service installation information:
installing a target service based on the target service installation information.
8. The method according to 7, further comprising, after the obtaining the target service installation information:
detecting whether a target service is stored in the service management component or not according to the target service installation information;
if the target service is stored in the service management component, calling an onStartCommand function of the target service;
and if the target service is not stored in the service management component, installing the target service based on the target service installation information.
9. The method of 7 or 8, the installing the target service based on the target service installation information, comprising:
acquiring a Context object of a plug-in providing target service;
creating a target service by using a Context object of a plug-in providing the target service based on the target service installation information;
initializing the target service.
10. The method of 9, wherein creating a target service using a Context object of a plug-in providing the target service based on the target service installation information comprises:
acquiring a class loader of a plug-in providing target service from a Context object of the plug-in;
acquiring a full class name of a target service from the target service installation information;
based on the full class name of the target service, acquiring a system class object of the target service by utilizing a class loader of the plug-in through a reflection mechanism;
and calling the newInstance of the system class of the target service through a reflection mechanism to call a constructor to create the target service.
11. The method of 9, the initializing the target service, comprising:
calling a function of attachBaseContext of the target service through a reflection mechanism;
invoking an onCreate function of the target service.
12. The method according to any one of claims 8 to 11, further comprising, after installing the target service based on the target service installation information:
saving the target service in the service management component.
13. The method according to any one of claims 8 to 12, further comprising, after installing the target service based on the target service installation information:
the onStartCommand function of the target service is invoked.
14. An apparatus for initiating a plug-in service, comprising:
the receiving unit is used for receiving the service starting request information of the client through the Binder object of the service management component;
the execution unit is used for starting the target service in the process of the service management component according to the service starting request information;
the service management component manages all services in the process where the service management component is located, and the service management component and the client run in different processes.
15. The apparatus according to claim 14, wherein the receiving unit is specifically configured to invoke a startService function of an aid dl interface object of the service management component according to the service initiation request information.
16. The apparatus according to claim 15, wherein the executing unit is specifically configured to access a startService function of the service management component core class through an internal class object that inherits the AIDL interface in the service management component; wherein a core class of the service management component implements the AIDL interface.
17. The apparatus of claim 16, the execution unit, comprising:
the first detection module is used for detecting whether target service installation information is stored in the service management assembly or not according to the service starting request information;
the acquisition module is used for responding to the fact that target service installation information is stored in the service management assembly according to the detection result of the first detection module and acquiring the target service installation information;
and the creating module is used for responding to that target service installation information is not stored in the service management assembly according to the detection result of the first detection module and creating the target service installation information.
18. The apparatus of claim 17, wherein the creating module is specifically configured to:
detecting whether a plug-in for providing target service is stored in the service management component or not according to the service starting request information;
if a plug-in providing the target service is stored in the service management component, acquiring a ServiceInfo object of the target service from the plug-in;
if the plug-in providing the target service is not stored in the service management component, acquiring a ServiceInfo object of the target service from an installation package of the plug-in providing the target service;
and creating target service installation information based on the starting service request information and the ServiceInfo object of the target service.
19. The apparatus of claim 17 or 18, the execution unit, further comprising:
and the first storage module is used for storing the target service installation information in the service management component.
20. The apparatus according to any one of claims 17 to 19, the execution unit further comprising:
an installation module for installing a target service based on the target service installation information after the creation module creates the target service installation information.
21. The apparatus of 20, the execution unit, further comprising:
the second detection module is used for detecting whether the target service is stored in the service management assembly or not according to the target service installation information;
the execution module is used for responding to the storage of the target service in the service management component according to the detection result of the second detection module and calling the onStartCommand function of the target service;
the installation module is further configured to respond to that no target service is stored in the service management component according to the detection result of the second detection module, and install the target service based on the target service installation information.
22. The apparatus of claim 20 or 21, wherein the mounting module is specifically configured to:
acquiring a Context object of a plug-in providing target service;
creating a target service by using a Context object of a plug-in providing the target service based on the target service installation information;
initializing the target service.
23. According to the apparatus of claim 22, the installation module creates the target service using a Context object of a plug-in providing the target service based on the target service installation information, and is specifically configured to:
acquiring a class loader of a plug-in providing target service from a Context object of the plug-in;
acquiring a full class name of a target service from the target service installation information;
based on the full class name of the target service, acquiring a system class object of the target service by utilizing a class loader of the plug-in through a reflection mechanism;
and calling the newInstance of the system class of the target service through a reflection mechanism to call a constructor to create the target service.
24. According to the apparatus of 22, the installation module initializes the target service, specifically configured to:
calling a function of attachBaseContext of the target service through a reflection mechanism;
invoking an onCreate function of the target service.
25. The apparatus according to any one of claims 21 to 24, the execution unit further comprising:
and the second storage module is used for storing the target service in the service management component.
26. The apparatus according to any one of claims 21 to 25, wherein the execution module is further configured to invoke an onStartCommand function of the target service after the installation module installs the target service based on the target service installation information.
27. A terminal device, comprising: a processor and a memory; wherein,
the memory is used for storing the method for starting the plug-in service of any one of 1 to 13;
the processor is used for executing the method for starting the plug-in service.
In the present specification, the embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts in the embodiments are referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The method and apparatus, device of the present invention may be implemented in a number of ways. For example, the method, apparatus and device of the present invention may be implemented by software, hardware, firmware or any combination of software, hardware and firmware. The above-described order for the steps of the method is for illustrative purposes only, and the steps of the method of the present invention are not limited to the order specifically described above unless specifically indicated otherwise. Furthermore, in some embodiments, the present invention may also be embodied as a program recorded in a recording medium, the program including machine-readable instructions for implementing a method according to the present invention. Thus, the present invention also covers a recording medium storing a program for executing the method according to the present invention.
The description of the present invention has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the invention in the form disclosed. Many modifications and variations will be apparent to practitioners skilled in this art. The embodiment was chosen and described in order to best explain the principles of the invention and the practical application, and to enable others of ordinary skill in the art to understand the invention for various embodiments with various modifications as are suited to the particular use contemplated.

Claims (25)

1. A method for initiating a plug-in service, comprising:
receiving service starting request information of a client through a Binder object of a service management component;
starting the target service in the process of the service management component according to the service starting request information;
the service management component manages all services in the process where the service management component is located, and the service management component and the client run in different processes;
the starting of the target service in the process of the service management component according to the service starting request information comprises the following steps:
detecting whether target service installation information is stored in the service management component or not according to the service starting request information;
if the target service installation information is not stored in the service management component, creating the target service installation information, wherein the creating comprises:
detecting whether a plug-in for providing target service is stored in the service management component or not according to the service starting request information;
if a plug-in providing the target service is stored in the service management component, acquiring a ServiceInfo object of the target service from the plug-in;
if the plug-in providing the target service is not stored in the service management component, acquiring a ServiceInfo object of the target service from an installation package of the plug-in providing the target service;
and creating target service installation information based on the starting service request information and the ServiceInfo object of the target service.
2. The method of claim 1, wherein receiving, by a Binder object of the service management component, the service initiation request information of the client comprises:
and calling a startService function of an AIDL interface object of the service management component according to the service starting request information.
3. The method of claim 2, wherein;
the starting of the target service in the process of the service management component according to the service starting request information comprises the following steps:
accessing a startService function of the service management component core class through an internal class object inheriting the AIDL interface in the service management component; wherein a core class of the service management component implements the AIDL interface.
4. The method according to any one of claims 1 to 3, wherein the starting of the target service in the process in which the service management component is located according to the start service request information includes: detecting whether target service installation information is stored in the service management component or not according to the service starting request information;
and if the target service installation information is stored in the service management component, acquiring the target service installation information.
5. The method of claim 1, wherein after creating the target service installation information, further comprising:
and saving the target service installation information in the service management component.
6. The method of any of claim 1, wherein after creating the target service installation information, further comprising:
installing a target service based on the target service installation information.
7. The method of claim 6, wherein after obtaining the target service installation information, further comprising:
detecting whether a target service is stored in the service management component or not according to the target service installation information;
if the target service is stored in the service management component, calling an onStartCommand function of the target service;
and if the target service is not stored in the service management component, installing the target service based on the target service installation information.
8. The method of claim 6 or 7, wherein installing the target service based on the target service installation information comprises:
acquiring a Context object of a plug-in providing target service;
creating a target service by using a Context object of a plug-in providing the target service based on the target service installation information;
initializing the target service.
9. The method of claim 8, wherein creating a target service using a Context object of a plug-in providing the target service based on the target service installation information comprises:
acquiring a class loader of a plug-in providing target service from a Context object of the plug-in;
acquiring a full class name of a target service from the target service installation information;
based on the full class name of the target service, acquiring a system class object of the target service by utilizing a class loader of the plug-in through a reflection mechanism;
and calling the newInstance of the system class of the target service through a reflection mechanism to call a constructor to create the target service.
10. The method of claim 8, wherein the initializing the target service comprises:
calling a function of attachBaseContext of the target service through a reflection mechanism;
invoking an onCreate function of the target service.
11. The method of claim 10, wherein after installing the target service based on the target service installation information, further comprising:
saving the target service in the service management component.
12. The method of claim 11, wherein after installing the target service based on the target service installation information, further comprising:
the onStartCommand function of the target service is invoked.
13. An apparatus for initiating a plug-in service, comprising:
the receiving unit is used for receiving the service starting request information of the client through the Binder object of the service management component;
the execution unit is used for starting the target service in the process of the service management component according to the service starting request information;
the service management component manages all services in the process where the service management component is located, and the service management component and the client run in different processes;
the execution unit includes:
the first detection module is used for detecting whether target service installation information is stored in the service management assembly or not according to the service starting request information;
the creating module is used for responding to that target service installation information is not stored in the service management assembly according to the detection result of the first detection module and creating the target service installation information;
the creating module is specifically configured to:
detecting whether a plug-in for providing target service is stored in the service management component or not according to the service starting request information;
if a plug-in providing the target service is stored in the service management component, acquiring a ServiceInfo object of the target service from the plug-in;
if the plug-in providing the target service is not stored in the service management component, acquiring a ServiceInfo object of the target service from an installation package of the plug-in providing the target service;
and creating target service installation information based on the starting service request information and the ServiceInfo object of the target service.
14. The apparatus according to claim 13, wherein the receiving unit is specifically configured to invoke a startService function of an aid dl interface object of the service management component according to the start service request information.
15. The apparatus according to claim 14, wherein the execution unit is specifically configured to access a startService function of the service management component core class via an inner class object in the service management component that inherits the aid-l interface; wherein a core class of the service management component implements the AIDL interface.
16. The apparatus of claim 15, wherein the execution unit comprises:
and the acquisition module is used for responding to the fact that target service installation information is stored in the service management assembly according to the detection result of the first detection module and acquiring the target service installation information.
17. The apparatus of claim 15 or 16, wherein the execution unit further comprises:
and the first storage module is used for storing the target service installation information in the service management component.
18. The apparatus of claim 17, wherein the execution unit further comprises:
an installation module for installing a target service based on the target service installation information after the creation module creates the target service installation information.
19. The apparatus of claim 18, wherein the execution unit further comprises:
the second detection module is used for detecting whether the target service is stored in the service management assembly or not according to the target service installation information;
the execution module is used for responding to the storage of the target service in the service management component according to the detection result of the second detection module and calling the onStartCommand function of the target service;
the installation module is further configured to respond to that no target service is stored in the service management component according to the detection result of the second detection module, and install the target service based on the target service installation information.
20. The apparatus according to claim 19, wherein the installation module is specifically configured to:
acquiring a Context object of a plug-in providing target service;
creating a target service by using a Context object of a plug-in providing the target service based on the target service installation information;
initializing the target service.
21. The apparatus according to claim 20, wherein the installation module creates the target service based on the target service installation information using a Context object of a plug-in providing the target service, and is specifically configured to:
acquiring a class loader of a plug-in providing target service from a Context object of the plug-in;
acquiring a full class name of a target service from the target service installation information;
based on the full class name of the target service, acquiring a system class object of the target service by utilizing a class loader of the plug-in through a reflection mechanism;
and calling the newInstance of the system class of the target service through a reflection mechanism to call a constructor to create the target service.
22. The apparatus according to claim 20, wherein the installation module initializes the target service, in particular to:
calling a function of attachBaseContext of the target service through a reflection mechanism;
invoking an onCreate function of the target service.
23. The apparatus of claim 22, wherein the execution unit further comprises:
and the second storage module is used for storing the target service in the service management component.
24. The apparatus of claim 22, wherein the execution module is further configured to invoke an onStartCommand function of the target service after the installation module installs the target service based on the target service installation information.
25. A terminal device, comprising: a processor and a memory; wherein,
the memory is used for storing the method for starting the plug-in service of any one of claims 1 to 12;
the processor is used for executing the method for starting the plug-in service.
CN201710157645.XA 2017-03-16 2017-03-16 Method and device for starting plug-in service and terminal equipment Active CN106933636B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710157645.XA CN106933636B (en) 2017-03-16 2017-03-16 Method and device for starting plug-in service and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710157645.XA CN106933636B (en) 2017-03-16 2017-03-16 Method and device for starting plug-in service and terminal equipment

Publications (2)

Publication Number Publication Date
CN106933636A CN106933636A (en) 2017-07-07
CN106933636B true CN106933636B (en) 2020-08-18

Family

ID=59433479

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710157645.XA Active CN106933636B (en) 2017-03-16 2017-03-16 Method and device for starting plug-in service and terminal equipment

Country Status (1)

Country Link
CN (1) CN106933636B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109240843B (en) * 2018-08-10 2021-12-07 海信视像科技股份有限公司 Application processing method and device
CN109445960B (en) * 2018-10-18 2021-03-02 腾讯科技(深圳)有限公司 Application routing method, device and storage medium
CN109828796B (en) * 2019-01-17 2022-04-15 武汉精立电子技术有限公司 Plug-in calling method and device based on microkernel architecture
CN110806882B (en) * 2019-11-08 2023-05-26 山东德昌电子科技有限公司 Method and system for monitoring installation of plug-in

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101978390A (en) * 2008-03-25 2011-02-16 微软公司 Service initiation techniques
CN103902390A (en) * 2014-03-12 2014-07-02 深圳创维-Rgb电子有限公司 Inter-process communication method based on Android application layer and basis application communication system
CN105354081A (en) * 2015-11-26 2016-02-24 北京奇虎科技有限公司 Synchronous service binding method and apparatus
CN106484461A (en) * 2016-09-13 2017-03-08 北京智能管家科技有限公司 Service keepalive method and device in intelligent terminal

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101188623B (en) * 2006-11-20 2011-02-02 国际商业机器公司 Method and system for dynamic binding door components
EP2372543A1 (en) * 2010-03-22 2011-10-05 Huchtemann, Ralph Method and device for transferring data for rendering a multi-dimensional animation
US20110276950A1 (en) * 2010-05-05 2011-11-10 Microsoft Corporation Name binding extensibility for typed programming language
US20120188595A1 (en) * 2011-01-25 2012-07-26 Joseph Harold Teibel Print specification conversion
CN103246518A (en) * 2013-05-23 2013-08-14 北京邮电大学 Configuration method and device based on service component architecture
CN103632331B (en) * 2013-11-26 2016-06-29 福建四创软件有限公司 A kind of data service method of configurable plug-in type

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101978390A (en) * 2008-03-25 2011-02-16 微软公司 Service initiation techniques
CN103902390A (en) * 2014-03-12 2014-07-02 深圳创维-Rgb电子有限公司 Inter-process communication method based on Android application layer and basis application communication system
CN105354081A (en) * 2015-11-26 2016-02-24 北京奇虎科技有限公司 Synchronous service binding method and apparatus
CN106484461A (en) * 2016-09-13 2017-03-08 北京智能管家科技有限公司 Service keepalive method and device in intelligent terminal

Also Published As

Publication number Publication date
CN106933636A (en) 2017-07-07

Similar Documents

Publication Publication Date Title
CN107329985B (en) Page collection method and device and mobile terminal
CN103473092B (en) A kind of download the processing method of application, device and terminal unit
CN106066686B (en) A kind of information processing method and terminal device
CN104598262A (en) Method and device for updating mobile application
CN110046497B (en) Function hook realization method, device and storage medium
EP3010262B1 (en) Method for realizing cellphone without card and cellphone
CN103544033A (en) Method, device and associated equipment for rolling back application program
CN106933636B (en) Method and device for starting plug-in service and terminal equipment
CN108834132B (en) Data transmission method and equipment and related medium product
CN108920220B (en) Function calling method, device and terminal
CN103455348A (en) Subarea adjustment method, device, terminal, server and system
CN106843868B (en) Multi-account login method and device and mobile terminal
CN106959859B (en) Calling method and device of system calling function
JP5997848B2 (en) Mobile terminal resource processing method, apparatus, client-side computer, server, mobile terminal, program, and recording medium
CN104699501A (en) Method and device for running application program
US11150913B2 (en) Method, device, and terminal for accelerating startup of application
CN106506815A (en) A kind of application enables method and relevant device
CN106095423B (en) Method, terminal and server for providing browsing service
US9928134B2 (en) Method and apparatus for repairing dynamic link library file
CN106874038B (en) Application installation method and device and mobile terminal
CN109145598B (en) Virus detection method and device for script file, terminal and storage medium
CN104866288A (en) Method, device and terminal for accessing application program
CN106528231A (en) Method and apparatus for starting application
CN106933626B (en) Application association method and device
CN107122204B (en) Application unloading state detection method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant