A Linux-compatible Android multi-application camera access method and device

By creating containers and virtual cameras on Linux systems, the problem that multiple cameras cannot be used simultaneously in the Linux-compatible Android environment is solved, and the function of multiple applications to access different cameras at the same time is realized, which is suitable for scenarios such as monitoring and split-screen meetings.

CN113342422BActive Publication Date: 2025-08-26JIDE TECH RES INST (WUHAN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202110726449.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-29
Publication Date
2025-08-26
Estimated Expiration
2041-06-29

AI Technical Summary

Technical Problem

The existing Android technology framework does not support multiple cameras being accessed by different applications at the same time, resulting in the problem that multiple cameras cannot be used simultaneously in Linux-compatible Android environments.

Method used

By creating containers on Linux systems, mounting the camera and starting camera framework services in Android systems, monitoring device insertion and unplugging events, virtualizing the front and rear cameras, and managing the camera information list through the HAL layer, allocating camera usage rights based on application priorities and idle status.

Benefits of technology

It realizes that multiple USB cameras can be accessed by different applications at the same time on the PC host, and supports multiple applications to use different cameras at the same time, which is suitable for scenarios such as monitoring and split-screen meetings.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113342422B_ABST
    Figure CN113342422B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for multiple applications in Linux compatible with Android to access cameras. The method and device create a container on Linux and mount a camera on the Linux side into the container. The method starts a camera framework service process in the Android system, which monitors the events of devices being inserted or removed in the / dev directory. When a camera is detected to be inserted, the camera framework service process of the Android system virtualizes the single camera into a front camera and a rear camera. When an Android application accesses the camera, the HAL layer adapts the Android application to use an idle camera. The process priority of the application using the camera is compared with the process priority of the application requesting to use the camera to determine the use of the camera. This method enables multiple apps to access different cameras simultaneously.
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 method and device for multiple applications in Linux compatible with Android to access a camera. 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] Unlike PCs, mobile devices only have two cameras: a front-facing camera and a rear-facing camera, and they don't support USB ports to expand additional cameras. PCs running a Linux operating system compatible with Android not only have built-in cameras but can also connect to additional USB cameras via USB ports. However, the existing Android technology framework doesn't support external USB cameras, so these PC cameras can't be fully utilized.

[0005] In the existing Android technology framework, the camera framework service will cache the camera ID (1 for the front camera, 0 for the rear camera) and process PID after the camera is opened by an App. When accepting a new camera opening request, the requested camera ID (1 for the front camera, 0 for the rear camera) will be searched in the cache. If the camera ID (1 for the front camera, 0 for the rear camera) is already found in the cache, it proves that the camera has been opened. The previously opened camera will be closed, and the new request to open the camera will be accepted at the same time. In the case of multiple front cameras and multiple rear cameras, the existing camera framework service only uses the camera ID (1 for the front camera, 0 for the rear camera) to determine whether it is opened, which will result in multiple cameras not being able to be opened at the same time.

[0006] In practice, it is often necessary to use one camera for multiple tasks. However, in the existing technology, one camera can only be occupied by one application. When one application is using the camera, all other applications cannot use the camera. Summary of the Invention

[0007] In order to solve the problem that multiple Android applications can access multiple cameras at the same time in a Linux-compatible Android environment, the present invention provides a Linux-compatible Android multi-application camera access method and device.

[0008] On the one hand, the present invention provides a method for multiple applications to access 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. The method includes the following steps:

[0009] Step S1: Create a container on Linux and mount the camera on the Linux side into the container; start the container on Linux and start the Android system in the container;

[0010] Step S2: Starting a camera framework service process in the Android system, the camera framework service process monitors events in which devices in the / dev directory are plugged in or unplugged;

[0011] When a camera is detected to be inserted, the camera framework service process of the Android system virtualizes the single camera into a front camera and a rear camera. The camera framework service process 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; the camera information list includes the camera type ID, the process priority of the application that opens the camera, the process ID of the application that opens the camera, and the camera name;

