Method for adjusting screen brightness and electronic equipment
By managing the working mode and priority of the camera in the hardware abstraction layer, the bright flash jump problem caused by untimely ambient light detection is solved, and the accuracy of screen brightness and user experience are improved.
Patent Information
- Application Number
- CN202410311491.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-14
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2044-03-14
AI Technical Summary
When using the camera to detect ambient light, the screen brightness is not suitable when the ambient light changes and then lights up, resulting in a brightness and jump, affecting the user's visual experience.
By separately managing the working mode and priority of the target camera in the hardware abstraction layer, we ensure that the ambient light parameters are reported in a timely manner, avoid the use of the brightness value of the last screen light, and adopt a low frame rate acquisition strategy after high frame rate to take into account the timeliness of data reporting. and power consumption.
Ensure the accuracy of screen brightness, avoid the phenomenon of bright flashing and jumping, improve the user's visual experience, and save resources, solving the problem of untimely reporting of ambient light parameters in traditional solutions.
Smart Images

Figure CN119252209A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic equipment, and in particular to a method for adjusting screen brightness and an electronic equipment. Background Art
[0002] Currently, mobile phones, tablet computers and other electronic devices are equipped with ambient light devices to detect ambient light and automatically adjust the screen brightness according to the detection of ambient light. With the development of technology, cameras with the function of detecting ambient light have emerged. Therefore, by allowing cameras with photosensitivity to detect ambient light, independent ambient light devices can be removed and the overall circuit layout of electronic devices can be optimized.
[0003] However, this has brought new problems. In actual use, it was found that when the camera was used for ambient light detection, the screen would flicker when the environment changed brightness. That is, the initial brightness of the screen after it was turned on again was not suitable for the brightness of the actual environment of the electronic device, resulting in a poor visual experience for the user. Summary of the invention
[0004] The present application provides a method and electronic device for adjusting screen brightness, which can ensure that ambient light parameters are reported in a timely manner after the screen is turned on, thereby ensuring the accuracy of the initial brightness of the screen after the screen is turned on again, and avoiding flashing and jumping of the screen that affects the user's visual experience.
[0005] In a first aspect, a method for adjusting screen brightness is provided, the method comprising: in a screen-off state, obtaining a first screen-on operation; in response to the first screen-on operation, obtaining a camera identifier in a hardware abstraction layer of a software system of an electronic device, the camera identifier being used to indicate a target camera corresponding to an ambient light detection function; in the hardware abstraction layer, determining a target operating mode of a target camera according to a preset priority, the operating modes of the target camera including a camera mode and an ambient light mode; when the target operating mode is determined to be an ambient light mode, starting the target camera through the hardware abstraction layer, and enabling the target camera to collect ambient light parameters in the ambient light mode, and adjusting the screen brightness according to the collected ambient light parameters.
[0006] In the technical solution of the present application, the conflict and priority management of the working mode of the target camera is mainly completed by calling the corresponding interface in the hardware abstraction layer, and the target working mode of the target camera is determined, so that there is no need to execute this process with the unified management of all cameras in the framework layer, which saves the execution time and ensures the timely reporting of the ambient light parameters of the target camera, avoiding the problem of determining the brightness value of the last screen-on operation before the screen-on operation as the target brightness for screen-on operation due to untimely reporting, but not matching the actual environment.
[0007] In the traditional solution of using cameras to collect ambient light, the working mode of the target camera needs to be determined at the framework layer along with the conflict and priority management of all cameras, which results in a long waiting time and causes the first frame ambient light parameters to be reported untimely. The electronic device can only assign the brightness value according to the last time the screen was turned on, but it does not match the actual environment, resulting in bright flashes. When the technical solution of this application is adopted, since the working mode of the target camera is determined separately at the hardware abstraction layer, the waiting time is shortened, so that the first frame ambient light parameters can be reported in time.
[0008] In combination with the first aspect, in certain implementations of the first aspect, the preset priority is used to indicate that the priority of the camera mode of the target camera is higher than the priority of the ambient light mode of the target camera. At the hardware abstraction layer, when the target working mode of the target camera is determined according to the preset priority, it may include: when the target camera is working in the camera mode, determining the target working mode is the camera mode; or when the target camera is not working in the camera mode, determining the target working mode is the ambient light mode. That is to say, the target camera is used to perform ambient light detection under the premise of ensuring that the basic shooting function of the target camera is not affected.
[0009] In combination with the first aspect, in certain implementations of the first aspect, when the hardware abstraction layer of the software system of the electronic device obtains the camera identification, it can include: in the sensor control module of the hardware abstraction layer, calling the function of opening the camera through the AIDL interface, and sending the camera identification to the camera control module of the hardware abstraction layer; in the hardware abstraction layer, determining the target working mode of the target camera according to the preset priority, including: performing conflict and priority management in the camera control module, so as to determine the target working mode according to the preset priority. In this implementation, an example of how to determine the target working mode is given, which is completed by calling the appropriate interface through the cooperation of the sensor control module and the camera control module.
[0010] In combination with the first aspect, in certain implementations of the first aspect, when the target camera collects ambient light parameters in the ambient light mode, the method further includes: using the target camera to collect ambient light parameters N times at a first frame rate, where N is an integer greater than 1; after collecting the ambient light parameters N times, using the target camera to continuously collect ambient light parameters at a second frame rate, where the second frame rate is less than the first frame rate. In this implementation, the data reporting cycle is shortened mainly by reporting the first N frames of data at a higher frame rate, so that the target camera can report the ambient light parameters more quickly, thereby ensuring that the first frame of ambient light data is reported in time, avoiding the use of the last brightness value of the screen due to untimely reporting, and thus avoiding bright flash jumps. A high frame rate will lead to high power consumption, but a low frame rate will easily lead to untimely reporting of the first frame of ambient light parameters, so this solution adopts a high frame rate in the early stage and a low frame rate in the later stage, taking into account both low power consumption and timely reporting.
[0011] In combination with the first aspect, in certain implementations of the first aspect, when the first screen-on operation is a face wake-up operation, at the hardware abstraction layer, determining the target operating mode of the target camera according to a preset priority may include: determining the target operating mode as an ambient light mode, and changing the target operating mode to a camera mode after receiving the first frame ambient light parameters. In this implementation, when a conflict occurs between the screen-on task and face recognition (face wake-up, that is, face unlocking the screen), the target camera is first operated in the ambient light mode, and after obtaining the first frame ambient light parameters, the target camera is then operated in the camera mode, thereby ensuring that the first frame ambient light parameters are reported in a timely manner, avoiding flashing and jumping, and can also return in time to continue to perform the face recognition task.
[0012] In the traditional solution, since the camera mode has a higher priority than the ambient light mode, face unlocking is prioritized after the face wake-up operation occurs, releasing the resources for ambient light detection. Ambient light detection is not performed until the face unlocking is completed, resulting in the first frame ambient light parameters not being reported in time and bright flashes.
[0013] In combination with the first aspect, in certain implementations of the first aspect, during the period of collecting ambient light parameters using the target camera, the above method also includes: creating a first thread to periodically read the ambient light parameters, and marking the first flag as not stopped each time the first thread is awakened, the first flag is used to indicate whether the periodically read thread is stopped; when the first screen-off operation is obtained, in response to the first screen-off operation, the first flag is marked as stopped, and the first thread is stopped. In this implementation, the stopping method of the first thread is modified from the traditional solution of stopping when the next wake-up cycle arrives because the first flag is marked as stopped, to stopping directly when the screen-off operation occurs. This solution solves the problem of idle threads that occur when the screen is frequently turned on and off with the simplest change in the execution opportunity. Due to this stopping method in the traditional solution, if a second screen-on operation occurs after the screen-off operation during the dormancy period of the first thread, the second screen-on operation will cause the first flag to be modified to not stop again, and the second thread will be started to read data. Then, after the dormancy period ends, the first flag read is not stopped, resulting in the first thread and the second thread both reading data, but the data read by the first thread is useless, which is equivalent to running the thread in vain and wasting resources. In short, for frequent screen-on and screen-off scenarios, the first thread cannot be stopped according to the traditional solution, and multiple threads periodically read data, and the first thread runs in vain and wastes resources. However, the solution of the present application will stop the first thread immediately after the screen-off operation occurs, so the first thread will not be unable to stop.
[0014] In combination with the first aspect, in certain implementations of the first aspect, when a first screen-off operation is obtained, in response to the first screen-off operation, the first flag is marked as stopped, and the first thread is stopped, which may include: when the first screen-off operation is obtained during the wake-up period of the first thread, the first thread is stopped directly; or when the first screen-off operation is obtained during the sleep period of the first thread, the first thread is first awakened and then stopped. In this implementation, when the screen-off operation is obtained during the wake-up period of the first thread, the thread is stopped directly, and when the screen-off operation is obtained during the sleep period, the thread is first awakened and then stopped.
[0015] In a second aspect, another method for adjusting screen brightness is provided, the method comprising: in a screen-off state, obtaining a first screen-on operation; in response to the first screen-on operation, obtaining a camera identifier in a hardware abstraction layer of a software system of the electronic device, the camera identifier being used to indicate a target camera corresponding to an ambient light detection function; in the hardware abstraction layer, determining a target operating mode of the target camera according to a preset priority, the operating modes of the target camera including a camera mode and an ambient light mode; when the target operating mode is determined to be an ambient light mode, starting the target camera through the hardware abstraction layer; using the target camera to collect ambient light parameters N times at a first frame rate, where N is an integer greater than 1, and adjusting the screen brightness according to the collected ambient light parameters; after collecting the ambient light parameters N times, using the target camera to continuously collect the ambient light parameters at a second frame rate, where the second frame rate is less than the first frame rate, and adjusting the screen brightness according to the collected ambient light parameters.
[0016] In the technical solution of this application, the data reporting cycle is shortened by reporting the first N frames of data at a higher frame rate, so that the target camera can report the ambient light parameters more quickly, thereby ensuring that the first frame of ambient light data is reported in time, avoiding the use of the last brightness value of the screen due to untimely reporting, and thus avoiding bright flash jumps. A high frame rate will lead to high power consumption, but a low frame rate will easily lead to untimely reporting of the first frame of ambient light parameters, so this solution adopts a high frame rate in the early stage and a low frame rate in the later stage, taking into account both low power consumption and timely reporting.
[0017] According to a third aspect, another method for adjusting screen brightness is provided, the method comprising: in a screen-off state, obtaining a first screen-on operation, the first screen-on operation being a face wake-up operation; in response to the first screen-on operation, obtaining a camera identifier in a hardware abstraction layer of a software system of the electronic device, the camera identifier being used to indicate a target camera corresponding to an ambient light detection function; in the hardware abstraction layer, determining a target operating mode of the target camera as an ambient light mode; starting the target camera through the hardware abstraction layer and enabling the target camera to collect ambient light parameters in the ambient light mode, and adjusting the screen brightness according to the collected ambient light parameters; upon receiving the first frame of ambient light parameters reported by the target camera, updating the target operating mode of the target camera to a camera mode in the hardware abstraction layer; starting the target camera through the hardware abstraction layer and enabling the target camera to collect face images in the camera mode.
[0018] In the technical solution of the present application, when there is a conflict between the screen lighting task and face recognition (face wake-up, that is, face unlocking the screen), the target camera is first operated in ambient light mode, and after obtaining the first frame ambient light parameters, the target camera is operated in camera mode, thereby ensuring that the first frame ambient light parameters are reported in time to avoid bright flashes and jumps. In addition, it can return in time to continue the face recognition task.
[0019] In the traditional solution, since the camera mode has a higher priority than the ambient light mode, face unlocking is prioritized after the face wake-up operation occurs, releasing the resources for ambient light detection. Ambient light detection is not performed until the face unlocking is completed, resulting in the first frame ambient light parameters not being reported in time and bright flashes.
[0020] In a fourth aspect, another method for adjusting screen brightness is provided, the method comprising: in a screen-off state, obtaining a first screen-on operation; in response to the first screen-on operation, obtaining a camera identifier in a hardware abstraction layer of a software system of an electronic device, the camera identifier being used to indicate a target camera corresponding to an ambient light detection function; in the hardware abstraction layer, determining a target operating mode of the target camera according to a preset priority, the operating mode of the target camera including a camera mode and an ambient light mode; when the target operating mode is determined to be an ambient light mode, starting the target camera through the hardware abstraction layer, and enabling the target camera to collect ambient light parameters in the ambient light mode, and adjusting the screen brightness according to the collected ambient light parameters; during the period of collecting ambient light parameters using the target camera, creating a first thread for periodic reading of the ambient light parameters, and marking a first identifier as not stopping each time the first thread is awakened, the first identifier being used to indicate whether the periodically read thread is stopped; when the first screen-off operation is obtained, in response to the first screen-off operation, marking the first identifier as stopped, and stopping the first thread.
[0021] In the technical solution of the present application, the main method of stopping the first thread is to change the stop mode of the first thread from the traditional solution that stops when the next wake-up cycle arrives because the first flag is marked as stopped, to directly stop when the screen-off operation occurs. This solution uses the simplest change in the execution opportunity to solve the problem of idle running threads when the screen is frequently turned on and off. Due to such a stop method in the traditional solution, if a second screen-on operation occurs after the screen-off operation during the dormancy period of the first thread, the second screen-on operation will cause the first flag to be modified to not stop again, and the second thread will be started to read data. Then, after the dormancy cycle ends, the first flag read is not stopped, resulting in the first thread and the second thread both reading data thereafter, but the data read by the first thread is useless, which is equivalent to an idle running thread, wasting resources. In short, for the frequent screen-on and screen-off scenarios, the first thread cannot be stopped according to the traditional solution, and multiple threads periodically read data, and the first thread runs idle and wastes resources. However, the solution of the present application will stop the first thread immediately after the screen-off operation occurs, so the first thread will not be unable to stop.
[0022] In combination with the fourth aspect, in certain implementations of the fourth aspect, when a first screen-off operation is obtained, in response to the first screen-off operation, the first flag is marked as stopped, and the first thread is stopped, including: when the first screen-off operation is obtained during the wake-up period of the first thread, the first thread is stopped directly; or when the first screen-off operation is obtained during the sleep period of the first thread, the first thread is first awakened and then stopped. In this implementation, when the screen-off operation is obtained during the wake-up period of the first thread, the thread is stopped directly, and when it is obtained during the sleep period, the thread is awakened first and then stopped.
[0023] In a fifth aspect, a device for adjusting screen brightness is provided, the device comprising a unit composed of software and / or hardware for executing any one of the methods in the first to fourth aspects.
[0024] In the sixth aspect, an electronic device is provided, comprising a memory, one or more processors, and a computer program stored in the memory and executable on the processors, wherein when the one or more processors execute the computer program, the electronic device is enabled to implement any one of the methods in the first to fourth aspects.
[0025] In the seventh aspect, a chip is provided, comprising a processor, wherein the processor is used to read and execute a computer program stored in a memory, and when the computer program is executed by the processor, the electronic device where the chip is located can implement any one of the methods in the first to fourth aspects.
[0026] Optionally, the chip also includes a memory, and the memory is electrically connected to the processor.
[0027] Optionally, the chip may also include a communication interface.
[0028] In an eighth aspect, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by an electronic device, any one of the methods in the first to fourth aspects can be implemented.
[0029] In a ninth aspect, a computer program product is provided, which includes a computer program, and when the computer program is executed by an electronic device, it can implement any one of the methods in the first to fourth aspects. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 It is a schematic diagram of the change in screen brightness value after the screen is turned on again after the environment changes.
[0031] Figure 2 It is a schematic diagram of a traditional execution framework for ambient light detection using a camera.
[0032] Figure 3It is a schematic diagram of an execution process of adjusting screen brightness according to an embodiment of the present application.
[0033] Figure 4 It is a schematic flowchart of a method for adjusting screen brightness in an embodiment of the present application.
[0034] Figure 5 It is a schematic flowchart of another method for adjusting screen brightness according to an embodiment of the present application.
[0035] Figure 6 The diagram is a schematic diagram of the execution process of periodically reading ambient light parameters in a traditional solution.
[0036] Figure 7 It is a schematic diagram of an execution process of periodically reading ambient light parameters according to an embodiment of the present application.
[0037] Figure 8 This is a schematic diagram of the conflict between the face recognition task and the ambient light detection task.
[0038] Fig. 9 It is a schematic diagram of an execution process of obtaining ambient light parameters according to an embodiment of the present application.
[0039] Fig.10 This is a schematic diagram of threads running idle due to frequent screen on and off.
[0040] Fig.11 It is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0041] The scheme of the embodiment of the present application is introduced below with reference to the accompanying drawings.
[0042] Figure 1 It is a schematic diagram of the change in screen brightness value after the screen is turned on again after the environment changes. Figure 1 For example, a user originally used an electronic device outdoors in the sun, then turned off the screen of the electronic device, walked into a dark room, and then turned on the screen of the electronic device again. Figure 1 As shown in (a), the user uses an electronic device outdoors in the sun, and the brightness of the screen of the electronic device is 90%. After the electronic device performs the screen-off operation, the screen of the electronic device is black, as shown in FIG. Figure 1 As shown in (b) in the figure. The screen-off operation can be executed in response to the user pressing the screen-off mechanical button, or it can be executed based on the fact that the electronic device has not been operated within a preset time in the automatic screen-off, or it can be executed based on the user's operation on the lock screen touch control. There is no limitation. Then suppose the user walks into the room, here we take walking into a dark room as an example. After entering the dark room, the electronic device is initially in a black screen state as shown in the figure. Figure 1As shown in (c) in the figure. Assume that the user performs a screen-on operation at this time, for example, the user may press a screen-on mechanical button, or may perform a face unlock operation, etc., without limitation. When the screen-on operation is triggered, the electronic device turns on the screen, such as Figure 1 However, the screen brightness is 90% when the screen is on, and then the brightness is updated to 30% as the ambient light detection continues. Figure 1 As shown in (e).
[0043] In a dark room, the most comfortable brightness for using electronic devices is 30%. However, after the screen is turned on again, it becomes very bright first and then returns to normal brightness, that is, the brightness flashes and jumps, causing users to feel dazzling at the moment the screen is turned on, affecting their visual experience.
[0044] Figure 1 The electronic device can be a portable electronic device such as a mobile phone or a tablet computer that can automatically adjust the screen brightness.
[0045] against Figure 1 After analysis, it was found that the electronic device used a camera to detect ambient light, and the reason for the flashing was that when the screen was turned on again, it was not the actual ambient light parameters that were used, but the brightness value when the screen was turned on for the last time. Figure 1 The ambient light parameter used in (d) is Figure 1 (a) The brightness value when the screen was last turned on before the screen-off operation was executed, resulting in the brightness value being too high relative to that in a dark room. Further analysis of why the actual ambient light parameters were not used to adjust the screen brightness revealed that this was because the data of the ambient light detection was not reported in time after the screen was turned on again, resulting in the electronic device directly using the brightness value of the last time the screen was turned on before the black screen was turned on to turn on the screen. Further analysis of why the reporting was not timely revealed that this was because the electronic device used a camera for ambient light detection, and the camera needed to perform some preparatory work before being able to perform ambient light detection, especially the relevant modules in each structural layer of the software system of the electronic device needed to be prepared, and if the delay of the preparation work was long, the ambient light parameters could not be reported in time after the screen-on operation occurred. For traditional independent ambient light detection devices, there is no need for so many modules to cooperate, and the time required for the preparation work is very short, so there will be no situation where it cannot be reported in time, so it is not within the scope of this application.
[0046] In the current solution of using the camera to detect ambient light, there is a problem of untimely data reporting, which results in the screen only being able to use the brightness value of the last time the screen was turned on before it went black when it turns on again. This does not match the actual environment and causes visual discomfort to the user. The present application provides a new solution for adjusting the screen brightness, which moves the operations of conflict and priority management of the target camera (the camera used to detect ambient light) from the framework layer to the hardware abstraction layer, so that the conflict and priority management of the two functions of the target camera are managed separately at the hardware abstraction layer, rather than together with the camera functions of other cameras at the framework layer. This can effectively shorten the delay and ensure that the ambient light parameters of the first frame can be reported in time, avoiding the use of the brightness value of the previous screen turn on due to untimely reporting. In short, the present application solution hopes that when it is executed, there will be no Figure 1 Instead of the situation shown in (d) in Figure 1 After the screen light operation shown in (c), the display is directly Figure 1 (e) shows the brightness value adapted to the actual environment.
[0047] Figure 2 It is a schematic diagram of a traditional execution framework for ambient light detection using a camera. For ease of understanding, the software system of the electronic device is first described. A software system is installed in the electronic device, and the software system can run on a processor. The software system can be an Android system, a Windows system, an IOS system, a Hongmeng system, etc., and the architecture adopted by the software system can be a layered architecture, an event-driven architecture, a micro-core architecture, a microservice architecture, or a cloud architecture. The embodiment of the present application takes the Android system of a layered architecture as an example to illustrate the software structure of the electronic device. The Android system can be divided into four layers, from top to bottom, namely, the application layer, the framework layer (Framework, FWK), the hardware abstraction layer (HAL) and the kernel layer.
[0048] The application layer may include a series of applications, such as camera, calendar, map, WLAN, music, short message, gallery, call, ambient light detection, face unlocking, etc., which are used to interact directly with users. These applications can be system built-in applications or non-system level applications. And these applications can have icons and application interfaces, or have application interfaces without icons, or have neither icons nor application interfaces.
[0049] The framework layer includes some predefined functions, which can provide application programming interfaces (APIs) and programming frameworks for applications in the application layer. The application programming interfaces provided by the framework layer may include interfaces related to camera services, interfaces related to sensor services, and interfaces related to other services. Interfaces related to different services can be defined as different service modules. For example, interfaces related to sensor services can be defined as sensor service modules, interfaces related to camera services can be defined as camera service modules, interfaces related to other services can be defined as other service modules, etc.
[0050] The hardware abstraction layer is located between the framework layer and the kernel layer. Its purpose is to abstract the hardware. The hardware abstraction layer hides the hardware interface details of a specific platform and provides a virtual hardware platform for the software system, making it hardware-independent and portable on multiple platforms.
[0051] The kernel layer is the layer between hardware and software. The kernel layer may include display drivers, camera drivers, audio drivers, sensor drivers, etc., through which the display screen, front / rear cameras, audio players, sensors, etc. can be driven.
[0052] like Figure 2As shown, the sensor service module in the framework layer may include sub-modules such as SensorManager and SensorSerivce. In the scheme of using a camera to detect ambient light, the SensorManager is used to adjust the brightness of the display screen of the electronic device according to the brightness of the detected ambient light. SensorSerivce is used to implement the communication between the relevant applications that need to call the sensor in the application layer and the Sensor HAL. Optionally, the sensor service module can be used as an independent process, and the SensorManager and SensorSerivce can be two threads in the process. The camera service module includes sub-modules such as ICameraSerivce and CameraSerivce. CameraService can be used to implement the communication between the application that needs to call the camera in the application layer (for example, camera application, face unlocking application, ambient light detection application, etc.) and Camera HAL. Optionally, the camera service module can be used as an independent process, and ICameraSerivce and CameraSerivce can be two threads in the process. The electronic device is provided with multiple cameras, multiple cameras cannot be enabled at the same time, and different functions of the same camera cannot be enabled at the same time. When the front camera is used to replace the ambient light detection device, in order to solve the enabling priority problem of different functions of multiple cameras, in the solution of using the camera to detect ambient light, the CameraSerivce in the camera service module is modified, and the judgment logic of the enabling priority of different functions of the camera is added, so that when two or more camera functions need to be enabled at the same time, one of them can be enabled according to the judgment logic.
[0053] In the hardware abstraction layer, according to the functions implemented, the hardware abstraction layer can be further refined into a camera-related hardware abstraction layer (i.e., the Camera HAL described in the subsequent embodiments), a sensor-related hardware abstraction layer (i.e., the Sensor HAL described in the subsequent embodiments), etc. The camera-related hardware abstraction layer can be defined as a camera control module, and the sensor-related hardware abstraction layer can be defined as a sensor control module. Optionally, the camera control module can be used as an independent process, and the sensor control module can also be used as an independent process. In order to realize the ambient light detection function of the front camera, the sensor control module (Sensor HAL) is modified in the scheme of using the camera to detect ambient light. Specifically, an ambient light service control submodule (i.e., the CameraLightManager described in the subsequent embodiments) is added to the sensor control module, and the ambient light service control submodule provides multiple interfaces, including an Active interface, a DeActive interface, etc. Among them, the Active interface is used to turn on the ambient light detection function of the front camera. The DeActive interface is used to turn off the ambient light detection function of the front camera. The camera control module (Camera HAL) is also modified in the scheme of using the camera to detect ambient light. Specifically, a camera function customization submodule (i.e., CamxLightCustom described in the subsequent embodiments) is added to the camera control module, and the existing function submodules (such as CHI-CDK, CAMX, etc.) in the camera control module are modified. Among them, the camera function customization submodule is used to obtain the ambient light brightness detected by the front camera when the front camera is used as an ambient light detection device, and send the ambient light brightness detected by the front camera to the sensor control module, so that the sensor control module reports the ambient light brightness to the sensor service module, thereby adjusting the display brightness of the electronic device. CHI-CDK is a customizable code implementation set. In the solution of using the camera to detect ambient light, on the basis of the original code implementation set of CHI-CDK, AIDL (Android Interface Definition Language) service initialization-related code is added, so that different processes in the electronic device (such as Sensor HAL and Camera HAL) can communicate with each other. Among them, AIDL is used to define the interface between the client and the server of the Android system based on Binder communication. Binder is a cross-process communication mechanism of the Android system, which allows different processes to communicate, and even communicate across devices.CAMX is a set of code implementations of a general functional interface. In the solution of using a camera to detect ambient light, the Open Camera function is modified based on the original code implementation set in CAMX, and a logic branch is added that can skip the configuration of image output resources for the front camera. Therefore, when the front camera is used as an ambient light detection device, the process of configuring image output resources for the front camera can be skipped, thereby reducing the power consumption of the front camera and improving the performance of the electronic device.
[0054] The camera service module controls the opening and closing of the target camera by sending instructions to the camera control module (Camera HAL). In the solution of independent ambient light detection device, the sensor service module controls the opening and closing of the ambient light detection device by sending instructions to the sensor control module (Sensor HAL), but in the solution of camera detecting ambient light, the opening and closing of the target camera needs to be controlled by the instructions sent by the sensor service module. However, since the sensor control module cannot pass the instructions sent by the sensor service module to the target camera (not in the same operation link), it is necessary to establish a control path between the sensor control module and the camera service module, so as to realize the control of the target camera by the Sensor HAL with the help of the camera service module. Since the sensor control module of the HAL layer is an independent process and the camera service module of the FWK layer is also an independent process, when establishing the control path between the sensor control module of the HAL layer and the camera service module of the FWK layer, it is established based on the HIDL service. Among them, HIDL is used to define the interface between the HAL layer and the FWK layer of the Android system based on Binder communication. After opening the control path between the sensor control module and the camera service module, it is also necessary to establish a data path between the sensor control module and the camera control module, so that after turning on the ambient light detection function of the target camera, the camera control module transmits the ambient light parameters detected by the target camera to the sensor control module, which is then sent to the sensor service module by the sensor control module, thereby realizing the adjustment of the brightness of the display screen.
[0055] In this solution, the camera control module (i.e., Camera HAL) can be an independent process, which can be defined as a camera control process. The sub-modules included in the camera control module (such as CHK-CDK, CAMX, CamxLightCustom, etc.) can be different threads in the camera control process. AIDL service initialization can be the process of pulling up the AIDL service. By initializing the AIDL service, communication between the client and the server based on the AIDL service can be achieved. AIDL service initialization can be performed in the camera control module, specifically, it can be performed in the CHK-CDK of the camera control module. The AIDL service can be initialized during the startup of the electronic device, and can also be initialized after startup when the client and server based on the AIDL service need to communicate. The process of AIDL service initialization can correspond to Figure 2 Step ① in Figure 2 When the electronic device is turned on, the AIDL service in the CHI-CDK of the Camera HAL is initialized, which can be to pull up the AIDL service.
[0056] It should be noted that AIDL service is used to realize communication between different processes. For two processes communicating based on AIDL service, one process is used to generate data and can be used as AIDL server; the other process is used to issue control instructions and receive data and can be used as AIDL client.
[0057] After that, the sensor service module sends a brightness monitoring command to the Sensor HAL ( Figure 2 In step ②), after receiving the brightness monitoring command, SensorHAL calls Active based on AIDL service and registers the data callback function in Camera HAL ( Figure 2 In step ③), the Sensor HAL calls the libcamera2ndk_vendor interface based on the HIDL service and sends the logical camera identifier to the camera service module ( Figure 2 In step ④), the camera service module calls the Open Camera function in CAMX of CameraHAL through CameraService and executes the Open Camera function. Through the interface of CamxLightCustom, it sends a control instruction to the camera driver, so that the camera driver applies for CSL resource cache for the ambient light detection function of the front camera, powers on the front camera, initializes the camera register, creates an asynchronous reading thread, etc. ( Figure 2 In step ⑤), the camera control module obtains the ambient light parameters periodically output by the target camera and sends them to the sensor control module through the data callback function ( Figure 2Step ⑥) in the above description is sent by the sensor control module to the sensor service module, and the sensor service module adjusts the brightness of the display screen of the electronic device based on this.
[0058] It should be noted that cameras generally include two types, front cameras and rear cameras, and the number of front cameras and rear cameras is at least one respectively. Moreover, the front camera and the rear camera have multiple functions respectively, including at least one of a photo taking function, a face unlocking function, an ambient light detection function, and the like. In order to distinguish different types of cameras and different functions of cameras of the same type, the embodiment of the present application abstracts multiple logical cameras according to the type and function of the camera, and each logical camera corresponds to an identifier. For example, according to the photo taking function of the front camera, a logical camera A can be abstracted, and according to the ambient light detection function of the front camera, a logical camera B can be abstracted. The logical camera A and the logical camera B can correspond to the same front camera or to different front cameras. For the photo taking function of the logical camera A, i.e., the front camera, the identifier set is Camera ID=1, and for the ambient light detection function of the logical camera B, i.e., the front camera, the identifier set is Camera ID=4.
[0059] It should also be understood that in a solution using a camera to detect ambient light, when a target camera is used instead of an ambient light detection device, no image output resources will be configured for the camera, and the camera will not capture images.
[0060] exist Figure 2 In the entire execution process shown, since the camera management link is superimposed on the original ambient light detection link, starting the camera requires more preparation work at the FWK layer, such as conflict and priority management. However, all camera management at the FWK layer is unified management of all cameras, which takes a relatively long time. With the development of technology, the management of cameras will become more complicated as the functions of the cameras become richer. In addition, if the camera has more initialization registers, the preparation time will be extended. This results in a long time after receiving the instruction issued in step ④, when it is determined that the target camera needs to work in the ambient light detection mode, and the reporting time limit of the first frame ambient light parameters is missed, resulting in the electronic device only being able to use the last brightness value to light up the screen, which does not match the actual ambient brightness.
[0061] In addition, modifications to the FWK layer will be subject to strict testing requirements, making it difficult to upgrade the solution later, and the solution has the potential to affect product testing requirements.
[0062] In response to the problems existing in the above-mentioned scheme, the present application optimizes the above-mentioned scheme with as few changes as possible. By transferring the preparatory work performed in the FWK layer to the HAL layer, the function of using the camera for ambient light detection is separately managed in terms of conflicts and priorities in the HAL layer. Such optimization will not affect the FWK layer's management of other cameras and other camera functions, and makes the ambient light detection function no longer dependent on and accommodate the FWK layer's unified management of all camera functions, shortening the waiting time and ensuring that the first frame ambient light parameters are reported in time, thereby solving the problem of flashing and jumping after the screen is turned on again.
[0063] Figure 3 It is a schematic diagram of an execution process of adjusting screen brightness according to an embodiment of the present application. Figure 3 Zhongyu Figure 2 The same steps can be referred to Figure 2 The relevant content will not be elaborated. Figure 3 As shown, Figure 2 The camera service module in the FWK layer is removed, and a camera conflict and priority management module is added to CAMX in Camera HAL to manage the two functions of the target camera (camera function and ambient light detection function); and a switch interface module, that is, the Open / Close interface, is added to Camera HAL to confirm the logical camera ID (that is, the camera ID) of the target camera. After receiving the Open Camera command sent from Active, it is sent to the camera conflict and priority management module. After the camera conflict and priority management module determines that the target working mode of the target camera is the ambient light mode, it executes subsequent steps such as creating threads. It can be seen that Figure 3 Yes Figure 2 Step ④ in the above is moved down to the HAL layer for independent execution, and is no longer executed together with the unified management of all cameras in the FWK layer. After such optimization, the preparation work that must be performed by the FWK layer is omitted, the duration of the entire execution process is shortened, and the timeliness of data reporting is guaranteed.
[0064] Figure 4 is a schematic flow chart of a method for adjusting screen brightness in an embodiment of the present application. Figure 4 The method can be applied to electronic devices such as mobile phones, tablet computers, and laptop computers.
[0065] S401. In the screen-off state, obtain the first screen-on operation.
[0066] The first screen-on operation may be an interactive operation input by the user for turning on the screen, or other operations such as alarm clock wake-up. The interactive operation input by the user for turning on the screen may be an operation in which the user presses a mechanical button for turning on the screen, or may be a face unlocking operation (face wake-up operation), etc., without limitation.
[0067] S402: In response to a first screen-lighting operation, a camera identifier is obtained in a hardware abstraction layer of a software system of the electronic device, where the camera identifier is used to indicate a target camera corresponding to an ambient light detection function.
[0068] The target camera can be Figure 2 and Figure 3 The target camera, that is, the camera capable of performing ambient light detection, can be a front camera or a rear camera. This application mainly takes the target camera as a front camera as an example.
[0069] For other cameras, the camera ID can be used to indicate which camera it is. For the target camera, since it has two functions, there is a camera ID corresponding to each of the two functions, which is the ID of the logical camera mentioned above. For example, suppose an electronic device has a front camera and two rear cameras. The front camera has two working modes: camera mode and ambient light mode. Therefore, the camera mode of the front camera can be corresponded to camera ID #1, and the two rear cameras can be corresponded to camera ID #2 and camera ID #3 respectively, and the ambient light mode of the front camera can be corresponded to camera ID #4. Then, after obtaining the current camera ID of the target camera, the camera ID may be camera ID #1 or camera ID #4, thereby indicating that the working mode is camera mode or ambient light mode respectively.
[0070] It should be understood that before the meaning of the camera identification is parsed, it is impossible to know the corresponding camera and function, but the camera identification can be used to indicate the target camera for ambient light detection.
[0071] In one implementation, when the hardware abstraction layer of the software system of the electronic device obtains the camera identification, it can include: in the sensor control module of the hardware abstraction layer, calling the function of opening the camera through the AIDL interface, and sending the camera identification to the camera control module of the hardware abstraction layer; in the hardware abstraction layer, determining the target working mode of the target camera according to the preset priority, including: performing conflict and priority management in the camera control module, so as to determine the target working mode according to the preset priority. In this implementation, an example of how to determine the target working mode is given, which is completed by calling the appropriate interface through the cooperation of the sensor control module and the camera control module.
[0072] S403: At the hardware abstraction layer, determine a target working mode of the target camera according to a preset priority, where the working mode of the target camera includes a camera mode and an ambient light mode.
[0073] That is to say, the working mode of the target camera is managed at the HAL layer, and which working mode the target camera currently needs to adopt is determined based on the preset priority according to the camera identifier. Assuming that the preset priority is that the camera mode is higher than the ambient light mode, the management of this step includes: when the camera identifier indicates the camera mode, start the relevant modules of the target camera in the camera mode, use the target camera to collect image data, and at the same time turn off the relevant modules in the ambient light mode, that is, release the resources corresponding to the ambient light mode; when the camera identifier indicates the ambient light mode, start the relevant modules of the target camera in the ambient light mode, use the target camera to collect ambient light parameters, and at the same time turn off the relevant modules in the camera mode, that is, release the resources corresponding to the camera mode, and no longer output the image.
[0074] The camera ID can be reported to the camera control module by calling a function through the AIDL interface to determine the target working mode.
[0075] In one implementation, the AIDL interface includes functions for opening and closing the camera, namely, the OpenCamera function and the Close Camera function. The AIDL interface calls the open / close interface (Open / Close interface) corresponding to the CamxLightCustom module in the camera control module (Camera HAL), and then calls the CAMX module, performs conflict and priority management in the CAMX module, and thus confirms the current working mode of the target camera. This process can be implemented, for example, by using the following code, calling the Open Camera function and the Close Camera function to obtain the camera identifier (cameraFwkId), which is a logical camera identifier, not an actual camera identifier.
[0076] interface ILuxService{
[0077] int OpenCamera(in int cameraFwkId);
[0078] int CloseCamera(in int cameraFwkId);
[0079] …
[0080] }
[0081] exist Figure 2When conflict management is performed in the scheme shown, when the target camera is turned on, the camera identifier of the target camera's camera mode is CameraID=1, and the camera identifier of the target camera's ambient light mode is CameraID=4. After obtaining the CameraID, when the electronic device does not include the camera identifier of the ambient light mode, that is, when the target camera does not have the function of enabling the ambient light mode or does not have the function of the ambient light mode, the target camera is directly started according to the camera mode; when the electronic device includes the camera identifier of the ambient light mode, that is, when the target camera has the function of enabling the ambient light mode, the CameraID is first judged to determine whether m_perCameraInfo[logicalCameraId].isCameraOpened is true. If it is true, the ambient light CameraID is first closed to release resources. After the closure is completed, the target camera is started according to the camera mode. If it is not true (that is, false), the target camera is directly started according to the camera mode. Figure 2 In the conflict management scheme shown in the figure, when the target camera is turned off, the CameraID that conflicts with the ambient light cameraID is obtained through the tag. If the currently closed CameraID is equal to the conflicting CameraID, the ambient light cameraID needs to be reopened after the closing process of the currently closed CameraID is completed. Otherwise, no processing is performed. The above conflict management can be done in Figure 3 The CAMX module shown is implemented in the
[0082] The above process can be implemented by the following code, for example.
[0083]
[0084] In one implementation, the preset priority is used to indicate that the priority of the camera mode of the target camera is higher than the priority of the ambient light mode of the target camera. At the hardware abstraction layer, when the target working mode of the target camera is determined according to the preset priority, it may include: when the target camera is working in the camera mode, determining the target working mode is the camera mode; or when the target camera is not working in the camera mode, determining the target working mode is the ambient light mode. That is to say, the target camera is used to perform ambient light detection under the premise of ensuring that the basic shooting function of the target camera is not affected.
[0085] In one implementation, when the first screen-on operation is a face wake-up operation, at the hardware abstraction layer, the target operating mode of the target camera is determined according to a preset priority, which may include: determining the target operating mode as the ambient light mode, and changing the target operating mode to the camera mode after receiving the first frame ambient light parameters. In this implementation, when a conflict occurs between the screen-on task and face recognition (face wake-up, that is, face unlocking the screen), the target camera is first operated in the ambient light mode, and then the target camera is operated in the camera mode after the first frame ambient light parameters are obtained, thereby ensuring that the first frame ambient light parameters are reported in a timely manner to avoid bright flashes and jumps, and in addition, it can return in time to continue to perform the face recognition task.
[0086] In the traditional solution, since the camera mode has a higher priority than the ambient light mode, face recognition is prioritized after the face wake-up operation occurs, releasing the resources for ambient light detection. Ambient light detection is not performed until face recognition is completed, resulting in the first frame ambient light parameters not being reported in time and bright flashes.
[0087] S404: When the target working mode is determined to be the ambient light mode, the target camera is started through the hardware abstraction layer, and the target camera is enabled to collect ambient light parameters in the ambient light mode, and the screen brightness is adjusted according to the collected ambient light parameters.
[0088] That is, when it is confirmed that the current target camera is working in the ambient light mode, the ambient light parameters are obtained. When obtaining the ambient light parameters, the data can be obtained periodically, for example, the data can be reported every 400 milliseconds (ms), but it should be understood that there is no limitation on the specific value.
[0089] It should be understood that since steps S403 and S404 are both executed at the HAL layer, the ambient light parameters reported by the target camera here are reported in a timely manner (that is, the first frame ambient light parameters are reported early enough), so the assignment according to the last brightness value can be avoided. For the ambient light detection link, the first frame ambient light parameters need to be reported to the sensor service module within 200ms after the screen light operation occurs. If the report cannot be successful within 200ms, the brightness value of the last screen light will be assigned. In other words, the sensor service module has a time limit for reporting the first frame ambient light parameters of ambient light. When the target camera cannot report within the reporting time of the first frame ambient light parameters corresponding to the sensor service module, the sensor service module will switch to lighting the screen according to the brightness value of the last screen light before the first screen light operation.
[0090] In one implementation, during the period of using the target camera to collect ambient light parameters, the above method also includes: creating a first thread to periodically read the ambient light parameters, and marking the first identifier as not stopping each time the first thread is awakened, the first identifier is used to indicate whether the periodically read thread is stopped; when the first screen-off operation is obtained, in response to the first screen-off operation, the first identifier is marked as stopped, and the first thread is stopped. In this implementation, the stopping method of the first thread is changed from the traditional solution that stops when the next wake-up cycle arrives because the first identifier is marked as stopped to directly stop when the screen-off operation occurs. This solution uses the simplest change in execution opportunity to solve the problem of idle running threads when the screen is frequently turned on and off. Due to such a stopping method in the traditional solution, if a second screen-on operation occurs after the screen-off operation during the dormancy of the first thread, the second screen-on operation will cause the first identifier to be modified to not stop again, and the second thread will be started to read data. Then, after the end of the dormancy cycle, the first identifier read is not stopped, resulting in the first thread and the second thread both reading data thereafter, but the data read by the first thread is useless, which is equivalent to an idle running thread, wasting resources. In short, for the frequent screen on and off scenario, the first thread cannot be stopped according to the traditional solution, and multiple threads periodically read data, and the first thread runs idle and wastes resources. However, the solution of this application will stop the first thread immediately after the screen off operation occurs, so the first thread will not be unable to stop.
[0091] In one example, when a first screen-off operation is obtained, in response to the first screen-off operation, the first flag is marked as stopped, and the first thread is stopped, which may include: when the first screen-off operation is obtained during the wake-up period of the first thread, the first thread is stopped directly; or when the first screen-off operation is obtained during the sleep period of the first thread, the first thread is woken up first and then stopped. In this implementation, when the screen-off operation is obtained during the wake-up period of the first thread, the thread is stopped directly, and when the screen-off operation is obtained during the sleep period, the thread is woken up first and then stopped.
[0092] Figure 4 The scheme shown mainly completes the conflict and priority management of the working mode of the target camera by calling the corresponding interface in the hardware abstraction layer, and determines the target working mode of the target camera, so that there is no need to execute the process with the unified management of all cameras in the framework layer, which saves the execution time and ensures the timely reporting of the ambient light parameters of the target camera, avoiding the problem that the brightness value of the last screen-on operation before the screen-on operation is determined as the target brightness for screen-on operation due to untimely reporting, but it does not match the actual environment.
[0093] Figure 5 It is a schematic flowchart of another method for adjusting screen brightness according to an embodiment of the present application. Figure 5It can be understood as combining the system structure to Figure 4 The method shown is described.
[0094] S501. Perform flag bit determination in the sensor control module (sensor HAL).
[0095] Here, it refers to the determination of the registration flag bit of the ambient light detection function, for example, it can be the determination of the flag bit is_ambient_light to determine whether it is true. If it is true, it means that the registration has been successful, if it is not true (false), it means that it has not been registered, and at this time, the registration of step S502 needs to be performed.
[0096] S502: The sensor control module registers an ambient light detection function with the camera control module (Camera HAL).
[0097] You can register by calling the AIDL interface through Active, and the registration function can call RegisterLuxCallback.
[0098] After booting up, execute step S501 and step S502 to register. After registration, Camera HAL can send ambient light parameters to sensor HAL through callback. However, it should be understood that registration is only required once, and it is not necessary to register every time the ambient light parameters need to be read. In other words, step S501 and step S502 do not need to be executed after each screen-on event (screen-on operation). They can be used after the first execution after booting up.
[0099] S503: After receiving the screen-on event, the sensor service module of the framework layer reports the screen-on event to sensorHAL.
[0100] The screen-on event is the screen-on operation, such as the first screen-on operation mentioned above. The screen-on event may be the operation of the corresponding control or button, or it may be face recognition, that is, face wake-up (face unlocking) operation, or wake-up after the alarm rings, etc. There is no limitation.
[0101] S504: The sensor control module sends a camera identifier corresponding to the ambient light detection service to the camera control module.
[0102] The camera ID is used to represent the ID of a camera capable of detecting ambient light, but it should be understood that here it is specifically the ID of the ambient light mode of the camera capable of detecting ambient light, for example, it may be CameraID=4 in the above text.
[0103] The function int OpenCamera(in int cameraFwkID) can be called through the AIDL interface to obtain the camera ID and send the camera ID to the camera control module.
[0104] S505: The camera control module performs conflict and priority management.
[0105] Conflict and priority management is mainly to confirm whether the target camera can work in ambient light mode, perform ambient light detection, or continue to work in camera mode. Figure 2 In the solution shown, the conflict and priority management at the FWK layer is a unified management of all logical cameras, but for Figure 5 The management here is only to manage the conflicts and priorities of the two working modes of the target camera (target camera). This is why the duration of this step can be effectively shortened and the first frame ambient light parameters can be reported in time.
[0106] S506: The camera control module starts the target camera.
[0107] Before starting the target camera, it is necessary to determine whether the target camera supports the ambient light detection function and confirm that the target camera is started in the ambient light mode.
[0108] S507: The camera control module sends an instruction to start the target camera to the camera driver.
[0109] S508: The camera driver is powered on and registers are initialized.
[0110] When detecting ambient light, the camera does not need to output image data, so there is no need to configure a corresponding buffer for the image data. Therefore, the registers initialized here are only used for the acquisition process of ambient light parameters.
[0111] S509: The camera driver cyclically reads the ambient light parameters collected by the target camera.
[0112] This cycle is the reading cycle, that is, the data is read once every certain reading time interval. It should also be understood that the frame rate mentioned above is used to set the duration of the reading cycle. For example, assuming the frame rate is 30 frames per second, it is equivalent to a reading cycle (reading time interval or reading interval) of 10ms. The data is read once when the reading cycle arrives, and then the periodic reading thread will go into sleep mode, wait for the sleep cycle (that is, the reading cycle) to end, and then wake up again to read the data, and so on, and the reading cycle continues.
[0113] S510, the camera loop sends the ambient light parameters collected by the target camera to the camera control module in a callback manner.
[0114] That is to say, each time the ambient light parameters are read, they will be sent to the camera control module.
[0115] S511. The camera control module sends the brightness value to the sensor control module by way of callback.
[0116] The brightness value here can be understood as the target brightness, that is, you want to brighten the screen according to this brightness value.
[0117] It should be understood that step S511 is also executed each time the ambient light parameters are read, that is, it is executed in a loop.
[0118] S512: The sensor control module reports the brightness value to the sensor service module, so that the sensor service module can set the screen brightness based on the brightness value.
[0119] from Figure 5 It can be seen that the framework layer is only involved in reporting the screen-on event and receiving the target brightness value, and other steps are executed in the HAL layer, thereby controlling the camera driver to collect ambient light parameters and ensuring timely reporting of ambient light parameters.
[0120] Figure 6 The diagram is a schematic diagram of the execution process of periodically reading ambient light parameters in a traditional solution. Figure 6 The scheme for periodically reading ambient light parameters is in Figure 2 As shown in the execution process. Figure 6 As shown, when the ambient light brightness is read and calculated in step ⑤, a reading interval of 400ms is adopted, that is, the reading is performed in a loop at a frame rate of 5 frames per second (ie, 5 fps).
[0121] It takes a certain amount of integration time from obtaining the original brightness (lux rawdata) from the camera to outputting the ambient light parameters. This means that the first reading may read the original brightness instead of the ambient light parameters after the integration is completed. The data is not accurate enough, which leads to inaccurate ambient light parameters in the first frame, and then inaccurate adjustment of the screen brightness. You need to wait another 400ms to read the accurate value. This means that even if the ambient light parameters of the first frame are reported successfully, there may still be inaccuracies. In this case, the screen brightness will be an inaccurate brightness value during the 400ms waiting for the next reading. If the first frame report fails, you have to wait another 400ms for the next reading. The ambient light data of the first frame must be reported successfully within 200ms. If the first frame report fails, the brightness value of the last screen on will be directly used. Both of the above situations may cause the screen brightness to not match the actual ambient brightness, resulting in a poor visual experience.
[0122] To address the above problems, the present application adopts a dual frame rate reading method, using a higher frame rate reading for the first few frames and then changing to a low frame rate reading, thereby ensuring that the first few frames are read quickly and accurate ambient light parameters can be quickly obtained, and then a low frame rate is used to reduce power consumption.
[0123] The present application provides another method for adjusting screen brightness, the method comprising: in a screen-off state, obtaining a first screen-on operation; in response to the first screen-on operation, obtaining a camera identifier in a hardware abstraction layer of a software system of an electronic device, the camera identifier being used to indicate a target camera corresponding to an ambient light detection function; in the hardware abstraction layer, determining a target operating mode of a target camera according to a preset priority, the operating modes of the target camera including a camera mode and an ambient light mode; when the target operating mode is determined to be an ambient light mode, starting the target camera through the hardware abstraction layer; using the target camera to collect ambient light parameters N times at a first frame rate, N being an integer greater than 1, and adjusting the screen brightness according to the collected ambient light parameters; after collecting the ambient light parameters N times, using the target camera to continuously collect the ambient light parameters at a second frame rate, the second frame rate being less than the first frame rate, and adjusting the screen brightness according to the collected ambient light parameters.
[0124] This solution mainly shortens the data reporting cycle by reporting the first N frames of data at a higher frame rate, allowing the target camera to report the ambient light parameters more quickly, thereby ensuring that the first frame of ambient light data is reported in time, avoiding the situation where the last screen brightness value is used due to untimely reporting, thus avoiding bright flickering. A high frame rate will lead to high power consumption, but a low frame rate will easily lead to untimely reporting of the first frame of ambient light parameters, so this solution adopts a high frame rate in the early stage and a low frame rate in the later stage, taking into account both low power consumption and timely reporting requirements.
[0125] Below Figure 7 Take as an example the execution process of the link of periodically reading the ambient light parameters in this method is explained, that is, Figure 7 This can be regarded as an example of the process of reading N frames at the first frame rate and then reading subsequent frames at the second frame rate in the above-mentioned amplification.
[0126] Figure 7 It is a schematic diagram of an execution process of periodically reading ambient light parameters according to an embodiment of the present application. Figure 7 The scheme for periodically reading ambient light parameters is in Figure 3 As shown in the execution process. Figure 7As shown, when the ambient light brightness is read and calculated in step ⑤, the first N frames are read at a reading interval of 10ms (frame rate is 30 frames per second (fps)), and then the subsequent frames are read at a reading interval of 400ms (frame rate is 5fps). 30fps can be regarded as an example of the first frame rate, and 5fps can be regarded as an example of the second frame rate. N can be a suitable value such as 3 or 5.
[0127] However, it should be understood that in actual use, it can also be set to other appropriate values, for example, the first 4 frames can be collected at a frame rate of 20 frames / second, and the frame rate of 3 frames / second starting from the 5th frame, etc. There is no limitation.
[0128] Figure 8 This is a schematic diagram of the conflict between the face recognition task and the ambient light detection task. Figure 8 As shown, in Figure 3 Based on the steps shown, when the face recognition task passes step ⑦, CameraService is used to obtain the event of opening the target camera. Since the target camera is also used to collect ambient light, a conflict occurs. When performing camera conflict and priority management, since the priority of the camera mode is higher than the ambient light mode, step ⑧ will be executed to close the ambient light detection camera ID. Here, the resources in the ambient light mode of the target camera are closed. This results in the ambient light detection task being closed before it is completed, and the first frame ambient light parameter reporting fails. After waiting for 200ms, the electronic device does not receive the ambient light parameters, and directly uses the brightness value of the last screen on to light up the screen, resulting in the screen brightness not being able to use the accurate brightness value, causing bright flashes and jumps.
[0129] against Figure 8 To solve the problem shown, the present application provides an optimization solution, which ensures that the resources for ambient light detection are not released too early, resulting in the missing of the first frame ambient light parameters, by modifying the mark bit (identifier) of releasing resources only after the first frame ambient light parameters are successfully received, thereby avoiding bright flashes caused by untimely reporting.
[0130] The present application provides another method for adjusting screen brightness, the method comprising: in a screen-off state, obtaining a first screen-on operation, the first screen-on operation being a face wake-up operation; in response to the first screen-on operation, obtaining a camera identifier in a hardware abstraction layer of a software system of an electronic device, the camera identifier being used to indicate a target camera corresponding to an ambient light detection function; in the hardware abstraction layer, determining a target operating mode of the target camera as an ambient light mode; starting the target camera through the hardware abstraction layer and enabling the target camera to collect ambient light parameters in the ambient light mode, and adjusting the screen brightness according to the collected ambient light parameters; upon receiving the first frame of ambient light parameters reported by the target camera, updating the target operating mode of the target camera to a camera mode in the hardware abstraction layer; starting the target camera through the hardware abstraction layer and enabling the target camera to collect face images in the camera mode.
[0131] In this solution, when there is a conflict between the screen-lighting task and face recognition (face wake-up, that is, face unlocking the screen), the target camera is first operated in ambient light mode, and after obtaining the first frame ambient light parameters, the target camera is operated in camera mode, thereby ensuring that the first frame ambient light parameters are reported in time to avoid bright flashes and jumps. In addition, it can return in time to continue the face recognition task.
[0132] Fig. 9 It is a schematic diagram of an execution process of obtaining ambient light parameters according to an embodiment of the present application. Fig. 9 The face recognition task and the ambient light detection task are triggered and executed at the same time, causing conflicts. However, it should be understood that Fig. 9 The scenario shown requires that both face recognition and ambient light detection are performed by the target camera to cause a conflict. If two independent cameras perform face recognition and ambient light detection respectively, there will be no conflict. Since the front camera and the screen are facing the same direction, and face recognition often requires taking a person's face image, the front camera is generally used. The purpose of ambient light detection is to adjust the screen brightness. The front camera and the screen are facing the same direction, so the front camera can also be used for ambient light detection. After the two preferred solutions are superimposed, the front camera needs to collect images for face recognition tasks and collect ambient light parameters for ambient light detection tasks, which causes a conflict.
[0133] S901. The camera service module of the framework layer sends a request to open the camera to the camera control module of the hardware abstraction layer.
[0134] In this request, the camera mode of the target camera is requested to be turned on, and Camera ID=1.
[0135] In one possible case, the execution of step S901 may be triggered by the operation of face unlocking the screen or face waking up the screen. Under the triggering of this operation, not only the face recognition task needs to be performed to unlock or wake up the screen, but also the ambient light detection task needs to be performed to adjust the screen brightness.
[0136] S902: Perform conflict and priority management at the camera control module, and turn off the ambient light mode of the target camera (Camera ID=4).
[0137] During conflict and priority management, since the camera mode of the target camera has a higher priority than the ambient light mode, the target working mode will be determined to be the camera mode. At this time, the ambient light mode needs to be turned off to release the resources of the ambient light mode.
[0138] S903, determining whether the resource release flag of the ambient light mode of the target camera is true, if it is true, releasing the resources of the ambient light mode, if it is false, waiting (not releasing resources).
[0139] The resource release identifier may be an identifier of a resource release function ReleaseCamLightProcess.
[0140] In the conventional solution, the operation of modifying the flag to true is performed when step S902 is executed, resulting in the release resource flag read to be true when step S903 is executed. Fig. 9 In the illustrated solution, when step S902 is executed, the resource release flag is not modified, so the resource release flag is still false. Therefore, when step S903 is executed, the resource will not be released because false is read.
[0141] S904: The camera driver periodically reports ambient light parameters to the camera control module.
[0142] For the relevant contents of periodically reading the ambient light parameters, please refer to the above text and will not be repeated here.
[0143] S905 . After receiving the ambient light parameters of the first frame, the camera control module sets the resource release flag to true.
[0144] The resource release flag will be changed to true only after the first frame ambient light parameters are obtained.
[0145] S906: The camera control module sends the brightness value to the sensor control module through callback.
[0146] You can refer to the same steps as above and will not repeat them here.
[0147] S907: The sensor control module sends the brightness value to the sensor service module.
[0148] You can refer to the same steps as above and will not repeat them here.
[0149] It should also be understood that step S903 will wait after being judged as false, but the waiting is also limited, so it will be judged again when the time limit is reached. When it is judged again, due to the execution of step S905, it is judged as true and the resources are released.
[0150] Fig. 9 It can be executed Figure 3 The process shown or Figure 4 The process shown in the figure can be understood as when the first screen-on operation is face wake-up, both face recognition and ambient light detection tasks need to be performed to light up the screen. However, since the camera mode (Camera ID = 1) has a higher priority than the ambient light mode (Camera ID = 4), the resources of Camera ID = 4 are released, and the face recognition task is performed first. This causes the ambient light parameter reporting to fail, and the electronic device will directly use the brightness value of the last screen-on to light up the screen, causing flashing. Therefore, it is used Fig. 9 In the solution shown, resources are released only after the first frame ambient light parameters are successfully reported, and the face recognition task is executed. Releasing resources includes releasing the requested buffer and turning off the ambient light detection function of the camera.
[0151] In one implementation, a semaphore operation can be added to the resource release function ReleaseCamLightProcess to ensure that the first frame ambient light parameters are released after they are successfully reported. You can wait for the ambient light parameters or wait for a 40ms timeout. If the ambient light parameter mark is set to true, it means that the first frame ambient light parameters have been successfully reported, and you can perform subsequent release. In order to prevent blocking, that is, waiting for the ambient light parameters to be reported, a 40ms waiting time limit is set, and subsequent release is performed when it exceeds 40ms.
[0152] The above process can be implemented, for example, using the following code.
[0153]
[0154] In the thread that reads the first frame ambient light parameter, mValidValueArrived will be set to true after reading the first frame ambient light parameter, notifying the target camera that the ambient light mode resources have permission to be released. You can notify the release resource function ReleaseCamLightProcess to execute. In ReleaseCamLightProcess, first read the first frame ambient light parameter flag mValidValueArrived, and continue to execute release when it is true.
[0155] The above process can be implemented, for example, using the following code.
[0156]
[0157] Fig.10 This is a schematic diagram of threads running idle due to frequent screen on and off. When the screen is frequently turned on and off, a data reading thread is created each time the screen is turned on. When the screen is turned on and off quickly, there is a probability that there will be idle threads, which will affect the ambient light data reporting performance and power consumption. Fig.10 As shown, when the screen is turned on for the nth time, the flag bit (mThreadTerminate) of the reading thread is set to not stop (that is, set to false), and thread 1 is created. It should be understood that the creation of thread 1 and the setting of the flag bit to false are executed almost at the same time. After thread 1 is created and reads data once, thread 1 enters sleep and waits for a sleep cycle to end before the next reading. A sleep cycle is a reading time interval, also a reading cycle, which can be 400ms, for example.
[0158] However, in this sleep cycle, the screen goes off for the nth time, so that the flag of the reading thread is set to true (stop). If there is no subsequent n+1th screen on, it will wait until the sleep cycle ends. When reading next time, the flag is true, and thread 1 stops. However, the screen comes on for the n+1th time in this sleep cycle, so that the flag of the reading thread is reset to false (not stopping). Therefore, for thread 1, at the end of a sleep cycle, the next time it reads, the flag becomes false, making it impossible to stop thread 1. Since the n+1th screen on triggers the creation of thread 2, both threads read data periodically, affecting performance and causing unnecessary power consumption.
[0159] In response to the above problems, the present application provides an optimization solution, which will quickly wake up thread 1 and then stop thread 1 when the screen is turned off for the nth time.
[0160] The present application provides another method for adjusting screen brightness, which includes: in a screen-off state, obtaining a first screen-on operation; in response to the first screen-on operation, obtaining a camera identifier in a hardware abstraction layer of a software system of an electronic device, the camera identifier being used to indicate a target camera corresponding to an ambient light detection function; in the hardware abstraction layer, determining a target operating mode of a target camera according to a preset priority, the operating mode of the target camera including a camera mode and an ambient light mode; when the target operating mode is determined to be an ambient light mode, starting the target camera through the hardware abstraction layer, and enabling the target camera to collect ambient light parameters in the ambient light mode, and adjusting the screen brightness according to the collected ambient light parameters; during the period of collecting ambient light parameters using the target camera, creating a first thread (e.g., thread 1) to periodically read the ambient light parameters, and marking a first identifier (e.g., mThreadTerminate) as not stopped each time the first thread is awakened, the first identifier being used to indicate whether the periodically read thread is stopped; when the first screen-off operation is obtained, in response to the first screen-off operation, marking the first identifier as stopped, and stopping the first thread.
[0161] This solution mainly changes the stopping method of the first thread from the traditional solution that stops when the next wake-up cycle arrives because the first flag is marked as stopped, to stopping directly when the screen-off operation occurs. This solution uses the simplest change in the execution opportunity to solve the problem of idle running threads when the screen is frequently turned on and off. Due to such a stopping method in the traditional solution, if a second screen-on operation occurs after the screen-off operation during the dormancy period of the first thread, the second screen-on operation will cause the first flag to be modified to not stop again, and the second thread will be started to read data. Then, after the dormancy cycle ends, the first flag read is not stopped, resulting in the first thread and the second thread both reading data thereafter, but the data read by the first thread is useless, which is equivalent to an idle running thread, wasting resources. In short, for the frequent screen-on and screen-off scenarios, the first thread cannot be stopped according to the traditional solution, and multiple threads periodically read data, and the first thread runs idle and wastes resources. However, the solution of the present application will stop the first thread immediately after the screen-off operation occurs, so the first thread will not be unable to stop.
[0162] In one implementation, when the first screen-off operation is obtained, in response to the first screen-off operation, the first flag is marked as stopped, and the first thread is stopped, including: when the first screen-off operation is obtained during the wake-up period of the first thread, the first thread is stopped directly; or when the first screen-off operation is obtained during the sleep period of the first thread, the first thread is first awakened and then stopped. In this implementation, when the screen-off operation is obtained during the wake-up period of the first thread, the thread is stopped directly, and when the screen-off operation is obtained during the sleep period, the thread is awakened first and then stopped.
[0163] In one implementation, thread 1 may be quickly awakened by executing the following code in the ReleaseCamLightProcess function.
[0164]
[0165] In another implementation, during the read wait period (that is, during the sleep period), a semaphore check can be added, and when a stop semaphore is received, the read thread can be quickly stopped. For example, the following code can be used to implement this.
[0166] pCamxLightCustom->mCondition.wait_for(delayLock,
[0167] std::chrono::milliseconds(READ_SLEEP_TIME),
[0168] [pCamxLightCustom]{return pCamxLightCustom->mThreadTerminate.load();});
[0169] The above mainly introduces the method of the embodiment of the present application in conjunction with the accompanying drawings. It should be understood that although the steps in the flowcharts involved in the above embodiments are shown in sequence, these steps are not necessarily performed in sequence in the order shown in the figure. Unless clearly stated in this article, there is no strict order restriction on the execution of these steps, and these steps can be performed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with other steps or at least a part of the steps or stages in other steps. The device of the embodiment of the present application is introduced below in conjunction with the accompanying drawings.
[0170] Fig.11 Schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application. Fig.11As shown, 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, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, a sensor module 180, a camera 113, a display screen 114, etc. Among them, the sensor module 180 may include a pressure sensor 180A, a touch sensor 180K, etc.
[0171] It should be noted that the electronic device 100 does not include an ambient light sensor, that is, the sensor module 180 does not include an ambient light sensor.
[0172] 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.
[0173] For example, Fig.11 The processor 110 shown 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. Among them, different processing units may be independent devices or integrated in one or more processors.
[0174] 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.
[0175] 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.
[0176] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0177] In some embodiments, the I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). The processor 110 may include multiple groups of I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 113, etc. through different I2C bus interfaces. For example, the processor 110 may be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 communicates with the touch sensor 180K through the I2C bus interface, thereby realizing the touch function of the electronic device 100.
[0178] In some embodiments, the MIPI interface may be used to connect the processor 110 with peripheral devices such as the display screen 114 and the camera 113 .
[0179] The electronic device 100 implements the display function through a GPU, a display screen 114, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 114 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.
[0180] The display screen 114 is used to display images, videos, etc. The display screen 114 includes a display panel. In some embodiments, the electronic device 100 may include 1 or N display screens 114, where N is a positive integer greater than 1.
[0181] The electronic device 100 can realize the shooting function through the ISP, the camera 113, the video codec, the GPU, the display screen 114 and the application processor.
[0182] The ISP is used to process the data fed back by the camera 113. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. The ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP can be set in the camera 113.
[0183] In some embodiments, the electronic device 100 may include 1 or N cameras 113 , where N is a positive integer greater than 1.
[0184] In the embodiment of the present application, the electronic device 100 includes a target camera, that is, the N cameras include a target camera, and the target camera can be used for both collecting images and detecting ambient light.
[0185] The N cameras also include a camera for face recognition, which can wake up or unlock the screen by performing face recognition tasks.
[0186] In some implementations, the target camera is used to collect facial images during face recognition tasks and to collect ambient light parameters during ambient light detection tasks.
[0187] 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.), 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.
[0188] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 114. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 114, the electronic device 100 detects the touch operation intensity according to the pressure sensor 180A. The electronic device 100 can also calculate the touch position according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example, when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.
[0189] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 114, and the touch sensor 180K and the display screen 114 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 114. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 114.
[0190] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0191] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0192] The embodiment of the present application also provides an electronic device, which includes: one or more processors, a memory, and a computer program stored in the memory and executable on the one or more processors, wherein the one or more processors execute the computer program so that the electronic device can implement the steps in any of the above methods. The embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by the electronic device, the steps in each of the above method embodiments can be implemented.
[0193] Computer-readable media may include at least: any entity or device capable of carrying computer program codes to a camera / electronic device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk, or an optical disk. In some jurisdictions, based on legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0194] The present application embodiment provides a computer program product, which includes a computer program, and when the computer program is executed by an electronic device, the steps in the above-mentioned method embodiments can be implemented. The computer program includes computer program code, which can be in source code form, object code form, executable file or some intermediate form.
[0195] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0196] 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.
[0197] In the embodiments provided in the present application, it should be understood that the disclosed devices / equipment and methods can be implemented in other ways. For example, the device / equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as 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.
[0198] 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.
[0199] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0200] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0201] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0202] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0203] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for adjusting screen brightness, characterized in that: include: In the screen-off state, obtain the first screen-on operation; In response to the first screen-lighting operation, obtaining a camera identifier in a hardware abstraction layer of a software system of the electronic device, where the camera identifier is used to indicate a target camera corresponding to an ambient light detection function; At the hardware abstraction layer, determining a target operating mode of the target camera according to a preset priority, the operating mode of the target camera including a camera mode and an ambient light mode; When the target working mode is determined to be the ambient light mode, the target camera is started through the hardware abstraction layer, and the target camera is enabled to collect ambient light parameters in the ambient light mode, and the screen brightness is adjusted according to the collected ambient light parameters.
2. The method according to claim 1, characterized in that The preset priority is used to indicate that the priority of the camera mode of the target camera is higher than the priority of the ambient light mode of the target camera, and in the hardware abstraction layer, determining the target working mode of the target camera according to the preset priority includes: When the target camera is operating in the camera mode, determining that the target operating mode is the camera mode; or, When the target camera is not operating in the camera mode, it is determined that the target operating mode is the ambient light mode.
3. The method according to claim 1, characterized in that The step of obtaining the camera identifier at the hardware abstraction layer of the software system of the electronic device includes: In the sensor control module of the hardware abstraction layer, a function for opening the camera is called through an AIDL interface, and the camera identifier is sent to the camera control module of the hardware abstraction layer; Determining the target working mode of the target camera according to a preset priority at the hardware abstraction layer includes: Conflict and priority management is performed in the camera control module, so as to determine the target working mode according to the preset priority.
4. The method according to claim 1, characterized in that When the target camera collects ambient light parameters in the ambient light mode, the method further includes: Using the target camera to collect ambient light parameters N times at a first frame rate, where N is an integer greater than 1; After collecting the environmental sightseeing parameters N times, the target camera is used to continuously collect the environmental light parameters at a second frame rate, where the second frame rate is less than the first frame rate.
5. The method according to claim 1, characterized in that When the first screen-on operation is a face wake-up operation, determining, at the hardware abstraction layer, a target operating mode of the target camera according to a preset priority, includes: The target working mode is determined to be an ambient light mode, and after receiving the first frame ambient light parameter, the target working mode is changed to a camera mode.
6. The method according to any one of claims 1 to 5, characterized in that During the process of collecting the ambient light parameters by using the target camera, the method further includes: Creating a first thread to periodically read ambient light parameters, and marking a first flag as not stopped each time the first thread is awakened, wherein the first flag is used to indicate whether the periodically reading thread is stopped; When the first screen-off operation is obtained, in response to the first screen-off operation, the first identifier is marked as stopped, and the first thread is stopped.
7. The method according to claim 6, characterized in that When the first screen-off operation is acquired, in response to the first screen-off operation, marking the first identifier as stopped and stopping the first thread includes: When the first screen-off operation is acquired during the wake-up period of the first thread, directly stop the first thread; or, When the first screen-off operation is acquired during the dormancy of the first thread, the first thread is first awakened and then stopped.
8. An electronic device, characterized in that: The electronic device includes: one or more processors, and a memory; The memory is coupled to the one or more processors, and the memory is used to store computer program codes, wherein the computer program codes include computer instructions, and the one or more processors call the computer instructions to enable the electronic device to perform the method as claimed in any one of claims 1 to 7.
9. A chip system, characterized in that: The chip system is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions so that the electronic device executes the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium comprises instructions, which, when executed on an electronic device, cause the electronic device to perform the method as claimed in any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for adjusting brightness of display screen
CN106157926A
Shooting method and device, storage medium and computer program product
CN113645408A
Screen brightness adjusting method and adjusting device of in-vehicle infotainment system and vehicle
CN116092446A
Screen brightness adjusting method and device, storage medium and electronic equipment
CN117116203A
Intelligent screen brightness adjustment method and apparatus, and storage medium and mobile terminal
WO2019120028A1
Cited By
Method for realizing light sensation based on CMOS sensor, storage medium and electronic equipment
CN121409399A