A method for obtaining ambient light brightness, electronic device, storage medium and chip

By using the ambient light customization module of the hardware abstraction layer in electronic devices to call the front camera to obtain ambient light brightness, the problems of high power consumption and low accuracy in the existing technology are solved, and more efficient ambient light brightness acquisition and calibration are achieved. .

CN117956290BActive Publication Date: 2024-10-25HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311787277.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-22
Publication Date
2024-10-25
Estimated Expiration
2043-12-22

AI Technical Summary

Technical Problem

The existing method of obtaining ambient light brightness through the front camera of existing electronic devices increases power consumption and affects user experience. In addition, due to hardware problems, the accuracy of the acquired ambient light brightness may be low, affecting calibration efficiency and real-time performance.

Method used

The ambient light customization module in the hardware abstraction layer calls the front camera to obtain the ambient light brightness, which reduces the processing requirements for preview photos and reduces power consumption. The obtained brightness value is calibrated through the calibration coefficient to improve accuracy and calibration efficiency. .

Benefits of technology

It reduces the power consumption of electronic equipment, improves user experience, improves the accuracy of ambient light brightness through calibration coefficients, and enhances the real-time and efficiency of calibration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117956290B_ABST
    Figure CN117956290B_ABST
Patent Text Reader

Abstract

The present application provides a method for obtaining ambient light brightness, an electronic device, a storage medium and a chip. The method can obtain ambient light brightness through a front camera, thereby reducing the cost of the electronic device increased by installing an ambient light detection device, and because no additional hole is required in the electronic device to install the ambient light detection device, the aesthetics of the electronic device is improved; and the electronic device can call the front camera to obtain the ambient light brightness value through the ambient light customization module in the hardware abstraction layer, compared with calling the camera through the camera customization module in the framework layer to obtain a frame of preview photos, performing a series of processing on the preview photos, and obtaining the ambient light brightness solution, since the present application does not need to perform a series of processing on the preview photos, the power consumption of the electronic device can be reduced, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminals, and in particular to a method for obtaining ambient light brightness, an electronic device, a storage medium and a chip. Background Art

[0002] Currently, electronic devices such as mobile phones and tablets have the function of automatically adjusting the brightness of the display screen. This function is implemented based on an ambient light detection device (eg, ambient light sensor, brightness sensor, etc.) in front of the display screen of the electronic device.

[0003] As is known to all, the front camera in an electronic device has the ability to detect the brightness of ambient light. Therefore, in order to reduce the cost of the electronic device and improve the aesthetics of the electronic device, some electronic devices obtain the brightness of ambient light through the front camera.

[0004] The usual solution for obtaining the ambient light brightness is to call the camera through the camera customization module in the framework layer of the electronic device to obtain a frame of preview photo, then calculate the brightness of each pixel in the preview photo, and then calculate the average pixel brightness of the preset photo, and use the average pixel brightness value as the ambient light brightness. This solution for obtaining the ambient light brightness requires the camera to output the preview photo and perform a series of processing on the preview photo, which increases the power consumption of the electronic device and may cause the electronic device to heat up, affecting the user experience. Summary of the invention

[0005] The present application provides a method for obtaining ambient light brightness, an electronic device, a storage medium and a chip, which can reduce the power consumption of the electronic device and improve the user experience.

[0006] In a first aspect, a method for obtaining ambient light brightness is provided, which is applied to an electronic device, wherein the electronic device includes an application layer, a framework layer, and a hardware abstraction layer, wherein the hardware abstraction layer includes a camera brightness manager and an ambient light customization module, and the method includes:

[0007] In response to an event (first trigger event) triggered by a user in an electronic device to obtain the ambient light brightness, the application layer sends an instruction (first instruction) to obtain a target brightness value to the camera brightness manager in the hardware abstraction layer through the framework layer; after receiving the first instruction, the camera brightness manager notifies the ambient light customization module in the hardware abstraction layer through the framework layer to call the front camera to obtain the target brightness value.

[0008] In the embodiment of the present application, the electronic device can obtain the target brightness value through the front camera, thereby reducing the cost of the electronic device increased by installing the ambient light detection device, and because no additional hole is required in the electronic device to install the ambient light detection device, the aesthetics of the electronic device is improved;

[0009] Furthermore, the electronic device can call the front camera through the ambient light customization module in the hardware abstraction layer to obtain the target brightness value, without having to call the camera through the camera customization module in the framework layer to obtain a frame of preview photo to obtain the ambient light brightness. Since the camera does not need to output the preview photo and perform a series of processing on the preview photo, the power consumption of the electronic device is reduced.

[0010] In combination with the first aspect, in some implementations of the first aspect, the ambient light customization module includes a brightness value reading and calculation module, and after the camera brightness manager receives the first instruction, it notifies the ambient light customization module in the hardware abstraction layer through the framework layer to call the front camera to obtain the target brightness value, including:

[0011] After receiving the first instruction, the camera brightness manager notifies the brightness value reading and calculation module through the framework layer to call the front camera to obtain the first brightness value; the brightness value reading and calculation module determines the target brightness value based on the first brightness value and the calibration coefficient.

[0012] It should be understood that hardware problems of electronic devices may affect the accuracy of the ambient light brightness obtained by the front camera. For example, due to problems such as the camera lens transmittance and the display screen transmittance, the ambient light brightness obtained by the front camera may be lower than the actual ambient light brightness.

[0013] In an embodiment of the present application, the electronic device can calibrate the first brightness value obtained by the front camera by calling the brightness value reading and calculation module according to the calibration coefficient, so that the first brightness value is close to the actual ambient light brightness, thereby improving the accuracy of the ambient light brightness obtained by the front camera.

[0014] In combination with the first aspect, in some implementations of the first aspect, after notifying the brightness value reading and calculation module through the framework layer to call the front camera to obtain the first brightness value, the method further includes:

[0015] The brightness value reading and calculating module fills the first brightness value in the callback function.

[0016] In combination with the first aspect, in some implementations of the first aspect, the brightness value reading and calculating module determines the target brightness value based on the first brightness value and the calibration coefficient, including:

[0017] In the process of notifying the brightness value reading and calculation module through the framework layer to call the front camera to obtain the first brightness value, and the brightness value reading and calculation module filling the first brightness value in the callback function, in response to the event (second trigger event) triggered by the user in the electronic device to calibrate the acquired ambient light brightness, the application layer sends an instruction (second instruction) for determining the calibration coefficient to the camera brightness manager through the framework layer, and the second instruction is used to instruct the electronic device to determine the calibration coefficient based on the second brightness value; after receiving the second instruction, the camera brightness manager notifies the brightness value reading and calculation module through the framework layer to call the front camera to obtain the second brightness value, and determines the calibration coefficient based on the second brightness value; the camera brightness manager interrupts the brightness value reading and calculation module calling the front camera to obtain the first brightness value; the brightness value reading and calculation module obtains the first brightness value from the callback function; the ambient light customization module determines the target brightness value according to the first brightness value and the calibration coefficient.

[0018] It should be understood that the brightness value reading and calculation module calls the front camera to obtain the first brightness value and the brightness value reading and calculation module calls the front camera to obtain the second brightness value. Both need to call the front camera, but there is only one front camera in the electronic device and it cannot be called at the same time. That is to say, when the brightness value reading and calculation module calls the front camera to obtain the second brightness value, the camera brightness manager will interrupt the brightness value reading and calculation module calling the front camera to obtain the first brightness value, and the brightness value reading and calculation module can no longer call the front camera to obtain the first brightness value. In the embodiment of the present application, since the brightness value reading and calculation module fills the first brightness value in the callback function before the interrupt processing, the brightness value reading and calculation module can obtain the first brightness value from the callback function, so that it can be ensured that the brightness value reading and calculation module calls the front camera to obtain the second brightness value (the second brightness value is used to determine the calibration coefficient) at the same time, the brightness value reading and calculation module can obtain the first brightness value;

[0019] It should also be understood that the solution of obtaining the ambient light brightness through the camera customization module in the framework layer usually requires first opening the front camera, determining the calibration coefficient based on the obtained ambient light brightness, and then obtaining the ambient light brightness by opening the front camera, and performing calibration based on the ambient light brightness and the calibration coefficient. It cannot guarantee that the camera customization module can obtain the ambient light brightness value at the same time, thus affecting the real-time performance and efficiency of the calibration. In the embodiment of the present application, since the brightness value reading and calculation module can obtain the first brightness value from the callback function, it can ensure that the brightness value reading and calculation module can obtain the first brightness value while calling the front camera to obtain the second brightness value, thereby ensuring the real-time performance and improving the calibration efficiency.

[0020] In combination with the first aspect, in some implementations of the first aspect, the ambient light customization module includes a callback function database management module, the callback function database management module includes an object of the callback function, and the brightness value reading and calculation module obtains the first brightness value from the callback function, including:

[0021] The callback function database management module reads the first brightness value in the callback function corresponding to the object broadcasted by the calculation module from the brightness value; and the brightness value reading module obtains the first brightness value.

[0022] In an embodiment of the present application, the ambient light customization module includes a callback function database management module. The callback function database management module can read the first brightness value in the callback function corresponding to the object of the callback function broadcast by the calculation module. The brightness value reading module can obtain the first brightness value, thereby ensuring that the brightness value reading module can obtain the first brightness value from the broadcast of the callback function database management module when the brightness value cannot be obtained through the front camera.

[0023] In combination with the first aspect, in certain implementations of the first aspect, after the camera brightness manager receives the first instruction, the priority of the brightness value reading and calculation module calling the front camera is equal to the priority of the brightness value reading and calculation module calling the front camera after the camera brightness manager receives the second instruction.

[0024] In combination with the first aspect, in some implementations of the first aspect, the method further includes:

[0025] When the ambient light customization module determines that the first process is in an abnormal state, it is prohibited to pass the target brightness value to the camera hardware manager through the callback function, and the first process includes the ambient light customization module calling the front camera to obtain the target brightness value; when the ambient light customization module determines that the second process is in an abnormal state, it is prohibited to pass the second brightness value to the camera hardware manager through the callback function, and the second process includes the brightness value reading and calculation module calling the front camera to obtain the second brightness value.

[0026] In an embodiment of the present application, when the ambient light customization module determines that the first process or the second process is in an abnormal state, the target brightness value or the second brightness value may be prohibited from being passed to the camera hardware manager through the callback function, thereby preventing the callback function from still passing data when the first process or the second process is in an abnormal state, thereby ensuring the stability of the electronic device.

[0027] In combination with the first aspect, in some implementations of the first aspect, the ambient light customization module includes a death monitoring module, and the method further includes:

[0028] The death monitoring module monitors the first process and the second process, and when either of the first process and the second process is in an abnormal state, sends a death notification to the callback function database management module; when the callback function database management module receives the death notification and the instruction sent by the camera brightness manager to cancel the callback function of the first process, it is determined that the first process is in an abnormal state; when the callback function database management module receives the death notification and the instruction sent by the camera brightness manager to cancel the callback function of the second process, it is determined that the second process is in an abnormal state.

[0029] In the embodiment of the present application, when determining that the first process or the second process is in an abnormal state, the callback function database management module is required to make a determination based on two data: a received death notification and a received instruction to cancel the callback function of the first process or the second process. This can avoid the situation where the death monitoring module cannot accurately monitor which process among multiple processes is in an abnormal state, resulting in monitoring errors, and avoid the influence of other events (such as the screen of an electronic device turning off) on the determination that the first process or the second process is in an abnormal state. This can accurately determine that the first process or the second process is in an abnormal state, thereby improving the reliability of determining that the first process or the second process is in an abnormal state.

[0030] In a second aspect, an electronic device is provided, and the electronic device is used to execute the method provided in the first aspect. Specifically, the electronic device may include a processing unit for executing any possible implementation manner of the first aspect.

[0031] In a third aspect, an electronic device is provided, comprising: one or more processors; one or more memories; one or more memories storing one or more computer programs, the one or more computer programs comprising instructions, which, when executed by the one or more processors, enable the electronic device to execute a method in any possible implementation of the first aspect described above.

[0032] According to a fourth aspect, a computer-readable storage medium is provided, comprising computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method according to the first aspect.

