WO2021190469A1 - Terminal apparatus, and control method for calling application program interface therefor - Google Patents

Terminal apparatus, and control method for calling application program interface therefor Download PDF

Info

Publication number
WO2021190469A1
WO2021190469A1 PCT/CN2021/082260 CN2021082260W WO2021190469A1 WO 2021190469 A1 WO2021190469 A1 WO 2021190469A1 CN 2021082260 W CN2021082260 W CN 2021082260W WO 2021190469 A1 WO2021190469 A1 WO 2021190469A1
Authority
WO
WIPO (PCT)
Prior art keywords
interface
class
client process
application program
built
Prior art date
Application number
PCT/CN2021/082260
Other languages
French (fr)
Chinese (zh)
Inventor
关安杰
Original Assignee
广州华多网络科技有限公司
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 广州华多网络科技有限公司 filed Critical 广州华多网络科技有限公司
Publication of WO2021190469A1 publication Critical patent/WO2021190469A1/en

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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/541Client-server

Definitions

  • the invention relates to the application development technology of the Android operating system, in particular to an application program interface call control method, and also to its corresponding terminal equipment.
  • AIDL is one of the IPC (Inter-Process Communication) methods in Android, and is an abbreviation of Android Interface definition language (Android interface definition language).
  • IPC Inter-Process Communication
  • Android Interface definition language Android interface definition language
  • the Client program needs to connect to the Service class of the Server program, obtain the proxy object of the Binder class in the onServiceConnected method, and call the Binder class through the proxy object Interface methods to obtain the functions provided by the Binder class; 7, the Client program needs to maintain its connection with the Service class, because the Service class is the carrier of its communication and interaction.
  • the primary purpose of the present invention is to provide an application program interface call control method for improving application program development efficiency.
  • a terminal device compatible with it is also provided based on the method of the previous object.
  • the present invention provides an application program interface call control method, which includes the following steps:
  • the service component After the service component pre-registered to the operating system of this application is started, the service component accepts the binding communication with the client process of the same application or a different application through the application;
  • This application creates an instance object of the implementation class corresponding to the interface class in response to the interface creation request initiated by the client process based on calling the interface class; the interface registration information corresponding to the implementation class is pre-registered to the interface by this application In the library, it is set in a one-to-one correspondence with the interface class;
  • This application responds to an interface call request for invoking the built-in method of the instance object initiated by the client process, and the request includes the attribute information for executing the built-in method determined according to the interface registration information of the interface library , Call and execute the built-in method of the instance object according to the attribute information to generate result data and feed it back to the client process.
  • the method further includes the following steps:
  • the interface registration information in the interface library includes:
  • Class table information that characterizes the corresponding relationship between the interface identifier of the interface, the implementation class, and the interface class, so as to determine the one-to-one correspondence between the interface class and the implementation class according to the interface identifier;
  • Method table information that characterizes the relationship between the implementation class and its built-in methods and the call operation information of these built-in methods, so as to execute method calls;
  • the instance table information that characterizes the correspondence between the implementation class instance objects that are providing services to the client process and the object identifiers with unique characteristics, so as to implement the invocation of the instance objects.
  • the attribute information includes the interface identifier or object identifier corresponding to the implementation class to which the built-in method belongs and the invocation operation information of the built-in method, and the invocation operation information includes the method identifier and operation of the built-in method. Parameters and return value types.
  • the application program when the application program responds to an interface creation request, it queries the class table information to determine the corresponding implementation class according to the interface identifier specified by the request, so as to create an instance object of the implementation class for it;
  • the built-in method is determined by querying the method table information to call it.
  • the service component of the application program is bound to multiple client processes in parallel, and the application program is suitable for starting one or more of the client processes.
  • the application program and the program to which the client process belongs shall comply with a predetermined agreement, the attribute information is encapsulated and unencapsulated in the first format, and the result data is encapsulated and unencapsulated in the second format.
  • the performance of the application in the memory and the client process construct functional modules corresponding to the functions according to mutual agreements, both of which include a parsing module and a transceiver module, wherein the parsing module is responsible for executing the first format and the first format.
  • the functions related to the second format are realized, and the transceiver module is used to perform communication transmission related to the first format and the second format.
  • the application program constructs an interface management module for uniformly executing the client process and the application program's own access to the interface library.
  • the client process is responsible for maintaining the communication state with the service process to ensure the stability of the cross-process communication between the client process and the service process.
  • the method further includes the following steps:
  • the instance table information generated by the call of the client process is cleared.
  • a terminal device provided by the present invention includes a central processing unit and a memory, and the central processing unit is used to call and run a computer program stored in the memory to execute the above-mentioned
  • the application program interface calls the steps of the control method.
  • the present invention has the following advantages:
  • the method of the present invention uses the interface library to store and manage the implementation classes of the application program, and register its built-in implementation classes in the interface library in advance when the application program is running, and then be called by the client process.
  • the interface identifier is associated with the interface class of the client process and the implementation class of the application, as well as the memory resources such as instance objects and proxy objects of the implementation class. It plays a role in centralized scheduling and management of calls between processes, making the application (Expressed as a service process)
  • the interface call between the client process is more flexible and efficient.
  • the interface library also configures storage and management mechanisms for it, so that the relevant attribute information required for the operation of the built-in method of the instance object can be interoperated across processes by querying the interface library. Therefore, the client process can communicate with each other through its The proxy object can pass parameters and call the built-in methods of the instance object of the service process. Therefore, the setting of the interface library and its protocol analysis mechanism makes it possible to communicate efficiently across processes.
  • the improvement of cross-process communication efficiency is reflected in the development process, especially in the development process of the Android operating system, which can greatly improve the efficiency of program development.
  • the implementation of the present invention makes it unnecessary to perform a completely consistent interface configuration process for a new interface based on AIDL when calling interfaces between different processes.
  • developers only need to create an API interface class and its implementation class for the cross-process communication interface, instead of repeating other well-known steps.
  • the API interface will be registered in the interface library, and the functions corresponding to other known steps are automatically implemented by the method of the present invention in a program process.
  • the present invention can greatly improve the efficiency of program development, help release development capabilities, and comprehensively reduce project development costs.
  • the service process of the present invention is equipped with service components, its interface calling mechanism can provide services for multiple client processes in parallel, regardless of whether these client processes belong to this application or other applications, which is a joint development Projects such as login module, authorization module, payment module, filter module, etc. provide a convenient basis for technical implementation.
  • it is the application program or the client process of a different application program, as long as it complies with the protocol regulated by the method of the present invention, it also has the ability to interact with the application program of the present invention, so as to realize the resource connection with the application program. Call each other and share memory resources with the service process represented by this application.
  • This basic technology is also conducive to ensuring the survival of service processes or client processes in memory, the mechanism of binding each other through service components, scheduling activities that implement class interfaces, and making it possible for processes to wake up each other, ensuring The activity of each process in the memory, to prevent each process from being terminated during the memory cleaning process, and even one process can be used to restart another process, so that these processes are always running in the system.
  • the service process realizes the ability of centralized maintenance and service of the interface, and the client process can simplify the development.
  • One or more client processes regardless of whether these processes belong to the same application or different programs, can be provided by the service process to provide interface services. For terminal programs related to joint development projects that focus on realizing some core functions, or for scenarios that require extended plug-ins, it is more efficient.
  • the present invention adopts a protocol analysis mechanism for the intermediate process data between the service process and the client process. Specifically, the first format is adopted at the call level and the second format is adopted at the result level.
  • the first format is adopted at the call level and the second format is adopted at the result level.
  • Develop some analysis modules with concentrated functions and configure them in the client process and service process so as to facilitate the modular development of the analysis and packaging functions corresponding to different formats, and further improve the development efficiency while ensuring the security of communication between different processes.
  • FIG. 1 is a schematic diagram of the realization structure of the client process and the service process in the principle on which the present invention is implemented;
  • FIG. 2 is a schematic flowchart of an application program interface calling control method in a typical embodiment of the present invention
  • FIG. 3 is a schematic flowchart of a cross-process communication method in a typical embodiment of the present invention.
  • Fig. 4 is a schematic flow diagram of specific steps of step S23 in the cross-process communication method of the present invention.
  • client includes both wireless signal receiver devices, which only have wireless signal receiver devices without transmitting capabilities, and include A device for receiving and transmitting hardware, which has a device capable of receiving and transmitting hardware for two-way communication on a two-way communication link.
  • Such devices may include: cellular or other communication devices such as personal computers, tablet computers, which have single-line displays or multi-line displays or cellular or other communication devices without multi-line displays; PCS (Personal Communications Service, personal communication) System), which can combine voice, data processing, fax and/or data communication capabilities; PDA (Personal Digital Assistant), which can include radio frequency receivers, pagers, Internet/Intranet access, web browsers, and notes Notebook, calendar, and/or GPS (Global Positioning System) receiver; conventional laptop and/or palmtop computer or other equipment, which has and/or includes a conventional laptop and/or radio frequency receiver Palm-size computer or other equipment.
  • cellular or other communication devices such as personal computers, tablet computers, which have single-line displays or multi-line displays or cellular or other communication devices without multi-line displays
  • PCS Personal Communications Service, personal communication) System
  • PDA Personal Digital Assistant
  • GPS Global Positioning System
  • the “client”, “terminal”, and “terminal device” used here may be portable, transportable, installed in vehicles (air, sea and/or land), or suitable and/or configured to be locally Operate, and/or in a distributed form, operate in any other location on the earth and/or space.
  • the “client”, “terminal”, and “terminal device” used here can also be communication terminals, internet terminals, music/video playback terminals, such as PDA, MID (Mobile Internet Device, mobile Internet device) and/or Mobile phones with music/video playback functions can also be devices such as smart TVs and set-top boxes.
  • terminal equipment and “mobile terminal” in the present invention is essentially a device with the equivalent capabilities of a personal computer, which has a central processing unit (including arithmetic unit and controller), memory, and input
  • the hardware devices of the necessary components disclosed by the Von Neumann principle, such as equipment and output devices, have computer programs stored in their memory, and the central processing unit transfers the programs stored in the external memory into the memory to run, executes the instructions in the programs, and
  • the input and output devices interact to complete specific functions.
  • the application program of the present invention runs in the form of a computer program in a terminal device such as a mobile terminal such as a mobile phone, a tablet, etc.
  • the terminal device runs Android or a forward compatible Android (for example, the "Hongmeng" recently developed by Huawei-Harmony OS) operating system.
  • the application program is scheduled to run in the memory by the central processing unit to implement the relevant method of the present invention.
  • each application program will run in a virtual machine of the system.
  • the operating system also supports a multi-process architecture. Therefore, the same application program may include multiple processes, for example, a process that provides service functions is run by registering a service component on the basis of the main process.
  • a protocol mechanism is established between the service process 2 and the client process 1, and the two have complied with the relevant development agreement in advance. Therefore, in scenarios where the data format is required, it includes encapsulation and decapsulation (analysis) in a specific data format.
  • This kind of agreement exists between each other, so the data encapsulated by the other party can be recognized by each other, and the content transmitted by the other party can be restored correctly. That is to say, between the client process 1 and the service process 2, the data format encapsulated by one party can be correctly parsed by the other party in accordance with the pre-agreement.
  • the agreement between service process 2 and client process 1 defines two formats, the first is the request format, and the second is the result format.
  • the request format is used to encapsulate and decapsulate various requests initiated by the client process 1.
  • the data involved is mainly the interface identifier and method identifier (and attribute information such as method operating parameters and return value types) obtained after the client process parses the interface class annotations.
  • the object identifier carried by the proxy object, etc., and the result format is used to encapsulate and decapsulate various result data generated by the execution of the service process 2.
  • the return value after the method is called and executed.
  • the request format is usually encapsulated by the client process 1 and parsed by the service process 2, and the result data is usually encapsulated by the service process 2 and parsed by the client process 1. For this reason, it will be revealed below that both the client process 1 and the service process 2 will construct specialized functional modules, namely, the parsing modules 13, 23 to implement the encapsulation and decapsulation functions related to these data formats.
  • the service process 2 is responsible for the registration of the interface and subsequently receives the interface creation and invocation request of the client process 1, and provides the interface creation and invocation service for the client process 1.
  • the service process 2 needs to register a service component 20 with the system, thereby realizing background operation.
  • the service process 2 mainly includes a business module 21, an execution module 22, a parsing module 23, a transceiver module 24, and the service component 20, and maintains an interface library 25 by performing registration after startup.
  • the business module 21 is responsible for the interface implementation class The registration function; its service component 20 is mainly provided to the client process 1 for binding, so as to ensure the communication between the service process 2 and the client process 1; on the one hand, the transceiver module 24 is responsible for receiving various requests from the client process 1, On the other hand, it is responsible for feeding back various result data to the client process 1, through its two-way service function to meet the communication transmission between the service process 2 and the client process 1.
  • Its analysis module 23 is mainly used to parse out the client process 1 in the first format (Request format) encapsulated various requests, and encapsulate various result data in the second format (result format) to send to the client process 1 through its transceiver module 24; its execution module 22 is mainly responsible for the response when the client process 1 requests an interface call.
  • the client process 1 is mainly responsible for interacting with the service process 2, serving the interface creation and invocation requirements of its business module 11, and maintaining the request process of interface creation and invocation. After the client process 1 is started, it seeks to bind with the service component 20 of the service process 2, and is responsible for maintaining the bound connection state. If the service process 2 is not started, the client process 1 can even be responsible for calling the service component 20 running the service process 2 to facilitate subsequent calls to related interfaces by itself.
  • client process 1 also has a transceiver module 14 and analysis module 13 corresponding to service process 2.
  • the transceiver module 14 is responsible for receiving various types of service process 2.
  • the result data is responsible for issuing various requests initiated by its own business module 11 to the service process 2; its parsing module 13 is mainly used to parse out the interface identifier from the programming annotations of the interface to be called by its business module 11 and use the first One format encapsulates it into an interface creation request, and is further used to parse the attribute information from the programming annotations of the implementation class built-in method to be called by its business module 11 and encapsulate it into an interface call request in the first format, so that it can be followed by the customer
  • the transceiving module 14 of process 1 sends these requests to the service process 2; the parsing module 13 analyzes various result data from the service process 2 in reverse, including the interface creation request and the result data corresponding to the interface call request for feedback Business module 11 for client process 1.
  • the interface library 3 of the present invention can realize the unified execution of the client process 1 and the service process 2 to access the interface library 3 by constructing a functionally relatively independent interface management module.
  • the interface management module can generally be constructed by the service process 2, or the service process 2 and the client process 1 can each construct their own required functions, and the implementation method is flexible.
  • the interface library 3 maintained by the interface management module is logically mainly maintained by the service process 2 for use by the client process 1, but in an interactive manner, both the service process 2 and the client process 1 will access the interface library 3 in order to implement relevant protocol analysis mechanism.
  • the interface library 3 is mainly used to record relevant data related to the interface, and its manifestation can be flexibly implemented by those skilled in the art.
  • the interface library 3 is mainly used to store the interface registration information formed by the registration of the service process 2 and the interface registration information related to the instance objects generated during the interaction between the service process 2 and the client process 1.
  • the interface registration information can be constructed as the following tables: class table, method table, and instance table.
  • the class table is used to store expression class table information.
  • the class table information is used to characterize the corresponding relationship between the interface identifier of the interface and the implementation class and interface class. Through this corresponding relationship, the client process 1 can query and determine the relevant interface identifier according to the interface class to be called by its business module 11, and the service process 2
  • the relevant implementation classes can be determined according to the parsed interface identification query, and they correspond to each other and can be uniquely determined.
  • the method table is used to store expression method table information.
  • the method table information is used to characterize the relationship between the implementation class and its built-in methods, and the call operation information of these built-in methods.
  • the characterization of the relationship between the implementation class and its built-in methods can be achieved by establishing a unique correspondence relationship between the call operation information of the built-in method in the method table information and the interface identifier.
  • the invoking operation information is the relevant information determined by the service process 2 for each built-in method when the implementation class is registered, including the method identifier assigned to the built-in method, the operating parameters required for the operation of the method, and the method The defined return value type.
  • the client process 1 clarifies the built-in method of a certain implementation class specified by its business module 11, it can query the interface registration information in the interface library 3, specifically the method table, to obtain the method Table information, more clearly, obtain the method ID related to the built-in method. Then, the client process 1 merges the operating parameters and return value types provided by the service module 11 corresponding to the built-in method, and transmits these invocation operating information to the service process 2. After the service process 2 parses out the calling operation information transmitted from the client process 1, and obtains the method identifier therein, it can query the interface library 25 based on the method identifier to determine the built-in method in the specific instance object for execution.
  • the instance table is used to store the information of the expression instance table.
  • the instance table information is used to characterize the information related to the implementation class instance objects that are providing services for the client process 1.
  • each instance object can be assigned a corresponding object identifier, and the proxy object can also carry the identifier.
  • the instance object is further associated with the proxy object, and the instance object can also be determined through the object identifier to be called.
  • other direct or indirect identifiers can also be given, and even further associated with the interface identifiers of related implementation classes. In short, as long as it is sufficient to ensure the uniqueness of subsequent calls to the instance object through the proxy object.
  • Those skilled in the art should be able to implement such things flexibly.
  • Interface registration information refers to the information related to the creation and invocation of the interface used to implement this method, including all kinds of information obtained by the service process 2 by parsing the programming annotations of the implementation class when it is started, and the running process of the service process 2 Instance information maintained in.
  • the business module 21 of the service process 2 will provide the implementation class of the API interface of the service, call the method of registering the service class to register, and the method of registering the service class internally calls the interface management module. After receiving the registration request, it obtains the relevant information of the registered implementation class. , Whether the parsing class is annotated with the interface identifier of the implementation class according to the use of the protocol, and when there is an interface identifier, it is stored as interface registration information for invocation.
  • the service process 2 completes the registration of the interface through this process, forms the basic data of the interface registration information, and provides a key foundation for subsequent cross-process interface calls.
  • the proxy object of the client process 1 needs to call the analysis mechanism of the client process 1 , Query the interface library 3, generally the method table information in it, determine the interface identifier or object identifier corresponding to the built-in method and its calling operation information, and form the attribute information required to run the built-in method, so as to finally provide it to the service process 2 Reverse analysis and use it to ensure that the built-in method of the instance object can be effectively invoked and executed by the service process 2.
  • the attribute is used to indicate the specific instance object by the interface identifier or the object identifier depends on the specific realization of the proxy object.
  • the following principles of the present invention disclose a situation in which the object identifier is used for realization, the original A person of ordinary skill in the art should also understand that the same effect can also be achieved through the interface identification, as long as it is ensured that there is a one-to-one correspondence with the proxy object and the instance object and that each process agrees with each other.
  • the proxy object referred to here is implemented using Java proxy technology.
  • Java proxy technology Those skilled in the art can use Java proxy technology to map the instance object of the corresponding implementation class created by the service process 2 in response to the interface creation request on the client process.
  • the corresponding proxy object The proxy object is generated by the response of the interface creation request.
  • the service process 2 allocates the corresponding object identifier after the instance object is generated, and provides the object identifier to the client process to generate the proxy object.
  • the proxy object also carries the object. Object ID.
  • the business module 11 of the client process 1 initiates a request service for a certain interface class, and the client process 1 responds with a request service method.
  • the method for requesting service uses an analysis mechanism to query the interface library 3 to determine the corresponding interface identifier of the interface class, encapsulate it into request format data, and transmit it to the service process 2.
  • the service process 2 parses the request format data after receiving it, and uses the interface identifier to query the interface registration information in the interface library 3, determines the corresponding implementation class, creates its instance object, and can generate a unique object identifier for the object at the same time ,
  • the corresponding relationship between the object identifier and the object is stored as instance table information, so the proxy object generated by the subsequent client process 1 should naturally carry the object identifier, so that the subsequent proxy object only needs to pass its object identifier to the service process 2, and the service Process 2 can determine the corresponding instance object based on its uniqueness.
  • the client process 1 After the client process 1 generates the proxy object, it is returned to the service module 11 of the client process 1 for further method calls.
  • the business module 11 of the client process 1 obtains the proxy object corresponding to its interface creation request, and further initiates an interface call request to call the relevant built-in method of the instance object pointed to by the proxy object.
  • the client process 1 invokes the analysis mechanism to obtain the method identifier, operating parameters, return value type, and object identifier related to the built-in method, and uses these information to form attribute information, which is formatted and encapsulated and sent to the service process 2.
  • the service process 2 calls the analysis mechanism to parse out the specific information in the attribute information. The service process then calls and executes the built-in method.
  • the instance object to be called can be determined, and the specific internal information can be determined according to the method identifier.
  • Build a method and then pass related operating parameters to the built-in method, and run as the passed parameters of the built-in method. After the built-in method runs, a result that meets the return value type is obtained. Then, the service process 2 can encapsulate the related result data in the second format and return it to the client process 1. After the proxy object in the client process 1 obtains the corresponding analysis of the data call analysis mechanism, it returns to the service module 11 of the client process 1 to complete the response to its interface call request.
  • a step of clearing memory can also be performed.
  • the interface management module clears the related objects in the instance table of the interface library 3 .
  • the client process 1 and the service process 2 can also start or wake up each other one-way or each other according to preset rules, such as timing and trigger conditions, so that both parties can Live in the memory, avoid being cleaned up by the operating system or the memory cleaning program of third-party security software.
  • the application program interface call control method of the present invention is implemented in the form of a computer program, and the application program of the present invention is provided. After the application program is installed and run in the operating system, the execution includes the following steps:
  • step S11 after the service component 20 pre-registered to the operating system of the application is started, the service component 20 accepts the binding communication of the client process 1 belonging to the same application or a different application with the application.
  • this application can declare a service component 20 in its installation configuration file Androidmanifest.xml file. After the service component 20 is started by the system, the application will play the role of service process 2 in the memory.
  • the service component 20 can communicate and interact with other client processes 1.
  • the client process 1 can be either the process where the service component of the application is located, or other applications, especially the client process 1 that is displayed when the application is running for some joint development projects that have agreed on a protocol scheme.
  • an application-related process will run in an independent virtual machine, but it is also allowed to exist in the same application to implement a multi-process architecture.
  • this application can declare service components The way to achieve multi-process architecture. From this, it can be understood that client process 1 and service process 2 can run in the same virtual machine or different virtual machines in parallel.
  • client process 1 does not belong to this application, it means that client process 1 and service process 2 belong to different Memory virtual machine, but due to the realization of the present invention, the development of the interface call between them becomes more convenient.
  • the client process 1 can be bound to it. According to the above-mentioned principle of the present invention, the client process 1 is also responsible for maintaining the connection state between it and the service component in order to determine the stable connection between the client process 1 and the application. After the client process 1 and the service process 2 are bound, the subsequent functions related to the interface call can be further completed.
  • Step S12 In response to the interface creation request initiated by the client process 1 based on calling the interface class, the application creates an instance object of the implementation class corresponding to the interface class; the interface registration information corresponding to the implementation class is used by the application It is registered in the interface library 3 in advance, and is set in a one-to-one correspondence with the interface class.
  • the client process 1 of the present invention will initiate an interface creation request to the application according to the needs of its own business module 11 to use related interfaces.
  • the service module 11 when its service module 11 runs to define or call an instruction of a related interface class, an interface call will occur.
  • the service module 11 first needs the system to create a related interface for it.
  • the client process 1 inquires the class table information in the interface library 3 according to the pre-protocol parsing mechanism, that is, calls its parsing module 13, and determines the interface identifier uniquely corresponding to the interface to be created based on the class table information, and uses the first format to pair
  • the query result is encapsulated, encapsulated into the requested format data, and sent to the application.
  • the transceiver module 24 of the service process 2 of this application will receive the request through the service component and pass it to the parsing module 23 for parsing.
  • the parsing module 23 can decapsulate the request format data to obtain the interface identifier, and then call its execution module 22 After determining the corresponding implementation class from the class table information of the interface library 3 according to the interface identifier, the execution module 22 executes the creation of an instance object of the implementation class.
  • this application has pre-registered the interface registration information related to the implementation class in the interface library 3. According to the corresponding relationship between the implementation class and the interface identifier, it is possible to avoid incorrectly calling the implementation class.
  • the instance object After the instance object is created, it is given an object identifier with unique characteristics. The one-to-one correspondence between the object identifier and the instance object will also be updated to the interface library 3 by this application, and the object identifier will also be used as
  • the result data is encapsulated into result format data in the second format by the parsing module 23 of the service process 2 of this application, and then fed back to the client process 1 via the transceiver module 24.
  • the transceiving module 14 of the client process 1 After receiving the result format data, the transceiving module 14 of the client process 1 passes it to the parsing module 13 of the client process 1 to parse the object identification, and then uses Java proxy technology to create a proxy object of the instance object, which naturally carries the object Logo.
  • the proxy object can communicate with the service process 2 based on its own object identifier, so that the service process 2 can correctly call the relevant instance object.
  • the instance object After the instance object is created, its related information is stored in the instance table of the interface library 3 as the instance table information to provide services. If the client process 1 and the service component 20 of the service process 2 are unbound, the instance table information will become the remaining redundant information. Therefore, a parallel step can be set up to implement the cleanup of the redundant information, specifically After the client process 1 and the service process 2 are unbound, the redundant information in the interface library 3 is deleted. This step can theoretically be implemented in the service process 2 in order to centrally manage the memory, or it can be set in the client process 1, which is implemented by the client process 1 before it determines to unbind.
  • the application program can further provide the client process 1 with a call service for the built-in method of the instance object.
  • Step S13 The application program responds to the interface call request for calling the built-in method of the instance object initiated by the client process 1, and the request includes the interface registration information determined according to the interface library 3 for executing the internal method. According to the attribute information of the method, the built-in method of the instance object is invoked and executed according to the attribute information to generate result data and fed back to the client process 1.
  • the client process 1 After the client process 1 successfully establishes the proxy object of the instance object, it returns to its service module 11 for further calls.
  • the service module 11 of the client process 1 will then initiate an interface call request to a built-in method of the instance object through the proxy object.
  • the proxy object can combine the calling operation information obtained by querying the method table information in the interface library 3, and combine the object identifier carried by itself, the internal
  • the parsing module 13 is encapsulated into the interface call request in the requested format,
  • the transceiver module 14 sends to the application program.
  • the transceiver module 24 of the application program receives the interface call request transmitted by the proxy object, calls the analysis module 23 to analyze the attribute information therein, and then calls the execution module 22 to execute the call to the built-in method.
  • the execution module 22 queries the interface library 3, the corresponding instance object can be determined from the instance table according to the object identifier in the attribute information, and the built-in method of the corresponding instance object can be determined from the method table according to the method identifier, and then Pass the operating parameter data in the attribute information to the target built-in method in the target instance object, call and execute it, so that the target built-in method returns result data that meets the return value type specification.
  • the result data obtained by running the built-in method is encapsulated by the parsing module 23 of the application program into a result format and then sent back to the proxy object of the client process 1.
  • the proxy object parses the result data in reverse and returns it to the business module 11.
  • the service module 11 then obtains the invoking operation result of the built-in method of the instance object generated by the implementation class corresponding to the invoking interface class, and completes the entire process of invoking the interface.
  • the return value type does not need to be added as attribute information. On the one hand, it is not necessary to record the item in the method table information of the interface library 3, and on the other hand, there is no need to interact with the client process 1 and the service process 2. If this item is used in the process, those skilled in the art should be aware of this alternative.
  • this application can independently build an interface management module to centrally manage access to the interface library 3, and provide a calling interface for the modules that need to access the interface library 3 for call execution. , This can improve memory efficiency.
  • the implementation of this exemplary embodiment helps to provide an application program with a cross-process service function at the application program level, and facilitates the access of other applications, thereby facilitating the development of joint program projects.
  • the application program embodied in this exemplary embodiment is installed on a mobile device such as a mobile terminal or a tablet, it can be embodied as another embodiment of the present invention, and this embodiment is embodied as a terminal device provided by the present invention. It includes a central processing unit and a memory, and the central processing unit is used to call and run a computer program stored in the memory to execute each specific step of the application program interface call control method as described above.
  • a cross-process communication method of the present invention includes the following steps:
  • step S21 the client process 1 queries the interface library 3 pre-registered with the interface registration information by the service process 2 to obtain the interface identifier of the interface class according to the invocation of the interface class by its service module 11, and encapsulates the interface class according to the pre-protocol request format.
  • Service process 2 initiates an interface creation request.
  • the interface library 3 has been pre-configured by the service process 2, and the service process 2 has registered class table information and method table information with the interface library 3, and is in the process of interacting with the client process 1.
  • the information of the maintenance instance table is also updated. Therefore, the client process 1 can directly use the interface registration information of the interface library 3 in this step.
  • the client process 1 and the service process 2 also implement their respective internal functional modules according to the principles of the present invention.
  • the business module 11 of the client process 1 first initiates a call to a specific interface class.
  • the client process 1 uses its parsing module 13 to query the interface registration information of the interface library 3, specifically through the interface
  • the class table in library 3 is queried to obtain the interface identifier corresponding to the interface class.
  • the parsing module 13 complies with the agreement with the service process 2 and encapsulates the interface identifier into a request format to form an interface creation request, which is sent to the service process 2 via the transceiver module 14 of the client process 1.
  • Step S22 the service process 2 receives the interface creation request, parses the request, uses the interface identifier therein to execute the creation operation of the corresponding implementation class, generates an instance object of the implementation class, and reversely encapsulates the backward client process in the pre-contracted result format 1 Feedback the result data generated by the creation operation;
  • the service process 2 After the service process 2 receives the interface creation request via its transceiver module 24, its parsing module 23 parses out the interface identifier therein, and then its execution module 22 queries the interface library 3 to determine the implementation class corresponding to the interface identifier After that, the action of creating an instance object of the implementation class is performed.
  • an object identifier is assigned to the instance object, and the object identifier can be used by the client process 1.
  • the service process 2 constructs the instance object, it encapsulates the object identifier of the instance object into the result data according to the second format of the pre-protocol, and returns it to the client process 1 through its transceiver module 24.
  • step S23 the client process 1 receives the result data, parses it into a proxy object of the instance object according to the protocol, and returns it to the business module 11 of the client process 1, so that the business module 11 can call the proxy object. Implement calling the instance object.
  • the client process 1 After the client process 1 receives the result data through its transceiving module 14, it will be handed over to its parsing module 13 to parse out the object identifier therein, and use Java proxy technology to construct a proxy object for the instance object pointed to by the object identifier.
  • the proxy object carries the object identifier, and then returns the proxy object to the service module 11 of the client process 1 for the next method call.
  • the service module 11 can call the instance object by calling the proxy object.
  • the business module 11 uses proxy objects to implement calls to its corresponding instance objects.
  • the client process 1 can follow the following specific steps Cooperate with service process 2 to call the proxy object to further implement the call to the built-in method of the instance object it points to:
  • step S231 the service module 11 of the client process 1 initiates an interface call request for calling the method of the proxy object.
  • the business module 11 of the client process 1 When the business module 11 of the client process 1 needs to call the built-in method of the interface class of the corresponding proxy object, it initiates the interface call request, and expects the returned result by calling the proxy object.
  • the proxy object For the acquisition, the proxy object is responsible for the execution of the intermediate process.
  • Step S232 The proxy object queries the interface library 3 to determine the corresponding attribute information of the method, forms the attribute information into a pre-protocol request format, and sends it to the service process 2.
  • the proxy object can combine the calling operation information obtained by querying the method table information in the interface library 3, and combine the object ID it carries, the method ID of the built-in method, and the built-in information passed by the business module 11.
  • the operating parameters (data) of the method and the attribute information such as the return value type of the built-in method are encapsulated by the calling analysis module 13 into an interface calling request in the request format, and then sent to the service process 2 via the transceiver module 14.
  • step S233 the service process 2 receives and queries the interface library 3 to parse out the attribute information, and calls the corresponding implementation class object to execute the corresponding method therein.
  • the transceiver module 24 of the service process 2 receives the interface call request transmitted by the proxy object, calls the analysis module 23 to analyze the attribute information therein, and then calls the execution module 22 to execute the call to the target method.
  • the execution module 22 queries the interface library 3, the corresponding instance object can be determined from the instance table according to the object identifier in the attribute information, and the built-in method of the corresponding instance object can be determined from the method table according to the method identifier, and then Pass the operating parameter data in the attribute information to the target built-in method in the target instance object, call and execute it, so that the target method returns result data that meets the return value type specification.
  • step S234 the service process 2 feeds back the result data after the execution of the method to the client process 1 in a pre-agreeed result format.
  • the result data obtained by the service process 2 calling the running target method is encapsulated into the result format by the parsing module 23 of the service process 2, and then sent back to the proxy object of the client process 1 through the transceiver module 24 of the service process 2 for internal transmission by the client process 1. Used by its business module 11.
  • step S235 the client process 1 receives the result data, analyzes and restores it, and returns it to its service module 11.
  • the proxy object After the client process 1 receives the result data returned by the service process 2 to the proxy object through its transceiving module 14, the proxy object calls the parsing module 13 to parse the result data in reverse, and returns the parsed result data directly to the business module 11. Then, the service module 11 obtains the calling operation result of the built-in method of the instance object generated by the implementation class corresponding to the calling interface class, and completes the whole process of calling the interface.
  • the return value type does not need to be added as attribute information.
  • the implementation of this exemplary embodiment provides a bottom-level implementation scheme for cross-process communication, so that the principles of the present invention can be applied to the bottom layer, and solve the technical obstacles in cross-process communication.
  • the application program embodied in this exemplary embodiment is further installed on a mobile device such as a mobile terminal or a tablet, it can be embodied as another embodiment of the present invention, and this embodiment is embodied as a method provided by the present invention.
  • the terminal device includes a central processing unit and a memory, and the central processing unit is used to invoke and run a computer program stored in the memory to execute the steps of the aforementioned cross-process communication method.
  • the present invention simplifies the development steps involved in the realization of communication interfaces in the application program development process, and provides a simpler and more efficient cross-process communication solution for jointly developed program projects.
  • the present invention includes equipment for performing one or more of the operations and methods described in the present invention.
  • These devices may be specially designed and manufactured for the required purpose, or may also include known devices in general-purpose computers.
  • These devices have computer programs stored in their memory, which are selectively activated or reconfigured.
  • Such a computer program may be stored in a device (for example, a computer) readable medium or in any type of medium suitable for storing electronic instructions and respectively coupled to a bus.
  • the computer readable medium includes, but is not limited to, any Types of disks (including floppy disks, hard disks, optical disks, CD-ROMs, and magneto-optical disks), ROM (Read-Only Memory), RAM (Random Access Memory), EPROM (Erasable Programmable Read-Only Memory) , Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory, magnetic card or optical card. That is, the readable medium includes any medium that stores or transmits information in a readable form by a device (for example, a computer).
  • a device for example, a computer.

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

