A Linux-compatible Android camera access method and device

By creating containers and virtual camera information on the Linux system, the problem of Android applications not being able to recognize and use USB cameras is solved, and the function of using cameras normally in Linux-compatible Android environments is realized, and the application ecosystem of the Linux operating system is expanded.

CN113448648BActive Publication Date: 2025-09-02JIDE TECH RES INST (WUHAN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110726443.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-29
Publication Date
2025-09-02
Estimated Expiration
2041-06-29

AI Technical Summary

Technical Problem

In a Linux-compatible Android environment, Android applications cannot recognize and use USB cameras, resulting in the inability to operate the front and rear cameras normally.

Method used

By creating containers on Linux systems, mounting the camera into the container, and enabling camera framework services on the Android side, filtering and virtual camera information, using the HAL layer cache and adding to the front and rear camera information list, enabling Android applications to access the camera.

Benefits of technology

It realizes that in a Linux-compatible Android environment, Android applications can use the USB camera and built-in camera of the Linux system normally, expanding the application ecosystem of the Linux operating system and providing a larger camera selection space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113448648B_ABST
    Figure CN113448648B_ABST
Patent Text Reader

Abstract

The present invention discloses a Linux-compatible Android camera access method and device. The method involves creating a container on Linux and mounting a Linux-based camera into the container. A camera framework service is enabled on the Android side, which polls and scans devices in the / dev directory to select cameras. The camera framework service sends a notification message to the HAL layer on the Android side, which caches camera information. The Android system's camera framework service virtualizes a single camera into a front camera and a rear camera. The camera framework service notifies the HAL layer of information about the virtual front and rear cameras via an interface, allowing Android applications to access the camera. This method plays an invaluable role in expanding the ecosystem of the Linux operating system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer operating systems, and in particular to a Linux-compatible Android camera access method and device. Background Art

[0002] As the Android application ecosystem has become the world's largest, cross-platform Android application development has become an industry trend. As we all know, the biggest problem with Linux desktop operating systems has always been the lack of an application ecosystem, which has prevented Linux desktop systems from becoming mainstream. Therefore, running Android applications on Linux desktop systems is becoming increasingly popular.

[0003] A Linux-compatible Android environment is a technology that allows Android applications to run on the Linux operating system, significantly enriching the Linux operating system's application ecosystem. A Linux-compatible Android environment generally consists of a host and a guest. The host runs on the Linux system and primarily includes the Android container and user interaction window. The Android container isolates some kernel resources from the Linux system to support the guest. The guest primarily includes a specially customized Android application framework and Android runtime library, and Android applications run on the guest.

[0004] PCs running a Linux operating system compatible with Android can have built-in cameras and external cameras connected via USB ports. However, these devices belong to the Linux system, and the Android environment in the container does not have access to them. Furthermore, PCs differ from mobile devices in many ways. Mobile devices lack USB ports and all have built-in cameras, with fixed camera hardware parameters. PCs, on the other hand, may not always have built-in cameras; they often support cameras through external USB ports, and USB cameras have a wide variety of hardware parameters. Currently, the Android system does not support USB cameras, which means that Android applications cannot use USB cameras in a Linux-compatible Android environment.

[0005] The Android system supports two types of cameras: one is the front camera and the other is the rear camera. Currently, all mobile devices on the market are equipped with two cameras, one for the front and one for the rear. However, when a USB camera is inserted into a PC with a Linux operating system compatible with the Android environment, the Android system cannot identify the type of camera and cannot operate the camera. Summary of the Invention

[0006] In order to solve the problem that in a Linux-compatible Android environment, an Android application can use the camera of the Linux system (including a USB camera and a built-in camera) to complete various functional operations of the front camera and the rear camera, the present invention provides a Linux-compatible Android camera access method and device.

[0007] On the one hand, the present invention provides a method for accessing a camera in a Linux-compatible Android environment. The method is applied in an operating environment in which an Android system is compatible with Linux, and the method comprises the following steps:

[0008] Step S1: Create a container on Linux and mount the camera on the Linux side into the container;

[0009] Step S2: Start a container on Linux and start the Android system in the container;

[0010] Step S3: Enable the camera framework service on the Android side, poll and scan the devices in the / dev directory, and filter out the cameras; the camera framework service sends a notification message to the HAL layer on the Android side, and the HAL layer caches the camera information;

[0011] Step S4: The camera framework service of the Android system virtualizes the single camera into a front camera and a rear camera. The camera framework service notifies the HAL layer of the information of the virtual front camera and rear camera through the interface, so that the camera of the Linux system is added to the front camera information list and rear camera information list of the HAL layer;

[0012] Step S5: The Android application accesses the camera according to the front camera information list and the rear camera information list.

[0013] Furthermore, the method enables the camera framework service on the Android side, polls and scans the devices in the / dev directory, and filters out the cameras, specifically including:

[0014] Enable the camera framework service on the Android side, poll and scan the devices in the / dev directory, first determine whether there are any devices in the / dev directory that are not processed by the system. If there are any devices that are not processed by the system, continue to determine whether the devices that are not processed by the system support the V42L specification. If there are no devices that are not processed by the system, end the scan; if the devices that are not processed by the system support the V42L specification, continue to determine the image capture capability of the device; if the devices that are not processed by the system do not support the V42L specification, continue to poll and scan the devices in the / dev directory; when the image capture capability of the device meets the system requirements, continue to determine whether the format of the device's acquired data is supported by the system; when the image capture capability of the device does not meet the system requirements, continue to poll and scan the devices in the / dev directory; if the format of the device's acquired data is supported by the system, cache the camera information; if the format of the device's acquired data is not supported by the system, continue to poll and scan the devices in the / dev directory until the scan is completed.

[0015] Furthermore, the camera framework service notifies the HAL layer of the information of the virtual front camera and rear camera through the interface, so that the camera of the Linux system is added to the front camera information list and rear camera information list of the HAL layer, specifically:

[0016] The camera framework service judges the virtual front camera information and rear camera information: if the virtual front camera information does not exist in the front camera information list, the virtual front camera information is added to the front camera information list, if it exists, it is not added; if the virtual rear camera information does not exist in the rear camera information list, the virtual rear camera information is added to the rear camera information list, if it exists, it is not added; the HAL layer notifies the camera framework service of the updated front camera information list and rear camera information list, and the camera framework service updates the camera information.

[0017] Furthermore, the step S1 creates a container on Linux and mounts the camera on the Linux side into the container, including: opening device permissions to the container when creating the container; and mounting the camera on the Linux side into the container through a control group.

[0018] Furthermore, step S5, in which the Android application accesses the camera according to the front camera information list and the rear camera information list, includes: when the Android application calls the camera, the camera framework service first determines whether the camera exists and whether the camera is occupied. If the camera exists and is not occupied, the HAL layer is notified, and the HAL layer opens the camera.

[0019] On the other hand, the present invention provides a Linux-compatible Android camera access device, which is applied in an operating environment compatible with the Android system running on Linux, and includes:

[0020] The container creation unit is used to create a container on Linux and mount the camera on the Linux side into the container;

[0021] The container startup unit is used to start the container on Linux and start the Android system in the container;

[0022] The camera information cache processing unit is used to: enable the camera framework service on the Android side, poll and scan the devices in the / dev directory, and filter out cameras; the camera framework service sends a notification message to the HAL layer on the Android side, and the HAL layer caches the camera information;

[0023] The virtual camera unit is used to: The Android system's camera framework service virtualizes a single camera into a front camera and a rear camera. The camera framework service notifies the HAL layer of the information of the virtual front camera and rear camera through the interface, so that the Linux system's camera is added to the HAL layer's front camera information list and rear camera information list;

[0024] Access the camera unit, which is used for: Android applications to access the camera based on the front camera information list and the rear camera information list.

[0025] Furthermore, the camera information cache processing unit is used to:

[0026] Enable the camera framework service on the Android side, poll and scan the devices in the / dev directory, first determine whether there are any devices in the / dev directory that are not processed by the system. If there are any devices that are not processed by the system, continue to determine whether the devices that are not processed by the system support the V42L specification. If there are no devices that are not processed by the system, end the scan; if the devices that are not processed by the system support the V42L specification, continue to determine the image capture capability of the device; if the devices that are not processed by the system do not support the V42L specification, continue to poll and scan the devices in the / dev directory; when the image capture capability of the device meets the system requirements, continue to determine whether the format of the device's acquired data is supported by the system; when the image capture capability of the device does not meet the system requirements, continue to poll and scan the devices in the / dev directory; if the format of the device's acquired data is supported by the system, cache the camera information; if the format of the device's acquired data is not supported by the system, continue to poll and scan the devices in the / dev directory until the scan is completed.

[0027] Furthermore, the virtual camera unit is used to:

[0028] The camera framework service judges the virtual front camera information and rear camera information: if the virtual front camera information does not exist in the front camera information list, the virtual front camera information is added to the front camera information list, if it exists, it is not added; if the virtual rear camera information does not exist in the rear camera information list, the virtual rear camera information is added to the rear camera information list, if it exists, it is not added; the HAL layer notifies the camera framework service of the updated front camera information list and rear camera information list, and the camera framework service updates the camera information.

[0029] Furthermore, the container creation unit is used to: open device permissions to the container when creating the container; and mount the camera on the Linux side into the container through the control group.

[0030] Furthermore, the camera access unit is used for: when the Android application calls the camera, the camera framework service first determines whether the camera exists and whether the camera is occupied. If the camera exists and is not occupied, the HAL layer is notified, and the HAL layer opens the camera.

[0031] Compared with the prior art, the present invention has the following advantages:

[0032] Currently, most applications use cameras to implement various functions. The technical solution of this invention solves the problem of Android-compatible Linux operating systems lacking front or rear built-in cameras, leaving Android applications without cameras. This invention plays an invaluable role in expanding the ecosystem of the Linux operating system. Furthermore, because the USB camera is detachable and replaceable, it provides customers with the flexibility to choose the camera that suits their needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 This is a schematic diagram of a method for accessing a camera in Linux compatible with Android provided by an embodiment of the present invention;

[0034] Figure 2 This is a schematic diagram of a Linux-compatible Android camera access device provided by an embodiment of the present invention;

[0035] Figure 3 This is a schematic diagram of a network architecture of a Linux-compatible Android virtual front camera and rear camera provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0036] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0037] For an operating environment compatible with running Android on a Linux operating system, the Android operating environment runs in a container.