[0033] In a fifth aspect, a chip is provided, comprising a memory for storing instructions; and a processor for calling and executing instructions from the memory, so that an electronic device equipped with the chip executes the method of the first aspect above. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 It is a structural diagram of an electronic device 100 provided in an embodiment of the present application.

[0035] Figure 2It is a schematic diagram of the software structure of the electronic device 100 according to an embodiment of the present application.

[0036] Figure 3 It is a set of graphical user interfaces provided by the embodiments of the present application.

[0037] Figure 4 This is another set of graphical user interfaces provided by an embodiment of the present application.

[0038] Figure 5 This is another set of graphical user interfaces provided by an embodiment of the present application.

[0039] Figure 6 This is another set of graphical user interfaces provided by an embodiment of the present application.

[0040] Figure 7 It is a schematic flow chart of a method 200 for obtaining ambient light brightness provided in an embodiment of the present application.

[0041] Figure 8 This is a data flow diagram for obtaining ambient light brightness provided in an embodiment of the present application.

[0042] Fig. 9 This is a timing diagram for obtaining ambient light brightness provided in an embodiment of the present application.

[0043] Fig.10 yes Fig. 9 Detailed timing diagram of S310 and S311.

[0044] Fig.11 This is a data flow diagram of the first process and the second process provided in an embodiment of the present application simultaneously acquiring the ambient light brightness.

[0045] Fig.12 This is a timing diagram of the first process and the second process provided in an embodiment of the present application simultaneously acquiring the ambient light brightness.

[0046] Fig.13 It is a schematic flow chart of a method 500 for ensuring system stability of an electronic device provided in an embodiment of the present application.

[0047] Fig.14 It is a data flow diagram for ensuring the system stability of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "plurality" or "multiple" refers to two or more than two.

[0049] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.

[0050] The method provided in the embodiment of the present application is applied to electronic devices. The electronic device may also be referred to as a terminal, a user equipment (UE), a mobile station (MS), a mobile terminal (MT), etc. The electronic device may be an electronic device (mobile phone), a smart TV, a wearable device, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) electronic device, an augmented reality (AR) electronic device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, etc. The embodiment of the present application does not limit the specific technology and specific device form adopted by the electronic device.

[0051] Figure 11 is a schematic diagram of the structure of an electronic device 100 (taking a mobile phone as an example) provided in an embodiment of the present application. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, an antenna 1, an antenna 2, a mobile communication module 140, a wireless communication module 150, an audio module 160, a sensor module 170, a camera 181, a display screen 182, etc. The sensor module 170 may include a pressure sensor 170A, a gyroscope sensor 170B, etc.

[0052] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0053] 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 memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0054] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0055] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0056] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0057] In the embodiment of the present application, the electronic device 100 can call the camera through the processor 110 to obtain the ambient light brightness, and calibrate the ambient light brightness through the processor 110, and adjust the brightness of the display screen according to the calibrated ambient light brightness.

[0058] The electronic device 100 can also create a process through the processor 110 to obtain the ambient light brightness, and create another process to determine the calibration coefficient after obtaining the ambient light brightness, and ensure that the two processes can obtain the ambient light brightness at the same time, thereby ensuring the real-time calibration and improving the calibration efficiency.

[0059] The electronic device 100 can also determine whether a process is in an abnormal state through the processor 110. When it is determined that the process is in an abnormal state, the process is prohibited from obtaining the ambient light brightness, thereby ensuring the system stability of the electronic device.

[0060] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 140, the wireless communication module 150, the modem processor and the baseband processor.

[0061] The electronic device 100 implements the display function through a GPU, a display screen 182, and an application processor.

[0062] The display screen 182 is used to display images, videos, etc. The display screen 182 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), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 182, where N is a positive integer greater than 1.

[0063] The electronic device 100 can realize the shooting function through ISP, camera 181, video codec, GPU, display screen 182 and application processor.

[0064] In the embodiment of the present application, the electronic device 100 can obtain the brightness of the ambient light through the camera 181, and then adjust the brightness of the display screen 182 according to the brightness of the ambient light.

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

[0066] The internal memory 121 can be used to store computer executable program codes, and the executable program codes include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc., and also for example, ambient light brightness data and calibration coefficients in the embodiments of the present application), 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 storage (UFS), etc.

[0067] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 160 and the application processor.

[0068] The pressure sensor 170A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 170A can be disposed on the display screen 182 .

[0069] The gyro sensor 170B may be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (ie, x, y, and z axes) may be determined by the gyro sensor 170B.

[0070] The hardware structure of the electronic device 100 is introduced here. It can be understood that: Figure 1The components included in the hardware structure shown do not constitute a specific limitation on the electronic device 100. The electronic device 100 may have more or fewer components than those shown in the figure, may combine two or more components, or may have different component configurations. The various components shown in the figure may be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and / or application specific integrated circuits.

[0071] In addition, an operating system is running on the above components, such as the iOS operating system developed by Apple, the Android open source operating system developed by Google, and the Windows operating system developed by Microsoft. Application programs can be installed and run on the operating system.

[0072] The operating system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.

[0073] Figure 2 1 is a schematic diagram of the software structure of the electronic device 100 of the embodiment of the present application. The software structure includes several layers, each layer has a clear role and division of labor, and the layers communicate with each other through software interfaces. In some embodiments, the software structure is divided into an application layer, an application framework layer, a hardware abstraction layer, a kernel layer, and a hardware layer from top to bottom.

[0074] The application layer can include a series of application packages (Application, App), such as, Figure 2 The display brightness adjustment APP, brightness calibration APP, etc. are shown. Of course, in some embodiments, the application layer may also include application packages such as camera, gallery, calendar, map, navigation, etc. When these application packages are running, they can access various service modules provided by the application framework layer through the application programming interface (API) and execute corresponding services.

[0075] For example, when the display brightness adjustment APP is running, the sensor manager (SensorManager) provided by the application framework layer can be accessed through the application interface, and the task of obtaining the ambient light brightness is performed to realize the function of adjusting the display brightness.

[0076] The application framework layer (Framework, FWK), referred to as the framework layer, provides application programming interface (application programming interface, API) and programming framework for the application layer. The framework layer includes some predefined functions. For example, Figure 2 The camera interface (ICameraService), camera service (CameraService), sensor manager (SensorManger) and sensor service (SensorService) are shown.

[0077] Among them, ICameraService is the interface of the camera service, which is used to request connection, add monitoring, etc. ICameraService is mainly implemented through the CameraService class. CameraService is a service that interacts with the application layer and the hardware abstraction layer, and plays a connecting role. CameraService basically manages all behaviors of the camera, such as turning the camera on and off, taking pictures through the camera, and obtaining camera data. SensorManger is an abstract class, which is mainly used by the application layer. This class is an interface provided to the application layer. SensorService is a sensor framework layer service, which interacts with the underlying driver kernel through the hardware abstraction layer interface. SensorService basically manages all behaviors of the sensor, such as turning the sensor on and off, obtaining sensor data, etc.

[0078] The Hardware Abstraction Layer (Hal) is a package of the Linux kernel driver, providing an interface to the upper layer. It hides the hardware interface details of a specific platform and provides a virtual hardware platform for the software structure, making it hardware-independent and portable on multiple platforms. Figure 2 As shown, the hardware abstraction layer includes a camera hardware abstraction layer, a sensor hardware abstraction layer, etc.

[0079] Among them, the camera hardware abstraction layer includes a code implementation set for customizable requirements (CHI-CDK) and a code implementation set for common functional interfaces (CAMX). CHI-CDK includes customizable interfaces, and CAMX includes some highly unified functional interfaces.

[0080] CHI-CDK includes an Android Interface Definition Language (AIDL) initialization module, which is used to initialize AIDL. AIDL is a language used in Android to define cross-process communication interfaces. It is used to describe the methods, parameters, and data types associated with an interface, allowing different Android components (applications, services, etc.) to communicate in different processes.

[0081] CAMX includes a camera customization module (Open Camera), which is mainly used to operate the underlying camera device to obtain the ambient light brightness. Open Camera includes an ambient light customization module (Camxlightcustom), which is mainly used to call the camera device to obtain the ambient light brightness.

[0082] The sensor hardware abstraction layer includes the sensor hardware abstraction interface (Sensor Hal), the camera brightness manager (CameralightManager), and the camera hardware access interface (libcamera2ndk_vendor).

[0083] Among them, the Sensor Hal interface is mainly used to interact with the underlying driver kernel, CameralightManager is mainly used to send instructions to the ambient light customization module in the camera hardware abstraction layer, for example, sending instructions to register callback functions, and receiving data sent by the ambient light customization module, for example, ambient light brightness, and libcamera2ndk_vendor is mainly used to enable the camera brightness manager to interact with the camera interface in the framework layer.

[0084] The kernel layer is the layer between hardware and software. Figure 2 As shown, the kernel layer may at least include a non-volatile memory driver, a camera driver, etc.

[0085] The hardware layer includes at least non-volatile memory, camera, etc.

[0086] Understandably, Figure 2 The layers in the software structure shown and the components contained in each layer do not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer layers than shown in the figure, and each layer may include more or fewer components, for example, the kernel layer includes sensor drivers, etc., and for another example, the software structure may also include system libraries, etc., which are not limited in the present application.

[0087] It is understandable that in order to implement the method for obtaining the ambient light brightness in the embodiment of the present application, the electronic device includes hardware and / or software modules corresponding to the execution of each function. In combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments.

[0088] It should be noted that although the embodiments of the present application are described using the Android system as an example, its basic principles are also applicable to electronic devices based on operating systems such as iOS or Windows.

[0089] The execution subject of the method for obtaining the brightness of ambient light provided in the embodiment of the present application can be the above-mentioned electronic device, or it can be a functional module and / or functional entity in the electronic device that can implement the method for obtaining the brightness of ambient light, and the scheme of the present application can be implemented by hardware and / or software, which can be determined according to actual use requirements, and the embodiment of the present application is not limited. Taking an electronic device as an example, the method for obtaining the brightness of ambient light provided in the embodiment of the present application is exemplarily described in combination with the accompanying drawings.

[0090] The technical problems to be solved by this application and the inventive concept of this application are introduced below.

[0091] At present, electronic devices such as mobile phones and tablets have the function of automatically adjusting the brightness of the display screen. This function is realized based on the ambient light detection device (for example, ambient light sensor, brightness sensor, etc.) in front of the electronic device display screen. The ambient light detection device can sense the ambient light brightness, and the electronic device can adaptively adjust the brightness and color temperature of the display screen in the electronic device according to the sensed ambient light brightness.

[0092] However, installing an ambient light detection device on an electronic device will increase the cost of the electronic device. When installing an ambient light detection device in an electronic device, a hole needs to be opened in the glass ink of the display screen of the display. Installing the ambient light detection device in the hole will affect the appearance of the electronic device.

[0093] As is known to all, a front camera in an electronic device is equipped with a photoresistor and a photosensitive sensor. Therefore, in order to reduce the cost of the electronic device and improve the aesthetics of the electronic device, some electronic devices obtain the ambient light brightness through the front camera.

[0094] The solution for obtaining the ambient light brightness through the front camera is usually to call the camera through the application framework layer to obtain a frame of preview photo, then calculate the brightness of each pixel in the preview photo, and then calculate the average pixel brightness of the preset photo, and use the average pixel brightness value as the ambient light brightness. For the sake of ease of description, the above-mentioned running activity for obtaining the ambient light brightness is called process 1. This solution for obtaining the ambient light brightness through process 1 requires the camera to output the preview photo and perform a series of processing on the preview photo, which increases the power consumption of the electronic device and may cause the electronic device to heat up, affecting the user experience.

[0095] Moreover, hardware problems of electronic devices may affect the accuracy of the ambient light brightness obtained by the front camera. For example, due to problems such as the camera lens transmittance and the display screen transmittance, the ambient light brightness obtained by the front camera may be less than the actual ambient light brightness. For example, the higher the camera lens transmittance, the closer the obtained ambient light brightness is to the actual ambient light brightness, and the lower the camera lens transmittance, the more the obtained ambient light brightness deviates from the actual ambient light brightness. Therefore, the solution for obtaining ambient light brightness through the front camera usually calibrates the ambient light brightness obtained by the front camera.