A terminal apparatus and control method for calling application program interface therefor. The method comprises the following steps: an application program receiving, after a service component thereof is activated, binding communication of a client process by means of the service component; the application program creating, in response to an interface creation request initiated by the client process on the basis of calling an interface class, an instance object of a corresponding implementation class, wherein interface registration information corresponding to the implementation class is pre-registered in an interface library by the application program; and the application program calling and executing, in response to an interface calling request initiated by the client process for calling a built-in method of the instance object, the built-in method of the instance object to generate and feed back resulting data to the client process, wherein the request comprises property information determined according to the interface registration information in the interface library for executing the built-in method. The present invention simplifies development steps related to implementing a communication interface during an application program development process, and provides a simple, convenient, and efficient cross-process communication solution.

Description

终端设备及其应用程序接口调用控制方法Terminal equipment and its application program interface calling control method
本申请要求于2020年03月24日提交中国专利局、申请号为202010212433.9、发明名称为“终端设备及其应用程序接口调用控制方法”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on March 24, 2020, the application number is 202010212433.9, and the invention title is "terminal equipment and its application program interface call control method", the entire content of which is incorporated by reference In this application.
技术领域Technical field
本发明涉及Android操作系统的应用程序开发技术,尤其涉及一种应用程序接口调用控制方法,还涉及其相应的终端设备。The invention relates to the application development technology of the Android operating system, in particular to an application program interface call control method, and also to its corresponding terminal equipment.
背景技术Background technique
开发Android应用过程中,根据业务规模、场景的不同,我们会开始引入多进程通信技术到现有技术体系中。使用多进程通信技术,能突破应用可分配系统资源的限制(Android系统资源的分配以进程为基本单位),让应用的可使用资源成倍增长,能实现应用保活等业务需求,但是增加了多进程通信的技术体系,我们就需要处理多进程通信中数据传输的问题,由此将大幅度增加开发的技术复杂度。In the process of developing Android applications, we will begin to introduce multi-process communication technology into the existing technology system according to different business scales and scenarios. The use of multi-process communication technology can break through the limitation of the application's allocable system resources (the allocation of Android system resources is based on the process as the basic unit), so that the available resources of the application can be doubled, and business needs such as application keep-alive can be achieved, but it has increased For the technical system of multi-process communication, we need to deal with the problem of data transmission in multi-process communication, which will greatly increase the technical complexity of development.
Android官方本身提供了多种解决多进程通信的技术,我们通常使用AIDL来实现进程间通信。AIDL是Android中IPC(Inter-Process Communication)方式中的一种,是Android Interface definition language(Android接口定义语言)的缩写。AIDL虽然各方面指标都较为符合实际需要,但处理过程复杂,开发成本较高。The Android official itself provides a variety of technologies to solve multi-process communication. We usually use AIDL to achieve inter-process communication. AIDL is one of the IPC (Inter-Process Communication) methods in Android, and is an abbreviation of Android Interface definition language (Android interface definition language). Although AIDL's indicators are more in line with actual needs, the processing process is complicated and the development cost is high.
一般使用AIDL开发一个支持多进程通信的接口方法,我们需要做如下操作:1、创建aidl文件,在aidl文件中定义接口类;2、如果接口类的方法的参数中含有自定义类型,还需要为该类型再定义一个aidl文件;3、需要创建一个Service类为提供服务的进程提供信息的通信服务;4、定义一个Binder类去实现aidl中定义的接口类,在实现类中实现功能逻辑;5、Service类通过onBind接口返回步骤4中Binder类的对象给Client程序;6、Client程序需要去连接Server程序的Service类,在onServiceConnected方法中获取Binder类的代理对象,通过代理对象调用Binder类的接口方法来 获取Binder类提供的功能;7、Client程序需要维护其与Service类的连接状态,因为Service类是其通信交互的载体。Generally using AIDL to develop an interface method that supports multi-process communication, we need to do the following: 1. Create an aidl file and define the interface class in the aidl file; 2. If the parameter of the interface class method contains a custom type, you also need Define another aidl file for this type; 3. A Service class needs to be created to provide information communication services for the process providing services; 4. A Binder class is defined to implement the interface class defined in aidl, and the functional logic is implemented in the implementation class; 5. The Service class returns the object of the Binder class in step 4 to the Client program through the onBind interface; 6. The Client program needs to connect to the Service class of the Server program, obtain the proxy object of the Binder class in the onServiceConnected method, and call the Binder class through the proxy object Interface methods to obtain the functions provided by the Binder class; 7, the Client program needs to maintain its connection with the Service class, because the Service class is the carrier of its communication and interaction.
按照上述利用AIDL开发多进程通信的接口方法可以创建一个跨进程接口,问题的关键在于,通常情况下每个提供IPC服务的接口类都需要按照上述的步骤重新操作一遍,如此可以看出,现有技术虽然支持ipc通信,但是其开发步骤复杂而繁琐、可扩充性差,导致开发成本较高。这特别不利于一些需要联合运行的项目的开发。According to the above-mentioned interface method of using AIDL to develop multi-process communication, a cross-process interface can be created. The key to the problem is that in general, each interface class that provides IPC services needs to be operated again according to the above steps. It can be seen that now Although some technologies support ipc communication, their development steps are complex and cumbersome, and their scalability is poor, leading to high development costs. This is particularly unfavorable for the development of projects that require joint operation.
发明内容Summary of the invention
本发明的首要目的在于为提升应用程序开发效率而提供一种应用程序接口调用控制方法。The primary purpose of the present invention is to provide an application program interface call control method for improving application program development efficiency.
相应的,作为本发明的其他目的,也基于前一目的的方法而提供与之相适应的终端设备。Correspondingly, as another object of the present invention, a terminal device compatible with it is also provided based on the method of the previous object.
为满足本发明的首要目的,本发明提供的一种应用程序接口调用控制方法,该方法包括如下步骤:In order to meet the primary purpose of the present invention, the present invention provides an application program interface call control method, which includes the following steps:
本应用程序在其预注册到操作系统的服务组件被启动后,通过该服务组件接受与本应用程序属于同一应用程序或不同应用程序的客户进程的绑定通信;After the service component pre-registered to the operating system of this application is started, the service component accepts the binding communication with the client process of the same application or a different application through the application;
本应用程序响应于所述客户进程基于调用接口类而发起的接口创建请求,创建与该接口类相应的实现类的实例对象;所述实现类相应的接口注册信息被本应用程序预先注册到接口库中,其与所述接口类一一对应设置;This application creates an instance object of the implementation class corresponding to the interface class in response to the interface creation request initiated by the client process based on calling the interface class; the interface registration information corresponding to the implementation class is pre-registered to the interface by this application In the library, it is set in a one-to-one correspondence with the interface class;
本应用程序响应于所述客户进程发起的关于调用该实例对象的内建方法的接口调用请求,该请求中包含依据所述接口库的接口注册信息确定的用于执行该内建方法的属性信息,依据所述属性信息调用执行该实例对象的内建方法以产生结果数据反馈给客户进程。This application responds to an interface call request for invoking the built-in method of the instance object initiated by the client process, and the request includes the attribute information for executing the built-in method determined according to the interface registration information of the interface library , Call and execute the built-in method of the instance object according to the attribute information to generate result data and feed it back to the client process.
部分实施例中,该方法还包括如下步骤:In some embodiments, the method further includes the following steps:
执行对本应用程序的版本更新,在更新后的本应用程序运行后,重新执行对所述接口库的注册,使所述接口库中所注册的接口个数增加或减少。Perform a version update of the application program. After the updated application program runs, re-register the interface library to increase or decrease the number of interfaces registered in the interface library.
较佳的,所述的接口库中的接口注册信息包括:Preferably, the interface registration information in the interface library includes:
表征接口的接口标识与实现类、接口类之间对应关系的类表信息,以便依据所述接口标识确定接口类与实现类之间的一一对应关系;Class table information that characterizes the corresponding relationship between the interface identifier of the interface, the implementation class, and the interface class, so as to determine the one-to-one correspondence between the interface class and the implementation class according to the interface identifier;
表征实现类及其内建方法之间关系及该些内建方法的调用运行信息的方法表信息,以便执行方法调用;Method table information that characterizes the relationship between the implementation class and its built-in methods and the call operation information of these built-in methods, so as to execute method calls;
表征正在为客户进程提供服务的实现类实例对象及其具有唯一性特征的对象标识之间对应关系的实例表信息,以便实施实例对象的调用。The instance table information that characterizes the correspondence between the implementation class instance objects that are providing services to the client process and the object identifiers with unique characteristics, so as to implement the invocation of the instance objects.
具体的,所述属性信息包括内建方法所属的实现类对应的接口标识或对象标识和该内建方法的所述调用运行信息,所述调用运行信息包括所述内建方法的方法标识、运行参数、返回值类型。Specifically, the attribute information includes the interface identifier or object identifier corresponding to the implementation class to which the built-in method belongs and the invocation operation information of the built-in method, and the invocation operation information includes the method identifier and operation of the built-in method. Parameters and return value types.
相应的,本应用程序响应接口创建请求时,依据该请求指定的接口标识,查询所述类表信息确定对应的实现类,以为其创建该实现类的实例对象;Correspondingly, when the application program responds to an interface creation request, it queries the class table information to determine the corresponding implementation class according to the interface identifier specified by the request, so as to create an instance object of the implementation class for it;
本应用程序响应接口调用请求时,依据该请求提供的属性信息,通过查询所述方法表信息确定所述的内建方法以调用之。When this application program responds to an interface call request, according to the attribute information provided by the request, the built-in method is determined by querying the method table information to call it.
一些实施例中,本应用程序的服务组件并行地与多个所述的客户进程进行绑定,本应用程序适于启动其中的一个或多个所述的客户进程。In some embodiments, the service component of the application program is bound to multiple client processes in parallel, and the application program is suitable for starting one or more of the client processes.
较佳的,本应用程序与客户进程所属程序之间遵守预约定的协议,采用第一格式封装和解封装所述的属性信息,采用第二格式封装和解封装所述的结果数据。Preferably, the application program and the program to which the client process belongs shall comply with a predetermined agreement, the attribute information is encapsulated and unencapsulated in the first format, and the result data is encapsulated and unencapsulated in the second format.
进一步,本应用程序在内存中的表现与客户进程之间依据彼此的协议建构有功能相对应的功能模块,均包括有解析模块和收发模块,其中,解析模块负责执行所述第一格式和第二格式相关的功能实现,所述收发模块用于执行所述第一格式和第二格式相关的通信传输。Further, the performance of the application in the memory and the client process construct functional modules corresponding to the functions according to mutual agreements, both of which include a parsing module and a transceiver module, wherein the parsing module is responsible for executing the first format and the first format. The functions related to the second format are realized, and the transceiver module is used to perform communication transmission related to the first format and the second format.
较佳的,本应用程序建构一接口管理模块,用于统一执行客户进程和本应用程序自身对所述接口库的访问。Preferably, the application program constructs an interface management module for uniformly executing the client process and the application program's own access to the interface library.
进一步,客户进程负责维护与服务进程的通信状态,以确保客户进程与服务进程之间跨进程通信的稳定性。Further, the client process is responsible for maintaining the communication state with the service process to ensure the stability of the cross-process communication between the client process and the service process.
部分实施例中,本方法还包括如下步骤:In some embodiments, the method further includes the following steps:
在客户进程与本应用程序的服务组件解除绑定后,清除由所述客户进程调用产生的实例表信息。After the client process is unbound with the service component of the application, the instance table information generated by the call of the client process is cleared.
为满足本发明的其他目的,本发明提供的一种终端设备,包括中央处理器和存储器,所述中央处理器用于调用运行存储于所述存储器中的计算机程序以执行如前一目的所述的应用程序接口调用控制方法的步骤。In order to meet other objectives of the present invention, a terminal device provided by the present invention includes a central processing unit and a memory, and the central processing unit is used to call and run a computer program stored in the memory to execute the above-mentioned The application program interface calls the steps of the control method.
相对于现有技术,本发明具备如下优点:Compared with the prior art, the present invention has the following advantages:
首先,本发明的方法,利用接口库存储和管理应用程序的实现类,在本应用程序运行时预先向接口库中注册其内建的实现类,后供客户进程调用,这一过程中,通过接口标识关联起客户进程的接口类和本应用程序的实现类以及实现类的实例对象、代理对象等内存资源,对进程与进程之间的调用起到集中调度和管控的作用,使得本应用程序(表现为服务进程)与客户进程之间的接口调用更为灵活高效。对于类的方法层面,接口库也为其配置了存储和管理机制,使得实例对象的内建方法运行所需的相关属性信息均可通过查询接口库实现跨进程互通,由此,客户进程通过其代理对象便可实现对服务进程的实例对象的内建方法进行传参和调用。所以,接口库及其协议解析机制的设置,使跨进程高效通信成为可能。First of all, the method of the present invention uses the interface library to store and manage the implementation classes of the application program, and register its built-in implementation classes in the interface library in advance when the application program is running, and then be called by the client process. In this process, through The interface identifier is associated with the interface class of the client process and the implementation class of the application, as well as the memory resources such as instance objects and proxy objects of the implementation class. It plays a role in centralized scheduling and management of calls between processes, making the application (Expressed as a service process) The interface call between the client process is more flexible and efficient. For the method level of the class, the interface library also configures storage and management mechanisms for it, so that the relevant attribute information required for the operation of the built-in method of the instance object can be interoperated across processes by querying the interface library. Therefore, the client process can communicate with each other through its The proxy object can pass parameters and call the built-in methods of the instance object of the service process. Therefore, the setting of the interface library and its protocol analysis mechanism makes it possible to communicate efficiently across processes.
其次,跨进程通信效率的提高,体现到开发过程中,尤其是在Android操作系统的开发过程中,便可大大提高程序开发效率。在Android中,本发明的实现,使得不同进程之间调用接口时,不必基于AIDL每次针对新的接口又执行完全一致的接口配置流程,也就是说,本发明简化了Android系统中新增跨进程通信接口的开发步骤,在本发明的基础上,开发人员只需针对跨进程通信接口,创建API接口类及其实现类即可,而不必重复其他公知步骤,后续运行本发明的方法实现的程序时,API接口便会被注册到接口库中,其他公知步骤对应的功能均由本发明的方法以程序进程的方式自动去实现。所以,当实现了本发明的应用程序被升级后,若升级版本中增删了相关的跨进程通信接口,便会体现为接口库的接口注册信息的变动。可见,本发明可大大提升程序开发效率,有助于释放开发能力,从而 综合降低项目开发成本。Secondly, the improvement of cross-process communication efficiency is reflected in the development process, especially in the development process of the Android operating system, which can greatly improve the efficiency of program development. In Android, the implementation of the present invention makes it unnecessary to perform a completely consistent interface configuration process for a new interface based on AIDL when calling interfaces between different processes. For the development steps of the process communication interface, on the basis of the present invention, developers only need to create an API interface class and its implementation class for the cross-process communication interface, instead of repeating other well-known steps. During the program, the API interface will be registered in the interface library, and the functions corresponding to other known steps are automatically implemented by the method of the present invention in a program process. Therefore, after the application that implements the present invention is upgraded, if the relevant cross-process communication interface is added or deleted in the upgraded version, it will be reflected in the change of the interface registration information of the interface library. It can be seen that the present invention can greatly improve the efficiency of program development, help release development capabilities, and comprehensively reduce project development costs.
再者,本发明的服务进程由于配备了服务组件,其接口调用机制便可并行地为多个客户进程提供服务,无论这些客户进程是属于本应用程序还是其他应用程序,这就为一些联合开发的项目例如登录模块、授权模块、支付模块、过滤模块等提供了便利的技术实现基础。无论是本应用程序还是不同应用程序的客户进程,只要其遵守本发明的方法所规范的协议,也就具备与本发明的应用程序实现交互的能力,从而便可实现与本应用程序的资源的相互调用,与本应用程序所表现的服务进程共享内存资源。这一基础技术,也有利于确保维持服务进程或客户进程在内存中的存活,相互之间通过服务组件进行绑定的机制,调度实现类接口的活动,使进程间互相唤醒成为可能,确保了各进程在内存中的活跃性,而避免各进程在内存清理过程中被结束,甚至可以通过其中一个进程重新启动另一进程,使这些进程始终在系统中运行。Furthermore, because the service process of the present invention is equipped with service components, its interface calling mechanism can provide services for multiple client processes in parallel, regardless of whether these client processes belong to this application or other applications, which is a joint development Projects such as login module, authorization module, payment module, filter module, etc. provide a convenient basis for technical implementation. Whether it is the application program or the client process of a different application program, as long as it complies with the protocol regulated by the method of the present invention, it also has the ability to interact with the application program of the present invention, so as to realize the resource connection with the application program. Call each other and share memory resources with the service process represented by this application. This basic technology is also conducive to ensuring the survival of service processes or client processes in memory, the mechanism of binding each other through service components, scheduling activities that implement class interfaces, and making it possible for processes to wake up each other, ensuring The activity of each process in the memory, to prevent each process from being terminated during the memory cleaning process, and even one process can be used to restart another process, so that these processes are always running in the system.
进而,服务进程实现了接口集中维护和服务的能力,而客户进程可以简化开发,一个或多个客户进程,无论这些进程是属于同一应用程序还是不同程序,均可由服务进程提供接口服务,这对于集中实现一些核心功能的联合开发项目相关的终端程序而言或者对于一些需要扩展插件的场景而言,更能体现其高效的效果。Furthermore, the service process realizes the ability of centralized maintenance and service of the interface, and the client process can simplify the development. One or more client processes, regardless of whether these processes belong to the same application or different programs, can be provided by the service process to provide interface services. For terminal programs related to joint development projects that focus on realizing some core functions, or for scenarios that require extended plug-ins, it is more efficient.
此外,本发明在服务进程与客户进程之间针对中间过程数据采用了协议解析机制,具体是在调用层面采用第一格式,在结果层面采用第二格式,两种格式并行不悖,便于由本领域技术人员开发些功能集中的解析模块配置到客户进程和服务进程中,便于对不同格式相对应的解析和封装功能进行模块化开发,进一步在提高开发效率的同时,确保不同进程间通信的安全性。In addition, the present invention adopts a protocol analysis mechanism for the intermediate process data between the service process and the client process. Specifically, the first format is adopted at the call level and the second format is adopted at the result level. Develop some analysis modules with concentrated functions and configure them in the client process and service process, so as to facilitate the modular development of the analysis and packaging functions corresponding to different formats, and further improve the development efficiency while ensuring the security of communication between different processes.
本发明附加的方面和优点将在下面的描述中部分给出,这些将从下面的描述中变得明显,或通过本发明的实践了解到。The additional aspects and advantages of the present invention will be partly given in the following description, which will become obvious from the following description, or be understood through the practice of the present invention.
附图说明Description of the drawings
本发明上述的和/或附加的方面和优点从下面结合附图对实施例的描述中将变得明显和容易理解,其中:The above and/or additional aspects and advantages of the present invention will become obvious and easy to understand from the following description of the embodiments in conjunction with the accompanying drawings, in which:
图1为本发明据以实现的原理中的客户进程与服务进程实现架构示意图;FIG. 1 is a schematic diagram of the realization structure of the client process and the service process in the principle on which the present invention is implemented;
图2为本发明一种典型实施例中的应用程序接口调用控制方法的流程示意图;FIG. 2 is a schematic flowchart of an application program interface calling control method in a typical embodiment of the present invention;
图3为本发明一种典型实施例中跨进程通信方法的流程示意图;FIG. 3 is a schematic flowchart of a cross-process communication method in a typical embodiment of the present invention;
图4为本发明的跨进程通信方法中步骤S23的具体步骤流程示意图。Fig. 4 is a schematic flow diagram of specific steps of step S23 in the cross-process communication method of the present invention.
具体实施方式Detailed ways
下面详细描述本发明的实施例,所述实施例的示例在附图中示出,其中自始至终相同或类似的标号表示相同或类似的元件或具有相同或类似功能的元件。下面通过参考附图描述的实施例是示例性的,仅用于解释本发明,而不能解释为对本发明的限制。The embodiments of the present invention are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals indicate the same or similar elements or elements with the same or similar functions. The embodiments described below with reference to the drawings are exemplary, and are only used to explain the present invention, but cannot be construed as limiting the present invention.
本技术领域技术人员可以理解,除非特意声明,这里使用的单数形式“一”、“一个”、“所述”和“该”也可包括复数形式。应该进一步理解的是,本发明的说明书中使用的措辞“包括”是指存在所述特征、整数、步骤、操作、元件和/或组件,但是并不排除存在或添加一个或多个其他特征、整数、步骤、操作、元件、组件和/或它们的组。应该理解,当我们称元件被“连接”或“耦接”到另一元件时,它可以直接连接或耦接到其他元件,或者也可以存在中间元件。此外,这里使用的“连接”或“耦接”可以包括无线连接或无线耦接。这里使用的措辞“和/或”包括一个或更多个相关联的列出项的全部或任一单元和全部组合。Those skilled in the art can understand that, unless specifically stated, the singular forms "a", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the described features, integers, steps, operations, elements and/or components, but does not exclude the presence or addition of one or more other features, Integers, steps, operations, elements, components, and/or groups of them. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element, or intervening elements may also be present. In addition, “connected” or “coupled” used herein may include wireless connection or wireless coupling. The term "and/or" as used herein includes all or any unit and all combinations of one or more associated listed items.
本技术领域技术人员可以理解,除非另外定义,这里使用的所有术语(包括技术术语和科学术语),具有与本发明所属领域中的普通技术人员的一般理解相同的意义。还应该理解的是,诸如通用字典中定义的那些术语,应该被理解为具有与现有技术的上下文中的意义一致的意义,并且除非像这里一样被特定定义,否则不会用理想化或过于正式的含义来解释。Those skilled in the art can understand that, unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as those commonly understood by those of ordinary skill in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have a meaning consistent with the meaning in the context of the prior art, and unless specifically defined as here, they will not be idealized or overly Explain the formal meaning.
本技术领域技术人员可以理解,这里所使用的“客户端”、“终端”、“终 端设备”既包括无线信号接收器的设备,其仅具备无发射能力的无线信号接收器的设备,又包括接收和发射硬件的设备,其具有能够在双向通信链路上,进行双向通信的接收和发射硬件的设备。这种设备可以包括:蜂窝或其他诸如个人计算机、平板电脑之类的通信设备,其具有单线路显示器或多线路显示器或没有多线路显示器的蜂窝或其他通信设备;PCS(Personal Communications Service,个人通信系统),其可以组合语音、数据处理、传真和/或数据通信能力;PDA(Personal Digital Assistant,个人数字助理),其可以包括射频接收器、寻呼机、互联网/内联网访问、网络浏览器、记事本、日历和/或GPS(Global Positioning System,全球定位系统)接收器;常规膝上型和/或掌上型计算机或其他设备,其具有和/或包括射频接收器的常规膝上型和/或掌上型计算机或其他设备。这里所使用的“客户端”、“终端”、“终端设备”可以是便携式、可运输、安装在交通工具(航空、海运和/或陆地)中的,或者适合于和/或配置为在本地运行,和/或以分布形式,运行在地球和/或空间的任何其他位置运行。这里所使用的“客户端”、“终端”、“终端设备”还可以是通信终端、上网终端、音乐/视频播放终端,例如可以是PDA、MID(Mobile Internet Device,移动互联网设备)和/或具有音乐/视频播放功能的移动电话,也可以是智能电视、机顶盒等设备。Those skilled in the art can understand that the "client", "terminal", and "terminal device" used herein include both wireless signal receiver devices, which only have wireless signal receiver devices without transmitting capabilities, and include A device for receiving and transmitting hardware, which has a device capable of receiving and transmitting hardware for two-way communication on a two-way communication link. Such devices may include: cellular or other communication devices such as personal computers, tablet computers, which have single-line displays or multi-line displays or cellular or other communication devices without multi-line displays; PCS (Personal Communications Service, personal communication) System), which can combine voice, data processing, fax and/or data communication capabilities; PDA (Personal Digital Assistant), which can include radio frequency receivers, pagers, Internet/Intranet access, web browsers, and notes Notebook, calendar, and/or GPS (Global Positioning System) receiver; conventional laptop and/or palmtop computer or other equipment, which has and/or includes a conventional laptop and/or radio frequency receiver Palm-size computer or other equipment. The "client", "terminal", and "terminal device" used here may be portable, transportable, installed in vehicles (air, sea and/or land), or suitable and/or configured to be locally Operate, and/or in a distributed form, operate in any other location on the earth and/or space. The "client", "terminal", and "terminal device" used here can also be communication terminals, internet terminals, music/video playback terminals, such as PDA, MID (Mobile Internet Device, mobile Internet device) and/or Mobile phones with music/video playback functions can also be devices such as smart TVs and set-top boxes.
本发明所称的“终端设备”、“移动终端”等名称所指向的硬件,本质上是具备个人计算机等效能力的设备,为具有中央处理器(包括运算器和控制器)、存储器、输入设备以及输出设备等冯诺依曼原理所揭示的必要构件的硬件装置,计算机程序存储于其存储器中,中央处理器将存储在外存中的程序调入内存中运行,执行程序中的指令,与输入输出设备交互,借此完成特定的功能。The hardware referred to by the names "terminal equipment" and "mobile terminal" in the present invention is essentially a device with the equivalent capabilities of a personal computer, which has a central processing unit (including arithmetic unit and controller), memory, and input The hardware devices of the necessary components disclosed by the Von Neumann principle, such as equipment and output devices, have computer programs stored in their memory, and the central processing unit transfers the programs stored in the external memory into the memory to run, executes the instructions in the programs, and The input and output devices interact to complete specific functions.
以下结合附图先揭示本发明的主要实现原理:The main implementation principles of the present invention are first disclosed below in conjunction with the accompanying drawings:
本发明的应用程序以计算机程序的形式运行于诸如手机、平板等移动终端之类的终端设备中,该终端设备运行有Android或前向兼容Android(例如华为公司新近开发的“鸿蒙”——Harmony OS)的操作系统。应用 程序被中央处理器调度入内存中运行,而实现本发明的相关方法。The application program of the present invention runs in the form of a computer program in a terminal device such as a mobile terminal such as a mobile phone, a tablet, etc. The terminal device runs Android or a forward compatible Android (for example, the "Hongmeng" recently developed by Huawei-Harmony OS) operating system. The application program is scheduled to run in the memory by the central processing unit to implement the relevant method of the present invention.
根据操作系统固有的机制,每个应用程序将具体运行于系统的一个虚拟机中。当然,操作系统也支持多进程架构,因此,同一应用程序可以包括多个进程,例如在主进程基础上通过注册服务组件运行其提供服务功能的进程。According to the inherent mechanism of the operating system, each application program will run in a virtual machine of the system. Of course, the operating system also supports a multi-process architecture. Therefore, the same application program may include multiple processes, for example, a process that provides service functions is run by registering a service component on the basis of the main process.
请参阅图1,当本发明实现的相关方法所在应用程序在内存中运行后,在内存中将允许存在与本发明的相关方法相关联的两类进程,一类作为本应用程序的主体的服务进程2,另一类是属于本应用程序或者属于其他应用程序但可以与该服务进程2交互实现接口调用的客户进程1。Please refer to Figure 1. After the application in which the relevant method implemented by the present invention is running in the memory, two types of processes associated with the relevant method of the present invention will be allowed to exist in the memory, one is the service that serves as the main body of the application. Process 2, the other type is client process 1 that belongs to this application or belongs to other applications but can interact with the service process 2 to implement interface calls.
服务进程2与客户进程1之间建立了协议机制,两者预先遵守了相关开发协议,因此,在需要用到数据格式的场景中,包括以特定数据格式封装和解封装(解析),由于两者之间存在这种协议,所以可以互相识别对方封装的数据,从而正确还原对方传输过来的内容。也就是说,客户进程1与服务进程2之间,由一方封装的数据格式,可以被另一方依照预先协议而正确解析。服务进程2与客户进程1之间的协议,定义了两种格式,第一种是请求格式,第二种是结果格式。请求格式用于封装和解封装客户进程1发起的各种请求,涉及的数据主要是客户进程解析接口类注解后获得的接口标识、方法标识(及方法的运行参数、返回值类型等属性信息)、代理对象携带的对象标识等,结果格式则用于封装和解封装服务进程2执行调用产生的各种结果数据,主要是实例化实现类,生成实例对象后为其分配的对象标识、实例对象的内建方法被调用执行后的返回值等。请求格式通常由客户进程1封装而由服务进程2解析,结果数据通常由服务进程2封装而由客户进程1解析。为此,在下文将揭示,客户进程1和服务进程2均将构建专门的功能模块即解析模块13、23用于实施这些数据格式相关的的封装和解封装功能。A protocol mechanism is established between the service process 2 and the client process 1, and the two have complied with the relevant development agreement in advance. Therefore, in scenarios where the data format is required, it includes encapsulation and decapsulation (analysis) in a specific data format. This kind of agreement exists between each other, so the data encapsulated by the other party can be recognized by each other, and the content transmitted by the other party can be restored correctly. That is to say, between the client process 1 and the service process 2, the data format encapsulated by one party can be correctly parsed by the other party in accordance with the pre-agreement. The agreement between service process 2 and client process 1 defines two formats, the first is the request format, and the second is the result format. The request format is used to encapsulate and decapsulate various requests initiated by the client process 1. The data involved is mainly the interface identifier and method identifier (and attribute information such as method operating parameters and return value types) obtained after the client process parses the interface class annotations. The object identifier carried by the proxy object, etc., and the result format is used to encapsulate and decapsulate various result data generated by the execution of the service process 2. The return value after the method is called and executed. The request format is usually encapsulated by the client process 1 and parsed by the service process 2, and the result data is usually encapsulated by the service process 2 and parsed by the client process 1. For this reason, it will be revealed below that both the client process 1 and the service process 2 will construct specialized functional modules, namely, the parsing modules 13, 23 to implement the encapsulation and decapsulation functions related to these data formats.
所述的服务进程2,负责接口的注册并在后续接收客户进程1的接口创建和调用请求,而为客户进程1提供接口创建和调用服务。服务进程2为了维持其服务功能,需要向系统注册一服务组件20,由此实现后台运行。服务进程2主要包括业务模块21、执行模块22、解析模块23、收发模块 24以及所述的服务组件20,并通过启动后执行注册来维护一接口库25,其业务模块21负责接口实现类的所述的注册功能;其服务组件20主要提供给客户进程1进行绑定,以便确保服务进程2和客户进程1之间的通信;其收发模块24一方面负责接收客户进程1的各类请求,另一方面则负责向客户进程1反馈各种结果数据,通过其双向服务功能满足服务进程2与客户进程1之间的通信传输;其解析模块23主要用于解析出客户进程1以第一格式(请求格式)封装的各种请求,以及以第二格式(结果格式)封装各种结果数据以通过其收发模块24发送给客户进程1;其执行模块22主要负责客户进程1请求接口调用时相应实现类的创建及实现类的内建方法的执行功能。The service process 2 is responsible for the registration of the interface and subsequently receives the interface creation and invocation request of the client process 1, and provides the interface creation and invocation service for the client process 1. In order to maintain its service function, the service process 2 needs to register a service component 20 with the system, thereby realizing background operation. The service process 2 mainly includes a business module 21, an execution module 22, a parsing module 23, a transceiver module 24, and the service component 20, and maintains an interface library 25 by performing registration after startup. The business module 21 is responsible for the interface implementation class The registration function; its service component 20 is mainly provided to the client process 1 for binding, so as to ensure the communication between the service process 2 and the client process 1; on the one hand, the transceiver module 24 is responsible for receiving various requests from the client process 1, On the other hand, it is responsible for feeding back various result data to the client process 1, through its two-way service function to meet the communication transmission between the service process 2 and the client process 1. Its analysis module 23 is mainly used to parse out the client process 1 in the first format (Request format) encapsulated various requests, and encapsulate various result data in the second format (result format) to send to the client process 1 through its transceiver module 24; its execution module 22 is mainly responsible for the response when the client process 1 requests an interface call The creation of the realization class and the execution function of the built-in method of the realization class.
所述的客户进程1,主要负责与服务进程2交互,服务于其业务模块11的接口创建和调用需求,维护接口创建和调用的请求过程。客户进程1在其启动后,便寻求与服务进程2的服务组件20的绑定,并且负责维护绑定后的连接状态。如果服务进程2未启动,客户进程1甚至可以负责调用运行服务进程2的服务组件20以方便自身后续调用相关接口。对应服务进程2,客户进程1除了其自身的业务模块11外,同理也构建有与服务进程2相应的收发模块14和解析模块13,其收发模块14一方面负责接收服务进程2的各类结果数据,另一方面则负责向服务进程2发出自身业务模块11发起的各种请求;其解析模块13主要用于从其业务模块11要调用的接口的编程注解中解析出接口标识并以第一格式将之封装成接口创建请求,以及进一步用于从其业务模块11要调用的实现类内建方法的编程注解中解析出属性信息并以第一格式封装成接口调用请求,以便后续由客户进程1的收发模块14将这些请求发送给服务进程2;解析模块13逆向则解析由所述服务进程2传来的各种结果数据,包括接口创建请求、接口调用请求对应的结果数据,以便反馈给客户进程1的业务模块11。The client process 1 is mainly responsible for interacting with the service process 2, serving the interface creation and invocation requirements of its business module 11, and maintaining the request process of interface creation and invocation. After the client process 1 is started, it seeks to bind with the service component 20 of the service process 2, and is responsible for maintaining the bound connection state. If the service process 2 is not started, the client process 1 can even be responsible for calling the service component 20 running the service process 2 to facilitate subsequent calls to related interfaces by itself. Corresponding to service process 2, in addition to its own business module 11, client process 1 also has a transceiver module 14 and analysis module 13 corresponding to service process 2. The transceiver module 14 is responsible for receiving various types of service process 2. The result data, on the other hand, is responsible for issuing various requests initiated by its own business module 11 to the service process 2; its parsing module 13 is mainly used to parse out the interface identifier from the programming annotations of the interface to be called by its business module 11 and use the first One format encapsulates it into an interface creation request, and is further used to parse the attribute information from the programming annotations of the implementation class built-in method to be called by its business module 11 and encapsulate it into an interface call request in the first format, so that it can be followed by the customer The transceiving module 14 of process 1 sends these requests to the service process 2; the parsing module 13 analyzes various result data from the service process 2 in reverse, including the interface creation request and the result data corresponding to the interface call request for feedback Business module 11 for client process 1.
需要说明的是,在Android及其兼容系统中,自身存在着IPC机制,这一机制允许接口跨进程交互。开发时,定义一个Binder类去实现利用AIDL预先定义的接口类,而在实现类中实现功能逻辑。服务进程2的服务组件20运行后,客户进程1与之连接,在onServiceConnected方法中获 取该Binder类的代理对象,通过代理对象调用Binder类的接口方法来获取Binder类提供的功能。同时,客户进程1负责维护其自身与服务组件20之间的连接状态。本发明的实现,也是基于底层的这一机制,而通过本发明的相关步骤来实现对这一机制的有效利用,对此本领域技术人员应可理解。It should be noted that in Android and its compatible systems, there is an IPC mechanism in itself, which allows interfaces to interact across processes. When developing, define a Binder class to realize the interface class defined in advance by AIDL, and realize the functional logic in the realization class. After the service component 20 of the service process 2 runs, the client process 1 connects to it, obtains the proxy object of the Binder class in the onServiceConnected method, and calls the interface method of the Binder class through the proxy object to obtain the functions provided by the Binder class. At the same time, the client process 1 is responsible for maintaining the connection state between itself and the service component 20. The realization of the present invention is also based on this underlying mechanism, and the effective use of this mechanism is realized through the relevant steps of the present invention, which should be understood by those skilled in the art.
本发明所述的接口库3,可以通过构造一个功能上相对独立的接口管理模块来实现统一执行客户进程1和服务进程2对所述接口库3的访问。当然,这是逻辑上的要求,实际上,所述接口管理模块一般可以由服务进程2建构,也可以由服务进程2和客户进程1各自建构自己所需部分功能,其实现方式是灵活的。接口管理模块所维护的接口库3,在逻辑上主要由服务进程2维护,供客户进程1利用,但表现在交互方式,服务进程2和客户进程1均会访问接口库3以便实现相关协议解析机制。The interface library 3 of the present invention can realize the unified execution of the client process 1 and the service process 2 to access the interface library 3 by constructing a functionally relatively independent interface management module. Of course, this is a logical requirement. In fact, the interface management module can generally be constructed by the service process 2, or the service process 2 and the client process 1 can each construct their own required functions, and the implementation method is flexible. The interface library 3 maintained by the interface management module is logically mainly maintained by the service process 2 for use by the client process 1, but in an interactive manner, both the service process 2 and the client process 1 will access the interface library 3 in order to implement relevant protocol analysis mechanism.
如前所述,所述的接口库3,主要用于记录接口相关的相关数据,其表现形式可由本领域技术人员灵活实现。接口库3主要用于存储服务进程2注册形成的接口注册信息,以及在服务进程2与客户进程1交互过程中产生的实例对象相关的接口注册信息。例如,接口注册信息可以构造为下列表格:类表、方法表、实例表。As mentioned above, the interface library 3 is mainly used to record relevant data related to the interface, and its manifestation can be flexibly implemented by those skilled in the art. The interface library 3 is mainly used to store the interface registration information formed by the registration of the service process 2 and the interface registration information related to the instance objects generated during the interaction between the service process 2 and the client process 1. For example, the interface registration information can be constructed as the following tables: class table, method table, and instance table.
所述的类表,用于存储表达类表信息。类表信息用于表征接口的接口标识与实现类、接口类之间对应关系,通过这种对应关系,客户进程1可以依据其业务模块11要调用的接口类而查询确定相关接口标识,服务进程2可以依据解析出的接口标识查询确定相关的实现类,它们之间相互对应,可以唯一性确定。The class table is used to store expression class table information. The class table information is used to characterize the corresponding relationship between the interface identifier of the interface and the implementation class and interface class. Through this corresponding relationship, the client process 1 can query and determine the relevant interface identifier according to the interface class to be called by its business module 11, and the service process 2 The relevant implementation classes can be determined according to the parsed interface identification query, and they correspond to each other and can be uniquely determined.
所述的方法表,用于存储表达方法表信息。方法表信息用于表征实现类与其内建方法之间关系,及该些内建方法的调用运行信息。实现类与其内建方法之间关系的表征,可以通过为方法表信息中的内建方法的调用运行信息建立到接口标识之间的唯一对应关系来实现。所述的调用运行信息,则是服务进程2在注册实现类时,为各个内建方法确定的相关信息,包括分配给该内建方法的方法标识、该方法运行所需的运行参数以及该方法所 定义的返回值类型。本领域技术人员可以理解,当客户进程1将其业务模块11指定的某实现类的内建方法予以明确之后,便可通过查询接口库3中的接口注册信息,具体是查询方法表,获得方法表信息,更明确的是获得该内建方法相关的方法标识。然后,客户进程1合并业务模块11对应该内建方法而提供的运行参数和返回值类型,将这些调用运行信息传输给服务进程2。服务进程2在解析出客户进程1传输过来的调用运行信息之后,获得其中的方法标识,便可依据该方法标识查询接口库25而确定具体的实例对象中的内建方法以便执行之。The method table is used to store expression method table information. The method table information is used to characterize the relationship between the implementation class and its built-in methods, and the call operation information of these built-in methods. The characterization of the relationship between the implementation class and its built-in methods can be achieved by establishing a unique correspondence relationship between the call operation information of the built-in method in the method table information and the interface identifier. The invoking operation information is the relevant information determined by the service process 2 for each built-in method when the implementation class is registered, including the method identifier assigned to the built-in method, the operating parameters required for the operation of the method, and the method The defined return value type. Those skilled in the art can understand that after the client process 1 clarifies the built-in method of a certain implementation class specified by its business module 11, it can query the interface registration information in the interface library 3, specifically the method table, to obtain the method Table information, more clearly, obtain the method ID related to the built-in method. Then, the client process 1 merges the operating parameters and return value types provided by the service module 11 corresponding to the built-in method, and transmits these invocation operating information to the service process 2. After the service process 2 parses out the calling operation information transmitted from the client process 1, and obtains the method identifier therein, it can query the interface library 25 based on the method identifier to determine the built-in method in the specific instance object for execution.
所述的实例表,用于存储表达实例表信息。实例表信息用于表征正在为客户进程1提供服务的实现类实例对象相关的信息,具体而言,可以为每个实例对象赋予一个相应的对象标识,同时使代理对象也携带该标识,这样,进一步将实例对象与所述代理对象建立起关联,通过该对象标识也可确定该实例对象从而加以调用。当然,也可赋予其他直接或间接的标识,甚至进一步关联起相关实现类的接口标识,总之,只要足以确保后续通过代理对象对实例对象的唯一性对应的调用即可。诸如此类,本领域技术人员应可灵活实现。The instance table is used to store the information of the expression instance table. The instance table information is used to characterize the information related to the implementation class instance objects that are providing services for the client process 1. Specifically, each instance object can be assigned a corresponding object identifier, and the proxy object can also carry the identifier. In this way, The instance object is further associated with the proxy object, and the instance object can also be determined through the object identifier to be called. Of course, other direct or indirect identifiers can also be given, and even further associated with the interface identifiers of related implementation classes. In short, as long as it is sufficient to ensure the uniqueness of subsequent calls to the instance object through the proxy object. Those skilled in the art should be able to implement such things flexibly.
接口注册信息是指用于实现本方法的接口创建和调用相关的信息,既包括由服务进程2在其启动时通过解析实现类的编程注解而获得的各类信息,也包括服务进程2运行过程中维护的实例信息。服务进程2的业务模块21将提供服务的API接口的实现类,调用注册服务类的方法,进行注册,注册服务类的方法内部调用接口管理模块接收到注册请求后,获取注册的实现类相关信息,解析类是否根据协议使用相关注解标注了实现类的接口标识,在其存在接口标识时将其存储为接口注册信息以供调用。继而,解析该类的相关内建方法是否使用了本发明的协议的注解,在其使用了规范的注解后将该内建方法相关的接口标识、方法标识、运行参数、返回值类型等作为接口注册信息的一部分存储到所述的方法表中。服务进程2通过这一过程完成了接口的注册,形成所述的接口注册信息的基础数据,为后续跨进程接口调用提供了关键基础。Interface registration information refers to the information related to the creation and invocation of the interface used to implement this method, including all kinds of information obtained by the service process 2 by parsing the programming annotations of the implementation class when it is started, and the running process of the service process 2 Instance information maintained in. The business module 21 of the service process 2 will provide the implementation class of the API interface of the service, call the method of registering the service class to register, and the method of registering the service class internally calls the interface management module. After receiving the registration request, it obtains the relevant information of the registered implementation class. , Whether the parsing class is annotated with the interface identifier of the implementation class according to the use of the protocol, and when there is an interface identifier, it is stored as interface registration information for invocation. Then, analyze whether the related built-in methods of this class use the annotations of the protocol of the present invention, and use the standard annotations related to the built-in method as the interface identification, method identification, operating parameters, return value type, etc. Part of the registration information is stored in the method table. The service process 2 completes the registration of the interface through this process, forms the basic data of the interface registration information, and provides a key foundation for subsequent cross-process interface calls.
在接口注册信息的基础上,客户进程1在实际调用实例对象的内建方法时,是通过该实例对象的代理对象来实现的,因此,客户进程1的代理对象需要调用客户进程1的解析机制,查询接口库3,一般是其中的方法表信息,确定该内建方法对应的接口标识或对象标识及其调用运行信息,构成运行该内建方法所需的属性信息,以便最终提供给服务进程2逆向解析并利用之,确保该实例对象的内建方法能被服务进程2有效调用执行。需要指出的是,属性是否是以接口标识还是对象标识加以指示具体的实例对象,视代理对象的具体实现而定,尽管本发明下述原理揭示了一种利用对象标识来实现的情况,但本领域普通技术人员也应当理解,还可通过该接口标识来起到相同的效果,只要确保其与代理对象、实例对象之间存在一一对应关系并确保各进程彼此协议认可即可。Based on the interface registration information, when the client process 1 actually calls the built-in method of the instance object, it is implemented through the proxy object of the instance object. Therefore, the proxy object of the client process 1 needs to call the analysis mechanism of the client process 1 , Query the interface library 3, generally the method table information in it, determine the interface identifier or object identifier corresponding to the built-in method and its calling operation information, and form the attribute information required to run the built-in method, so as to finally provide it to the service process 2 Reverse analysis and use it to ensure that the built-in method of the instance object can be effectively invoked and executed by the service process 2. It needs to be pointed out that whether the attribute is used to indicate the specific instance object by the interface identifier or the object identifier depends on the specific realization of the proxy object. Although the following principles of the present invention disclose a situation in which the object identifier is used for realization, the original A person of ordinary skill in the art should also understand that the same effect can also be achieved through the interface identification, as long as it is ensured that there is a one-to-one correspondence with the proxy object and the instance object and that each process agrees with each other.
此处所称的代理对象,是利用Java代理技术实现的,本领域技术人员通过Java代理技术可以将服务进程2响应于接口创建请求而创建的相应实现类的所述实例对象在客户进程处映射出相应的代理对象,代理对象是因接口创建请求的响应而产生的,服务进程2在实例对象产生后分配相应的对象标识,将该对象标识提供给客户进程生成代理对象,代理对象也便携带该对象标识。The proxy object referred to here is implemented using Java proxy technology. Those skilled in the art can use Java proxy technology to map the instance object of the corresponding implementation class created by the service process 2 in response to the interface creation request on the client process. The corresponding proxy object. The proxy object is generated by the response of the interface creation request. The service process 2 allocates the corresponding object identifier after the instance object is generated, and provides the object identifier to the client process to generate the proxy object. The proxy object also carries the object. Object ID.
对应于接口创建请求的环节,客户进程1的业务模块11发起对某接口类的请求服务,客户进程1以一请求服务的方法响应之。该请求服务的方法利用解析机制查询接口库3确定该接口类相应的接口标识,将之封装成请求格式数据,传输给服务进程2。服务进程2收到该请求格式数据后进行解析,并利用其中的接口标识查询接口库3中的接口注册信息,确定相应的实现类,创建其实例对象,同时可为该对象生成唯一的对象标识,将对象标识与该对象的对应关系存储为实例表信息,由此后续客户进程1产生的代理对象也自然应携带该对象标识,以便后续代理对象只要将其对象标识传递给服务进程2,服务进程2即可据之唯一性确定相应的实例对象。而客户进程1产生代理对象后,便将其返回给客户进程1的业务模块11做进一步的方法调用。Corresponding to the link of the interface creation request, the business module 11 of the client process 1 initiates a request service for a certain interface class, and the client process 1 responds with a request service method. The method for requesting service uses an analysis mechanism to query the interface library 3 to determine the corresponding interface identifier of the interface class, encapsulate it into request format data, and transmit it to the service process 2. The service process 2 parses the request format data after receiving it, and uses the interface identifier to query the interface registration information in the interface library 3, determines the corresponding implementation class, creates its instance object, and can generate a unique object identifier for the object at the same time , The corresponding relationship between the object identifier and the object is stored as instance table information, so the proxy object generated by the subsequent client process 1 should naturally carry the object identifier, so that the subsequent proxy object only needs to pass its object identifier to the service process 2, and the service Process 2 can determine the corresponding instance object based on its uniqueness. After the client process 1 generates the proxy object, it is returned to the service module 11 of the client process 1 for further method calls.
对应于接口调用请求的环节,客户进程1的业务模块11拿到与其接口 创建请求相对应的代理对象后,进一步发起调用代理对象所指向的实例对象的相关内建方法的接口调用请求。客户进程1响应于该接口调用请求,调用解析机制获得内建方法相关的方法标识、运行参数、返回值类型以及对象标识,以这些信息构成属性信息,进行格式封装后发送给服务进程2。服务进程2调用解析机制解析出属性信息中的各项具体信息,服务进程于是调用执行该内建方法,根据其中的对象标识可以确定要调用的实例对象,根据其中的方法标识可以确定具体的内建方法,然后将相关的运行参数传递给该内建方法,作为其传递参数进行运行,在该内建方法运行后获取符合所述返回值类型的结果。继而,服务进程2便可将相关的结果数据进行第二格式的封装后,返回给客户进程1。客户进程1中的代理对象获得到数据调用解析机制对应解析后即返回给客户进程1的业务模块11,完成对其接口调用请求的响应。Corresponding to the link of the interface call request, the business module 11 of the client process 1 obtains the proxy object corresponding to its interface creation request, and further initiates an interface call request to call the relevant built-in method of the instance object pointed to by the proxy object. In response to the interface call request, the client process 1 invokes the analysis mechanism to obtain the method identifier, operating parameters, return value type, and object identifier related to the built-in method, and uses these information to form attribute information, which is formatted and encapsulated and sent to the service process 2. The service process 2 calls the analysis mechanism to parse out the specific information in the attribute information. The service process then calls and executes the built-in method. According to the object identifier, the instance object to be called can be determined, and the specific internal information can be determined according to the method identifier. Build a method, and then pass related operating parameters to the built-in method, and run as the passed parameters of the built-in method. After the built-in method runs, a result that meets the return value type is obtained. Then, the service process 2 can encapsulate the related result data in the second format and return it to the client process 1. After the proxy object in the client process 1 obtains the corresponding analysis of the data call analysis mechanism, it returns to the service module 11 of the client process 1 to complete the response to its interface call request.
可以看出,无论何种环节,客户进程1与服务进程2之间运用预协议的解析机制进行解析或者封装时,均需配合所述接口库3中的接口注册信息的运用,以便使得相关格式数据具有明确的用途。It can be seen that no matter what the link, when the client process 1 and the service process 2 are parsed or encapsulated using the pre-protocol analysis mechanism, they need to cooperate with the use of the interface registration information in the interface library 3 to make the relevant format The data has a clear purpose.
通常,当客户进程1与服务进程2的服务组件20解除绑定后,还可以执行一个清理内存的步骤,通过执行该步骤,由接口管理模块将接口库3的实例表中的相关对象清理掉。另一方面,出于程序保活的目的,客户进程1与服务进程2之间也可依照预设规则,如定时、根据触发条件等,单向或者相互地启动或者唤醒对方,使双方均能够存活于内存中,避免被操作系统或第三方安全软件的内存清理程序清理掉。Generally, after the client process 1 and the service component 20 of the service process 2 are unbound, a step of clearing memory can also be performed. By performing this step, the interface management module clears the related objects in the instance table of the interface library 3 . On the other hand, for the purpose of program keep-alive, the client process 1 and the service process 2 can also start or wake up each other one-way or each other according to preset rules, such as timing and trigger conditions, so that both parties can Live in the memory, avoid being cleaned up by the operating system or the memory cleaning program of third-party security software.
由以上对本发明的原理的揭示可知,通过客户进程1与服务进程2之间的协议,将AIDL定义跨进程接口的步骤通过接口库3实现复用,可以大幅降低涉及跨进程接口开发的重复开发率,为跨进程通信的高阶应用提供坚实的技术基础。From the above disclosure of the principle of the present invention, it can be seen that through the agreement between the client process 1 and the service process 2, the steps of AIDL defining the cross-process interface are reused through the interface library 3, which can greatly reduce the repetitive development involving cross-process interface development. Rate, providing a solid technical foundation for high-end applications of cross-process communication.
体现在简化开发过程提升开发效率方面,在运用了本发明的原理的应用程序的开发过程中,如果需要扩展跨进程通信接口,只需创建接口类及其对应的实现类即可,为接口类及其对应的实现类重复做底层通信开发。这一变化体现到应用程序的不同应用版本中时,可以知晓,更新后的新版 本应用程序,其服务进程2的业务模块21向接口库3重新注册所有实现类后,接口库3中的接口总数会对应出现增加或减少。如开发人员扩展增加了接口,对应增加了接口类及其实现类,接口库3中的接口总数便相应增加,如果开发人员删除了接口,对应减少了接口类及其实现类,那么,接口库3中的接口总数也就相应减少。总之,无需再利用AIDL做更多重复开发,也体现为避免产生一些不必要的AIDL定义文件。Reflected in simplifying the development process and improving development efficiency, in the development process of an application that uses the principles of the present invention, if it is necessary to extend the cross-process communication interface, only the interface class and its corresponding implementation class need to be created, which is an interface class And its corresponding implementation classes repeat the development of the underlying communication. When this change is reflected in different application versions of the application, it can be known that after the updated new version of the application, the service module 21 of the service process 2 re-registers all implementation classes with the interface library 3, and the interface in the interface library 3 The total will increase or decrease accordingly. If the developer expands the interface and adds the interface class and its implementation class, the total number of interfaces in the interface library 3 will increase accordingly. If the developer deletes the interface, the interface class and its implementation class are correspondingly reduced, then the interface library The total number of interfaces in 3 is reduced accordingly. In short, there is no need to use AIDL for more repetitive development, which is also reflected in the avoidance of unnecessary AIDL definition files.
在理解上述本发明的实现原理的基础上,以下将从本发明实现原理的不同角度考察本发明的各种表现。On the basis of understanding the implementation principle of the present invention described above, the following will examine various performances of the present invention from different perspectives of the implementation principle of the present invention.
请结合图2,在由本发明的原理所表现的应用程序层面,体现为本发明的一种典型实施例。该实施例中,本发明的应用程序接口调用控制方法,以计算机程序的形式实现,而提供本发明的应用程序,该应用程序在操作系统中安装运行后,执行包括如下的步骤:Please refer to FIG. 2, at the level of the application program expressed by the principle of the present invention, it is embodied as a typical embodiment of the present invention. In this embodiment, the application program interface call control method of the present invention is implemented in the form of a computer program, and the application program of the present invention is provided. After the application program is installed and run in the operating system, the execution includes the following steps:
步骤S11,本应用程序在其预注册到操作系统的服务组件20被启动后,通过该服务组件20接受与本应用程序属于同一应用程序或不同应用程序的客户进程1的绑定通信。In step S11, after the service component 20 pre-registered to the operating system of the application is started, the service component 20 accepts the binding communication of the client process 1 belonging to the same application or a different application with the application.
以Android系统为例,本应用程序可以通过在其安装配置文件Androidmanifest.xml文件中声明一个服务组件20,在该服务组件20被系统启动后,本应用程序在内存中发挥服务进程2的作用,可以通过该服务组件20与其他客户进程1实现通信交互。所述的客户进程1既可以是本应用程序的例如服务组件所在的进程,也可以是其他应用程序,特别是一些约定了协议方案的联合开发项目的应用程序运行时所表现的客户进程1。Taking the Android system as an example, this application can declare a service component 20 in its installation configuration file Androidmanifest.xml file. After the service component 20 is started by the system, the application will play the role of service process 2 in the memory. The service component 20 can communicate and interact with other client processes 1. The client process 1 can be either the process where the service component of the application is located, or other applications, especially the client process 1 that is displayed when the application is running for some joint development projects that have agreed on a protocol scheme.
根据Android操作系统的原理,一般而言,一个应用程序相关的进程将运行于一个独立的虚拟机中,但也允许存在同一应用程序中实现多进程架构,例如本应用程序就可以通过声明服务组件的方式,实现多进程架构。由此,可以理解,客户进程1与服务进程2可以并行地运行在同一虚拟机或不同虚拟机中,当客户进程1不属于本应用程序时,意味着客户进程1与服务进程2属于不同的内存虚拟机,但由于本发明的实现,使得它们之 间的接口调用相关的开发变得更为简便。According to the principles of the Android operating system, generally speaking, an application-related process will run in an independent virtual machine, but it is also allowed to exist in the same application to implement a multi-process architecture. For example, this application can declare service components The way to achieve multi-process architecture. From this, it can be understood that client process 1 and service process 2 can run in the same virtual machine or different virtual machines in parallel. When client process 1 does not belong to this application, it means that client process 1 and service process 2 belong to different Memory virtual machine, but due to the realization of the present invention, the development of the interface call between them becomes more convenient.
服务组件20被启动后,客户进程1便可与之绑定。根据本发明的上述原理,客户进程1后续还要负责维护其与该服务组件之间的连接状态,以确定客户进程1与本应用程序之间的稳定连接。在客户进程1与服务进程2实现绑定的基础上,后续方能进一步完成接口调用相关的功能。After the service component 20 is started, the client process 1 can be bound to it. According to the above-mentioned principle of the present invention, the client process 1 is also responsible for maintaining the connection state between it and the service component in order to determine the stable connection between the client process 1 and the application. After the client process 1 and the service process 2 are bound, the subsequent functions related to the interface call can be further completed.
步骤S12,本应用程序响应于所述客户进程1基于调用接口类而发起的接口创建请求,创建与该接口类相应的实现类的实例对象;所述实现类相应的接口注册信息被本应用程序预先注册到接口库3中,其与所述接口类一一对应设置。Step S12: In response to the interface creation request initiated by the client process 1 based on calling the interface class, the application creates an instance object of the implementation class corresponding to the interface class; the interface registration information corresponding to the implementation class is used by the application It is registered in the interface library 3 in advance, and is set in a one-to-one correspondence with the interface class.
如前所述,本发明的客户进程1根据其自身业务模块11使用相关接口的需要,将向本应用程序发起接口创建请求。As mentioned above, the client process 1 of the present invention will initiate an interface creation request to the application according to the needs of its own business module 11 to use related interfaces.
在客户进程1内部,其业务模块11运行到定义或者调用相关接口类的指令时,会发生接口调用,在此处业务模块11首先需要系统为之创建相关接口。客户进程1进而根据预协议的解析机制,也即调用其解析模块13,查询接口库3中的类表信息,根据类表信息确定与需创建的接口唯一对应的接口标识,采用第一格式对查询结果进行封装,封装成请求格式数据,发送给本应用程序。In the client process 1, when its service module 11 runs to define or call an instruction of a related interface class, an interface call will occur. Here, the service module 11 first needs the system to create a related interface for it. The client process 1 then inquires the class table information in the interface library 3 according to the pre-protocol parsing mechanism, that is, calls its parsing module 13, and determines the interface identifier uniquely corresponding to the interface to be created based on the class table information, and uses the first format to pair The query result is encapsulated, encapsulated into the requested format data, and sent to the application.
因此,本应用程序的服务进程2的收发模块24会通过服务组件接收到该请求并交给解析模块23进行解析,解析模块23得以解封装该请求格式数据获得接口标识,然后调用其执行模块22,执行模块22依据所述接口标识从接口库3的类表信息中确定对应的实现类后,执行创建该实现类的实例对象。如前所述,本应用程序已经预先向接口库3中注册了与该实现类相关的接口注册信息,依据实现类与接口标识之间的对应关系,可以避免错误调用实现类。Therefore, the transceiver module 24 of the service process 2 of this application will receive the request through the service component and pass it to the parsing module 23 for parsing. The parsing module 23 can decapsulate the request format data to obtain the interface identifier, and then call its execution module 22 After determining the corresponding implementation class from the class table information of the interface library 3 according to the interface identifier, the execution module 22 executes the creation of an instance object of the implementation class. As mentioned above, this application has pre-registered the interface registration information related to the implementation class in the interface library 3. According to the corresponding relationship between the implementation class and the interface identifier, it is possible to avoid incorrectly calling the implementation class.
实例对象被创建后,被赋予具有唯一性特征的对象标识,对象标识与实例对象的这种一一对应关系,也会被本应用程序更新到接口库3中,并且该对象标识也会被作为结果数据,经由本应用程序的服务进程2的解析模块23以第二格式封装成结果格式数据,然后经收发模块24反馈给客户进程1。客户进程1的收发模块14收到该结果格式数据后,交给客户进程 1的解析模块13解析出对象标识,然后利用Java代理技术创建所述实例对象的代理对象,该代理对象自然携带该对象标识。由此,当客户进程1的业务模块11要通过代理对象发起对实例对象的调用时,代理对象便可凭其自身的对象标识与服务进程2沟通,使得服务进程2能够正确调用相关实例对象。After the instance object is created, it is given an object identifier with unique characteristics. The one-to-one correspondence between the object identifier and the instance object will also be updated to the interface library 3 by this application, and the object identifier will also be used as The result data is encapsulated into result format data in the second format by the parsing module 23 of the service process 2 of this application, and then fed back to the client process 1 via the transceiver module 24. After receiving the result format data, the transceiving module 14 of the client process 1 passes it to the parsing module 13 of the client process 1 to parse the object identification, and then uses Java proxy technology to create a proxy object of the instance object, which naturally carries the object Logo. Thus, when the service module 11 of the client process 1 initiates a call to the instance object through the proxy object, the proxy object can communicate with the service process 2 based on its own object identifier, so that the service process 2 can correctly call the relevant instance object.
实例对象被创建后,其相关信息被存储到接口库3的实例表中作为实例表信息而提供服务。如果客户进程1与服务进程2的服务组件20解除绑定,这些实例表信息便会成为残存的冗余信息,因此,可以设置一个并行的步骤,来实施对这些冗余信息的清理,具体是在客户进程1与服务进程2解除绑定后,删除接口库3中的这些冗余信息。这一步骤理论上可实现在服务进程2中以便能够集中管理内存,也可设置在客户进程1中,由客户进程1在其自身确定解除绑定之前实施之。After the instance object is created, its related information is stored in the instance table of the interface library 3 as the instance table information to provide services. If the client process 1 and the service component 20 of the service process 2 are unbound, the instance table information will become the remaining redundant information. Therefore, a parallel step can be set up to implement the cleanup of the redundant information, specifically After the client process 1 and the service process 2 are unbound, the redundant information in the interface library 3 is deleted. This step can theoretically be implemented in the service process 2 in order to centrally manage the memory, or it can be set in the client process 1, which is implemented by the client process 1 before it determines to unbind.
在成功创造所述实例对象的基础上,本应用程序便可进一步为客户进程1提供对该实例对象的内建方法的调用服务。On the basis of successfully creating the instance object, the application program can further provide the client process 1 with a call service for the built-in method of the instance object.
步骤S13,本应用程序响应于所述客户进程1发起的关于调用该实例对象的内建方法的接口调用请求,该请求中包含依据所述接口库3的接口注册信息确定的用于执行该内建方法的属性信息,依据所述属性信息调用执行该实例对象的内建方法以产生结果数据反馈给客户进程1。Step S13: The application program responds to the interface call request for calling the built-in method of the instance object initiated by the client process 1, and the request includes the interface registration information determined according to the interface library 3 for executing the internal method. According to the attribute information of the method, the built-in method of the instance object is invoked and executed according to the attribute information to generate result data and fed back to the client process 1.
客户进程1成功建立所述实例对象的代理对象后,返回给其业务模块11做进一步的调用。客户进程1的业务模块11继而将通过该代理对象发起对所述实例对象的某个内建方法的接口调用请求。参照前述关于本发明的原理的揭示,一旦业务模块11发起这样的请求,代理对象便可结合查询接口库3中的方法表信息而获得的调用运行信息,将其自身携带的对象标识、该内建方法的方法标识、业务模块11传递的该内建方法的运行参数(数据),以及该内建方法的返回值类型等属性信息,调用解析模块13封装成请求格式的接口调用请求后,经收发模块14发送给所述的本应用程序。After the client process 1 successfully establishes the proxy object of the instance object, it returns to its service module 11 for further calls. The service module 11 of the client process 1 will then initiate an interface call request to a built-in method of the instance object through the proxy object. With reference to the foregoing disclosure of the principle of the present invention, once the business module 11 initiates such a request, the proxy object can combine the calling operation information obtained by querying the method table information in the interface library 3, and combine the object identifier carried by itself, the internal After the method identification of the built-in method, the operating parameters (data) of the built-in method passed by the business module 11, and the return value type of the built-in method and other attribute information, the parsing module 13 is encapsulated into the interface call request in the requested format, The transceiver module 14 sends to the application program.
本应用程序的收发模块24收到代理对象传输的接口调用请求,调用解析模块23解析出其中的属性信息后,调用执行模块22执行对内建方法的调用。执行模块22查询接口库3,依据属性信息中的对象标识可以从实例 表中确定对应的实例对象,而依据所述的方法标识则可以从方法表中确定对应的实例对象的内建方法,然后将属性信息中的运行参数数据传参给目标实例对象中的目标内建方法,调用执行之,使目标内建方法返回符合所述返回值类型规范的结果数据。运行该内建方法获得的结果数据被本应用程序的解析模块23封装成结果格式后回传给客户进程1的代理对象,代理对象则逆向将之解析出结果数据后,向业务模块11返回,业务模块11于是获得了调用接口类对应的实现类所生成的实例对象的内建方法的调用运行结果,完成接口调用全过程。The transceiver module 24 of the application program receives the interface call request transmitted by the proxy object, calls the analysis module 23 to analyze the attribute information therein, and then calls the execution module 22 to execute the call to the built-in method. The execution module 22 queries the interface library 3, the corresponding instance object can be determined from the instance table according to the object identifier in the attribute information, and the built-in method of the corresponding instance object can be determined from the method table according to the method identifier, and then Pass the operating parameter data in the attribute information to the target built-in method in the target instance object, call and execute it, so that the target built-in method returns result data that meets the return value type specification. The result data obtained by running the built-in method is encapsulated by the parsing module 23 of the application program into a result format and then sent back to the proxy object of the client process 1. The proxy object parses the result data in reverse and returns it to the business module 11. The service module 11 then obtains the invoking operation result of the built-in method of the instance object generated by the implementation class corresponding to the invoking interface class, and completes the entire process of invoking the interface.
在某些实施例中,所述返回值类型不必作为属性信息加入,一方面可以考虑不必在接口库3的方法表信息中记录该项,另一方面则不必在客户进程1、服务进程2交互过程中使用该项,本领域技术人员应当知晓此一变通。In some embodiments, the return value type does not need to be added as attribute information. On the one hand, it is not necessary to record the item in the method table information of the interface library 3, and on the other hand, there is no need to interact with the client process 1 and the service process 2. If this item is used in the process, those skilled in the art should be aware of this alternative.
在某些实施例中,如前所述,本应用程序可以独立构建一接口管理模块来集中管理对所述接口库3的访问,向需要访问接口库3的模块提供调用接口供调用执行即可,如此可提升内存效率。In some embodiments, as mentioned above, this application can independently build an interface management module to centrally manage access to the interface library 3, and provide a calling interface for the modules that need to access the interface library 3 for call execution. , This can improve memory efficiency.
本典型实施例的实现,有助于在应用程序层面提供具有跨进程服务机能的应用程序,方便其他应用程序接入,从而方便联合程序项目的开发。The implementation of this exemplary embodiment helps to provide an application program with a cross-process service function at the application program level, and facilitates the access of other applications, thereby facilitating the development of joint program projects.
进一步将这一典型实施例所体现的应用程序安装于移动终端、平板之类的移动设备后,可体现为本发明的另一实施例,该实施例体现为本发明提供的一种终端设备,包括中央处理器和存储器,所述中央处理器用于调用运行存储于所述存储器中的计算机程序以执行如前所述的应用程序接口调用控制方法的各个具体步骤。Further, after the application program embodied in this exemplary embodiment is installed on a mobile device such as a mobile terminal or a tablet, it can be embodied as another embodiment of the present invention, and this embodiment is embodied as a terminal device provided by the present invention. It includes a central processing unit and a memory, and the central processing unit is used to call and run a computer program stored in the memory to execute each specific step of the application program interface call control method as described above.
请结合图3,在由本发明的原理所表现的进程层面,体现为本发明的另一种典型实施例。在该实施例中,本发明的一种跨进程通信方法,包括如下步骤:Please refer to FIG. 3, at the process level expressed by the principle of the present invention, it is embodied as another typical embodiment of the present invention. In this embodiment, a cross-process communication method of the present invention includes the following steps:
步骤S21,客户进程1根据其业务模块11对接口类的调用,查询由服务进程2预先注册了接口注册信息的接口库3获得该接口类的接口标识,按照预协议的请求格式进行封装,向服务进程2发起接口创建请求。In step S21, the client process 1 queries the interface library 3 pre-registered with the interface registration information by the service process 2 to obtain the interface identifier of the interface class according to the invocation of the interface class by its service module 11, and encapsulates the interface class according to the pre-protocol request format. Service process 2 initiates an interface creation request.
如本发明的原理及其他实施例所述,接口库3已经被服务进程2预先配置,服务进程2已经向接口库3注册了类表信息和方法表信息,并且在与客户进程1交互过程中还会更新维护实例表信息,因此,客户进程1可以在本步骤中直接利用接口库3的接口注册信息。此外,客户进程1和服务进程2也按照本发明的原理实现了其各自内部的各个功能模块。As described in the principle of the present invention and other embodiments, the interface library 3 has been pre-configured by the service process 2, and the service process 2 has registered class table information and method table information with the interface library 3, and is in the process of interacting with the client process 1. The information of the maintenance instance table is also updated. Therefore, the client process 1 can directly use the interface registration information of the interface library 3 in this step. In addition, the client process 1 and the service process 2 also implement their respective internal functional modules according to the principles of the present invention.
客户进程1的业务模块11首先发起针对某个特定接口类的调用,客户进程1根据对该接口类的调用,由其解析模块13查询所述的接口库3的接口注册信息,具体是通过接口库3中的类表,查询获得与该接口类相对应的接口标识。然后,解析模块13遵守与服务进程2的协议,将接口标识封装为请求格式,构成接口创建请求,经客户进程1的收发模块14发送给服务进程2。The business module 11 of the client process 1 first initiates a call to a specific interface class. According to the call to the interface class, the client process 1 uses its parsing module 13 to query the interface registration information of the interface library 3, specifically through the interface The class table in library 3 is queried to obtain the interface identifier corresponding to the interface class. Then, the parsing module 13 complies with the agreement with the service process 2 and encapsulates the interface identifier into a request format to form an interface creation request, which is sent to the service process 2 via the transceiver module 14 of the client process 1.
步骤S22,服务进程2接收该接口创建请求,解析该请求,利用其中的接口标识执行对应的实现类的创建操作,产生该实现类的实例对象,逆向以预协议的结果格式封装后向客户进程1反馈该创建操作产生的结果数据;Step S22, the service process 2 receives the interface creation request, parses the request, uses the interface identifier therein to execute the creation operation of the corresponding implementation class, generates an instance object of the implementation class, and reversely encapsulates the backward client process in the pre-contracted result format 1 Feedback the result data generated by the creation operation;
服务进程2经其收发模块24接收到该接口创建请求后,由其解析模块23解析出其中的接口标识,然后,由其执行模块22向接口库3查询确定与该接口标识相对应的实现类之后,执行创建该实现类的实例对象的动作。After the service process 2 receives the interface creation request via its transceiver module 24, its parsing module 23 parses out the interface identifier therein, and then its execution module 22 queries the interface library 3 to determine the implementation class corresponding to the interface identifier After that, the action of creating an instance object of the implementation class is performed.
该实现对象获得创建之后,为该实例对象分配一对象标识,该对象标识可供客户进程1使用。服务进程2构建实例对象之后,便将该实例对象的对象标识按照预协议的第二格式封装成结果数据,通过其收发模块24返回给客户进程1。After the implementation object is created, an object identifier is assigned to the instance object, and the object identifier can be used by the client process 1. After the service process 2 constructs the instance object, it encapsulates the object identifier of the instance object into the result data according to the second format of the pre-protocol, and returns it to the client process 1 through its transceiver module 24.
步骤S23,客户进程1接收所述结果数据,按照协议解析成所述实例对象的代理对象,将之返回给客户进程1的业务模块11,以供所述业务模块11通过调用所述代理对象而实现调用所述实例对象。In step S23, the client process 1 receives the result data, parses it into a proxy object of the instance object according to the protocol, and returns it to the business module 11 of the client process 1, so that the business module 11 can call the proxy object. Implement calling the instance object.
客户进程1经其收发模块14接收到所述的结果数据之后,便交由其解析模块13解析出其中的对象标识,利用Java代理技术构建出该对象标识所指向的实例对象的代理对象,该代理对象携带该对象标识,进而将该代理对象返回给客户进程1的业务模块11做下一步的方法调用,业务模块 11通过调用所述的代理对象,便可实现对所述实例对象的调用。After the client process 1 receives the result data through its transceiving module 14, it will be handed over to its parsing module 13 to parse out the object identifier therein, and use Java proxy technology to construct a proxy object for the instance object pointed to by the object identifier. The proxy object carries the object identifier, and then returns the proxy object to the service module 11 of the client process 1 for the next method call. The service module 11 can call the instance object by calling the proxy object.
请结合图4,除遵照本领域技术人员可以理解的方式,实现业务模块11利用代理对象实现对其相应的实例对象的调用外,在进一步优化的实施例中,客户进程1可以按照如下具体步骤与服务进程2配合调用代理对象,进一步实现对其所指向的实例对象的内建方法的调用:Please refer to Figure 4, in addition to following a method that can be understood by those skilled in the art, the business module 11 uses proxy objects to implement calls to its corresponding instance objects. In a further optimized embodiment, the client process 1 can follow the following specific steps Cooperate with service process 2 to call the proxy object to further implement the call to the built-in method of the instance object it points to:
步骤S231,客户进程1的业务模块11发起调用所述代理对象的方法的接口调用请求。In step S231, the service module 11 of the client process 1 initiates an interface call request for calling the method of the proxy object.
客户进程1的业务模块11需要调用其已经获得对应的代理对象的接口类的内建方法时,便发起所述的接口调用请求,通过调用所述的代理对象,来期待返回的结果,该结果的获取,由代理对象来负责中间过程的执行。When the business module 11 of the client process 1 needs to call the built-in method of the interface class of the corresponding proxy object, it initiates the interface call request, and expects the returned result by calling the proxy object. For the acquisition, the proxy object is responsible for the execution of the intermediate process.
步骤S232,所述代理对象向接口库3查询确定该方法的相应的属性信息,将所述属性信息形成预协议的请求格式后,发送给服务进程2。Step S232: The proxy object queries the interface library 3 to determine the corresponding attribute information of the method, forms the attribute information into a pre-protocol request format, and sends it to the service process 2.
如前所述,代理对象便可结合查询接口库3中的方法表信息而获得的调用运行信息,将其自身携带的对象标识、该内建方法的方法标识、业务模块11传递的该内建方法的运行参数(数据),以及该内建方法的返回值类型等属性信息,调用解析模块13封装成请求格式的接口调用请求后,经收发模块14发送给服务进程2。As mentioned above, the proxy object can combine the calling operation information obtained by querying the method table information in the interface library 3, and combine the object ID it carries, the method ID of the built-in method, and the built-in information passed by the business module 11. The operating parameters (data) of the method and the attribute information such as the return value type of the built-in method are encapsulated by the calling analysis module 13 into an interface calling request in the request format, and then sent to the service process 2 via the transceiver module 14.
步骤S233,服务进程2接收并查询接口库3解析出该属性信息,调用相应的实现类对象执行其中相应的方法。In step S233, the service process 2 receives and queries the interface library 3 to parse out the attribute information, and calls the corresponding implementation class object to execute the corresponding method therein.
服务进程2的收发模块24收到代理对象传输的接口调用请求,调用解析模块23解析出其中的属性信息后,调用执行模块22执行对目标方法的调用。执行模块22查询接口库3,依据属性信息中的对象标识可以从实例表中确定对应的实例对象,而依据所述的方法标识则可以从方法表中确定对应的实例对象的内建方法,然后将属性信息中的运行参数数据传参给目标实例对象中的目标内建方法,调用执行之,使目标方法返回符合所述返回值类型规范的结果数据。The transceiver module 24 of the service process 2 receives the interface call request transmitted by the proxy object, calls the analysis module 23 to analyze the attribute information therein, and then calls the execution module 22 to execute the call to the target method. The execution module 22 queries the interface library 3, the corresponding instance object can be determined from the instance table according to the object identifier in the attribute information, and the built-in method of the corresponding instance object can be determined from the method table according to the method identifier, and then Pass the operating parameter data in the attribute information to the target built-in method in the target instance object, call and execute it, so that the target method returns result data that meets the return value type specification.
步骤S234,服务进程2以预协议的结果格式向客户进程1反馈该方法执行后的结果数据。In step S234, the service process 2 feeds back the result data after the execution of the method to the client process 1 in a pre-agreeed result format.
服务进程2调用运行目标方法获得的结果数据被服务进程2的解析模 块23封装成结果格式后,经由服务进程2的收发模块24回传给客户进程1的代理对象,以供客户进程1内部传递给其业务模块11使用。The result data obtained by the service process 2 calling the running target method is encapsulated into the result format by the parsing module 23 of the service process 2, and then sent back to the proxy object of the client process 1 through the transceiver module 24 of the service process 2 for internal transmission by the client process 1. Used by its business module 11.
步骤S235,客户进程1接收该结果数据,将其解析还原后返回给其业务模块11。In step S235, the client process 1 receives the result data, analyzes and restores it, and returns it to its service module 11.
客户进程1通过其收发模块14接收到服务进程2返回给代理对象的结果数据后,由代理对象调用解析模块13,逆向将之解析出结果数据,把解析出的结果数据直接返回给业务模块11,业务模块11于是获得了调用接口类对应的实现类所生成的实例对象的内建方法的调用运行结果,完成接口调用全过程。After the client process 1 receives the result data returned by the service process 2 to the proxy object through its transceiving module 14, the proxy object calls the parsing module 13 to parse the result data in reverse, and returns the parsed result data directly to the business module 11. Then, the service module 11 obtains the calling operation result of the built-in method of the instance object generated by the implementation class corresponding to the calling interface class, and completes the whole process of calling the interface.
同理,在某些实施例中,所述返回值类型不必作为属性信息加入,一方面可以考虑不必在接口库3的方法表信息中记录该项,另一方面则不必在客户进程1、服务进程2交互过程中使用该项,本领域技术人员应当知晓此一变通。Similarly, in some embodiments, the return value type does not need to be added as attribute information. On the one hand, it is not necessary to record the item in the method table information of the interface library 3, and on the other hand, it does not need to be added in the client process 1. This item is used in the process of process 2 interaction, and those skilled in the art should be aware of this alternative.
本典型实施例的实现,提供了跨进程通信的底层实现方案,使得本发明的原理能够其底层应用,解决了跨进程通信存在的技术障碍。The implementation of this exemplary embodiment provides a bottom-level implementation scheme for cross-process communication, so that the principles of the present invention can be applied to the bottom layer, and solve the technical obstacles in cross-process communication.
同理,进一步将这一典型实施例所体现的应用程序安装于移动终端、平板之类的移动设备后,可体现为本发明的另一实施例,该实施例体现为本发明提供的一种终端设备,包括中央处理器和存储器,所述中央处理器用于调用运行存储于所述存储器中的计算机程序以执行如前所述的跨进程通信方法的步骤。In the same way, after the application program embodied in this exemplary embodiment is further installed on a mobile device such as a mobile terminal or a tablet, it can be embodied as another embodiment of the present invention, and this embodiment is embodied as a method provided by the present invention. The terminal device includes a central processing unit and a memory, and the central processing unit is used to invoke and run a computer program stored in the memory to execute the steps of the aforementioned cross-process communication method.
综上所述,本发明简化了应用程序开发过程中涉及通信接口实现的开发步骤,为联合开发的程序项目提供了更为简便高效的跨进程通信解决方案。In summary, the present invention simplifies the development steps involved in the realization of communication interfaces in the application program development process, and provides a simpler and more efficient cross-process communication solution for jointly developed program projects.
本技术领域技术人员可以理解,本发明包括涉及用于执行本发明中所述操作、方法中的一项或多项的设备。这些设备可以为所需的目的而专门设计和制造,或者也可以包括通用计算机中的已知设备。这些设备具有存储在其存储器之内的计算机程序,这些计算机程序选择性地激活或重构。 这样的计算机程序可以被存储在设备(例如,计算机)可读介质中或者存储在适于存储电子指令并分别耦联到总线的任何类型的介质中,所述计算机可读介质包括但不限于任何类型的盘(包括软盘、硬盘、光盘、CD-ROM、和磁光盘)、ROM(Read-Only Memory,只读存储器)、RAM(Random Access Memory,随即存储器)、EPROM(Erasable Programmable Read-Only Memory,可擦写可编程只读存储器)、EEPROM(Electrically Erasable Programmable Read-Only Memory,电可擦可编程只读存储器)、闪存、磁性卡片或光线卡片。也就是,可读介质包括由设备(例如,计算机)以能够读的形式存储或传输信息的任何介质。Those skilled in the art can understand that the present invention includes equipment for performing one or more of the operations and methods described in the present invention. These devices may be specially designed and manufactured for the required purpose, or may also include known devices in general-purpose computers. These devices have computer programs stored in their memory, which are selectively activated or reconfigured. Such a computer program may be stored in a device (for example, a computer) readable medium or in any type of medium suitable for storing electronic instructions and respectively coupled to a bus. The computer readable medium includes, but is not limited to, any Types of disks (including floppy disks, hard disks, optical disks, CD-ROMs, and magneto-optical disks), ROM (Read-Only Memory), RAM (Random Access Memory), EPROM (Erasable Programmable Read-Only Memory) , Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory, magnetic card or optical card. That is, the readable medium includes any medium that stores or transmits information in a readable form by a device (for example, a computer).
本技术领域技术人员可以理解,可以用计算机程序指令来实现这些结构图和/或框图和/或流图中的每个框以及这些结构图和/或框图和/或流图中的框的组合。本技术领域技术人员可以理解,可以将这些计算机程序指令提供给通用计算机、专业计算机或其他可编程数据处理方法的处理器来实现,从而通过计算机或其他可编程数据处理方法的处理器来执行本发明公开的结构图和/或框图和/或流图的框或多个框中指定的方案。Those skilled in the art can understand that computer program instructions can be used to implement each block in these structural diagrams and/or block diagrams and/or flow diagrams and combinations of blocks in these structural diagrams and/or block diagrams and/or flow diagrams. . Those skilled in the art can understand that these computer program instructions can be provided to processors of general-purpose computers, professional computers, or other programmable data processing methods for implementation, so that the computer or other programmable data processing method processors can execute this The structure diagram and/or block diagram and/or flow diagram of the disclosure of the invention are specified in the block or multiple blocks.
本技术领域技术人员可以理解,本发明中已经讨论过的各种操作、方法、流程中的步骤、措施、方案可以被交替、更改、组合或删除。进一步地,具有本发明中已经讨论过的各种操作、方法、流程中的其他步骤、措施、方案也可以被交替、更改、重排、分解、组合或删除。进一步地,现有技术中的具有与本发明中公开的各种操作、方法、流程中的步骤、措施、方案也可以被交替、更改、重排、分解、组合或删除。Those skilled in the art can understand that the various operations, methods, and steps, measures, and solutions in the process that have been discussed in the present invention can be alternated, changed, combined, or deleted. Further, the various operations, methods, and other steps, measures, and solutions in the process that have been discussed in the present invention can also be alternated, changed, rearranged, decomposed, combined, or deleted. Further, the steps, measures, and schemes in the various operations, methods, and procedures disclosed in the present invention in the prior art can also be alternated, changed, rearranged, decomposed, combined or deleted.
以上所述仅是本发明的部分实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本发明的保护范围。The above are only part of the embodiments of the present invention. It should be pointed out that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and modifications can be made, and these improvements and modifications are also It should be regarded as the protection scope of the present invention.

