Method for adjusting brightness of display screen, electronic device, storage medium, and program product

The target camera detects the ambient light brightness and realizes automatic adjustment of the brightness of the electronic device display screen, solving the problem of additional configuration of ambient light detection devices in the prior art to increase costs, and achieving lower cost and higher performance equipment performance.

WO2025129684A1PCT designated stage expired Publication Date: 2025-06-26HONOR DEVICE CO LTD

Patent Information

Application Number
PCT/CN2023/141226
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-12-22
Publication Date
2025-06-26

AI Technical Summary

Technical Problem

Existing electronic devices need to be equipped with additional ambient light detection devices when adjusting the brightness of the display, which increases the cost of the equipment.

Method used

The target camera detects the ambient light brightness, and automatically adjusts the display brightness without the need for additional ambient light detection devices.

Benefits of technology

It reduces the cost of electronic devices, reduces the power consumption of target cameras, and improves the performance of the device.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023141226_26062025_PF_FP_ABST
    Figure CN2023141226_26062025_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of electronic devices, and discloses a method for adjusting the brightness of a display screen, an electronic device, a storage medium, and a program product. The method comprises: when a screen of an electronic device is turned on, a target camera is powered on; the electronic device detects the ambient light brightness by means of the target camera; on the basis of the ambient light brightness detected by the target camera, the electronic device adjusts the brightness of the display screen, wherein when the electronic device adjusts the brightness of the display screen, the target camera does not collect an image, and a camera application is not started; in response to an operation of a user, the electronic device starts the camera application; when the camera application is started, the electronic device collects an image by means of the target camera and displays an interface of the camera application, wherein the interface of the camera application comprises the image collected by the target camera. In the present application, an ambient light detection device does not need to be configured, and the ambient light brightness is detected on the basis of the target camera, thereby reducing the cost of the electronic device. In addition, no image is collected, thereby reducing power consumption of the target camera, improving performance of the electronic device.
Need to check novelty before this filing date? Find Prior Art

Description

Display screen brightness adjustment method, electronic device, storage medium and program product Technical Field

[0001] The present application relates to the technical field of electronic equipment, and in particular to a method for adjusting the brightness of a display screen, an electronic device, a storage medium, and a program product. Background Art

[0002] Currently, the displays of many electronic devices, including smartphones, tablets, desktop computers, and wearable devices, all feature automatic brightness adjustment. This feature automatically adjusts the display brightness based on ambient light levels to adapt to different light intensity environments, thereby improving the user experience and reducing the power consumption of electronic devices.

[0003] In the related art, an ambient light detection device is usually configured on an electronic device. When the electronic device turns on the screen, the ambient light brightness is detected by the ambient light detection device, and the brightness of the electronic device's display screen is adjusted based on the detected ambient light brightness.

[0004] However, this method requires additional configuration of an ambient light detection device, which increases the cost of the electronic device.

[0005] Summary of the Invention

[0006] To address the problems of related technologies, embodiments of the present application provide a method for adjusting display brightness, an electronic device, a storage medium, and a program product. This method eliminates the need for an additional ambient light detection device and instead detects ambient light brightness through a target camera, thereby reducing the cost of the electronic device. The technical solution is as follows:

[0007] In a first aspect, a method for adjusting the brightness of a display screen is provided, the method comprising:

[0008] After the electronic device's screen lights up, power on the target camera;

[0009] The electronic device detects the brightness of the ambient light through the target camera;

[0010] Based on the ambient light brightness detected by the target camera, the electronic device adjusts the brightness of the display screen, and during the process of the electronic device adjusting the brightness of the display screen, the target camera does not capture images and the camera application is not started;

[0011] In response to a user operation, the electronic device starts the camera application;

[0012] After starting the camera application, the electronic device captures images through the target camera and displays the interface of the camera application, where the interface of the camera application includes the images captured by the target camera.

[0013] In a first possible implementation of the first aspect, after the screen of the electronic device turns on, powering on the target camera includes:

[0014] Based on the screen of the electronic device being turned on, the target camera is powered on to initialize the target camera.

[0015] In a second possible implementation of the first aspect, the electronic device collecting an image through the target camera includes:

[0016] Based on the camera application being started, the electronic device powers off the target camera and then powers on the target camera;

[0017] The electronic device obtains the image captured by the target camera.

[0018] In a third possible implementation manner of the first aspect, the method further includes:

[0019] After starting the camera application, the electronic device does not adjust the brightness of the display screen.

[0020] In a third possible implementation of the first aspect, after the electronic device turns on the screen and before the target camera is powered on, the method further includes:

[0021] After the screen of the electronic device turns on, the face unlocking application is started;

[0022] After the face unlock application is started, the electronic device captures an image through the target camera, and after the display screen is unlocked, the face unlock application is closed;

[0023] After the face application is closed, the electronic device powers off the target camera.

[0024] In a fourth possible implementation manner of the first aspect, the method further includes:

[0025] In response to the user's operation, the electronic device closes the camera application;

[0026] After closing the camera application, the electronic device detects the ambient light brightness through the target camera;

[0027] The electronic device adjusts the brightness of the display screen based on the ambient light brightness detected by the target camera. During the process of the electronic device adjusting the brightness of the display screen, the target camera does not capture images.

[0028] In a fifth possible implementation of the first aspect, the electronic device detecting the ambient light brightness through the target camera includes:

[0029] Based on the camera application being closed, the electronic device powers off the target camera and then powers on the target camera;

[0030] The electronic device obtains the ambient light brightness detected by the target camera.

[0031] In a sixth possible implementation of the first aspect, the software system of the electronic device includes a framework layer, a hardware abstraction layer, and a kernel layer, the framework layer includes a camera service module and a sensor service module, the hardware abstraction layer includes a camera control module and a sensor control module, and the kernel layer includes a camera driver. After the electronic device turns on the screen, powering on the target camera includes:

[0032] Based on the electronic device turning on the screen, the sensor service module sends a brightness monitoring instruction to the sensor control module;

[0033] After receiving the brightness monitoring instruction, the sensor control module calls a first interface based on an AIDL service, and then calls a second interface based on a HIDL (HAL interface definition language) service to send a first instruction to the camera service module, where the first instruction includes a first identifier, and the first identifier corresponds to the ambient light detection function of the target camera;

[0034] 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 target camera, initialize the camera register and create a reading thread for the ambient light brightness.

[0035] In a seventh possible implementation manner of the first aspect, before the camera service module calls the first function in the camera control module, the method further includes:

[0036] After receiving the first instruction, the camera service module queries a camera list, where the camera list is used to store identifiers of enabled cameras;

[0037] When it is determined that the camera list is empty, the camera service module executes and calls the first function in the camera control module.

[0038] Here, enabling in the embodiment of the application may mean turning on and working normally.

[0039] In an eighth possible implementation manner of the first aspect, after the camera service module calls the first function in the camera control module, the method further includes:

[0040] The camera service module stores the first identifier in the camera list.

[0041] In a ninth possible implementation of the first aspect, the camera service module calls a first function in the camera control module and executes the first function according to the first identifier, including:

[0042] The camera service module calls the first sub-function in the first function to determine whether the target camera supports the ambient light detection function corresponding to the first identifier;

[0043] When it is determined that the target camera supports the ambient light detection function corresponding to the first identifier, the second sub-function in the first function is called. By executing the second sub-function, the camera driver is controlled to power on the target camera, initialize the camera register and create a reading thread for the ambient light brightness, and no image output resources are configured for the target camera.

[0044] In a tenth possible implementation manner of the first aspect, before the electronic device detects the brightness of the ambient light through the target camera, the electronic device further includes:

[0045] After the target camera is powered on, the camera control module obtains a target number from the camera register, where the target number is used to represent the number of times the ambient light brightness detected by the target camera is read after the screen of the electronic device is turned on;

[0046] When the target number is 0, the camera control module writes the first frequency into the camera register and controls the target camera to detect the ambient light brightness according to the first frequency;

[0047] When the target number is greater than 0, the camera control module writes a second frequency into the camera register and controls the target camera to detect the ambient light brightness according to the second frequency, and the first frequency is greater than the second frequency.

[0048] In an eleventh possible implementation of the first aspect, the electronic device adjusting the brightness of the display screen based on the brightness of the ambient light detected by the target camera includes:

[0049] The camera control module obtains a first ambient light brightness output by the target camera, and sends a second ambient light brightness to the sensor control module through a data callback function, where the second ambient light brightness is generated based on the first ambient light brightness;