[0096] Generally, when calibrating the ambient light brightness obtained by the front camera, firstly, an ambient light brightness is obtained through process 1, and then the ambient light brightness is obtained again through the front camera, and the calibration coefficient is determined through the ambient light. For the convenience of description, the above-mentioned operation activity of determining the calibration coefficient through the ambient light obtained again is called process 2. Finally, the ambient light brightness obtained by process 1 is calibrated according to the calibration coefficient determined by process 2. It can be seen from the above that process 1 needs to turn on the front camera to obtain the ambient light brightness, and process 2 also needs to turn on the front camera to obtain the ambient light brightness, but there is only one front camera. When process 2 turns on the front camera, the front camera turned on by process 1 needs to be closed. In this way, it cannot be guaranteed that process 1 and process 2 obtain the ambient light brightness at the same time. Therefore, the solution for obtaining the ambient light brightness through the front camera is usually to first open the front camera through process 2, determine the calibration coefficient, and then open the front camera through process 1 to obtain the ambient light brightness, and implement calibration according to the ambient light brightness and the calibration coefficient, which affects the real-time performance and efficiency of the calibration.

[0097] The method for obtaining ambient light brightness provided in the embodiment of the present application can use the front camera in the electronic device to obtain the ambient light brightness, thereby reducing the cost of the electronic device increased by installing the ambient light detection device, and because no additional holes are required to install the ambient light detection device, the aesthetics of the electronic device is improved.

[0098] In addition, the embodiment of the present application can read the ambient light brightness from the register of the photoresistor or photosensor installed in the front camera, without the need for the camera to output preview photos and perform a series of processing on the preview photos, thereby reducing the power consumption of the electronic device.

[0099] For the sake of ease of description, the above-mentioned operating activity of reading the ambient light brightness from the register of the photoresistor or photosensor installed in the front camera is called the first process, and the operating activity of reading the ambient light brightness again from the register of the photoresistor or photosensor installed in the front camera and determining the calibration coefficient through the ambient light is called the second process.

[0100] In the embodiment of the present application, the ambient light brightness can be read through the first process, and the calibration coefficient can be determined through the second process, and the first process and the second process can simultaneously obtain the ambient light brightness, thereby ensuring the real-time performance of the calibration and improving the calibration efficiency. The implementation method of the first process and the second process simultaneously obtaining the ambient light brightness can be referred to in the following embodiment, which will not be elaborated here.

[0101] The following describes the method for obtaining ambient light brightness provided by an embodiment of the present application in conjunction with specific application scenarios.

[0102] the following Figure 3 It is a set of graphical user interfaces (GUI) provided in the embodiments of the present application.

[0103] In one scenario, an electronic device detects a user's power-on operation. Figure 3 , electronic devices include power buttons, Figure 3 The user interface shown in (a) is an interface displayed when the electronic device is not turned on. When the electronic device is not turned on, the user presses the power button for a preset time, such as 3 seconds, and the electronic device can detect the user's power-on operation. The user presses the power button for a preset time, and the electronic device displays Figure 3 In the power-on logo shown in (b), during the process of displaying the power-on logo, in response to the power-on operation, the electronic device reads the ambient light brightness from the register of the photoresistor or photosensor installed in the front camera, and adaptively adjusts the brightness of the display screen in the electronic device according to the ambient light brightness.

[0104] the following Figure 4 This is another set of GUIs provided by an embodiment of the present application.

[0105] In another scenario, the electronic device detects the user's restart operation, please refer to Figure 4 , electronic devices include power buttons, Figure 4The user interface shown in (a) is an interface displayed when the electronic device is powered on. When the electronic device is powered on, the user presses the power button for a preset time, such as 3 seconds. In response to the user's operation, the electronic device displays the following Figure 4 The user interface shown in (b) is as follows: Figure 4 As shown in (b) in the figure, the interface includes two controls, "restart" and "shutdown". When the user clicks the "restart" control, the electronic device can detect the user's restart operation. In response to the restart operation, the electronic device reads the ambient light brightness from the register of the photoresistor or photosensor installed in the front camera, and adaptively adjusts the brightness of the display screen in the electronic device according to the ambient light brightness.

[0106] the following Figure 5 This is another set of GUIs provided by an embodiment of the present application.

[0107] In another scenario, the electronic device detects the user's operation of turning on automatic brightness adjustment. Figure 5 , Figure 5 The user interface shown in (a) includes a series of application icons, including "Camera", "Gallery", "Settings", etc. The user clicks the "Settings" icon, and in response to the user's operation, the electronic device displays the following Figure 5 The user interface shown in (b) includes controls such as "flight mode", "wireless LAN", "cellular network", and "display and brightness". The user clicks the "display and brightness" control. In response to the user's operation, the electronic device displays the following Figure 5 The user interface shown in (c) includes controls such as "automatic adjustment". When the user turns on the "automatic adjustment" control, the electronic device can detect the user's operation of turning on automatic brightness adjustment. In response to the operation of turning on automatic brightness adjustment, the electronic device reads the ambient light brightness from the register of the photoresistor or photosensor installed in the front camera, and adaptively adjusts the brightness of the display screen in the electronic device according to the ambient light brightness.

[0108] the following Figure 6 This is another set of GUIs provided by an embodiment of the present application.

[0109] In another scenario, the electronic device detects the user's calibration operation, please refer to Figure 6 , Figure 6 The user interface shown in (a) includes a series of application icons, including "Camera", "Gallery", "Calibration", etc. The user clicks the "Calibration" icon, and in response to the user's operation, the electronic device displays the following Figure 6The user interface shown in (b) includes controls such as "Start" and "End". When the user clicks the "Start" control, the electronic device can detect the user's calibration operation. In response to the user's calibration operation, the electronic device reads the ambient light brightness from the register of the photoresistor or photosensitive sensor installed in the front camera, determines the calibration coefficient based on the ambient light brightness, and calibrates the ambient light brightness based on the calibration coefficient, so that the electronic device can adaptively adjust the brightness of the display screen in the electronic device according to the calibrated ambient light brightness.

[0110] Through the above Figures 2 to 6 It can be seen that the embodiments of the present application can respond to the user's power-on operation, restart operation, automatic brightness adjustment operation, or calibration operation by reading the ambient light brightness from the register of the photoresistor or photosensor installed in the front camera. There is no need for the camera to output preview photos and perform a series of processing on the preview photos, thereby reducing the power consumption of the electronic device.

[0111] Combination of the above Figures 2 to 6 The application scenario of the method for obtaining the ambient light brightness provided in the embodiment of the present application is introduced. The internal implementation process of the method for obtaining the ambient light brightness provided in the embodiment of the present application is introduced below.

[0112] Please refer to Figure 7 , Figure 7 1 is a schematic flow chart of a method 200 for obtaining ambient light brightness provided in an embodiment of the present application. The method 200 may be executed by an electronic device, or by a processor or chip in the electronic device, and the embodiment of the present application does not make any limitation. For ease of description, the method 200 is described in detail by taking an electronic device as an example.

[0113] S201. In response to a first trigger event, the electronic device reads a brightness value of 1 through an ambient light detection device in a front camera.

[0114] It should be understood that the first trigger event may be a user executing Figure 3 The user's boot operation, Figure 4 Restart operation in , or Figure 5 An event triggered by the operation of turning on automatic brightness adjustment, where the first trigger event is used to trigger the electronic device to read the brightness value through the front camera.

[0115] It should also be understood that the ambient light detection device in the front camera can be a photoresistor, a photosensor, etc., and the embodiments of the present application are not limited to this.

[0116] It is also understandable that hardware problems of electronic devices may affect the accuracy of the ambient light brightness obtained by the front camera. For example, due to problems such as the camera lens transmittance and the display screen transmittance, the ambient light brightness obtained by the front camera may be lower than the actual ambient light brightness. Therefore, in the embodiment of the present application, the brightness value 1 refers to a brightness value that is lower than the actual ambient light brightness.

[0117] In the embodiment of the present application, after the ambient light detection device in the front camera senses the brightness value 1, the brightness value 1 is stored in the register of the ambient light detection device, and the electronic device can read the brightness value 1 from the register of the ambient light detection device.

[0118] S202: The electronic device determines a brightness value 2 according to the brightness value 1 and a calibration coefficient.

[0119] It should be understood that due to hardware problems of the electronic device, the brightness value 1 obtained by the front camera is smaller than the actual ambient light brightness. The embodiment of the present application can calibrate the brightness value 1 through a calibration coefficient to make the obtained brightness value close to the actual ambient light brightness. In the embodiment of the present application, the brightness value 2 refers to the brightness value after calibration that is close to the actual ambient light brightness.

[0120] It should also be understood that the calibration coefficients may be pre-stored in a non-volatile memory (NVM). NVM has the characteristics of non-volatility and high storage density. When the electronic device is turned off or an abnormality occurs, the calibration coefficients stored in the NVM will not be lost.

[0121] In the implementation, for example, the actual ambient light brightness value is 10, the brightness value 1 obtained by the electronic device through the front camera is 8, and the calibration coefficient stored in the NVM is 1.25. The electronic device can multiply the brightness value 1 of 8 by the calibration coefficient 1.25, and the determined brightness value 2 is 10.

[0122] In the embodiment of the present application, the electronic device can read the brightness value through the front camera, thereby reducing the cost of the electronic device increased by installing the ambient light detection device, and because no additional hole is required to install the ambient light detection device, the aesthetics of the electronic device is improved;

[0123] Furthermore, the electronic device can read the ambient light brightness from the ambient light detection device installed in the front camera, and there is no need for the camera to output preview photos and perform a series of processing on the preview photos, thereby reducing the power consumption of the electronic device.

[0124] Moreover, the electronic device can also calibrate the ambient light brightness according to the calibration coefficient, thereby improving the accuracy of the ambient light brightness obtained through the front camera.

[0125] The above embodiments are combined with the attached Figure 7 A method 200 for obtaining ambient light brightness is introduced. Figures 8 to 10 The method 200 is described in detail.

[0126] Figure 8 is a data flow diagram for obtaining ambient light brightness provided by an embodiment of the present application. Fig. 9 This is a timing diagram for obtaining ambient light brightness provided by an embodiment of the present application, including S301 to S314. Fig.10 yes Fig. 9 Detailed timing diagram of S310 and S311. Figure 8 Data interaction between modules Fig. 9 and Fig.10 The steps in the embodiment correspond to each other, therefore, the present application describes in detail Fig. 9 and Fig.10 Steps in Figure 8 The data flows involved can be found in Fig. 9 and Fig.10 .

[0127] S301. In response to a first trigger event, the application layer sends a startup instruction to a startup service in the framework layer.

[0128] The first trigger event in the embodiment of the present application may be a user executing Figure 3 The power-on operation or Figure 4 An event triggered by a restart operation in the process, wherein the first trigger event is used to turn on the electronic device and trigger the electronic device to read a brightness value through a front camera.

[0129] In the embodiment of the present application, when the electronic device is turned on, the electronic device can automatically read the ambient light brightness and adaptively adjust the brightness of the display screen in the electronic device according to the ambient light brightness.

[0130] Figure 8 and Fig. 9 The display brightness adjustment APP in the application layer is a module that allows users to perform power-on or restart operations in the application layer.

[0131] S302: After receiving the power-on instruction, the power-on service notifies the camera hardware abstraction layer to initialize.

[0132] It should be understood that Figure 8It can be seen that the camera hardware abstraction layer includes CHI-CDK and CAMX, among which CHI-CDK includes AIDL initialization module, CAMX includes Open Camera, Open Camera includes Camxlightcustom, Camxlightcustom includes application buffer module and power-on / initialization register module. After receiving the power-on instruction, the boot service notifies the AIDL initialization module, application buffer module and power-on / initialization register module in the camera hardware abstraction layer to initialize. Of course, in some embodiments, it can also notify Figure 8 Initialize any module that needs to be initialized, for example, notify each interface to initialize, etc. Initialization is a programming language term, and its function is to assign variables to default values, set interfaces to default states, and prepare those that are not prepared.

[0133] S303: After receiving the initialization notification, the camera hardware abstraction layer initializes AIDL through the AIDL initialization module.