Claims (12)

  1. 一种应用程序接口调用控制方法,其特征在于,该方法包括如下步骤:An application program interface call control method, characterized in that the method includes the following steps:
    本应用程序在其预注册到操作系统的服务组件被启动后,通过该服务组件接受与本应用程序属于同一应用程序或不同应用程序的客户进程的绑定通信;After the service component pre-registered to the operating system of this application is started, the service component accepts the binding communication with the client process of the same application or a different application through the application;
    本应用程序响应于所述客户进程基于调用接口类而发起的接口创建请求,创建与该接口类相应的实现类的实例对象;所述实现类相应的接口注册信息被本应用程序预先注册到接口库中,其与所述接口类一一对应设置;This application creates an instance object of the implementation class corresponding to the interface class in response to the interface creation request initiated by the client process based on calling the interface class; the interface registration information corresponding to the implementation class is pre-registered to the interface by this application In the library, it is set in a one-to-one correspondence with the interface class;
    本应用程序响应于所述客户进程发起的关于调用该实例对象的内建方法的接口调用请求,该请求中包含依据所述接口库的接口注册信息确定的用于执行该内建方法的属性信息,依据所述属性信息调用执行该实例对象的内建方法以产生结果数据反馈给客户进程。This application responds to an interface call request for invoking the built-in method of the instance object initiated by the client process, and the request includes the attribute information for executing the built-in method determined according to the interface registration information of the interface library , Call and execute the built-in method of the instance object according to the attribute information to generate result data and feed it back to the client process.
  2. 根据权利要求1所述的方法,其特征在于,该方法还包括如下步骤:The method according to claim 1, wherein the method further comprises the following steps:
    执行对本应用程序的版本更新,在更新后的本应用程序运行后,重新执行对所述接口库的注册,使所述接口库中所注册的接口个数增加或减少。Perform a version update of the application program. After the updated application program runs, re-register the interface library to increase or decrease the number of interfaces registered in the interface library.
  3. 根据权利要求1所述的方法,其特征在于,所述的接口库中的接口注册信息包括:The method according to claim 1, wherein the interface registration information in the interface library comprises:
    表征接口的接口标识与实现类、接口类之间对应关系的类表信息,以便依据所述接口标识确定接口类与实现类之间的一一对应关系;Class table information that characterizes the corresponding relationship between the interface identifier of the interface, the implementation class, and the interface class, so as to determine the one-to-one correspondence between the interface class and the implementation class according to the interface identifier;
    表征实现类及其内建方法之间关系及该些内建方法的调用运行信息的方法表信息,以便执行方法调用;Method table information that characterizes the relationship between the implementation class and its built-in methods and the call operation information of these built-in methods, so as to execute method calls;
    表征正在为客户进程提供服务的实现类实例对象及其具有唯一性特征的对象标识之间对应关系的实例表信息,以便实施实例对象的调用。The instance table information that characterizes the correspondence between the implementation class instance objects that are providing services to the client process and the object identifiers with unique characteristics, so as to implement the invocation of the instance objects.
  4. 根据权利要求3所述的方法,其特征在于,所述属性信息包括内建方法所属的实现类对应的接口标识或对象标识和该内建方法的所述调用运行信息,所述调用运行信息包括所述内建方法的方法标识、运行参数、返回值类型。The method according to claim 3, wherein the attribute information includes the interface identifier or object identifier corresponding to the implementation class to which the built-in method belongs and the invocation operation information of the built-in method, and the invocation operation information includes The method identifier, operating parameters, and return value type of the built-in method.
  5. 根据权利要求3或4所述的方法,其特征在于:The method according to claim 3 or 4, characterized in that:
    本应用程序响应接口创建请求时,依据该请求指定的接口标识,查询所述类表信息确定对应的实现类,以为其创建该实现类的实例对象;When this application responds to an interface creation request, it queries the class table information to determine the corresponding implementation class according to the interface identifier specified by the request, so as to create an instance object of the implementation class for it;
    本应用程序响应接口调用请求时,依据该请求提供的属性信息,通过查询所述方法表信息确定所述的内建方法以调用之。When this application program responds to an interface call request, according to the attribute information provided by the request, the built-in method is determined by querying the method table information to call it.
  6. 根据权利要求1所述的方法,其特征在于,本应用程序的服务组件并行地与多个所述的客户进程进行绑定,本应用程序适于启动其中的一个或多个所述的客户进程。The method according to claim 1, wherein the service component of the application program is bound to a plurality of the client processes in parallel, and the application program is suitable for starting one or more of the client processes .
  7. 根据权利要求1所述的方法,其特征在于,本应用程序与客户进程所属程序之间遵守预约定的协议,采用第一格式封装和解封装所述的属性信息,采用第二格式封装和解封装所述的结果数据。The method according to claim 1, wherein the application program and the program to which the client process belongs complies with a predetermined agreement, the attribute information is encapsulated and decapsulated in a first format, and the attribute information is encapsulated and decapsulated in a second format. The result data described.
  8. 根据权利要求7所述的方法,其特征在于,本应用程序在内存中的表现与客户进程之间依据彼此的协议建构有功能相对应的功能模块,均包括有解析模块和收发模块,其中,解析模块负责执行所述第一格式和第二格式相关的功能实现,所述收发模块用于执行所述第一格式和第二格式相关的数据的传输。The method according to claim 7, wherein the performance of the application in the memory and the client process construct functional modules corresponding to each other according to the mutual agreement, and both include a parsing module and a transceiver module, wherein, The parsing module is responsible for implementing the functional implementation related to the first format and the second format, and the transceiver module is used to perform the transmission of data related to the first format and the second format.
  9. 根据权利要求1所述的方法,其特征在于,本应用程序建构一接口管理模块,用于统一执行客户进程和本应用程序自身对所述接口库的访问。The method according to claim 1, wherein the application program constructs an interface management module for uniformly executing the client process and the application program's own access to the interface library.
  10. 根据权利要求1所述的方法,其特征在于,客户进程负责维护与服务进程的通信状态,以确保客户进程与服务进程之间跨进程通信的稳定性。The method according to claim 1, wherein the client process is responsible for maintaining the communication state with the service process to ensure the stability of cross-process communication between the client process and the service process.
  11. 根据权利要求1所述的方法,其特征在于,还包括如下步骤:The method according to claim 1, characterized in that it further comprises the following steps:
    在客户进程与本应用程序的服务组件解除绑定后,清除由所述客户进程调用产生的实例表信息。After the client process is unbound with the service component of the application, the instance table information generated by the call of the client process is cleared.
  12. 一种终端设备,包括中央处理器和存储器,其特征在于:所述中央处理器用于调用运行存储于所述存储器中的计算机程序以执行如权利要求1至11中任意一项所述的应用程序接口调用控制方法的步骤。A terminal device, comprising a central processing unit and a memory, wherein the central processing unit is used to call and run a computer program stored in the memory to execute the application program according to any one of claims 1 to 11 The steps for the interface to call the control method.