[0038] Containers are a lightweight virtualization technology recently introduced by the Linux kernel. They allow you to run a new Linux system (including other Linux-based systems, such as Android) within a Linux system. Containers isolate the client and host systems from each other. Unlike traditional virtual machine-based solutions, container technology allows the client and host systems to share resources such as CPU, memory, and storage, resulting in minimal resource overhead. Furthermore, with proper configuration, the client system can directly access the host's hardware resources, further improving client system performance.

[0039] Due to the isolation of the Docker container, Linux cannot access Android's internal storage directory, and Android applications on Linux cannot directly access Linux-side files.

[0040] Figure 1 1 is a schematic diagram of a method for accessing a camera in a Linux-compatible Android environment provided by an embodiment of the present invention. The method is applied in an operating environment in which Linux is compatible with an Android system, and the method includes the following steps:

[0041] Step S1: Create a container on Linux and mount the camera on the Linux side into the container;

[0042] When creating an Android environment container, some device access permissions are also opened;

[0043] In a Linux-compatible Android environment, all hardware devices used by the Android environment originate from the Linux system. When the Android environment is restarted or booted for the first time, access to existing devices in the Linux system must be granted to the Android environment. For an Android runtime environment compatible with Linux, since the Android runtime environment runs in a container, the Android HAL hardware abstraction layer (HAL) does not have direct access to Linux hardware devices. However, by using the existing Linux container creation command, you can grant device permissions directly to the container during container creation, thus giving the Android environment access to the device.