[0050] The sensor control module sends the second ambient light brightness to the sensor service module;

[0051] The sensor service module adjusts the brightness of the display screen of the electronic device based on the brightness of the second ambient light.

[0052] Among them, the first ambient light brightness and the second ambient light brightness are not a brightness value, but a type of brightness value. The first ambient light brightness is the ambient light brightness output by the front camera at different times, and the second ambient light brightness is the ambient light brightness sent by the camera control module to the sensor control module at different times.

[0053] In a twelfth possible implementation manner of the first aspect, before the camera control module obtains the first ambient light brightness output by the target camera and sends the second ambient light brightness to the sensor control module through a data callback function, the method further includes:

[0054] Upon powering on the electronic device and receiving the brightness monitoring instruction, the sensor control module calls the first interface and registers the data callback function in the camera control module.

[0055] In a thirteenth possible implementation manner of the first aspect, before the sensor control module calls the first interface and registers the data callback function in the camera control module, the method further includes:

[0056] Based on the electronic device being powered on, the camera control module initializes the AIDL service.

[0057] In a fourteenth possible implementation manner of the first aspect, the method further includes:

[0058] After the screen of the electronic device is turned off, the sensor control module calls a third interface based on the AIDL service, and then calls the second interface to send a second instruction to the camera service module, where the second instruction includes the first identifier;

[0059] 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 target camera.

[0060] In a fifteenth possible implementation manner of the first aspect, the method further includes:

[0061] During the process of adjusting the brightness of the display screen by the electronic device, when the camera control module is detected to be unresponsive by the first death monitoring object, the camera control module sends a first death notification message to the sensor control module;

[0062] After receiving the first death notification message, the sensor control module calls the first interface and then calls the second interface to send the first instruction to the camera service module to enable the ambient light detection function of the target camera.

[0063] The non-response of the camera control module may be that after the ambient light detection function is turned on, the camera control module does not respond to the operation of sending the ambient light brightness detected by the front camera to the sensor control module.

[0064] In a sixteenth possible implementation of the first aspect, the sensor control module calls the first interface and then calls the second interface, and before sending the first instruction to the camera service module, further comprising:

[0065] The sensor control module determines whether the AIDL service is started;

[0066] When it is determined that the AIDL service is started, the sensor control module executes the operation of calling the first interface, then calling the second interface, and sending a third instruction to the camera service module.

[0067] In a seventeenth possible implementation manner of the first aspect, the method further includes:

[0068] 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;

[0069] After receiving the second death notification message, the sensor control module calls the first interface to send an initialization instruction to the camera control module;

[0070] After receiving the initialization instruction, the camera control module initializes the target camera and a data callback function, and the data callback function is used to send the ambient light brightness detected by the target camera to the sensor control module.

[0071] The non-response of the camera control module may be that the camera control module does not respond to an operation of turning off the ambient light detection function after the screen of the electronic device is turned off.

[0072] In an eighteenth possible implementation manner of the first aspect, before the sensor control module calls the first interface to send the initialization instruction to the camera control module, the method further includes:

[0073] The sensor control module determines whether the screen of the electronic device is off;

[0074] When it is determined that the screen of the electronic device is off, the sensor control module executes the operation of calling the first interface and sending an initialization instruction to the camera control module.

[0075] In a nineteenth possible implementation manner of the first aspect, the method further includes:

[0076] After the screen of the electronic device turns 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;

[0077] After receiving the third death notification message, the camera control module closes the reading thread and destroys the data callback function, where the data callback function is used to send the ambient light brightness detected by the target camera to the sensor control module;

[0078] The sensor control module calls a third interface based on the AIDL service, then calls the second interface, and sends a second instruction to the camera service module, where the second instruction includes the first identifier;

[0079] After receiving the second instruction, the camera service module calls a 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 target camera;

[0080] After the sensor control module restarts, it calls the first interface, registers the data callback function in the camera control module, and calls the second interface to send the first instruction to the camera service module to enable the ambient light detection function of the target camera.

[0081] The non-response of the sensor control module may be that the camera control module does not respond to the operation of turning on the ambient light detection function of the front camera after the screen of the electronic device is turned on.

[0082] In a twentieth possible implementation of the first aspect, the software system of the electronic device includes a framework layer, a hardware abstraction layer, and a kernel layer, the framework layer includes a camera service module and a sensor service module, the hardware abstraction layer includes a camera control module and a sensor control module, and the kernel layer includes a camera driver. Based on the camera application being started, the electronic device powers off the target camera and then powers on the target camera, including:

[0083] Based on the camera application being started, the camera service module receives a third instruction, the third instruction including a second identifier and a second package name, the second identifier corresponding to the camera function of the target camera, and the second package name being the package name of the camera application;

[0084] The camera service module determines that a first identifier exists, and determines a priority between the first identifier and the second identifier based on a first package name and a second package name, wherein the first identifier corresponds to an ambient light detection function of the target camera, and the first package name is a package name of an ambient light detection application;

[0085] The camera service module determines that the priority of the first identifier is lower than the priority of the second identifier, controls the camera driver to power off the target camera to turn off the ambient light detection function of the target camera, and then controls the camera driver to power on the target camera to turn on the photo taking function of the target camera.

[0086] 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 method for adjusting the brightness of the display screen described in the first aspect.

[0087] 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 adjusting the brightness of the display screen described in the first aspect can be implemented.

[0088] In a fourth aspect, a computer program product is provided, which includes a computer program. When the computer program is executed by a processor, it can implement the method for adjusting the brightness of the display screen described in the first aspect.

[0089] The beneficial effects of the technical solution provided by the embodiments of the present application are:

[0090] In this application, the target camera has an image acquisition function and an ambient light detection function, which makes it possible for the target camera to be used as an ambient light detection device. After the electronic device turns on the screen, the target camera is powered on, and the ambient light brightness is detected by the target camera, and then the brightness of the display screen is adjusted based on the detected ambient light brightness, so there is no need to configure an additional ambient light detection device, that is, the automatic adjustment of the display screen brightness is achieved, reducing the cost of the electronic device. Moreover, in the process of adjusting the brightness of the display screen, the target camera only detects the ambient light brightness, and does not capture images, let alone output images, which greatly reduces the power consumption of the target camera, saves electricity, and improves the performance of the electronic device.

[0091] Furthermore, during the display brightness adjustment process, the camera application is not started. When the camera application is started based on the user's operation, the electronic device captures the image through the target camera and displays the image on the camera application interface, thereby meeting the user's photo-taking needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0092] FIG1 is a schematic structural diagram of an electronic device provided in an embodiment of the present application;

[0093] FIG2 is a software structure block diagram of an electronic device provided in an embodiment of the present application;

[0094] FIG3 is a flow chart of a method for adjusting display screen brightness provided in an embodiment of the present application;

[0095] FIG4 is a flow chart of another method for adjusting display screen brightness provided in an embodiment of the present application;

[0096] FIG5 is a flow chart of another method for adjusting display screen brightness provided in an embodiment of the present application;

[0097] FIG6 is a flowchart of a method for turning off the screen and disabling the ambient light detection function of the front camera provided by an embodiment of the present application;

[0098] FIG7 is a flowchart of another embodiment of the present application to turn off the screen to disable the ambient light detection function of the front camera;

[0099] FIG8 is a flowchart of a method for managing camera enabling priority according to an embodiment of the present application;

[0100] FIG9 is a flowchart of another method for managing camera enabling priority provided in an embodiment of the present application;

[0101] FIG10 is a flowchart of another method for managing camera enabling priority provided in an embodiment of the present application;

[0102] FIG11 is a flowchart of another method for managing camera enabling priority provided in an embodiment of the present application;

[0103] FIG12 is a flowchart of another method for managing camera enabling priority provided in an embodiment of the present application;

[0104] FIG13 is a flowchart of another method for managing camera enabling priority provided in an embodiment of the present application;

[0105] FIG14 is a flowchart of a method for managing an ambient light detection function provided by an embodiment of the present application;

[0106] FIG15 is a flowchart of another method for managing an ambient light detection function provided by an embodiment of the present application;

[0107] FIG16 is a flowchart of another method for managing an ambient light detection function provided by an embodiment of the present application;

[0108] FIG17 is a flowchart of another method for managing an ambient light detection function provided by an embodiment of the present application;

[0109] FIG18 is a flowchart of another method for managing an ambient light detection function provided by an embodiment of the present application;

[0110] FIG19 is a flowchart of another method for managing an ambient light detection function provided by an embodiment of the present application;