PCT/CN2021/082260 2020-03-24 2021-03-23 Terminal apparatus, and control method for calling application program interface therefor WO2021190469A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010212433.9A CN111338828B (en) 2020-03-24 2020-03-24 Terminal equipment and application program interface calling control method thereof
CN202010212433.9 2020-03-24

Publications (1)

Publication Number Publication Date
WO2021190469A1 true WO2021190469A1 (en) 2021-09-30

Family

ID=71184553

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/082260 WO2021190469A1 (en) 2020-03-24 2021-03-23 Terminal apparatus, and control method for calling application program interface therefor

Country Status (2)

Country Link
CN (1) CN111338828B (en)
WO (1) WO2021190469A1 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114020498A (en) * 2022-01-04 2022-02-08 深圳市明源云科技有限公司 Remote calling method, device, equipment and storage medium for different deployment scenes
CN114564954A (en) * 2022-03-01 2022-05-31 天元大数据信用管理有限公司 Index management method and system for maintaining index uniqueness
CN116048744A (en) * 2022-08-19 2023-05-02 荣耀终端有限公司 Image acquisition method and related electronic equipment
CN116483328A (en) * 2023-06-19 2023-07-25 广州信位通讯科技有限公司 System and method for running HongMong APP on ThreadX embedded software platform
CN117076160A (en) * 2023-10-16 2023-11-17 腾讯科技(深圳)有限公司 Component calling method, device, equipment and storage medium

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111338828B (en) * 2020-03-24 2022-04-08 广州方硅信息技术有限公司 Terminal equipment and application program interface calling control method thereof
CN111880866B (en) * 2020-07-30 2024-03-12 广州方硅信息技术有限公司 Cross-process callback execution method, device, equipment and storage medium
CN112099795A (en) * 2020-09-28 2020-12-18 广州华多网络科技有限公司 Interface notification message construction method, device, equipment and storage medium
CN112817779A (en) * 2021-01-29 2021-05-18 京东方科技集团股份有限公司 Communication method, device, equipment and medium for modular application program
CN117056317B (en) * 2023-10-11 2024-01-26 腾讯科技(深圳)有限公司 Data processing method, device, equipment and computer readable storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110258611A1 (en) * 2010-04-20 2011-10-20 Microsoft Corporation Visualization of runtime analysis across dynamic boundaries
CN104618437A (en) * 2014-12-31 2015-05-13 成都卓影科技有限公司 Adaptation method for android terminal device system setting interface
CN105827672A (en) * 2015-01-05 2016-08-03 阿里巴巴集团控股有限公司 Remote call method and remote call device
CN106547567A (en) * 2016-11-25 2017-03-29 山东大学 Interprocess communication system and its implementation under multi-service in a kind of Android system
CN109729149A (en) * 2018-12-03 2019-05-07 国云科技股份有限公司 A kind of micro services framework implementation method based on note
CN109933443A (en) * 2019-03-07 2019-06-25 腾讯科技(深圳)有限公司 Inter-process communication methods, device, computer equipment and readable storage medium storing program for executing
CN111338828A (en) * 2020-03-24 2020-06-26 广州华多网络科技有限公司 Terminal equipment and application program interface calling control method thereof
CN111400070A (en) * 2020-03-24 2020-07-10 广州华多网络科技有限公司 Terminal equipment and cross-process interface calling implementation and execution method thereof
CN111443961A (en) * 2020-03-24 2020-07-24 广州华多网络科技有限公司 Terminal equipment and cross-process communication method thereof
CN111880866A (en) * 2020-07-30 2020-11-03 广州华多网络科技有限公司 Cross-process callback execution method, device, equipment and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7543300B2 (en) * 2004-11-16 2009-06-02 International Business Machines Corporation Interface for application components
CN108055248B (en) * 2017-11-30 2020-12-25 平安科技(深圳)有限公司 Dubbo framework-based remote calling method, server and storage medium
CN109213611B (en) * 2018-08-01 2021-07-02 天津字节跳动科技有限公司 Cross-process communication method, device, terminal and storage medium
CN110275790A (en) * 2019-06-26 2019-09-24 北京金山安全软件有限公司 Inter-process communication synchronization callback method, system and related equipment in application program

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110258611A1 (en) * 2010-04-20 2011-10-20 Microsoft Corporation Visualization of runtime analysis across dynamic boundaries
CN104618437A (en) * 2014-12-31 2015-05-13 成都卓影科技有限公司 Adaptation method for android terminal device system setting interface
CN105827672A (en) * 2015-01-05 2016-08-03 阿里巴巴集团控股有限公司 Remote call method and remote call device
CN106547567A (en) * 2016-11-25 2017-03-29 山东大学 Interprocess communication system and its implementation under multi-service in a kind of Android system
CN109729149A (en) * 2018-12-03 2019-05-07 国云科技股份有限公司 A kind of micro services framework implementation method based on note
CN109933443A (en) * 2019-03-07 2019-06-25 腾讯科技(深圳)有限公司 Inter-process communication methods, device, computer equipment and readable storage medium storing program for executing
CN111338828A (en) * 2020-03-24 2020-06-26 广州华多网络科技有限公司 Terminal equipment and application program interface calling control method thereof
CN111400070A (en) * 2020-03-24 2020-07-10 广州华多网络科技有限公司 Terminal equipment and cross-process interface calling implementation and execution method thereof
CN111443961A (en) * 2020-03-24 2020-07-24 广州华多网络科技有限公司 Terminal equipment and cross-process communication method thereof
CN111880866A (en) * 2020-07-30 2020-11-03 广州华多网络科技有限公司 Cross-process callback execution method, device, equipment and storage medium

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114020498A (en) * 2022-01-04 2022-02-08 深圳市明源云科技有限公司 Remote calling method, device, equipment and storage medium for different deployment scenes
CN114564954A (en) * 2022-03-01 2022-05-31 天元大数据信用管理有限公司 Index management method and system for maintaining index uniqueness
CN114564954B (en) * 2022-03-01 2024-04-12 天元大数据信用管理有限公司 Index management method and system for maintaining index uniqueness
CN116048744A (en) * 2022-08-19 2023-05-02 荣耀终端有限公司 Image acquisition method and related electronic equipment
CN116048744B (en) * 2022-08-19 2023-09-12 荣耀终端有限公司 Image acquisition method and related electronic equipment
CN116483328A (en) * 2023-06-19 2023-07-25 广州信位通讯科技有限公司 System and method for running HongMong APP on ThreadX embedded software platform
CN116483328B (en) * 2023-06-19 2023-09-12 广州信位通讯科技有限公司 System and method for running HongMong APP on ThreadX embedded software platform
CN117076160A (en) * 2023-10-16 2023-11-17 腾讯科技(深圳)有限公司 Component calling method, device, equipment and storage medium
CN117076160B (en) * 2023-10-16 2024-01-26 腾讯科技(深圳)有限公司 Component calling method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN111338828B (en) 2022-04-08
CN111338828A (en) 2020-06-26