[0044] Device files in the Linux system's / dev directory represent peripheral devices, such as / dev / video0, which represents the first media device (a camera). However, / dev / video0 is only for user convenience. The Linux kernel represents different devices using major and minor numbers, which are used to load the corresponding driver.

[0045] major number: indicates different device types

[0046] minor number: represents different partitions of the same device

[0047] For example:

[0048]

[0049] The major number for video0, video1, video2, and video3 is 81. The minor number for video starts at 0 and increases by 1 for each new camera. Therefore, we can use major number 81 to identify a camera. When creating an Android container using Docker, we can grant access to device 81 to the Android container.

[0050] Docker is a container technology that effectively divides the resources of a single operating system into isolated groups, allowing for better balancing of conflicting resource usage requirements between these groups. Linux is compatible with the Android environment, and the Android system runs in a Docker container on the Linux side.

[0051] The container creation command (docker create) can create a Docker container using a Docker image. The --device-cgroup-rule='c 81:*rmw' parameter of dockercreate can mount the device group with cgroup (control group) 81 (camera device) into the Docker container and set the permissions of the device group with cgroup (control group) 81 (camera device) so that the Android system running in the Docker container has permission to open and operate the device group with cgroup (control group) 81 (camera device) on the Linux side.

[0052] Cgroups (control groups) are a mechanism provided by the Linux kernel that limits, records, and isolates the physical resources used by groups of processes. Connecting a USB camera to a Linux system generates a device node with Cgroup 81 (typically / dev / video0 or / dev / video1, but the name is not fixed). Therefore, when creating a container, you can mount the Linux camera device into a Docker container by specifying the --device-cgroup-rule='c 81:*rmw' parameter.