[0111] Figure 20 is a performance optimization logic block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0112] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0113] 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 relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0114] In modern life, electronic devices such as smartphones, tablets, and laptops have become indispensable. To meet user needs in varying lighting scenarios, these devices offer automatic brightness adjustment. When the screen is on, the device uses a built-in ambient light sensor to detect the ambient light level. Based on this, the device adjusts the display brightness, ensuring a pleasant viewing experience in varying lighting conditions.

[0115] 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 all 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), ULP (Ultra Low Power) mode, etc., which makes it possible to use cameras as ambient light detection devices.

[0116] In view of this, an embodiment of the present application proposes a method of replacing an ambient light detection device with a target camera to detect ambient light brightness, and then adjusting the brightness of a display screen 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.

[0117] Using the method of the embodiment of the present application to adjust the brightness of the display screen of an electronic device can not only reduce the cost of the electronic device, but also reduce power consumption and improve the performance of the electronic device.

[0118] Figure 1 shows a schematic diagram of the structure of an electronic device 100. The electronic device 100 can be a mobile phone, a personal computer (PC), a tablet computer, an AR (Augmented Reality) device, a VR (Virtual Reality) device, an in-vehicle 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 194, etc.

[0119] 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). Different processing units may be independent devices or integrated into one or more processors.

[0120] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. When processor 110 needs to use the same instruction or data again, it can directly access the memory, avoiding repeated accesses and reducing processor 110 latency, thereby improving system efficiency.

[0121] In some embodiments, the processor 110 may include one or more interfaces. The interfaces 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.

[0122] The internal memory 121 can be used to store computer executable program code, which includes instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can 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 can 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.

[0123] The electronic device 100 can implement display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing that 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 that 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 be 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), a mini-LED, a micro-LED, a micro-o-LED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than one.

[0124] The electronic device 100 can implement a shooting function through an ISP, camera 193, a video codec, a GPU, a display 194, and an application processor. The ISP is used to process data fed back by the camera 193. For example, when the shutter is opened to take a photo, light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, which is then passed to the ISP for processing and transformed into a visible image. The ISP can also perform algorithmic optimization on image noise, brightness, and skin tone. The ISP can also optimize parameters such as exposure and color temperature of the captured scene. In some embodiments, the ISP can be installed in the camera 193. The camera 193 is used to capture still images or videos. An object is projected onto the photosensitive element through the lens, which 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, which is then passed to the ISP for conversion into a digital image signal. The ISP outputs the digital image signal to the 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 one or N cameras 193 , where N is a positive integer greater than one.

[0125] 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. 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, and the like.

[0126] 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 via the external memory interface 120 to implement data storage. For example, files such as music and videos can be stored on the external memory card.

[0127] USB port 130 is an interface that complies with USB standards and may be a Mini USB port, a Micro USB port, a USB Type-C port, or the like. USB port 130 can be used to connect a charger to charge electronic device 100, transfer data between electronic device 100 and peripheral devices, connect headphones to play audio, or connect to other electronic devices, such as augmented reality devices.

[0128] The charging management module 140 is configured to receive charging input from a charger. The charger can be either a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 can receive charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 can receive wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also provide power to the electronic device via the power management module 141.

[0129] 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 provides power to the processor 110, the internal memory 121, the display 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 count, and battery health status (leakage, impedance). 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.

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

[0131] 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 antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.

[0132] 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 (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and perform filtering, amplification, and other processing on 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.

[0133] The wireless communication module 160 can provide wireless communication solutions applied to the electronic device 100, 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 (NFC), infrared technology (IR), etc. 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, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0134] 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 a network and other devices through wireless communication technologies. The wireless communication technologies may include Global System for Mobile communications (GSM), General Packet Radio Service (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).

[0135] The electronic device 100 can implement audio functions such as music playback and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0136] It will be understood that the structure illustrated in the embodiments 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 can be implemented in hardware, software, or a combination of software and hardware. In addition, the interface connection relationship between the modules illustrated in the embodiments of the present application is merely 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 from those in the above embodiments, or a combination of multiple interface connection methods.

[0137] A software system is installed in the electronic device 100, and the software system can run on the processor 110. The software system can be an Android system, a Windows system, an IOS system, a Hongmeng system, etc., and the architecture adopted by the software system can be a layered architecture, an event-driven architecture, a micro-kernel architecture, a microservice 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. Referring to Figure 2, the Android system can be divided into four layers, from top to bottom, respectively, the application layer, the framework layer (Framework, FWK), the hardware abstraction layer (HAL) and the kernel layer.

[0138] The application layer can include a range of applications, such as camera, calendar, map, WLAN, music, short message, gallery, call, ambient light detection, face unlock, etc., for direct interaction with the user. These applications can be built-in system applications or non-system applications. These applications can have icons and application interfaces, or they can have application interfaces without icons, or they can have neither icons nor application interfaces.

[0139] The framework layer includes some predefined functions that 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). 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 in the application layer that need to call sensors and the Sensor HAL. Optionally, the sensor service module can be 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 in the application layer that need to call the camera (for example, camera applications, face unlocking applications, ambient light detection applications, etc.) and Camera HAL. Optionally, the camera service module can be 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 problem of enabling priority of different functions of multiple cameras, the embodiment of the present application modifies the CameraSerivce in the camera service module, and adds a judgment logic for 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.

[0140] The hardware abstraction layer (HAL) is located between the framework layer and the kernel layer, and its purpose is to abstract the hardware. The HAL 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. Depending on the functions implemented, the HAL can be further refined into a camera-related HAL (i.e., the Camera HAL described in subsequent embodiments), a sensor-related HAL (i.e., the Sensor HAL described in subsequent embodiments), etc. The camera-related HAL can be defined as a camera control module, and the sensor-related HAL can be defined as a sensor control module. Optionally, the camera control module can be an independent process, and the sensor control module can also be an independent process. To implement 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 subsequent embodiments) is added to the sensor control module. The ambient light service control submodule provides multiple interfaces, including an Active interface and a DeActive interface. Among them, the Active interface is used to enable 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 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 brightness of the display screen 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) 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 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 with each other and even communicate across devices.CAMX is a code implementation set of a general functional interface. The embodiment of the present application modifies the first function (i.e., the Open Camera function) in the original code implementation set in CAMX, 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.

[0141] The kernel layer is the layer between hardware and software. The kernel layer may include display drivers, camera drivers, audio drivers, sensor drivers, etc. These drivers can drive the display screen, front / rear cameras, audio players, sensors, etc.

[0142] The present invention provides a method for adjusting the brightness of a display screen. Taking the electronic device 100 having the software system shown in FIG2 as an example, referring to FIG3 , the method flow provided by the present invention includes:

[0143] 301. After the screen of the electronic device turns on, power on the front camera.

[0144] 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 with a preset gesture (such as double-clicking, etc.), lifting the electronic device, etc. 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.

[0145] 302. The electronic device detects the ambient light brightness through the front camera.

[0146] 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 automatically adjusting the brightness of the display screen.

[0147] 303. Based on the ambient light brightness detected by the front camera, the electronic device adjusts the brightness of the display screen.

[0148] In one 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 the electronic device may obtain the default brightness of the display screen of the electronic device and adjust the default brightness based on the first ambient light brightness to obtain the adjusted display brightness.

[0149] In another possible implementation, the ambient light brightness detected by the front camera can be a second ambient light brightness generated based on the first ambient light brightness output by the front camera, and the electronic device can adjust the display brightness based on the second ambient light brightness. For example, the electronic device can use the second ambient light brightness as the adjusted display brightness; or the electronic device can obtain the default brightness of the display screen of the electronic device and adjust the default brightness based on the second ambient light brightness to obtain the adjusted display brightness.

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

[0151] 304. In response to the user's operation, the electronic device starts a camera application.

[0152] After the electronic device turns on the screen, the electronic device can detect the user's touch operation on the camera application. When the user's touch operation on the camera application icon is detected, the electronic device starts the camera application; the electronic device can also detect the call operation of the camera application by a third-party application. When the third-party application is detected calling the camera application, the electronic device can start the camera application.

[0153] 305. After starting the camera application, the electronic device captures images through the front camera and displays the interface of the camera application.

[0154] Before the camera application is started, the front camera is powered on, and the electronic device adjusts the brightness of the display screen based on the ambient light brightness detected by the front camera. After the camera application is started, based on the camera application being started, the photo-taking 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-taking function is not enabled, and each camera usually enables one function. In order to realize the photo-taking 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 and turns on the photo-taking function of the front camera. After the photo-taking 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-taking needs.

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