[0012] Step S3: When an Android application accesses a camera, first analyze and determine whether the camera type id accessed by the Android application is a front camera id or a rear camera id; then, based on the camera name, determine whether there is an idle camera in the front camera information list or the rear camera information list of the HAL layer; if there is an idle camera, the HAL layer adapts the Android application to use the idle camera; if there is no idle camera, compare the priority of the process of the application that is using the camera with the priority of the process of the application requesting to use the camera. If the priority of the process of the application that is using the camera is high, the opening fails. If the priority of the process of the application requesting to use the camera is high, close the camera that is being opened, open the camera for the application requesting to use the camera, and update the opened camera information cache queue list at the same time.

[0013] Furthermore, in step S2, the camera framework service process monitors the event of the device being inserted or unplugged in the / dev directory, including: when the camera framework service process monitors the device in the / dev directory being unplugged, the name of the unplugged camera is notified to the HAL layer, and the HAL layer deletes the name of the unplugged camera from the front camera list and the rear camera list.

[0014] Furthermore, in step S2, the camera framework service process monitors the events of devices being inserted or unplugged in the / dev directory, specifically: through inotify_add_watch(fd, " / dev", "IN_CREATE | IN_DELETE") to sense the insertion or unplugging of the camera, IN_CREATE indicates that the camera is inserted, and IN_DELETE indicates that the camera is unplugged.

[0015] Furthermore, in step S2, when it is monitored that a camera is inserted, the camera framework service of the Android system virtualizes a single camera into a front camera and a rear camera, and the camera framework service process notifies the HAL layer of the information of the virtual front camera and rear camera through the interface, including: when a new camera is added, the camera framework service process notifies the HAL layer twice: adding a new front camera and adding a new rear camera, and the HAL layer adds the camera information to the corresponding front camera list or rear camera list according to the camera type.

[0016] Furthermore, in step S3, if there is an idle camera, the HAL layer adapts the idle camera for the Android application, including: the HAL layer selects an idle camera in the front camera list or the rear camera list according to whether the camera type to be used by the Android application is front or rear; the status of the camera selected for use in the front camera list or the rear camera list is marked as in use, the camera is opened, and the process number and camera name of the application that opens the camera are saved.

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

[0018] The container creation and startup unit is used to: create a container on Linux and mount the camera on the Linux side into the container; start the container on Linux and start the Android system in the container;

[0019] The virtual camera unit is used to start the camera framework service process in the Android system. The camera framework service process monitors the events of devices being inserted or removed in the / dev directory.

[0020] When a camera is detected to be inserted, the camera framework service process of the Android system virtualizes the single camera into a front camera and a rear camera. The camera framework service process 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; the camera information list includes the camera type ID, the process priority of the application that opens the camera, the process ID of the application that opens the camera, and the camera name;

[0021] The camera access unit is used for: when an Android application accesses the camera, first analyzing and judging whether the camera type id accessed by the Android application is the front camera id or the rear camera id; then judging whether there is an idle camera in the front camera information list or the rear camera information list of the HAL layer according to the camera name; if there is an idle camera, the HAL layer adapts the Android application to use the idle camera; if there is no idle camera, comparing the priority of the process of the application that is using the camera with the priority of the process of the application requesting to use the camera, if the priority of the process of the application that is using the camera is high, the opening fails; if the priority of the process of the application requesting to use the camera is high, closing the camera that is being opened, opening the camera for the application requesting to use the camera, and updating the opened camera information cache queue list at the same time.

[0022] Furthermore, the virtual camera unit is used to: when the camera framework service process monitors the device in the / dev directory and it is unplugged, notify the HAL layer of the name of the unplugged camera, and the HAL layer deletes the unplugged camera name from the front camera list and the rear camera list.

[0023] Furthermore, the virtual camera unit is used to sense the camera being inserted or removed through inotify_add_watch(fd, " / dev", "IN_CREATE | IN_DELETE"), where IN_CREATE indicates that the camera is inserted, and IN_DELETE indicates that the camera is removed.

[0024] Furthermore, the virtual camera unit is used to: when a new camera is added, the camera framework service process notifies the HAL layer twice: adding a new front camera and adding a new rear camera, and the HAL layer adds the camera information to the corresponding front camera list or rear camera list according to the camera type.

[0025] Furthermore, the camera access unit is used to: the HAL layer selects an idle camera in the front camera list or the rear camera list according to the camera type that the Android application needs to use, which is front or rear; marks the status of the camera selected for use in the front camera list or the rear camera list as in use, opens the camera, and saves the process number and camera name of the application that opens the camera.

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

