Disclosure of Invention
The embodiment of the application provides a vehicle-mounted application implementation method, a vehicle and a storage medium, so that an application developer only needs to develop one version, the development cost is reduced, and the development period is shortened. The technical scheme is as follows:
In one aspect, there is provided a vehicle-mounted application implementation method, applied to a vehicle-mounted system, the vehicle-mounted system including an application layer, an adaptation layer, and a service layer, the application layer running a plurality of applications, each application including a first code file for providing a Java interface and an AIDL interface, the adaptation layer including a second code file for providing an abstract service inherited from a service in the service layer and for providing an AIDL interface, the method comprising:
when any application receives a service call request, calling an AIDL interface of the adaptation layer through a Java interface and an AIDL interface provided by a first code file of any application;
invoking abstract services of the adaptation layer through an AIDL interface of the adaptation layer;
and calling the service in the service layer through the abstract service of the adaptation layer.
In one possible implementation, the method further includes:
After the vehicle-mounted system operates, a target service integrating a plurality of abstract services in the second code file is created through the adaptation layer, and the target service is registered in a manifest file.
In one possible implementation, the method further includes:
registering a plurality of event schedulers in the target service, wherein each event scheduler is used for processing one type of event;
The method for calling the service in the service layer through the abstract service of the adaptation layer comprises the following steps:
Calling a corresponding event dispatcher through the abstract service of the adaptation layer;
and calling the service in the service layer through the event dispatcher.
In one possible implementation manner, the first code file is further used for providing a plurality of listeners, and after the Java interface and the AIDL interface provided by the first code file of any application call the AIDL interface of the adaptation layer, the method further comprises:
after capturing a first event by any monitor, establishing a mapping relation between the first event and the monitor monitoring the first event;
After any monitor monitors callback of the first event, determining a plurality of callback interfaces of the first event based on the mapping relation, and sequentially triggering the callback interfaces, wherein one monitor corresponds to one callback interface.
In one possible implementation, the second code file is further configured to provide a plurality of listeners, and the method further includes:
After capturing a second event by any monitor, establishing a mapping relation between the second event and the monitor monitoring the second event;
And when the adaptation layer needs to send a callback message corresponding to the second event to the application layer, determining a plurality of callback interfaces of the second event based on the monitor corresponding to the second event and the mapping relation, and triggering the callback interfaces in sequence, wherein one monitor corresponds to one callback interface.
In one possible implementation, the first code file includes at least one of:
An AIDL interface specification for defining at least one of a method, parameters, and return values of an AIDL interface;
An AIDL subfile, the AIDL subfile describing a structure of an AIDL interface;
The first code data are used for realizing an application end service connection function and/or a connection retry function;
a plurality of AIDL interfaces including at least one of a set-up service initialization interface, a registration event listening interface, an acquisition event value interface, and a modification event value interface;
And the second code data is used for managing interface call and callback monitoring.
In one possible implementation, the second code file includes at least one of the following:
An AIDL interface specification for defining at least one of a method, parameters, and return values of an AIDL interface;
An AIDL subfile, the AIDL subfile describing a structure of an AIDL interface;
a plurality of AIDL interfaces including at least one of a set-up service initialization interface, a registration event listening interface, an acquisition event value interface, and a modification event value interface;
The abstract class is inherited from the service class in the service layer and is used for realizing abstract service;
and third code data for processing event callbacks.
In another aspect, a vehicle is provided, the vehicle including a processor and a memory, the memory having stored therein at least one program code, the at least one program code loaded and executed by the processor to implement an in-vehicle application implementation method as described in any of the above implementations.
In another aspect, a computer readable storage medium is provided, in which at least one program code is stored, the at least one program code being loaded and executed by a processor to implement the vehicle-mounted application implementation method according to any of the above-mentioned implementations.
In another aspect, a computer program product is provided, the computer program product comprising at least one piece of program code, the at least one piece of program code being loaded and executed by a processor to implement an in-vehicle application implementation method as described in any of the implementations above.
The technical scheme provided by the embodiment of the application has the beneficial effects that at least:
The embodiment of the application provides a vehicle-mounted application implementation method, which is characterized in that an adaptation layer is added in a vehicle-mounted system, the adaptation layer is abutted against a service layer, and the application layer realizes the call of services in the service layer by calling the adaptation layer, so that the interface called by the application layer is fixed, the interface called by the application layer is not changed along with the change of the service layer in the vehicle-mounted system, and only different adaptation layers are configured for the service layers in different vehicle-mounted systems, so that an application developer only needs to develop one version, the development cost is reduced, and the development period is shortened.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application will be described in further detail with reference to the accompanying drawings.
The terms "first," "second," "third," and "fourth" and the like in the description and in the claims and drawings are used for distinguishing between different objects and not necessarily for describing a particular sequential or chronological order. Furthermore, the terms "comprising," "including," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus.
It should be noted that, information (including but not limited to user equipment information, user personal information, etc.), data (including but not limited to data for analysis, stored data, presented data, etc.), and signals related to the present disclosure are all authorized by the user or are fully authorized by the parties. The collection, use and processing of relevant data requires compliance with relevant national and regional laws and regulations. For example, service invocation requests, events, etc. referred to in the present application are all acquired with sufficient authorization.
The implementation method of the vehicle-mounted application provided by the embodiment of the application is executed by the vehicle-mounted system. In some embodiments, as shown in FIG. 1, the in-vehicle system includes an application layer, an adaptation layer, and a service layer. The application layer runs a plurality of applications, each application comprises a first code file, the first code file is used for providing Java interfaces and AIDL (Android Interface Definition Language ) interfaces, the adaptation layer comprises a second code file, the second code file is used for providing abstract services inherited from services in the service layer and is used for providing AIDL interfaces, and therefore when the application layer needs to call services in the service layer, the application layer can call the AIDL interfaces in the application layer through Java interfaces in the application layer, call the AIDL interfaces in the adaptation layer through AIDL interfaces in the application layer, and call the abstract services in the adaptation layer through AIDL interfaces in the adaptation layer. Since the abstract services in the adaptation layer are inherited from the services in the service layer, by invoking the abstract services in the adaptation layer, the corresponding services in the service layer can be invoked.
In the development architecture of applications, each application needs to interface with a Framework (FW) interface of the service layer to invoke a service in the service layer through the FW interface. However, different interface specifications are adopted by service layers of different vehicle-mounted systems, so that application developers need to develop a plurality of different application versions aiming at the different interface specifications. The vehicle-mounted system provided by the embodiment of the application introduces the adaptation layer between the application layer and the service layer, the adaptation layer is based on the AIDL interface specification, the interface communication between the application layer and the adaptation layer is encapsulated, and the encapsulation not only can realize the standardization of the communication mode, but also can dynamically add the interface. Therefore, the adaptation work of the service layer is concentrated on the adaptation layer, so that the adaptation process of each vehicle-mounted system is unified. Accordingly, the problem caused by the difference of interface specifications of service layers of different in-vehicle systems is solved.
AIDL is an interface definition language on the Android platform that describes the interfaces used for communication between different processes. It allows a developer to define an interface method for interaction between a client and a server, including input parameters, output parameters, and return values. The AIDL generates Java classes for data transfer and method invocation between different processes based on the interface definition. AIDL is mainly used to solve the communication problem between different processes in Android applications, especially in cases involving inter-process communication (IPC).
The AIDL interface defines that each application definitely defines the function and the data transmission mode, and the aim is achieved through the AIDL interface. These interfaces generate corresponding Java classes at the compilation stage to support cross-process communication. In order to ensure standardization of the interface and improve the use convenience of the interface, in the embodiment of the application, a set of encapsulation interface specifications between an application layer and an adaptation layer are created on the basis of the AIDL interface. This will help to provide a unified interface for the application layer, while the adaptation layer provides corresponding service capabilities. In the embodiment of the application, the packaging specification is integrated into a jar file so as to be convenient for application developers to use.
Cross-process communication, namely, cross-process communication can be carried out among different modules through Java classes generated by AIDL. In this way, different applications can run in separate processes, achieving a high degree of isolation and modularity.
Dynamic extension-new applications can be seamlessly integrated with existing modules by defining interfaces that conform to the AIDL specification. In this way, the expandability of the in-vehicle system is improved, and new functions can be more easily introduced into the in-vehicle system.
Fig. 2 is a flowchart of a method for implementing a vehicle-mounted application according to an embodiment of the present application, where a vehicle is used as an execution body and a vehicle-mounted system is operated in the vehicle, and the vehicle-mounted system includes an application layer, an adaptation layer and a service layer. The application layer runs a plurality of applications, each application comprising a first code file for providing a Java interface and an AIDL interface, the adaptation layer comprising a second code file for providing abstract services inherited from services in the service layer and for providing an AIDL interface. As shown in fig. 2, the method includes:
201. when any application receives a service call request, the vehicle calls an AIDL interface of the adaptation layer through a Java interface and an AIDL interface provided by a first code file of the any application.
In the embodiment of the application, a set of encapsulation interface specifications between an application layer and an adaptation layer are created on the basis of an AIDL interface. This will help to provide a unified interface for the application layer, while the adaptation layer provides corresponding service capabilities. In the embodiment of the application, the package specification is integrated into a jar file, and the first code file and the second code file are the jar file.
In one possible implementation, the first code file includes at least one of:
(1) An AIDL interface specification for defining at least one of a method, parameters, and return values of an AIDL interface. (2) An AIDL subfile, which is used to describe the structure of the AIDL interface. (3) And the first code data is used for realizing an application end service connection function and/or a connection retry function. (4) The system comprises a plurality of AIDL interfaces, wherein the AIDL interfaces comprise at least one of a service initialization interface, a registration event monitoring interface, an acquisition event value interface and a modification event value interface; (5) second code data for managing interface calls and callback snoops.
It should be noted that, in the embodiment of the present application, the AIDL interface generates a corresponding Java interface in the compiling stage, so, although the first code file only includes the AIDL interface specification and the AIDL subfiles, after the vehicle system operates, the AIDL interface generates a corresponding Java interface in the compiling stage, and thus, the first code file may provide the AIDL interface and the Java interface.
In some embodiments, the first code file includes second code data for providing a plurality of listeners through which callback listening is implemented. Optionally, the first code file is further used for providing a plurality of listeners, after the Java interface and the AIDL interface provided by the first code file of any application call the AIDL interface of the adaptation layer, the method further comprises the steps of establishing a mapping relation between the first event and the listeners listening to the first event after the first event is captured by any one of the listeners, and determining a plurality of callback interfaces of the first event based on the mapping relation after the callback of the first event is listened to by any one of the listeners, and triggering the callback interfaces in sequence, wherein one of the listeners corresponds to one callback interface. By the method, a plurality of listeners can be effectively managed and called, and all relevant callbacks are ensured to be executed after the event is triggered.
In one possible implementation, the abstract service is registered in the manifest file before it can be invoked. The method further includes creating, by the adaptation layer, a target service integrating the plurality of abstract services in the second code file after the in-vehicle system is running, and registering the target service in the manifest file. Subsequently, a corresponding abstract service may be invoked based on the manifest file.
In one possible implementation, the second code file includes at least one of (1) an AIDL interface specification for defining at least one of a method, a parameter, and a return value of the AIDL interface. (2) An AIDL subfile, which is used to describe the structure of the AIDL interface. (3) The system comprises a plurality of AIDL interfaces including at least one of a set-up service initialization interface, a registration event listening interface, an acquisition event value interface, and a modification event value interface. (4) The abstract class inherits from the service class in the service layer and is used for realizing abstract service. (5) And the third code data is used for processing event callback.
The first code file and the second code file each comprise an AIDL interface specification, an AIDL sub-file and a plurality of AIDL interfaces, the AIDL interface specification in the first code file is the same as the AIDL sub-file, and the plurality of AIDL interfaces in the first code file and the plurality of AIDL interfaces in the second code file are in one-to-one correspondence, so that the application layer and the adaptation layer can communicate based on the first code file and the second code file.
In the embodiment of the application, the first code file provides a Java interface and an AIDL interface, wherein the Java interface is generated in the compiling process of the AIDL interface. The vehicle calls the AIDL interface of the adaptation layer through the Java interface and the AIDL interface provided by the first code file of any application, comprising that the vehicle calls the AIDL interface provided by the first code file through the Java interface provided by the first code file of any application; the AIDL interface of the adaptation layer is called through the AIDL interface provided by the first code file. The Java interfaces in the first code file and the AIDL interfaces in the second code file are in one-to-one correspondence, and the AIDL interfaces in the first code file and the AIDL interfaces in the second code file are correspondingly set by a developer in the development process.
202. The vehicle invokes the abstract services of the adaptation layer through the AIDL interface of the adaptation layer.
The Java interface and the AIDL interface provided by the first code file of the application carry corresponding parameters when the AIDL interface of the adaptation layer is called, and the abstract service in the adaptation layer can be determined to be called based on the corresponding parameters.
In one possible implementation, the second code file includes third code data for providing a plurality of listeners through which event callbacks are processed. In some embodiments, the second code file is further used for providing a plurality of listeners, the method further comprises the steps of after the second event is captured through any listener, establishing a mapping relation between the second event and the listeners which monitor the second event, and determining a plurality of callback interfaces of the second event based on the listeners corresponding to the second event and the mapping relation when the adaptation layer needs to send callback information corresponding to the second event to the application layer, and sequentially triggering the callback interfaces, wherein one listener corresponds to one callback interface. By the method, a plurality of listeners can be effectively managed and called, and all relevant callbacks are ensured to be executed after the event is triggered.
203. The vehicle invokes a service in the service layer through the abstract service of the adaptation layer.
In one possible implementation, a plurality of event schedulers are registered in the service layer, and it should be noted that the event schedulers need to be registered in the service layer after definition is completed, so that the event schedulers can be normally used. A corresponding event processing range is set for each event scheduler, and each event scheduler only processes events in a specific range, so that modular management is realized. The method further includes registering a plurality of event schedulers in the target service, each event scheduler for processing a class of events. The vehicle calls the service in the service layer through the abstract service of the adaptation layer, and the vehicle calls the corresponding event dispatcher through the abstract service of the adaptation layer, and calls the service in the service layer through the event dispatcher.
The embodiment of the application provides a vehicle-mounted application implementation method, which is characterized in that an adaptation layer is added in a vehicle-mounted system, the adaptation layer is abutted against a service layer, and the application layer realizes the call of services in the service layer by calling the adaptation layer, so that the interface called by the application layer is fixed, the interface called by the application layer is not changed along with the change of the service layer in the vehicle-mounted system, and only different adaptation layers are configured for the service layers in different vehicle-mounted systems, so that an application developer only needs to develop one version, the development cost is reduced, and the development period is shortened.
The generation process of the first code file and the second code file comprises the following steps:
1. interface specification-interface specification to be explicitly defined, the interface specification including method, parameters, return values, etc. of the interface.
2. Creating AIDL subfiles, namely creating corresponding AIDL subfiles according to defined interface specifications, wherein the AIDL subfiles are used for describing the structure of an AIDL interface and generating corresponding JAVA interfaces when compiling.
3. First code data is written, and the first code data is used for realizing an application end service connection function and/or a connection retry function. And the connection operation of the application layer and the adaptation layer service is uniformly processed in the communication layer, and the connection of the service is not required to be concerned for the application layer.
4. And (3) encapsulating the application calling interface, namely establishing a service initialization interface, registering an event monitoring interface, acquiring an event value interface, modifying the event value interface and the like.
5. In actual development, one event often needs to be captured by a plurality of listeners at the same time, and in order to adopt a Map data structure in the embodiment of the application, the event is used as a Key, the corresponding callback is realized as a Value, and the listeners are stored in a mapping form. After receiving the callback from the server, finding all callback implementations corresponding to the callback implementations in the Map according to the event, and then triggering the callback interfaces one by one in sequence. By the method, a plurality of listeners can be effectively managed and called, and all relevant callbacks are ensured to be executed after the event is triggered.
6. An abstract class is established, which is intended to facilitate the adaptation layer to implement the service. In communication jar, the created abstract class inherits from services in the service layer to handle connection maintenance and event callbacks for clients. Similarly, a Map data structure is employed in which events are treated as keys and callbacks are treated as values. When callback information needs to be carried out to the client, all related callback implementations can be positioned in the Map according to the event as a Key, and callback interfaces are triggered orderly one by one. By the method, a plurality of listeners can be effectively managed, and all related callbacks can be smoothly executed after the event is triggered.
7. And generating an encapsulation specification jar file, wherein the encapsulation specification jar file is packaged into a jar file based on steps 1,2, 3,4 and 5, namely a first code file, and is packaged into a jar file based on steps 1,2, 4 and 6, namely a second code file.
Subsequently, the generated jar file may be provided to an application developer, who may integrate the jar file into an application to easily communicate with the adaptation layer without concern for differences in service layers of different vehicle-mounted systems.
Fig. 3 is a schematic structural diagram of a vehicle according to an embodiment of the present application. In general, the vehicle 300 includes a processor 301.
The processor 301 may include one or more computer-readable storage media, which may be non-transitory. In some embodiments, a non-transitory computer readable storage medium in processor 301 is used to store at least one program code for execution by processor 901 to perform the operations performed by a vehicle in the in-vehicle application implementation method provided by the method embodiments of the present application.
Those skilled in the art will appreciate that the configuration shown in fig. 3 is not limiting of the vehicle 300 and may include more or fewer components than shown, or may combine certain components, or may employ a different arrangement of components.
The embodiment of the application also provides a computer readable storage medium, wherein at least one program code is stored in the computer readable storage medium, and the at least one program code is loaded and executed by a processor to realize the vehicle-mounted application implementation method according to any implementation mode.
Embodiments of the present application also provide a computer program product comprising at least one program code loaded and executed by a processor to implement a vehicle-mounted application implementation method as described in any of the above implementations.
The foregoing is illustrative of the present application and is not to be construed as limiting thereof, but rather as various modifications, equivalent arrangements, improvements, etc., which fall within the spirit and principles of the present application.