[0156] In another embodiment of the present application, after the camera application is started, in response to a user operation, the electronic device closes the camera application. After closing the camera application, 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. During 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, based on the camera application being closed, the electronic device can power off the front camera, turn off the photo-taking function of the front camera, and then power on the front camera, turn on the ambient light detection function of the front camera, and then obtain the ambient light brightness detected by the front camera.

[0157] 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 entered by the user, and can also unlock the display screen by starting a 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.

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

[0159] Of course, if the electronic device first receives an instruction to turn on the front camera from the ambient light detection app and then receives an instruction to turn on the front camera from the face unlock app, the electronic device will first turn on the ambient light detection function of the front camera to adjust the display brightness, 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 for the different enabling orders of the ambient light detection function and the face unlock function of the front camera can be found in the flowcharts of the subsequent Figures 11 and 12, which will not be described in detail here.

[0160] For an electronic device having the software system shown in FIG2 , 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. In the embodiment of the present application, the sensor control module of the HAL layer 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.

[0161] 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. Therefore, 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.

[0162] Regarding the process of establishing a data path between the sensor control module and the camera control module, see FIG4 . An embodiment of the present application provides a method for adjusting display brightness. The method can be executed by an electronic device 100 having the software system shown in FIG2 . The method flow provided by the embodiment of the present application includes:

[0163] 401. Based on the electronic device being powered on, the camera control module initializes the AIDL service.

[0164] 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 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 step ① in Figure 5. Referring to Figure 5, when the electronic device is powered on, the AIDL service in the CHI-CDK of the Camera HAL is initialized, which can be to pull up the AIDL service.

[0165] Optionally, the AIDL service initialization process can be implemented using the following code:

[0166] CamLightAidlImpl::GetInstance()->Init(…).

[0167] 402. The sensor service module sends a brightness monitoring instruction to the sensor control module.

[0168] In the embodiments of the present application, the sensor service module (i.e., SensorService) can be an independent process, which can be defined as the sensor service process. The submodules included in the sensor service module (such as SensorManager, SensorService, etc.) can be threads in the sensor service process. The sensor control module (i.e., Sensor HAL) can also be an independent process, which can be defined as the sensor control process. The submodules included in the sensor control module (such as CameraLightManager, etc.) can be threads in the sensor control process.

[0169] After the electronic device is powered on, the ambient light detection application in the application layer sends a screen-on message to the sensor service module. This screen-on message may include the package name of the ambient light detection application. This screen-on message is used to instruct the sensor service module to adjust the brightness of the electronic device's display screen. Upon receiving this screen-on message, the sensor service module sends a brightness monitoring instruction to the sensor control module. This 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.

[0170] Optionally, the sensor service module may send the brightness monitoring instruction to the sensor control module by: the sensor service process sends the brightness monitoring instruction to the sensor control process. Referring to Figure 5 , the sensor service module may send the brightness monitoring instruction to the sensor control module by: the SensorManager in the FWK layer generates the 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 via the SensorService.

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

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

[0173] 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 a server in subsequent embodiments); the sensor control module (Sensor HAL) is used to receive ambient light brightness and can be regarded as an AIDL client (referred to as a client in subsequent embodiments).

[0174] The first interface may be an Active interface. The Active interface is used to enable the ambient light detection function of the front camera. After the sensor control module calls the Active interface to enable the ambient light detection function of the front camera, the sensor control module may call the Active interface to register a data callback function in the camera control module. The camera control module may use the data callback function to 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.

[0175] In this 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 is an AIDL interface, its declaration usually contains two parameters: one can be the client's 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, this callback object corresponds to ReportLusStatus in Figure 5.

[0176] The Active interface can be declared using the following code:

[0177] Furthermore, based on the declaration of the Active interface, the sensor control module and the camera control module can each register a callback interface on this end. Once the callback interface registration is complete in the sensor control module and the camera control module, the data callback function registration in the camera control module is complete. Optionally, the sensor control module can register the callback interface in CamLightManager, and the camera control module can register the callback interface in CamxLightCustom.

[0178] The following code can be used when registering the callback interface in the sensor control module: CamLightManager::RegisterLuxCb(){ mCamLightService->RegisterLuxCallback(callingPid,mLuxCallback);}

[0179] The following code can be used when registering the callback interface in the camera control module:

[0180] void CamxLightCustom::RegisterLightLuxStatusCb(Callback callback)

[0181] Optionally, the sensor control module calls the first interface based on the AIDL service, and the steps of registering the data callback function in the camera control module can correspond to steps ② and ③ in Figure 5, specifically including: after the Sensor HAL receives the brightness monitoring instruction, it calls the Active interface in CamLightManager, and based on the declaration content of the Active interface, registers the callback interface in CamLightManager, and registers the callback interface in CamxLightCustom. When the callback interfaces in CamLightManager and CamxLightCustom are registered, the registration of the data callback function is completed.

[0182] 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 after 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 or is turned off to be turned off is turned off.

[0183] Optionally, due to the limitations 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 can 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 can be calibrated. The data calibration function can be LuxValueConvert().

[0184] Optionally, the electronic device may experience a sudden process 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 crashes 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 end respectively. In one possible implementation, the camera control module may register a first death monitoring object on this end when registering the callback interface. By registering the first death monitoring object, the crash of the camera control module in the screen-on scene and the screen-off scene can be monitored. The sensor control module may register a second death monitoring object on this end when registering the callback interface. By registering the second death monitoring object, the crash of the sensor control module in the screen-on scene and the screen-off scene can be monitored. Optionally, it can correspond to step ① in Figure 15, specifically including: 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.

[0185] Optionally, for electronic devices, the front cameras on some electronic devices may support the ambient light detection function, while the front cameras on some electronic devices may not support the ambient light detection function. To avoid enabling the front camera that does not support the ambient light detection function and reduce resource consumption of the electronic device, the sensor control module may obtain the value of the preset flag before calling the first interface to enable 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. Then, based on the value of the preset flag, it is determined 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 enable 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. The preset flag can be is_ambient_light, which is used to indicate whether the front camera supports the ambient light detection function. The value of the preset flag can be true or false. When the value of the preset flag is true, it can be determined that the front camera supports the ambient light detection function; when the value of the preset flag is false, it can be determined that the front camera does not support the ambient light detection function.

[0186] 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 the need for re-registration; when the electronic device is turned off, the data callback function registered in this step will be destroyed. When the electronic device is turned on again, the above steps 401 to 403 need to be executed to register the data callback function.

[0187] 404. The sensor control module calls the second interface based on the HIDL service and sends a first instruction to the camera service module.

[0188] Typically, cameras include two types: front cameras and rear cameras, and there are at least one front camera and rear camera respectively. Moreover, the front camera and rear camera each have multiple functions, including at least one of a photo taking function, a face unlocking function, and an ambient light detection function. 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, based on the photo taking function of the front camera, a logical camera A can be abstracted, and based on the ambient light detection function of the front camera, a logical camera B can be abstracted. Logical camera A and logical camera B can correspond to the same front camera or to different front cameras. For the photo taking function of logical camera A, i.e., the front camera, the identifier set is Camera ID=1, and for the ambient light detection function of logical camera B, i.e., the front camera, the identifier set is Camera ID=4.

[0189] In an embodiment of the present application, the sensor control module can call the first interface to generate a first instruction, and then the second interface sends the first instruction to the camera service module. Among them, the second interface belongs to the interface of the HIDL service, which can be libcamera2ndk_vendor in Figure 5, 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 may include a first identifier, which corresponds to the ambient light detection function of the front camera, and can be Camera ID=4. The first instruction may also include a first package name, which is the package name of the ambient light detection application.

[0190] Optionally, the sensor service module calls the second interface to send the first instruction to the camera service module, which can correspond to step ④ in Figure 5, specifically including: 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.

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

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