[0053] Step S2: Start a container on Linux and start the Android system in the container;

[0054] Step S3: Enable the camera framework service on the Android side, poll and scan the devices in the / dev directory, and filter out the cameras; the camera framework service sends a notification message to the HAL layer on the Android side, and the HAL layer caches the camera information;

[0055] In the preceding steps, when creating the Android container, access rights to multiple devices in Linux were shared with the Android environment. We need to filter out camera devices from these devices and notify the HAL layer to cache them for app calls. At the same time, the data format collected by these devices must be one of the data formats allowed by the system.

[0056] V4L2 is a video framework designed specifically for Linux devices. Its core framework resides in the Linux kernel. Detecting whether a device is a camera and obtaining the data format captured by the device are based on V4L2 commands. These commands determine whether the current device and driver support the V4L2 specification, retrieve the device's capabilities, and obtain the device's supported formats.

[0057] Step S4: The camera framework service of the Android system virtualizes the single camera into a front camera and a rear camera. The camera framework service notifies the HAL layer of the information of the virtual front camera and rear camera through the interface, so that the camera of the Linux system is added to the front camera information list and rear camera information list of the HAL layer;

[0058] In the Android system, system camera information is cached in two places: the Android system camera framework and the camera HAL layer. When an app calls the camera, the system camera framework first determines whether a camera exists and is occupied. If an unoccupied camera exists, it calls the HAL layer and requests that the camera be opened.

[0059] The above steps have cached the Linux camera information in the camera framework service. However, the camera cannot be directly called by the app at this time because the Android system is currently mainly oriented towards mobile devices and only supports operating the camera through ID 1 (front camera) and ID 0 (rear camera). There is currently no way to call cameras with unknown IDs. In actual operation, whether the app opens the front camera or the rear camera is determined by the app's own business. In addition to the built-in camera that may exist on the PC, an unknown number of USB cameras may be plugged in. In order to ensure that all apps can operate the camera normally in various situations, we virtualize each camera device in the Linux system into a front camera and a rear camera. After connecting a USB camera, the application can operate the device by opening the front camera or the rear camera.

