Method for adjusting screen brightness and electronic device
By managing the camera's working mode and priority at the hardware abstraction layer, and employing a strategy of high frame rate in the early stage and low frame rate in the later stage to report ambient light parameters in a timely manner, the problem of untimely ambient light parameters in camera detection is solved, improving screen brightness adaptability and user experience.
Patent Information
- Application Number
- CN202410311491.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-14
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2044-03-14
AI Technical Summary
When using a camera to detect ambient light, the ambient light parameters are not reported in a timely manner, causing the screen brightness to be inconsistent with the actual environment, resulting in flickering and jumping of brightness, which affects the user's visual experience.
The working mode and priority of the target camera are managed separately at the hardware abstraction layer. Ambient light parameters are collected by using a high frame rate in the early stage and a low frame rate in the later stage. The thread is stopped immediately when the screen is turned off to avoid the thread running idly and ensure that the ambient light parameters of the first frame are reported in a timely manner.
It shortens the ambient light parameter reporting time, avoids flickering and jumping, improves the user's visual experience, and takes into account both low power consumption and timely reporting requirements.
Smart Images

Figure CN119252209B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of electronic devices, and in particular to a method for adjusting screen brightness and an electronic device. BACKGROUND
[0002] Currently, mobile phones, tablet computers and other electronic devices are provided with ambient light devices for detecting ambient light, and the screen brightness is automatically adjusted according to the detection of ambient light. With the development of technology, a camera with the function of detecting ambient light has appeared, so that the independent ambient light device can be removed by allowing the camera with the function of detecting ambient light to detect ambient light, thereby optimizing the overall circuit layout of the electronic device.
[0003] However, this brings new problems. In actual use, it is found that when the camera is used for ambient light detection, there is a bright and dark change in the environment, and the screen will have a bright and dark jump phenomenon when the screen is turned on again, that is, the initial brightness of the screen after the screen is turned on again is not suitable for the brightness of the actual environment of the electronic device, resulting in poor visual experience of the user. SUMMARY
[0004] The present application provides a method for adjusting screen brightness and an electronic device, which can ensure that the ambient light parameter is reported in time after the screen-on operation occurs, thereby ensuring the accuracy of the initial brightness of the screen after the screen is turned on again, and avoiding the influence of bright and dark jumps on the visual experience of the user.
[0005] In a first aspect, a method for adjusting screen brightness is provided, which comprises: in an off-screen state, obtaining a first screen-on operation; in response to the first screen-on operation, obtaining a camera identifier at 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; at the hardware abstraction layer, determining a target working mode of the target camera according to a preset priority, the working mode of the target camera including a camera mode and an ambient light mode; when the target working mode is determined as the ambient light mode, starting the target camera through the hardware abstraction layer, and causing 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 are mainly completed by calling the corresponding interface at the hardware abstraction layer, the target working mode of the target camera is determined, so that the process does not need to be executed again with the unified management of all cameras in the framework layer, the execution time is saved, the timely reporting of the ambient light parameter of the target camera is ensured, and the problem that the brightness value of the last screen-on before the screen-on operation is determined as the target brightness for screen-on, but does not match the actual environment is avoided.
[0007] In a conventional scheme of collecting ambient light by using a camera, determining the working mode of the target camera is required to be performed together with the conflict and priority management of all cameras at the framework layer, resulting in a long waiting time, causing the first frame of ambient light parameter reporting to be not timely, and the electronic device can only assign the last brightness value of the screen-on according to the last brightness value of the screen-on, which does not match the actual environment, and a bright flicker jump occurs. When the technical scheme of the present application is adopted, since the working mode of the target camera is determined at the hardware abstraction layer, the waiting time is shortened, so that the first frame of ambient light parameter can be reported in time.
[0008] In combination with the first aspect, in some 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, and when the target working mode of the target camera is determined at the hardware abstraction layer according to the preset priority, it can include: when the target camera is working in the camera mode, the target working mode is determined as the camera mode; or when the target camera is not working in the camera mode, the target working mode is determined as the ambient light mode. That is, under the premise of ensuring that the basic shooting function of the target camera is not affected, the target camera is used for ambient light detection.
[0009] In combination with the first aspect, in some implementations of the first aspect, when the camera identifier is acquired at the hardware abstraction layer of the software system of the electronic device, it can include: at the sensor control module of the hardware abstraction layer, the function of opening the camera is called through the AIDL interface, and the camera identifier is sent to the camera control module of the hardware abstraction layer; at the hardware abstraction layer, the target working mode of the target camera is determined according to the preset priority, including: the camera control module performs conflict and priority management, 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] With reference to the first aspect, in some implementations of the first aspect, when the target camera is collecting the ambient light parameter in the ambient light mode, the method further includes: collecting N times of the ambient light parameter by the target camera at a first frame rate, N being an integer greater than 1; and after collecting the N times of the ambient light parameter, continuously collecting the ambient light parameter by the target camera at a second frame rate, the second frame rate being less than the first frame rate. In this implementation, the first N frames of data are reported at a higher frame rate to shorten the cycle length of data reporting, so that the target camera reports the ambient light parameter more quickly, thereby ensuring that the first frame of ambient light data is reported in time, avoiding the use of the last screen-on brightness value due to the delay in reporting, and avoiding brightness flickering. High frame rate can result in high power consumption, but low frame rate can result in delayed reporting of the first frame of ambient light parameter, so this scheme uses a high frame rate in the early stage and a low frame rate in the later stage, balancing the requirements of low power consumption and timely reporting.
[0011] With reference to the first aspect, in some implementations of the first aspect, when the first screen-on operation is a face wake-up operation, determining the target working mode of the target camera according to the preset priority at the hardware abstraction layer can include: determining the target working mode as the ambient light mode, and changing the target working mode to the camera mode after receiving the first frame of ambient light parameter. In this implementation, when the screen-on task and face recognition (face wake-up, i.e., face screen unlocking) conflict, the target camera is first operated in the ambient light mode to obtain the first frame of ambient light parameter, and then the target camera is operated in the camera mode, thereby ensuring that the first frame of ambient light parameter is reported in time and avoiding brightness flickering, and further ensuring that the face recognition task is executed in time.
[0012] In the traditional scheme, because the priority of the camera mode is higher than that of the ambient light mode, the face unlocking is processed first after the face wake-up operation, and the resources for ambient light detection are released, and the ambient light detection is not performed until the face unlocking is completed, resulting in delayed reporting of the first frame of ambient light parameter and brightness flickering.
[0013] With reference to the first aspect, in some implementations of the first aspect, during the collection of the ambient light parameter by the target camera, the method further comprises: creating a first thread for periodic reading of the ambient light parameter, and marking the first flag as not stopping each time the first thread is woken up, the first flag being used to indicate whether the thread for periodic reading is stopped; and when the first screen-off operation is acquired, in response to the first screen-off operation, marking the first flag as stopping and stopping the first thread. In this implementation, the stopping manner of the first thread is changed from the traditional scheme of stopping when the next wake-up period comes because the first flag is marked as stopping, to directly stopping when the screen-off operation occurs. This scheme solves the problem of empty thread running in the case of frequent screen-on and screen-off by the simplest change of execution opportunity. Because of such a stopping manner in the traditional scheme, if a second screen-on operation occurs after the screen-off operation during the sleep period of the first thread, the second screen-on operation will cause the first flag to be modified as not stopping again, and a second thread will be started for data reading. Then, after the sleep period ends, the first flag read is not stopping, resulting in the first thread and the second thread both reading data after that, but the data read by the first thread is useless, equivalent to empty thread running, wasting resources. In short, for the frequent screen-on and screen-off scenario, the first thread cannot be stopped according to the traditional scheme, resulting in multiple threads reading data periodically, and the first thread running empty and wasting resources. However, by using the scheme of the present application, the first thread will be stopped immediately after the screen-off operation occurs, so the first thread cannot be stopped.
[0014] With reference to the first aspect, in some implementations of the first aspect, when the first screen-off operation is acquired, in response to the first screen-off operation, marking the first flag as stopping and stopping the first thread can comprise: when the first screen-off operation is acquired during the wake-up of the first thread, directly stopping the first thread; or when the first screen-off operation is acquired during the sleep of the first thread, first waking up the first thread and then stopping the first thread. In this implementation, when the screen-off operation is acquired during the wake-up of the first thread, it is directly stopped, and when it is acquired during the sleep, it is first woken up and then stopped.
[0015] In a second aspect, another method for adjusting screen brightness is provided, which includes: in an off-screen state, obtaining a first screen-on operation; in response to the first screen-on operation, obtaining a camera identifier at 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; at the hardware abstraction layer, determining a target working mode of the target camera according to a preset priority, the working mode of the target camera including a camera mode and an ambient light mode; when the target working mode is determined as the ambient light mode, starting the target camera through the hardware abstraction layer; collecting N times of ambient light parameters at a first frame rate by using the target camera, N being an integer greater than 1, and adjusting the screen brightness according to the collected ambient light parameters; after collecting the N times of ambient light parameters, continuously collecting ambient light parameters at a second frame rate by using the target camera, the second frame rate being less than the first frame rate, and adjusting the screen brightness according to the collected ambient light parameters.
[0016] In the technical solution of the present application, the first N frames of data are reported at a higher frame rate, the cycle length of data reporting is shortened, the target camera reports ambient light parameters more quickly, so that the first frame of ambient light data is reported in time, and the last screen-on brightness value is used due to the delay in reporting, so that the brightness flickering is avoided. High frame rate will cause high power consumption, but low frame rate will cause the first frame of ambient light parameters to be reported in time, so the solution adopts a high frame rate in the early stage and a low frame rate in the later stage, which takes into account the requirements of low power consumption and timely reporting.
[0017] In a third aspect, another method for adjusting screen brightness is provided, which includes: in an off-screen 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 at 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; at the hardware abstraction layer, determining a target working mode of the target camera as an ambient light mode; starting the target camera through the hardware abstraction layer and making the target camera collect ambient light parameters in the ambient light mode, and adjusting the screen brightness according to the collected ambient light parameters; after receiving the first frame of ambient light parameters reported by the target camera, updating the target working mode of the target camera to the camera mode at the hardware abstraction layer; starting the target camera through the hardware abstraction layer and making the target camera collect face images in the camera mode.
[0018] In the technical solution of the present application, when the screen-on task and face recognition (face wake-up, that is, face unlocking the screen) conflict, the target camera is first made to work in the ambient light mode, and after the first frame of ambient light parameters is obtained, the target camera is made to work in the camera mode, so that the first frame of ambient light parameters is reported in time, the brightness flickering is avoided, and the face recognition task can be returned to continue to be executed in time.
[0019] In the traditional scheme, because the priority of the camera mode is higher than that of the ambient light mode, the face unlocking is preferentially processed after the face wake-up operation occurs, the resources for ambient light detection are released, and the ambient light detection is not performed until the face unlocking is completed, resulting in that the first frame of ambient light parameters is not reported in time, and bright flashing jumps occur.
[0020] In a fourth aspect, another method for adjusting screen brightness is provided, which includes: in an off-screen 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 working mode of the target camera according to a preset priority, the working mode of the target camera including a camera mode and an ambient light mode; when the target working mode is determined as the ambient light mode, starting the target camera through the hardware abstraction layer, and causing 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 collection of the ambient light parameters by 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 woken up, the first identifier being used to indicate whether the periodic reading thread is stopped; when a first screen-off operation is obtained, marking the first identifier as stopped in response to the first screen-off operation, and stopping the first thread.
[0021] In the technical scheme of the present application, the stopping manner of the first thread is changed from being stopped when the next wake-up period comes and the first identifier is marked as stopped in the traditional scheme to being directly stopped when the screen-off operation occurs. This scheme solves the problem of empty thread running by changing the simplest execution opportunity. In the traditional scheme, if a second screen-on operation occurs after the screen-off operation during the sleep period of the first thread, the second screen-on operation will cause the first identifier to be modified as not stopped, and a second thread will be started for data reading. After the sleep period ends, the first identifier read is not stopped, causing the first thread and the second thread to read data after that, but the data read by the first thread is useless, which is equivalent to empty thread running and wasting resources. In short, for the frequent screen-on and screen-off scene, the first thread cannot be stopped according to the traditional scheme, multiple threads are reading data periodically, and the first thread is running empty and wasting resources. The scheme of the present application will not cause the first thread to stop, so the first thread will not stop.
[0022] In a fourth aspect, in some implementations of the fourth aspect, when the first screen-off operation is acquired, in response to the first screen-off operation, the first identifier is marked as stopped, and the first thread is stopped, including: when the first screen-off operation is acquired during the wake-up of the first thread, the first thread is directly stopped; or when the first screen-off operation is acquired during the sleep of the first thread, the first thread is first woken up, and then the first thread is stopped. In this implementation, when the screen-off operation is acquired during the wake-up of the first thread, the first thread is directly stopped, and when the screen-off operation is acquired during the sleep, the first thread is first woken up and then stopped.
[0023] In a fifth aspect, a device for adjusting screen brightness is provided, which includes a unit composed of software and / or hardware for executing any one of the methods in the first aspect to the fourth aspect.
[0024] In a sixth aspect, an electronic device is provided, which includes a memory, one or more processors, and a computer program stored in the memory and executable on the processors, 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 aspect to the fourth aspect.
[0025] In a seventh aspect, a chip is provided, which includes a processor for reading and executing a computer program stored in a memory, when the computer program is executed by the processor, the electronic device in which the chip is located is enabled to implement any one of the methods in the first aspect to the fourth aspect.
[0026] Optionally, the chip further includes a memory, which is electrically connected with the processor.
[0027] Optionally, the chip can further include a communication interface.
[0028] In an eighth aspect, a computer readable storage medium is provided, which stores a computer program, when the computer program is executed by an electronic device, any one of the methods in the first aspect to the fourth aspect can be implemented.
[0029] In a ninth aspect, a computer program product is provided, which includes a computer program, when the computer program is executed by an electronic device, any one of the methods in the first aspect to the fourth aspect can be implemented. BRIEF DESCRIPTION OF DRAWINGS
[0030] Figure 1 is a schematic diagram of the change of the screen brightness value after the environment changes and the screen is turned on again.
[0031] Figure 2 is a schematic diagram of a traditional execution framework for environment light detection using a camera.
[0032] Figure 3is a schematic diagram of an execution process of adjusting screen brightness according to an embodiment of the present application.
[0033] Figure 4 is a schematic flow chart of a method of adjusting screen brightness according to an embodiment of the present application.
[0034] Figure 5 is a schematic flow chart of another method of adjusting screen brightness according to an embodiment of the present application.
[0035] Figure 6 is a schematic diagram of an execution process of periodically reading an ambient light parameter in a conventional scheme.
[0036] Figure 7 is a schematic diagram of an execution process of periodically reading an ambient light parameter according to an embodiment of the present application.
[0037] Figure 8 is a conflict diagram of a face recognition task and an ambient light detection task.
[0038] Figure 9 is a schematic diagram of an execution process of acquiring an ambient light parameter according to an embodiment of the present application.
[0039] Figure 10 is a schematic diagram of thread idling caused by frequent screen turning on and off.
[0040] Figure 11 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0041] The scheme of the embodiments of the present application will be described below with reference to the accompanying drawings.
[0042] Figure 1 is a schematic diagram of a change of a screen brightness value after the screen is turned on again after the environment changes. Figure 1 Take a process as an example, in which a user uses an electronic device in sunlight outdoors, then the user turns off the screen of the electronic device and walks into a dark room, and then turns on the screen of the electronic device again. Figure 1 As shown in (a) of FIG. 10, the user uses the electronic device in sunlight outdoors, and the brightness of the screen of the electronic device is 90%. After the electronic device performs a screen-off operation, the electronic device is in a black screen state, as shown in (b) of FIG. 10. Figure 1 The screen-off operation can be performed in response to a user pressing a screen-off mechanical button, or can be performed based on no operation on the electronic device within a preset time length in automatic screen-off, or can be performed based on a user operation on a lock screen touch control, and there is no limitation. It is assumed that the user walks into a room indoors, for example, a dark room. After entering the dark room, the electronic device is still in a black screen state, as shown in (c) of FIG. 10. Figure 1As shown in (c). Assume the user performs a screen-on operation, such as pressing the screen-on mechanical button or using facial recognition for unlocking; there are no specific limitations. Triggered by this screen-on operation, the electronic device lights up its screen, as shown... Figure 1 As shown in (d). However, at this point, the screen brightness is 90% when the screen is on, but then it is updated to 30% as the ambient light detection continues, as shown in (d). 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 is initially very bright before returning to normal brightness, which is a flickering phenomenon. This causes a glaring sensation for the user when the screen is turned on, affecting the user's visual experience.
[0044] Figure 1 Electronic devices can be portable devices such as mobile phones and tablets that can automatically adjust screen brightness.
[0045] against Figure 1 The phenomenon shown was analyzed and found to be caused by the electronic device using a camera for ambient light detection. The flickering occurred because the screen was not using the actual ambient light parameters when it was turned on again, but rather the brightness value from the last time the screen was turned on. Figure 1 The ambient light parameters used in (d) are Figure 1 (a) The brightness value during the last screen-on operation before the screen-off operation resulted in an excessively high brightness value compared to a dark room. Further analysis revealed that the actual ambient light parameters were not used to adjust the screen brightness because the ambient light detection data was not reported in a timely manner after the screen was turned on again. This caused the electronic device to directly use the brightness value from the last screen-on operation before the screen went black. Further analysis revealed that the electronic device used a camera for ambient light detection. Before the camera could perform ambient light detection, it needed to perform some preparatory work, especially requiring relevant modules in various structural layers of the electronic device's software system to be ready. If the preparatory work was delayed for a long time, the ambient light parameters could not be reported in a timely manner after the screen-on operation. For traditional independent ambient light detection devices, so many modules are not required and the preparatory work time is very short. Therefore, the failure to report in a timely manner does not occur and is not within the scope of this application.
[0046] In view of the problem of current camera-based ambient light detection solutions that data reporting is not timely, resulting in the screen being able to only use the last brightness value of the last screen-on when the screen is on again, which does not match the actual environment, causing user visual discomfort. The present application provides a new screen brightness adjustment solution, by moving the operation 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 in the hardware abstraction layer, rather than being managed together with the camera functions of other cameras in the framework layer, thereby effectively shortening the time delay, ensuring that the first frame of ambient light parameters can be reported in time, and avoiding the use of the last screen-on brightness value due to untimely reporting. In short, the present application solution hopes that when it is executed, the situation shown in (d) of Figure 1 will not occur, but after the screen-on operation shown in (c) of Figure 1 , it can directly display the brightness value that matches the actual environment shown in (e) of Figure 1 .
[0047] Figure 2 is a schematic diagram of a traditional execution framework for ambient light detection using a camera. To facilitate understanding, the software system of the electronic device is first described. The software system is installed in the electronic device and 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 used by the software system can be a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. The present application embodiment takes the Android system with a layered architecture as an example to exemplarily describe the software structure of the electronic device. The Android system can be divided into four layers, from top to bottom, application layer, framework layer (Framework, FWK), hardware abstraction layer (Hardware Abstraction Layer, HAL), and kernel layer.
[0048] The application layer can include a series of applications, such as camera, calendar, map, WLAN, music, short message, gallery, call, ambient light detection, face unlock, etc., for direct interaction with the user. These applications can be system built-in applications or non-system level applications. These applications can have icons and application interfaces, or can have application interfaces without icons, or can have neither icons nor application interfaces.
[0049] The framework layer includes some pre-defined functions, which can provide an application programming interface (API) and a programming framework for the applications in the application layer. The application programming interface provided by the framework layer can include a camera service related interface, a sensor service related interface, and other service related interfaces. Different service related interfaces can be defined as different service modules, for example, the sensor service related interface can be defined as a sensor service module, the camera service related interface can be defined as a camera service module, and the other service related interface can be defined as another service module, and the like.
[0050] The hardware abstraction layer is located between the framework layer and the kernel layer, and the purpose is to abstract the hardware. The hardware abstraction layer hides the hardware interface details of a specific platform, provides a virtual hardware platform for the software system, and makes it hardware independent, which can be ported on multiple platforms.
[0051] The kernel layer is a layer between hardware and software. The kernel layer can include a display driver, a camera driver, an audio driver, a sensor driver, and the like, and through these drivers, a display screen, a front / rear camera, an audio player, a sensor, and the like can be driven.
[0052] As Figure 2As shown, the sensor service module in the framework layer can include sub-modules such as SensorManager, SensorSerivce, etc. In the scheme of detecting ambient light by using the camera, the SensorManager is configured to adjust the brightness of the display screen of the electronic device according to the detected ambient light brightness. The SensorSerivce is configured to realize the communication between the related applications in the application layer which need to call the sensor and the Sensor HAL. Alternatively, the sensor service module can be a separate process, and the SensorManager and the SensorSerivce can be two threads in the process. The camera service module includes sub-modules such as ICameraSerivce, CameraSerivce, etc. The CameraService is configured to realize the communication between the applications in the application layer which need to call the camera (for example, the camera application, the face unlocking application, the ambient light detection application, etc.) and the Camera HAL. Alternatively, the camera service module can be a separate process, and the ICameraSerivce and the CameraSerivce can be two threads in the process. The electronic device is provided with multiple cameras, the multiple cameras cannot be enabled at the same time, and different functions of the same camera also 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 problem of the enabling priority of different functions of the multiple cameras, in the scheme of detecting ambient light by using the camera, 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 than two camera functions need to be enabled at the same time, the judgment logic can be used to enable one of them.
[0053] In the hardware abstraction layer, according to the implemented functions, 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 a separate process, and the sensor control module can also be a separate process. To implement the ambient light detection function of the front camera, the sensor control module (Sensor HAL) is modified in the scheme of detecting ambient light using a camera. Specifically, an ambient light service control submodule (i.e. the CameraLightManager described in the subsequent embodiments) is added to the sensor control module, which provides multiple interfaces, including an Active interface, a DeActive interface, etc. 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 detecting ambient light using a camera. Specifically, a camera function customization submodule (i.e. the 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. 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 detector, 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 screen brightness of the electronic device. CHI-CDK is a customizable code implementation set. In the scheme of detecting ambient light using a camera, AIDL (Android Interface Definition Language) service initialization related code is added to the original code implementation set of CHI-CDK, so that different processes (such as Sensor HAL and Camera HAL) in the electronic device can communicate with each other. AIDL is used to define the interface between the client and the server of the Binder communication-based Android system. Binder is a cross-process communication mechanism of the Android system, which allows different processes to communicate with each other, and even communicate across devices.The CAMX is a code implementation set of a general functional interface. In the scheme of detecting ambient light by using a camera, the Open Camera function in the original code implementation set in the CAMX is modified based on the original code implementation set in the CAMX. A logic branch that can skip the configuration of a front camera resource is added. Therefore, when the front camera is used as an ambient light detection device, the process of configuring the front camera resource can be skipped, the power consumption of the front camera is reduced, and the performance of the electronic device is improved.
[0054] The camera service module controls the opening and closing of the target camera by issuing instructions to the camera control module (Camera HAL). In the scheme of an independent ambient light detection device, the sensor service module controls the opening and closing of the ambient light detection device by issuing instructions to the sensor control module (Sensor HAL). However, in the scheme of detecting ambient light by using a camera, the opening and closing of the target camera needs to be controlled by the instructions issued by the sensor service module. However, since the sensor control module cannot pass the instructions issued by the sensor service module to the target camera (not in the same running 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 through the camera service module. Since the sensor control module at the HAL layer is an independent process, and the camera service module at the FWK layer is also an independent process, when establishing the control path between the sensor control module at the HAL layer and the camera service module at the FWK layer, the establishment is based on HIDL service. HIDL is used to define the interface between the HAL layer and the FWK layer of the Android system based on Binder communication. After the control path between the sensor control module and the camera service module is opened, a data path between the sensor control module and the camera control module also needs to be established. Therefore, after the ambient light detection function of the target camera is opened, the camera control module transmits the ambient light parameters detected by the target camera to the sensor control module, and then the sensor control module sends the ambient light parameters to the sensor service module, so as to realize the adjustment of the brightness of the display screen.
[0055] In the scheme, the camera control module (i.e., Camera HAL) can be an independent process, which can be defined as a camera control process, and the sub-modules (such as CHK-CDK, CAMX, CamxLightCustom, etc.) included in the camera control module can be different threads in the camera control process. AIDL service initialization can be a process of starting the AIDL service. By initializing the AIDL service, communication between the AIDL service-based client and server can be achieved. AIDL service initialization can be performed in the camera control module, specifically, in CHK-CDK of the camera control module. The AIDL service can be initialized during the booting process of the electronic device, or after the booting process based on the need for communication between the AIDL service-based client and server. The process of AIDL service initialization can correspond to Figure 2 Step 1 in Figure 2 When the electronic device is booted, the AIDL service in CHI-CDK of Camera HAL is initialized, which can be starting the AIDL service.
[0056] It should be noted that the AIDL service is used to realize communication between different processes. For two processes based on AIDL service communication, one process is used to generate data and can be an AIDL server; the other process is used to issue control instructions and receive data and can be an AIDL client.
[0057] Then, the sensor service module sends a brightness monitoring instruction to the Sensor HAL Figure 2 Step 2 in After receiving the brightness monitoring instruction, the Sensor HAL calls the Active based on the AIDL service, registers a data callback function in the Camera HAL Figure 2 Step 3 in The Sensor HAL calls the libcamera2ndk_vendor interface based on the HIDL service, sends a logical camera identifier to the camera service module Figure 2 Step 4 in The camera service module calls the Open Camera function in CAMX of Camera HAL through CameraService, executes the Open Camera function, sends control instructions to the camera driver through the interface of CamxLightCustom, 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 Step 5 in 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 2(Step ⑥) and then the sensor control module sends it to the sensor service module, which adjusts the brightness of the electronic device's display screen based on this.
[0058] It should be noted that cameras typically include two types: front-facing cameras and rear-facing cameras, with at least one front-facing camera and at least one rear-facing camera. Furthermore, both front-facing and rear-facing cameras have multiple functions, including at least one of the following: photo taking, face unlock, and ambient light detection. To distinguish between different types of cameras and different functions of the same type of camera, this application embodiment abstracts multiple logical cameras based on their type and function, with each logical camera corresponding to an identifier. For example, based on the photo taking function of the front-facing camera, logical camera A can be abstracted; based on the ambient light detection function of the front-facing camera, logical camera B can be abstracted. Logic camera A and logical camera B can correspond to the same front-facing camera or different front-facing cameras. For logical camera A, i.e., the photo taking function of the front-facing camera, the identifier is set as Camera ID = 1; for logical camera B, i.e., the ambient light detection function of the front-facing camera, the identifier is set as Camera ID = 4.
[0059] It should also be understood that in a solution that uses a camera to detect ambient light, when the target camera is used in place of the 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 flow shown, because a camera management link is superimposed on the original ambient light detection link, starting the camera requires a lot of preparation work at the FWK layer, such as conflict and priority management. Since the FWK layer manages all cameras uniformly, this process is relatively lengthy. As technology advances and camera functions become more sophisticated, management will only become more complex. Furthermore, if the camera has many initialization registers, this preparation time will also be extended. This results in a significant time elapsed after receiving the instruction from step ④ and determining that the target camera needs to operate in ambient light detection mode. This causes the reporting deadline for the first frame of ambient light parameters to be missed, forcing the electronic device to use the last brightness value to turn on the screen, resulting in a mismatch with the actual ambient brightness.
[0061] Furthermore, modifications to the FWK layer are subject to strict testing requirements, making it difficult to upgrade the solution in the future, and the solution may also affect product testing requirements.
[0062] In view of the problems in the above scheme, the application optimizes the above scheme with as few changes as possible. The preparation work performed in the FWK layer is converted to be performed in the HAL layer, and the function of detecting ambient light by using the camera is separately managed in the HAL layer in terms of conflict and priority. Such optimization does not affect the management of other cameras and other camera functions in the FWK layer, and makes the ambient light detection function no longer depend on and adapt to the unified management of the FWK layer for all camera functions, shortens the waiting time, ensures the timely reporting of the first frame of ambient light parameters, and thus solves the bright flashing jump problem after the screen is turned on again.
[0063] Figure 3 is a schematic diagram of an execution process of adjusting screen brightness in an embodiment of the application. Figure 3 The steps in Figure 2 are the same as those in Figure 2 The related content will not be repeated. As shown in Figure 3 , the camera service module in the FWK layer in Figure 2 is removed, a camera conflict and priority management module is added in CAMX in the Camera HAL, for managing the two functions (camera function and ambient light detection function) of the target camera, and a switch interface module, that is, an Open / Close interface, is added in the Camera HAL, for confirming the logical camera identifier (that is, the camera identifier) of the target camera. After receiving an Open Camera instruction sent from the Active, the Open / Close interface sends the instruction 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, the camera conflict and priority management module performs subsequent steps such as thread creation. As can be seen, Figure 3 Step 4 in Figure 2 is moved down to be performed in the HAL layer alone, instead of being performed together with the unified management of all cameras in the FWK layer. After such optimization, the preparation work that must be performed in the FWK layer is saved, the time length of the entire execution process is shortened, and the timeliness of data reporting is ensured.
[0064] Figure 4 is a schematic flowchart of a method for adjusting screen brightness in an embodiment of the application. The following describes each step in Figure 4 . The method can be applied to electronic devices such as mobile phones, tablet computers, and notebook computers.
[0065] S401, in a screen-off state, a first screen-on operation is acquired.
[0066] The first screen-on action can be a user-input interaction to turn on the screen, or it can be another action such as waking up an alarm. The user-input interaction to turn on the screen can be the user pressing the mechanical button to turn on the screen, or it can be a face unlock operation (face wake-up operation), etc., there are no restrictions.
[0067] S402, In response to the first screen-on operation, obtain the camera identifier in the hardware abstraction layer of the software system of the electronic device. The camera identifier is used to indicate the target camera corresponding to the ambient light detection function.
[0068] The target camera can be Figure 2 and Figure 3 The target camera, which is the camera capable of ambient light detection, can be a front-facing camera or a rear-facing camera. This application primarily uses a front-facing camera as an example.
[0069] For other cameras, the camera identifier indicates which camera it is. For the target camera, since it has two functions, each function corresponds to a separate camera identifier, which is the logical camera identifier mentioned above. For example, suppose an electronic device has a front-facing camera and two rear-facing cameras. The front-facing camera has two operating modes: camera mode and ambient light mode. Therefore, the camera mode of the front-facing camera can be associated with camera identifier #1, the two rear-facing cameras with camera identifiers #2 and #3 respectively, and the ambient light mode of the front-facing camera with camera identifier #4. Then, after obtaining the current camera identifier of the target camera, this camera identifier could be either camera identifier #1 or camera identifier #4, thus indicating whether the operating mode is camera mode or ambient light mode, respectively.
[0070] It should be understood that the corresponding camera and function cannot be known before the meaning of the camera identifier is deciphered, but the camera identifier can be used to indicate the target camera for ambient light detection.
[0071] In one implementation, when obtaining the camera identifier at the hardware abstraction layer (HAL) of the electronic device's software system, the process may include: the sensor control module at the HAL calling a function to open the camera via an AIDL interface, sending the camera identifier to the camera control module at the HAL; and at the HAL, determining the target operating mode of the target camera according to a preset priority, including conflict and priority management in the camera control module to determine the target operating mode according to the preset priority. This implementation provides an example of how the target operating mode is determined, achieved through the cooperation of the sensor control module and the camera control module, calling appropriate interfaces.
[0072] S403, determining a target working mode of the target camera according to a preset priority at the hardware abstraction layer, the working mode of the target camera including a camera mode and an ambient light mode.
[0073] That is, the working mode of the target camera is managed at the HAL layer, and according to the camera identifier, it is determined which working mode the target camera needs to adopt currently based on the preset priority. 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, starting the related modules of the target camera in the camera mode, collecting image data by using the target camera, and at the same time, closing the related modules in the ambient light mode, that is, releasing the resources corresponding to the ambient light mode; when the camera identifier indicates the ambient light mode, starting the related modules of the target camera in the ambient light mode, collecting ambient light parameters by using the target camera, and at the same time, closing the related modules in the camera mode, that is, releasing the resources corresponding to the camera mode, and no longer outputting images.
[0074] The camera identifier can be reported to the camera control module in the form of calling a function of an AIDL interface, so as to determine the target working mode.
[0075] In an implementation manner, the AIDL interface includes functions of opening and closing the camera, that is, OpenCamera function and CloseCamera function, and the corresponding opening and closing interfaces (Open / Close interfaces) of the CamxLightCustom module in the camera control module (Camera HAL) are called through the AIDL interface, and then the CAMX module is called, and the conflict and priority management are performed in the CAMX module, so as to confirm the current working mode of the target camera. This process can be implemented by using the following code, for example, the OpenCamera function and the CloseCamera function are called 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] In Figure 2In the conflict management shown in the scheme, when the target camera is opened, the camera identifier of the camera mode of the target camera is CameraID=1, and the camera identifier of the ambient light mode of the target camera is CameraID=4. After the CameraID is obtained, when the electronic device does not include the camera identifier of the ambient light mode, that is, the target camera does not have 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, the target camera has the function of the ambient light mode, the CameraID is first judged, whether m_perCameraInfo[logicalCameraId].isCameraOpened is true, if true, the ambient light CameraID is first closed, the resources are released, after the closing is completed, the target camera is started according to the camera mode, if not true (that is, false), the target camera is directly started according to the camera mode. In Figure 2 In the conflict management shown in the scheme, when the target camera is closed, the CameraID in conflict with the ambient light cameraID is obtained through the tag, if the CameraID being closed is equal to the CameraID in conflict, the ambient light cameraID needs to be re-opened after the closing process of the CameraID being closed is completed, otherwise no processing is performed. The above conflict management can be performed in the CAMX module shown. Figure 3
[0082] The above process can be implemented by the following code, for example.
[0083]
[0084] In an implementation mode, 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 when the target working mode of the target camera is determined according to the preset priority in the hardware abstraction layer, it can include: when the target camera is working in the camera mode, the target working mode is determined as the camera mode; or when the target camera is not working in the camera mode, the target working mode is determined as the ambient light mode. That is, on the premise of ensuring that the basic shooting function of the target camera is not affected, the ambient light detection is performed by using the target camera.
[0085] In an implementation, when the first screen-on operation is a face wake-up operation, the target working mode of the target camera is determined according to a preset priority at the hardware abstraction layer, which can include: determining the target working mode as the ambient light mode, and changing the target working mode to the camera mode after receiving the first ambient light parameter. In this implementation, when the screen-on task and the face recognition (face wake-up, that is, face screen unlocking) conflict, the target camera is first caused to work in the ambient light mode to obtain the first ambient light parameter, and then the target camera is caused to work in the camera mode, so as to ensure timely reporting of the first ambient light parameter and avoid bright flashing jumps, and in addition, the face recognition task can be continued to be executed in time.
[0086] In the conventional scheme, because the priority of the camera mode is higher than that of the ambient light mode, the face recognition is processed preferentially after the face wake-up operation occurs, the resources for ambient light detection are released, and the ambient light detection is not performed until the face recognition is completed, which causes the first ambient light parameter to be reported in time and bright flashing jumps to occur.
[0087] S404, when the target working mode is determined as the ambient light mode, the target camera is started through the hardware abstraction layer, and the target camera is caused 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 works in the ambient light mode, the ambient light parameters are obtained. When the ambient light parameters are obtained, they can be obtained periodically, for example, data can be reported once every 400 milliseconds (ms), but it should be understood that the specific value is not limited.
[0089] It should be understood that because steps S403 and S404 are both executed at the HAL layer, the ambient light parameters reported by the target camera are reported in time (that is, the first ambient light parameter is reported early enough), so the last brightness value can be avoided. For the ambient light detection link, the first ambient light parameter needs to be reported to the sensor service module within 200 ms after the screen-on operation occurs. If the reporting is not successful within 200 ms, the brightness value of the last screen-on operation is assigned. That is, the sensor service module has a time limit for reporting the first ambient light parameter of the ambient light. When the target camera cannot report within the reporting time limit of the first ambient light parameter of the sensor service module, the sensor service module will change the screen-on operation according to the brightness value of the last screen-on operation before the first screen-on operation.
[0090] In an implementation, during the collection of the ambient light parameter by the target camera, the method further comprises: creating a first thread for periodic reading of the ambient light parameter, and marking a first identifier as not stopping each time the first thread is woken up, the first identifier being used to indicate whether the thread for periodic reading is stopped; and 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. In this implementation, the stopping manner of the first thread is changed from the traditional scheme of stopping when the next wake-up period comes because the first identifier is marked as stopped, to directly stopping when the screen-off operation occurs. This scheme solves the problem of the empty thread running when the screen is frequently turned on and off, with the simplest change of the execution opportunity. Because of such stopping manner in the traditional scheme, if a second screen-on operation occurs after the screen-off operation during the sleep period of the first thread, the second screen-on operation will cause the first identifier to be modified as not stopping again, and a second thread will be started for data reading. Then, after the sleep period ends, the first identifier read is not stopping, causing the first thread and the second thread to read data after that, but the data read by the first thread is useless, equivalent to an empty thread running, wasting resources. In short, for the frequent on-off screen scenario, the first thread cannot be stopped according to the traditional scheme, multiple threads are running for periodic data reading, and the first thread is running empty, wasting resources. However, by using the scheme of the present application, the first thread will be stopped immediately after the screen-off operation occurs, so the first thread cannot be stopped.
[0091] In one example, 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 can comprise: when the first screen-off operation is acquired during the wake-up period of the first thread, directly stopping the first thread; or when the first screen-off operation is acquired during the sleep period of the first thread, first waking up the first thread and then stopping the first thread. In this implementation, when the screen-off operation is acquired during the wake-up period of the first thread, it is directly stopped, and when it is acquired during the sleep period, it is first woken up and then stopped.
[0092] Figure 4 The scheme shown mainly determines the target working mode of the target camera by calling the corresponding interface in the hardware abstraction layer to complete the conflict and priority management of the working mode of the target camera, so that the process does not need to be executed again with the unified management of all cameras in the framework layer, saving the execution time, ensuring the timely reporting of the ambient light parameter of the target camera, and avoiding the problem that the brightness value of the last screen-on before the screen-on operation is determined as the target brightness for screen-on, which does not match the actual environment.
[0093] Figure 5 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 a description of the method in combination with the system structure. Figure 4
[0094] S501, the sensor control module (sensor HAL) performs a flag bit determination.
[0095] Here refers to the determination of the registration flag bit for 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 is successful, if it is not true (false), it means that it has not been registered, at this time, the registration of step S502 needs to be performed.
[0096] S502, the sensor control module registers the ambient light detection function to the camera control module (Camera HAL).
[0097] The registration can be performed by Active, calling the AIDL interface, and the registration function can call RegisterLuxCallback.
[0098] After the power is turned on, steps S501 and S502 are performed for registration, after the registration, the Camera HAL can send the ambient light parameter to the sensor HAL through the callback. However, it should be understood that the registration only needs to be performed once, and it is not necessary to perform the registration every time when the ambient light parameter needs to be read. That is to say, steps S501 and S502 do not need to be performed after every screen-on event (screen-on operation), but only need to be performed once after the power is turned on, and then they can be used all the time.
[0099] S503, the sensor service module of the framework layer reports the screen-on event to the sensor HAL after receiving the screen-on event.
[0100] The screen-on event is the screen-on operation, for example, the first screen-on operation described above. The screen-on event can be an operation on a corresponding control or key, can be a face recognition, that is, a face wake-up (face unlocking) operation, or can be a wake-up after the alarm rings, and there is no limitation.
[0101] S504, the sensor control module sends the camera identifier corresponding to the ambient light detection service to the camera control module.
[0102] The camera identifier is used to represent the identifier of the camera capable of detecting ambient light, but it should be understood that, specifically, it is the identifier of the ambient light mode of the camera capable of detecting ambient light, for example, it can be CameraID=4 in the above.
[0103] The camera identifier can be obtained by calling the function int OpenCamera(in int cameraFwkID) through the AIDL interface, and the camera identifier is sent to the camera control module.
[0104] S505, the camera control module performs conflict and priority management.
[0105] The conflict and priority management is mainly to confirm whether the target camera can work in the ambient light mode, perform ambient light detection, or continue to work in the camera mode. It should be understood that, for the target camera, the conflict and priority management is mainly to confirm whether the target camera can work in the ambient light mode, perform ambient light detection, or continue to work in the camera mode. Figure 2 As shown in the scheme, the conflict and priority management at the FWK layer is the unified management of all logical cameras, but for the target camera, the conflict and priority management is only performed on the target camera (target camera), and therefore the time length of this step can be effectively shortened, and the first frame of ambient light parameters can be timely reported. Figure 5 As shown in the scheme, the conflict and priority management at the FWK layer is the unified management of all logical cameras, but for the target camera, the conflict and priority management is only performed on the target camera (target camera), and therefore the time length of this step can be effectively shortened, and the first frame of ambient light parameters can be timely reported.
[0106] S506, the camera control module starts the target camera.
[0107] Before starting the target camera, it is necessary to judge whether the target camera supports the ambient light detection function, and to confirm that the target camera is started in the ambient light mode.
[0108] S507, the camera control module sends a command to start the target camera to the camera driver.
[0109] S508, the camera driver is powered on and the register is initialized.
[0110] During ambient light detection, the camera does not need to output image data, so it does not need to be configured with a buffer corresponding to the image data, so the register initialized here is only used for the ambient light parameter collection process.
[0111] S509, the camera driver cyclically reads the ambient light parameters collected by the target camera.
[0112] The cycle period is also the reading period, that is, data is read once every certain reading time interval. It should also be understood that the frame rate in the foregoing is used to set the length of the reading period. For example, assuming that the frame rate is 30 frames / s, the reading period (reading time interval or reading interval) is 10 ms. When the reading period comes, data is read once, and then the periodic reading thread enters sleep, and after the sleep period (that is, the reading period) ends, it is woken up again to read data once, and so on, and the reading is cyclically performed.
[0113] S510, the camera cyclically sends the ambient light parameters collected by the target camera to the camera control module in the form of callback.
[0114] That is, each time the ambient light parameter is read, it is sent to the camera control module.
[0115] S511, the camera control module sends the brightness value to the sensor control module by callback.
[0116] The brightness value here can be understood as a target brightness, that is, it is desired to turn on the screen according to the brightness value.
[0117] It should be understood that step S511 is also executed each time the ambient light parameter is 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 only participates in reporting the screen-on event and receiving the target brightness value, and other steps are executed in the HAL layer, so as to control the camera driver to collect the ambient light parameter, and ensure that the ambient light parameter is reported in time.
[0120] Figure 6 is a schematic diagram of the execution process of the periodic reading of the ambient light parameter in a conventional scheme. Figure 6 The scheme of periodically reading the ambient light parameter in Figure 2 is carried out in the execution process shown in Figure 6 As shown in
[0121] From the camera to obtain the original brightness (lux rawdata) to output the ambient light parameter needs a certain integration time, which leads to the first reading may read the original brightness, rather than the integrated ambient light parameter after completion, the data is not accurate enough, so that the first frame of ambient light parameter is inaccurate, and then the screen brightness is not accurate. In order to read the accurate value, it is still necessary to wait for 400ms. This leads to even if the first frame of ambient light parameter is reported successfully, there may still be inaccurate conditions, so during the 400ms waiting for the next reading, the screen brightness is an inaccurate brightness value. If the first frame is not reported successfully, the next reading will be performed after waiting for 400ms, and the first frame of ambient light data requires to be reported successfully within 200ms. If the first frame is not reported successfully, the last screen-on brightness value will be directly used. The above two situations may cause the screen brightness to not match the actual ambient brightness, and the visual experience is poor.
[0122] To solve the above problems, the application adopts a double frame rate reading mode, a higher frame rate is used to read the first few frames, and then a low frame rate is used to read, so as to ensure fast reading of the first few frames, and accurate ambient light parameters can be quickly obtained, and a low frame rate is used to reduce power consumption.
[0123] The application provides another method for adjusting screen brightness, which comprises: in an off-screen 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 working mode of the target camera according to a preset priority, the working mode of the target camera comprising a camera mode and an ambient light mode; when the target working mode is determined as the ambient light mode, starting the target camera through the hardware abstraction layer; collecting N times of ambient light parameters by using the target camera 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 N times of ambient light parameters, continuously collecting ambient light parameters by using the target camera 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] The scheme mainly reports the first N frames of data at a higher frame rate, shortens the cycle length of data reporting, and makes the target camera report the ambient light parameters more quickly, so as to ensure that the first frame of ambient light data is reported in time, avoid the situation that only the brightness value of the last screen-on is used due to the delay in reporting, and avoid brightness flickering. High frame rate will cause high power consumption, but low frame rate will easily cause the first frame of ambient light parameters to be reported in time, so the scheme adopts a high frame rate in the early stage and a low frame rate in the later stage, and takes into account the two requirements of low power consumption and timely reporting.
[0125] The execution process of the periodic reading of ambient light parameters in the method will be described below with respect to Figure 7 , that is, Figure 7 The above amplification can be regarded as an example of the process of reading N frames at a first frame rate and reading subsequent frames at a second frame rate.
[0126] Figure 7 is a schematic diagram of the execution process of the periodic reading of ambient light parameters in an embodiment of the application. Figure 7 The scheme for periodically reading ambient light parameters in Figure 3 is performed in the execution process shown in Figure 7As shown, when the ambient light brightness reading and calculation in step ⑤ are performed in a loop, the first N frames are read using a 10 ms reading interval (30 frames per second (fps) frame rate), and then the subsequent frames are read using a 400 ms reading interval (5 fps frame rate). 30 fps can be regarded as an example of a first frame rate, and 5 fps can be regarded as an example of a second frame rate. N can be a suitable value such as 3 or 5.
[0127] However, it should be understood that other suitable values can also be set in actual use, for example, the first 4 frames can be collected at a frame rate of 20 frames per second, and the 5th frame can be collected at a frame rate of 3 frames per second, and the like, without limitation.
[0128] Figure 8 is a conflict diagram of the face recognition task and the ambient light detection task. As shown in Figure 8 , on the basis of the steps shown in Figure 3 , when the face recognition task passes step ⑦ and uses the CameraService to obtain an event of opening the target camera, a conflict occurs because the target camera is also used to collect ambient light. When the camera conflict and priority management are performed, because the priority of the camera mode is higher than that of the ambient light mode, step ⑧ is executed to close the ambient light detection camera ID, that is, the resources in the ambient light mode of the target camera are closed, which causes the ambient light detection task to be closed before it is completed, the first-frame ambient light parameter reporting fails, and the electronic device directly uses the brightness value of the last screen-on to perform screen-on without waiting for the ambient light parameter for 200 ms, which causes the screen brightness to be unable to use the accurate brightness value, resulting in screen brightness flickering and jumping.
[0129] In view of the Figure 8 problem shown, the application provides an optimization scheme, which modifies the release resource flag (identifier) only after the first-frame ambient light parameter is successfully received to ensure that the resources for ambient light detection are not released too early to cause the first-frame ambient light parameter to be missing, thereby avoiding screen brightness flickering and jumping caused by the ambient light parameter reporting not being timely.
[0130] The application provides another method for adjusting screen brightness, which comprises the following steps: in an off-screen 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 for indicating a target camera corresponding to an ambient light detection function; in the hardware abstraction layer, determining a target working mode of the target camera as an ambient light mode; starting the target camera in the hardware abstraction layer and enabling the target camera to collect an ambient light parameter in the ambient light mode, and adjusting the screen brightness according to the collected ambient light parameter; after receiving a first ambient light parameter reported by the target camera, updating the target working mode of the target camera as a camera mode in the hardware abstraction layer; starting the target camera in the hardware abstraction layer and enabling the target camera to collect a face image in the camera mode.
[0131] In this scheme, when the screen-on task and the face recognition (face wake-up, that is, face screen unlocking) conflict, the target camera is first enabled to work in the ambient light mode, and then the target camera is enabled to work in the camera mode after the first ambient light parameter is obtained, so that the reporting of the first ambient light parameter is ensured to be timely, and the bright flashing jump is avoided, and in addition, the face recognition task can be returned to be executed in time.
[0132] Figure 9 FIG. 1 is a schematic diagram of an execution process for obtaining an ambient light parameter according to an embodiment of the application. Figure 9 In the case shown in FIG. 1, the face recognition task and the ambient light detection task are triggered to be executed at the same time, which causes a conflict. However, it should be understood that Figure 9 The scene shown in FIG. 1 needs to be that the face recognition and the ambient light detection are both executed by the target camera, and the conflict will not occur if two independent cameras are used to perform the face recognition and the ambient light detection respectively. Since the front camera and the screen are in the same direction, the front camera is generally used for face recognition, and the purpose of the ambient light detection is to adjust the screen brightness. Therefore, the front camera can be preferentially used for the ambient light detection, and after the two preferred schemes are superimposed, the front camera needs to perform image collection for the face recognition task and ambient light parameter collection for the ambient light detection task, which causes a conflict.
[0133] S901, the camera service module of the framework layer sends a request for opening the camera to the camera control module of the hardware abstraction layer.
[0134] In the request, the camera mode of the target camera is requested to be opened, and Camera ID=1.
[0135] In a possible case, the execution of step S901 can be triggered under the operation of a face-unlocking screen or a face-waking screen, in which operation, not only the face recognition task is to be performed to unlock or wake up the screen, but also the ambient light detection task is to be performed to adjust the screen brightness.
[0136] S902, conflict and priority management is performed at the camera control module, and the ambient light mode of the target camera (Camera ID=4) is closed.
[0137] In the conflict and priority management, since the priority of the camera mode of the target camera is higher than that of the ambient light mode, it is determined that the target working mode is the camera mode, and at this time, the ambient light mode needs to be closed to release the resources of the ambient light mode.
[0138] S903, it is judged whether the release resource identifier of the ambient light mode of the target camera is true, if true, the resources of the ambient light mode are released, and if false, the resources are not released.
[0139] The release resource identifier can be the identifier of the release resource function ReleaseCamLightProcess.
[0140] In the conventional scheme, the operation of modifying the identifier to true is performed when step S902 is executed, so that when step S903 is executed, the read release resource identifier is true. However, in the scheme shown in FIG. 8, when step S902 is executed, the release resource identifier is not modified, so the release resource identifier is still false, and therefore when step S903 is executed, since false is read, the resources are not released. Figure 9
[0141] S904, the camera driver periodically reports the ambient light parameter to the camera control module.
[0142] The related content of periodically reading the ambient light parameter can be referred to the above, and will not be repeated here.
[0143] S905, the camera control module sets the release resource identifier to true after receiving the first frame of ambient light parameter.
[0144] The release resource identifier is modified to true only after the first frame of ambient light parameter is obtained.
[0145] S906, the camera control module sends the brightness value to the sensor control module through callback.
[0146] The introduction of the same step can be referred to the above, and will not be repeated here.
[0147] S907, the sensor control module sends the luminance value to the sensor service module.
[0148] The above steps can be referred to the description of the above steps, and will not be repeated.
[0149] It should also be understood that step S903 will wait after judging false, but the waiting is also time-limited, so it will be judged again when the time limit is reached, and when it is judged again, it is true due to the execution of step S905, and the resources are released.
[0150] Figure 9 It can be executed in the process shown in Figure 3 or the process shown in Figure 4 It can be understood that when the first screen-on operation is face wake-up, both face recognition task and ambient light detection task are needed to turn on the screen, but because the camera mode (Camera ID = 1) has higher priority than the ambient light mode (Camera ID = 4), the resources of Camera ID = 4 are released, and the face recognition task is executed first. The ambient light parameter reporting fails, and the electronic device will directly use the brightness value of the last screen-on to turn on the screen, causing the brightness to jump. Therefore, the scheme shown in Figure 9 only releases the resources after the first frame of ambient light parameter reporting is successful, and then executes the face recognition task. The release of resources includes releasing the buffer and closing the ambient light detection function of the camera.
[0151] In an implementation manner, the first frame of ambient light parameter reporting can be ensured to be successful before the resources are released by adding a semaphore operation in the release resource function ReleaseCamLightProcess. The ambient light parameter or the 40ms timeout can be waited for first, and if the ambient light parameter is marked as true, it means that the first frame of ambient light parameter has been reported successfully, and the subsequent release can be performed. In order to prevent blocking, that is, waiting for the reporting of the ambient light parameter all the time, a 40ms waiting time limit is set, and when the 40ms is exceeded, the subsequent release is performed.
[0152] The above process can be implemented by using the following code, for example.
[0153]
[0154] In the thread of reading the first frame of ambient light parameter, when the first frame of ambient light parameter is read, mValidValueArrived is set to true, which informs the resource of the ambient light mode of the target camera that it can release. The release resource function ReleaseCamLightProcess can be informed to execute. In ReleaseCamLightProcess, the flag mValidValueArrived of the first frame of ambient light parameter is read first. When it is read to be true, release is continued.
[0155] The above process can be implemented by the following code, for example.
[0156]
[0157] Figure 10 is a schematic diagram of frequent screen on and off causing thread to run empty. When the screen is frequently turned on and off, a reading data thread is created every time the screen is turned on. When the screen is quickly turned on and off, there is a probability that the thread runs empty, which affects the performance of ambient light data reporting and power consumption. Figure 10 As shown in the figure, at the nth time of screen on, the flag (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 to false are almost simultaneously executed. After thread 1 reads data once, it enters sleep and waits for a sleep period to end before the next reading. A sleep period is a reading time interval, that is, a reading period, which can be 400 ms, for example.
[0158] However, in this sleep period, the nth screen off occurs, so that the flag of the reading thread is set to true (stop). If there is no subsequent nth+1 screen on, it will wait for the sleep period to end, and the next reading will stop thread 1 when the flag is true. However, in this sleep period, the nth+1 screen on occurs, so that the flag of the reading thread is set to false again. Therefore, for thread 1, at the end of a sleep period, the next reading will read the flag to be false, which will not stop thread 1. Since thread 2 is created at the same time as the nth+1 screen on, two threads are periodically reading data, which affects performance and causes unnecessary power consumption.
[0159] To solve the above problem, an optimization scheme is provided, which quickly wakes up thread 1 and then stops thread 1 at the nth screen off.
[0160] The application provides another method for adjusting screen brightness, which comprises: in an off-screen 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 working mode of the target camera according to a preset priority, the working mode of the target camera comprising a camera mode and an ambient light mode; when the target working mode is determined as the ambient light mode, starting the target camera through the hardware abstraction layer, and enabling the target camera to collect an ambient light parameter in the ambient light mode, and adjusting the screen brightness according to the collected ambient light parameter; during the collection of the ambient light parameter by the target camera, creating a first thread (for example, thread 1) for periodic reading of the ambient light parameter, and marking a first identifier (for example, mThreadTerminate) as not stopping each time the first thread is woken up, the first identifier being used to indicate whether a thread for periodic reading is stopped; and when a first screen-off operation is obtained, marking the first identifier as stopped in response to the first screen-off operation, and stopping the first thread.
[0161] The scheme mainly modifies the stopping mode of the first thread from the traditional scheme of stopping when the next wake-up period comes because the first identifier is marked as stopped, to directly stopping when the screen-off operation occurs. The scheme solves the problem of empty thread running by changing the simplest execution opportunity. In the traditional scheme, if a second screen-on operation occurs after the screen-off operation during the sleep period of the first thread, the second screen-on operation will cause the first identifier to be modified as not stopping, and a second thread will be started for data reading. After the sleep period ends, the first identifier read is not stopping, which causes the first thread and the second thread to read data after that, but the data read by the first thread is useless, which is equivalent to empty thread running and wasting resources. In short, for the frequent screen-on and screen-off scene, the first thread cannot be stopped according to the traditional scheme, multiple threads are running for periodic data reading, and the first thread is running empty and wasting resources. The scheme of the application will not cause the first thread to stop because the first thread will be stopped immediately after the screen-off operation occurs.
[0162] In an implementation mode, when the first screen-off operation is obtained, the first identifier is marked as stopped in response to the first screen-off operation, and the first thread is stopped, comprising: when the first screen-off operation is obtained during the wake-up period of the first thread, the first thread is directly stopped; 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 the implementation mode, the first thread is directly stopped when the screen-off operation is obtained during the wake-up period of the first thread, and the first thread is woken up first and then stopped when the screen-off operation is obtained during the sleep period.
[0163] In one implementation, the following code can be executed by the ReleaseCamLightProcess function to implement the fast wake-up thread 1.
[0164]
[0165] In another implementation, the following code can be used to implement the fast stop of the reading thread by adding a semaphore judgment during the reading waiting (i.e., the sleep) and receiving a stop semaphore.
[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 embodiments of the present application in combination with the drawings. It should be understood that although each step in the flowchart involved in each of the above embodiments is displayed in sequence, these steps are not necessarily executed in sequence as shown in the figure. Unless explicitly stated herein, the execution of these steps has no strict sequence limitation, and these steps can be executed in other sequences. Moreover, at least a part of the steps in the flowchart involved in each of the above embodiments can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least a part of other steps or steps or stages in other steps. The device of the embodiments of the present application is introduced below in combination with the drawings.
[0170] Figure 11 is a schematic diagram of the hardware structure of an electronic device of the embodiments of the present application. As shown in Figure 11As shown, the electronic device 100 can 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, and the like. Among them, the sensor module 180 can include a pressure sensor 180A, a touch sensor 180K, and the like.
[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 can be understood that the structure shown in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than shown, or combine certain components, or split certain components, or different component arrangements. The components shown can be implemented in hardware, software, or a combination of software and hardware.
[0173] Exemplarily, Figure 11 The processor 110 shown can include one or more processing units, for example: the processor 110 can include an application processor (AP), a modem processor, a graphics processing unit (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), and the like. Among them, different processing units can be independent devices, or can be integrated in one or more processors.
[0174] Among them, the controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to instruction operation codes and timing signals to complete the control of fetching instructions and executing instructions.
[0175] The processor 110 can also include memory that stores instructions and data. In some embodiments, the memory in the processor 110 is cache memory. The cache memory can hold instructions or data recently used or frequently used by the processor 110. If the processor 110 needs to use the instructions or data again, it can directly call the instructions or data from the cache memory. This avoids repeated access and reduces the waiting time of the processor 110, thereby improving the efficiency of the system.
[0176] In some embodiments, the processor 110 can include one or more interfaces. The interfaces can 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 that includes a serial data line (SDA) and a serial clock line (SCL). The processor 110 can include multiple sets of I2C bus. The processor 110 can be coupled to the touch sensor 180K, the charger, the flash, the camera 113, etc. through different I2C bus interfaces, respectively. For example, the processor 110 can be coupled to the touch sensor 180K through an I2C interface, so that the processor 110 and the touch sensor 180K communicate through the I2C bus interface, and realize the touch function of the electronic device 100.
[0178] In some embodiments, the MIPI interface can be used to connect the processor 110 and the display screen 114, the camera 113, and other peripheral devices.
[0179] The electronic device 100 implements a display function through a GPU, a display screen 114, and an application processor, etc. The GPU is a microprocessor for image processing, connected to the display screen 114 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 can include one or more GPUs that 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 can include 1 or N display screens 114, N being a positive integer greater than 1.
[0181] The electronic device 100 can implement a shooting function through an ISP, a camera 113, a video codec, a GPU, a display screen 114, and an application processor, etc.
[0182] The ISP is used to process data fed back by the camera 113. For example, when taking a photo, the shutter is opened, the light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing to convert it into an image visible to the naked eye. The ISP can also optimize the algorithm for 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 arranged in the camera 113.
[0183] In some embodiments, the electronic device 100 can include 1 or N cameras 113, N being a positive integer greater than 1.
[0184] In the embodiments of the present application, the electronic device 100 includes a target camera, that is, the target camera is included in the N cameras and can be used to collect images and detect ambient light.
[0185] The N cameras also include a camera for face recognition, which performs screen wake-up or screen unlocking, etc. through the face recognition task.
[0186] In some implementations, the target camera is used to collect face images when performing a face recognition task and to collect ambient light parameters when performing an ambient light detection task.
[0187] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 performs 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 can include a program storage area and a data storage area. The program storage area can store an operating system, at least one application program (such as a sound playing function, an image playing function, etc.) required by a function, etc. The data storage area can store data (such as audio data, a phone book, etc.) created during the use of the electronic device 100, etc. In addition, the internal memory 121 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0188] The pressure sensor 180A is used to sense a pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be disposed on the display screen 114. There are many types of pressure sensors 180A, such as a resistive pressure sensor, an inductive pressure sensor, a capacitive pressure sensor, etc. The capacitive pressure sensor can include at least two parallel plates with conductive material. When a force is applied to 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 is applied to the display screen 114, the electronic device 100 detects the intensity of the touch operation according to the pressure sensor 180A. The electronic device 100 can also calculate the position of the touch according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations applied to 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 a first pressure threshold is applied to a short message application icon, an instruction to view a short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold is applied to the short message application icon, an instruction to create a new short message is executed.
[0189] The touch sensor 180K, also referred to as a "touch panel". The touch sensor 180K can be disposed on the display screen 114, and the touch sensor 180K and the display screen 114 form a touch screen, also referred to as a "touch panel". The touch sensor 180K is used to detect a touch operation applied thereto or in the vicinity thereof. The touch sensor can transmit the detected touch operation to the application processor to determine the touch event type. 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 disposed on the surface of the electronic device 100, which is different from the position where the display screen 114 is located.
[0190] It should be noted that the information interaction, execution process and the like between the above apparatuses / units are based on the same concept as the method embodiments of the present application, and specific functions and brought technical effects can be referred to the method embodiments part, which will not be described here.
[0191] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or software function unit. In addition, the specific name of each functional unit and module is only for easy distinction, and does not limit the protection scope of the present application. The specific working process of the unit and module in the system can refer to the corresponding process in the foregoing method embodiments, which will not be described here.
[0192] The embodiment of the present application also provides an electronic device, which comprises one or more processors, a memory, and a computer program stored in the memory and executable on the one or more processors, and the one or more processors execute the computer program to enable the electronic device to implement the steps in any of the foregoing methods. The embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and the computer program is executed by an electronic device to implement the steps in each of the foregoing method embodiments.
[0193] The computer-readable medium can at least include any entity or device capable of carrying a computer program code to a photographing device / electronic device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunications signal, and a software distribution medium. For example, a U disk, a mobile hard disk, a magnetic disk or an optical disk, etc. In some jurisdictions, according to legislation and patent practice, the computer-readable medium cannot be an electrical carrier signal and a telecommunications signal.
[0194] The embodiment of the present application provides a computer program product, which comprises a computer program, and when the computer program is executed by an electronic device, the steps in each of the foregoing method embodiments can be implemented. The computer program comprises computer program code, which can be in the form of source code, object code, an executable file or some intermediate form.
[0195] In the above embodiments, the description of each embodiment is focused on, and the parts not described or recorded in a certain embodiment can be referred to the relevant description of other embodiments.
[0196] Those skilled in the art can understand that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. Professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0197] In the embodiments provided in the present application, it should be understood that the disclosed apparatuses / devices and methods can be implemented in other ways. For example, the above-described apparatus / device embodiments are only schematic. The division of the modules or units is only a logical function division, and there can be another division manner in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between the units can be indirect couplings or communication connections through some interfaces, devices or units, and can be electrical, mechanical or in other forms.
[0198] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e. they can be located in one place, or distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiments.
[0199] It should be understood that when used in the specification and the appended claims of the present application, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or sets thereof.
[0200] It should also be understood that the term "and / or" used in the specification and the appended claims of the present application means any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.
[0201] In addition, in the description of the specification and the appended claims of the present application, the terms "first", "second", "third" and the like are only used to distinguish the description, and cannot be understood as indicating or implying relative importance.
[0202] Reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the application. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" or "in a various embodiment" or "in some embodiment" or "in other embodiments" in various places throughout this specification are not necessarily all referring to the same embodiment, but can refer to one or more of the same or different embodiments. Furthermore, the term "comprising" or "containing" or "including" or "having" or "characterized by" as used herein encompasses the presence of stated features, steps or components or integers, but does not preclude the presence or addition of one or more other features, steps, components or integers. The term "consisting essentially of" or "consisting of" as used herein exclude the presence of other features, steps, components or integers.
[0203] The above embodiments are only used to illustrate the technical solutions of the present application, but not limit the present application; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it still can modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. A method of adjusting screen brightness, characterized by, Comprising: In the off-screen state, obtaining a first screen-on operation; In response to the first screen-on operation, obtaining a camera identifier at 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; At the hardware abstraction layer, determining a target working mode of the target camera according to a preset priority, the working mode of the target camera including a camera mode and an ambient light mode; When the target working mode is determined as the ambient light mode, starting the target camera through the hardware abstraction layer, and causing the target camera to collect an ambient light parameter in the ambient light mode, and adjusting the screen brightness according to the collected ambient light parameter.
2. The method of claim 1, wherein, 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 the determining the target working mode of the target camera at the hardware abstraction layer according to the preset priority comprises: When the target camera is working in the camera mode, determining the target working mode as the camera mode; or, When the target camera is not working in the camera mode, determining the target working mode as the ambient light mode.
3. The method of claim 1, wherein, The obtaining the camera identifier at the hardware abstraction layer of the software system of the electronic device comprises: At a sensor control module of the hardware abstraction layer, sending the camera identifier to a camera control module of the hardware abstraction layer through a function of opening a camera by an AIDL interface call. The determining the target working mode of the target camera at the hardware abstraction layer according to the preset priority comprises: Performing conflict and priority management at the camera control module, so as to determine the target working mode according to the preset priority.
4. The method of claim 1, wherein, When the target camera collects the ambient light parameter in the ambient light mode, the method further comprises: Collecting N times of ambient light parameters by the target camera at a first frame rate, N being an integer greater than 1; After collecting N times of ambient light parameters, continuously collecting ambient light parameters by the target camera at a second frame rate, the second frame rate being less than the first frame rate.
5. The method of claim 1, wherein, When the first screen-on operation is a face wake-up operation, the determining the target working mode of the target camera at the hardware abstraction layer according to the preset priority comprises: Determining the target working mode as the ambient light mode, and changing the target working mode to the camera mode after receiving a first ambient light parameter.
6. The method according to any one of claims 1 to 5, characterized in that, During the collecting the ambient light parameter by the target camera, the method further comprises: Creating a first thread for periodic reading of the ambient light parameter, and marking a first identifier as not stopping each time the first thread is woken up, the first identifier being used to indicate whether the thread for periodic reading is stopped; When a 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.
7. The method of claim 6, wherein, The marking the first identifier as stopped and stopping the first thread in response to the first screen-off operation when the first screen-off operation is obtained comprises: When the first screen-out operation is acquired during the wake-up of the first thread, the first thread is directly stopped; or When the first screen-out operation is acquired during the sleep of the first thread, the first thread is first woken up, and then the first thread is stopped.
8. An electronic device, comprising: The electronic device comprises one or more processors and a memory; The memory is coupled to the one or more processors, and the memory is configured to store computer program codes, the computer program codes comprising computer instructions, and the one or more processors are configured to invoke the computer instructions to cause the electronic device to perform the method according to any one of claims 1 to 7.
9. A chip system, characterized by The chip system is applied to an electronic device, and the chip system comprises one or more processors configured to invoke computer instructions to cause the electronic device to perform the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium comprises instructions configured to cause an electronic device to perform the method according to any one of claims 1 to 7 when the instructions are executed on the electronic device.
Citation Information
Patent Citations
Screen brightness adjusting method and device, storage medium and electronic equipment
CN117116203A
Screen brightness adjustment method and apparatus, and storage medium and electronic device
WO2024045829A1