[0134] It should be understood that after AIDL is initialized through the AIDL initialization module, Figure 8 The modules shown in the figure can communicate across processes.

[0135] S304: After receiving the initialization notification, the camera hardware abstraction layer applies for a buffer zone from the memory through a buffer zone application module.

[0136] It should be understood that the buffer is a storage space of a specified size reserved in the memory for temporary storage of the ambient light brightness value.

[0137] S305: After receiving the initialization notification, the camera hardware abstraction layer powers on or initializes the registers in the camera through the power-on / initialization register module.

[0138] It should be understood that initializing or powering on the register in the camera specifically refers to initializing or powering on the register of the ambient light detection device in the camera, and the initialized or powered-on register can read the ambient light brightness.

[0139] S306. In response to the first trigger event, the application layer sends an instruction to obtain the ambient light brightness value to the camera brightness manager in the sensor hardware abstraction layer through the sensor manager and sensor service in the framework layer and the sensor hardware abstraction layer interface in the sensor hardware abstraction layer. After receiving instruction 1, the camera brightness manager sends instruction 1 to the camera service in the framework layer through the first active interface in the camera brightness manager, the camera hardware access interface in the sensor hardware abstraction layer and the camera interface in the framework layer, and sends an instruction to register a callback function to the ambient light customization module in the camera hardware abstraction layer through the first active interface in the camera brightness manager.

[0140] It should be understood that for ease of description, in the embodiment of the present application, in response to the first trigger event, the application layer sends an instruction to the camera brightness manager to obtain the ambient light brightness value as instruction 1, and after the camera brightness manager receives instruction 1, the instruction to register the callback function sent to the ambient light customization module is called instruction 2.

[0141] The first trigger event in the embodiment of the present application may be a user executing Figure 3 The power-on operation or Figure 4 The event is triggered by the restart operation in the Figure 3 The power-on operation or Figure 4 After the restart operation in , when the user's electronic device is turned on, the camera hardware abstraction layer has been initialized, and the user has turned off Figure 5 After resetting the "Auto Adjust" control shown in (c) Figure 5 The event triggered by the "Auto Adjust" control shown in (c) in FIG.

[0142] Figure 8 and Fig. 9 The display brightness adjustment APP is a module that allows users to perform power-on operations, restart operations, or enable automatic brightness adjustment operations in the application layer.

[0143] It should also be understood that the solution for obtaining the ambient light brightness through the front camera is usually to call the camera to obtain a frame of preview photo through the camera customization module in the application framework layer to obtain the ambient light brightness. In order to avoid the problem of high power consumption caused by the above solution, the camera customization module in the hardware abstraction layer can be used to read the ambient light brightness value from the ambient light detection device in the camera. Therefore, in order to enable the instruction 1 issued by the application layer to smoothly reach the camera customization module in the hardware abstraction layer, please refer to the implementation. Figure 8The application layer sends instruction 1 to the camera brightness manager in the sensor hardware abstraction layer through the sensor manager and sensor service in the framework layer and the sensor hardware abstraction layer interface in the sensor hardware abstraction layer, and then sends instruction 1 to the camera service in the framework layer through the first active interface in the camera brightness manager, the camera hardware access interface in the sensor hardware abstraction layer and the camera interface in the framework layer. After receiving instruction 1, the camera service sends instruction 1 to the camera customization module in the hardware abstraction layer.

[0144] It can be understood that the callback function is the application of the function pointer. In layman's terms, the callback function is to call a function by using the function pointer, and the callback function registration is the process of passing the function pointer as a parameter to facilitate the use of other modules. In this embodiment of the application, in order to pass the ambient light brightness value read by the camera customization module in the hardware abstraction layer to the application layer, the ambient light brightness value can be filled into the callback function and passed through the callback function and the sensor hardware layer and framework layer. Therefore, please refer to Figure 8 When the application layer passes instruction 1 down to the camera manager through layers, instruction 2 can be sent to the ambient light customization module in the camera hardware abstraction layer through the first active interface in the camera brightness manager. Instruction 2 is used to instruct the ambient light customization module to register a callback function.

[0145] It can be understood that the application layer sends instruction 1 to the camera brightness manager in the sensor hardware abstraction layer through the sensor manager and sensor service in the framework layer and the sensor hardware abstraction layer interface in the sensor hardware abstraction layer. After receiving instruction 1, the camera brightness manager creates a process. This process is for the display brightness adjustment APP to call the front camera to obtain the ambient light brightness. For the convenience of description, this process is called the first process in the embodiment of the present application. The first process mainly includes S307 to S312. Therefore, Figure 8 The instruction 2 sent by the first active interface in the process to the ambient light customization module includes the process identifier (PID) of the first process.

[0146] S307 . After receiving instruction 2 , the ambient light customization module registers the callback function through the callback function registration module and saves the CB object and the process number in the callback function database management module.

[0147] It should be understood that the CB object is used to indicate the registered callback function, the process number is the identifier of the process, and the process number of the embodiment of the present application can be the process number of the first process.

[0148] In implementation, registering the callback function through the callback function registration module may be: illustratively, void RegisterLuxCallback (in int pid, vendor.XXX.hardware.camlight.ILuxCallback callback).

[0149] Among them, RegisterLuxCallback() refers to the function name of the registered callback function, pid refers to the process number, and Callback refers to the callback function.

[0150] S308. After receiving instruction 1, the camera service determines the priority of the called camera according to the camera identification through the camera identification management module.

[0151] In the embodiment of the present application, instruction 1 includes the package name (PackageName) of the application for obtaining the ambient light brightness.

[0152] It should be understood that many applications in electronic devices need to call the front camera to implement certain functions. For example, "camera" applications use the front camera to realize selfies, and "social" applications use the front camera to realize video calls, Figure 3 The calibration APP and the display brightness adjustment APP shown in the figure adjust the display brightness by calling the front camera. In a scenario, when an application is calling the front camera, another application may also need to call the front camera. However, there is only one front camera and it can only be called by one application. In order to avoid conflicts when different applications call the front camera, such as Figure 8 As shown, the camera service in the framework layer of the embodiment of the present application includes a camera identification management module, which stores the correspondence between the package name of the application, the camera identification and the priority. The camera identification management module determines the priority of the called camera according to the camera identification based on the correspondence.

[0153] For example, the corresponding relationship between the package name of the application, the camera ID and the priority can be referred to in the following table:

[0154] Table 1

[0155] The package name of the application Camera logo Priority Application 1 CameraID1 Highest Application 2 CameraID2 high Application 3 CameraID3 middle Application 4 CameraID4 Low Application 5 CameraID4 Low

[0156] It should also be understood that the package name of the application and the camera ID have a one-to-one correspondence. In implementation, after the camera service receives instruction 1, instruction 1 includes the package name of the application for obtaining the ambient light brightness, such as application 4. The camera ID management module can determine the camera ID of the camera that the application needs to call based on Table 1. For example, the camera ID corresponding to application 4 is CameraID4.

[0157] It should be noted that when an application is calling the front camera, if no other application is calling the front camera, then the front camera can be called directly regardless of whether the priority of the application calling the front camera is high or low.

[0158] In the process of one application calling the front camera, when another application also needs to call the front camera, the camera identification management module can determine the priority of the application calling the front camera according to the corresponding relationship shown in Table 1. The application with a high priority calls the front camera first, and the application with a low priority calls the front camera later. For applications with the same priority, the calling instruction of the application received later by the camera identification management module will interrupt the calling instruction of the application received earlier. In other words, the application that receives the calling instruction later by the camera identification management module can call the front camera and interrupt the application that receives the calling instruction earlier. For example, in the process of application 3 calling the front camera, application 4 also needs to call the front camera. Since the priority of application 3 is higher than that of application 4, application 3 calls first and application 4 calls later. For another example, in the process of application 4 calling the front camera, application 5 also needs to call the front camera. Since the priority of application 4 is equal to the priority of application 5, however, application 4 sends the calling instruction to the camera identification management module first, and application 5 sends the calling instruction to the camera identification management module later, so application 5 can call the front camera and interrupt application 4 from calling the front camera.

[0159] S309: The camera service notifies the ambient light customization module in the camera hardware abstraction layer to obtain the ambient light brightness value through the camera according to the priority of the called camera.

[0160] S310: After receiving the notification, the ambient light customization module reads and calculates the ambient light brightness value through the brightness value reading and calculation module.

[0161] Please refer to Fig.10In the implementation, when S310 reads and calculates the ambient light brightness value through the brightness value reading and calculation module, the brightness value reading and calculation module sends an instruction to read the brightness value to the camera through the camera driver in the kernel layer (for the convenience of description, this instruction is referred to as instruction 3), and the camera reads the brightness value after receiving instruction 3 (this brightness value is referred to as brightness value 1 in the embodiment of the present application), and the camera returns the brightness value 1 to the brightness value reading and calculation module in the ambient light customization module through the camera driver.

[0162] The brightness value reading and calculation module sends an instruction to read the calibration coefficient to the non-volatile memory through the non-volatile memory driver in the kernel layer (for the convenience of description, this instruction is called instruction 4). After receiving instruction 4, the calibration coefficient is read, and the non-volatile memory returns the calibration coefficient to the brightness value reading and calculation module in the ambient light customization module through the non-volatile memory driver.

[0163] It should be noted that after the ambient light customization module receives the above notification, it can cyclically read and calculate the ambient light brightness value through the brightness value reading and calculation module. For example, the brightness value reading and calculation module sends instruction 3 to the camera through the camera driver cycle in the kernel layer, so that the brightness value reading and calculation module can obtain the constantly changing ambient light brightness value.

[0164] In implementation, the electronic device can create multiple threads in the first process, and read the ambient light brightness value through the multiple threads in a loop. A process refers to an execution process of a program with independent functions on a certain data set, and a thread refers to an execution entity or execution unit within a process. A process includes multiple threads.

[0165] S311 , after receiving the calibration coefficient and the brightness value 1 , the brightness value reading and calculating module determines the brightness value 2 according to the calibration coefficient and the brightness value 1 .

[0166] For example, the calibration coefficient stored in the NVM is 1.25, and the electronic device may multiply the value 8 of the brightness value 1 by the calibration coefficient 1.25 to determine the brightness value 2 as 10.

[0167] S312. The brightness value reading and calculation module transmits the brightness value 2 to the reporting ambient light status interface in the camera hardware manager in the sensor hardware abstraction layer through the callback function.

[0168] It should be understood that the brightness value reading and calculating module can fill the brightness value 2 into the callback function and pass the brightness value 2 through the callback function.

[0169] S313. After receiving the brightness value 2, the report ambient light status interface transmits the brightness value 2 to the display brightness adjustment APP in the application layer through the sensor hardware abstraction layer interface in the sensor hardware abstraction layer, the sensor service in the framework layer, and the sensor manager in the framework layer.

[0170] S314 . After receiving the brightness value 2 , the display brightness adjustment APP adjusts the display brightness according to the brightness value 2 .

[0171] In the embodiment of the present application, the electronic device can read the brightness value through the front camera, thereby reducing the cost of the electronic device increased by installing the ambient light detection device, and because no additional hole is required to install the ambient light detection device, the aesthetics of the electronic device is improved;

[0172] Furthermore, the electronic device can read the ambient light brightness value from the ambient light detection device in the camera through the camera customization module in the hardware abstraction layer, and there is no need to call the camera through the camera customization module in the application framework layer to obtain a frame of preview photo to obtain the ambient light brightness. Since the camera does not need to output the preview photo and perform a series of processing on the preview photo, the power consumption of the electronic device is reduced.

[0173] Moreover, the electronic device can also calibrate the ambient light brightness according to the calibration coefficient, thereby improving the accuracy of the ambient light brightness obtained through the front camera.

[0174] The above embodiments are combined Figures 7 to 10 The implementation process of a method 200 for obtaining ambient light brightness provided in an embodiment of the present application is described. Fig.11 and Fig.12 The internal implementation method in which the first process and the second process in the above embodiment can simultaneously obtain the ambient light brightness is described in detail.