[0060] Step S5: The Android application accesses the camera according to the front camera information list and the rear camera information list.

[0061] Furthermore, the method enables the camera framework service on the Android side, polls and scans the devices in the / dev directory, and filters out the cameras, specifically including:

[0062] Enable the camera framework service on the Android side, poll and scan the devices in the / dev directory, first determine whether there are any devices in the / dev directory that are not processed by the system. If there are any devices that are not processed by the system, continue to determine whether the devices that are not processed by the system support the V42L specification. If there are no devices that are not processed by the system, end the scan; if the devices that are not processed by the system support the V42L specification, continue to determine the image capture capability of the device; if the devices that are not processed by the system do not support the V42L specification, continue to poll and scan the devices in the / dev directory; when the image capture capability of the device meets the system requirements, continue to determine whether the format of the device's acquired data is supported by the system; when the image capture capability of the device does not meet the system requirements, continue to poll and scan the devices in the / dev directory; if the format of the device's acquired data is supported by the system, cache the camera information; if the format of the device's acquired data is not supported by the system, continue to poll and scan the devices in the / dev directory until the scan is completed.

[0063] Furthermore, the camera framework service notifies the HAL layer of the information of the virtual front camera and rear camera through the interface, so that the camera of the Linux system is added to the front camera information list and rear camera information list of the HAL layer, specifically:

[0064] The camera framework service judges the virtual front camera information and rear camera information: if the virtual front camera information does not exist in the front camera information list, the virtual front camera information is added to the front camera information list, if it exists, it is not added; if the virtual rear camera information does not exist in the rear camera information list, the virtual rear camera information is added to the rear camera information list, if it exists, it is not added; the HAL layer notifies the camera framework service of the updated front camera information list and rear camera information list, and the camera framework service updates the camera information.

[0065] Furthermore, the step S1 creates a container on Linux and mounts the camera on the Linux side into the container, including: opening device permissions to the container when creating the container; and mounting the camera on the Linux side into the container through a control group.

[0066] Furthermore, step S5, in which the Android application accesses the camera according to the front camera information list and the rear camera information list, includes: when the Android application calls the camera, the camera framework service first determines whether the camera exists and whether the camera is occupied. If the camera exists and is not occupied, the HAL layer is notified, and the HAL layer opens the camera.

[0067] Figure 21 is a schematic diagram of a Linux-compatible Android camera access device provided by an embodiment of the present invention. The device is applied in an operating environment compatible with the Android system running on Linux, and the device includes:

[0068] The container creation unit is used to create a container on Linux and mount the camera on the Linux side into the container;

[0069] The container startup unit is used to start the container on Linux and start the Android system in the container;

[0070] The camera information cache processing unit is used to: enable the camera framework service on the Android side, poll and scan the devices in the / dev directory, and filter out cameras; the camera framework service sends a notification message to the HAL layer on the Android side, and the HAL layer caches the camera information;

[0071] The virtual camera unit is used to: The Android system's camera framework service virtualizes a single camera into a front camera and a rear camera. The camera framework service notifies the HAL layer of the information of the virtual front camera and rear camera through the interface, so that the Linux system's camera is added to the HAL layer's front camera information list and rear camera information list;

[0072] Access the camera unit, which is used for: Android applications to access the camera based on the front camera information list and the rear camera information list.

[0073] Furthermore, the camera information cache processing unit is used to:

[0074] Enable the camera framework service on the Android side, poll and scan the devices in the / dev directory, first determine whether there are any devices in the / dev directory that are not processed by the system. If there are any devices that are not processed by the system, continue to determine whether the devices that are not processed by the system support the V42L specification. If there are no devices that are not processed by the system, end the scan; if the devices that are not processed by the system support the V42L specification, continue to determine the image capture capability of the device; if the devices that are not processed by the system do not support the V42L specification, continue to poll and scan the devices in the / dev directory; when the image capture capability of the device meets the system requirements, continue to determine whether the format of the device's acquired data is supported by the system; when the image capture capability of the device does not meet the system requirements, continue to poll and scan the devices in the / dev directory; if the format of the device's acquired data is supported by the system, cache the camera information; if the format of the device's acquired data is not supported by the system, continue to poll and scan the devices in the / dev directory until the scan is completed.