[0027] The technical solution proposed by the present invention can ensure that each camera can be operated by different applications after multiple USB cameras are inserted into the PC host, realizing the function of multiple apps accessing different cameras at the same time, and can be widely used in scenarios such as monitoring and split-screen conferencing. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 This is a schematic diagram of a method for multiple applications in Linux compatible with Android to access a camera provided by an embodiment of the present invention;

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

[0030] 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

[0031] 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.

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

[0033] 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.

[0034] 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.

[0035] Figure 11 is a schematic diagram of a method for accessing a camera using multiple applications on Linux that is compatible with Android, provided by an embodiment of the present invention. The method is applied in an operating environment where Linux is compatible with the Android system, and the method includes the following steps:

[0036] Step S1: Create a container on Linux and mount the camera on the Linux side into the container; start the container on Linux and start the Android system in the container;

[0037] Step S2: Starting a camera framework service process in the Android system, the camera framework service process monitors events in which devices in the / dev directory are plugged in or unplugged;

[0038] When a camera is detected to be inserted, the camera framework service process of the Android system virtualizes the single camera into a front camera and a rear camera. The camera framework service process notifies the HAL layer application abstraction layer of the information of the virtual front camera and rear camera through the interface, so that the Linux system camera is added to the front camera information list and rear camera information list of the HAL layer; the camera information list includes the camera type ID, the process priority of the application that opens the camera, the process ID of the application that opens the camera, and the camera name;

[0039] Each node in the Linux system's / dev directory describes an external device. When an external device is connected, a device descriptor is created in this directory. When the device is removed, the node is deleted. Therefore, we can monitor the / dev directory using Linux's inotify mechanism to detect the insertion and removal of USB cameras. inotify is a mechanism used by the Linux kernel to notify userspace programs of file system changes.

[0040] In this solution, inotify_add_watch(fd, " / dev", "IN_CREATE | IN_DELETE") is used to detect the insertion and removal of the USB camera. The IN_CREATE event indicates that the camera is inserted, and the IN_DELETE event indicates that the camera is removed.

[0041] S201, monitoring the insertion and removal of the USB camera;

[0042] After the camera framework service monitors the / dev directory, when a device is unplugged or removed, the camera framework service receives an event response. We obtain the device name (multimedia devices, including cameras, with the first part of the device name being video) from the event structure inotify_event and combine it with the monitored directory to form a complete device name (for example, dev / video1).

[0043] S202, the Android system virtualizes each newly added USB device into a front camera and a rear camera;

[0044] In the Android system, apps can only operate the camera through ID 0 (rear camera) or 1 (front camera). Whether to open the front camera or the rear camera is determined by the app's own business. There may be only one USB camera plugged into a PC, or there may be multiple. In order to ensure that all apps can operate the camera normally in various situations, we need to split each external camera device into a front camera and a rear camera. Ensure that after connecting a USB camera, the app can operate the device by opening the front camera or the rear camera.

[0045] We no longer need this virtual process when unplugging the USB camera. We only need to notify the HAL layer of the name of the unplugged USB camera and let the HAL layer delete the given camera from the front camera list and the rear camera list.

[0046] S203, HAL layer processes the newly added or deleted USB camera;

[0047] In order to achieve multi-channel camera access, the HAL layer will have two lists, the front camera list and the rear camera list. Each piece of information in the list is a camera.

[0048] The camera service framework passes camera information to the HAL layer, including:

[0049] New camera information:

[0050] Camera type (0: rear, 1: front), camera name (dev / video0, etc.), rotation angle (rear 90 degrees, front 270 degrees);

[0051] Delete camera information:

[0052] Camera name (dev / video0, etc.).

[0053] When a new camera is added, the HAL layer needs to add the camera information to the corresponding camera list (front camera list, rear camera list) based on the camera type. When adding a new camera, the camera framework service will notify the HAL layer twice: once for adding a rear camera and once for adding a front camera. When deleting a camera, the camera framework service only needs to notify the HAL layer once. The HAL layer retrieves and deletes the camera name (dev / video0, etc.) from the front camera list and rear camera list, and closes the open camera. Regardless of whether the camera is added or deleted, the HAL layer must notify the camera framework service to update the camera information after updating the camera information.