[0175] Fig.11 The data flow diagram of the first process and the second process simultaneously obtaining the ambient light brightness provided by the embodiment of the present application is as follows: Fig.12 is a timing diagram of the first process and the second process simultaneously acquiring the ambient light brightness provided by the embodiment of the present application, including S401 to S417, Fig.11 Data interaction between modules Fig.12 The steps in correspondence one to one, therefore, the embodiment of the present application describes in detail Fig.12 Steps in Fig.11 The data flows involved can be found in Fig.12 .

[0176] S401. In response to the first trigger event, the application layer sends instruction 1 to the camera brightness manager in the sensor hardware abstraction layer through the sensor manager and sensor service in the framework layer and the sensor hardware abstraction layer interface in the sensor hardware abstraction layer. After receiving instruction 1, the camera brightness manager sends instruction 1 to the camera service in the framework layer through the first active interface in the camera brightness manager, the camera hardware access interface in the sensor hardware abstraction layer and the camera interface in the framework layer, and sends instruction 2 to the ambient light customization module in the camera hardware abstraction layer through the first active interface in the camera brightness manager.

[0177] It should be understood that the implementation process of S401 may refer to S306 and will not be described in detail here.

[0178] S402 . After receiving instruction 2 , the ambient light customization module registers callback function 1 through the callback function registration module and saves the CB1 object and process number 1 in the callback function database management module.

[0179] It should be understood that in response to the first trigger event, the application layer can send instruction 1 to the camera brightness manager in the sensor hardware abstraction layer through the sensor manager and sensor service in the framework layer and the sensor hardware abstraction layer interface in the sensor hardware abstraction layer. After receiving instruction 1, the camera brightness manager creates a process. This process is for the display brightness adjustment APP to call the front camera to obtain the ambient light brightness. For ease of description, this embodiment of the application refers to this process as the first process. In the first process, the callback function registered by the callback function registration module is called callback function 1. The CB1 object is used to indicate callback function 1, and process number 1 is the identifier of the first process. The first process of the embodiment of the present application includes S402 to S405, and S414 to S415.

[0180] S403: After receiving instruction 1, the camera service determines the priority of the called camera according to the camera identification through the camera identification management module.

[0181] It should be understood that the implementation process of S403 may refer to S308 and will not be described in detail here.

[0182] Exemplarily, the package name of the application program included in instruction 1 in the embodiment of the present application is application 4 in Table 1, the camera identifier corresponding to application 4 is CameraID4, and the priority corresponding to CameraID4 is low.

[0183] S404: The camera service notifies the ambient light customization module in the camera hardware abstraction layer to obtain the ambient light brightness value through the camera according to the priority of the called camera.

[0184] S405 . After receiving the notification, the ambient light customization module reads a brightness value of 1 through the brightness value reading and calculation module.

[0185] It should be understood that the implementation process of S405 is similar to the implementation process of S310, except that when S310 is executed, the electronic device has already responded to Figure 6 The user calibration operation shown is to calibrate the ambient light brightness, and the calibration coefficient has been pre-stored in the non-volatile memory, so S310 can directly read the brightness value 1 and the calibration coefficient, and when S405 is executed, the electronic device has not yet responded. Figure 6 The user calibration operation shown is to calibrate the ambient light brightness. The calibration coefficient is not stored in the non-volatile memory, so S405 can only read a brightness value of 1.

[0186] In the implementation, the implementation process of S405 reading brightness value 1 can refer to Fig.10 The brightness value reading and calculation module sends instruction 3 to the camera through the camera driver in the kernel layer. After the camera receives instruction 3, the brightness value is 1. The camera returns the brightness value 1 to the brightness value reading and calculation module in the ambient light customization module through the camera driver.

[0187] S406. During the process of the camera brightness manager executing the first process, the electronic device detects a second trigger event. In response to the second trigger event, the application layer sends instruction 5 to the camera brightness manager in the sensor hardware abstraction layer through the sensor manager and sensor service in the framework layer and the sensor hardware abstraction layer interface in the sensor hardware abstraction layer. After receiving instruction 5, the camera brightness manager sends instruction 5 to the camera service in the framework layer through the first active interface in the camera brightness manager, the camera hardware access interface in the sensor hardware abstraction layer and the camera interface in the framework layer, and sends instruction 6 to the ambient light customization module in the camera hardware abstraction layer through the first active interface in the camera brightness manager.

[0188] It should be understood that for ease of description, in the embodiment of the present application, in response to the second trigger event, the application layer sends an instruction to the camera brightness manager to obtain the ambient light brightness value as instruction 5, and after the camera brightness manager receives instruction 5, the instruction to register the callback function sent to the ambient light customization module is called instruction 6.

[0189] It should also be understood that the second trigger event in the embodiment of the present application may be a user executing Figure 6 The events triggered after the user calibration operation are shown. Fig.11 and Fig.12 The calibration APP in can be Figure 6 The “Calibration” application is shown in (a).

[0190] S407 . After receiving instruction 6 , the ambient light customization module registers callback function 2 through the callback function registration module and saves the CB2 object and process number 2 in the callback function database management module.

[0191] In response to the second trigger event, the application layer can send instruction 5 to the camera brightness manager in the sensor hardware abstraction layer through the sensor manager and sensor service in the framework layer and the sensor hardware abstraction layer interface in the sensor hardware abstraction layer. After receiving instruction 5, the camera brightness manager creates a process. The process is to calibrate the APP to call the front camera to obtain the ambient light brightness and determine the calibration coefficient according to the ambient light brightness. For ease of description, the embodiment of the present application refers to the process as the second process. In the second process, the callback function registered by the callback function registration module is called callback function 2. The CB2 object is used to indicate callback function 2, and process number 2 is the identifier of the second process. The second process of the embodiment of the present application includes S407 to S413.

[0192] S408. After receiving instruction 5, the camera service determines the priority of the called camera according to the camera identification through the camera identification management module.

[0193] In implementation, the priority of the called camera can be determined in a manner similar to S308, which will not be described in detail here.

[0194] refer to Fig.12 In an embodiment of the present application, in response to a first trigger event, when a display brightness adjustment APP calls the front camera, and in response to a second trigger event, when a calibration APP needs to call the front camera, the camera identification management module can determine the priority of the application calling the front camera according to the corresponding relationship shown in Table 1.

[0195] For example, assuming that the package name of the application is application 3 in Table 1, the camera identifier corresponding to application 3 is CameraID3, the priority corresponding to CameraID3 is medium, and the package name of the application is application 4 in Table 1, the camera identifier corresponding to application 4 is CameraID4, and the priority corresponding to CameraID4 is low, then the priority of application 3 calling the front camera is higher than the priority of application 4 calling the front camera. Therefore, application 3 can be used through the first process to first call the front camera to obtain the ambient light brightness, and application 4 can be used through the second process to call the front camera later to obtain the ambient light brightness. The brightness of the ambient light is obtained. That is to say, assuming that instruction 1 of S403 is sent by application 3 in Table 1, and instruction 5 in S408 is sent by application 4, then S404 and S405 can be executed first to make the brightness value reading and calculation module read the brightness value 1, and then execute steps similar to S312 and S313 to pass the brightness value 1 to application 3 in the application layer through the callback function, and then through S409 to S412, the brightness value reading and calculation module reads the brightness value 3, and passes the brightness value 3 to application 4 in the application layer through the callback function, so that both the first process and the second process can obtain the brightness of the ambient light.

[0196] Assuming that the package name of the application is Application 5 in Table 1, the camera ID corresponding to Application 5 is CameraID4, and the priority corresponding to CameraID4 is low, and the package name of the application is Application 4 in Table 1, the camera ID corresponding to Application 4 is CameraID4, and the priority corresponding to CameraID4 is low, then the priority of Application 5 calling the front camera is the same as the priority of Application 4 calling the front camera. Then, since the priority rule specified by the camera identification management module is: for applications with the same priority, the calling instruction of the application received later by the camera identification management module will interrupt the calling instruction of the application received earlier. It can be seen from S406 that the camera brightness manager receives instruction 1 first and then instruction 5. Then, The application 4 calls the front camera to obtain the ambient light brightness through the second process, and the first process is interrupted. That is to say, assuming that the instruction 1 of S403 is sent by the application 5 in Table 1, and the instruction 5 in S408 is sent by the application 4, then S409 to S412 can be executed to make the brightness value reading and calculation module read the brightness value 3, fill the brightness value 3 into the callback function, and pass the brightness value 3 to the application 4 in the application layer through the callback function. If the steps S404 and S405 are not executed, the brightness value reading and calculation module cannot read the brightness value 1. Since the brightness value reading and calculation module cannot read the brightness value 1, it is impossible to pass the brightness value 1 to the application layer through the callback function. In this way, the second process can obtain the ambient light brightness value, and the first process cannot obtain the ambient light brightness value.

[0197] S409: The camera service notifies the ambient light customization module in the camera hardware abstraction layer to obtain the ambient light brightness value through the camera according to the priority of the called camera.

[0198] It should be understood that in S409 , the ambient light customization module is notified that the ambient light brightness value obtained through the camera is a brightness value of 3.

[0199] S410 . After receiving the notification, the ambient light customization module reads a brightness value of 3 through the brightness value reading and calculation module.

[0200] In the implementation, the brightness value reading and calculation module sends an instruction to read the brightness value 3 to the camera through the camera driver in the kernel layer (for ease of description, the instruction is called instruction 7, for example, Fig.11 Instruction 7 in the figure is an instruction for reading brightness value 3), after receiving instruction 3, the camera reads the brightness value (the brightness value in this embodiment of the application is referred to as brightness value 3, for example, Fig.11 The brightness value 3 in the image is the brightness value read by the camera after receiving instruction 3), and the camera returns the brightness value 3 to the brightness value reading and calculation module in the ambient light customization module through the camera driver.

[0201] S411. The brightness value reading and calculation module transmits the brightness value 3 to the reporting ambient light status interface in the camera hardware manager in the sensor hardware abstraction layer through a callback function.

[0202] It should be understood that the brightness value reading and calculating module can fill the brightness value 3 into the callback function and pass the brightness value 3 through the callback function.

[0203] S412. After receiving the brightness value 3, the report ambient light status interface transmits the brightness value 3 to the calibration APP in the application layer through the sensor hardware abstraction layer interface in the sensor hardware abstraction layer, the sensor service in the framework layer, and the sensor manager in the framework layer.

[0204] S413 . After receiving the brightness value 3 , the calibration APP calculates the calibration coefficient according to the brightness value 3 and saves it in the non-volatile memory.

[0205] In the implementation, after the calibration APP receives the brightness value 3, it can Fig.11 The processor shown calculates the calibration coefficient according to the actual ambient light brightness and the brightness value 3. Exemplarily, the actual ambient light brightness is 10, the brightness value 3 is 8, and the ratio of the actual ambient light brightness value 10 to the brightness value 3 value 8, 1.25, is used as the calibration coefficient.

[0206] S414 , after receiving the calibration coefficient and the brightness value 1 , the brightness value reading and calculating module determines the brightness value 2 according to the calibration coefficient and the brightness value 1 .

[0207] In implementation, such as Fig.11 As shown, the brightness value reading and calculation module sends instruction 4 to the non-volatile memory through the non-volatile memory driver in the kernel layer, reads the calibration coefficient after receiving instruction 4, and the non-volatile memory returns the calibration coefficient to the brightness value reading and calculation module in the ambient light customization module through the non-volatile memory driver.

[0208] It should be understood that the brightness value 1 is the brightness value read by the brightness value reading and calculation module in the first process, and the calibration coefficient is the data calculated by S413 after the brightness value reading and calculation module reads the brightness value 3 in the second process. It can be seen from the above embodiments that when the display brightness adjustment APP calls the front camera and the calibration APP calls the front camera with the same priority, the first process is interrupted, and the second process is executed first to make the brightness value reading and calculation module read the brightness value 3. After the first process is interrupted, the first process cannot be executed to make the brightness value reading and calculation module read the brightness value 1, and the first process cannot be executed to pass the brightness value 1 to the application layer through the callback function. However, before the interruption, the brightness value 1 has been filled in the callback function, so that the first process and the second process cannot obtain the brightness value data at the same time.

