Service providing method, device, electronic device, storage medium and computer program product
By establishing a transfer node between the first container and the second container, non-Android operating systems can remotely call Android operating system hardware services, which solves the problem of being unable to directly call Android hardware resources under non-Android systems and improves the speed of hardware functions. Adaptation and efficiency.
Patent Information
- Application Number
- CN202410902864.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-07-05
AI Technical Summary
Android hardware resources cannot be directly called under non-Android operating systems, resulting in complex and inefficient hardware function adaptation.
By running the first operating system in the first container and running the Android operating system in the second container, the transfer node is used to enable the first operating system to remotely call hardware services in the second operating system, thereby accessing hardware resources.
It achieves rapid adaptation of the hardware functions of the first operating system, simplifies the cross-container hardware resource calling process, and improves efficiency.
Smart Images

Figure CN118445032B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and more particularly, to a service providing method, apparatus, electronic device, storage medium, and computer program product. Background Art
[0002] With the development of container virtualization technology and the continuous improvement of embedded system technology, it has become possible to run two or even more containers on embedded hardware platforms. Typically, containers running on a computer are isolated from each other and independently perform their functions. Furthermore, communication between containers can be achieved over the network.
[0003] At present, the hardware drivers provided by hardware manufacturers basically support the Android system. Among them, most graphics and multimedia related drivers or driver calling libraries are closed source and do not match non-Android operating systems. This will result in the inability to directly call these hardware resources under non-Android operating systems. Summary of the Invention
[0004] The present disclosure provides a service provision method, apparatus, electronic device, storage medium, and computer program product to at least solve the problem in the above-mentioned related technologies that these hardware resources cannot be directly called under non-Android operating systems.
[0005] According to a first aspect of an embodiment of the present disclosure, a service providing method is provided, which is applied to a service platform, wherein the service platform runs at least a first container and a second container, wherein a first operating system runs in the first container, and a second operating system different from the first operating system runs in the second container, comprising: obtaining a call request sent by the first operating system in the first container, wherein the call request is used to call a target hardware service of the second operating system in the second container; determining a target switching node under the second container that matches the target hardware service, wherein the switching node is used to implement communication between the first container and the second container; sending the call request from the first container to the second container by accessing the target switching node; sending the target hardware service result from the second container to the first container by accessing the target switching node, wherein the hardware service result is a result generated by the second operating system in the second container executing the target hardware service in response to the call request.
[0006] Optionally, the first container contains a first virtual node corresponding to the target transit node, and the second container contains a second virtual node corresponding to the target transit node; the sending of the call request from the first container to the second container by accessing the target transit node includes: sending the call request to the target transit node by accessing the first virtual node; sending the call request to the second virtual node through the target transit node to send the call request to the second operating system; the sending of the target hardware service result from the second container to the first container by accessing the target transit node includes: sending the hardware service result to the target transit node through the second virtual node; sending the hardware service result to the first container through the target transit node.
[0007] Optionally, the first container includes multiple first virtual nodes, the second container includes multiple second virtual nodes, and multiple transfer nodes corresponding one-to-one to the multiple second virtual nodes are set under the second container. Each transfer node communicates with one of the multiple first virtual nodes, and the multiple transfer nodes are applied to different types of hardware services.
[0008] Optionally, the first container includes a target mapping relationship library, which includes mapping relationships between the multiple first virtual nodes and the multiple transfer nodes; and further includes: determining the first virtual node corresponding to the target transfer node through the target mapping relationship library.
[0009] Optionally, the first container includes multiple mapping relationship libraries, and the target mapping relationship library is one of the multiple mapping relationship libraries; the first container further includes environment variables, and the environment variables are set to make the calling priority of the target mapping relationship library the highest.
[0010] Optionally, before obtaining the call request sent by the first operating system in the first container, it also includes: creating the first virtual node in the first container, and associating the created first virtual node with the target transit node, wherein the node name of the first virtual node is different from the node name of the corresponding target transit node.
[0011] Optionally, the first operating system is a non-Android system, the second operating system is an Android system, and the target hardware service is a service for accessing an Android hardware library provided by the Android system.
[0012] According to a second aspect of an embodiment of the present disclosure, a service providing device is provided, which is applied to a service platform, wherein the service platform runs at least a first container and a second container, wherein a first operating system runs in the first container, and a second operating system different from the first operating system runs in the second container, including: a call request acquisition module, configured to acquire a call request sent by the first operating system in the first container, wherein the call request is used to call a target hardware service of the second operating system in the second container; a transfer node determination module, configured to determine a target transfer node under the second container that matches the target hardware service, wherein the transfer node is used to implement communication between the first container and the second container; a request forwarding module, configured to send the call request from the first container to the second container by accessing the target transfer node; a service result acquisition module, configured to send the target hardware service result from the second container to the first container by accessing the target transfer node, wherein the hardware service result is a result generated by the second operating system in the second container executing the target hardware service in response to the call request.
[0013] Optionally, the first container contains a first virtual node corresponding to the target transit node, and the second container contains a second virtual node corresponding to the target transit node; the request forwarding module is configured to: send the call request to the target transit node by accessing the first virtual node; send the call request to the second virtual node through the target transit node to send the call request to the second operating system; the service result acquisition module is configured to: send the hardware service result to the target transit node through the second virtual node; send the hardware service result to the first container through the target transit node.
[0014] Optionally, the first container includes multiple first virtual nodes, the second container includes multiple second virtual nodes, and multiple transfer nodes corresponding one-to-one to the multiple second virtual nodes are set under the second container. Each transfer node communicates with one of the multiple first virtual nodes, and the multiple transfer nodes are applied to different types of hardware services.
[0015] Optionally, the first container includes a target mapping relationship library, which includes mapping relationships between the multiple first virtual nodes and the multiple transit nodes; the service providing device also includes: a virtual node determination module, which is configured to determine the first virtual node corresponding to the target transit node through the target mapping relationship library.
[0016] Optionally, the first container includes multiple mapping relationship libraries, and the target mapping relationship library is one of the multiple mapping relationship libraries; the first container further includes environment variables, and the environment variables are set to make the calling priority of the target mapping relationship library the highest.
[0017] Optionally, the service providing device also includes: an association module, configured to create the first virtual node in the first container, and associate the created first virtual node with the target transit node, wherein the node name of the first virtual node is different from the node name of the corresponding target transit node.
[0018] Optionally, the first operating system is a non-Android system, the second operating system is an Android system, and the target hardware service is a service for accessing an Android hardware library provided by the Android system.
[0019] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing execution instructions; wherein the processor is configured to execute the instructions to implement the service providing method according to the present disclosure.
[0020] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the service providing method according to the present disclosure.
[0021] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program, which implements the service providing method according to the present disclosure when executed by a processor.
[0022] The technical solutions provided by the embodiments of the present disclosure bring at least the following beneficial effects:
[0023] In the present disclosure, by running a first operating system in a first container and a second operating system in a second container, and connecting the first and second containers through a switching node, the first operating system can remotely call services in the second operating system, that is, call the second operating system driver to access hardware resources, which can ensure rapid adaptation of the hardware functions of the first operating system.
[0024] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute an improper limitation of the present disclosure.
[0026] Figure 1 is a flowchart illustrating a service providing method according to an exemplary embodiment of the present disclosure;
[0027] Figure 2 is a schematic diagram illustrating a system communication architecture between LXC containers according to an exemplary embodiment of the present disclosure;
[0028] Figure 3 is a schematic diagram illustrating the corresponding association between a first virtual node and a transit node according to an exemplary embodiment of the present disclosure;
[0029] Figure 4 is a schematic diagram illustrating another system communication architecture between LXC containers according to an exemplary embodiment of the present disclosure;
[0030] Figure 5 is a schematic diagram illustrating obtaining a service result from a second operating system in response to a call request according to an exemplary embodiment of the present disclosure;
[0031] Figure 6 is a block diagram illustrating a service providing apparatus according to an exemplary embodiment of the present disclosure;
[0032] Figure 7 is a block diagram illustrating an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0033] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0034] It should be noted that the terms "first," "second," and the like in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the numbers used in this manner are interchangeable where appropriate so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The implementation methods described in the following examples do not represent all implementation methods consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with certain aspects of the present disclosure as detailed in the appended claims.
[0035] It should be noted that the phrase "at least one of the several items" in this disclosure includes three types of parallel situations: "any one of the several items", "a combination of any multiple of the several items", and "all of the several items". For example, "including at least one of A and B" includes the following three parallel situations: (1) including A; (2) including B; (3) including A and B. For another example, "performing at least one of step 1 and step 2" means the following three parallel situations: (1) performing step 1; (2) performing step 2; and (3) performing both step 1 and step 2.
[0036] OpenHarmony, short for OpenAtom OpenHarmony, is an open source project of the Hongmeng operating system. In addition to supporting the LiteOS kernel, the OpenHarmony system also supports the Linux kernel using a standard system. In this way, OpenHarmony can be used not only in small systems, but also in more complex large systems, so as to better meet the needs of all aspects. OpenHarmony's standard system is aimed at devices with application processors such as Arm Cortex-A, and supports devices with a minimum memory of 128MiB. It can provide enhanced interactivity, 3D GPU and hardware synthesis capabilities, more controls and richer graphics capabilities, and a complete application framework. At present, due to incomplete hardware driver adaptation, the hardware capabilities of some chips have not been fully utilized, such as the hardware encoding and decoding capabilities of multimedia.
[0037] Since containers running on computers are usually isolated from each other, communication between containers usually uses the network, mainly including the following: access through the container IP; access through the host machine's IP:port; access through link establishment connection; create a bridge network through User-defined networks, and containers in the same bridge network can access each other.
[0038] In the related art, the hardware drivers provided by hardware manufacturers basically support the Android system. Among them, the graphics and multimedia-related drivers or the libraries that call the drivers are mostly closed source and incompatible with non-Android operating systems. For example, they are incompatible with the aforementioned Hongmeng system. This results in the inability to directly call these hardware resources under non-Android operating systems. In addition, although containers can communicate through the network, network communication between containers is usually initiated and received at the application layer, which cannot directly operate hardware devices and obtain hardware data. This makes the process of calling hardware resources across containers complicated and inefficient.
[0039] To address the aforementioned issues in related technologies, the present disclosure provides a service provision method, apparatus, electronic device, storage medium, and computer program product. By running a first operating system in a first container and a second operating system in a second container, and connecting the first and second containers via a transfer node, the first operating system can remotely call services in the second operating system. That is, the second operating system driver can be called to access hardware resources, ensuring rapid adaptation of the first operating system's hardware functions.
[0040] Below, some technical terms involved in this disclosure are explained.
[0041] LXC, short for Linux Containers, is an operating system-level virtualization technology and a userspace interface for the Linux kernel's container functionality. It packages application software systems into a container, containing the application code and the required operating system kernel and libraries. This allows for the allocation of available hardware resources between different containers through a unified namespace and shared APIs, creating independent sandboxed execution environments for applications. This makes it easy for Linux users to create and manage system or application containers.
[0042] Halium is a collaborative project that aims to unify the hardware abstraction layer for projects running Linux on mobile devices pre-installed with Android. The project aims to standardize the middleware software used by various projects to communicate with the Android daemon and utilize the hardware on the installed device. It will be distributed as free and open source software under a mixed software license.
[0043] Binder is an inter-process communication mechanism and remote system call method unique to Android. In other words, one Android process can call a routine in another Android process, and can use binder to identify the method to be called and pass parameters between processes.
[0044] Hybris or libhybris is mainly used to solve the compatibility problem of libc library. That is, its purpose is to run libraries compiled with bionic (mainly closed-source HAL libraries under Android) on systems based on GNU C library.
[0045] Figure 1This is a flowchart illustrating a service provision method according to an exemplary embodiment of the present disclosure, which is applied to a service platform. The service platform can run at least a first container and a second container. The first container can run a first operating system, and the second container can run a second operating system different from the first operating system.
[0046] Reference Figure 1 In step 101, a call request sent by a first operating system in a first container may be obtained, wherein the call request may be used to call a target hardware service of a second operating system in a second container. Exemplarily, a call request generated by a target application in the first container may be obtained. Exemplarily, the first operating system may be HarmonyOS. Figure 2 1 is a schematic diagram showing a system communication architecture between lxc containers according to an exemplary embodiment of the present disclosure. Figure 2 The system communication architecture between LXC containers is mainly composed of Openharmony system container (hereinafter referred to as OH container), Android system container (hereinafter referred to as Halium container), binder device and driver, libhybris and other parts.
[0047] It should be noted that the OpenHarmony standard system typically runs directly on the Linux kernel. However, through container virtualization technology, it can also be run in a Linux-based container, that is, the OpenHarmony standard system can be run in the aforementioned OH container. The OH container can be placed in the foreground, and users running the OpenHarmony standard system in the OH container will have the same experience as running the OpenHarmony standard system directly on the Linux kernel.
[0048] The second operating system runs in the above-mentioned Android system container, that is, the halium container. Exemplarily, the second operating system can be a streamlined Android system that can provide basic access to the Android hardware library. The vendor partition provided by the hardware manufacturer can be mounted in the halium container. This partition is extracted from the complete Android image and can contain the Android libraries and services required for hardware device drivers. Since these libraries and services are generated based on the bionic library, Openharmony cannot use them directly. Through the lightweight halium container, the operation problems of Android libraries and services can be solved without taking up too many hardware resources.
[0049] The above-mentioned "libhybris" can be used to solve the compatibility problem of the libc library. The present disclosure can use the libhybris library in the OH container, can call the Android library in the OH environment, and can communicate with the service in the Halium container through the binder device driver.
[0050] According to an exemplary embodiment of the present disclosure, a first virtual node may be created in the first container, and the created first virtual node may be associated with a target transit node, wherein the node name of the first virtual node may be different from the node name of the corresponding target transit node.
[0051] Figure 3 1 is a schematic diagram showing the corresponding association between the first virtual node and the transit node according to an exemplary embodiment of the present disclosure. Figure 3 The OH container can contain the gst-droid multimedia plug-in, libhybris, and libubinder libraries. The gst-droid multimedia plug-in can change the way multimedia hardware calls in the Openharmony system are called from directly through the Openharmony HAL layer to calling the Android library through libhybris.
[0052] Figure 3 At least one transfer node is set outside the halium container, namely " / dev / binder", " / dev / hwbinder", and " / dev / vndbinder". In addition, at least one first virtual node is also set in the OH container, namely " / dev / u-binder" and " / dev / u-hwbinder". In addition, the first virtual node " / dev / u-binder" can have a mapping relationship with the transfer node " / dev / binder"; the first virtual node " / dev / u-hwbinder" can have a mapping relationship with the transfer node " / dev / hwbinder".
[0053] In addition, the node name of the first virtual node " / dev / u-binder" is: " / dev / u-binder", which is different from the node name of the corresponding transfer node " / dev / binder": " / dev / binder"; the node name of the first virtual node " / dev / u-hwbinder" is " / dev / u-hwbinder", which is different from the node name of the corresponding transfer node " / dev / hwbinder": " / dev / hwbinder". Specifically, the libubinder library can be added to the OH container, which changes the node name for accessing the binder device when calling the Android library in Openharmony. That is, at least one first virtual node obtained after renaming at least one transfer node can be created in the OH container, and the created first virtual node can be associated with the corresponding transfer node. In this way, when using the above-mentioned system communication architecture to make cross-container resource calls, there is no need to modify the core code of the OH container and the halium container, which is convenient for porting and maintenance.
[0054] In step 102, a target transit node matching the target hardware service under the second container may be determined, wherein the transit node may be used to implement communication between the first container and the second container.
[0055] In step 103, the call request may be sent from the first container to the second container by accessing the target transit node.
[0056] In step 104, the target hardware service result may be sent from the second container to the first container by accessing the target transit node, wherein the hardware service result may be a result generated by the second operating system in the second container executing the target hardware service in response to the call request.
[0057] According to an exemplary embodiment of the present disclosure, the first operating system may be a non-Android system, the second operating system may be an Android system, and the target hardware service may be a service for accessing an Android hardware library provided by the Android system.
[0058] According to an exemplary embodiment of the present disclosure, the target hardware service may be a camera service (cameraservice) or a multimedia service (mediaservice).
[0059] According to an exemplary embodiment of the present disclosure, the first container may include a first virtual node corresponding to the target transit node, and the second container may include a second virtual node corresponding to the target transit node.
[0060] The call request can be sent to the target transit node by accessing the first virtual node. The call request can then be sent to the second virtual node via the target transit node to send the call request to the second operating system. Next, the hardware service result can be sent to the target transit node via the second virtual node. The hardware service result can then be sent to the first container via the target transit node.
[0061] Specifically, as mentioned above, the above-mentioned first container can contain at least one first virtual node: " / dev / u-binder" and " / dev / u-hwbinder"; the second container can correspond to at least one transit node " / dev / binder", " / dev / hwbinder", and " / dev / vndbinder"; at least one first virtual node can have a one-to-one correspondence with at least one transit node, and the above-mentioned target transit node can be one of the at least one transit nodes.
[0062] A first virtual node corresponding to the target transit node in at least one first virtual node can be determined. For example, after obtaining the call request generated by the target application in the first container, the service to be accessed by the call request can be determined first, and then which transit node should be used to provide the service based on the service to be accessed. It should be noted that the types of services provided by different transit nodes may be different from each other. Therefore, the type of service to be accessed by the call request can be determined first, and then a transit node capable of providing the corresponding type of service can be found based on the type of service to be accessed to provide the service. It is assumed that the transit node " / dev / binder" will be used to provide the service.
[0063] Then, the first virtual node corresponding to the target transit node " / dev / binder" among the at least one first virtual node can be determined. As previously described, a mapping relationship exists between the first virtual node " / dev / u-binder" in the OH container and the target transit node " / dev / binder". Therefore, the first virtual node corresponding to the target transit node " / dev / binder" can be determined to be " / dev / u-binder".
[0064] Next, the target transit node can be accessed by accessing the first virtual node, and the service result can be obtained from the second operating system using the target transit node. That is, the target transit node " / dev / binder" can be accessed by accessing the first virtual node " / dev / u-binder", and the service of accessing the Android hardware library can be obtained from the Android system using the target transit node " / dev / binder".
[0065] Furthermore, the second container may further include at least one second virtual node, and the at least one second virtual node may correspond one-to-one with the at least one transit node. Furthermore, the at least one second virtual node may be a mapped virtual node with the same name as the at least one transit node, i.e., the second virtual node and the corresponding transit node may have the same name.
[0066] For example, refer to Figure 4 , Figure 4 It is a schematic diagram showing another system communication architecture between LXC containers according to an exemplary embodiment of the present disclosure. There is at least one corresponding transfer node under the Halium container, namely " / dev / binder", " / dev / hwbinder", and " / dev / vndbinder". In addition, the Halium container may include a mapping virtual node " / dev / binder" with the same name corresponding to the transfer node " / dev / binder", a mapping virtual node " / dev / hwbinder" with the same name corresponding to the transfer node " / dev / hwbinder", and a mapping virtual node " / dev / vndbinder" with the same name corresponding to the transfer node " / dev / vndbinder".
[0067] The target transfer node can be accessed by accessing the first virtual node, and the second virtual node corresponding to the target transfer node in at least one second virtual node can be accessed through the target transfer node to receive the service result obtained by the second operating system using the second virtual node. For example, assuming that the target transfer node is " / dev / hwbinder", the second virtual node corresponding to the target transfer node " / dev / hwbinder" in at least one second virtual node contained in the halium container, that is, the mapping virtual node " / dev / hwbinder" with the same name can be accessed through the target transfer node " / dev / hwbinder" to receive the service result obtained by the Android system using the mapping virtual node " / dev / hwbinder" with the same name.
[0068] Return to reference Figure 4 In the same kernel, two binder devices can be set up, one for the OH container and the other for the Halium container. Specifically, the Halium container can have at least one corresponding transfer node: " / dev / binder", " / dev / hwbinder", or " / dev / vndbinder". These transfer nodes can also correspond to at least one first virtual node " / dev / u-binder" and " / dev / u-hwbinder" in the OH container.
[0069] In addition, the OH container may also include a virtual node " / dev / binder" for internal use within the OH container. This virtual node " / dev / binder" may be mapped to " / dev / OH-binder" outside the OH container. That is, when the OH container wants to access services in the first operating system running in the OH container, it can access the node " / dev / OH-binder" outside the OH container by accessing the virtual node " / dev / binder". Furthermore, " / dev / OH-binder" can obtain service results from the first operating system and return the service results to the OH container.
[0070] In this way, by using the mount -o bind method, at container startup, at least one first virtual node is created within the first container by renaming at least one transit node. This achieves cross-mapping of binder device nodes, ensuring conflict between the Openharmony system and the Android system when accessing / dev / binder while providing a bridge for the OH container to access the Halum container. Furthermore, by leveraging the binder communication mechanism, inter-system communication efficiency can be improved.
[0071] According to exemplary embodiments of the present disclosure, as previously described, a first container may include multiple first virtual nodes, a second container may include multiple second virtual nodes, and the second container may be provided with multiple transit nodes corresponding one-to-one to the multiple second virtual nodes. Each transit node may communicate with one of the multiple first virtual nodes, and the multiple transit nodes may be applied to different types of hardware services.
[0072] According to an exemplary embodiment of the present disclosure, the first container may further include a target mapping relationship library, which may include mapping relationships between multiple first virtual nodes and multiple transit nodes. The target mapping relationship library may also be used to determine the first virtual node corresponding to the target transit node.
[0073] According to an exemplary embodiment of the present disclosure, the first container may include multiple mapping relationship libraries, and the target mapping relationship library may be one of the multiple mapping relationship libraries. The first container may also include an environment variable, and the environment variable may be set to give the target mapping relationship library the highest call priority.
[0074] Specifically, the target mapping relationship library may be a libubinder library, which may include a mapping relationship between at least one first virtual node and at least one transit node. Furthermore, the first container may also include an environment variable "HYBRIS_LD_LIBRARY_PATH," which may specify a call priority for each of the multiple mapping relationship libraries, with the target mapping relationship library having the highest call priority.
[0075] It should be noted that the OH container contains directories mounted from the Halium container. These directories contain a libbinder library, which can contain a mapping relationship between at least one transfer node under the Halium container and at least one virtual node mapped with the same name. Among them, "same-name mapping" means that the name of the mapped virtual node is the same as the name of the mapped node.
[0076] For example, the mapping virtual node with the same name corresponding to the transfer node " / dev / binder" can be " / dev / binder"; the mapping virtual node with the same name corresponding to the transfer node " / dev / hwbinder" can be " / dev / hwbinder"; the mapping virtual node with the same name corresponding to the transfer node " / dev / vndbinder" can be " / dev / vndbinder".
[0077] Normally, when the OH container wants to access a service, it will call the libbinder library by default. Assuming the OH container currently wants to call the transfer node " / dev / binder" under the Halium container, the virtual node recorded in the default libbinder library that has a mapping relationship with the transfer node " / dev / binder" is " / dev / binder," and the node " / dev / OH-binder" outside the OH container has a mapping relationship with the virtual node " / dev / binder" within the OH container. At this point, the OH container will access the " / dev / OH-binder" node by accessing the virtual node " / dev / binder" found in the default libbinder library to access the service in the first operating system. However, the node that the OH container actually wants to access is actually the transfer node " / dev / binder" under the Halium container, meaning that the OH container will be unable to access the service it really wants to access.
[0078] To address these shortcomings, the present disclosure configures the "HYBRIS_LD_LIBRARY_PATH" environment variable in the OH container, adds the / opt / android / lib / ubinder path to the first position, and creates a soft link with the same name as the libbinder library in this path, pointing to the libbinder library. This allows the OH container to prioritize Android libraries in the / opt / android / lib / ubinder directory when accessing services through hybris, based on the call priority (i.e., the order) specified by the "HYBRIS_LD_LIBRARY_PATH" environment variable.
[0079] As mentioned above, the mapping relationship between at least one virtual node obtained by renaming at least one transfer node and at least one transfer node recorded in the libubinder library, that is, the first virtual node created in the OH container is renamed. Therefore, when the OH container wants to call the transfer node " / dev / binder" under the halium container, it can be determined that the virtual node corresponding to the transfer node " / dev / binder" under the halium container that is actually to be accessed is the first virtual node " / dev / u-binder" based on the mapping relationship contained in the target mapping relationship library with the highest call priority indicated by the above-mentioned environment variable: "first virtual node " / dev / u-binder" - transfer node " / dev / binder" under the halium container. Then, the transfer node " / dev / binder" under the halium container can be accessed by accessing the first virtual node " / dev / u-binder", which means that the OH container can access the service that it really wants to access.
[0080] It can be seen that in the present disclosure, the library function directory index order can be configured through the "HYBRIS_LD_LIBRARY_PATH" environment variable, thereby enabling the calling of library files with the same name but different contents in two containers to avoid conflicts.
[0081] Figure 5 FIG. 1 is a schematic diagram illustrating obtaining a service result from a second operating system in response to a call request according to an exemplary embodiment of the present disclosure. Figure 5The OH container can contain both OH libraries and Android libraries. OH libraries can include the gst-droid multimedia plugin, libcamera_commom, and libhybris_commom. "libcamera_commom" is a general library for camera functions, while "libhybris_commom" is a general library for libhybris. Android libraries can include libcamera_compat_layer, libcamera_client, and libubinder. The gst-droid multimedia plugin changes the way multimedia hardware is called in the Openharmony system from directly calling Openharmony's Halium layer to calling the Android library in the Halium container through libhybris.
[0082] This disclosure provides a communication architecture between an OH container and a Halium container running on an embedded platform. The OH container can remotely invoke hardware services in the Halium container through the libhybris interface and the binder device. This allows remote invocation of Android drivers to access hardware resources. This allows for rapid adaptation of the Openharmony system to new hardware platforms, resolving the issue of being unable to use Android hardware drivers in the Openharmony system.
[0083] Figure 6 is a block diagram illustrating a service providing apparatus according to an exemplary embodiment of the present disclosure.
[0084] Reference Figure 6 The service providing device 600 may include a call request obtaining module 601 , a transfer node determining module 602 , a request forwarding module 603 and a service result obtaining module 604 .
[0085] The call request acquisition module 601 can acquire a call request sent by the first operating system in the first container, wherein the call request can be used to invoke a target hardware service of the second operating system in the second container. Exemplarily, the call request generated by the target application in the first container can be acquired.
[0086] According to an exemplary embodiment of the present disclosure, the service providing apparatus may further include an association module. The association module may create a first virtual node within the first container and associate the created first virtual node with a target transit node, wherein the node name of the first virtual node may be different from the node name of the corresponding target transit node.
[0087] The transfer node determination module 602 may determine a target transfer node matching the target hardware service under the second container, wherein the transfer node may be used to implement communication between the first container and the second container.
[0088] The request forwarding module 603 may send the call request from the first container to the second container by accessing the target transit node.
[0089] The service result acquisition module 604 can send the target hardware service result from the second container to the first container by accessing the target transfer node, wherein the hardware service result can be the result generated by the second operating system in the second container executing the target hardware service in response to the call request.
[0090] According to an exemplary embodiment of the present disclosure, the first operating system may be a non-Android system, the second operating system may be an Android system, and the target hardware service may be a service for accessing an Android hardware library provided by the Android system.
[0091] According to an exemplary embodiment of the present disclosure, the target hardware service may be a camera service or a multimedia service.
[0092] According to an exemplary embodiment of the present disclosure, the first container may include a first virtual node corresponding to the target transit node, and the second container may include a second virtual node corresponding to the target transit node.
[0093] The request forwarding module 603 can send the call request to the target transit node by accessing the first virtual node. The request forwarding module 603 can then send the call request to the second virtual node via the target transit node to send the call request to the second operating system. Next, the service result acquisition module 604 can send the hardware service result to the target transit node via the second virtual node. The service result acquisition module 604 can then send the hardware service result to the first container via the target transit node.
[0094] According to exemplary embodiments of the present disclosure, as previously described, a first container may include multiple first virtual nodes, a second container may include multiple second virtual nodes, and the second container may be provided with multiple transit nodes corresponding one-to-one to the multiple second virtual nodes. Each transit node may communicate with one of the multiple first virtual nodes, and the multiple transit nodes may be applied to different types of hardware services.
[0095] According to an exemplary embodiment of the present disclosure, the first container may further include a target mapping relationship library, which may include mapping relationships between multiple first virtual nodes and multiple transit nodes. The target mapping relationship library may also be used to determine the first virtual node corresponding to the target transit node.
[0096] According to an exemplary embodiment of the present disclosure, the first container may include multiple mapping relationship libraries, and the target mapping relationship library may be one of the multiple mapping relationship libraries. The first container may also include an environment variable, and the environment variable may be set to give the target mapping relationship library the highest call priority.
[0097] Figure 7 is a block diagram illustrating an electronic device 700 according to an exemplary embodiment of the present disclosure.
[0098] Reference Figure 7 The electronic device 700 includes at least one memory 701 and at least one processor 702. The at least one memory 701 stores instructions. When the instructions are executed by the at least one processor 702, the service providing method according to the exemplary embodiment of the present disclosure is executed.
[0099] As an example, electronic device 700 may be a PC, tablet device, personal digital assistant, smartphone, or other device capable of executing the aforementioned instructions. Here, electronic device 700 is not necessarily a single electronic device, but may also be any collection of devices or circuits capable of executing the aforementioned instructions (or instruction sets) individually or in combination. Electronic device 700 may also be part of an integrated control system or system manager, or may be configured as a portable electronic device that interfaces with local or remote devices (e.g., via wireless transmission).
[0100] In electronic device 700, processor 702 may include a central processing unit (CPU), a graphics processing unit (GPU), a programmable logic device, a dedicated processor system, a microcontroller, or a microprocessor. By way of example and not limitation, the processor may also include an analog processor, a digital processor, a microprocessor, a multi-core processor, a processor array, a network processor, and the like.
[0101] The processor 702 can execute instructions or codes stored in the memory 701, wherein the memory 701 can also store data. Instructions and data can also be sent and received over the network via the network interface device, wherein the network interface device can use any known transmission protocol.
[0102] The memory 701 may be integrated with the processor 702, for example, by placing RAM or flash memory within an integrated circuit microprocessor or the like. Furthermore, the memory 701 may comprise a separate device, such as an external disk drive, a storage array, or any other storage device usable by a database system. The memory 701 and the processor 702 may be operatively coupled or may communicate with each other, for example, via an I / O port, a network connection, or the like, such that the processor 702 can access files stored in the memory.
[0103] In addition, the electronic device 700 may further include a video display (such as a liquid crystal display) and a user interaction interface (such as a keyboard, a mouse, a touch input device, etc.) All components of the electronic device 700 may be connected to each other via a bus and / or a network.
[0104] According to an exemplary embodiment of the present disclosure, a computer-readable storage medium may also be provided, which, when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the above-mentioned service providing method. Examples of computer-readable storage media include: read-only memory (ROM), random access programmable read-only memory (PROM), electrically erasable programmable read-only memory (EEPROM), random access memory (RAM), dynamic random access memory (DRAM), static random access memory (SRAM), flash memory, non-volatile memory, CD-ROM, CD-R, CD+R, CD-RW, CD+RW, DVD-ROM, DVD-R, DVD+R, DVD-RW, DVD+RW, DVD-RAM, BD-ROM, BD-R, BD-R LTH, BD-RE, Blu-ray or optical disk storage, hard disk drive (HDD), solid state drive (SSD), card storage (such as a multimedia card, secure digital (SD) card or extreme digital (XD) card), magnetic tape, floppy disk, magneto-optical data storage device, optical data storage device, hard disk, solid state disk and any other device configured to store a computer program and any associated data, data files and data structures in a non-transitory manner and provide the computer program and any associated data, data files and data structures to a processor or computer so that the processor or computer can execute the computer program. The computer program in the above-mentioned computer-readable storage medium can be executed in an environment deployed in a computer device such as a client, a host, an agent device, a server, etc. In addition, in one example, the computer program and any associated data, data files and data structures are distributed on a networked computer system so that the computer program and any associated data, data files and data structures are stored, accessed and executed in a distributed manner by one or more processors or computers.
[0105] According to exemplary embodiments of the present disclosure, a computer program product may also be provided, including a computer program, which implements the service providing method according to the present disclosure when executed by a processor.
[0106] According to the service provision method, apparatus, electronic device, storage medium, and computer program product of the present disclosure, by running a first operating system in a first container and a second operating system in a second container, and connecting the first and second containers via a switching node, the first operating system can remotely call services in the second operating system. That is, the second operating system driver can be called to access hardware resources, ensuring rapid adaptation of the hardware functions of the first operating system.
[0107] According to an exemplary embodiment of the present disclosure, when using the above-mentioned system communication architecture to perform cross-container resource calls, there is no need to modify the core codes of the OH container and the Halium container, which facilitates transplantation and maintenance.
[0108] According to an exemplary embodiment of the present disclosure, at container startup, at least one first virtual node can be created within the first container by renaming at least one transfer node using the mount -o bind method. This achieves cross-mapping of binder device nodes, ensuring conflict-free access between the Openharmony system and the Android system when accessing / dev / binder while also providing a bridge for the OH container to access the Halum container. Furthermore, by leveraging the binder communication mechanism, inter-system communication efficiency can be improved.
[0109] According to an exemplary embodiment of the present disclosure, the library function directory index order can be configured through the "HYBRIS_LD_LIBRARY_PATH" environment variable, thereby enabling the calling of library files with the same name but different contents in two containers to avoid conflicts.
[0110] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.
[0111] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A service providing method, applied to a service platform, wherein the service platform runs at least a first container and a second container, wherein the first container runs a first operating system, and the second container runs a second operating system different from the first operating system, characterized in that: include: Obtaining a call request sent by the first operating system in the first container, wherein the call request is used to call a target hardware service of the second operating system in the second container; Determine a target transfer node under the second container that matches the target hardware service, wherein the transfer node is used to implement communication between the first container and the second container; By accessing the target transit node, sending the call request from the first container to the second container; By accessing the target transit node, sending the target hardware service result from the second container to the first container, wherein the hardware service result is a result generated by the second operating system in the second container executing the target hardware service in response to the call request; The first container includes a first virtual node corresponding to the target transit node, and the second container includes a second virtual node corresponding to the target transit node; The first container includes a plurality of first virtual nodes, the second container includes a plurality of second virtual nodes, a plurality of transfer nodes corresponding to the plurality of second virtual nodes are arranged under the second container, and each transfer node communicates with a first virtual node among the plurality of first virtual nodes; The first container includes a target mapping relationship library, and the target mapping relationship library includes mapping relationships between the multiple first virtual nodes and the multiple transfer nodes; Also includes: Determine, through the target mapping relationship library, a first virtual node corresponding to the target transit node; The first container includes a plurality of mapping relationship libraries, the target mapping relationship library is one of the plurality of mapping relationship libraries, the plurality of mapping relationship libraries further include a libbinder library, the libbinder library includes mapping relationships between the plurality of transfer nodes and a plurality of virtual nodes mapped based on the same names of the plurality of transfer nodes, and the virtual nodes mapped with the same names have corresponding nodes outside the first container, and the nodes corresponding to the virtual nodes mapped with the same names outside the first container are used to access services in the first operating system; The first container also includes environment variables, and the environment variables are set to make the calling priority of the target mapping relationship library the highest.
2. The service providing method according to claim 1, characterized in that: The step of sending the call request from the first container to the second container by accessing the target transit node includes: By accessing the first virtual node, sending the call request to the target transit node; Sending the call request to the second virtual node through the target transit node to send the call request to the second operating system; The step of sending the target hardware service result from the second container to the first container by accessing the target transfer node comprises: Sending the hardware service result to the target transfer node through the second virtual node; The hardware service result is sent to the first container through the target transit node.
3. The service providing method according to claim 2, wherein: The multiple transfer nodes are applied to different types of hardware services.
4. The service providing method according to claim 2, wherein: Before obtaining the call request sent by the first operating system in the first container, the method further includes: The first virtual node is created in the first container, and the created first virtual node is associated with the target transit node, wherein the node name of the first virtual node is different from the node name of the corresponding target transit node.
5. The service providing method according to claim 1, wherein: The first operating system is a non-Android system, the second operating system is an Android system, and the target hardware service is a service for accessing an Android hardware library provided by the Android system.
6. A service providing device, applied to a service platform, wherein the service platform runs at least a first container and a second container, wherein the first container runs a first operating system, and the second container runs a second operating system different from the first operating system, characterized in that: include: a call request acquisition module, configured to acquire a call request sent by the first operating system in the first container, wherein the call request is used to call a target hardware service of the second operating system in the second container; a transfer node determination module, configured to determine a target transfer node under the second container that matches the target hardware service, wherein the transfer node is used to implement communication between the first container and the second container; a request forwarding module, configured to send the call request from the first container to the second container by accessing the target transit node; a service result acquisition module, configured to send a target hardware service result from the second container to the first container by accessing the target transit node, wherein the hardware service result is a result generated by the second operating system in the second container executing the target hardware service in response to the call request; The first container includes a first virtual node corresponding to the target transit node, and the second container includes a second virtual node corresponding to the target transit node; The first container includes a plurality of first virtual nodes, the second container includes a plurality of second virtual nodes, a plurality of transfer nodes corresponding to the plurality of second virtual nodes are arranged under the second container, and each transfer node communicates with a first virtual node among the plurality of first virtual nodes; The first container includes a target mapping relationship library, and the target mapping relationship library includes mapping relationships between the multiple first virtual nodes and the multiple transfer nodes; The service providing device also includes: A virtual node determination module is configured to determine a first virtual node corresponding to the target transit node through the target mapping relationship library; The first container includes a plurality of mapping relationship libraries, the target mapping relationship library is one of the plurality of mapping relationship libraries, the plurality of mapping relationship libraries further include a libbinder library, the libbinder library includes mapping relationships between the plurality of transfer nodes and a plurality of virtual nodes mapped based on the same names of the plurality of transfer nodes, and the virtual nodes mapped with the same names have corresponding nodes outside the first container, and the nodes corresponding to the virtual nodes mapped with the same names outside the first container are used to access services in the first operating system; The first container also includes environment variables, and the environment variables are set to make the calling priority of the target mapping relationship library the highest.
7. An electronic device, characterized in that: include: processor; a memory for storing execution instructions; The processor is configured to execute the instructions to implement the service providing method as claimed in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the service providing method as claimed in any one of claims 1 to 5.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the service providing method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Linux and Android coexistence and interaction method based on Feiteng platform and shared kernel
CN110618876A
Method and device for software operating system to call Android HIDL interface, equipment and medium
CN114077462A