[0054] Step S3: When an Android application accesses a camera, first analyze and determine whether the camera type id accessed by the Android application is a front camera id or a rear camera id; then, based on the camera name, determine whether there is an idle camera in the front camera information list or the rear camera information list of the HAL layer; if there is an idle camera, the HAL layer adapts the Android application to use the idle camera; if there is no idle camera, compare the priority of the process of the application that is using the camera with the priority of the process of the application requesting to use the camera. If the priority of the process of the application that is using the camera is high, the opening fails. If the priority of the process of the application requesting to use the camera is high, close the camera that is being opened, open the camera for the application requesting to use the camera, and update the opened camera information cache queue list at the same time.

[0055] The solution of the existing technology: An App opens the camera by passing the camera ID (0: rear camera, 1: front camera) to the camera service. In the camera service, there will be a cache queue list of information about the opened camera devices. Each message in the queue contains: the camera ID, the process ID (PID) of the App that opens the camera, and the process priority of the App that opens the camera (which can be refreshed dynamically). The camera ID is used to limit the front and rear cameras to only one App at a time. The Android system is currently mainly aimed at mobile devices, and there are only one or more devices for both the front and rear cameras. However, in the technical solution of the present invention, there are multiple devices for both the front and rear cameras. The existing technology uses the camera ID to determine whether the camera is opened, which will result in one of the many cameras being opened while the others cannot be opened.

[0056] Furthermore, in step S2, the camera framework service process monitors the event of the device being inserted or unplugged in the / dev directory, including: when the camera framework service process monitors the device in the / dev directory being unplugged, the name of the unplugged camera is notified to the HAL layer, and the HAL layer deletes the name of the unplugged camera from the front camera list and the rear camera list.

[0057] Furthermore, in step S2, the camera framework service process monitors the events of devices being inserted or unplugged in the / dev directory, specifically: through inotify_add_watch(fd, " / dev", "IN_CREATE | IN_DELETE") to sense the insertion or unplugging of the camera, IN_CREATE indicates that the camera is inserted, and IN_DELETE indicates that the camera is unplugged.

[0058] Furthermore, in step S2, when it is monitored that a camera is inserted, the camera framework service of the Android system virtualizes a single camera into a front camera and a rear camera, and the camera framework service process notifies the HAL layer of the information of the virtual front camera and rear camera through the interface, including: when a new camera is added, the camera framework service process notifies the HAL layer twice: adding a new front camera and adding a new rear camera, and the HAL layer adds the camera information to the corresponding front camera list or rear camera list according to the camera type.

[0059] Furthermore, in step S3, if there is an idle camera, the HAL layer adapts the idle camera for the Android application, including: the HAL layer selects an idle camera in the front camera list or the rear camera list according to whether the camera type to be used by the Android application is front or rear; the status of the camera selected for use in the front camera list or the rear camera list is marked as in use, the camera is opened, and the process number and camera name of the application that opens the camera are saved.

[0060] The technical solution of the present invention can handle simultaneous access to multiple front and rear cameras, such as: application A opens the rear camera (camera ID: 0, app PID: 2001, device name: / dev / video0), and application B opens the rear camera (camera ID: 0, app PID: 2002, device name: / dev / video1).

[0061] The front and rear camera information of this invention is different from the single information in Android's default storage. Instead, it is stored in a list format. The list capacity is unlimited. No matter how many USB cameras are connected to the PC host, all of this information will be added to the front and rear camera information lists. Each information in the list includes: device name ( / dev / video0, etc.), rotation angle (front 270 degrees, rear 90 degrees), usage status (1: in use, 0: idle). When the app operates the camera, the system automatically selects one of the idle devices for the app to operate.

[0062] After the HAL layer opens the camera, it will use a cache list to record the process number and device name of the application that opened the camera, and set the device to a busy state. Other applications will not operate this device when they open the camera again. When the camera is closed after the application's camera service is completed, the device will be found according to the process number, and the device will be turned off. At the same time, the device status in the front and rear device lists will be set to idle. The core of this process is that when different apps operate the camera, they will search for idle devices in the front camera information list or the rear camera information list. When an idle device is found, it will be opened directly and the process number and device name of the application that opened the device will be recorded for subsequent applications to switch between the front and rear cameras and turn off the camera.