[0209] From the above, it can be seen that when the display brightness adjustment APP calls the front camera and the calibration APP calls the front camera with the same priority, although the calibration APP can call the front camera and interrupts the display brightness adjustment APP calling the front camera, before the interruption, the brightness value 1 has been filled in the callback function 1 in the first process. Then, in order to enable the first process and the second process to obtain the brightness value data at the same time, the embodiment of the present application can broadcast the brightness value 1 filled in the callback function 1 corresponding to the CB1 object to the first process through the callback function database management module, and the first process can obtain the brightness value 1.

[0210] Since the callback function database management module broadcasts the brightness value 1 filled in the callback function 1 corresponding to the CB1 object to the first process, the brightness value reading and calculation module in the first process can receive the brightness value 1. After receiving the brightness value 1, the brightness value reading and calculation module determines the brightness value 2 according to the calibration coefficient returned by the non-volatile memory, and fills the brightness value 2 in the callback function 1 again. The implementation method of determining the brightness value 2 according to the brightness value 1 and the calibration coefficient can refer to the above embodiment, which will not be repeated here.

[0211] S415. The brightness value reading and calculation module transmits the brightness value 2 to the reporting ambient light status interface in the camera hardware manager in the sensor hardware abstraction layer through the callback function.

[0212] S416. After receiving the brightness value 2, the report ambient light status interface transmits the brightness value 2 to the display brightness adjustment APP in the application layer through the sensor hardware abstraction layer interface in the sensor hardware abstraction layer, the sensor service in the framework layer, and the sensor manager in the framework layer.

[0213] S417 . After receiving the brightness value 2 , the display brightness adjustment APP adjusts the display brightness according to the brightness value 2 .

[0214] In summary, during the process of the display brightness adjustment APP calling the front camera to obtain the brightness value (the running activity of the first process mentioned above), the calibration APP calls the front camera to obtain the brightness value to determine the calibration coefficient (the running activity of the second process mentioned above). Since the priority of the display brightness adjustment APP calling the front camera to obtain the brightness value is the same as the priority of the calibration APP calling the front camera to obtain the brightness value, but there is only one front camera and it cannot be called by two applications at the same time, the calibration APP can obtain the brightness value through the second process and interrupt the first process, so that the second process can obtain the brightness value, and the first process cannot obtain the brightness value, making the first process and the second process have no effect. The brightness value can be obtained simultaneously by the method that the brightness value has been filled in the callback function of the first process (for example, callback function 1) before the first process is interrupted, and the CB object of the callback function and the process number (for example, CB1 and process number 1) are saved in the callback function database management module. Then, the callback function database management module broadcasts the brightness value filled in the callback function 1 corresponding to the CB1 object to the first process. Specifically, the callback function database management module reads the brightness value 1 filled in the callback function 1 corresponding to the CB1 object broadcast by the calculation module, so that the first process can obtain the brightness value, ensuring that the first process and the second process can obtain the brightness value at the same time.

[0215] Furthermore, the embodiment of the present application can read the ambient light brightness through the first process and determine the calibration coefficient through the second process. The first process and the second process can obtain the ambient light brightness at the same time, thereby ensuring the real-time calibration and improving the calibration efficiency.

[0216] The above embodiments are combined Fig.11 and Fig.12 The internal implementation method in which the first process and the second process in the embodiment of the present application can simultaneously obtain the ambient light brightness is introduced. The following embodiments describe in detail the internal implementation process of how to ensure the system stability of the electronic device when an abnormality occurs in the first process or the second process.

[0217] Please refer to Fig.13 , Fig.13 It is a schematic flow chart of a method 500 for ensuring system stability of an electronic device provided in an embodiment of the present application.

[0218] S501. A death monitoring module monitors a first process and a second process, and sends a death notification to a callback function database management module when either the first process or the second process is in an abnormal state.

[0219] It should be understood that the death monitoring module can refer to Fig.14 The death monitoring module in the camera hardware abstraction layer shown in the figure is used to monitor whether the process is abnormal. Fig.14 It is a data flow diagram for ensuring the system stability of an electronic device provided in an embodiment of the present application.

[0220] In one case, for example Figure 8 In the example, only the first process obtains the brightness value. At this time, when the death monitoring module detects the process abnormality, since there is only one first process, the death monitoring module sends a death notification to the callback function database management module, and the death notification includes the process number of the first process. In another case, for example, Fig.11 and Fig.14 In the process, both the first process and the second process obtain brightness values. At this time, when the death monitoring module detects a process abnormality, since the death monitoring module is not sure whether it is the first process abnormality or the second process abnormality, the death notification sent by the death monitoring module to the callback function database management module does not include the process number.

[0221] In other embodiments, the process abnormality may also be expressed as a process error, a process crash, a process crash, etc., which is not limited in the embodiments of the present application.

[0222] S502: When the target process is in an abnormal state, the camera brightness manager calls the deregistration callback function interface through the second activity interface to send an instruction to deregister the callback function of the target process to the callback function database management module, wherein the instruction includes the process number of the target process.

[0223] It should be understood that the second activity interface and the deregistration callback interface can refer to Fig.14 The DeActive in the camera brightness manager and the deregistration callback function interface in the camera hardware abstraction layer are shown.

[0224] Exemplarily, the deregistration callback function interface may be:

[0225] void UnRegisterLuxCallback(in int pid, in vendor.XXX.hardware.camlight.ILuxCallback callback).

[0226] Among them, UnRegisterLuxCallback() is the function name of the unregister callback function, pid is the process number, and callback is the callback function.

[0227] It should also be understood that the target process can be the first process or the second process.

[0228] Assuming that the target process is the first process, when the first process is in an abnormal state, the camera brightness manager calls the deregistration callback function interface through the second activity interface to send an instruction to deregister the callback function of the first process to the callback function database management module. The instruction includes the process number of the first process, and the process number of the first process can be the process number 1 in the above embodiment.

[0229] Assuming that the target process is the second process, when the second process is in an abnormal state, the camera brightness manager calls the deregistration callback function interface through the second activity interface to send an instruction to the callback function database management module to deregister the callback function of the second process. The instruction includes the process number of the second process, and the process number of the second process can be the process number 2 in the above embodiment.

[0230] S503: The callback function database management module receives the death notification and the instruction to cancel the callback function of the target process, and determines that the target process is in an abnormal state.

[0231] It should be understood that when the electronic device executes the screen-off process, the camera brightness manager will also call the deregistration callback function interface through the second activity interface to send an instruction to the callback function database management module to deregister the callback function of the screen-off process. Therefore, when determining whether an abnormality occurs in the target process, the embodiment of the present application requires the callback function database management module to simultaneously receive the death notification sent through S501 and the instruction to deregister the callback function of the target process sent through S502. When the callback function database management module receives these two messages at the same time, it can be determined that the target process is in an abnormal state.

[0232] S504. When it is determined that the target process is in an abnormal state, the callback function database management module clears the CB object of the target process and prohibits the transmission of the brightness value to the report ambient light status interface in the camera hardware manager in the sensor hardware abstraction layer through the callback function corresponding to the CB object.

[0233] As can be seen from the above embodiments, the callback function database management module stores the process numbers of the first process and the second process, as well as the CB object of the callback function of the first process and the CB object of the callback function of the second process. Exemplarily, the data stored in the callback function database management module can refer to the following table:

[0234] Table 2

[0235] CB Object Process number CB1 Process number 1 CB2 Process number 2

[0236] For example, please refer to Fig.14 , assuming that the callback function database management module determines that the second process is in an abnormal state, then the callback function database management module clears the CB2 object corresponding to process number 2 from the above Table 2. After clearing the CB2 object, the brightness value reading and calculation module cannot pass the brightness value 3 to the report ambient light status interface in the camera hardware manager in the sensor hardware abstraction layer through the callback function 2 corresponding to the CB2 object, so the application layer cannot obtain the brightness value 3, and the first process is still in a normal state. The brightness value reading and calculation module can pass the brightness value 2 to the report ambient light status interface in the camera hardware manager in the sensor hardware abstraction layer through the callback function 1 corresponding to the CB1 object, and the application layer can also obtain the brightness value 2.

[0237] It should be understood that there are many reasons that may cause process exceptions, such as null pointer exception, stack overflow, array out of bounds, slow system response, etc. If the process is abnormal, the brightness value reading and calculation module in the camera hardware abstraction layer still passes the brightness value 2 to the report ambient light status interface in the camera hardware manager in the sensor hardware abstraction layer through the callback function, so that the application layer obtains the brightness value 2, which will affect the system stability of the electronic device.

[0238] In the embodiment of the present application, when determining that the target process is in an abnormal state, the callback function database management module is required to make a determination based on two data: the received death notification and the received instruction of the callback function for deregistering the target process. This can avoid the situation where the death monitoring module cannot accurately monitor which process among multiple processes is in an abnormal state, resulting in a monitoring error, and avoid the influence of other events (such as the screen of the electronic device turning off) on the determination that the target process is in an abnormal state, so that the target process can be accurately determined to be in an abnormal state, thereby improving the reliability of determining that the target process is in an abnormal state; and when it is determined that the target process is in an abnormal state, the callback function database management module clears the CB object of the target process, and prohibits the callback function corresponding to the CB object from passing the brightness value to the report ambient light status interface in the camera hardware manager in the sensor hardware abstraction layer, so as to prevent the callback function from still passing data when the target process is in an abnormal state, thereby ensuring the stability of the electronic device.

[0239] The above embodiments are combined Fig.13 and Fig.14 The internal implementation process of how to ensure the system stability of the electronic device when an abnormality occurs in the first process or the second process is described. The following embodiment summarizes the method for obtaining the ambient light brightness involved in the above embodiment.

[0240] The method for obtaining the ambient light brightness provided in the embodiment of the present application includes:

[0241] In response to the first trigger event, the application layer sends a first instruction to the camera brightness manager in the hardware abstraction layer through the framework layer, and the first instruction is used to instruct the electronic device to obtain a target brightness value; after receiving the first instruction, the camera brightness manager notifies the ambient light customization module in the hardware abstraction layer through the framework layer to call the front camera to obtain the target brightness value.

[0242] It should be understood that the first trigger event may be a user executing Figure 3 The user's boot operation, Figure 4 Restart operation in , or Figure 5 An event triggered by the operation of turning on automatic brightness adjustment, where the first trigger event is used to trigger the electronic device to read the brightness value through the front camera. Figure 8 , Fig. 9 , Fig.11 and Fig.12 The display brightness adjustment APP is a module that allows users to perform power-on operations, restart operations, or enable automatic brightness adjustment operations in the application layer.

[0243] It can also be understood that the first instruction can refer to Figure 8 Instruction 1 shows the target brightness value. Figure 8 The brightness value 2 shown, instruction 1 is used to instruct the electronic device to obtain the brightness value 2. Since the hardware problem of the electronic device may cause the ambient light brightness obtained by the front camera to be less than the actual ambient light brightness, the embodiment of the present application can calibrate the ambient light brightness obtained by the front camera to make the obtained brightness value close to the actual ambient light brightness. In the embodiment of the present application, the brightness value 2 refers to the brightness value after calibration that is close to the realized ambient light brightness. For the implementation method of calibrating the ambient light brightness obtained by the front camera, reference can be made to other embodiments, which will not be repeated here.

[0244] The first instruction sent by the application layer to the camera brightness manager in the hardware abstraction layer through the framework layer can be: Figure 8 , the display brightness adjustment APP in the application layer sends instruction 1 to the camera brightness manager in the sensor hardware abstraction layer through the sensor manager and sensor service in the framework layer and the sensor hardware abstraction layer interface in the sensor hardware abstraction layer.

[0245] After receiving the first instruction, the camera brightness manager notifies the ambient light customization module in the hardware abstraction layer through the framework layer to call the front camera to obtain the target brightness value. Please refer to Figure 8After receiving instruction 1, the camera brightness manager sends instruction 1 to the camera service in the framework layer through the first active interface in the camera brightness manager, the camera hardware access interface in the sensor hardware abstraction layer, and the camera interface in the framework layer. After receiving instruction 1, the camera service notifies the ambient light customization module in the camera hardware abstraction layer to call the camera to obtain the brightness value.