[0193] The first function is used to enable any function of any camera in the electronic device. The first function may be an Open Camera function. After receiving the first instruction, the camera service module may call the first function in the camera control module and execute the first function based on the first identifier. Based on the first identifier, it can be determined that the ambient light detection function of the front camera needs to be enabled. In this case, the front camera will be used instead of the ambient light detection device. When the front camera is used instead of the ambient light detection device, the front camera needs to detect the ambient light brightness without capturing an image. To reduce the power consumption of the front camera, the camera service module, based on the first identifier, executes the processes in the first function necessary to enable the ambient light detection function of the front camera, such as applying for a CSL resource cache, powering on the front camera, initializing camera registers, and creating a reading thread for ambient light brightness. It skips processes unrelated to enabling the ambient light detection function of the front camera, such as configuring image output resources. Executing the first function generates corresponding control instructions, which are issued to the camera driver, thereby instructing the camera driver to apply for a CSL resource cache for the front camera, power on the front camera, initialize camera registers, and create a reading thread. The created read thread is used to read and calculate the ambient light brightness detected by the front camera. Optionally, the read thread can be an asynchronous read thread. Optionally, the read thread can periodically read the ambient light brightness detected by the front camera. Based on the initialization of the camera register, the period for the front camera to detect 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.

[0194] Optionally, this step may correspond to step ⑤ in FIG5 , specifically including: when receiving the first instruction, calling the Open Camera function in CAMX of the Camera HAL through CameraService, and executing the Open Camera function, and 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.

[0195] When the method of the embodiment of the present application is used, when the front camera is used instead of the ambient light detection device, no image output resources will 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.

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

[0197] The second ambient light brightness is generated based on the first ambient light brightness. The second ambient light brightness may be equal to the first ambient light brightness, or 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 may be generated based on the first ambient light brightness and the third ambient light brightness, where the third ambient light brightness is the calibrated ambient light brightness obtained by calibrating the first ambient light brightness using the calibration coefficient provided by the data calibration function. The second ambient light brightness may also be generated based on the first ambient light brightness, the third ambient light brightness, and the status parameter of the front camera, where the status parameter includes available and unavailable, where 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 embodiments of the present application are not a single brightness value, but rather 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.

[0198] In one 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. 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.

[0199] Optionally, the camera control module may send the second ambient light brightness to the sensor control module via 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 via the data callback function.

[0200] Based on the 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:

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

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

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

[0204] For the third method, the form of the filled data callback function can be: pCamxLightCustom->mStatusCb(static_cast <float>(luxValue),luxValueFinal,status);

[0205] Wherein, 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 ambient light brightness after calibration, and status is the status parameter of the front camera.

[0206] Optionally, three specific implementation methods are listed here. You can select only one of these methods to return the second ambient light brightness, or you can select multiple methods to return the second ambient light brightness. Each time the second ambient light brightness is returned, you can use the same method or different methods. For example, you can use the first implementation method to return the second ambient light brightness the first time, the second implementation method to return the second ambient light brightness the second time, the third implementation method to return the second ambient light brightness the third time, and so on. You can also use multiple methods to return the second ambient light brightness each time, and then combine the second ambient light brightness returned by the multiple methods.

[0207] 407. The sensor control module sends the second ambient light brightness to the sensor service module.

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

[0209] In one possible implementation, when the sensor service module sends a brightness monitoring instruction to the sensor control module, it registers a callback function in the sensor control module. Through this callback function, the sensor control module can send the second ambient light brightness to the sensor service module. Alternatively, the sensor control module can fill the second ambient light brightness into the callback function, and through this callback function, send the second ambient light brightness to the sensor control module.

[0210] In another possible implementation, the sensor service module may periodically read the second ambient light brightness of the sensor control module.

[0211] For the sensor control module's processing logic for the second ambient light brightness, see the following code: ::ndk::ScopedAStatus ReportLuxStatus(const LuxStatus&out_data){ / / Client data processing logic}

[0212] Optionally, steps 406 to 407 may correspond to steps ⑤ and ⑥ in FIG5 , specifically including: CamxLightCustom of Camera HAL obtains the first ambient light brightness output by the front camera, and returns the second ambient light brightness to the ReportLuxStatus object in CamLightManager of Sensor HAL through a pre-registered data callback function. The ReportLuxStatus object reports the second ambient light brightness to SensorManager through SensorSerivce.

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

[0214] In one possible implementation, adjusting the brightness of the display screen may include 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 historical ambient light brightness and the second ambient light brightness, and then set the brightness of the display screen to the determined brightness.

[0215] 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 that affect the user experience.

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

[0217] The above description is made using the example of the electronic device turning on the screen for the first time when the screen is turned on. When the electronic device turns on the screen for a non-first time, the electronic device may not execute the initialization process of the AIDL service in step 401 and the registration process of the data callback function in step 403, but execute other steps. For details, please refer to the process shown in Figure 4 or Figure 5, which will not be repeated here.

[0218] Referring to Figure 6, an embodiment of the present application provides a method for turning off the ambient light detection function of the front camera when the screen is off. When the screen of the electronic device is off, the ambient light detection function of the front camera can be turned off to reduce the power consumption of the electronic device. Taking the electronic device 100 having the software system shown in Figure 2 as an example of executing the embodiment of the present application, this method can be independent of the display brightness adjustment process shown in Figure 4, without a timing relationship, and can also be executed at any time after step 405 in Figure 4. Referring to Figure 6, the method flow provided by the embodiment of the present application includes:

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

[0220] Optionally, based on the screen being turned off of the electronic device, the sensor service module may receive a screen-off message from the electronic device. After receiving the screen-off message, the sensor service module may send a stop brightness monitoring instruction to the sensor control module. After receiving the stop brightness monitoring instruction, the sensor control module may call a third interface to generate a second instruction, and then call the second interface to send the second instruction to the camera service module. The third interface may be a DeActive interface, which is used to turn off the ambient light detection function of the front camera. The second instruction may be a Close Camera instruction, including a first identifier, a first package name, etc.

[0221] Optionally, this step may correspond to ①②③④ in Figure 7, specifically including: 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.

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

[0223] After receiving the second instruction, the camera service module calls the second function in the camera control module and executes the second function based on the first identifier. By executing the second function, a corresponding shutdown instruction can be generated and sent to the camera driver. Based on the shutdown instruction, the camera driver shuts down the reading thread, stops reading the ambient light brightness, powers down the front camera, and releases the CSL cache resources requested for the front camera. Furthermore, after the camera driver shuts down the reading thread, the camera control process stops sending the second ambient light brightness to the sensor control module via the data callback function.

[0224] The logic code for turning off the ambient light detection function of the front camera can be: CloseCamLightSensor(const struct camera3_device*pCamera3Device,bool&isCamLightId) (turn off the Camera light id encapsulation function)

[0225] Optionally, this step may correspond to step ⑤ in FIG7 , specifically including: based on the Close Camera instruction, CameraSerivce calls the Close Camera function in CAMX of the 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.

[0226] Usually, electronic devices are equipped with a front camera and a rear camera. The front camera supports image output mode and ambient light detection mode. The image output mode corresponds to the photo taking function, face unlocking function, etc. of the front camera. In the image output mode, the front camera needs to capture 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 in order to improve the user's usage needs, and compared with the image output mode, the user demand is lower. In actual application, the front camera and the rear camera cannot be enabled at the same time, and the image output mode and ambient light detection mode of the front camera cannot be enabled at the same time. In order to solve the problem of camera enabling priority, the embodiment of the present application sets corresponding identifiers 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.

[0227] Specifically, the process of configuring a corresponding identifier for a camera in an electronic device may include: during the electronic device's startup process, the camera control module interacts with the camera driver to obtain the type and function of the camera in the electronic device, then abstracts multiple logical cameras based on the camera type and function, and sets a corresponding identifier for each logical camera. For example, the identifier set for the front camera's photo function is CameraID=1; the identifier set for the front camera's ambient light detection function is CameraID=4.

[0228] The above is the process of setting the flag for the ambient light detection function of the front camera. Please refer to the following code:

[0229] Taking CameraID=1 and CameraID=4 as an example, the conflict judgment logic configured in the camera control module is:

[0230] To ensure normal user use, 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 photo service can be provided to the user. To facilitate subsequent use, 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.

[0231] 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, which includes a target identifier and a target package name. After receiving the target instruction, the camera service module queries the camera list, which is used to store the identifiers corresponding to the currently enabled cameras. 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.

[0232] The above judgment logic can be found in the following code: TagName: "com.xxx.device.capabilities.camLightSupported"; / / Static capability name. int CamLightManager::CamLightCheck(ACameraManager*manager, ACameraIdList *cameraIdList) ret = ACameraManager_openCamera(mCameraManager, (const char*)buff, &mDeviceCb, &mDevice);

[0233] Among them, ACameraManager_openCamera is the interface function of Open Camera, and buff is PackageName.

[0234] Based on the above judgment logic, before executing step 405 in FIG. 4 , the camera service module may query the camera list, and execute step 405 when the camera list is empty.