[0075] Furthermore, the virtual camera unit is used to:

[0076] The camera framework service judges the virtual front camera information and rear camera information: if the virtual front camera information does not exist in the front camera information list, the virtual front camera information is added to the front camera information list, if it exists, it is not added; if the virtual rear camera information does not exist in the rear camera information list, the virtual rear camera information is added to the rear camera information list, if it exists, it is not added; the HAL layer notifies the camera framework service of the updated front camera information list and rear camera information list, and the camera framework service updates the camera information.

[0077] Furthermore, the container creation unit is used to: open device permissions to the container when creating the container; and mount the camera on the Linux side into the container through the control group.

[0078] Furthermore, the camera access unit is used for: when the Android application calls the camera, the camera framework service first determines whether the camera exists and whether the camera is occupied. If the camera exists and is not occupied, the HAL layer is notified, and the HAL layer opens the camera.

[0079] Figure 3 This diagram shows a network architecture for virtual front and rear cameras compatible with Android on Linux, as provided by an embodiment of the present invention. In the diagram, each camera on the Linux system (including built-in cameras and USB cameras) is added to the front and rear camera information lists. This virtualizes the Linux camera into a camera supported by the Android system. When opening the front or rear camera, Android applications can select from the lists, allowing for multiple options.

[0080] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art will be able to modify the technical solutions described in the aforementioned embodiments or substitute equivalents for some of the technical features. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention.

Claims

1. A Linux-compatible Android camera access method, characterized in that: The method is applied in an operating environment compatible with the Android system running on Linux, and the method includes the following steps: Step S1: Create a container on Linux and mount the camera on the Linux side into the container; Step S2: Start a container on Linux and start the Android system in the container; Step S3: Enable the camera framework service on the Android side, poll and scan the devices in the / dev directory, and filter out the cameras; the camera framework service sends a notification message to the HAL layer on the Android side, and the HAL layer caches the camera information; Step S4: The camera framework service of the Android system virtualizes the single camera into a front camera and a rear camera. The camera framework service notifies the HAL layer of the information of the virtual front camera and rear camera through the interface, so that the camera of the Linux system is added to the front camera information list and rear camera information list of the HAL layer; Step S5: The Android application accesses the camera according to the front camera information list and the rear camera information list; The method enables the camera framework service on the Android side, polls and scans the devices in the / dev directory, and filters out cameras, specifically including: Enable the camera framework service on the Android side, poll and scan the devices in the / dev directory, first determine whether there are any devices in the / dev directory that are not processed by the system. If there are any devices that are not processed by the system, continue to determine whether the devices that are not processed by the system support the V42L specification. If there are no devices that are not processed by the system, end the scan; if the devices that are not processed by the system support the V42L specification, continue to determine the image capture capability of the device; if the devices that are not processed by the system do not support the V42L specification, continue to poll and scan the devices in the / dev directory; when the image capture capability of the device meets the system requirements, continue to determine whether the format of the device's acquired data is supported by the system; when the image capture capability of the device does not meet the system requirements, continue to poll and scan the devices in the / dev directory; if the format of the device's acquired data is supported by the system, cache the camera information; if the format of the device's acquired data is not supported by the system, continue to poll and scan the devices in the / dev directory until the scan is completed.

2. The method for accessing a camera in Linux compatible with Android according to claim 1, wherein: The camera framework service notifies the HAL layer of the information of the virtual front camera and rear camera through the interface, so that the camera of the Linux system is added to the front camera information list and rear camera information list of the HAL layer, specifically: The camera framework service determines the virtual front camera information and rear camera information: if the virtual front camera information does not exist in the front camera information list, the virtual front camera information is added to the front camera information list; if it exists, the virtual front camera information is not added; If the virtual rear camera information does not exist in the rear camera information list, the virtual rear camera information is added to the rear camera information list. If it exists, it is not added. The HAL layer notifies the camera framework service of the updated front camera information list and rear camera information list, and the camera framework service updates the camera information.