[0063] It should be noted that when an app wants to open either the front or rear camera, it doesn't know which camera to open in the list. It only knows to open the front or rear camera, but cannot select which one to open. The HAL layer determines which device to open.

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

[0065] The container creation and startup unit is used to: create a container on Linux and mount the camera on the Linux side into the container; start the container on Linux and start the Android system in the container;

[0066] The virtual camera unit is used to start the camera framework service process in the Android system. The camera framework service process monitors the events of devices being inserted or removed in the / dev directory.

[0067] When a camera is detected to be inserted, the camera framework service process of the Android system virtualizes the single camera into a front camera and a rear camera. The camera framework service process 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; the camera information list includes the camera type ID, the process priority of the application that opens the camera, the process ID of the application that opens the camera, and the camera name;

[0068] The camera access unit is used for: when an Android application accesses the camera, first analyzing and judging whether the camera type id accessed by the Android application is the front camera id or the rear camera id; then judging whether there is an idle camera in the front camera information list or the rear camera information list of the HAL layer according to the camera name; if there is an idle camera, the HAL layer adapts the Android application to use the idle camera; if there is no idle camera, comparing the priority of the process of the application that is using the camera with the priority of the process of the application requesting to use the camera, if the priority of the process of the application that is using the camera is high, the opening fails; if the priority of the process of the application requesting to use the camera is high, closing the camera that is being opened, opening the camera for the application requesting to use the camera, and updating the opened camera information cache queue list at the same time.

[0069] Furthermore, the virtual camera unit is used to: when the camera framework service process monitors the device in the / dev directory and it is unplugged, notify the HAL layer of the name of the unplugged camera, and the HAL layer deletes the unplugged camera name from the front camera list and the rear camera list.

[0070] Furthermore, the virtual camera unit is used to sense the camera being inserted or removed through inotify_add_watch(fd, " / dev", "IN_CREATE | IN_DELETE"), where IN_CREATE indicates that the camera is inserted, and IN_DELETE indicates that the camera is removed.

[0071] Furthermore, the virtual camera unit is used to: when a new camera is added, the camera framework service process notifies the HAL layer twice: adding a new front camera and adding a new rear camera, and the HAL layer adds the camera information to the corresponding front camera list or rear camera list according to the camera type.

[0072] Furthermore, the camera access unit is used to: the HAL layer selects an idle camera in the front camera list or the rear camera list according to the camera type that the Android application needs to use, which is front or rear; marks the status of the camera selected for use in the front camera list or the rear camera list as in use, opens the camera, and saves the process number and camera name of the application that opens the camera.

[0073] 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.

[0074] 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 multi-application 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; start the container on Linux and start the Android system in the container; Step S2: Starting a camera framework service process in the Android system, the camera framework service process monitors events in which devices in the / dev directory are plugged in or unplugged; When a camera is detected to be plugged in, the Android system's camera framework service process virtualizes the single camera into a front camera and a rear camera. The camera framework service process notifies the HAL layer of the information of the virtual front and rear cameras through the interface, so that the Linux system's camera is added to the front camera information list and rear camera information list of the HAL layer; The camera information list includes the camera type ID, the process priority of the application that opens the camera, the process ID of the application that opens the camera, and the camera name; Step S3: When the Android application accesses the camera, first analyze and determine whether the camera type ID accessed by the Android application is a front camera ID or a rear camera ID; Then, based on the camera name, determine whether there is an idle camera in the front camera information list or the rear camera information list of the HAL layer; if there is an idle camera, the HAL layer adapts the Android application to use the idle camera; If there is no idle camera, compare the priority of the process of the application that is using the camera with the priority of the process of the application requesting to use the camera. If the priority of the process of the application that is using the camera is higher, the opening will fail. If the priority of the process of the application requesting to use the camera is higher, close the camera that is being opened, open the camera for the application requesting to use the camera, and update the queue list of the opened camera information cache.

2. The Linux-compatible Android multi-application camera access method according to claim 1, wherein: In step S2, the camera framework service process monitors the event of a device being inserted or unplugged in the / dev directory, including: when the camera framework service process monitors the device in the / dev directory being unplugged, the name of the unplugged camera is notified to the HAL layer, and the HAL layer deletes the unplugged camera name from the front camera list and the rear camera list.

