Service interaction method and apparatus, server, storage medium, and program product
By registering services on the server and using a unified JSON string protocol format, the problem of excessive interface definitions between multiple ecosystem application services is solved, simplifying service interaction, reducing coupling, and improving interaction efficiency and scalability.
Patent Information
- Application Number
- CN202410593514.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-13
- Publication Date
- 2026-01-13
- Estimated Expiration
- 2044-05-13
AI Technical Summary
In the interaction process between multiple ecosystem application services, too many interface definitions lead to complex interactions and high coupling, making it difficult to achieve clear logical interactions.
By registering listening interfaces for all services on the server, the interaction between the service seeker and the service provider is realized by calling the interfaces through an intermediate server. A unified JSON string protocol format is adopted to reduce the number of interface definitions and simplify callback methods.
It reduces the coupling between application layers, simplifies the logical interaction process, and improves scalability and interaction efficiency.
Smart Images

Figure CN118540380B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of vehicle technology, and in particular to a service interaction method, apparatus, server, storage medium, and program product. Background Technology
[0002] With the rapid development of vehicle networking technology, the concept of software-defined vehicles has become a trend in automotive development. The development of automotive software makes cars more intelligent and also gives the intelligent cockpit ecosystem unlimited development possibilities. One scenario is the interaction between the system and ecosystem applications.
[0003] In existing technologies, ecosystem applications are typically treated as a service, defining various AIDL interfaces as SDKs (Software Development Kits) to provide data to other parties. This approach is convenient when an ecosystem application has only one service. However, if an ecosystem application has multiple services, especially multimedia applications which may involve multiple information sources, there may be 7 or 8 services. The interaction between each service and the system becomes very complex, and there are also many custom interfaces. Summary of the Invention
[0004] This application provides a service interaction method, apparatus, server, storage medium, and program product to solve the problem in related technologies that there is a large amount of interface data defined in order to realize the interaction between different application services.
[0005] The first aspect of this application provides a service interaction method applied to a server, on which listening interfaces for all services are registered, including the following steps: obtaining data and / or event acquisition requests from service acquisition parties; determining the service provider offering the data and / or events based on the data and / or event acquisition requests; and using the interfaces to call the service provider to obtain the data and / or events, wherein the service provider sends the data and / or events to the service acquisition party after unifying the data and / or events into a unified format.
[0006] Optionally, the data acquisition request includes the name of the service acquisition party, the name of the service provider, and data parameters; the event acquisition request includes the name of the service acquisition party, the name of the service provider, and the name of the event. Determining the service provider that provides the data and / or event based on the data and / or event acquisition request includes: parsing the data and / or event acquisition request to obtain the name of the service provider; and determining the service provider based on the name of the service provider.
[0007] Optionally, the methods in the interface include: data acquisition methods, data provision methods, passive data reception methods, event sending methods, and event reception methods.
[0008] Optionally, data and / or events can be obtained by calling the service provider through the interface, including: if it is a data request, providing data by calling the data providing method through the interface; if it is an event request, sending the event by calling the event sending method through the interface.
[0009] Optionally, before obtaining the data and / or event acquisition requests from the service acquirer, the method further includes: monitoring the status of all services; if the service acquirer calls the data acquisition method and / or event reception method in the interface, then obtaining the data and / or event acquisition requests from the service acquirer.
[0010] Optionally, the protocol format is uniformly set to a JSON string.
[0011] A second aspect of this application provides a service interaction apparatus. The apparatus is applied to a server, which has registered listening interfaces for all services. The apparatus includes: an acquisition module for acquiring data and / or event acquisition requests from service acquisition parties; a determination module for determining the service provider offering the data and / or events based on the data and / or event acquisition requests; and a calling module for using the interfaces to call the service provider to obtain the data and / or events, wherein the service provider sends the data and / or events to the service acquisition party after unifying the data and / or events into a unified format.
[0012] Optionally, the data acquisition request includes the name of the service acquisition party, the name of the service provider, and data parameters; the event acquisition request includes the name of the service acquisition party, the name of the service provider, and the event name; the determination module is further used to: parse the data and / or event acquisition requests to obtain the name of the service provider; and determine the service provider based on the name of the service provider.
[0013] Optionally, the methods in the interface include: data acquisition methods, data provision methods, passive data reception methods, event sending methods, and event reception methods.
[0014] Optionally, the calling module is further used to: provide data by calling the data providing method using the interface if it is a data request; and send the event by calling the event sending method using the interface if it is an event request.
[0015] Optionally, the service interaction device further includes: a listening module, used to listen to the status of all services before obtaining the data and / or event acquisition request from the service acquisition party; if the service acquisition party calls the data acquisition method and / or event reception method in the interface, then the service acquisition party's data and / or event acquisition request is obtained.
[0016] Optionally, the protocol format is uniformly set to a JSON string.
[0017] A third aspect of this application provides a server, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. The processor executes the program to perform the service interaction method as described in the above embodiments.
[0018] A fourth aspect of this application provides a computer-readable storage medium having a computer program or instructions stored thereon, which, when executed by a processor, are used to implement the service interaction method as described in the above embodiments.
[0019] A fifth aspect of this application provides a computer program product, including a computer program or instructions, which, when executed, implement the service interaction method as described in the above embodiments.
[0020] Therefore, this application has at least the following beneficial effects:
[0021] This application embodiment registers all services on a server, enabling interaction between different application services (service seekers and service providers) through an intermediate server-side API call. This reduces the number of API definitions, decreases coupling between application layers, and simplifies callback API method definitions, resulting in clearer logical interactions. Therefore, it solves the technical problem in related technologies where a large amount of API data needs to be defined to achieve interaction between different application services.
[0022] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0023] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0024] Figure 1 This is a flowchart of a service interaction method provided according to an embodiment of this application;
[0025] Figure 2 This is a flowchart illustrating a service interaction method provided according to a specific embodiment of this application;
[0026] Figure 3 This is a schematic diagram of a service interaction device provided according to an embodiment of this application;
[0027] Figure 4 This is a schematic diagram of the structure of a server provided according to an embodiment of this application. Detailed Implementation
[0028] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0029] The service interaction method, apparatus, server, storage medium, and program product of this application are described below with reference to the accompanying drawings. Addressing the problem mentioned in the background art center that when an ecosystem application has multiple services, the interaction between each service and the system becomes very complex, and there are many custom interfaces, this application provides a service interaction method. In this method, all services can be registered on a server, and the interaction between the service seeker and the service provider is achieved by calling interfaces through an intermediate server. This solves the problem in related technologies where a large amount of interface data is defined to achieve interaction between different application services.
[0030] Specifically, Figure 1 This is a flowchart illustrating a service interaction method provided in an embodiment of this application.
[0031] It should be noted that the method in this application embodiment is applied to a server, that is, an intermediate service, and has registered listening interfaces for all services for listening to applications (i.e., services in this application embodiment).
[0032] like Figure 1 As shown, the service interaction method includes the following steps:
[0033] In step S101, the data and / or event acquisition request from the service acquisition party is obtained.
[0034] The service provider can be various applications installed inside the vehicle's cockpit system, including system applications such as launchers.
[0035] It should be noted that all services register different listeners with the intermediate service via AIDL, using the module ID as the category.
[0036] It is understood that the embodiments of this application can obtain data and / or event acquisition requests from the service acquisition party.
[0037] In this embodiment of the application, before obtaining the data and / or event acquisition request from the service acquisition party, the method further includes: monitoring the status of all services; if the service acquisition party calls the data acquisition method and / or event reception method in the interface, then the data and / or event acquisition request from the service acquisition party is obtained.
[0038] It is understood that the embodiments of this application can monitor the status of all services. If the service obtainer calls the data obtain method and / or event receive method in the interface, the data and / or event obtainer request of the service obtainer can be obtained.
[0039] In step S102, the service provider that provides the data and / or events is determined based on the data and / or event acquisition request.
[0040] The data acquisition request includes the name of the service acquisition party, the name of the service provider, and the data parameters; the event acquisition request includes the name of the service acquisition party, the name of the service provider, and the name of the event.
[0041] In this embodiment of the application, determining the service provider that provides data and / or events based on the data and / or event acquisition request includes: parsing the data and / or event acquisition request to obtain the name of the service provider; and determining the service provider based on the name of the service provider.
[0042] Since the data acquisition request and event acquisition request carry the name of the service provider, this application embodiment can parse the data and / or event acquisition request to obtain the name of the service provider; and determine the service provider based on the name of the service provider.
[0043] In step S103, the service provider is used to call the interface to obtain data and / or events, wherein the service provider sends the data and / or events to the service recipient after unifying the format.
[0044] The methods in the interface include: getData method, provideData method, receiveData method, sendEvent method, and receiveEvent method; the unified format is JSON string protocol format.
[0045] Since all services have registered listeners on the intermediate service, the intermediate service has listener interfaces for all services. Therefore, in this embodiment, the service provider can use the interface to call the service provider to obtain the data and / or events required by the service recipient. Thus, only one interface is needed to call to realize the interaction between services, which greatly reduces the coupling between application layers. Furthermore, the service provider sends the data and / or events to the service recipient after unifying the format, so as to facilitate data interaction between services.
[0046] In this application embodiment, obtaining data and / or events by calling the service provider through an interface includes: if it is a data request, then providing data by calling the data providing method through the interface; if it is an event request, then sending the event by calling the event sending method through the interface.
[0047] It is understood that the embodiments of this application can use the interface to call the corresponding method to obtain data and events from the service provider. If the service requester is a data request, the interface is used to call the data provision method to provide data. If the service requester is an event request, the interface is used to call the event sending method to send the event. This realizes the use of the methods in the interface to call the service provider to provide data or events, which greatly reduces the definition of callback interface methods.
[0048] The following specific embodiment illustrates the service interaction method of this application, including a cockpit application and an intermediate service, wherein: the cockpit application refers to various Apps installed inside the cockpit system, including system applications such as launchers; the intermediate service is an intermediate service used for data transmission and event passing between services.
[0049] The interaction between different services includes the following steps:
[0050] 1. Initialize intermediate services.
[0051] 2. Each application module registers different listeners with the intermediate service via AIDL, using the module ID as the category;
[0052] 3. Define a standard, generic callback interface. Traditional AIDL interface definitions require defining business-related interface methods based on module functionality, such as retrieving playlist data, music playback status, and controlling music playback / pause operations. This approach only requires defining 5 methods:
[0053] getData: Used for applications to actively retrieve data; onGetData: Used for applications to provide data; onNotifyData: Used for applications to passively receive data; sendEvent: Used for sending events; onEvent: Used for receiving events.
[0054] Each method requires three parameters: the source module `sid` (equivalent to the service recipient in this application), the target module `tid` (equivalent to the service provider in this application), the event `id` (equivalent to the event name in this application), and the `param` parameter. The source module `id` identifies the requester and is used to find the corresponding callback when returning data. The target module `id` is used to find the corresponding service provider module. The event `id` represents the specific function request. The parameter is a standard JSON string parameter. All inter-application service interactions use these five methods.
[0055] If the cockpit system has two application modules, A and B, and module C serves as an intermediary service, such as... Figure 2 As shown, the steps are as follows:
[0056] 1. The system starts up and launches the intermediate service C.
[0057] 2. Modules A and B call methods in C to register different listener callbacks with module ID as the category, which are used to passively receive data events sent by each module.
[0058] 3. Module A requests data / sending status from service C through an interface. Service C finds the interface provided by module B based on parameters such as the target module ID and returns the data / sending status.
[0059] When module A needs to retrieve data from module B, it can call the `getData` method of module C's AIDL interface. This method requires passing the source module's `sid`, the target module's `tid`, and data parameters. The source module's `sid` identifies the requester and is used to find the corresponding callback when data is returned. The target module's `id` is used to find the corresponding service provider module. The event ID indicates the specific function request. The parameters are standard JSON string parameters.
[0060] After service C finds the registered listening interface of module B, it calls the onGetData method of module B to return the data of module B.
[0061] 4. Module B receives the interface request from the callback of service C, processes it with business logic, and then sends data to module A based on the source module ID.
[0062] The data returned by module B is uniformly in JSON string protocol format. After module A receives the data, it converts it. In this way, A obtains the data provided by B. The request process for event types is the same as that for data requests.
[0063] It's important to note that the service interaction method described above employs an intermediary service approach. The system and ecosystem applications can register listeners with this intermediary service, providing a standardized interface protocol to define various events for interaction between the system and applications. This significantly reduces coupling between application layers and simplifies the definition of callback interface methods, making logical interactions clearer. Furthermore, when extending functional interfaces, only the corresponding event IDs need to be defined, further reducing coupling between applications and eliminating the need to define additional AIDL interfaces, thus greatly improving scalability.
[0064] According to the service interaction method proposed in the embodiments of this application, all services can be registered on the server, and the interaction between the service seeker and the service provider can be realized through the intermediate server calling interface. This reduces the number of interface definitions, reduces the coupling between application layers, and also reduces the definition of callback interface methods, making the logical interaction clearer.
[0065] Next, the service interaction apparatus proposed according to the embodiments of this application is described with reference to the accompanying drawings.
[0066] Figure 3 This is a block diagram of a service interaction device according to an embodiment of this application.
[0067] like Figure 3 As shown, the service interaction device 10 includes: an acquisition module 100, a determination module 200, and a calling module 300.
[0068] The acquisition module 100 is used to acquire data and / or event acquisition requests from the service acquisition party; the determination module 200 is used to determine the service provider that provides data and / or events based on the data and / or event acquisition requests; and the invocation module 300 is used to invoke the service provider through an interface to obtain data and / or events, wherein the service provider sends the data and / or events to the service acquisition party after unifying the data and / or events into a unified format.
[0069] In this embodiment of the application, the data acquisition request includes the name of the service acquisition party, the name of the service provider, and data parameters; the event acquisition request includes the name of the service acquisition party, the name of the service provider, and the name of the event; and the determination module is further used to: parse the data and / or event acquisition requests to obtain the name of the service provider; and determine the service provider based on the name of the service provider.
[0070] In this embodiment of the application, the methods in the interface include: a data acquisition method, a data provision method, a passive data reception method, an event sending method, and an event reception method.
[0071] In this embodiment of the application, the calling module 300 is further configured to: if it is a data request, provide data by calling the data providing method through the interface; if it is an event request, send the event by calling the event sending method through the interface.
[0072] In this embodiment of the application, the device 10 further includes a monitoring module.
[0073] The listening module is used to listen to the status of all services before obtaining data and / or event retrieval requests from the service retrieval party; if it detects that the service retrieval party has called the data retrieval method and / or event reception method in the interface, it will obtain the data and / or event retrieval request from the service retrieval party.
[0074] In this embodiment of the application, the unified format is a JSON string protocol format.
[0075] It should be noted that the foregoing explanation of the service interaction method embodiment also applies to the service interaction device of this embodiment, and will not be repeated here.
[0076] According to the service interaction device proposed in the embodiments of this application, all services can be registered on the server, and the interaction between the service seeker and the service provider can be realized through the intermediate server calling interface. This reduces the number of interface definitions, reduces the coupling between application layers, and also reduces the definition of callback interface methods, making the logical interaction clearer.
[0077] Figure 4 A schematic diagram of the structure of a server provided in an embodiment of this application. The server may include:
[0078] The memory 401, the processor 402, and the computer program stored on the memory 401 and capable of running on the processor 402.
[0079] When the processor 402 executes the program, it implements the service interaction method provided in the above embodiments.
[0080] Furthermore, the server also includes:
[0081] Communication interface 403 is used for communication between memory 401 and processor 402.
[0082] The memory 401 is used to store computer programs that can run on the processor 402.
[0083] The memory 401 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0084] If the memory 401, processor 402, and communication interface 403 are implemented independently, then the communication interface 403, memory 401, and processor 402 can be interconnected via a bus to complete communication between them. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be divided into address buses, data buses, control buses, etc. For ease of representation, Figure 4 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0085] Optionally, in a specific implementation, if the memory 401, processor 402, and communication interface 403 are integrated on a single chip, then the memory 401, processor 402, and communication interface 403 can communicate with each other through an internal interface.
[0086] Processor 402 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.
[0087] This application also provides a computer-readable storage medium storing a computer program or instructions thereon, which, when executed by a processor, implements the above-described service interaction method.
[0088] This application also provides a computer program product, including a computer program or instructions, which, when executed, implement a service interaction method such as the one described above.
[0089] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0090] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0091] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0092] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or more of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0093] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it includes one or a combination of the steps of the method embodiments.
Claims
1. A service interaction method, characterized by, The method is applied to a server on which a listening interface of all services is registered, and comprises the following steps: obtaining a data and / or event obtaining request of a service obtaining party, wherein the data obtaining request comprises a name of the service obtaining party, a name of a service providing party and a data parameter, and the event obtaining request comprises the name of the service obtaining party, the name of the service providing party and a name of the event; determining the service providing party providing the data and / or the event according to the data and / or the event obtaining request, wherein the determining comprises: parsing the data and / or the event obtaining request to obtain the name of the service providing party, and determining the service providing party based on the name of the service providing party; obtaining the data and / or the event by calling the service providing party through an interface, wherein the service providing party sends the data and / or the event in a unified format to the service obtaining party, and the interface defines a method comprising: a data obtaining method, a data providing method, a passive data accepting method, an event sending method and an event accepting method; and the obtaining the data and / or the event by calling the service providing party through the interface comprises: if the request is the data request, the data is provided by calling the data providing method through the interface; and if the request is the event request, the event is sent by calling the event sending method through the interface.
2. The service interaction method of claim 1, wherein, Before the data and / or event obtaining request of the service obtaining party is obtained, the method further comprises: listening to states of all services; if the data obtaining method and / or the event accepting method in the interface are called by the service obtaining party, obtaining the data and / or event obtaining request of the service obtaining party.
3. The service interaction method according to claim 1, wherein the unified format is a protocol format of a json string.
4. A service interaction apparatus characterized by comprising: The device is applied to a server on which a listening interface of all services is registered, and comprises: an obtaining module, configured to obtain a data and / or event obtaining request of a service obtaining party, wherein the data obtaining request comprises a name of the service obtaining party, a name of a service providing party and a data parameter, and the event obtaining request comprises the name of the service obtaining party, the name of the service providing party and a name of the event; a determining module, configured to determine the service providing party providing the data and / or the event according to the data and / or the event obtaining request, wherein the determining comprises: parsing the data and / or the event obtaining request to obtain the name of the service providing party, and determining the service providing party based on the name of the service providing party; an obtaining module, configured to obtain the data and / or the event by calling the service providing party through an interface, wherein the service providing party sends the data and / or the event in a unified format to the service obtaining party, and the interface defines a method comprising: a data obtaining method, a data providing method, a passive data accepting method, an event sending method and an event accepting method; and the obtaining the data and / or the event by calling the service providing party through the interface comprises: if the request is the data request, the data is provided by calling the data providing method through the interface; and if the request is the event request, the event is sent by calling the event sending method through the interface. The calling module is configured to call the service provider by using an interface to obtain the data and / or the event, wherein the service provider sends the data and / or the event to the service requester after unifying the format of the data and / or the event, and the interface defines methods including a data obtaining method, a data providing method, a passive data accepting method, an event sending method and an event accepting method; the calling the service provider by using the interface to obtain the data and / or the event includes: if the request is the data request, calling the data providing method by using the interface to provide the data; and if the request is the event request, calling the event sending method by using the interface to send the event.
5. A server, characterized by The computer program or instructions are executed by the processor to implement the service interaction method according to any one of claims 1-3. The computer program or instructions are executed by the processor to implement the service interaction method according to any one of claims 1-3.
6. A computer readable storage medium having stored thereon a computer program or instructions, characterized in that, The computer program or instructions are executed by the processor to implement the service interaction method according to any one of claims 1-3.
7. A computer program product comprising computer programs or instructions, characterized in that,
Citation Information
Patent Citations
Data request method and system and storage medium
CN114401307A
Vehicle interaction method and device, terminal equipment and computer readable storage medium
CN115426410A