3. The method for accessing a camera compatible with Linux and Android according to claim 1, wherein: The step S1 creates a container on Linux and mounts the camera on the Linux side into the container, including: opening device permissions to the container when creating the container; and mounting the camera on the Linux side into the container through a control group.

4. The method for accessing a camera compatible with Linux and Android according to claim 1, wherein: The step S5 Android application accesses the camera according to the front camera information list and the rear camera information list, including: when the Android application calls the camera, the camera framework service first determines whether the camera exists and whether the camera is occupied. If the camera exists and is not occupied, the HAL layer is notified, and the HAL layer opens the camera.

5. A Linux-compatible Android camera access device, characterized in that: The device is applied in an operating environment compatible with the Android system running on Linux, and the device includes: The container creation unit is used to create a container on Linux and mount the camera on the Linux side into the container; The container startup unit is used to start the container on Linux and start the Android system in the container; The camera information cache processing unit is used to: enable the camera framework service on the Android side, poll and scan the devices in the / dev directory, and filter out cameras; the camera framework service sends a notification message to the HAL layer on the Android side, and the HAL layer caches the camera information; The virtual camera unit is used to: The Android system's camera framework service virtualizes a single camera into a front camera and a rear camera. The camera framework service notifies the HAL layer of the information of the virtual front camera and rear camera through the interface, so that the Linux system's camera is added to the HAL layer's front camera information list and rear camera information list; Access the camera unit, which is used for: Android applications to access the camera based on the front camera information list and the rear camera information list; Wherein, the camera information cache processing unit is used to: Enable the camera framework service on the Android side, poll and scan the devices in the / dev directory, first determine whether there are any devices in the / dev directory that are not processed by the system. If there are any devices that are not processed by the system, continue to determine whether the devices that are not processed by the system support the V42L specification. If there are no devices that are not processed by the system, end the scan; if the devices that are not processed by the system support the V42L specification, continue to determine the image capture capability of the device; if the devices that are not processed by the system do not support the V42L specification, continue to poll and scan the devices in the / dev directory; when the image capture capability of the device meets the system requirements, continue to determine whether the format of the device's acquired data is supported by the system; when the image capture capability of the device does not meet the system requirements, continue to poll and scan the devices in the / dev directory; if the format of the device's acquired data is supported by the system, cache the camera information; if the format of the device's acquired data is not supported by the system, continue to poll and scan the devices in the / dev directory until the scan is completed.

6. The Linux-compatible Android camera access device according to claim 5, wherein: The virtual camera unit is used to: The camera framework service determines the virtual front camera information and rear camera information: if the virtual front camera information does not exist in the front camera information list, the virtual front camera information is added to the front camera information list; if it exists, the virtual front camera information is not added; If the virtual rear camera information does not exist in the rear camera information list, the virtual rear camera information is added to the rear camera information list. If it exists, it is not added. The HAL layer notifies the camera framework service of the updated front camera information list and rear camera information list, and the camera framework service updates the camera information.

7. The Linux-compatible Android camera access device according to claim 5, wherein: The container creation unit is used to: open device permissions to the container when creating the container; and mount the camera on the Linux side into the container through the control group.

8. The Linux-compatible Android camera access device according to claim 5, wherein: The camera access unit is used for: when the Android application calls the camera, the camera framework service first determines whether the camera exists and whether the camera is occupied. If the camera exists and is not occupied, the HAL layer is notified, and the HAL layer opens the camera.

Citation Information

Patent Citations

  • Method and device for controlling camera shooting based on Android application program in Linux system

    CN112612536A

  • Camera resource access method, operating system, terminal and virtual camera

    CN112749022A