3. The Linux-compatible Android multi-application camera access method according to claim 1, wherein: In step S2, the camera framework service process monitors the events of devices being inserted or unplugged in the / dev directory, specifically: through inotify_add_watch(fd," / dev","IN_CREATE|IN_DELETE") to sense the insertion or unplugging of the camera, IN_CREATE indicates that the camera is inserted, and IN_DELETE indicates that the camera is unplugged.

4. The Linux-compatible Android multi-application camera access method according to claim 1, wherein: In step S2, when it is monitored that a camera is inserted, the camera framework service of the Android system virtualizes a single camera into a front camera and a rear camera, and the camera framework service process notifies the HAL layer of the information of the virtual front camera and rear camera through the interface, including: when a new camera is added, the camera framework service process notifies the HAL layer twice: adding a new front camera and adding a new rear camera, and the HAL layer adds the camera information to the corresponding front camera list or rear camera list according to the camera type.

5. The Linux-compatible Android multi-application camera access method according to claim 1, wherein: In step S3, if there is an idle camera, the HAL layer adapts the idle camera for the Android application, including: the HAL layer selects an idle camera in the front camera list or the rear camera list according to whether the camera type to be used by the Android application is front or rear; the status of the camera selected for use in the front camera list or the rear camera list is marked as in use, the camera is opened, and the process number and camera name of the application that opens the camera are saved.

6. A Linux-compatible Android multi-application 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 and startup unit is used to: create a container on Linux and mount the camera on the Linux side into the container; start the container on Linux and start the Android system in the container; The virtual camera unit is used to start the camera framework service process in the Android system. The camera framework service process monitors the events of devices being inserted or removed in the / dev directory. When a camera is detected to be inserted, the camera framework service process of the Android system virtualizes the single camera into a front camera and a rear camera. The camera framework service process 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; the camera information list includes the camera type ID, the process priority of the application that opens the camera, the process ID of the application that opens the camera, and the camera name; The camera access unit is used for: when an Android application accesses the camera, first analyzing and determining whether the camera type id accessed by the Android application is the front camera id or the rear camera id; then judging whether there is an idle camera in the front camera information list or the rear camera information list of the HAL layer according to the camera name; if there is an idle camera, the HAL layer adapts the use of the idle camera for the Android application; if there is no idle camera, comparing the priority of the process of the application that is using the camera with the priority of the process of the application requesting to use the camera, if the priority of the process of the application that is using the camera is high, the opening fails; if the priority of the process of the application requesting to use the camera is high, closing the camera that is being opened, opening the camera for the application requesting to use the camera, and updating the opened camera information cache queue list at the same time.

7. The Linux-compatible Android multi-application camera access device according to claim 6, wherein: The virtual camera unit is used to: when the camera framework service process monitors the device in the / dev directory and it is unplugged, notify the HAL layer of the name of the unplugged camera, and the HAL layer deletes the unplugged camera name from the front camera list and the rear camera list.

8. The Linux-compatible Android multi-application camera access device according to claim 6, wherein: The virtual camera unit is used to sense the camera being inserted or unplugged through inotify_add_watch(fd," / dev","IN_CREATE|IN_DELETE"). IN_CREATE indicates that the camera is inserted, and IN_DELETE indicates that the camera is unplugged.

9. The Linux-compatible Android multi-application camera access device according to claim 6, wherein: The virtual camera unit is used to: when a new camera is added, the camera framework service process notifies the HAL layer twice: adding a new front camera and adding a new rear camera. The HAL layer adds the camera information to the corresponding front camera list or rear camera list according to the camera type.

10. The Linux-compatible Android multi-application camera access device according to claim 6, wherein: The camera access unit is used for: the HAL layer selects an idle camera from the front camera list or the rear camera list according to whether the camera type to be used by the Android application is front or rear; The state of the camera selected in the front camera list or the rear camera list is marked as in use, the camera is opened, and the process ID of the application that opens the camera and the camera name are saved.

Citation Information

Patent Citations

  • Method for simultaneously utilizing one camera by computer system and a plurality of application programs

    CN101833520A

  • 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