[0246] In the embodiment of the present application, the electronic device can obtain the target brightness value through the front camera, thereby reducing the cost of the electronic device increased by installing the ambient light detection device, and because no additional hole is required in the electronic device to install the ambient light detection device, the aesthetics of the electronic device is improved;

[0247] Furthermore, the electronic device can call the front camera through the ambient light customization module in the hardware abstraction layer to obtain the target brightness value, without having to call the camera through the camera customization module in the framework layer to obtain a frame of preview photo to obtain the ambient light brightness. Since the camera does not need to output the preview photo and perform a series of processing on the preview photo, the power consumption of the electronic device is reduced.

[0248] In some embodiments, the ambient light customization module includes a brightness value reading and calculation module. After receiving the first instruction, the camera brightness manager notifies the ambient light customization module in the hardware abstraction layer through the framework layer to call the front camera to obtain the target brightness value, including:

[0249] After receiving the first instruction, the camera brightness manager notifies the brightness value reading and calculation module through the framework layer to call the front camera to obtain the first brightness value; the brightness value reading and calculation module determines the target brightness value based on the first brightness value and the calibration coefficient.

[0250] It should be understood that the brightness value reading and calculation module can refer to Figure 8 , Fig.11 or Fig.13 The brightness value reading and calculation module shown is a module in the ambient light customization module (Camxlightcustom) in the camera customization module (Open Camera). The first brightness value can be referred to Figure 8 Brightness value 1 is shown.

[0251] In the implementation, the implementation method of obtaining the first brightness value is: For example, please refer to Figure 8 and Fig.10After receiving instruction 1, the camera brightness manager notifies the brightness value reading and calculation module through the framework layer to call the front camera to obtain the brightness value, wherein the brightness value reading and calculation module sends instruction 3 to the camera through the camera driver in the kernel layer. After receiving instruction 3, the camera reads the brightness value 1, and the camera returns the brightness value 1 to the brightness value reading and calculation module in the ambient light customization module through the camera driver.

[0252] It should be understood that the calibration coefficients are data pre-stored in the NVM, and the calibration coefficients stored in the NVM will not be easily lost.

[0253] In the implementation, the calibration coefficient is obtained as follows: For example, please refer to Figure 8 and Fig.10 The brightness value reading and calculation module sends instruction 4 to the non-volatile memory through the non-volatile memory driver in the kernel layer. After receiving instruction 4, the non-volatile memory reads the calibration coefficient. The non-volatile memory returns the calibration coefficient to the brightness value reading and calculation module in the ambient light customization module through the non-volatile memory driver.

[0254] In the implementation, the brightness reading and calculation module determines the target brightness value based on the first brightness value and the calibration coefficient as follows: For example, the actual ambient light brightness value is 10, the brightness value 1 obtained by the electronic device through the front camera is 8, and the calibration coefficient stored in the NVM is 1.25. The electronic device can multiply the brightness value 1 of 8 by the calibration coefficient 1.25, and the determined brightness value 2 is 10.

[0255] It should be understood that hardware problems of electronic devices may affect the accuracy of the ambient light brightness obtained by the front camera. For example, due to problems such as the camera lens transmittance and the display screen transmittance, the ambient light brightness obtained by the front camera may be lower than the actual ambient light brightness. In the embodiment of the present application, the electronic device can call the front camera to obtain the first brightness value according to the calibration coefficient of the brightness value reading and calculation module to calibrate the first brightness value, so that the first brightness value is close to the actual ambient light brightness, thereby improving the accuracy of the ambient light brightness obtained by the front camera.

[0256] In some embodiments, after notifying the brightness value reading and calculation module through the framework layer to call the front camera to obtain the first brightness value, the method further includes:

[0257] The brightness value reading and calculating module fills the first brightness value in the callback function.

[0258] It should be understood that the callback function is used to pass the brightness value obtained by the brightness value reading and calculation module to the sensor hardware abstraction layer, and the sensor hardware abstraction layer passes the brightness value to the application layer through the framework layer.

[0259] It should also be understood that the calibration coefficients in the above embodiments are pre-stored in the NVM, and the calibration coefficients in the embodiments of the present application can be calculated in real time. Therefore, before calculating the calibration coefficients, after the brightness value reading and calculation module calls the front camera to obtain the first brightness value, since the calibration coefficient has not been calculated, the brightness value reading and calculation module can fill in the first brightness value in the callback function, and the brightness value reading and calculation module passes the first brightness value to the sensor hardware abstraction layer through the callback function, and the sensor hardware abstraction layer passes the brightness value to the application layer through the framework layer. For example, please refer to Figure 8 The brightness value reading and calculation module passes the brightness value 1 to the report ambient light status interface in the camera hardware manager in the sensor hardware abstraction layer through the callback function. The report ambient light status interface passes the brightness value 1 to the application layer through the sensor hardware abstraction layer interface, sensor service and sensor manager.

[0260] In some embodiments, the brightness value reading and calculating module determines the target brightness value based on the first brightness value and the calibration coefficient, including:

[0261] In the process of notifying the brightness value reading and calculation module through the framework layer to call the front camera to obtain the first brightness value, and the brightness value reading and calculation module filling the first brightness value in the callback function, in response to the second trigger event, the application layer sends a second instruction to the camera brightness manager through the framework layer, and the second instruction is used to instruct the electronic device to determine the calibration coefficient based on the second brightness value; after receiving the second instruction, the camera brightness manager notifies the brightness value reading and calculation module through the framework layer to call the front camera to obtain the second brightness value, and determines the calibration coefficient based on the second brightness value; the camera brightness manager interrupts the brightness value reading and calculation module calling the front camera to obtain the first brightness value; the brightness value reading and calculation module obtains the first brightness value from the callback function; the ambient light customization module determines the target brightness value according to the first brightness value and the calibration coefficient.

[0262] The calibration coefficient in the embodiment of the present application is calculated in real time in response to the second trigger event.

[0263] It should be understood that the framework layer notifies the brightness value reading and calculation module to call the front camera to obtain the first brightness value, and the implementation process of the brightness value reading and calculation module filling the first brightness value in the callback function can refer to the above embodiment and will not be repeated here.

[0264] The second trigger event can be a user executing Figure 6 The events triggered after the user calibration operation are shown. Figure 8 , Fig. 9 , Fig.11 and Fig.12 The calibration APP in the application layer is an APP that users use to perform calibration operations in the application layer.

[0265] It should also be understood that the second instruction may refer to Fig.11 and Fig.12 In instruction 5, the second brightness value can be referred to Fig.11 and Fig.12 The second instruction is used to instruct the electronic device to obtain the brightness value 3 and determine the calibration coefficient based on the brightness value 3.

[0266] In implementation, the calibration coefficient can be determined based on the second brightness value as follows: For example, the actual ambient light brightness value is 10, the brightness value 3 is 8, and the ratio of the actual ambient light brightness value 10 to the brightness value 3 value 8, which is 1.25, is used as the calibration coefficient.

[0267] It can be understood that the application layer sends the second instruction to the camera brightness manager through the framework layer, and after the camera brightness manager receives the second instruction, it notifies the brightness value reading and calculation module through the framework layer to call the front camera to obtain the second brightness value. The implementation method can refer to the application layer sends the first instruction to the camera brightness manager through the framework layer, and after the camera brightness manager receives the first instruction, it notifies the brightness value reading and calculation module through the framework layer to call the front camera to obtain the first brightness value. It will not be repeated here.

[0268] It can also be understood that the brightness value reading and calculation module calls the front camera to obtain the first brightness value and the brightness value reading and calculation module calls the front camera to obtain the second brightness value both need to call the front camera, but there is only one front camera in the electronic device and it cannot be called at the same time, that is, when the brightness value reading and calculation module calls the front camera to obtain the second brightness value, the camera brightness manager interrupts the brightness value reading and calculation module calling the front camera to obtain the first brightness value, and the brightness value reading and calculation module can no longer call the front camera to obtain the first brightness value.

[0269] It can be seen from the above embodiments that when the calibration coefficient is calculated in real time, before the calibration coefficient is calculated, after the brightness value reading and calculation module calls the front camera to obtain the first brightness value, since the calibration coefficient has not been calculated yet, the brightness value reading and calculation module can fill in the first brightness value in the callback function. Therefore, after the camera brightness manager interrupts the brightness value reading and calculation module calling the front camera to obtain the first brightness value, the brightness value reading and calculation module can obtain the first brightness value from the callback function.

[0270] In the embodiment of the present application, since the brightness value reading and calculation module fills the first brightness value in the callback function before the interrupt processing, the brightness value reading and calculation module can obtain the first brightness value from the callback function, so that the brightness value reading and calculation module can obtain the first brightness value while calling the front camera to obtain the second brightness value (the second brightness value is used to determine the calibration coefficient);

[0271] It should also be understood that the solution of obtaining the ambient light brightness through the camera customization module in the framework layer usually requires first opening the front camera, determining the calibration coefficient based on the obtained ambient light brightness, and then obtaining the ambient light brightness by opening the front camera, and performing calibration based on the ambient light brightness and the calibration coefficient. It cannot guarantee that the camera customization module can obtain the ambient light brightness value at the same time, thus affecting the real-time performance and efficiency of the calibration. In the embodiment of the present application, since the brightness value reading and calculation module can obtain the first brightness value from the callback function, it can ensure that the brightness value reading and calculation module can obtain the first brightness value while calling the front camera to obtain the second brightness value, thereby ensuring the real-time performance and improving the calibration efficiency.

[0272] In some embodiments, the ambient light customization module includes a callback function database management module, the callback function database management module includes an object of the callback function, and the brightness value reading and calculation module obtains the first brightness value from the callback function, including:

[0273] The callback function database management module reads the first brightness value in the callback function corresponding to the object broadcasted by the calculation module from the brightness value; and the brightness value reading module obtains the first brightness value.

[0274] The callback function database management module can refer to Figure 8 and Fig.11 The callback function database management module shown belongs to the ambient light customization module in the camera hardware abstraction layer.

[0275] The callback function database management module is used to save CB objects and process numbers. For example, please refer to Figure 8 and Fig.11 After receiving instruction 1, the camera brightness manager creates the first process. The first process is to adjust the display brightness. The APP calls the front camera to obtain the ambient light brightness. In the first process, Figure 8The first active interface in sends instruction 2 to the ambient light customization module, and instruction 2 includes the process number of the first process (for example, the process number 1 mentioned above). After receiving instruction 2, the ambient light customization module registers the callback function through the callback function registration module and saves the CB object and the process number in the callback function database management module, and the CB object is used to indicate the registered callback function (for example, the callback function can be the callback function 1 mentioned above, and the CB object can be the CB1 object mentioned above).

[0276] In the implementation, the callback function database management module can broadcast the brightness value 1 in the callback function 1 corresponding to the CB1 object to the first process corresponding to the process number 1, so the first process can obtain the brightness value 1, and thus the brightness value reading and calculation module in the first process can obtain the brightness value 1.

[0277] In an embodiment of the present application, the ambient light customization module includes a callback function database management module. The callback function database management module can read the first brightness value in the callback function corresponding to the object of the callback function broadcast by the calculation module. The brightness value reading module can obtain the first brightness value, thereby ensuring that the brightness value reading module can obtain the first brightness value from the broadcast of the callback function database management module when the brightness value cannot be obtained through the front camera.

[0278] In some embodiments, after the camera brightness manager receives the first instruction, the priority of the brightness value reading and calculation module calling the front camera is equal to the priority of the brightness value reading and calculation module calling the front camera after the camera brightness manager receives the second instruction.

[0279] In layman's terms, in the embodiment of the present application, after the camera brightness manager receives the first instruction, the priority of the brightness value reading and calculation module calling the front camera is equal to the priority of the brightness value reading and calculation module calling the front camera after the camera brightness manager receives the second instruction: please refer to Fig.11 , the priority of the display brightness adjustment APP calling the front camera is the same as the priority of the brightness calibration APP calling the front camera.