[0235] Referring to FIG8 , an embodiment of the present application provides a method for managing camera enable priority. Taking the electronic device 100 having the software system shown in FIG2 as an example, this method has a sequential relationship with the method for adjusting display brightness shown in FIG4 , and can be executed after step 405 in FIG4 . Referring to FIG8 , the method flow provided in the embodiment of the present application includes:

[0236] 801. Based on the camera application being started, the camera service module receives a third instruction.

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

[0238] 802. The camera service module determines that the first identifier exists, and determines the priority of the first identifier and the second identifier according to the first package name and the second package name.

[0239] As shown in the embodiment of Figure 4, upon receiving the third instruction, the electronic device adjusts the display brightness based on the ambient light detected by the front camera, thereby enabling the ambient light detection function of the front camera. Upon 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 based on the first and second package names.

[0240] 803. The camera service module determines that the priority of the first identifier is lower than the priority of the second identifier, controls the camera driver to power off the front camera to turn off the ambient light detection function of the front camera, and then controls the camera driver to power on the front camera to turn on the photo taking function of the front camera.

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

[0242] Optionally, after the ambient light detection function of the front camera is disabled, the camera service module further sends a notification message to the sensor control module to inform the sensor control module that the ambient light detection function of the front camera has been disabled. Upon receiving the notification message, the sensor control module will not attempt to enable the ambient light detection function of the front camera again until it receives a notification message from the camera control module indicating that the front camera has been disabled.

[0243] Optionally, after the ambient light detection function of the front camera is turned off, the sensor control module can perform subsequent operations based on 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 one 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 is turned off or the second ambient light brightness returned by the data callback function is received again. Optionally, if the electronic device is turned off, 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 is turned off or the second ambient light brightness returned by the data callback function is received.

[0244] Furthermore, after the ambient light detection function of the front camera is disabled, the camera service module calls a first function in the camera control module and executes the first function based on the second identifier, thereby controlling the camera driver to apply for CSL resources for the front camera, power on the front camera, initialize camera registers, configure image output resources for the front camera, and so on. After the above operations are executed, the photo taking function of the front camera is enabled, the electronic device captures images through the front camera, and displays the interface of the camera application, thereby displaying the images captured by the front camera on the interface of the camera application.

[0245] By using 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.

[0246] Two points need to be explained here. First, the embodiment shown in Figure 8 is explained by taking the user opening the camera application and taking a photo with the front camera as an example. If the user opens the camera application and takes a photo with the rear camera, it can also be executed according to the process shown in Figure 8. The difference is that after turning off the ambient light detection function of the front camera, the photo taking function of the rear camera is turned on.

[0247] Secondly, the embodiment shown in FIG8 takes the user opening the camera application as an example. If the user opens other applications that need to call the camera, the process shown in FIG8 can also be used to execute, which will not be explained here one by one.

[0248] 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 closed, the ambient light detection function of the front camera can be turned on to adjust the brightness of the display screen. For this scenario, an embodiment of the present application provides a method for managing camera enable priority, which has a certain timing relationship with the embodiment shown in Figure 8 and can be executed after step 803. Taking the execution of the electronic device 100 having the software system shown in Figure 2 as an example, see Figure 9, the method flow provided by the embodiment of the present application includes:

[0249] 901. Based on the camera application being closed, the camera service module receives a fourth instruction.

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

[0251] 902. After receiving the fourth instruction, the camera service module controls the camera driver to power off the front camera to turn off the photo-taking function of the front camera, and then controls the camera driver to power on the front camera to turn on the ambient light detection function of the front camera.

[0252] After receiving the fourth instruction, the camera service module calls the second function in the camera control module and executes the second function based on the second flag, thereby controlling the camera driver to power off the front camera and release the CSL cache resources and image output resources requested for the front camera. After executing the above operations, the front camera's photo function is disabled.

[0253] Optionally, when the front camera's photo function is turned off, the camera control module may also send a notification message to the sensor control module, notifying the sensor control module that the front camera has been turned off and that the ambient light detection function of the front camera can be turned on. The notification message may include a status field for the front camera, such as CAMERA_FRONT_CLOSE.

[0254] Furthermore, after the front camera's photo function is disabled, the camera service module calls a first function in the camera control module and executes the first function based on the first identifier, thereby controlling the camera driver to apply for CSL resources for the front camera, power on the front camera, initialize camera registers, create a thread for reading ambient light brightness, and so on. After executing the above operations, the ambient light detection function of the front camera is enabled, and the electronic device detects the ambient light brightness through the front camera. Based on the ambient light brightness detected by the front camera, the brightness of the electronic device's display screen is then adjusted.

[0255] For this scenario, please refer to Figure 10. 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 notification message to SensorHAL through the data callback function. The notification message carries CAMERA_FRONT_CLOSE, etc. The notification message is used to notify SensorHAL that the front camera has been turned off. Upon receiving the 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.

[0256] 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 achieving automatic adjustment of the brightness of the display screen.

[0257] It should be noted that the embodiment shown in Figure 9 is explained by taking the example of a user opening the camera application, taking a photo with the front camera, and then closing the corresponding application. If the user opens the camera application, takes a photo with the rear camera, and then closes the rear camera, the process shown in Figure 9 can also be followed. 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 (such as the face unlock application) on the front camera and closing them, the process shown in Figure 9 can also be followed. The difference is that after turning off other functions of the front camera, the ambient light detection function of the front camera is turned on.

[0258] From the embodiment shown in FIG3 , it can be seen that after the electronic device turns on the screen, the ambient light detection application and the face unlock application (or camera application) may be started at the same time, and the ambient light detection process and the face unlock (or photo) process can be executed at the same time. In this way, the ambient light detection process may go to the camera service module before the face unlock (or photo) process, or it may go to the camera service module later than the face unlock (or photo) process. For these two situations, combined with the processes shown in FIG8 and FIG9 , it can be seen that the execution order of the ambient light detection process and the face unlock (or photo) process is different, and the subsequent processing flow is also different. The following will be explained in two scenarios respectively.

[0259] Scenario 1: The ambient light detection process is executed before the face unlock (or photo) process

[0260] In this scenario, the front camera's ambient light detection function executes before the face unlock (or photo) process. The camera service module first turns on the front camera's ambient light detection function, then turns off the front camera's ambient light detection function, and then turns on the front camera's face unlock (or photo) function. The specific execution of this process can be illustrated in conjunction with Figure 11. Referring to Figure 11, 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 Open Camera 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 registers, and create an asynchronous read thread, etc., thereby turning 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 the 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 the 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. The OnDeviceDisconnected field 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.

[0261] Scenario 2: The ambient light detection process is executed before the face unlock (or photo) process

[0262] In this scenario, the ambient light detection function of the front camera is executed later than the face unlocking (or taking pictures) process. The camera service module first turns on the face unlocking (or taking pictures) function of the front camera, and after turning off the face unlocking (or taking pictures) function, turns on the ambient light detection function of the front camera. When this process is specifically executed, it can be explained in conjunction with Figure 12. Referring to Figure 12, after the electronic device turns on the screen, CameraService receives a third instruction, which includes CameraID=1 and the package name of the face unlocking (or taking pictures) 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 unlocking (or taking pictures) function of the front camera corresponding to CameraID=1, power on the front camera, initialize the camera registers, configure the image output resources, etc., thereby turning on the face unlocking (or taking pictures) 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 unlocking (or photo taking) 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, 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 this notification message, SensorHAL determines that other high-priority functions are enabled and no longer turns on CameraID=4 repeatedly 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 unlock (or photo) function is turned off, CameraService turns on the ambient light detection function of the front camera. For this process, please refer to the process shown in Figure 10 and will not be repeated here.

[0263] In an embodiment of the present application, when the electronic device is in the screen-on 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 the 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 where the screen is turned off and the camera application is closed, 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. In this way, 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 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 further divided 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 this, in order to better manage the process of turning on and off the ambient light detection function, 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, Active (used to turn on the ambient light detection function) and DeActive (used to turn off the ambient light detection function).

[0264] In the first scenario, the ambient light detection function opening process is executed before the ambient light detection function closing process

