In-vehicle application implementation methods, vehicles and storage media
By introducing an adaptation layer to interface with the service layer in the vehicle system, the problems of high application development costs and long development cycles caused by different vehicle systems are solved. The standardization and modular management of the interface between the application layer and the service layer are realized, and the scalability of the vehicle system is improved.
Patent Information
- Application Number
- CN202410274170.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-11
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2044-03-11
AI Technical Summary
Because different vehicle systems have different service layers, application developers need to develop multiple versions to interface with different service layers, which increases development costs and time.
An adapter layer is introduced into the vehicle system. The adapter layer connects to the service layer, and the application layer calls the services of the service layer through the adapter layer. The interface of the application layer is fixed, so that only different adapter layers need to be configured for different vehicle systems, providing a unified interface specification and dynamic expansion capability.
It reduced application development costs, shortened development cycles, and achieved standardized and modular management of the interfaces between the application layer and the service layer, thereby improving the scalability of the vehicle system.
Smart Images

Figure CN118193078B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method for implementing in-vehicle applications, a vehicle, and a storage medium. Background Technology
[0002] In an in-vehicle system, each application needs to interface with the service layer of that system. Since different vehicles have different in-vehicle systems, and different service layers exist within each system, the specifications for interfacing with these different service layers also differ. This necessitates application developers creating multiple versions to interface with these different service layers, resulting in high application development costs and long development cycles. Summary of the Invention
[0003] This application provides a method for implementing an in-vehicle application, a vehicle, and a storage medium, enabling application developers to create only one version, reducing development costs and shortening the development cycle. The technical solution is as follows:
[0004] On one hand, a method for implementing in-vehicle applications is provided, applied to an in-vehicle system. The in-vehicle system includes an application layer, an adaptation layer, and a service layer. The application layer runs multiple applications, each including a first code file that provides Java and AIDL interfaces. The adaptation layer includes a second code file that provides abstract services inherited from services in the service layer and also provides AIDL interfaces. The method includes:
[0005] When any application receives a service call request, it calls the AIDL interface of the adaptation layer through the Java interface and AIDL interface provided by the first code file of the application.
[0006] The AIDL interface of the adaptation layer is used to call the abstract service of the adaptation layer;
[0007] The services in the service layer are invoked through the abstract services of the adaptation layer.
[0008] In one possible implementation, the method further includes:
[0009] After the vehicle system is running, a target service integrating multiple abstract services in the second code file is created through the adaptation layer, and the target service is registered in the manifest file.
[0010] In one possible implementation, the method further includes:
[0011] Multiple event schedulers are registered in the target service, and each event scheduler is used to handle a type of event.
[0012] The process of calling services in the service layer through the abstract service of the adaptation layer includes:
[0013] The corresponding event scheduler is invoked through the abstract service of the adaptation layer;
[0014] The event scheduler invokes the services in the service layer.
[0015] In one possible implementation, the first code file is further used to provide multiple listeners; after calling the AIDL interface of the adaptation layer through the Java interface and AIDL interface provided by the first code file of any application, the method further includes:
[0016] After the first event is captured by any listener, a mapping relationship is established between the first event and the listener that captured the first event;
[0017] After the callback of the first event is detected by any listener, multiple callback interfaces of the first event are determined based on the mapping relationship, and the multiple callback interfaces are triggered in sequence, wherein one listener corresponds to one callback interface.
[0018] In one possible implementation, the second code file is further used to provide multiple listeners; the method also includes:
[0019] After the second event is captured by any listener, a mapping relationship is established between the second event and the listener that captured the second event;
[0020] When the adaptation layer needs to send a callback message corresponding to the second event to the application layer, based on the listener corresponding to the second event and based on the mapping relationship, multiple callback interfaces of the second event are determined and triggered sequentially, wherein one listener corresponds to one callback interface.
[0021] In one possible implementation, the first code file includes at least one of the following:
[0022] AIDL Interface Specification, which defines at least one of the methods, parameters and return values of an AIDL interface;
[0023] AIDL sub-files, which are used to describe the structure of AIDL interfaces;
[0024] First code data, the first code data is used to implement the application-side service connection function and / or connection retry function;
[0025] Multiple AIDL interfaces, wherein the multiple AIDL interfaces include at least one of a service initialization interface, an event listener registration interface, an event value retrieval interface, and an event value modification interface;
[0026] The second code data is used to manage interface calls and callback listeners.
[0027] In one possible implementation, the second code file includes at least one of the following:
[0028] AIDL Interface Specification, which defines at least one of the methods, parameters and return values of an AIDL interface;
[0029] AIDL sub-files, which are used to describe the structure of AIDL interfaces;
[0030] Multiple AIDL interfaces, wherein the multiple AIDL interfaces include at least one of a service initialization interface, an event listener registration interface, an event value retrieval interface, and an event value modification interface;
[0031] An abstract class, which inherits from the service class in the service layer, is used to implement abstract services;
[0032] The third code data is used to handle event callbacks.
[0033] On the other hand, a vehicle is provided, the vehicle including a processor and a memory, the memory storing at least one piece of program code, the at least one piece of program code being loaded and executed by the processor to implement the in-vehicle application implementation method as described in any of the above implementations.
[0034] On the other hand, a computer-readable storage medium is provided, wherein at least one piece of program code is stored in the computer-readable storage medium, the at least one piece of program code being loaded and executed by a processor to implement the vehicle application implementation method as described in any of the above implementations.
[0035] On the other hand, a computer program product is provided, the computer program product including at least one piece of program code, the at least one piece of program code being loaded and executed by a processor to implement the vehicle application implementation method as described in any of the above implementations.
[0036] The beneficial effects of the technical solutions provided in this application include at least the following:
[0037] This application provides a method for implementing an in-vehicle application. This method adds an adaptation layer to the in-vehicle system, which interfaces with the service layer. The application layer calls the service layer by calling the adaptation layer. In this way, the interface called by the application layer is fixed, so that the interface called by the application layer does not change with the service layer in the in-vehicle system. Only different adaptation layers need to be configured for the service layer in different in-vehicle systems, so that application developers only need to develop one version, reducing development costs and shortening the development cycle. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 This is a schematic diagram of an in-vehicle system provided in an embodiment of this application;
[0040] Figure 2 This is a flowchart of a method for implementing an in-vehicle application provided in an embodiment of this application;
[0041] Figure 3 This is a schematic diagram of the structure of a vehicle provided in an embodiment of this application. Detailed Implementation
[0042] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0043] The terms "first," "second," "third," and "fourth," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0044] It should be noted that all information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in this disclosure are authorized by the user or fully authorized by all parties. The collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the service call requests and events involved in this application were obtained with full authorization.
[0045] The vehicle application implementation method provided in this application embodiment is executed by the vehicle system. In some embodiments, such as Figure 1 As shown, the in-vehicle system includes an application layer, an adaptation layer, and a service layer. The application layer runs multiple applications, each including a first code file that provides Java interfaces and AIDL (Android Interface Definition Language) interfaces. The adaptation layer includes a second code file that provides abstract services inherited from the services in the service layer and also provides AIDL interfaces. Thus, when the application layer needs to call a service in the service layer, it can first call the AIDL interface in the application layer through the Java interface, then call the AIDL interface in the adaptation layer through the application layer's AIDL interface, and finally call the abstract service in the adaptation layer through the AIDL interface in the adaptation layer. Since the abstract services in the adaptation layer inherit from the services in the service layer, calling the abstract services in the adaptation layer allows the invocation of the corresponding services in the service layer.
[0046] In the application development architecture, each application needs to interface with the service layer's Framework (FW) interface to call services in the service layer. However, different vehicle systems use different interface specifications for their service layers, requiring application developers to create multiple different application versions for different interface specifications. The vehicle system provided in this application introduces an adaptation layer between the application layer and the service layer. This adaptation layer, based on the AIDL interface specification, encapsulates the interface communication between the application layer and the adaptation layer. This encapsulation not only standardizes the communication method but also allows for the dynamic addition of interfaces. Therefore, the adaptation work of the service layer is centralized in the adaptation layer, unifying the adaptation process across different vehicle systems. Thus, the problem caused by the different interface specifications of the service layers of different vehicle systems is solved.
[0047] AIDL is an interface definition language for the Android platform used to describe the interfaces used for communication between different processes. It allows developers to define interface methods for interaction between clients and servers, including input parameters, output parameters, and return values. Based on these interface definitions, AIDL generates Java classes for data transfer and method calls between different processes. AIDL is primarily used to solve communication problems between different processes in Android applications, especially in cases involving inter-process communication (IPC).
[0048] AIDL Interface Definition: Each application explicitly defines its functionality and data transmission methods, achieving this through AIDL interfaces. These interfaces generate corresponding Java classes during the compilation phase, thus supporting cross-process communication. To ensure interface standardization and improve ease of use, this embodiment creates a set of encapsulation interface specifications between the application layer and the adaptation layer based on the AIDL interfaces. This helps provide a unified interface for the application layer, while the adaptation layer provides corresponding service capabilities. In this embodiment, this encapsulation specification is integrated into a single JAR file for easy use by application developers.
[0049] Inter-process communication: Java classes generated through AIDL enable cross-process communication between different modules. This allows different applications to run in independent processes, achieving a high degree of isolation and modularity.
[0050] Dynamic expansion: New applications can be seamlessly integrated with existing modules by defining interfaces that conform to the AIDL specification. This approach enhances the scalability of the in-vehicle system, making it easier to introduce new features.
[0051] Figure 2 This is a flowchart illustrating a method for implementing an in-vehicle application according to an embodiment of this application. This embodiment uses a vehicle as the executing entity for illustrative purposes. The vehicle runs an in-vehicle system, which includes an application layer, an adaptation layer, and a service layer. The application layer runs multiple applications, each including a first code file that provides Java and AIDL interfaces. The adaptation layer includes a second code file that provides abstract services inherited from services in the service layer and also provides AIDL interfaces. Figure 2 As shown, the method includes:
[0052] 201. When any application receives a service call request, the vehicle calls the AIDL interface of the adaptation layer through the Java interface and AIDL interface provided by the first code file of that application.
[0053] In this embodiment, a set of encapsulation interface specifications between the application layer and the adaptation layer is created based on the AIDL interface. This will help provide a unified interface for the application layer, while the adaptation layer provides corresponding service capabilities. In this embodiment, this encapsulation specification is integrated into a single JAR file, with the first and second code files being this JAR file.
[0054] In one possible implementation, the first code file includes at least one of the following:
[0055] (1) AIDL Interface Specification: This AIDL interface specification defines at least one of the methods, parameters, and return values of the AIDL interface. (2) AIDL Subfile: The AIDL subfile describes the structure of the AIDL interface. (3) First Code Data: The first code data is used to implement the application-side service connection function and / or connection retry function. (4) Multiple AIDL Interfaces: Multiple AIDL interfaces include at least one of the following: service initialization interface, event listener registration interface, event value retrieval interface, and event value modification interface. (5) Second Code Data: The second code data is used to manage interface calls and callback listeners.
[0056] It should be noted that in this embodiment of the application, the AIDL interface will generate a corresponding Java interface during the compilation stage. Therefore, although the first code file only includes the AIDL interface specification and AIDL sub-files, after the vehicle system is running, the AIDL interface will generate a corresponding Java interface during the compilation stage. Therefore, the first code file can provide both the AIDL interface and the Java interface.
[0057] In some embodiments, the first code file includes second code data, which provides multiple listeners for implementing callback listening. Optionally, the first code file further provides multiple listeners; after calling the AIDL interface of the adaptation layer through the Java interface and AIDL interface provided by the first code file of any application, the method further includes: after capturing a first event through any listener, establishing a mapping relationship between the first event and the listener that listened to the first event; after listening to the callback of the first event through any listener, determining multiple callback interfaces of the first event based on the mapping relationship, and triggering the multiple callback interfaces sequentially, wherein one listener corresponds to one callback interface. This approach effectively manages and calls multiple listeners, ensuring that all relevant callbacks are executed after the event is triggered.
[0058] In one possible implementation, abstract services can only be invoked after being registered in the manifest file. The method also includes: after the in-vehicle system is running, creating a target service that integrates multiple abstract services from a second code file through an adaptation layer, and registering the target service in the manifest file. Subsequently, the corresponding abstract service can be invoked based on the manifest file.
[0059] In one possible implementation, the second code file includes at least one of the following: (1) an AIDL interface specification, which defines at least one of the methods, parameters, and return values of the AIDL interface. (2) an AIDL sub-file, which describes the structure of the AIDL interface. (3) multiple AIDL interfaces, which include at least one of a service initialization interface, an event listener registration interface, an event value retrieval interface, and an event value modification interface. (4) an abstract class, which inherits from the service class in the service layer and is used to implement the abstract service. (5) third code data, which is used to handle event callbacks.
[0060] Both the first code file and the second code file include an AIDL interface specification, an AIDL sub-file, and multiple AIDL interfaces. Furthermore, the AIDL interface specification and the AIDL sub-file in the first code file are identical, and the multiple AIDL interfaces in the first code file correspond one-to-one with the multiple AIDL interfaces in the second code file. This enables the application layer and the adaptation layer to communicate based on the first code file and the second code file.
[0061] In this embodiment, the first code file provides a Java interface and an AIDL interface, wherein the Java interface is generated during the compilation of the AIDL interface. The vehicle calls the AIDL interface of the adaptation layer through the Java interface and AIDL interface provided by the first code file of any application, including: the vehicle calling the AIDL interface provided by the first code file through the Java interface provided by the first code file of any application; and calling the AIDL interface of the adaptation layer through the AIDL interface provided by the first code file. The Java interface and AIDL interface in the first code file are in one-to-one correspondence, and the AIDL interface in the first code file and the AIDL interface in the second code file are set by the developers during the development process.
[0062] 202. The vehicle calls the abstract service of the adaptation layer through the AIDL interface of the adaptation layer.
[0063] Specifically, when calling the AIDL interface of the adaptation layer through the Java interface and AIDL interface provided in the first code file of the application, corresponding parameters are carried. Based on the corresponding parameters, it can be determined which abstract service in the adaptation layer to call.
[0064] In one possible implementation, the second code file includes third code data, which provides multiple listeners for handling event callbacks. In some embodiments, the second code file further provides multiple listeners; the method further includes: after a second event is captured by any listener, establishing a mapping relationship between the second event and the listeners that captured the second event; when the adaptation layer needs to send a callback message corresponding to the second event to the application layer, based on the listeners corresponding to the second event and based on the mapping relationship, determining multiple callback interfaces for the second event, and triggering the multiple callback interfaces sequentially, wherein one listener corresponds to one callback interface. This approach effectively manages and invokes multiple listeners, ensuring that all relevant callbacks are executed after the event is triggered.
[0065] 203. The vehicle calls services in the service layer through the abstract service of the adaptation layer.
[0066] In one possible implementation, multiple event schedulers are registered in the service layer. It's important to note that after defining the event scheduler, it must be registered in the service layer to function correctly. Each event scheduler has a defined event handling scope, handling only events within that specific scope, thus achieving modular management. The method also includes registering multiple event schedulers in the target service, each handling a specific type of event. The vehicle invokes services in the service layer through the abstract service of the adaptation layer, including: invoking the corresponding event scheduler through the abstract service of the adaptation layer; and invoking services in the service layer through that event scheduler.
[0067] This application provides a method for implementing an in-vehicle application. This method adds an adaptation layer to the in-vehicle system, which interfaces with the service layer. The application layer calls the service layer by calling the adaptation layer. In this way, the interface called by the application layer is fixed, so that the interface called by the application layer does not change with the service layer in the in-vehicle system. Only different adaptation layers need to be configured for the service layer in different in-vehicle systems, so that application developers only need to develop one version, reducing development costs and shortening the development cycle.
[0068] The process of generating the first and second code files includes the following steps:
[0069] 1. Define the interface specification: Clearly define the interface specification that needs to be encapsulated, including the interface's methods, parameters, return values, etc.
[0070] 2. Create AIDL sub-files: Based on the defined interface specification, create the corresponding AIDL sub-files. The AIDL sub-files are used to describe the structure of the AIDL interface, and the corresponding JAVA interface will be generated during compilation.
[0071] 3. Write the first set of code data, which is used to implement the application-side service connection function and / or connection retry function. The connection operations between the application layer and the adaptation layer services are handled uniformly at the communication layer; the application layer does not need to concern itself with service connections.
[0072] 4. Encapsulate application call interfaces: establish service initialization interfaces, register event listener interfaces, obtain event value interfaces, and modify event value interfaces, etc.
[0073] 5. Management of application-layer interface calls and callback listeners (i.e., writing second-level code data): In actual development, an event often needs to be captured by multiple listeners simultaneously. This embodiment uses a Map data structure, with the event as the key and the corresponding callback implementation as the value, storing these listeners in a mapping format. When a callback is received from the server, all corresponding callback implementations can be found in the Map based on the event, and then these callback interfaces are triggered sequentially. This method effectively manages and calls multiple listeners, ensuring that all relevant callbacks are executed after an event is triggered.
[0074] 6. Create an abstract class: This facilitates service implementation in the adaptation layer. In the communication JAR, an abstract class inherits from the service layer to handle client connection maintenance and event callbacks. Similarly, a Map data structure is used, where events are treated as keys and callbacks as values. When a callback message needs to be sent to the client, the event can be used as the key to locate all relevant callback implementations in the Map, and these callback interfaces can be triggered sequentially. This approach effectively manages multiple listeners, ensuring that all relevant callbacks are executed smoothly after an event is triggered.
[0075] 7. Generate a packaged JAR file: Based on steps 1, 2, 3, 4 and 5, it is packaged into a single JAR file, which is the first code file; based on steps 1, 2, 4 and 6, it is packaged into a single JAR file, which is the second code file.
[0076] Subsequently, the generated JAR file can be provided to application developers, who can then integrate it into their applications to easily communicate with the adaptation layer without needing to worry about the differences in service layers across different in-vehicle systems.
[0077] Figure 3 This is a schematic diagram of the structure of a vehicle provided in an embodiment of this application. Typically, the vehicle 300 includes a processor 301.
[0078] Processor 301 may include one or more computer-readable storage media, which may be non-transitory. In some embodiments, the non-transitory computer-readable storage media in processor 301 are used to store at least one piece of program code, which is executed by processor 901 to implement the operations performed by the vehicle in the vehicle application implementation method provided in the method embodiments of this application.
[0079] Those skilled in the art will understand that Figure 3 The structure shown does not constitute a limitation on vehicle 300 and may include more or fewer components than shown, or combine certain components, or use different component arrangements.
[0080] This application also provides a computer-readable storage medium storing at least one piece of program code, which is loaded and executed by a processor to implement the vehicle application implementation method as described in any of the above implementations.
[0081] This application also provides a computer program product, which includes at least one piece of program code, which is loaded and executed by a processor to implement the vehicle application implementation method as described in any of the above implementation methods.
[0082] The above are merely optional embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for implementing an in-vehicle application, characterized in that, The method is applied to an in-vehicle system, which includes an application layer, an adaptation layer, and a service layer. The application layer runs multiple applications, each including a first code file that provides Java and AIDL interfaces. The adaptation layer includes a second code file that provides abstract services inherited from services in the service layer and also provides AIDL interfaces. When any application receives a service call request, it calls the AIDL interface of the adaptation layer through the Java interface and AIDL interface provided by the first code file of the application. The AIDL interface of the adaptation layer is used to call the abstract service of the adaptation layer; The services in the service layer are invoked through the abstract services of the adaptation layer.
2. The method according to claim 1, characterized in that, The method further includes: After the vehicle system is running, a target service integrating multiple abstract services in the second code file is created through the adaptation layer, and the target service is registered in the manifest file.
3. The method according to claim 2, characterized in that, The method further includes: Multiple event schedulers are registered in the target service, and each event scheduler is used to handle a type of event. The process of calling services in the service layer through the abstract service of the adaptation layer includes: The corresponding event scheduler is invoked through the abstract service of the adaptation layer; The event scheduler invokes the services in the service layer.
4. The method according to claim 1, characterized in that, The first code file is also used to provide multiple listeners; after calling the AIDL interface of the adaptation layer through the Java interface and AIDL interface provided by the first code file of any application, the method further includes: After the first event is captured by any listener, a mapping relationship is established between the first event and the listener that captured the first event; After the callback of the first event is detected by any listener, multiple callback interfaces of the first event are determined based on the mapping relationship, and the multiple callback interfaces are triggered in sequence, wherein one listener corresponds to one callback interface.
5. The method according to claim 1, characterized in that, The second code file is also used to provide multiple listeners; the method further includes: After the second event is captured by any listener, a mapping relationship is established between the second event and the listener that captured the second event; When the adaptation layer needs to send a callback message corresponding to the second event to the application layer, based on the listener corresponding to the second event and based on the mapping relationship, multiple callback interfaces of the second event are determined and triggered sequentially, wherein one listener corresponds to one callback interface.
6. The method according to claim 1, characterized in that, The first code file includes at least one of the following: AIDL Interface Specification, which defines at least one of the methods, parameters and return values of an AIDL interface; AIDL sub-files, which are used to describe the structure of AIDL interfaces; First code data, the first code data is used to implement the application-side service connection function and / or connection retry function; Multiple AIDL interfaces, wherein the multiple AIDL interfaces include at least one of a service initialization interface, an event listener registration interface, an event value retrieval interface, and an event value modification interface; The second code data is used to manage interface calls and callback listeners.
7. The method according to claim 1, characterized in that, The second code file includes at least one of the following: AIDL Interface Specification, which defines at least one of the methods, parameters and return values of an AIDL interface; AIDL sub-files, which are used to describe the structure of AIDL interfaces; Multiple AIDL interfaces, wherein the multiple AIDL interfaces include at least one of a service initialization interface, an event listener registration interface, an event value retrieval interface, and an event value modification interface; An abstract class, which inherits from the service class in the service layer, is used to implement abstract services; The third code data is used to handle event callbacks.
8. A vehicle, characterized in that, The vehicle includes a processor and a memory, the memory storing at least one piece of program code, which is loaded and executed by the processor to implement the in-vehicle application implementation method as described in any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one piece of program code, which is loaded and executed by a processor to implement the vehicle application implementation method as described in any one of claims 1-7.
10. A computer program product, characterized in that, The computer program product includes at least one piece of program code, which is loaded and executed by a processor to implement the in-vehicle application implementation method as described in any one of claims 1-7.
Citation Information
Patent Citations
Cross-application data collection method based on AIDL language
CN110808952A
Communication method and device, electronic equipment and storage medium
CN114579334A