Camera enabling priority management method, electronic device and storage medium
By introducing a camera service module into electronic devices, the enable status of the camera is managed, the enable conflicts between front-facing camera functions are solved, and the effective management of function priorities is achieved, and the system stability and user experience are improved.
Patent Information
- Application Number
- CN202311788067.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-22
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2043-12-22
AI Technical Summary
In existing electronic devices, there is a conflict of enablement when performing functions such as ambient light detection, photography and face unlocking, making it difficult to effectively manage its priority.
By introducing a camera service module into the software structure of the electronic device, the enable state of the camera is managed. Specific steps include receiving instructions, querying the camera list, judging based on priority and enabling or turning off the corresponding functions.
It realizes the enable priority management between different functions of the front camera, avoids functional conflicts, ensures the enablement of high-priority functions and the shutdown of low-priority functions, and improves the stability and user experience of the system.
Smart Images

Figure CN118450251B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic equipment, and in particular to a method for managing camera enabling priority, an electronic device and a storage medium. Background Art
[0002] At present, the display screens of many electronic devices such as smartphones, tablet computers, desktop computers, wearable devices, etc. all have the function of automatically adjusting brightness. The automatic brightness adjustment function can automatically adjust the brightness of the display screen according to the ambient light brightness to adapt to the light intensity in different environments, thereby improving the user experience. In order to reduce the cost of electronic devices, the front camera of the electronic device can be used as an ambient light detection device.
[0003] However, in addition to the ambient light detection function, the front camera of the electronic device also has the photo taking function, face unlocking function, etc. When the front camera is used as an ambient light detection device, it is necessary to provide a camera enabling priority management method to resolve the enabling conflict between different functions of the front camera. Summary of the invention
[0004] Multiple aspects of the present application provide a camera enable priority management method, electronic device and storage medium, which can resolve the enablement conflict between different functions of a target camera when the target camera is used as an ambient light detection device.
[0005] In a first aspect, a method for managing camera enabling priority is provided, the method being applied to an electronic device, wherein a software structure of the electronic device includes a framework layer, the framework layer includes a camera service module, and the method includes:
[0006] After the screen of the electronic device is turned on, the camera service module receives a first instruction, where the first instruction includes a first identifier, and the first identifier corresponds to an ambient light detection function of a target camera;
[0007] After receiving the first instruction, the camera service module queries a camera list, where the camera list is used to store identifiers of currently enabled cameras;
[0008] When the camera list is empty, the camera service module turns on the ambient light detection function of the target camera based on the first identifier.
[0009] In a first possible implementation manner of the first aspect, after the camera service module turns on the ambient light detection function of the target camera based on the first identifier, the method further includes:
[0010] After the screen of the electronic device is turned off, the camera service module receives a second instruction, where the second instruction includes the first identifier;
[0011] After receiving the second instruction, the camera service module turns off the ambient light detection function of the target camera based on the first identifier.
[0012] In a second possible implementation manner of the first aspect, the first instruction further includes a first package name, where the first package name is a package name of an ambient light detection application, and after the camera service module turns on the ambient light detection function of the target camera based on the first identifier, the method further includes:
[0013] After the camera application is started, the camera service module receives a third instruction, the third instruction includes a second identifier and a second package name, the second identifier corresponds to the camera function of the target camera, and the second package name is the package name of the camera application;
[0014] After receiving the third instruction, the camera service module determines that the first identifier exists in the camera list, and determines the priority of the first identifier and the second identifier according to the first package name and the second package name;
[0015] The camera service module determines that the priority of the first identifier is lower than the priority of the second identifier, turns off the ambient light detection function of the target camera, and then turns on the photo-taking function of the target camera based on the second identifier.
[0016] In a third possible implementation manner of the first aspect, the software structure of the electronic device further includes a hardware abstraction layer, the hardware abstraction layer includes a sensor control module, and after the camera service module determines that the priority of the first identifier is lower than the priority of the second identifier, and turns off the ambient light detection function of the target camera, further includes:
[0017] The camera service module sends a first notification message to the sensor control module, where the first notification message is used to notify the sensor control module that an ambient light detection function of the target camera has been turned off.
[0018] In a fourth possible implementation manner of the first aspect, after the camera service module turns on the photo-taking function of the target camera based on the second identifier, the method further includes:
[0019] After the camera application is closed, the camera service module receives a fourth instruction;
[0020] After receiving the fourth instruction, the camera service module turns off the photographing function of the target camera, and sends a second notification message to the sensor control module, where the second notification message is used to notify the sensor control module that the photographing function of the target camera has been turned off;
[0021] After receiving the second notification message, the sensor control module calls the first interface based on the AIDL service, and then calls the second interface based on the HIDL service to send the first instruction to the camera service module;
[0022] After receiving the first instruction, the camera service module turns on the ambient light detection function of the target camera based on the first identifier.
[0023] In a fifth possible implementation manner of the first aspect, after the camera service module turns on the photo-taking function of the target camera based on the second identifier, the method further includes:
[0024] After the screen of the electronic device is turned off, the camera service module turns off the photographing function of the target camera, and then sends a second notification message to the sensor control module, where the second notification message is used to notify the sensor control module that the photographing function of the target camera has been turned off;
[0025] After receiving the second notification message, when it is determined that the state machine of the sensor control module is in the first state, the sensor control module turns on the ambient light detection function of the target camera, and then turns off the ambient light detection function of the target camera based on the electronic device turning off the screen.
[0026] In a sixth possible implementation manner of the first aspect, after the camera service module turns on the photo-taking function of the target camera based on the second identifier, the method further includes:
[0027] After the screen of the electronic device is turned off, the camera service module turns off the photographing function of the target camera, and then sends a second notification message to the sensor control module, where the second notification message is used to notify the sensor control module that the photographing function of the target camera has been turned off;
[0028] After receiving the second notification message, when it is determined that the state machine of the sensor control module is in the second state, the sensor control module turns off the ambient light detection function of the target camera.
[0029] In a seventh possible implementation manner of the first aspect, after the screen of the electronic device is turned on and before the camera service module receives the first instruction, the method further includes:
[0030] After the screen of the electronic device is turned on, the face unlocking application is started;
[0031] After the face unlock application is started, the camera service receives a fifth instruction, the fifth instruction includes a third identifier, and the third identifier corresponds to the face unlock function of the target camera;
[0032] After receiving the fifth instruction, the camera service module turns on the face unlocking function of the target camera.
[0033] In an eighth possible implementation manner of the first aspect, the fifth instruction further includes a third package name, and the method further includes:
[0034] During the unlocking process of the display screen, when the first instruction is received, the camera service determines that the third identifier exists in the camera list, and determines the priority of the first identifier and the third identifier according to the first package name and the third package name;
[0035] The camera service module determines that the priority of the first identifier is lower than the priority of the third identifier, and sends a third notification message to the sensor control module, where the third notification message is used to notify the sensor control module that the ambient light detection function of the target camera fails to be turned on;
[0036] After the display screen of the electronic device is unlocked, the camera service module turns off the face unlocking function of the target camera, and then turns on the ambient light detection function of the target camera based on the first identifier.
[0037] In a second aspect, an electronic device is provided, comprising a processor and a memory; the memory stores at least one program code; the at least one program code is used to be called and executed by the processor to implement the camera enable priority management method as described in the first aspect.
[0038] In a third aspect, a computer-readable storage medium is provided, wherein at least one computer program is stored in the computer-readable storage medium, and when the at least one computer program is executed by a processor, the method for managing camera enabling priority as described in the first aspect can be implemented.
[0039] In a fourth aspect, a computer program product is provided, the computer program product comprising a computer program, and when the computer program is executed by a processor, the method for managing camera enabling priority as described in the first aspect can be implemented.
[0040] The beneficial effects of the technical solution provided by the embodiment of the present application are:
[0041] The embodiment of the present application sets different identifiers for different functions of the target camera, and provides a camera list for storing the currently enabled camera identifiers. After receiving the first instruction, when the camera list is found to be empty, the ambient light detection function of the target camera is turned on. The embodiment of the present application also sets different priorities for the package names of different applications. When the camera list is not empty, the enabling priority of different identifiers of the target camera is determined according to the priority of different package names, and then according to the determined priority, the high-priority function is enabled, and the low-priority function is turned off or not enabled, thereby providing a solution to the conflict of enabling different functions. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0043] Figure 1 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application;
[0044] Figure 2 It is a software structure block diagram of an electronic device provided in an embodiment of the present application;
[0045] Figure 3 is a flow chart of a method for adjusting display screen brightness provided in an embodiment of the present application;
[0046] Figure 4 is a flow chart of another method for adjusting the brightness of a display screen provided in an embodiment of the present application;
[0047] Figure 5 is a flow chart of another method for adjusting the brightness of a display screen provided in an embodiment of the present application;
[0048] Figure 6 This is a flow chart of a method for turning off the screen and disabling the ambient light detection function of a front camera provided in an embodiment of the present application;
[0049] Figure 7 This is another flowchart of turning off the screen and shutting down the ambient light detection function of the front camera provided in an embodiment of the present application;
[0050] Figure 8 is a flow chart of a method for managing camera enabling priority provided by an embodiment of the present application;
[0051] Fig. 9 is a flowchart of another method for managing camera enabling priority provided by an embodiment of the present application;
[0052] Fig.10is a flowchart of another method for managing camera enabling priority provided by an embodiment of the present application;
[0053] Fig.11 is a flowchart of another method for managing camera enabling priority provided by an embodiment of the present application;
[0054] Fig.12 is a flowchart of another method for managing camera enabling priority provided by an embodiment of the present application;
[0055] Fig.13 is a flowchart of another method for managing camera enabling priority provided by an embodiment of the present application;
[0056] Fig.14 is a flowchart of another method for managing camera enabling priority provided by an embodiment of the present application;
[0057] Fig.15 is a flow chart of a method for managing an ambient light detection function provided in an embodiment of the present application;
[0058] Fig.16 is a flow chart of another method for managing an ambient light detection function provided by an embodiment of the present application;
[0059] Fig.17 is a flow chart of another method for managing an ambient light detection function provided by an embodiment of the present application;
[0060] Fig.18 is a flow chart of another method for managing an ambient light detection function provided by an embodiment of the present application;
[0061] Fig.19 is a flow chart of another method for managing an ambient light detection function provided by an embodiment of the present application;
[0062] Fig. 20 is a flow chart of another method for managing an ambient light detection function provided by an embodiment of the present application;
[0063] Fig.21 It is a performance optimization logic block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0064] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0065] It can be understood that the terms "each", "multiple" and "any" used in the embodiments of the present application, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the corresponding multiple. For example, multiple words include 10 words, and each word refers to each of the 10 words, and any word refers to any one of the 10 words. In addition, the descriptions of "first", "second", etc. in the embodiments of the present application are used to distinguish different messages, devices, modules, etc., do not represent the order of precedence, and do not limit the "first" and "second" to different types.
[0066] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0067] In modern life, electronic devices such as smart phones, tablet computers, and laptops have become indispensable items in people's lives. In order to meet the needs of users in different lighting scenarios, electronic devices provide an automatic brightness adjustment function. After the electronic device screen is turned on, the built-in ambient light detection device can detect the ambient light brightness, and then adjust the brightness of the electronic device's display screen based on the ambient light brightness detected by the ambient light detection device, so that users have a good viewing experience under different lighting conditions.
[0068] Although the above method can adjust the brightness of the display screen, it requires an additional ambient light detection device, which increases the cost of the electronic device. Considering that current electronic devices are equipped with cameras, and most cameras have a light source detection function, when a camera that supports normal mode (i.e., photo mode) is used as an ambient light detection device, the power consumption of the camera that supports normal mode is high, which reduces the performance of the electronic device. With the development of technology, cameras can support multiple modes, including normal mode, ALS (Ambient Light Sensor mode) mode, ULP (Ultra Low Power) mode, etc., which makes it possible to use cameras as ambient light detection devices.
[0069] In view of this, the embodiment of the present application can replace the ambient light detection device with a target camera to detect the ambient light brightness, and then adjust the display screen brightness based on the ambient light brightness detected by the target camera. The target camera has an ambient light detection function and an image acquisition function, and can be a front camera of an electronic device or a rear camera of an electronic device. Considering that the display screen is set on the upper surface of the electronic device, the front camera is also set on the upper surface of the electronic device and is located on the same side as the display screen, and the ambient light brightness on different sides of the electronic device is different. In order to make the adjusted display screen brightness more in line with the current environment, this application takes the target camera as the front camera as an example for explanation. The method of the embodiment of the present application is used to adjust the display screen brightness of the electronic device, which can not only reduce the cost of the electronic device, but also has low power consumption and high performance of the electronic device.
[0070] Figure 1 The structure diagram of the electronic device 100 is shown. The electronic device 100 may be a mobile phone, a personal computer (PC), a tablet computer, an AR (Augmented Reality) device, a VR (Virtual Reality) device, a car computer, a wearable device, a smart home device, etc. The electronic device 100 may include a processor 110, an internal memory 121, a camera 193, a display screen 194, etc.
[0071] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0072] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. When the processor 110 needs to use the instruction or data again, it may be directly called from the memory, avoiding repeated access, reducing the waiting time of the processor 110, and thus improving the efficiency of the system.
[0073] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an Inter-Integrated Circuit (I2C) interface, an Inter-Integrated Circuit Sound (I2S) interface, a Pulse Code Modulation (PCM) interface, a Universal Asynchronous Receiver / Transmitter (UART) interface, a Mobile Industry Processor Interface (MIPI), a General-Purpose Input / Output (GPIO) interface, a Subscriber Identity Module (SIM interface), and / or a Universal Serial Bus (USB) interface, etc.
[0074] The internal memory 121 can be used to store computer executable program codes, which include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash memory (Universal Flash Storage, UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121 and / or instructions stored in a memory provided in the processor.
[0075] The electronic device 100 can realize the display function through a GPU, a display screen 194, and an application processor. Among them, the GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information. The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can use a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light-emitting diode or an active matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0076] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor. Among them, ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, the light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193. Camera 193 is used to capture static images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal oxide semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then transmits the electrical signal to ISP for conversion into a digital image signal. ISP outputs the digital image signal to DSP for processing. The DSP converts the digital image signal into an image signal in a standard format such as RGB, YUV, etc. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0077] Optionally, the electronic device 100 may further include an external memory interface 120, a Universal Serial Bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, and a user identification module card interface 195. Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, a bone conduction sensor 180M, etc.
[0078] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and videos are stored in the external memory card.
[0079] The USB interface 130 is an interface that complies with USB standard specifications, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100; it can also be used to transmit data between the electronic device 100 and peripheral devices; it can also be used to connect headphones to play audio through the headphones; it can also be used to connect other electronic devices, such as AR devices, etc.
[0080] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.
[0081] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, the wireless communication module 160, etc. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0082] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor, the baseband processor, and the like.
[0083] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0084] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (Low Noise Amplifier, LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.
[0085] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication technology (NFC), infrared technology (IR), etc.) applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and filters it, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0086] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include Global System for Mobile communications (GSM), General Packet Radio Dervice (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM and / or IR technology, etc. The GNSS may include a Global Positioning System (GPS), a Global Navigation Satellite System (GLONASS), a Beidou Navigation Satellite System (BDS), a Quasi-Zenith Satellite System (QZSS) and / or a Satellite Based Augmentation System (SBAS).
[0087] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D and the application processor.
[0088] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than those shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware. In addition, the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above-mentioned embodiments, or a combination of multiple interface connection methods.
[0089] The electronic device 100 is installed with a software system, which can run on the processor 110. The software system can be an Android system, a Windows system, an IOS system, a Hongmeng system, etc. The architecture adopted by the software system can be a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system with a layered architecture as an example to illustrate the software structure of the electronic device 100. See Figure 2 The Android system can be divided into four layers, from top to bottom: application layer, framework layer (Framework, FWK), hardware abstraction layer (HAL) and kernel layer.
[0090] The application layer may include a series of applications, such as camera, calendar, map, WLAN, music, short message, gallery, call, ambient light detection, face unlocking, etc., which are used to interact directly with users. These applications can be system built-in applications or non-system level applications. And these applications can have icons and application interfaces, or have application interfaces without icons, or have neither icons nor application interfaces.
[0091] The framework layer includes some predefined functions, which can provide application programming interfaces (APIs) and programming frameworks for applications in the application layer. The application programming interfaces provided by the framework layer may include interfaces related to camera services, interfaces related to sensor services, and interfaces related to other services. Interfaces related to different services can be defined as different service modules. For example, interfaces related to sensor services can be defined as sensor service modules, interfaces related to camera services can be defined as camera service modules, and interfaces related to other services can be defined as other service modules (not shown in the figure), etc. Among them, the sensor service module may include sub-modules such as SensorManager and SensorSerivce. SensorManager is used to adjust the brightness of the display screen of the electronic device according to the detected ambient light brightness. SensorSerivce is used to implement communication between related applications that need to call sensors in the application layer and SensorHAL. Optionally, the sensor service module can be used as an independent process, and SensorManager and SensorSerivce can be two threads in the process. The camera service module includes sub-modules such as ICameraSerivce and CameraSerivce. CameraService can be used to implement communication between applications that need to call the camera in the application layer (for example, camera applications, face unlocking applications, ambient light detection applications, etc.) and Camera HAL. Optionally, the camera service module can be used as an independent process, and ICameraSerivce and CameraSerivce can be two threads in the process. The electronic device is provided with multiple cameras, multiple cameras cannot be enabled at the same time, and different functions of the same camera cannot be enabled at the same time. When the front camera is used instead of the ambient light detection device, in order to solve the enabling priority problem of different functions of multiple cameras, the embodiment of the present application modifies the CameraSerivce in the camera service module, and adds the judgment logic of the enabling priority of different functions of the camera, so that when two or more camera functions need to be enabled at the same time, one can be enabled according to the judgment logic.
[0092] The hardware abstraction layer is located between the framework layer and the kernel layer, and its purpose is to abstract the hardware. The hardware abstraction layer hides the hardware interface details of a specific platform and provides a virtual hardware platform for the software system, making it hardware-independent and portable on multiple platforms. According to the functions implemented, the hardware abstraction layer can be further refined into a camera-related hardware abstraction layer (i.e., the Camera HAL described in the subsequent embodiments), a sensor-related hardware abstraction layer (i.e., the Sensor HAL described in the subsequent embodiments), and the like. The camera-related hardware abstraction layer can be defined as a camera control module, and the sensor-related hardware abstraction layer can be defined as a sensor control module. Optionally, the camera control module can be used as an independent process, and the sensor control module can also be used as an independent process. In order to realize the ambient light detection function of the front camera, the embodiment of the present application modifies the sensor control module (Sensor HAL). Specifically, an ambient light service control submodule (i.e., the CameraLightManager described in the subsequent embodiments) is added to the sensor control module, and the ambient light service control submodule provides multiple interfaces, including an Active interface, a DeActive interface, and the like. Among them, the Active interface is used to turn on the ambient light detection function of the front camera. The DeActive interface is used to turn off the ambient light detection function of the front camera. The embodiment of the present application also modifies the camera control module (Camera HAL). Specifically, a camera function customization submodule (i.e., CamxLightCustom described in the subsequent embodiments) is added to the camera control module, and the existing functional submodules (such as CHI-CDK, CAMX, etc.) in the camera control module are modified. Among them, the camera function customization submodule is used to obtain the ambient light brightness detected by the front camera when the front camera is used as an ambient light detection device, and send the ambient light brightness detected by the front camera to the sensor control module, so that the sensor control module reports the ambient light brightness to the sensor service module, thereby adjusting the display brightness of the electronic device. CHI-CDK is a customizable code implementation set. Based on the original code implementation set of CHI-CDK, the embodiment of the present application adds AIDL (Android Interface Definition Language, Android Interface Definition Language) service initialization-related code, so that different processes in the electronic device (such as Sensor HAL and Camera HAL) can communicate with each other. Among them, AIDL is used to define the interface between the client and the server of the Android system based on Binder communication. Binder is a cross-process communication mechanism of the Android system, which allows different processes to communicate and even communicate across devices.CAMX is a code implementation set of a general functional interface. Based on the original code implementation set in CAMX, the embodiment of the present application modifies the first function (i.e., the Open Camera function) therein, and adds a logic branch that can skip configuring image output resources for the front camera. Therefore, when the front camera is used as an ambient light detection device, the process of configuring image output resources for the front camera can be skipped, thereby reducing the power consumption of the front camera and improving the performance of the electronic device.
[0093] The kernel layer is the layer between hardware and software. The kernel layer may include display drivers, camera drivers, audio drivers, sensor drivers, etc., through which the display screen, front / rear cameras, audio players, sensors, etc. can be driven.
[0094] The present application provides a method for adjusting the brightness of a display screen. Figure 2 The electronic device 100 of the software system shown in the figure executes the embodiment of the present application as an example, see Figure 3 , the method flow provided in the embodiment of the present application includes:
[0095] 301. After the screen of the electronic device turns on, power on the front camera.
[0096] After the electronic device turns on the screen, the ambient light detection function is started, the electronic device powers on the front camera, and turns on the ambient light detection function of the front camera. The screen of the electronic device can be turned on for the first time when the device is turned on, or it can be a non-first time after the device is turned on. If the electronic device is in the off state, the electronic device can be turned on by long pressing the power button to light up the display. If the electronic device is in the on state, the display of the electronic device can be lit by touching the power button, touching the display using a preset gesture (such as double-clicking, etc.), lifting the electronic device, and so on. After the electronic device turns on the screen, the front camera is powered on. The front camera can be powered on based on the screen of the electronic device to initialize the front camera, thereby turning on the front camera to detect the ambient light brightness.
[0097] 302. The electronic device detects the brightness of ambient light through a front camera.
[0098] After the front camera is powered on, the ambient light detection function of the front camera is turned on. The electronic device can detect the ambient light brightness of the environment where the electronic device is located through the front camera, thereby realizing automatic adjustment of the brightness of the display screen.
[0099] 303. Based on the ambient light brightness detected by the front camera, the electronic device adjusts the brightness of the display screen.
[0100] In a possible implementation, the ambient light brightness detected by the front camera may be the first ambient light brightness output by the front camera, and the electronic device may adjust the display brightness based on the first ambient light brightness output by the front camera. For example, the electronic device may use the first ambient light brightness as the adjusted display brightness; or may obtain the default brightness of the display of the electronic device, and adjust the default brightness based on the first ambient light brightness to obtain the adjusted display brightness.
[0101] In another possible implementation, the ambient light brightness detected by the front camera may be a second ambient light brightness generated based on the first ambient light brightness output by the front camera, and the electronic device may adjust the display brightness based on the second ambient light brightness. For example, the electronic device may use the second ambient light brightness as the adjusted display brightness; or may obtain the default brightness of the display of the electronic device, and adjust the default brightness based on the second ambient light brightness to obtain the adjusted display brightness.
[0102] Considering that when the electronic device adjusts the brightness of the display screen, if the camera application is not started, the electronic device does not need to display the image. In order to reduce the power consumption of the front camera and improve the performance of the electronic device, the front camera does not capture images during the process of the electronic device adjusting the brightness of the display screen.
[0103] 304. In response to the user's operation, the electronic device starts a camera application.
[0104] After the electronic device turns on the screen, the electronic device can detect the user's touch operation on the camera application. When the electronic device detects the user's touch operation on the camera application icon, the electronic device starts the camera application. The electronic device can also detect the call operation of a third-party application on the camera application. When the electronic device detects that the third-party application calls the camera application, it can start the camera application.
[0105] 305. After starting the camera application, the electronic device captures images through the front camera and displays the interface of the camera application.
[0106] Before the camera application is started, the front camera is powered on, and the electronic device adjusts the display brightness according to the ambient light brightness detected by the front camera. After the camera application is started, based on the camera application being started, the photo function of the front camera needs to be turned on. Since the ambient light detection function of the front camera is enabled at this time, the photo function is not enabled, and each camera usually enables one function. In order to realize the photo function of the front camera, the electronic device powers off the front camera, turns off the ambient light detection function of the front camera, and then powers on the front camera to turn on the photo function of the front camera. After the photo function of the front camera is turned on, the electronic device can obtain the image captured by the front camera, and then display the image captured by the front camera on the interface of the camera application, thereby meeting the user's photo needs.
[0107] Optionally, after starting the camera application, the electronic device may not adjust the brightness of the display screen, thereby reducing the power consumption of the electronic device and improving the performance of the electronic device.
[0108] In another embodiment of the present application, after the camera application is started, in response to the user's operation, the electronic device turns off the camera application. After the camera application is turned off, the electronic device detects the ambient light brightness through the front camera, and then adjusts the display brightness based on the ambient light brightness detected by the front camera. In the process of the electronic device adjusting the display brightness, the front camera does not capture images. Specifically, when the electronic device detects the ambient light brightness through the front camera, the electronic device can power off the front camera and turn off the camera function of the front camera based on the camera application being turned off, and then power on the front camera and turn on the ambient light detection function of the front camera to obtain the ambient light brightness detected by the front camera.
[0109] In another embodiment of the present application, in order to protect the user's information security, the display screen of the electronic device can be set with a lock screen password. The electronic device can be unlocked by obtaining the lock screen password input by the user, and can also unlock the display screen by starting the face unlock application and using the face image captured by the front camera. In this way, after the electronic device turns on the screen, it will not only start the face unlock application and perform the face unlock operation, but also start the ambient light detection application and perform the display screen brightness adjustment operation. If after the electronic device turns on the screen, the electronic device first receives an instruction from the face unlock application to turn on the front camera, and then receives an instruction from the ambient light detection application to turn on the front camera, the electronic device will first turn on the face unlock function of the front camera, and after the screen is unlocked, turn on the ambient light detection function of the front camera.
[0110] Specifically, after the electronic device turns on the screen, the face unlocking application is started. After the face unlocking application is started, the electronic device collects images through the front camera. After the display screen is unlocked, the face unlocking application is closed. After the face application is closed, the electronic device powers off the front camera, turns off the face unlocking function of the front camera, then powers on the front camera and turns on the ambient light detection function of the front camera, thereby adjusting the brightness of the display screen through the ambient light brightness detected by the front camera.
[0111] Of course, if the electronic device first receives an instruction from the ambient light detection application to turn on the front camera, and then receives an instruction from the face unlock application to turn on the front camera, the electronic device will first turn on the ambient light detection function of the front camera to adjust the brightness of the display, and then turn on the face unlock function of the front camera to unlock the display. After the electronic device turns on the screen, the underlying processing logic of the electronic device under different enabling orders for the ambient light detection function and face unlock function of the front camera can be found in the subsequent Fig.11 and Fig.12 The flowchart is not described in detail here.
[0112] For the above Figure 2 For the electronic device of the software system shown, the camera service module can control the opening and closing of the front camera by issuing instructions to the camera control module, and the sensor service module can control the opening and closing of the ambient light detection device by issuing instructions to the sensor control module. When the front camera is used instead of the ambient light detection device, the opening and closing of the front camera needs to be controlled by the instructions issued by the sensor service module. Since the sensor control module cannot pass the instructions issued by the sensor service module to the front camera, and the camera control module can pass the instructions issued by the camera service module to the front camera, in order to realize the front camera replacing the ambient light detection device, it is necessary to establish a control path between the sensor control module and the camera service module, so as to realize the control of the front camera with the help of the camera service module. The sensor control module of the HAL layer of the embodiment of the present application can be used as an independent process, and the camera service module of the FWK layer can also be used as an independent process. Therefore, when establishing the control path between the sensor control module of the HAL layer and the camera service module of the FWK layer, it can be established based on the HIDL service. Among them, HIDL is used to define the interface between the HAL layer and the FWK layer of the Android system based on Binder communication.
[0113] After opening the control path between the sensor control module and the camera service module, it is also necessary to establish a data path between the sensor control module and the camera control module, so that after turning on the ambient light detection function of the front camera, the camera control module can transmit the ambient light brightness detected by the front camera to the sensor control module, and then the sensor control module sends it to the sensor service module, thereby realizing the adjustment of the display brightness.
[0114] For the process of establishing the data path between the sensor control module and the camera control module, see Figure 4 The present application embodiment provides a method for adjusting the brightness of a display screen, which can be performed by Figure 2 The electronic device 100 of the software system shown in the figure executes the method flow provided by the embodiment of the present application, including:
[0115] 401. Based on the electronic device being turned on, the camera control module initializes the AIDL service.
[0116] In an embodiment of the present application, the camera control module (i.e., Camera HAL) can be an independent process, which can be defined as a camera control process, and the submodules included in the camera control module (such as CHK-CDK, CAMX, CamxLightCustom, etc.) can be different threads in the camera control process. AIDL service initialization can be the process of pulling up the AIDL service. By initializing the AIDL service, communication between the client and the server based on the AIDL service can be achieved. AIDL service initialization can be performed in the camera control module, specifically, it can be performed in the CHK-CDK of the camera control module. The AIDL service can be initialized during the startup of the electronic device, or it can be initialized after startup when the client and server based on the AIDL service need to communicate. The embodiment of the present application does not limit the timing of AIDL service initialization. The process of AIDL service initialization can correspond to Figure 5 Step ① in Figure 5 When the electronic device is turned on, the AIDL service in the CHI-CDK of the Camera HAL is initialized, which can be to pull up the AIDL service.
[0117] Optionally, the AIDL service initialization process can be implemented using the following code:
[0118] CamLightAidlImpl::GetInstance()->Init(…).
[0119] 402. The sensor service module sends a brightness monitoring instruction to the sensor control module.
[0120] In the embodiment of the present application, the sensor service module (i.e., SensorService) can be used as an independent process, which can be defined as the sensor service process, and the submodules (such as SensorManager, SensorService, etc.) included in the sensor service module can be threads in the sensor service process. The sensor control module (i.e., Sensor HAL) can also be used as an independent process, which can be defined as the sensor control process, and the submodules (such as CameraLightManager, etc.) included in the sensor control module can be threads in the sensor control process.
[0121] After the electronic device is turned on, the ambient light detection application in the application layer sends a screen-lighting message to the sensor service module. The screen-lighting message may include the package name of the ambient light detection application. The screen-lighting message is used to instruct the sensor service module to adjust the brightness of the electronic device display screen. After receiving the screen-lighting message, the sensor service module sends a brightness monitoring instruction to the sensor control module. The brightness monitoring instruction is used to instruct the sensor control module to obtain the ambient light brightness. The brightness monitoring instruction can be in the form of a callback function, so that after the sensor control module obtains the ambient light brightness, it can return the obtained ambient light brightness to the sensor service module.
[0122] Optionally, the sensor service module sending the brightness monitoring instruction to the sensor control module may be: the sensor service process sends the brightness monitoring instruction to the sensor control process. Figure 5 Specifically, the sensor service module sends the brightness monitoring instruction to the sensor control module. The SensorManager in the FWK layer generates a brightness monitoring instruction based on the screen-on message sent by the ambient light detection application in the application layer, and sends the brightness monitoring instruction to the Sensor HAL in the HAL layer through the SensorService.
[0123] 403. After receiving the brightness monitoring instruction, the sensor control module calls the first interface based on the AIDL service and registers the data callback function in the camera control module.
[0124] After receiving the brightness monitoring instruction, the sensor control module calls the first interface based on the AIDL service and registers the data callback function in the camera control module. It can be based on the brightness monitoring instruction, the sensor control module calls the first interface and registers the data callback function in the camera control module. It can also be in response to the brightness monitoring instruction, the sensor control module calls the first interface and registers the data callback function in the camera control module.
[0125] In the computer field, AIDL service is used to achieve communication between different processes. For two processes based on AIDL service communication, one process is used to generate data and can be used as an AIDL server; the other process is used to issue control instructions and receive data, and can be used as an AIDL client. In an embodiment of the present application, when the front camera is used instead of the ambient light detection device, the camera control module (Camera HAL) is used to provide ambient light brightness and can be used as an independent process. Therefore, it can be regarded as an AIDL server (referred to as the server in subsequent embodiments); the sensor control module (SensorHAL) is used to receive ambient light brightness, and therefore, it can be regarded as an AIDL client (referred to as the client in subsequent embodiments).
[0126] Among them, the first interface can be an Active interface. The Active interface is used to turn on the ambient light detection function of the front camera. After the sensor control module calls the Active interface to turn on the ambient light detection function of the front camera, the sensor control module can call the Active interface to register a data callback function in the camera control module. Through the data callback function, the camera control module can send the ambient light brightness detected by the front camera to the sensor control module, thereby opening up the data path between the camera control module and the sensor control module, making it possible for the front camera to replace the ambient light device.
[0127] In the embodiment of the present application, the sensor control module calls the Active interface. Before registering the data callback function in the camera control module, the Active interface needs to be declared first. Since the Active interface belongs to the AIDL interface, its declaration usually contains two parameters. One can be the client's process ID (Process Identifier, PID), that is, the process ID of the process corresponding to the sensor control module (Sensor HAL) as the client; the other can be the client's callback object (CallBack), that is, the object in the sensor control module used to receive the ambient light brightness. Optionally, the callback object corresponds to Figure 5 ReportLusStatus in.
[0128] Among them, the following code can be used when declaring the Active interface:
[0129] interface ILuxService{
[0130] void RegisterLuxCallback(in int pid,in vendor.XXX.hardware.camlight.ILuxCallback callback);
[0131] void SetCalidata(in float calidata);
[0132] ….
[0133] Furthermore, based on the declaration content of the Active interface, the sensor control module and the camera control module can register callback interfaces on this end respectively. When the callback interface registration in the sensor control module and the camera control module is completed, the registration of the data callback function in the camera control module is completed. Optionally, the sensor control module can register the callback interface in CamLightManager, and the camera control module can register the callback interface in CamxLightCustom.
[0134] Among them, the following code can be used when registering the callback interface in the sensor control module:
[0135] CamLightManager::RegisterLuxCb(){
[0136] mCamLightService->RegisterLuxCallback(callingPid,mLuxCallback);
[0137] }
[0138] The following code can be used when registering the callback interface in the camera control module:
[0139] void CamxLightCustom::RegisterLightLuxStatusCb(Callback callback)
[0140] Optionally, the sensor control module calls the first interface based on the AIDL service, and the step of registering the data callback function in the camera control module may correspond to Figure 5 Steps ② and ③ specifically include: after the Sensor HAL receives the brightness monitoring instruction, it calls the Active interface in CamLightManager, registers the callback interface in CamLightManager based on the declaration content of the Active interface, and registers the callback interface in CamxLightCustom. When the callback interface registration in CamLightManager and CamxLightCustom is completed, the registration of the data callback function is completed.
[0141] Optionally, the data callback function can not only return the ambient light brightness detected by the front camera to the sensor control module when the ambient light detection function of the front camera is enabled; it can also send a notification message to the sensor control module to enable the ambient light detection function of the front camera when the ambient light detection function of the front camera fails to be enabled or is turned off, causing the camera that has failed to enable the ambient light detection function or is turned off to be turned off.
[0142] Optionally, due to the limitation of the photosensitivity of the front camera itself, there is a certain error between the ambient light brightness detected by the front camera and the ambient light brightness in the actual environment. In order to improve the accuracy of display brightness adjustment, the camera control module in the embodiment of the present application may also register a data calibration interface function in the callback interface when registering the callback interface. The data calibration function is used to provide a calibration coefficient between the ambient light brightness detected by the front camera and the ambient light brightness in the actual environment. When the ambient light brightness of the front camera is returned based on the callback interface, the ambient light brightness detected by the front camera may be calibrated. The data calibration function may be LuxValueConvert().
[0143] Optionally, a process of an electronic device may suddenly crash during operation, and crashes may also occur for the server and client involved in AIDL. In an embodiment of the present application, in order to be able to monitor the crash of the camera control module (server) and the sensor control module (client) in a timely manner, the sensor control module and the camera control module may also register death monitoring objects on this side, respectively. In one possible implementation, the camera control module may register a first death monitoring object on this side when registering a callback interface. By registering the first death monitoring object, the crash of the camera control module in the screen-on scenario and the screen-off scenario can be monitored. The sensor control module may register a second death monitoring object on this side when registering the callback interface. By registering the second death monitoring object, the crash of the sensor control module in the screen-on scenario and the screen-off scenario can be monitored. Optionally, it can correspond to Fig.15 Step ① specifically includes: in the process of SensorHAL registering the callback interface in CamLightManager, the second death monitoring object can be registered in CamLightManager, so that when the crash event of SensorHAL is monitored, a death notification message is generated to notify Camera HAL; in the process of Camera HAL registering the callback interface in CamxLightCustom, the first death monitoring object can be registered in CamxLightCustom, so that when the crash event of Camera HAL is monitored, a death notification message is generated to notify SensorHAL.
[0144] Optionally, for electronic devices, the front camera on some electronic devices may support the ambient light detection function, and the front camera on some electronic devices may not support the ambient light detection function. In order to avoid performing the enabling operation on the front camera that does not support the ambient light detection function and reduce the resource consumption of the electronic device, the sensor control module may obtain the value on the preset identification position before calling the first interface to turn on the ambient light detection function of the front camera, specifically before executing step 403, such as when the electronic device is turned on, or when a brightness monitoring instruction is received, and then based on the value on the preset identification position, determine whether the front camera of the electronic device supports the ambient light detection function. If the front camera supports the ambient light detection function, the first interface is called to turn on the ambient light detection function of the front camera. If the front camera does not support the ambient light detection function, the first interface is no longer called. Among them, the preset identification position can be is_ambient_light, which is used to indicate whether the front camera supports the ambient light detection function, and the value on the preset identification position can be true or false. When the value on the preset identification position is true, it can be determined that the front camera supports the ambient light detection function; when the value on the preset identification position is false, it can be determined that the front camera does not support the ambient light detection function.
[0145] It should be noted that when the electronic device is not turned off, the data callback function registered in this step can be directly used when the front camera is subsequently called to detect the ambient light brightness without re-registration; when the electronic device is turned off, the data callback function registered in this step will be destroyed, and when the electronic device is turned on again, the above steps 401 to 403 need to be executed to register the data callback function.
[0146] 404. The sensor control module calls the second interface based on the HIDL service and sends a first instruction to the camera service module.
[0147] Generally, cameras include two types: front cameras and rear cameras, and the number of front cameras and rear cameras is at least one respectively. Moreover, the front camera and the rear camera have multiple functions respectively, including at least one of a photo taking function, a face unlocking function, an ambient light detection function, and the like. In order to distinguish different types of cameras and different functions of cameras of the same type, the embodiment of the present application abstracts multiple logical cameras according to the type and function of the camera, and each logical camera corresponds to an identifier. For example, according to the photo taking function of the front camera, a logical camera A can be abstracted, and according to the ambient light detection function of the front camera, a logical camera B can be abstracted. The logical camera A and the logical camera B can correspond to the same front camera or to different front cameras. For the photo taking function of the logical camera A, i.e., the front camera, the identifier set is Camera ID=1, and for the ambient light detection function of the logical camera B, i.e., the front camera, the identifier set is Camera ID=4.
[0148] In the embodiment of the present application, the sensor control module can call the first interface to generate the first instruction, and then the second interface sends the first instruction to the camera service module. The second interface belongs to the interface of the HIDL service, which can be Figure 5 libcamera2ndk_vendor in etc. The camera service module can be an independent process, and the independent process can be defined as a camera service process. The first instruction can be an Open Camera instruction. The first instruction can include a first identifier, and the first identifier corresponds to the ambient light detection function of the front camera, which can be Camera ID=4. The first instruction can also include a first package name, and the first package name is the package name of the ambient light detection application.
[0149] Optionally, the sensor service module calls the second interface to send the first instruction to the camera service module, which may correspond to Figure 5 Step ④ specifically includes: calling the Active interface of CamLightManager in the Sensor HAL, generating a first instruction, and sending the first instruction to the ICameraService in the FWK layer through the libcamera2ndk_vendor interface based on the HIDL service.
[0150] 405. After receiving the first instruction, the camera service module calls the first function in the camera control module, and executes the first function according to the first identifier to control the camera driver to power on the front camera, initialize the camera register and create a reading thread for the ambient light brightness.
[0151] Optionally, the operations of powering on the front camera, initializing the camera register, etc. in this step may be a specific process of turning on the front camera, or may be a process of powering on and initializing the front camera.
[0152] Among them, the first function is used to turn on any function of any camera in the electronic device, and the first function can be an Open Camera function. After receiving the first instruction, the camera service module can call the first function in the camera control module and execute the first function according to the first identifier. According to the first identifier, it can be determined that the ambient light detection function of the front camera needs to be turned on. At this time, the front camera will replace the ambient light detection device. When the front camera replaces the ambient light detection device, the front camera needs to detect the ambient light brightness without collecting images. In order to reduce the power consumption of the front camera, the camera service module executes the necessary processes in the first function to turn on the ambient light detection function of the front camera according to the first identifier, such as applying for CSL resource cache, powering on the front camera, initializing camera registers, creating a reading thread for ambient light brightness, etc., and jumps out of the processes that are not related to turning on the ambient light detection function of the front camera, such as the process of configuring image output resources, etc. By executing the first function, a corresponding control instruction can be generated, and the control instruction is sent to the camera driver, thereby controlling the camera driver to apply for CSL resource cache for the front camera, power on the front camera, initialize camera registers, create a reading thread, etc. The created reading thread is used to read and calculate the ambient light brightness detected by the front camera. Optionally, the reading thread can be an asynchronous reading thread. Optionally, the reading thread can periodically read the ambient light brightness detected by the front camera. Based on the initialization of the camera register, the period of the front camera detecting the ambient light brightness, the frequency of the front camera detecting the ambient light brightness, etc. can be written into the front register to control the operation of the front camera.
[0153] Optionally, this step may correspond to Figure 5 ⑤ in it specifically includes: when receiving the first instruction, calling the Open Camera function in CAMX of Camera HAL through CameraService and executing the Open Camera function, sending a control instruction to the camera driver through the CamxLightCustom interface, so that the camera driver applies for CSL resource cache for the ambient light detection function of the front camera, powers on the front camera, initializes the camera register, creates an asynchronous read thread, etc.
[0154] When the method of the embodiment of the present application is adopted, when the front camera is used instead of the ambient light detection device, image output resources will not be configured for the front camera, and the front camera will not capture images, thereby reducing the resource consumption of the front camera and improving the performance of the electronic device.
[0155] 406. The camera control module obtains the first ambient light brightness output by the front camera, and sends the second ambient light brightness to the sensor control module through a data callback function.
[0156] Among them, the second ambient light brightness is generated based on the first ambient light brightness, and the second ambient light brightness can be equal to the first ambient light brightness, or the second ambient light brightness may not be equal to the first ambient light brightness. When the second ambient light brightness is not equal to the first ambient light brightness, the second ambient light brightness can be generated based on the first ambient light brightness and the third ambient light brightness, and the third ambient light brightness is the calibration coefficient provided by the data calibration function, and the first ambient light brightness is calibrated to obtain the calibrated ambient light brightness. The second ambient light brightness can also be generated based on the first ambient light brightness, the third ambient light brightness and the state parameters of the front camera, and the state parameters include available and unavailable, etc. Available means that the ambient light detection function of the front camera is available, and unavailable means that the ambient light detection function of the front camera is unavailable. It should be noted that the first ambient light brightness and the second ambient light brightness in the embodiment of the present application are not a brightness value, but represent a type of brightness value. For example, the first ambient light brightness represents the brightness value output by the front camera at different times; the second ambient light brightness represents the brightness value sent by the camera control module to the sensor control module at different times.
[0157] In a possible implementation, the camera driver can periodically read the first ambient light brightness detected by the front camera through a reading thread, and send the read first ambient light brightness to the camera control module, so that the camera control module can obtain the first ambient light brightness output by the front camera, and the reading cycle can be 200ms. The camera driver can also periodically read the first ambient light brightness detected by the front camera through a reading thread, and store the read first ambient light brightness in a cache. The camera control module can periodically read the first ambient light brightness stored in the cache of the camera driver, thereby obtaining the first ambient light brightness output by the front camera. Optionally, the reading cycle of the camera driver and the reading cycle of the camera control module can be the same or different.
[0158] Optionally, the camera control module may send the second ambient light brightness to the sensor control module through a pre-registered data callback function. Specifically, the camera control module may fill the second ambient light brightness into the pre-registered data callback function, and send the second ambient light brightness to the sensor control module through the data callback function.
[0159] In combination with different contents of the second ambient light brightness, the camera control module sends the second ambient light brightness to the sensor control module through a pre-registered data callback function, specifically including the following methods:
[0160] In the first manner, the camera control module fills the first ambient light brightness output by the front camera into the data callback function, and sends the first ambient light brightness to the sensor control module through the data callback function.
[0161] In the second method, the camera control module fills the first ambient light brightness detected by the front camera and the third ambient light brightness obtained after calibration into the data callback function, and sends the first ambient light brightness and the second ambient light brightness to the sensor control module through the data callback function.
[0162] In the third method, the camera control module fills the first ambient light brightness detected by the front camera, the third ambient light brightness obtained after calibration, and the status parameters of the front camera into the data callback function, and sends the first ambient light brightness, the second ambient light brightness and the status parameters to the sensor control module through the data callback function.
[0163] For the third method, the form of the filled data callback function can be:
[0164] pCamxLightCustom->mStatusCb(static_cast <float>(luxValue),luxValueFinal,status);
[0165] Among them, luxValue is the first ambient light brightness, that is, the ambient light brightness detected by the front camera, luxValueFinal is the third ambient light brightness, that is, the calibrated ambient light brightness, and status is the status parameter of the front camera.
[0166] Optionally, three specific implementation methods are listed here, and only one of them can be selected to return the second ambient light brightness, or multiple methods can be selected to return the second ambient light brightness. The same method or different methods can be used each time the second ambient light brightness is returned. For example, the first implementation method can be used to return the second ambient light brightness for the first time, the second implementation method can be used to return the second ambient light brightness for the second time, the third implementation method can be used to return the second ambient light brightness for the third time, and so on; the second ambient light brightness can also be returned once in multiple methods each time, and then the second ambient light brightness returned in multiple methods can be merged.
[0167] 407. The sensor control module sends the second ambient light brightness to the sensor service module.
[0168] Optionally, the ReportLuxStatus object in the sensor control module may receive the second ambient light brightness sent by the camera control module, and then send the second ambient light brightness to the sensor service module.
[0169] In a possible implementation, when the sensor service module sends a brightness monitoring instruction to the sensor control module, a callback function is registered in the sensor control module, and the sensor control module can send the second ambient light brightness to the sensor service module through the callback function. Optionally, the sensor control module can fill the second ambient light brightness into the callback function, and send the second ambient light brightness to the sensor control module through the callback function.
[0170] In another possible implementation, the sensor service module may periodically read the second ambient light brightness of the sensor control module.
[0171] For the processing logic of the sensor control module for the brightness of the second ambient light, please refer to the following code:
[0172] ::ndk::ScopedAStatus ReportLuxStatus(const LuxStatus&out_data){
[0173] / / Client data processing logic
[0174] }
[0175] Optionally, steps 406 to 407 may correspond to Figure 5 ⑤ and ⑥ specifically include: CamxLightCustom of Camera HAL obtains the first ambient light brightness output by the front camera, returns the second ambient light brightness to the ReportLuxStatus object in CamLightManager of Sensor HAL through a pre-registered data callback function, and the ReportLuxStatus object reports the second ambient light brightness to SensorManager through SensorSerivce.
[0176] 408. The sensor service module adjusts the brightness of the display screen of the electronic device based on the brightness of the second ambient light.
[0177] In a possible implementation, adjusting the brightness of the display screen may be setting the brightness of the display screen. Specifically, the sensor service module may determine the brightness of the display screen based on the second ambient light brightness, and then set the brightness of the display screen to the determined brightness; the sensor service module may also determine the brightness of the display screen based on the historical ambient light brightness and the second ambient light brightness, and then set the brightness of the display screen to the determined brightness.
[0178] In another possible implementation, adjusting the brightness of the display screen may be to adjust the initial brightness based on the initial brightness of the display screen. The initial brightness may be a brightness value pre-set by a technician. Specifically, the sensor service module may determine the brightness of the display screen based on the second ambient light brightness, and then adjust the brightness of the display screen from the initial brightness to the determined brightness; the sensor service module may also determine the brightness of the display screen based on the historical ambient light brightness and the second ambient light brightness, and then adjust the brightness of the display screen from the initial brightness to the determined brightness. Optionally, when adjusting the brightness of the display screen from the initial brightness to the determined brightness, it may be adjusted gradually to avoid excessive brightness changes affecting the user experience.
[0179] Optionally, when adjusting the brightness of the display screen, the sensor service may generate a brightness adjustment instruction, and then send the brightness adjustment instruction to the sensor control module. The sensor control module sends the brightness adjustment instruction to the display screen driver, so that the display screen driver executes the brightness adjustment instruction to adjust the brightness of the display screen.
[0180] The above description is based on the example that the screen of the electronic device is turned on for the first time when the device is turned on. When the screen of the electronic device is not turned on for the first time, the electronic device may not perform the initialization process of the AIDL service in step 401 and the registration process of the data callback function in step 403, but perform other steps. For details, see Figure 4 or Figure 5 The process shown will not be repeated here.
[0181] See also Figure 6 The embodiment of the present application provides a method for turning off the screen and turning off the ambient light detection function of the front camera. When the screen of the electronic device is turned off, the method can turn off the ambient light detection function of the front camera to reduce the power consumption of the electronic device. Figure 2 The electronic device 100 of the software system shown in the figure performs the embodiment of the present application as an example, and the method can be used with Figure 4 The display brightness adjustment process shown is independent and has no timing relationship. Figure 4 Executed at any time after step 405 in the above. Figure 6 , the method flow provided in the embodiment of the present application includes:
[0182] 601. After the screen of the electronic device is turned off, the sensor control module calls the third interface based on the AIDL service, and then calls the second interface to send a second instruction to the camera service module.
[0183] Optionally, based on the screen turning off of the electronic device, the sensor service module can receive a screen turning off message of the electronic device. After receiving the screen turning off message, the sensor service module can send a stop brightness monitoring instruction to the sensor control module. After receiving the stop brightness monitoring instruction, the sensor control module can call the third interface, generate a second instruction, and then call the second interface to send the second instruction to the camera service module. Among them, the third interface can be a DeActive interface, which is used to turn off the ambient light detection function of the front camera. The second instruction can be a Close Camera instruction, including a first identifier, a first package name, etc.
[0184] Optionally, this step may correspond to Figure 7 ①②③④ in it specifically include: SensorManager receives the screen-off message of the electronic device, generates a stop brightness monitoring instruction, and calls SensorSerivce to send the stop brightness monitoring instruction to Sensor HAL, Sensor HAL calls the DeActive interface of CameraLightManager to generate a Close Camera instruction, which includes Camera Id=4 and the package name of the ambient light detection application, and then calls libcamera2ndk_vendor to send the Close Camera instruction to the CameraSerivce of the FWK layer.
[0185] 602. After receiving the second instruction, the camera service module calls the second function in the camera control module, and executes the second function according to the first identifier to control the camera driver to close the reading thread and power off the front camera.
[0186] After receiving the second instruction, the camera service module turns off the ambient light detection function of the target camera based on the first identifier. Specifically, the camera service module calls the second function in the camera control module, and executes the second function according to the first identifier. By executing the second function, a corresponding shutdown instruction can be generated, and the generated shutdown instruction is sent to the camera driver. Based on the shutdown instruction, the camera driver turns off the reading thread, stops reading the ambient light brightness, and powers off the front camera, and then releases the CSL cache resources applied for the front camera. Furthermore, after the camera driver turns off the reading thread, the camera control process will stop sending the second ambient light brightness to the sensor control module through the data callback function.
[0187] The logic code for turning off the ambient light detection function of the front camera can be:
[0188] CloseCamLightSensor(const struct camera3_device*pCamera3Device,bool&isCamLightId)(Close Camera light id encapsulation function)
[0189] Optionally, this step may correspond to Figure 7 ⑤ in it specifically includes: based on the Close Camera instruction, CameraSerivce calls the Close Camera function in CAMX of Camera HAL, and by executing the Close Camera function, controls the camera driver to close the asynchronous reading thread, stops reading the ambient light brightness, powers off the front camera, and releases the CSL cache resources applied for the front camera.
[0190] Usually, electronic devices are equipped with a front camera and a rear camera. The front camera supports an image output mode and an ambient light detection mode. The image output mode corresponds to the photo function, face unlocking function, etc. of the front camera. In the image output mode, the front camera needs to collect images to meet the user's usage needs. Unlike the image output mode, in the ambient light detection mode, the display brightness is adjusted based on the ambient light brightness output by the front camera to improve the user's usage needs, and the user demand is lower than that in the image output mode. In actual application, the front camera and the rear camera cannot be enabled at the same time, and the image output mode and the ambient light detection mode of the front camera cannot be enabled at the same time. In order to solve the problem of enabling priority of the camera, the embodiment of the present application sets a corresponding identifier for each camera in the electronic device, each identifier corresponds to a logical function of the camera, and sets the conflict judgment logic of the camera identifier, and configures different priorities for different package names, so that the priority of different identifiers can be determined based on the package name priority.
[0191] Specifically, the process of configuring a corresponding identifier for a camera in an electronic device may include: during the power-on process of the electronic device, the camera control module interacts with the camera driver to obtain the type and function of the camera in the electronic device, and then abstracts multiple logical cameras based on the type and function of the camera, and sets a corresponding identifier for each logical camera. For example, the identifier set for the photo function of the front camera is CameraID=1; the identifier set for the ambient light detection function of the front camera is CameraID=4.
[0192] The above is the process of setting the flag for the ambient light detection function of the front camera, which can be seen in the following code:
[0193]
[0194] Taking CameraID=1 and CameraID=4 as an example, the conflict judgment logic configured in the camera control module is:
[0195]
[0196]
[0197] To ensure normal use by the user, the embodiment of the present application can configure the lowest priority for the package name of the ambient light detection application, so that when the user wants to open the camera application to take a photo, the user can be provided with a photo service. To facilitate subsequent applications, the camera control module can store the set camera identifier and the priority of different package names. Furthermore, the camera control module can send the set camera identifier and the priority of different package names to the camera service module for storage, so that the camera service module can manage the enabling priority of the camera.
[0198] In the embodiment of the present application, the management logic of the camera enabling priority of the camera service module can be: receiving a target instruction, the target instruction includes a target identifier and a target package name. After receiving the target instruction, the camera service module queries the camera list, and the camera list is used to store the identifier corresponding to the currently enabled camera. When the camera list is empty, it can be determined that there is no enabling conflict for the camera, and then based on the target instruction, the function of the camera corresponding to the target identifier is turned on; when the camera list is not empty, it can be determined that there is an enabling conflict for the camera, that is, there is currently an enabled camera, and then based on the target package name and the package name of the currently enabled camera, the priority of the target identifier and the identifier corresponding to the currently enabled camera can be determined. When the priority of the target identifier is lower than the priority of the currently enabled camera, the function of the camera corresponding to the target identifier is no longer turned on; when the priority of the target identifier is higher than the priority of the currently enabled camera, the currently enabled camera is turned off, and then the function of the camera corresponding to the target identifier is turned on.
[0199] The above judgment logic can be seen in the following code:
[0200] TagName: "com.xxx.device.capabilities.camLightSupported"; / / Static capability name.
[0201] int CamLightManager::CamLightCheck(ACameraManager*manager,ACameraIdList*cameraIdList)
[0202] ret=ACameraManager_openCamera(mCameraManager,(const char*)buff,&mDeviceCb,&mDevice);
[0203] Among them, ACameraManager_openCamera is the interface function of Open Camera, and buff is PackageName.
[0204] See also Figure 8 The embodiment of the present application provides a method for managing camera enabling priority, so as to have Figure 2 The electronic device 100 of the software system shown in FIG. Figure 8 , the method flow provided in the embodiment of the present application includes:
[0205] 801. After the screen of the electronic device turns on, the camera service module receives a first instruction.
[0206] The first instruction may include a first identifier and a first package name, etc. The first identifier corresponds to an ambient light detection function of the target camera. The first package name is the package name of the ambient light detection application.
[0207] This step can be Figure 4 Executed when step 404 is executed.
[0208] 802. After receiving the first instruction, the camera service module queries the camera list.
[0209] The camera list is used to store the IDs of currently enabled cameras. Figure 4 Executed before step 405.
[0210] 803. When the camera list is empty, the camera service module turns on the ambient light detection function of the target camera based on the first identifier.
[0211] After executing this step, it is determined that there is no identification of the currently enabled camera, and step 405 can be executed.
[0212] See also Fig. 9 The embodiment of the present application provides a camera enabling priority management method, which has Figure 2 The electronic device 100 of the software system shown in FIG. 1 is executed as an example, and the method is Figure 4 The method for adjusting the brightness of the display screen shown has a time sequence relationship, which can be Figure 4 Executed after step 405. Fig. 9 , the method flow provided in the embodiment of the present application includes:
[0213] 901. Based on the camera application being started, the camera service module receives a third instruction.
[0214] The third instruction includes a second identifier and a second package name. The second identifier corresponds to the photo function of the front camera, and the second package name is the package name of the camera application.
[0215] 902. After receiving the third instruction, the camera service module determines that the first identifier exists in the camera list, and determines the priority of the first identifier and the second identifier according to the first package name and the second package name.
[0216] pass Figure 4 It can be seen from the embodiment shown that when the third instruction is received, the electronic device adjusts the brightness of the display screen by the ambient light brightness detected by the front camera, and the ambient light detection function of the front camera is enabled. After receiving the third instruction, the camera service module queries the camera list, obtains the first identifier, and then determines the priority of the first identifier and the second identifier according to the first package name and the second package name.
[0217] 903. The camera service module determines that the priority of the first identifier is lower than the priority of the second identifier, turns off the ambient light detection function of the target camera, and then turns on the photo-taking function of the target camera based on the second identifier.
[0218] In an embodiment of the present application, the priority of the first package name is lower than the priority of the second package name, and therefore, it can be determined that the priority of the first identifier is lower than the priority of the second identifier. Based on the fact that the priority of the first identifier is lower than the priority of the second identifier, the camera service module controls the camera driver to power off the front camera to turn off the ambient light detection function of the front camera. Specifically, the camera service module calls the second function in the camera control module, and executes the second function according to the first identifier, thereby controlling the camera driver to turn off the reading thread, stop reading the ambient light brightness, and power off the front camera, and then release the CSL cache resources applied for the front camera. After the above operations are performed, the ambient light detection function of the front camera is turned off.
[0219] Optionally, after the ambient light detection function of the front camera is turned off, the camera service module further sends a first notification message to the sensor control module to notify the sensor control module that the ambient light detection function of the front camera has been turned off. After receiving the first notification message, the sensor control module will no longer attempt to turn on the ambient light detection function of the front camera until it receives a notification message from the camera control module that the front camera is turned off.
[0220] Optionally, after the ambient light detection function of the front camera is turned off, the sensor control module can perform subsequent operations according to whether the second ambient light brightness returned by the data callback function is received when the ambient light detection function of the front camera is turned off. In a possible implementation, when the ambient light detection function of the front camera is turned off, if the sensor control module receives the second ambient light brightness returned by the data callback function, the received second ambient light brightness is reported to the sensor service module, so that the sensor service module can adjust the brightness of the display screen according to the second ambient light brightness until the electronic device turns off the screen, or the second ambient light brightness returned by the data callback function is received again. Optionally, if the electronic device turns off the screen, the received second ambient light brightness is cleared. In another possible implementation, when the ambient light detection function of the front camera is turned off, if the sensor control module does not receive the second ambient light brightness returned by the data callback function, the preset ambient light brightness is reported to the sensor service module until the electronic device turns off the screen, or the second ambient light brightness returned by the data callback function is received.
[0221] Furthermore, after the ambient light detection function of the front camera is turned off, the camera service module calls the first function in the camera control module, and executes the first function according to the second identifier, thereby controlling the camera driver to apply for CSL resources for the front camera, power on the front camera, initialize the camera register, configure image output resources for the front camera, etc. After the above operations are performed, the camera function of the front camera is turned on, the electronic device captures images through the front camera, and displays the interface of the camera application, and then displays the images captured by the front camera on the interface of the camera application.
[0222] By adopting the method provided in the embodiment of the present application, after the ambient light detection function of the front camera is turned on, when the user needs to take a photo with the front camera, the ambient light detection function of the front camera can be turned off, and the image taken by the front camera can be displayed to meet the user's photo-taking needs.
[0223] There are two points to note here. First, Fig. 9 The embodiment shown is described by taking an example of a user opening a camera application and taking a photo with the front camera. If a user opens a camera application and takes a photo with the rear camera, the user can also follow the steps below. Figure 8 The process shown is executed, except that after the ambient light detection function of the front camera is turned off, the photo taking function of the rear camera is turned on.
[0224] Second, the above Fig. 9 The embodiment shown takes the user opening the camera application as an example. If the user opens other applications that need to call the camera, the Fig. 9 The process shown is executed and will not be explained one by one here.
[0225] After the camera application is started, because the priority of the first identifier corresponding to the ambient light detection function of the front camera is low, the ambient light detection function of the front camera is turned off and the photo taking function of the front camera is turned on. When the camera application is turned off, the ambient light detection function of the front camera can be turned on to adjust the brightness of the display screen. For this scenario, the embodiment of the present application provides a method for managing the priority of camera enablement. This method is similar to Fig. 9 The embodiment shown has a certain timing relationship and can be executed after step 903. Figure 2 The electronic device 100 of the software system shown in FIG. Fig.10 , the method flow provided in the embodiment of the present application includes:
[0226] 1001. Based on the camera application being closed, the camera service module receives a fourth instruction.
[0227] The fourth instruction is used to turn off the photo-taking function of the front camera, and the fourth instruction includes the second identifier and the second package name.
[0228] 1002. After receiving the fourth instruction, the camera service module turns off the photo-taking function of the target camera and sends a second notification message to the sensor control module.
[0229] After receiving the fourth instruction, the camera service module calls the second function in the camera control module, and executes the second function according to the second identifier, thereby controlling the camera driver to power off the front camera, and then releasing the CSL cache resources and image output resources applied for the front camera. After the above operations are performed, the photo taking function of the front camera is turned off.
[0230] Optionally, when the photo-taking function of the front camera is turned off, the camera control module may further send a second notification message to the sensor control module, the second notification message being used to notify the sensor control module that the front camera has been turned off and that the ambient light detection function of the front camera may be turned on. The second notification message may include a status field of the front camera, etc., and the status field may be CAMERA_FRONT_CLOSE.
[0231] 1003. After receiving the second notification message, the sensor control module calls the first interface based on the AIDL service, and then calls the second interface based on the HIDL service to send a first instruction to the camera service module.
[0232] 1004. After receiving the first instruction, the camera service module turns on the ambient light detection function of the target camera based on the first identifier.
[0233] After receiving the first instruction, the camera service module calls the first function in the camera control module, and executes the first function according to the first identifier, thereby controlling the camera driver to apply for CSL resources for the front camera, power on the front camera, initialize the camera register, create a reading thread for the ambient light brightness, etc. After the above operations are performed, the ambient light detection function of the front camera is turned on, and the electronic device detects the ambient light brightness through the front camera, and then adjusts the display brightness of the electronic device based on the ambient light brightness detected by the front camera.
[0234] For this scenario, see Fig.11 After the camera application is closed, CameraSerivce receives the fourth instruction. After receiving the fourth instruction, CameraSerivce calls the Close Camera function in CAMX of Camera HAL to execute the process of closing CameraID=1. When the process of CameraID=1 is executed, Camera HAL sends a second notification message to SensorHAL through the data callback function. The second notification message carries CAMERA_FRONT_CLOSE, etc. The notification message is used to notify SensorHAL that the front camera is closed. When receiving the second notification message, SensorHAL creates a read thread, calls the Active interface, and sends the first instruction to the CameraSerivce of the FWK layer through the libcamera2ndk_vendor interface to turn on the ambient light detection function of the front camera, so that the ambient light detection function can be automatically turned on after the front camera is turned off under the bright screen.
[0235] By adopting the method provided in the embodiment of the present application, the ambient light detection function of the front camera can be automatically turned on after the ambient light detection function of the front camera is turned off, thereby realizing automatic adjustment of the brightness of the display screen.
[0236] It should be noted that Fig.10 The embodiment shown is described by taking the example of a user opening a camera application, taking a photo with the front camera, and then closing the corresponding application. If the user opens a camera application, takes a photo with the rear camera, and then closes the rear camera, the user can also follow the steps below. Fig.10 The difference is that after turning off the photo function of the rear camera, the ambient light detection function of the front camera is turned on. Alternatively, after calling other applications of the front camera (such as face unlocking application) and turning them off, you can also follow Fig.10 The process shown is executed, except that the ambient light detection function of the front camera is turned off after the other functions of the front camera are turned off.
[0237] pass Figure 3 It can be seen from the embodiment shown that after the electronic device turns on the screen, the ambient light detection application and the face unlocking application (or camera application) may be started at the same time, and the ambient light detection process and the face unlocking (or photo taking) process may be executed at the same time. In this way, the ambient light detection process may go to the camera service module before the face unlocking (or photo taking) process, or it may go to the camera service module later than the face unlocking (or photo taking) process. For these two situations, combined Fig. 9 and Fig.10 As can be seen from the process shown, the execution order of the ambient light detection process and the face unlocking (or photo taking) process is different, and the subsequent processing process is also different. The following will be explained in two scenarios.
[0238] Scenario 1: The ambient light detection process is executed before the face unlock (or photo taking) process
[0239] In this scenario, the ambient light detection function of the front camera is executed before the face unlock (or photo) process. The camera service module first turns on the ambient light detection function of the front camera, then turns off the ambient light detection function of the front camera, and then turns on the face unlock (or photo) function of the front camera. Fig.12 See Fig.12 After the electronic device turns on the screen, SensorService sends a brightness monitoring instruction to SensorHAL. After receiving the brightness monitoring instruction, Sensor HAL calls the Active interface, and then calls the libcamera2ndk_vendor interface to send a first instruction to the CameraSerivce of the FWK layer. The first instruction includes CameraID=4 and the package name of the ambient light detection application. When it is determined that there is no identifier in the camera list, CameraSerivce can call the OpenCamera function in CAMX of Camera HAL, and execute the Open Camera function according to CameraID=4 to control the camera driver to apply for CLS cache resources for the ambient light detection function of the front camera corresponding to CameraID=4, power on the front camera, initialize the camera register, and create an asynchronous read thread, etc., so as to turn on the ambient light detection function of the front camera. In the process of turning on the ambient light detection function of the front camera, CameraService receives a third instruction, which includes CameraID=1 and the package name of the face unlocking (or taking pictures) application. CameraService determines that there is CameraID=4. Since the package name of the face unlocking (or taking pictures) application has a higher priority than the package name of the ambient light detection application, it can be determined that the priority of CameraID=4 is lower than the priority of CameraID=1. Therefore, it is necessary to turn off the ambient light detection function of the front camera. After CameraService waits for the ambient light detection function of the front camera to be enabled, it turns off the ambient light detection function of the front camera. Specifically, CameraSerivce can call the Close Camera function in CAMX of Camera HAL, execute the Close Camera function according to CameraID=4, control the camera driver to stop reading the ambient light brightness, power off the front camera, and release the CLS cache resources allocated for the ambient light detection function of the front camera with CameraID=4. After the ambient light detection function of the front camera is turned off, CameraService sends a notification message to SensorHAL. The notification message carries the OnDeviceDisconnected field, which is used to indicate that SensorHAL has turned off the ambient light detection function of the front camera.After receiving the notification message, SensorHAL calls the Active interface, and then calls the libcamera2ndk_vendor interface to send the first instruction to the CameraSerivce of the FWK layer. After receiving the first open instruction, CameraSerivce can call the Open Camera function in CAMX of Camera HAL, and execute the Open Camera function according to CameraID=1 to control the camera driver to apply for CLS cache resources for the face unlocking (or taking pictures) function of the front camera corresponding to CameraID=1, power on the front camera, initialize the camera registers, configure the output resources, etc., so as to turn on the face unlocking (or taking pictures) function of the front camera, and then perform the face unlocking (or taking pictures) operation.
[0240] Scenario 2: The ambient light detection process is executed later than the face unlock (or photo taking) process
[0241] In this scenario, after the electronic device turns on the screen, the face unlocking application is started. After the face unlocking application is started, the camera service receives the fifth instruction, which includes a third identifier. The third identifier corresponds to the face unlocking function of the target camera. After receiving the fifth instruction, the camera service module turns on the face unlocking function of the target camera. During the display screen unlocking process, when the first instruction is received, the camera service determines that the third identifier exists in the camera list, and determines the priority of the first identifier and the third identifier according to the first package name and the third package name. The camera service module determines that the priority of the first identifier is lower than the priority of the third identifier, and sends a third notification message to the sensor control module. The third notification message is used to notify the sensor control module that the ambient light detection function of the target camera fails to be turned on. After the display screen of the electronic device is unlocked, the camera service module turns off the face unlocking function of the target camera, and then turns on the ambient light detection function of the target camera based on the first identifier.
[0242] That is, after the electronic device turns on the screen, the ambient light detection function of the front camera is executed later than the face unlock (or photo) process. The camera service module first turns on the face unlock (or photo) function of the front camera, turns off the face unlock (or photo) function, and then turns on the ambient light detection function of the front camera. Fig.13 See Fig.13 After the electronic device turns on the screen, CameraService receives a third instruction, which includes CameraID=1 and the package name of the face unlock (or photo) application. When it is determined that there is no identifier in the camera list, CameraSerivce can call the Open Camera function in CAMX of Camera HAL, and execute the Open Camera function according to CameraID=1 to control the camera driver to apply for CLS cache resources for the face unlock (or photo) function of the front camera corresponding to CameraID=1, power on the front camera, initialize the camera register, configure the image output resources, etc., so as to turn on the face unlock (or photo) function of the front camera. In the process of turning on the ambient light detection function of the front camera, CameraService receives a first instruction, which includes CameraID=4 and the package name of the ambient light detection application. CameraService determines that CameraID=1 exists. Since the package name of the face unlock (or photo) application has a higher priority than the package name of the ambient light detection application, it can be determined that the priority of CameraID=4 is lower than that of CameraID=1. Therefore, CameraService does not turn on the ambient light detection function of the front camera, and then returns a notification message to SensorHAL that the ambient light detection function failed to be turned on. The notification message carries the CAMERA_IN_USE field. Based on the notification message, SensorHAL determines that other high-priority functions are being enabled and no longer repeatedly turns on CameraID=4 to reduce resource consumption of the electronic device. Since the ambient light detection function failed to be turned on, SensorHAL did not receive the ambient light brightness returned by the data callback function, and therefore reported the preset ambient light brightness to SensorService, so that SensorService can adjust the brightness of the display according to the preset ambient light brightness. When the face unlocking (or photo taking) function is turned off, CameraService turns on the ambient light detection function of the front camera. For this process, see Fig.10 The process shown will not be repeated here.
[0243] In an embodiment of the present application, when the electronic device is in a bright screen state, after the camera application is started, the ambient light detection function of the front camera is not enabled, and after the camera application is closed, the ambient light detection function of the front camera can be enabled. When the electronic device is in a screen-off state, the ambient light detection function of the front camera is turned off. A typical application scenario is that after the camera application is started, the camera application is turned off by turning off the display screen. Since the photo taking function of the front camera is turned off, the ambient light detection function of the front camera can be enabled, and when the display screen is turned off, the ambient light detection function of the front camera should also be turned off. In the scenario of turning off the screen to turn off the camera application, the opening process of the ambient light detection function and the closing process of the ambient light detection function may be instructed at the same time, so that the opening process of the ambient light detection function may go to the sensor control module before the closing process of the ambient light detection function, or it may go to the sensor control module later than the closing process of the ambient light detection function. The embodiment of the present application can be refined into two scenarios for explanation, one scenario is that the opening process of the ambient light detection function is executed before the closing process of the ambient light detection function, and the other scenario is that the opening process of the ambient light detection function is executed later than the closing process of the ambient light detection function. Before that, in order to better manage the ambient light detection function opening process and the ambient light detection function closing process, a state lock State machine can be added to the sensor control module. The state lock is used to record the state machine of the current sensor control module. The state machine includes no state, a first state (i.e. Active, used to turn on the ambient light detection function) and a second state (i.e. DeActive, used to turn off the ambient light detection function).
[0244] In the first scenario, the ambient light detection function opening process is executed before the ambient light detection function closing process
[0245] In this scenario, the ambient light detection function of the front camera can be turned on by executing steps 1001 to 1002, and then the ambient light detection function of the front camera can be turned off by executing steps 601-602. Specifically, after the screen of the electronic device is turned off, the camera service module turns off the photo-taking function of the target camera, and then sends a second notification message to the sensor control module, the second notification message is used to notify the sensor control module that the photo-taking function of the target camera has been turned off, after receiving the second notification message, when it is determined that the state machine of the sensor control module is in the first state, the first state can be that the sensor control module turns on the ambient light detection function of the target camera, and then turns off the ambient light detection function of the target camera based on the screen of the electronic device being turned off.
[0246] For this scenario, see Fig.14 After the camera application is started, when a touch operation on the power button is detected, the electronic device turns off the screen and the front camera is turned off. When the CameraSerivce of the FWK layer receives the fourth instruction, after receiving the fourth instruction, the CameraSerivce calls the Close Camera function in CAMX of the Camera HAL to execute the process of closing the function corresponding to CameraID=1. When the closing process of the function corresponding to CameraID=1 is executed, the Camera HAL sends a notification message to the SensorHAL through the data callback function. The notification message carries the field of the CAMERA_FRONT_CLOSE state to notify the SensorHAL that the front camera has been turned off. When the notification message is received, the Sensor HAL creates an asynchronous thread, calls the Active interface, and queries the state machine of the SensorHAL in the State machine. When the query result is no state, the state machine of the SensorHAL is recorded as Active, and then the libcamera2ndk_vendor interface is called to send the first instruction to the CameraSerivce of the FWK layer to turn on the ambient light detection function of the front camera. When Sensor HAL calls Active to turn on the CameraID=4 function, Sensor HAL also receives the stop brightness monitoring instruction sent by SensorSerivce. After receiving the stop brightness monitoring instruction, Sensor HAL waits to turn on the ambient light detection function of the front camera, and then calls the DeActive interface to query the state machine of SensorHAL in the State machine. When the query result is Active, the libcamera2ndk_vendor interface is called to send the second instruction to the CameraSerivce of the FWK layer to turn off the ambient light detection function of the front camera.
[0247] In the second scenario, the ambient light detection function opening process is executed later than the ambient light detection function closing process
[0248] In this scenario, after the ambient light detection function of the front camera is turned off, there is no need to turn on the ambient light detection function of the front camera again, that is, after the camera service module controls the camera driver to power off the front camera in step 1002 to turn off the photo-taking function of the front camera, the process ends. Specifically, after the electronic device turns off the screen, the camera service module turns off the photo-taking function of the target camera, and then sends a second notification message to the sensor control module, the second notification message is used to notify the sensor control module that the photo-taking function of the target camera has been turned off. After receiving the second notification message, when it is determined that the state machine of the sensor control module is in the first state, the sensor control module turns on the ambient light detection function of the target camera, and then turns off the ambient light detection function of the target camera based on the screen turning off of the electronic device.
[0249] For this scenario, see Fig.14 , after the camera application is started, when a touch operation on the power button is detected, the electronic device turns off the screen and the front camera is turned off. When the Sensor HAL receives the stop brightness monitoring instruction sent by the SensorSerivce, based on the stop brightness monitoring instruction, the Sensor HAL calls the DeActive interface, records the state machine of the SensorHAL in the State machine as DeActive, and then calls the libcamera2ndk_vendor interface to send a second instruction to the CameraSerivce of the FWK layer to turn off the ambient light detection function of the front camera. During the process of the Sensor HAL performing the DeActive operation on the function corresponding to CameraID=4, the SensorHAL receives a notification message sent by the Camera HAL through the data callback function, which carries the field of the CAMERA_FRONT_CLOSE state. Based on the notification message, the Sensor HAL creates an asynchronous thread, calls the Active interface, and queries the state machine of the SensorHAL in the State machine. When the query result is DeActive, the Sensor HAL will stop the Active operation and no longer turn on the ambient light detection function of the front camera.
[0250] In the embodiment of the present application, for the client (sensor control module) and server (camera control module) based on AIDL service, the server exception may include two scenarios, one is the server process crash when the screen-on ambient light detection function is enabled, and the other is the server process crash when the screen-off ambient light detection function is not enabled; the client exception is mainly the client crash when the screen-on ambient light detection function is enabled. For these three scenarios, monitoring can be performed based on the first death monitoring object and the second death monitoring object pre-registered in step 401, which will be introduced below.
[0251] After the ambient light detection function of the front camera is turned on by executing the above steps 401 to 405, in the process of adjusting the brightness of the display screen based on steps 406 to 408, when the camera control module does not respond, the first ambient light brightness output by the front camera cannot be sent to the sensor control module. In view of the abnormal situation of the server side during the process of adjusting the brightness of the display screen of the electronic device, the embodiment of the present application provides a management method for the ambient light detection function, which has Figure 2 The electronic device 100 with the software structure shown in FIG. 1 executes the embodiment of the present application as an example. Fig.15 The method may be performed after step 405. The method flow provided by the embodiment of the present application includes:
[0252] 1501. During the process of adjusting the brightness of a display screen of an electronic device, when the first death monitoring object monitors that a camera control module does not respond, the camera control module sends a first death notification message to a sensor control module.
[0253] Optionally, this step may correspond to Fig.16 Step ② in the embodiment specifically includes: during the process of adjusting the brightness of the display screen of the electronic device, the first death monitoring object monitors the Camera HAL in real time, and when it is monitored that the Camera HAL cannot send the first ambient light brightness output by the front camera to the sensor control module and to the SensorHAL, the Camera HAL can call the data callback function and send the first death notification message to the SensorHAL. The data callback function can be the data callback function registered in step 401.
[0254] 1502. The sensor control module determines whether the AIDL service is started.
[0255] 1503. When it is determined that the AIDL service is started, the sensor control module executes a call to the first interface, and then calls the second interface to send a first instruction to the camera service module to enable the ambient light detection function of the front camera.
[0256] Since the camera service module cannot return the ambient light brightness output by the front camera at this time, it is necessary to re-register the data callback function to ensure that the data path between the camera control module and the sensor control module can transmit data. Enabling the ambient light detection function of the front camera includes: the camera service module calls the first function in the camera control module, executes the first function according to the first identifier, controls the camera driver to apply for the CSL resource cache for ambient light detection for the front camera, powers on the front camera, initializes the camera register, and creates an asynchronous read thread.
[0257] Optionally, this step may correspond to Fig.16 Steps ②-⑥ in the process specifically include: when receiving the first death notification message, SensorHAL determines whether the AIDL service is started. When the AIDL service is started, the Active interface is called to register the data callback function, and then the libcamera2ndk_vendor interface is called to send the first instruction to CameraSerivce. The first instruction includes CameraID=4 and the package name of the ambient light detection application. After receiving the first instruction, CameraSerivce calls the OpenCamera function in Camera HAL, executes the OpenCamera function according to CameraID=4, and then controls the camera driver to apply for CLS resource cache for CameraID=4, and powers on the front camera, initializes the camera register, and creates an asynchronous reading thread. When the first ambient light brightness output by the front camera is read, Camera HAL fills the second ambient light brightness into the data callback function, sends the second ambient light brightness to SensorHAL through the data callback function, and is reported to SensorSerivce by SensorHAL.
[0258] In another embodiment of the present application, when the AIDL service is not started, it is necessary to wait for a preset period of time and then determine again whether the AIDL service is started.
[0259] After the screen of the electronic device is turned off, after executing the above steps 601 to 602, if the ambient light detection function of the front camera cannot be turned off normally, the server does not respond after the screen of the electronic device is turned off. The embodiment of the present application provides a management method for the ambient light detection function, which has Figure 2 The electronic device 100 with the software structure shown in FIG. 1 executes the embodiment of the present application as an example. Fig.17 The method may be performed after step 602. The method flow provided by the embodiment of the present application includes:
[0260] 1701. After the screen of the electronic device is turned off, when the first death monitoring object monitors that the camera control module does not respond, the camera control module sends a second death notification message to the sensor control module.
[0261] Optionally, this step corresponds to Fig.18 Step ① in the embodiment specifically includes: after the screen of the electronic device is turned off, the first death monitoring object monitors that the Camera HAL crashes and cannot normally turn off the ambient light detection function of the front camera. The data callback function can be called to send a second death notification message to the SensorHAL.
[0262] 1702. After receiving the second death notification message, the sensor control module determines whether the screen of the electronic device is turned off.
[0263] 1703. When it is determined that the screen of the electronic device is turned off, the sensor control module calls the first interface to send an initialization instruction to the camera control module.
[0264] 1704. After receiving the initialization instruction, the camera control module initializes the front camera and the data callback function.
[0265] Optionally, this step corresponds to Fig.18 Steps ② and ③ in the method specifically include: after receiving the second death notification message, the Sensor HAL may call the Active interface to initialize the camera registers and data callback functions in the Camera HAL.
[0266] In this scenario, since the display screen is off, there is no need to adjust the ambient light brightness, and the sensor control module no longer enables the front camera.
[0267] After the ambient light detection function of the front camera is enabled by executing the above steps 401 to 405, in the process of adjusting the brightness of the display screen based on steps 406 to 408, when the sensor control module cannot turn on the ambient light detection function of the front camera, the server does not respond during the process of adjusting the brightness of the display screen of the electronic device. The embodiment of the present application provides a management method for the ambient light detection function, which has Figure 2 The electronic device with the software structure shown in the figure performs the embodiment of the present application as an example, see Fig.19 , the method flow provided in the embodiment of the present application includes:
[0268] 1901. After the screen of the electronic device is turned on, when the second death monitoring object monitors that the sensor control module does not respond, the sensor control module sends a third death notification message to the camera control module.
[0269] Optionally, this step corresponds to Fig. 20 Step ① in the method specifically includes: after the screen of the electronic device is turned on, the second death monitoring object monitors the SensorHAL in real time, and when a crash event of the SensorHAL is monitored, the data callback function is called to send a third death notification message to the Camera HAL.
[0270] 1902. After receiving the third death notification message, the camera control module closes the reading thread and destroys the data callback function.
[0271] Optionally, this step corresponds to Fig. 20 Step ② in the method specifically includes: after receiving the third death notification message, the Camera HAL controls the camera driver to close the asynchronous reading thread, stop reading the ambient light brightness, and destroy the data callback function.
[0272] 1903. The sensor control module calls the third interface based on the AIDL service, and then calls the second interface to send a second instruction to the camera service module.
[0273] Optionally, this step corresponds to Fig. 20 Steps ③ and ④ specifically include: SensorHAL calls the DeActive interface, and then calls the libcamera2ndk_vendor interface to send a second instruction to CameraSerivce, where the second instruction includes CameraID=4 and the package name of the ambient light detection application.
[0274] 1904. After receiving the second instruction, the camera service module calls the second function in the camera control module, and executes the second function according to the first identifier to control the camera driver to close the reading thread and power off the front camera.
[0275] Optionally, this step corresponds to Fig. 20 Step ⑤ in the method specifically includes: after receiving the second instruction, CameraSerivce calls Camera HAL to control the camera driver to release the CSL resources applied for the function of CameraID=4, and power off the front camera.
[0276] 1905. After the sensor control module is restarted, the first interface is called to register a data callback function in the camera control module, and the second interface is called to send a first instruction to the camera service module to enable the ambient light detection function of the front camera.
[0277] Optionally, this step corresponds to Fig. 20 Step ⑥ specifically includes: SensorHAL calls the Active interface, and then calls the libcamera2ndk_vendor interface to send a first instruction to CameraSerivce, where the first instruction includes CameraID=4 and the package name of the ambient light detection application to enable the ambient light detection function of the front camera.
[0278] Generally, the camera software process is more complex than the physical ambient light software process, and consumes more power. Meeting the performance requirements cannot meet the power consumption requirements, and meeting the power consumption requirements cannot meet the performance requirements. To this end, the embodiment of the present application will also optimize the display brightness adjustment method in the above embodiment, so as to ensure that the first frame data can be reported in a timely and effective manner under the premise of reducing the function. Fig.21 ,This method mainly involves the following three aspects in terms of reducing power consumption and optimizing performance:
[0279] First, streamline the process of OpenCamera function in CAMX
[0280] With respect to the first aspect, the embodiment of the present application customizes the process of the original Open Camera function, adds a branch for jumping out of the image output distribution flow, and when calling CameraSerivce to call the Open Camera function in the Camera HAL, when the original Open Camera function supports turning on the ambient light detection function of the front camera, the encapsulation function OpenCamLightSensor is called to skip the image output distribution flow, thereby saving resource consumption when the front camera is used as an ambient light detection device and improving the performance of the electronic device.
[0281] For the simplified execution process of OpenCamera function, Figure 4 The adjustment process of the display brightness during the startup process shown is used as an example for explanation. Since the embodiment of the present application needs to turn on the ambient light detection function of the front camera, if the front camera does not support turning on the ambient light detection function of the front camera, it is impossible to enable the ambient light detection function of the front camera by calling the first function. Therefore, after calling the first function, the first sub-function in the first function will also be called to determine whether the front camera supports the ambient light detection function. If the front camera supports the ambient light detection function, the second sub-function in the first function will be called to control the camera driver to power on the front camera, initialize the camera register and create an asynchronous read thread. By executing this streamlined OpenCamera function, the image output and streaming process can be skipped, the opening time of the ambient light detection function can be shortened, and the performance of the electronic device can be improved.
[0282] Among them, the ambient light detection judgment function may be IsSupportCamLightSensor(), and the ambient light detection sensor function may be OpenCamLightSensor().
[0283] The above logic code for determining whether the front camera supports ambient light detection is:
[0284]
[0285] Of course, if the front camera does not support ambient light detection, you can interact with the camera driver in the kernel layer to control the camera driver to apply for CSL resource cache for the ambient light detection function of the front camera, power on the front camera, initialize the camera registers, and allocate streams for the front camera, so that the front camera can output images.
[0286] Second, set a higher priority for the reading thread
[0287] Considering that multiple threads may be executed simultaneously in the camera driver, in order to ensure the timely reporting of ambient light brightness, a higher priority can be set for the asynchronous thread, so that the execution of the reading thread can be prioritized when resources are limited.
[0288] Third, adaptive switching frequency
[0289] Electronic devices have strict requirements for the first frame data of ambient light brightness (the one frame data mentioned here is not the image frame), and generally require reporting within 300ms. There are no strict requirements for the second frame data and subsequent frames, and the reporting time of the first frame data depends on the frame rate of the front camera. When the frequency of the front camera is set to a lower frequency to reduce power consumption, the data may not be reported within 300 mm because the ambient light brightness requires integration time. In order to ensure that the first frame data can be reported in time, an embodiment of the present application provides an adaptive frequency switching method, which records the target number and writes the target number into the camera register. The target number can be the number of times the camera control module of the electronic device reads the ambient light brightness from the front camera after the screen is turned on this time, or it can be the number of times the camera control module of the electronic device reads the ambient light brightness from the front camera after the screen is turned on for the last time. After the electronic device turns off the screen, the target number recorded in the camera register will be cleared. After the front camera is powered on, the camera control module obtains the target number of times from the camera register. When the target number of times is 0, the camera control module writes the first frequency into the camera register and controls the front camera to detect the ambient light brightness according to the first frequency. When the target number of times is greater than 0, the camera control module writes the second frequency into the camera register and controls the front camera to detect the ambient light brightness according to the second frequency. The first frequency is greater than the second frequency. The first preset frame rate is higher than the second preset frame rate. The first preset frame rate can be 30fps, and the second preset frame rate can be 5fps or 3fps.
[0290] The optimization method may be performed after step 405 and before step 406. By adaptively adjusting the frequency of the front camera collecting the ambient light brightness, not only the first frame data is ensured to be reported in time, but also the power consumption of the electronic device is reduced.
[0291] An embodiment of the present application provides a computer-readable storage medium, in which at least one computer program is stored. When the at least one computer program is executed by a processor, the above-mentioned camera enabling priority management method can be implemented.
[0292] An embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it can implement the above-mentioned camera enabling priority management method.
[0293] It should also be noted that the term "includes", "comprising" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the existence of other identical elements in the process, method, commodity or device including the element.
[0294] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.< / float>
Claims
1. A method for managing camera enabling priority, characterized in that: The method is applied to an electronic device, the software structure of the electronic device includes a framework layer and a hardware abstraction layer, the framework layer includes a camera service module, the hardware abstraction layer includes a sensor control module, and the method includes: After the screen of the electronic device is turned on, the camera service module receives a first instruction sent by the sensor control module, where the first instruction includes a first identifier, and the first identifier corresponds to an ambient light detection function of a target camera; After receiving the first instruction, the camera service module queries a camera list, where the camera list is used to store identifiers of currently enabled cameras; When the camera list is empty, the camera service module turns on the ambient light detection function of the target camera based on the first identifier, and in the process of adjusting the brightness of the display screen based on the ambient light brightness detected by the target camera, the target camera does not capture images; When the camera application is started, the photographing function of the target camera is enabled but the ambient light detection function is disabled, after the screen of the electronic device is turned off, the camera service module turns off the photographing function of the target camera, and then sends a second notification message to the sensor control module, where the second notification message is used to notify the sensor control module that the photographing function of the target camera has been turned off; After receiving the second notification message, when it is determined that the state machine of the sensor control module is in the first state, the sensor control module turns on the ambient light detection function of the target camera, and then turns off the ambient light detection function of the target camera based on the electronic device turning off the screen, and the first state is used to turn on the ambient light detection function; when it is determined that the state machine of the sensor control module is in the second state, the sensor control module turns off the ambient light detection function of the target camera, and the second state is used to turn off the ambient light detection function.
2. The method according to claim 1, characterized in that After the camera service module turns on the ambient light detection function of the target camera based on the first identifier, the camera service module further includes: After the screen of the electronic device is turned off, the camera service module receives a second instruction, where the second instruction includes the first identifier; After receiving the second instruction, the camera service module turns off the ambient light detection function of the target camera based on the first identifier.
3. The method according to claim 1, characterized in that The first instruction also includes a first package name, the first package name is the package name of the ambient light detection application, and after the camera service module turns on the ambient light detection function of the target camera based on the first identifier, it also includes: After the camera application is started, the camera service module receives a third instruction, the third instruction includes a second identifier and a second package name, the second identifier corresponds to the camera function of the target camera, and the second package name is the package name of the camera application; After receiving the third instruction, the camera service module determines that the first identifier exists in the camera list, and determines the priority of the first identifier and the second identifier according to the first package name and the second package name; The camera service module determines that the priority of the first identifier is lower than the priority of the second identifier, turns off the ambient light detection function of the target camera, and then turns on the photo-taking function of the target camera based on the second identifier.
4. The method according to claim 3, characterized in that After the camera service module determines that the priority of the first identifier is lower than the priority of the second identifier and turns off the ambient light detection function of the target camera, the method further includes: The camera service module sends a first notification message to the sensor control module, where the first notification message is used to notify the sensor control module that an ambient light detection function of the target camera has been turned off.
5. The method according to claim 4, characterized in that After the camera service module turns on the photo-taking function of the target camera based on the second identifier, the camera service module further includes: After the camera application is closed, the camera service module receives a fourth instruction; After receiving the fourth instruction, the camera service module turns off the photographing function of the target camera, and sends a second notification message to the sensor control module, where the second notification message is used to notify the sensor control module that the photographing function of the target camera has been turned off; After receiving the second notification message, the sensor control module calls the first interface based on the AIDL service, and then calls the second interface based on the HIDL service to send the first instruction to the camera service module; After receiving the first instruction, the camera service module turns on the ambient light detection function of the target camera based on the first identifier.
6. The method according to claim 4, characterized in that After the electronic device turns on the screen and before the camera service module receives the first instruction, the method further includes: After the screen of the electronic device is turned on, the face unlocking application is started; After the face unlock application is started, the camera service receives a fifth instruction, the fifth instruction includes a third identifier, and the third identifier corresponds to the face unlock function of the target camera; After receiving the fifth instruction, the camera service module turns on the face unlocking function of the target camera.
7. The method according to claim 6, characterized in that The fifth instruction also includes a third package name, and the method further includes: During the unlocking process of the display screen, when the first instruction is received, the camera service determines that the third identifier exists in the camera list, and determines the priority of the first identifier and the third identifier according to the first package name and the third package name; The camera service module determines that the priority of the first identifier is lower than the priority of the third identifier, and sends a third notification message to the sensor control module, where the third notification message is used to notify the sensor control module that the ambient light detection function of the target camera fails to be turned on; After the display screen of the electronic device is unlocked, the camera service module turns off the face unlocking function of the target camera, and then turns on the ambient light detection function of the target camera based on the first identifier.
8. An electronic device, characterized in that: It comprises a processor and a memory; the memory stores at least one program code; the at least one program code is used to be called and executed by the processor to implement the camera enabling priority management method as described in any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one computer program, and when the at least one computer program is executed by the processor, it can implement the method for managing camera enabling priority according to any one of claims 1 to 7.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the method for managing camera enabling priority according to any one of claims 1 to 7 can be implemented.
Citation Information
Patent Citations
Camera control method, electronic equipment and computer readable storage medium
CN113778641A