[0265] In this scenario, you can first turn on the ambient light detection function of the front camera by executing steps 901 to 902, and then turn off the ambient light detection function of the front camera by executing steps 601-602. For this scenario, please refer to Figure 13. 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, CameraSerivce calls the Close Camera function in CAMX of the Camera HAL to execute the process of turning off the function corresponding to CameraID=1. When the shutdown process of the function corresponding to CameraID=1 is executed, Camera HAL sends a notification message to SensorHAL through the data callback function. The notification message carries the CAMERA_FRONT_CLOSE status field to notify SensorHAL that the front camera is closed. When receiving the notification message, Sensor HAL creates an asynchronous thread, calls the Active interface, and queries the state machine of SensorHAL in the State machine. When the query result is no state, the state machine of 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 the Sensor HAL calls Active to turn on the CameraID=4 function, the Sensor HAL also receives the stop brightness monitoring instruction sent by the SensorSerivce. After receiving the stop brightness monitoring instruction, the 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 the SensorHAL in the State machine. When the query result is Active, the libcamera2ndk_vendor interface is called to send a second instruction to the CameraSerivce of the FWK layer to turn off the ambient light detection function of the front camera.

[0266] In the second scenario, the ambient light detection function opening process is executed later than the ambient light detection function closing process.

[0267] 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 executing step 902 in which the camera service module controls the camera driver to power off the front camera to turn off the photo-taking function of the front camera, the process ends. For this scenario, please refer to Figure 13. 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. When the Sensor HAL performs the DeActive operation on the function corresponding to CameraID=4, the Sensor HAL receives a notification message sent by the Camera HAL through the data callback function. The notification message carries the CAMERA_FRONT_CLOSE state field. Based on the notification message, the Sensor HAL creates an asynchronous thread, calls the Active interface, and queries the state machine of the Sensor HAL in the State machine. When the query result is DeActive, the Sensor HAL stops the Active operation and no longer turns on the ambient light detection function of the front camera.

[0268] In the embodiment of the present application, for the AIDL-based client (sensor control module) and server (camera control module), server-side exceptions can 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 disabled. Client-side exceptions mainly occur when the screen-on ambient light detection function is enabled. For these three scenarios, monitoring can be performed based on the first and second death monitoring objects pre-registered in step 401, which will be introduced below.

[0269] After the ambient light detection function of the front camera is turned on by executing steps 401 to 405 above, during the process of adjusting the brightness of the display screen based on steps 406 to 408, if the camera control module does not respond and the first ambient light brightness output by the front camera cannot be sent to the sensor control module, an embodiment of the present application provides a method for managing the ambient light detection function to address abnormalities on the server side during the process of adjusting the brightness of the display screen of the electronic device. Taking the electronic device 100 having the software structure shown in FIG. 2 as an example, referring to FIG. 14 , the method can be executed after step 405. The method flow provided by the embodiment of the present application includes:

[0270] 1401. During the process of adjusting the brightness of a display screen of an electronic device, when the camera control module is detected to be unresponsive through a first death monitoring object, the camera control module sends a first death notification message to the sensor control module.

[0271] Optionally, this step may correspond to step ② in FIG. 15 , specifically including: during the process of adjusting the display brightness of the electronic device, the first death monitoring object monitors the Camera HAL in real time. When it is detected that the Camera HAL is unable to send the first ambient light brightness output by the front camera to the sensor control module and to the SensorHAL, the Camera HAL may call a data callback function to send a first death notification message to the SensorHAL. The data callback function may be the data callback function registered in step 401.

[0272] 1402. The sensor control module determines whether the AIDL service is started.

[0273] 1403. When it is determined that the AIDL service is started, the sensor control module executes a call to the first interface, then calls the second interface, and sends a first instruction to the camera service module to enable the ambient light detection function of the front camera.

[0274] 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 a first function in the camera control module, executes the first function based on a first identifier, controls the camera driver to apply for a CSL resource cache for ambient light detection for the front camera, powers on the front camera, initializes the camera registers, and creates an asynchronous read thread.

[0275] Optionally, this step may correspond to steps ②-⑥ in FIG15 , specifically including: upon receiving the first death notification message, the 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 a first instruction to the CameraSerivce. The first instruction includes CameraID=4 and the package name of the ambient light detection application. After receiving the first instruction, the CameraSerivce calls the OpenCamera function in the Camera HAL, executes the OpenCamera function according to CameraID=4, and then controls the camera driver to apply for the CLS resource cache for CameraID=4, 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, the Camera HAL fills the second ambient light brightness into the data callback function, sends the second ambient light brightness to the SensorHAL through the data callback function, and the SensorHAL reports it to the SensorSerivce.

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

[0277] After the electronic device turns off the screen, after executing steps 601 to 602 above, if the ambient light detection function of the front camera cannot be turned off normally, the embodiment of the present application provides a method for managing the ambient light detection function for the situation where the server does not respond after the electronic device turns off the screen. Taking the electronic device 100 having the software structure shown in Figure 2 as an example to execute the embodiment of the present application, see Figure 16. The method can be executed after step 602. The method flow provided by the embodiment of the present application includes:

[0278] 1601. 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.

[0279] Optionally, this step corresponds to step ① in Figure 16, specifically including: 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.

[0280] 1602. After receiving the second death notification message, the sensor control module determines whether the screen of the electronic device is off.

[0281] 1603. When it is determined that the screen of the electronic device is off, the sensor control module calls the first interface and sends an initialization instruction to the camera control module.

[0282] 1604. After receiving the initialization instruction, the camera control module initializes the front camera and the data callback function.

[0283] Optionally, this step corresponds to steps ② and ③ in FIG17 , specifically including: 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.

[0284] In this scenario, since the display screen is off, there is no need to adjust the ambient light brightness. At this time, the sensor control module no longer enables the front camera.

[0285] After the ambient light detection function of the front camera is enabled by executing steps 401 to 405 above, during the process of adjusting the brightness of the display screen based on steps 406 to 408, if the sensor control module cannot enable the ambient light detection function of the front camera, and 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 method for managing the ambient light detection function. Taking the electronic device having the software structure shown in FIG. 2 as an example, referring to FIG. 18 , the method flow provided by the embodiment of the present application includes:

[0286] 1801. After the screen of the electronic device is turned on, when the second death monitoring object monitors that the sensor control module is not responding, the sensor control module sends a third death notification message to the camera control module.

[0287] Optionally, this step corresponds to step ① in Figure 19, specifically including: after the electronic device turns on the screen, 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.

[0288] 1802. After receiving the third death notification message, the camera control module closes the reading thread and destroys the data callback function.

[0289] Optionally, this step corresponds to step ② in Figure 19, specifically including: 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.

[0290] 1803. 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.

[0291] Optionally, this step corresponds to steps ③ and ④ in Figure 19, specifically including: 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.

[0292] 1804. 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.

[0293] Optionally, this step corresponds to step ⑤ in Figure 19, specifically including: after receiving the second instruction, CameraSerivce calls Camera HAL, controls the camera driver to release the CSL resources applied for the function of CameraID=4, and powers off the front camera.

[0294] 1805. After the sensor control module restarts, it calls the first interface to register the data callback function in the camera control module, and 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.

[0295] Optionally, this step corresponds to step ⑥ in Figure 19, specifically including: 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.

[0296] 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 functions. In conjunction with Figure 20, this method mainly involves the following three aspects in terms of reducing power consumption and optimizing performance:

[0297] First, streamline the process of OpenCamera function in CAMX

[0298] Regarding 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 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 flow process, saving resource consumption when the front camera is used as an ambient light detection device and improving the performance of the electronic device.

[0299] The execution process of the simplified OpenCamera function is described by taking the process of adjusting the brightness of the display screen during the startup process shown in Figure 4 above as an example. 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 reading thread. By executing the simplified OpenCamera function, the image output and flow matching 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.

[0300] The ambient light detection judgment function may be IsSupportCamLightSensor(), and the ambient light detection sensor function may be OpenCamLightSensor().

[0301] The code for the logic of determining whether the front camera supports ambient light detection is:

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

[0303] Second, set a higher priority for the reading thread

[0304] Considering that multiple threads may be executed simultaneously in the camera driver, in order to ensure 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.

[0305] Third, adaptive switching frequency

[0306] Electronic devices have relatively strict requirements for the first frame data of ambient light brightness (the one frame data here is not the image frame), and generally require it to be reported 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, the 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 a target number of times from the camera register. When the target number of times is 0, the camera control module writes a first frequency into the camera register and controls the front camera to detect ambient light brightness at the first frequency. When the target number of times is greater than 0, the camera control module writes a second frequency into the camera register and controls the front camera to detect ambient light brightness at the second frequency, where 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 30 fps, and the second preset frame rate can be 5 fps or 3 fps.