Similar Documents

Publication Publication Date Title
WO2021190469A1 (en) Terminal apparatus, and control method for calling application program interface therefor
CN111400070B (en) Terminal equipment and cross-process interface calling realization and execution method thereof
CN111443961B (en) Terminal equipment and cross-process communication method thereof
WO2021109735A1 (en) Cross-chain-network-based resource processing method, and device
CN111880866B (en) Cross-process callback execution method, device, equipment and storage medium
US10318358B2 (en) System and method for extending a web service environment to support scalable asynchronous clients
US7665096B2 (en) DDS-assisted CORBA discovery
CN110336871A (en) A kind of document handling method, device, storage medium and electronic equipment
CA2511912A1 (en) System and method for building and execution of platform-neutral generic services' client applications
CN105094922A (en) Application installation-free operation control method and device
WO2015135221A1 (en) Inter-process communication method based on application layer of android and basic application communication system
WO2012122884A1 (en) Open plug-in management platform and plug-in management method implemented on browser
JP2015537307A (en) Component-oriented hybrid cloud operating system architecture and communication method thereof
US9037695B2 (en) Management of networked resources on different platforms with a common interface
CN113032166B (en) Inter-core communication method, processor, inter-core communication system, and computer-readable storage medium
JP2014528116A (en) Distributed resource management in portable computing devices
WO2019085780A1 (en) Cloud storage system and method for achieving user-defined data processing in cloud storage system
US11411812B2 (en) Dynamic service creation for microservice-based integration service
CN111582824A (en) Cloud resource synchronization method, device, equipment and storage medium
KR100833494B1 (en) Apparatus for lightweighting application through duplicating management of application in environment of OSGi middleware for embedded terminal and method thereof
CN116820527B (en) Program upgrading method, device, computer equipment and storage medium
US11929933B2 (en) Ephemeral data stream routing service
WO2022121492A1 (en) File transmission method and apparatus, computer device, and storage medium
WO2021057351A1 (en) Apparatus and method for controlling android bluetooth in glibc environment, and terminal device
WO2023035777A1 (en) Network configuration method, proxy component, controller, electronic device and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21774968

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21774968

Country of ref document: EP

Kind code of ref document: A1