Disclosure of Invention
The embodiment of the invention provides a method, a device and a storage medium for calling an Android HIDL interface by a Linux system, and the Android HIDL interface can be called by a Linux program in a mode of being compatible with package binder calling.
In a first aspect of the embodiments of the present invention, a method for invoking an Android HIDL interface by a Linux system is provided, including:
calling an Android HAL interface and a compatible packaging library of the Android HAL interface by a Linux system program;
the HAL compatible packaging library is driven based on the Binder, inquires and obtains a client instance of the Android HAL Binder Service;
and calling a corresponding Android HIDL interface based on the client instance.
Optionally, in a possible implementation manner of the first aspect, after the step of invoking the corresponding Android HIDL interface based on the client instance, the method further includes:
and calling a corresponding result based on the Android HIDL interface, and returning the result to the HAL compatible packaging library through the Binder.
Optionally, in a possible implementation manner of the first aspect, after returning the result to the Linux Binder Client through the Binder, the method further includes:
and after receiving the result returned by the Binder, the HAL compatible encapsulation library returns the result to the Linux system program through a function.
Optionally, in a possible implementation manner of the first aspect, the manner of invoking the Android HIDL interface is driven based on the binder, and is used for implementing that the Linux program invokes the Android HIDL interface.
In a second aspect of the embodiments of the present invention, a device for invoking an Android HIDL interface in a Linux system is provided, including:
the Linux system calling module is used for enabling a Linux system program to call the Android HAL interface and the compatible packaging library of the Android HAL interface;
the Binder driving and calling module is used for enabling the HAL compatible packaging library to be based on Binder driving, inquiring and obtaining a client instance of the Android HAL Binder Service;
and the Android HIDL interface calling module is used for calling the corresponding Android HIDL interface based on the client instance.
Optionally, in a possible implementation manner of the second aspect, the method further includes:
and the return module is used for calling a corresponding result based on the Android HIDL interface and returning the result to the HAL compatible packaging library through the Binder.
Optionally, in a possible implementation manner of the second aspect, the method further includes:
the return module is further configured to perform steps comprising:
and after receiving the result returned by the Binder, the HAL compatible encapsulation library returns the result to the Linux system program through a function.
Optionally, in a possible implementation manner of the second aspect, the manner of invoking the Android HIDL interface is driven based on the binder, and is used for implementing that the Linux program invokes the Android HIDL interface.
In a third aspect of embodiments of the present invention, a computer-readable storage medium is provided, where computer instructions are stored, and the computer instructions are configured to cause the computer to execute the method for android operating environment building according to any one of the above first aspects.
In a fourth aspect of the embodiments of the present invention, there is provided an electronic device, including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to cause the at least one processor to perform the method of android runtime environment construction of any of the above first aspects.
The invention provides a method, a device and a storage medium for calling an Android HIDL interface by a Linux system.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein.
It should be understood that, in various embodiments of the present invention, the sequence numbers of the processes do not mean the execution sequence, and the execution sequence of the processes should be determined by the functions and the internal logic of the processes, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
It should be understood that in the present application, "comprising" and "having" and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be understood that, in the present invention, "a plurality" means two or more. "and/or" is merely an association describing an associated object, meaning that three relationships may exist, for example, and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "comprises A, B and C" and "comprises A, B, C" means that all three of A, B, C comprise, "comprises A, B or C" means that one of A, B, C comprises, "comprises A, B and/or C" means that any 1 or any 2 or 3 of A, B, C comprises.
It should be understood that in the present invention, "B corresponding to a", "a corresponds to B", or "B corresponds to a" means that B is associated with a, and B can be determined from a. Determining B from a does not mean determining B from a alone, but may be determined from a and/or other information. And the matching of A and B means that the similarity of A and B is greater than or equal to a preset threshold value.
As used herein, "if" may be interpreted as "at … …" or "when … …" or "in response to a determination" or "in response to a detection", depending on the context.
The technical solution of the present invention will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
In the technical scheme provided by the invention, Init is a command line program. One of its main tasks is to create a directory where these files interact with the kernel space. After the Linux kernel is loaded, the first thing to do is to call the init program, that is, the init is the first program executed by the user space.
Noun explanations and explanations regarding the technical solutions provided by the present invention:
android HAL: an Android hardware abstraction layer;
HIDL: the HAL Interface Definition Language (HIDL) is adapted to specify an Interface Description Language (IDL) between the HAL and its subscribers, the HIDL allowing to specify types and method calls;
a Binder: is one of the interprocess communication (IPC) modes of the Android system;
client: and (4) a client.
The invention provides a method for calling an Android HIDL interface by a Linux system, which comprises the following steps of:
and S110, calling the Android HAL interface and a compatible packaging library of the Android HAL interface by the Linux system program. The Linux system program calls the Android HAL interface and also calls the compatible packaging library of the HAL interface.
And S120, inquiring and obtaining the client instance of the Android HAL Binder Service by the HAL compatible packaging library based on Binder driving. And the HAL compatible packaging library is driven by the binder, inquires and obtains the client instance of the Android HAL binder Service.
And S130, calling a corresponding Android HIDL interface based on the client instance. And calling the corresponding HAL interface method through the client instance of the binder.
And step S140, calling a corresponding result based on the Android HIDL interface, and returning the result to the HAL compatible packaging library through the Binder. After receiving the request, the Client performs corresponding processing and returns the result to the Linux Binder Client through the Binder.
And S150, after receiving the result returned by the Binder, the HAL compatible encapsulation library returns the result to the Linux system program through a function. After the Linux system calls the Binder method, the Service corresponding to the Android HAL receives the relevant request. And after receiving the data returned by the Binder, the HAL compatible encapsulation library returns the relevant result through a function and returns the result to the Linux calling program.
According to the technical scheme provided by the invention, the mode of calling the Android HIDL interface based on the binder drive is used for realizing that the Linux program calls the Android HIDL interface. And the Android HIDL interface can be called by the Linux program in a manner of compatible packaging and calling by the binder.
The construction of the Android HAL + Linux system isolation environment ensures that the Android HAL and the Linux system can normally run without mutual interference. The Android HAL interface compatible method provided by the invention ensures that the Linux system can call the Android HAL interface. Thus, a boot Linux operating system on the Android HAL can be realized.
The present invention further provides a device for invoking the Android HIDL interface by the Linux system, as shown in fig. 3, including:
the Linux system calling module is used for enabling a Linux system program to call the Android HAL interface and the compatible packaging library of the Android HAL interface;
the Binder driving and calling module is used for enabling the HAL compatible packaging library to be based on Binder driving, inquiring and obtaining a client instance of the Android HAL Binder Service;
and the Android HIDL interface calling module is used for calling the corresponding Android HIDL interface based on the client instance.
In one embodiment, further comprising:
and the return module is used for calling a corresponding result based on the Android HIDL interface and returning the result to the HAL compatible packaging library through the Binder.
In one embodiment, further comprising:
the return module is further configured to perform steps comprising:
and after receiving the result returned by the Binder, the HAL compatible encapsulation library returns the result to the Linux system program through a function.
In one embodiment, the mode of calling the Android HIDL interface is driven based on the binder, and the method is used for realizing that the Linux program calls the Android HIDL interface.
The readable storage medium may be a computer storage medium or a communication medium. Communication media includes any medium that facilitates transfer of a computer program from one place to another. Computer storage media may be any available media that can be accessed by a general purpose or special purpose computer. For example, a readable storage medium is coupled to the processor such that the processor can read information from, and write information to, the readable storage medium. Of course, the readable storage medium may also be an integral part of the processor. The processor and the readable storage medium may reside in an Application Specific Integrated Circuits (ASIC). Additionally, the ASIC may reside in user equipment. Of course, the processor and the readable storage medium may also reside as discrete components in a communication device. The readable storage medium may be a read-only memory (ROM), a random-access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
The present invention also provides a program product comprising execution instructions stored in a readable storage medium. The at least one processor of the device may read the execution instructions from the readable storage medium, and the execution of the execution instructions by the at least one processor causes the device to implement the methods provided by the various embodiments described above.
In the above embodiments of the terminal or the server, it should be understood that the Processor may be a Central Processing Unit (CPU), other general-purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present invention may be embodied directly in a hardware processor, or in a combination of the hardware and software modules within the processor.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.