[0280] It should be understood that the following rules need to be followed when an application calls the front camera: for applications of the same priority, the calling instructions of the application received after the camera identification management module will interrupt the calling instructions of the application received first. In the embodiment of the present application, a first instruction is issued at the application layer, and the brightness value reading and calculation module calls the front camera to obtain a first brightness value. During the process of the brightness value reading and calculation module filling the first brightness value in the callback function, the application layer issues a second instruction, and the brightness value reading and calculation module calls the front camera to obtain a second brightness value. Therefore, the brightness value reading and calculation module can be allowed to call the front camera to obtain the second brightness value, and the brightness value reading and calculation module is interrupted from calling the front camera to obtain the first brightness value.

[0281] Regarding the method of determining the priority of the application program calling the front camera, reference may be made to the above embodiment, which will not be described in detail here.

[0282] In some embodiments, the method further comprises:

[0283] When the ambient light customization module determines that the first process is in an abnormal state, it is prohibited to pass the target brightness value to the camera hardware manager through the callback function, and the first process includes the ambient light customization module calling the front camera to obtain the target brightness value; when the ambient light customization module determines that the second process is in an abnormal state, it is prohibited to pass the second brightness value to the camera hardware manager through the callback function, and the second process includes the brightness value reading and calculation module calling the front camera to obtain the second brightness value.

[0284] It should be understood that the first process refers to the process created after the camera brightness manager receives instruction 1. The second process refers to the process created after the camera brightness manager receives instruction 5. For the second process and the content contained in the second process, please refer to the above embodiment, which will not be repeated here.

[0285] There are many reasons that lead to process exceptions, such as null pointer exception, stack overflow, array out of bounds, slow system response, etc. If the process is abnormal, the brightness value reading and calculation module in the camera hardware abstraction layer still passes the brightness value to the report ambient light status interface in the camera hardware manager in the sensor hardware abstraction layer through the callback function, so that the application layer can obtain the brightness value, which will affect the system stability of the electronic device. Therefore, in the embodiment of the present application, when the first process is in an abnormal state, it is prohibited to pass the target brightness value to the camera hardware manager through the callback function, and when the second process is in an abnormal state, it is prohibited to pass the second brightness value to the camera hardware manager through the callback function.

[0286] In other embodiments, the process abnormality may also be expressed as a process error, a process crash, a process crash, etc., which is not limited in the embodiments of the present application.

[0287] In an embodiment of the present application, when the ambient light customization module determines that the first process or the second process is in an abnormal state, the target brightness value or the second brightness value may be prohibited from being passed to the camera hardware manager through the callback function, thereby preventing the callback function from still passing data when the first process or the second process is in an abnormal state, thereby ensuring the stability of the electronic device.

[0288] In some embodiments, the ambient light customization module includes a death monitoring module, and the method further includes:

[0289] The death monitoring module monitors the first process and the second process, and when either of the first process and the second process is in an abnormal state, sends a death notification to the callback function database management module; when the callback function database management module receives the death notification and the instruction sent by the camera brightness manager to cancel the callback function of the first process, it is determined that the first process is in an abnormal state; when the callback function database management module receives the death notification and the instruction sent by the camera brightness manager to cancel the callback function of the second process, it is determined that the second process is in an abnormal state.

[0290] It should be understood that the death monitoring module can refer to Fig.14 The death monitoring module in the , the death monitoring module belongs to the ambient light customization module, the death monitoring module is used to monitor whether the process is abnormal. In one case, for example Figure 8 In the example, only the first process obtains the brightness value. At this time, when the death monitoring module detects the process abnormality, since there is only one first process, the death monitoring module sends a death notification to the callback function database management module, and the death notification includes the process number of the first process. In another case, for example, Fig.11 and Fig.14 In the process, both the first process and the second process obtain brightness values. At this time, when the death monitoring module detects a process abnormality, since the death monitoring module is not sure whether it is the first process abnormality or the second process abnormality, the death notification sent by the death monitoring module to the callback function database management module does not include the process number.

[0291] In the implementation, the callback function instruction of the deregistration process sent by the camera brightness manager can be the camera brightness manager through Fig.14 The second activity interface call in Fig.14 The deregistration callback function interface in sends the callback function instruction of the deregistration process to the callback function database management module. Assuming that the first process is abnormal, the camera brightness manager can send the callback function instruction of the deregistration first process. Assuming that the second process is abnormal, the camera brightness manager can send the callback function instruction of the deregistration second process.

[0292] It should also be understood that when the electronic device executes the screen-off process, the camera brightness manager will also call the deregistration callback function interface through the second activity interface to send an instruction to deregister the callback function of the screen-off process to the callback function database management module. Therefore, when determining whether an abnormality occurs in the first process or the second process, the embodiment of the present application requires the callback function database management module to simultaneously receive the death notification and the instruction to deregister the callback function of the first process or the second process. When the callback function database management module receives these two messages at the same time, it can be determined that the first process or the second process is in an abnormal state.

[0293] In the embodiment of the present application, when determining that the first process or the second process is in an abnormal state, the callback function database management module is required to make a determination based on two data: a received death notification and a received instruction to cancel the callback function of the first process or the second process. This can avoid the situation where the death monitoring module cannot accurately monitor which process among multiple processes is in an abnormal state, resulting in monitoring errors, and avoid the influence of other events (such as the screen of an electronic device turning off) on the determination that the first process or the second process is in an abnormal state. This can accurately determine that the first process or the second process is in an abnormal state, thereby improving the reliability of determining that the first process or the second process is in an abnormal state.

[0294] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0295] It should also be understood that, during the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software. The steps of the method disclosed in conjunction with the embodiment of the present application can be directly embodied as a hardware processor executing the completion, or a combination of hardware and software units in the processor executing the completion. The software unit can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor executes the instructions in the memory, and completes the steps of the above method in conjunction with its hardware. To avoid repetition, it is not described in detail here.

[0296] The embodiment of the present application provides a computer program product, when the computer program product is run on an electronic device, the electronic device executes the technical solution in the above embodiment. Its implementation principle and technical effect are similar to those of the above method-related embodiments, and will not be repeated here.

[0297] The embodiment of the present application provides a readable storage medium, which contains instructions. When the instructions are executed in an electronic device, the electronic device executes the technical solution of the above embodiment. The implementation principle and technical effect are similar and will not be repeated here.

[0298] The embodiment of the present application provides a chip, which is used to execute instructions. When the chip is running, the technical solution in the above embodiment is executed. The implementation principle and technical effect are similar and will not be repeated here.

[0299] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loading and executing computer instructions on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, data center, etc. that contains one or more available media integrated. Available media may be magnetic media (eg, floppy disks, hard disks, tapes), optical media (eg, high-density digital video discs (DVD)), or semiconductor media (eg, solid state disks (SSD)).

[0300] It should be understood that the "embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, the various embodiments in the entire specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.

[0301] In this application, elements expressed in the singular are intended to mean "one or more" rather than "one and only one", unless otherwise specified. In this application, "at least one" is intended to mean "one or more", and "more than one" is intended to mean "two or more", unless otherwise specified.

[0302] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. A can be singular or plural, and B can be singular or plural.

[0303] In this document, the term "at least one of..." or "at least one of..." means all or any combination of the listed items. For example, "at least one of A, B, and C" may mean: A exists alone, B exists alone, C exists alone, A and B exist at the same time, B and C exist at the same time, and A, B, and C exist at the same time, where A may be singular or plural, B may be singular or plural, and C may be singular or plural.

[0304] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0305] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0306] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0307] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0308] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0309] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program codes.

[0310] The same or similar parts between the various embodiments in this application can refer to each other. In the various embodiments in this application, and the various implementation methods / implementation methods / implementation methods in each embodiment, if there is no special explanation and logical conflict, the terms and / or descriptions between different embodiments and the various implementation methods / implementation methods / implementation methods in each embodiment are consistent and can be referenced to each other. The technical features in different embodiments and the various implementation methods / implementation methods / implementation methods in each embodiment can be combined to form new embodiments, implementation methods, implementation methods, or implementation methods according to their inherent logical relationships. The above implementation methods of this application do not constitute a limitation on the scope of protection of this application.

[0311] The above are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims. In short, the above are only preferred embodiments of the technical solution of the present application, and are not used to limit the protection scope of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A method for obtaining ambient light brightness, applied to an electronic device, wherein the electronic device comprises an application layer, a framework layer and a hardware abstraction layer, wherein: The hardware abstraction layer includes a camera brightness manager and an ambient light customization module, and the ambient light customization module includes a brightness value reading and calculation module. The method includes: In response to a first trigger event, the application layer sends a first instruction to the camera brightness manager in the hardware abstraction layer through the framework layer, where the first instruction is used to instruct the electronic device to obtain a target brightness value; After receiving the first instruction, the camera brightness manager notifies the brightness value reading and calculation module in the ambient light customization module through the framework layer to call the front camera to obtain a first brightness value; The brightness value reading and calculating module determines the target brightness value based on the first brightness value and a calibration coefficient.

2. The method according to claim 1, characterized in that The ambient light customization module includes a callback function. After notifying the brightness value reading and calculation module in the ambient light customization module through the framework layer to call the front camera to obtain the first brightness value, the method further includes: The brightness value reading and calculating module fills the first brightness value in the callback function.

3. The method according to claim 2, characterized in that The brightness value reading and calculating module determines the target brightness value based on the first brightness value and the calibration coefficient, including: In the process of notifying the brightness value reading and calculating module through the framework layer to call the front camera to obtain the first brightness value, and the brightness value reading and calculating module filling the first brightness value in the callback function, in response to a second trigger event, the application layer sends a second instruction to the camera brightness manager through the framework layer, and the second instruction is used to instruct the electronic device to determine the calibration coefficient based on the second brightness value; After receiving the second instruction, the camera brightness manager notifies the brightness value reading and calculation module through the framework layer to call the front camera to obtain the second brightness value, and determines the calibration coefficient based on the second brightness value; The camera brightness manager performs interrupt processing on the brightness value reading and calculation module calling the front camera to obtain the first brightness value; The brightness value reading and calculating module obtains the first brightness value from the callback function; The ambient light customization module determines the target brightness value according to the first brightness value and the calibration coefficient.

4. The method according to claim 3, characterized in that The ambient light customization module includes a callback function database management module, the callback function database management module includes the object of the callback function, and the brightness value reading and calculation module obtains the first brightness value from the callback function, including: The callback function database management module reads the first brightness value in the callback function corresponding to the object broadcasted by the calculation module to the callback function from the brightness value; The brightness value reading module obtains the first brightness value.

5. The method according to claim 3, characterized in that: After the camera brightness manager receives the first instruction, the priority of the brightness value reading and calculating module calling the front camera is equal to the priority of the brightness value reading and calculating module calling the front camera after the camera brightness manager receives the second instruction.

6. The method according to any one of claims 3 to 5, characterized in that The method further comprises: When the ambient light customization module determines that the first process is in an abnormal state, prohibiting the target brightness value from being transmitted to the camera hardware manager through the callback function, the first process including the ambient light customization module calling the front camera to obtain the target brightness value; When the ambient light customization module determines that the second process is in an abnormal state, it is prohibited to pass the second brightness value to the camera hardware manager through the callback function, and the second process includes the brightness value reading and calculation module calling the front camera to obtain the second brightness value.

7. The method according to claim 6, characterized in that The ambient light customization module includes a death monitoring module, and the method further includes: The death monitoring module monitors the first process and the second process, and sends a death notification to the callback function database management module when either the first process or the second process is in an abnormal state; When the callback function database management module receives the death notification and the instruction of canceling the callback function of the first process sent by the camera brightness manager, determining that the first process is in an abnormal state; When the callback function database management module receives the death notification and the instruction sent by the camera brightness manager to cancel the callback function of the second process, it is determined that the second process is in an abnormal state.

8. An electronic device, characterized in that: include: one or more processors; one or more memories; The one or more memories store one or more computer programs, and the one or more computer programs include instructions. When the instructions are executed by the one or more processors, the electronic device performs the method as claimed in any one of claims 1 to 7.

9. A computer-readable storage medium, characterized in that: The method comprises computer instructions, which, when executed on an electronic device, cause the electronic device to execute the method as claimed in any one of claims 1 to 7.

10. A chip, characterized in that: The chip comprises: A memory for storing instructions; A processor, configured to call and execute the instructions from the memory, so that an electronic device equipped with the chip executes the method as claimed in any one of claims 1 to 7.