Inter-process communication method and system, vehicle-mounted terminal and storage medium
By using dynamic proxy and coroutine technology between the client and the server, combined with reflection and broadcast mechanisms, the problem of low inter-process communication performance in the existing technology is solved, and efficient and stable inter-process communication is achieved.
Patent Information
- Application Number
- CN202411446740.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-01-21
AI Technical Summary
In the prior art, the communication performance of the inter-process communication mechanism is relatively low, and it faces problems such as difficult development, complex implementation logic, limitations on applicable scenarios and project volume increase.
Through the dynamic agency mechanism and coroutine technology between the client and the server, the functional interface class and interface implementation classes are used to generate call requests and send them to the server, and use the reflex technology and broadcast mechanism to realize inter -process communication.
Simplified the call logic of the callor, directly based on the system's native functions to achieve inter -process communication, no need to introduce a third -party library, which improves the efficiency and stability of inter -process communication, thereby improving communication performance.
Smart Images

Figure CN119336527A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to an inter-process communication method, system, vehicle-mounted terminal and storage medium. Background Art
[0002] With the development of mobile Internet technology, multi-process architecture applications are becoming more and more common on various operating system platforms, and multiple processes are often required to work together to complete tasks. In order to achieve data exchange and resource sharing between different application processes, IPC (Inter-Process Communication) has become an indispensable part of the system. Traditional IPC methods include a variety of different implementation methods, such as those based on AIDL (Android Interface Definition Language), Socket, Content Provider, Messenger, and third-party libraries.
[0003] However, these traditional IPC mechanisms face many challenges in practical applications. For example: 1. The AIDL mechanism requires developers to manually implement the AIDL interface, and AIDL is implemented based on Binder (binder), and the Binder mechanism is relatively complex, which makes AIDL development difficult; 2. In the Socket mechanism, data needs to be copied and transmitted through the network stack, resulting in high overhead; 3. The ContentProvider mechanism is mainly suitable for data sharing scenarios and is not suitable for all types of inter-process communication needs; 4. The Messenger mechanism is also implemented based on Binder, mainly used for simple message passing, and is not suitable for complex data transmission; 5. Relying on third-party libraries increases the project size. Therefore, in related technologies, the inter-process communication mechanism still faces problems such as high development difficulty, complex implementation logic, limited applicable scenarios, or increased project size, which makes the communication performance of the inter-process communication mechanism low. Summary of the invention
[0004] In view of the above-mentioned shortcomings of the prior art, the present application discloses an inter-process communication method, system, vehicle-mounted terminal and storage medium, which are used to solve the technical problem of low communication performance of the inter-process communication mechanism in the prior art.
[0005] In the first aspect, the present application provides an inter-process communication method, which is applied to a client, and the method includes: in response to a function call instruction, determining a target function interface and a target function function corresponding to the called target function from a function interface class, wherein the function call instruction carries function parameters; creating a proxy class for the target function interface, using the proxy class to generate a call request with the interface class name of the target function interface, the function name of the target function function, and the function parameters, and creating a coroutine task corresponding to the call request, and setting the state of the coroutine task to a suspended state; sending the call request to a server, so that the server returns a call result according to the call request; upon receiving the call result, triggering the execution of the coroutine task to complete the call of the target function.
[0006] In one embodiment of the present application, the method for generating the call request includes: using the proxy class to create an instance object of the target function interface, the instance object containing the target function function; calling the instance object, obtaining the interface class name, the function name and the function parameters through reflection; encapsulating the interface class name, the function name and the function parameters into call information, and generating the call request based on the call information.
[0007] In one embodiment of the present application, sending the call request to the server includes: setting a result callback address, and encapsulating the result callback address and the call request into a broadcast message; sending the broadcast message to a preset broadcast address so that a first broadcast receiver of the server can listen to the broadcast message at the broadcast address, and so that the server broadcasts the call result to the result callback address; and receiving the call result at the result callback address through a pre-registered second broadcast receiver.
[0008] In one embodiment of the present application, triggering the execution of the coroutine task and completing the call of the target function includes: in response to the call result, setting the state of the coroutine task to the execution state; according to the call result, continuing to execute the coroutine task, processing the call logic of the target function, and completing the call of the target function.
[0009] In one embodiment of the present application, the function interface class includes various function interfaces provided by the server and at least one function function corresponding to the various function interfaces; determining the target function interface and target function corresponding to the called target function from the function interface class includes: parsing the function call instruction to obtain the function name of the target function, the function call instruction also carrying the function name; matching the target function interface from the function interface class according to the function name, and matching the target function function from the function function corresponding to the target function interface according to the function name.
[0010] In the second aspect, the present application provides an inter-process communication method, which is applied to a server, and the method includes: monitoring a call request sent by a client, wherein the call request carries the interface class name of a target function interface corresponding to the target function called by the client, the function name of the target function function, and function parameters; if the call request is monitored, parsing the call request to obtain the interface class name, the function name, and the function parameters; calling an interface implementation class, and using reflection to create an implementation object of the target function interface according to the interface class name, the interface implementation class including at least one function function corresponding to each function interface; calling the target function function in the implementation object according to the function name and the function parameters, obtaining the call result and sending it to the client.
[0011] In one embodiment of the present application, before the call request sent by the listening client is sent, it also includes: defining multiple functional interfaces and obtaining the functional function of at least one function under each functional interface; creating the interface implementation class according to at least one functional function corresponding to each functional interface; and creating a functional interface class according to each functional interface and at least one functional function corresponding to each functional interface, and sending the functional interface class to the client, so that the client makes a function call according to the functional interface class.
[0012] In the third aspect, the present application provides an inter-process communication system, which is applied to a server, and the system includes: an interface determination module, which is used to determine the target function interface and target function function corresponding to the called target function from the function interface class in response to a function call instruction, and the function call instruction carries function parameters; a function call module, which is used to create a proxy class of the target function interface, and use the proxy class to generate a call request with the interface class name of the target function interface, the function name of the target function function and the function parameters, and create a coroutine task corresponding to the call request, and set the state of the coroutine task to a suspended state; a request sending module, which is used to send the call request to the server, so that the server returns a call result according to the call request; a call implementation module, which is used to trigger the coroutine task when receiving the call result, and complete the call of the target function.
[0013] In a fourth aspect, the present application provides a vehicle-mounted terminal, comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the vehicle-mounted terminal implements the inter-process communication method described in the first aspect and / or the second aspect.
[0014] In a fifth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor of a computer, the computer executes the inter-process communication method described in the first aspect and / or the second aspect.
[0015] As described above, the inter-process communication method, system, vehicle terminal and storage medium provided in the embodiments of the present application are applied to the client and have the following beneficial effects:
[0016] First, according to the function call instruction, the target function interface and target function function corresponding to the called target function are determined from the function interface class, and the function call instruction carries function parameters. Then, a proxy class of the target function interface is created, and the proxy class is used to generate a call request with the interface class name of the target function interface, the function name of the target function function and the function parameters, and a coroutine task corresponding to the call request is created, and the state of the coroutine task is set to a suspended state. Then, a call request is sent to the server, so that the server returns the call result according to the call request, and when the call result is received, the coroutine task execution is triggered to complete the call of the target function. The two processes for inter-process communication are defined as client and server respectively, and the dynamic proxy mechanism and coroutine technology are combined to obtain the call result in a synchronous manner, which simplifies the call logic of the caller, and directly implements inter-process communication based on system native functions without the introduction of third-party libraries, thereby improving the efficiency and stability of inter-process communication, thereby improving the communication performance of inter-process communication.
[0017] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0019] Figure 1 is a schematic diagram of an implementation environment of an inter-process communication system shown in an exemplary embodiment of the present application;
[0020] Figure 2 is a flowchart of an inter-process communication method shown in an exemplary embodiment of the present application;
[0021] Figure 3 is a flowchart of another inter-process communication method shown in an exemplary embodiment of the present application;
[0022] Figure 4 is a flowchart of a specific inter-process communication method shown in an exemplary embodiment of the present application;
[0023] Figure 5 is a block diagram of an inter-process communication system shown in an exemplary embodiment of the present application;
[0024] Figure 6 is a block diagram of another inter-process communication system shown in an exemplary embodiment of the present application;
[0025] Figure 7 It is a structural schematic diagram of a vehicle-mounted terminal provided in one embodiment of the present application. DETAILED DESCRIPTION
[0026] The following will describe the implementation methods of the present application with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be understood that the preferred embodiments are only for illustrating the present application, not for limiting the scope of protection of the present application.
[0027] It should be noted that the illustrations provided in the following embodiments are only used to illustrate the basic concept of the present application in a schematic manner, and therefore the illustrations only show components related to the present application rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the form, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0028] In the following description, a large number of details are discussed to provide a more thorough explanation of the embodiments of the present application. However, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present application difficult to understand.
[0029] Traditional IPC methods include a variety of different implementation methods, such as AIDL, Socket, ContentProvider, Messenger, and reliance on third-party libraries, which realize the sharing, coordination or synchronization of data and resources between different application processes. However, the inventors of this application have found that these traditional IPC mechanisms face many challenges in practical applications. For example: 1. The AIDL mechanism requires developers to manually implement the AIDL interface, and AIDL is implemented based on Binder (binder), and the Binder mechanism is relatively complex, which makes AIDL development difficult; 2. Data in the Socket mechanism needs to be copied and transmitted through the network stack, resulting in high overhead; 3. The ContentProvider mechanism is mainly suitable for data sharing scenarios and is not suitable for all types of inter-process communication requirements; 4. The Messenger mechanism is also implemented based on Binder, mainly used for simple message transmission, and is not suitable for complex data transmission; 5. Relying on third-party libraries increases the project size. Therefore, the inter-process communication mechanism still faces problems such as high development difficulty, complex implementation logic, limited applicable scenarios, or increased project size, which makes the communication performance of the inter-process communication mechanism low.
[0030] Therefore, see Figure 1 , Figure 1 FIG. 1 is a schematic diagram of an implementation environment of an inter-process communication system shown in an exemplary embodiment of the present application. Figure 1As shown, the implementation environment includes a vehicle 110 and an inter-process communication system 120, wherein the in-process communication system 120 is embedded in the vehicle 110, and can be an inter-process communication system applied to the client, or an inter-process communication system applied to the server, for realizing inter-process communication in the vehicle 110, and the in-process communication system 120 includes but is not limited to a vehicle system, an on-board computer, etc. When the in-process communication system 120 is an inter-process communication system applied to the client, it combines a dynamic proxy mechanism and coroutine technology to obtain the call result in a synchronous manner, simplifies the caller's calling logic, and directly realizes inter-process communication based on system native functions, without the introduction of third-party libraries, thereby improving the efficiency and stability of inter-process communication, thereby improving the communication performance of inter-process communication.
[0031] First of all, it should be noted that:
[0032] IPC is a mechanism for exchanging information between different processes in an operating system, allowing different application processes to share data and resources, coordinate work, or synchronize operations;
[0033] Dynamic proxy is a proxy class that is dynamically generated at runtime. This proxy class can intercept calls to the original class method. The core of dynamic proxy is the proxy interface, which needs to be implemented in the proxy class. When the interface method of the proxy class is called, the rewritten version of the corresponding method in the proxy class will actually be executed. These methods can add additional logic, such as logging, performance monitoring, or transaction management.
[0034] Reflection is a function provided by the Java language that allows classes, objects, fields, and methods to be inspected or modified at runtime. The reflection mechanism allows Java code to dynamically analyze classes and objects at runtime without knowing the specific structure of the class at compile time.
[0035] Broadcast mechanism is a communication mechanism used to transmit messages between different applications. Broadcast is an event delivery method that allows one application process (sender) to send notifications or data to other application processes (receivers).
[0036] SuspendCoroutine in the suspend coroutine is a suspend function used to suspend the current coroutine in the coroutine and return the CoroutineContext (coroutine context), allowing the rest of the coroutine to continue executing after waiting for an event or operation to complete in the coroutine;
[0037] An interface is an abstract class that defines a set of method specifications. An interface does not contain any implementation, only the method signature (method name, parameter types, and return type).
[0038] An interface implementation class is a class that implements the methods defined by an interface.
[0039] It should also be noted that during inter-process communication, a process can both receive requests from other processes and request other processes. That is, this process can act as both a server and a client, and processes can make requests and respond to each other.
[0040] See also Figure 2 , Figure 2 is a flowchart of an inter-process communication method shown in an exemplary embodiment of the present application. The method can be applied to Figure 1 The implementation environment shown, it should be understood that the method can also be applied to other exemplary implementation environments, and this embodiment does not limit the implementation environment to which the method is applicable. In addition, in the embodiment of the present application, the inter-process communication method can be applied to the Android system, that is, it can be applied to mobile devices of the Android system, such as mobile phones, car terminals, etc.
[0041] like Figure 2 As shown, in an exemplary embodiment, the inter-process communication method is applied to the client, and at least includes steps S210 to S240, which are described in detail as follows:
[0042] Step S210, in response to a function calling instruction, determining a target function interface and a target function function corresponding to the called target function from the function interface class, wherein the function calling instruction carries function parameters.
[0043] Among them, the functional interface class is deployed and provided by the server, including various functional interfaces provided by the server to the application and at least one functional function corresponding to each functional interface.
[0044] It should be noted that a functional interface corresponds to at least one functional function, that is, a functional interface can implement the call of at least one function. In addition, the function parameter represents the execution parameter of the target function to be called, such as the address parameter in the location query function call instruction, which represents the execution parameter of the location query function.
[0045] Specifically, the target function interface and target function function corresponding to the called target function are determined from the function interface class, including: parsing the function call instruction to obtain the function name of the target function, the function call instruction also carrying the function name; matching the target function interface from the function interface class according to the function name, and matching the target function function from the function function corresponding to the target function interface according to the function name.
[0046] In this embodiment, the function call instruction carries the function name, and the function call instruction can be directly parsed to obtain the called target function and its function name. In a possible embodiment, if the function call instruction does not carry the function name, the function call instruction is parsed to extract the keywords in the function call instruction, and the called target function and its function name are obtained according to the keyword analysis. As a possible embodiment, the target function recognition model can be used to realize the recognition and acquisition of the target function and its function name.
[0047] Step S220, create a proxy class for the target function interface, use the proxy class to generate a call request with the interface class name of the target function interface, the function name and function parameters of the target function, and create a coroutine task corresponding to the call request, and set the state of the coroutine task to a suspended state.
[0048] In this embodiment, the state of the coroutine task is set to a suspended state through a suspend function in the coroutine technology.
[0049] In this embodiment, a dynamic proxy mechanism is used to create a proxy class of the target function interface, and function calls are implemented through the proxy class. In addition, coroutine technology is used to obtain the call result in a synchronous manner, thus simplifying the client's call logic for the target function.
[0050] In one embodiment, a method for generating a call request includes: using a proxy class to create an instance object of a target functional interface, the instance object containing a target functional function; calling the instance object to obtain the interface class name, function name and function parameters through reflection; encapsulating the interface class name, function name and function parameters into call information, and generating a call request based on the call information.
[0051] It should be noted that when creating a proxy class of the target function interface, the target function function is written into the proxy class, and when using the proxy class to create an instance object of the target function interface, the target function function is also written into the instance object, so the instance object contains the target function function.
[0052] In this embodiment, by creating an instance object, the native function of the system framework is directly used to obtain and call the proxy object to call the target function, thereby reducing the complexity of inter-process communication, eliminating the need to introduce a third-party library, reducing the dependency complexity of the project, reducing the size of the project, increasing the communication loading speed, and also increasing the efficiency and stability of inter-process communication. In addition, the interface class name, function name and function parameters are obtained through reflection technology, and the client's calling logic for the target function is further simplified by combining the dynamic proxy mechanism, coroutine technology and reflection technology.
[0053] Step S230, sending a call request to the server, so that the server returns a call result according to the call request.
[0054] Specifically, sending a call request to the server includes: setting a result callback address, and encapsulating the result callback address and the call request into a broadcast message; sending the broadcast message to a preset broadcast address, so that a first broadcast receiver of the server can listen to the broadcast message in the broadcast address, and the server can broadcast the call result to the result callback address; receiving the call result in the result callback address through a pre-registered second broadcast receiver.
[0055] In this embodiment, the broadcast mechanism is used to implement the sending of call requests. In this way, inter-process communication is achieved by combining the dynamic proxy mechanism, coroutine technology, reflection technology and broadcast mechanism, which further simplifies the client's calling logic for the target function and reduces the system resource overhead, which is beneficial to improving the communication efficiency of inter-process communication, thereby ensuring the communication performance of inter-process communication.
[0056] Step S240, when the call result is received, the coroutine task execution is triggered to complete the call of the target function.
[0057] In this embodiment, receiving the call result is a trigger condition. When the call result is received, the coroutine task will be triggered to execute the rest of the coroutine. In this way, the call results between processes are obtained in a synchronous manner, code nesting is reduced, and the efficiency of inter-process communication is improved, thereby improving the communication performance of inter-process communication.
[0058] Specifically, triggering the execution of the coroutine task to complete the call of the target function includes: in response to the call result, setting the state of the coroutine task to the execution state; according to the call result, continuing to execute the coroutine task, processing the call logic of the target function, and completing the call of the target function.
[0059] It should be noted that when the state of the coroutine task is set to the execution state, the coroutine context will be cached. After receiving the call result, the coroutine task will be restored through the coroutine context, that is, the state of the coroutine task will be set to the execution state, and then the coroutine task will continue to be executed according to the call result, and the subsequent call logic of the target function will be processed to complete the call of the target function.
[0060] In this embodiment, the coroutine technology is used to obtain the call results between processes in a synchronous manner. Compared with the asynchronous and callback function methods of obtaining the call results, the code nesting is reduced, the calling logic of the function call is simplified, and the communication performance of the inter-process communication is effectively improved.
[0061] The above-mentioned inter-process communication method first determines the target function interface and target function function corresponding to the called target function from the function interface class according to the function call instruction, and the function call instruction carries function parameters, and then creates a proxy class of the target function interface, and uses the proxy class to generate a call request with the interface class name of the target function interface, the function name of the target function function and the function parameters, and creates a coroutine task corresponding to the call request, sets the state of the coroutine task to a suspended state, and then sends a call request to the server, so that the server returns the call result according to the call request, and triggers the execution of the coroutine task when receiving the call result, completes the call of the target function, and defines the two processes for inter-process communication as the client and the server respectively, combines the dynamic proxy mechanism and the coroutine technology, obtains the call result in a synchronous manner, simplifies the call logic of the caller, and directly implements inter-process communication based on the system native function, without the need to introduce a third-party library, thereby improving the efficiency and stability of inter-process communication, thereby improving the communication performance of inter-process communication.
[0062] See also Figure 3 , Figure 3 is a flowchart of another inter-process communication method shown in an exemplary embodiment of the present application. The method can be applied to Figure 1 The implementation environment shown, it should be understood that the method can also be applied to other exemplary implementation environments, and this embodiment does not limit the implementation environment to which the method is applicable. In addition, in the embodiment of the present application, the inter-process communication method can be applied to the Android system, that is, it can be applied to mobile devices of the Android system, such as mobile phones, car terminals, etc.
[0063] like Figure 3 As shown, in an exemplary embodiment, the inter-process communication method is applied to the server, and at least includes steps S310 to S440, which are described in detail as follows:
[0064] Step S310, monitoring the call request sent by the client, the call request carrying the interface class name of the target function interface corresponding to the target function called by the client, the function name and function parameters of the target function;
[0065] Step S320: if a call request is intercepted, the call request is parsed to obtain the interface class name, function name and function parameters;
[0066] Step S330, calling the interface implementation class, using reflection to create an implementation object of the target functional interface according to the interface class name, the interface implementation class including at least one functional function corresponding to each functional interface;
[0067] Step S340, calling the target function in the implementation object according to the function name and function parameters, obtaining the calling result and sending it to the client.
[0068] In this embodiment, if the server monitors a call request sent by the client, it parses the call request to obtain the interface class name, function name and function parameters, and then calls the interface implementation class, and uses reflection to create an implementation object of the target functional interface according to the interface class name. The interface implementation class includes at least one functional function corresponding to each functional interface. Finally, according to the function name and function parameters, the target functional function in the implementation object is called to obtain the call result and send it to the client. By calling the interface implementation class, the implementation object is created using reflection technology, and then the client's call on the target function is implemented directly according to the way the implementation object executes the target function, which simplifies the sender's execution logic and eliminates the need to introduce third-party libraries, thereby improving the efficiency and stability of inter-process communication and thus improving the communication performance of inter-process communication.
[0069] It should be noted that when creating the implementation object of the target function interface, the target function is written into the implementation object, so the implementation object carries the target function.
[0070] In a possible embodiment, the server returns the call result in the form of broadcasting, so that inter-process communication is achieved through the system's native broadcasting mechanism, avoiding additional system resource overhead.
[0071] In one embodiment, before listening to the call request sent by the client, it also includes: defining multiple functional interfaces and obtaining the functional function of at least one function under each functional interface; creating an interface implementation class according to at least one functional function corresponding to each functional interface; and creating a functional interface class according to each functional interface and at least one functional function corresponding to each functional interface, and sending the functional interface class to the client, so that the client makes a function call according to the functional interface class.
[0072] It should be noted that the functional interface class declares the names of the functional interfaces and function names that the client can call, but does not include the implementation details of the specific functions; the interface implementation class is responsible for providing the actual logic of each function under each functional interface. On the server side, after defining the interface and its implementation, the service is deployed to ensure that the client can access it normally.
[0073] In this embodiment, a functional interface class and an interface implementation class are created, wherein the server sends the functional interface class to the client so that the client makes a function call according to the functional interface class, and the interface implementation class is deployed internally to implement the function called by the client. In this way, inter-process communication is achieved by creating two classes, namely, the functional interface class and the interface implementation class, thereby simplifying the function call logic, eliminating the need to introduce a third-party library, and improving the efficiency and stability of inter-process communication, thereby improving the communication performance of inter-process communication.
[0074] See also Figure 4 , Figure 4 FIG. 1 is a flowchart of a specific inter-process communication method shown in an exemplary embodiment of the present application. Figure 4 As shown, taking the voice process and the map process as examples, and taking the user querying the location address by voice as an example, the specific inter-process communication method is explained.
[0075] The voice process is the client and the map process is the server. The server map process provides a query tool interface QueryToolInterface, which defines a function queryAddress for querying a location based on a location name, and has an implementation class QueryToolImpl that implements the interface, and copies the query tool interface QueryToolInterface defined by the server to the client.
[0076] The detailed steps are as follows:
[0077] 1. After the user wakes up the voice assistant with voice, the voice process listens for voice commands, which are instructions for calling the location query function;
[0078] 2. The voice process performs voice recognition on the voice command;
[0079] 3. Determine the intention of the location query;
[0080] 4. The voice process uses dynamic proxy technology to create a proxy class for the query tool interface QueryToolIterface;
[0081] 5. The voice process calls the location query function of the proxy class;
[0082] 6. Generate a call request according to the interface class name of the query tool interface QueryToolIterface, the function name and function parameter (i.e., the query address, such as Guanyin Bridge) of the location query function queryAddress;
[0083] 7. Create a coroutine task corresponding to the call request inside the proxy class and set the state of the coroutine task to suspended state;
[0084] 8. The proxy class sends a call request to the map process via broadcast;
[0085] 9. The broadcast receiver of the map process receives the call request;
[0086] 10. Parse the call request and create an implementation object based on the implementation class QueryToolImpl of the query tool interface QueryToolInterface;
[0087] 11. Call the queryAddress function in the implementation object according to the function name and function parameters;
[0088] 12. Get the address call result (e.g. "** City ** District ** Street ** Road ** Number");
[0089] 13. The map process sends the address call result to the voice process in the form of broadcast;
[0090] 14. The broadcast receiver of the voice process receives the address call result;
[0091] 15. Restore the coroutine task through the coroutine context and process the location query call logic;
[0092] 16. The voice process successfully obtains the address information, and uses speech synthesis technology to synthesize the address information into audio, and voice broadcasts the detailed address of the queried location.
[0093] In the above embodiment, the voice process responds to the location query function call instruction, determines the query tool interface QueryToolInterface and the location query function function queryAddress corresponding to the called location function from the function interface class, the function call instruction carries the address parameter, then creates a proxy class of the query tool interface, uses the proxy class to generate a call request for the location query function by using the interface class name of the query tool interface, the function name of the location query function function and the address parameter, creates a coroutine task corresponding to the call request, sets the state of the coroutine task to the suspended state, and then sends the call request to the map process by broadcasting, so that the map process queries the address according to the call request and returns; and after monitoring the call request sent by the voice process, the map process parses the call request to obtain the interface class name, function name and address parameter, and then calls the interface implementation class QueryToolImpl, uses reflection to create an implementation object of the query tool interface according to the interface class name, and finally calls the location query function function queryAddress in the implementation object according to the function name and function parameters to obtain the address result and send the address result to the voice process by broadcasting; and when the voice process receives the address result, it triggers the execution of the coroutine task to complete the call of the location query function.
[0094] In this way, by combining the dynamic proxy mechanism, coroutine technology, reflection technology and broadcast mechanism, the communication between the voice process and the map process is realized, which further simplifies the calling logic of the voice process for the location query function and reduces the system resource overhead, which is conducive to improving the communication efficiency between the voice process and the map process, thereby ensuring the communication performance between the voice process and the map process.
[0095] See also Figure 5 , Figure 5 is a block diagram of an inter-process communication system shown in an exemplary embodiment of the present application. The system can be applied to Figure 1 The implementation environment shown is a schematic diagram. It should be understood that the system may also be applicable to other exemplary implementation environments, and this embodiment does not limit the implementation environment to which the system is applicable.
[0096] like Figure 5 As shown, in an exemplary embodiment, the inter-process communication system 500 is applied to the client, and at least includes an interface determination module 510, a function call module 520, a request sending module 530 and a call implementation module 540, which are described in detail as follows:
[0097] The interface determination module 510 is used to determine the target function interface and the target function function corresponding to the called target function from the function interface class in response to the function call instruction, and the function call instruction carries function parameters;
[0098] The function calling module 520 is used to create a proxy class of the target function interface, generate a call request by using the proxy class with the interface class name of the target function interface, the function name of the target function and the function parameters, and create a coroutine task corresponding to the call request, and set the state of the coroutine task to a suspended state;
[0099] The request sending module 530 is used to send a call request to the server, so that the server returns a call result according to the call request;
[0100] The call implementation module 540 is used to trigger the execution of the delayed coroutine task when receiving the call result, so as to complete the call of the target function.
[0101] It should be noted that the inter-process communication system provided in the above embodiment and the inter-process communication method applied to the client provided in the above embodiment belong to the same concept, wherein the contents of the operations performed by each module have been described in detail in the method embodiment and will not be repeated here.
[0102] See also Figure 6 , Figure 6 is a block diagram of another inter-process communication system shown in an exemplary embodiment of the present application. The system can be applied to Figure 1 The implementation environment shown is a schematic diagram. It should be understood that the system may also be applicable to other exemplary implementation environments, and this embodiment does not limit the implementation environment to which the system is applicable.
[0103] like Figure 6As shown, in an exemplary embodiment, the inter-process communication system 600 is applied to the server, and at least includes a request monitoring module 610, an information parsing module 620, an object creation module 630 and a function execution module 640, which are described in detail as follows:
[0104] The request monitoring module 610 is used to monitor the call request sent by the client, and the call request carries the interface class name of the target function interface corresponding to the target function called by the client, the function name and function parameters of the target function function;
[0105] The information parsing module 620 is used to parse the call request if it is monitored, and obtain the interface class name, function name and function parameters;
[0106] The object creation module 630 is used to call the interface implementation class and use reflection to create an implementation object of the target functional interface according to the interface class name. The interface implementation class includes at least one functional function corresponding to each functional interface.
[0107] The function execution module 640 is used to call the target function in the implementation object according to the function name and function parameters, obtain the call result and send it to the client.
[0108] It should be noted that the inter-process communication system provided in the above embodiment and the inter-process communication method applied to the server provided in the above embodiment belong to the same concept, wherein the contents of the operations performed by each module have been described in detail in the method embodiment and will not be repeated here.
[0109] See also Figure 7 , Figure 7 It is a structural schematic diagram of a vehicle-mounted terminal provided in one embodiment of the present application. Figure 7 The structure diagram of the computer system of the vehicle terminal suitable for implementing the embodiment of the present application is shown. It should be noted that: Figure 7 The computer system 700 of the vehicle-mounted terminal shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0110] like Figure 7As shown, computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to the program stored in read-only memory (ROM) 702 or the program loaded from storage part 708 to random access memory (RAM) 703, such as executing the method in the above embodiment. In RAM 703, various programs and data required for system operation are also stored. CPU 701, ROM 702 and RAM 703 are connected to each other through bus 704. Input / output (I / O) interface 705 is also connected to bus 704.
[0111] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed so that a computer program read therefrom is installed into the storage section 708 as needed.
[0112] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 709, and / or installed from a removable medium 711. When the computer program is executed by a central processing unit (CPU) 701, various functions defined in the system of the present application are executed.
[0113] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor of a computer, the computer executes the above-mentioned inter-process communication method applied to the client and / or the inter-process communication method applied to the server. The computer-readable storage medium may be included in the vehicle-mounted terminal described in the above-mentioned embodiment, or may exist independently without being assembled into the vehicle-mounted terminal.
[0114] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0115] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0116] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0117] The above embodiments are merely illustrative of the principles and effects of the present application, and are not intended to limit the present application. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present application shall still be covered by the claims of the present application.
Claims
1. An inter-process communication method, characterized in that: Applied to a client, the method comprises: In response to a function call instruction, determining a target function interface and a target function function corresponding to the called target function from the function interface class, wherein the function call instruction carries function parameters; Create a proxy class of the target function interface, use the proxy class to generate a call request with the interface class name of the target function interface, the function name of the target function and the function parameters, create a coroutine task corresponding to the call request, and set the state of the coroutine task to a suspended state; Sending the call request to the server, so that the server returns the call result according to the call request; When the call result is received, the coroutine task is triggered to execute and the call of the target function is completed.
2. The inter-process communication method according to claim 1, characterized in that: The method for generating the call request includes: Using the proxy class to create an instance object of the target functional interface, the instance object contains the target functional function; Call the instance object, and obtain the interface class name, the function name and the function parameters through reflection; The interface class name, the function name and the function parameters are encapsulated into call information, and the call request is generated according to the call information.
3. The inter-process communication method according to claim 2, characterized in that: The sending the call request to the server includes: Setting a result callback address, and encapsulating the result callback address and the call request into broadcast information; Sending the broadcast information to a preset broadcast address, so that the first broadcast receiver of the server can monitor the broadcast information at the broadcast address, and so that the server can broadcast the call result to the result callback address; The call result is received in the result callback address through a pre-registered second broadcast receiver.
4. The inter-process communication method according to claim 1, characterized in that: The triggering of the coroutine task execution and completing the calling of the target function includes: In response to the calling result, setting the state of the coroutine task to an execution state; According to the calling result, continue to execute the coroutine task, process the calling logic of the target function, and complete the calling of the target function.
5. The inter-process communication method according to any one of claims 1 to 4, characterized in that: The functional interface class includes various functional interfaces provided by the server and at least one functional function corresponding to each functional interface; The step of determining the target function interface and the target function function corresponding to the called target function from the function interface class includes: Parsing the function call instruction to obtain a function name of the target function, wherein the function call instruction also carries the function name; The target functional interface is matched from the functional interface class according to the functional name, and the target functional function is matched from the functional functions corresponding to the target functional interface according to the functional name.
6. An inter-process communication method, characterized in that: Applied to the server, the method includes: Monitor the call request sent by the client, the call request carries the interface class name of the target function interface corresponding to the target function called by the client, the function name and function parameters of the target function function; If the call request is intercepted, the call request is parsed to obtain the interface class name, the function name and the function parameters; Calling the interface implementation class, using reflection to create an implementation object of the target functional interface according to the interface class name, the interface implementation class including at least one functional function corresponding to each functional interface; According to the function name and the function parameters, the target function in the implementation object is called, and the call result is obtained and sent to the client.
7. The inter-process communication method according to claim 6, characterized in that: Before the call request sent by the monitoring client, it also includes: Define multiple functional interfaces and obtain the functional function of at least one function under each functional interface; According to at least one of the functional functions corresponding to each functional interface, the interface implementation class is created; and according to each functional interface and at least one of the functional functions corresponding to each functional interface, a functional interface class is created, and the functional interface class is sent to the client so that the client makes a functional call according to the functional interface class.
8. An inter-process communication system, characterized in that: Applied to the server, the system includes: An interface determination module, for determining a target function interface and a target function function corresponding to a called target function from a function interface class in response to a function call instruction, wherein the function call instruction carries function parameters; A function calling module, used to create a proxy class of the target function interface, use the proxy class to generate a call request with the interface class name of the target function interface, the function name of the target function and the function parameters, and create a coroutine task corresponding to the call request, and set the state of the coroutine task to a suspended state; A request sending module, used for sending the call request to the server, so that the server returns the call result according to the call request; The calling implementation module is used to trigger the execution of the coroutine task when receiving the calling result, so as to complete the calling of the target function.
9. A vehicle-mounted terminal, characterized in that: include: one or more processors; A storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, enables the vehicle terminal to implement the inter-process communication method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Computer-readable instructions are stored thereon, and when the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the inter-process communication method according to any one of claims 1 to 7.