[0307] This optimization method can be executed after step 405 and before step 406. By adaptively adjusting the frequency at which the front camera collects ambient light brightness, not only is the first frame data reported in a timely manner, but the power consumption of the electronic device is also reduced.

[0308] 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 method for adjusting the brightness of a display screen can be implemented.

[0309] 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 method for adjusting the brightness of the display screen.

[0310] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a..." does not preclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0311] The foregoing is merely 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 modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.< / float>

Claims

1. A method for adjusting the brightness of a display screen, characterized in that, The method includes: After the electronic device turns on the screen, power on the target camera; The electronic device detects the ambient light brightness through the target camera; Based on the ambient light brightness detected by the target camera, the electronic device adjusts the display screen brightness. During the process of the electronic device adjusting the display screen brightness, the target camera does not capture images, and the camera application is not started; In response to the user's operation, the electronic device starts the camera application; After starting the camera application, the electronic device captures images through the target camera and displays the interface of the camera application, and the interface of the camera application includes the images captured by the target camera.

2. The method according to claim 1, wherein The electronic device captures images through the target camera, including: Based on the start of the camera application, the electronic device powers off the target camera and then powers on the target camera; The electronic device obtains the images captured by the target camera.

3. The method according to claim 1, characterized in that, The method further includes: After starting the camera application, the electronic device does not adjust the display screen brightness.

4. The method according to claim 1, characterized in that, The method further includes: In response to the user's operation, the electronic device closes the camera application; After closing the camera application, the electronic device detects the ambient light brightness through the target camera; Based on the ambient light brightness detected by the target camera, the electronic device adjusts the display screen brightness. During the process of the electronic device adjusting the display screen brightness, the target camera does not capture images.

5. The method according to claim 4, characterized in that, The electronic device detects the ambient light brightness through the target camera, including: Based on the closing of the camera application, the electronic device powers off the target camera and then powers on the target camera; The electronic device obtains the ambient light brightness detected by the target camera.

6. The method according to claim 1, characterized in that, The software system of the electronic device includes a framework layer, a hardware abstraction layer, and a kernel layer. The framework layer includes a camera service module and a sensor service module. The hardware abstraction layer includes a camera control module and a sensor control module. The kernel layer includes a camera driver. After the electronic device turns on the screen and powers on the target camera, it includes: Based on the turning on of the screen of the electronic device, the sensor service module sends a brightness monitoring instruction to the sensor control module; After receiving the brightness monitoring instruction, the sensor control module calls a first interface based on the AIDL service, and then calls a second interface based on the HIDL service to send a first instruction to the camera service module. The first instruction packet includes a first identifier, and the first identifier corresponds to the ambient light detection function of the target camera; After receiving the first instruction, the camera service module calls a 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 target camera, initialize the camera register, and create a read thread for the ambient light brightness.

7. The method according to claim 6, characterized in that Before the electronic device detects the ambient light brightness through the target camera, it further includes: After the target camera is powered on, the camera control module obtains a target number of times from the camera register, and the target number of times is used to represent the number of times of reading the ambient light brightness detected by the target camera after the electronic device is turned on; When the target number of times is 0, the camera control module writes a first frequency into the camera register and controls the target camera to detect the ambient light brightness at the first frequency; When the target number of times is greater than 0, the camera control module writes a second frequency into the camera register and controls the target camera to detect the ambient light brightness at the second frequency, and the first frequency is greater than the second frequency.

8. The method according to claim 6, wherein Based on the ambient light brightness detected by the target camera, the electronic device adjusts the display screen brightness, including: The camera control module obtains a first ambient light brightness output by the target camera and sends a second ambient light brightness to the sensor control module through a data callback function, and the second ambient light brightness is generated based on the first ambient light brightness; The sensor control module sends the second ambient light brightness to the sensor service module; The sensor service module adjusts the display screen brightness of the electronic device based on the second ambient light brightness.

9. The method according to claim 8, wherein Before the camera control module obtains the first ambient light brightness output by the target camera and sends the second ambient light brightness to the sensor control module through a data callback function, it further includes: Based on the power-on of the electronic device, after receiving the brightness monitoring instruction, the sensor control module calls the first interface to register the data callback function in the camera control module.

10. The method according to claim 6, wherein The method further includes: After the electronic device is turned off the screen, the sensor control module calls a third interface based on the AIDL service, and then calls the second interface to send a second instruction to the camera service module, and the second instruction includes the first identifier; After receiving the second instruction, the camera service module calls a 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 target camera.

11. The method according to claim 6, wherein The method further includes: During the process of the electronic device adjusting the display screen brightness, when it is detected by a first death monitoring object that the camera control module does not respond, the camera control module sends a first death notification message to the sensor control module; After receiving the first death notification message, the sensor control module calls the first interface, and then calls The second interface sends the first instruction to the camera service module to enable the ambient light detection function of the target camera.

12. The method according to claim 11, wherein Before the sensor control module calls the first interface and then calls the second interface to send the first instruction to the camera service module, it further includes: The sensor control module determines whether the AIDL service is pulled up; When it is determined that the AIDL service is started, the sensor control module performs the operation of calling the first interface, then calling the second interface, and sending a third instruction to the camera service module.

13. The method according to claim 6, wherein The method further includes: After the electronic device is turned off the screen, when it is detected through a first death monitoring object that the camera control module does not respond, the camera control module sends a second death notification message to the sensor control module; After receiving the second death notification message, the sensor control module calls the first interface and sends an initialization instruction to the camera control module; After receiving the initialization instruction, the camera control module initializes the target camera and a data callback function, and the data callback function is used to send the ambient light brightness detected by the target camera to the sensor control module.

14. The method according to claim 13, wherein Before the sensor control module calls the first interface and sends an initialization instruction to the camera control module, it further includes: The sensor control module determines whether the electronic device is turned off the screen; When it is determined that the electronic device is turned off the screen, the sensor control module performs the operation of calling the first interface and sending an initialization instruction to the camera control module.

15. The method according to claim 6, wherein The method further includes: After the electronic device is turned on the screen, when it is detected through a second death monitoring object that the sensor control module does not respond, the sensor control module sends a third death notification message to the camera control module; After receiving the third death notification message, the camera control module closes the read thread and destroys the data callback function, and the data callback function is used to send the ambient light brightness detected by the target camera to the sensor control module; The sensor control module calls a third interface based on the AIDL service, then calls the second interface, and sends a second instruction to the camera service module, and the second instruction includes the first identifier; After receiving the second instruction, the camera service module calls a 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 read thread and power down the target camera; After the sensor control module restarts, it calls the first interface, registers the data callback function in the camera control module, and calls the second interface to send the first instruction to the camera service module to enable the ambient light detection function of the target camera.

16. The method according to claim 2, wherein The software system of the electronic device includes a framework layer, a hardware abstraction layer, and a kernel layer. The framework layer includes a camera service module and a sensor service module. The hardware abstraction layer includes a camera control module and a sensor control module. The kernel layer includes a camera driver. Based on the start of the camera application, the electronic device powers down the target camera and then powers on the target camera, including: Based on the start of the camera application, the camera service module receives a third instruction, which includes a second identifier and a second package name. The second identifier corresponds to the photographing function of the target camera, and the second package name is the package name of the camera application; The camera service module determines that there is a first identifier, and determines the priority of the first identifier and the second identifier according to the first package name and the second package name. The first identifier corresponds to the ambient light detection function of the target camera, and the first package name is the package name of the ambient light detection application; The camera service module determines that the priority of the first identifier is lower than the priority of the second identifier, controls the camera driver to power down the target camera to turn off the ambient light detection function of the target camera, and then controls the camera driver to power on the target camera to turn on the photographing function of the target camera.

17. An electronic device, characterized in that, It includes 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 method for adjusting the display screen brightness according to any one of claims 1 to 16.

18. A computer-readable storage medium, characterized in that, 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, it can implement the method for adjusting the display screen brightness according to any one of claims 1 to 16.

19. A computer program product, characterized in that, The computer program product includes a computer program, and when the computer program is executed by a processor, it can implement the method for adjusting the display screen brightness according to any one of claims 1 to 16.

Citation Information

Patent Citations

  • Mobile terminal and photographing method thereof

    CN105306806A

  • Image pick-up device control method and terminal

    CN105718194A

  • Brightness adjustment method and relevant product

    CN108764056A

  • Image shooting method and electronic equipment

    CN112153272A

  • Method and device for controlling terminal display and computer readable medium

    CN113783999A

Cited By

  • Method for realizing light sensation based on CMOS sensor, storage medium and electronic equipment

    CN121409399A