Method and device for determining interface electric quantity, electronic equipment and storage medium
By reading from the target storage partition when the electronic device is started and saving the interface power of the last shutdown in the shared memory, and determining the interface power to be displayed at the kernel layer, the problem of interface power jump when the electronic device is started is solved, and display efficiency and kernel security are improved.
Patent Information
- Application Number
- CN202311169781.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-11
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2043-09-11
AI Technical Summary
When the electronic device is started, the power of the displayed interface may jump, causing trouble to the user.
During the resource preload phase of the device startup process, the interface power of the last shutdown is read from the target storage partition and written to shared memory. During the kernel startup phase, the interface power is read from the shared memory through the kernel layer to determine the interface power to be displayed.
It avoids the interface power jump when electronic devices are started, improves the interface power display efficiency, and enhances the security of the kernel layer.
Smart Images

Figure CN119597376A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of battery technology, and in particular to a method, device, electronic device and storage medium for determining interface power. Background Art
[0002] At present, in order to better monitor the battery status in electronic devices, a fuel meter (such as a fuel meter chip outside the battery, etc.) is usually used to monitor the battery power. Since the fuel meter has a certain probability of jumping during the process of monitoring the battery power, especially when the electronic device is shut down and restarted, the monitored power is prone to jump. If the interface power displayed by the electronic device is consistent with the monitored power of the fuel meter, the displayed interface power will jump, causing trouble to the user. Therefore, how to prevent the interface power of the electronic device from jumping has become a technical problem that needs to be solved urgently. Summary of the invention
[0003] The embodiments of the present application disclose a method, device, electronic device and storage medium for determining interface power, which can prevent the interface power displayed on the electronic device from jumping when starting up, avoid causing trouble to the user, and improve the display efficiency of the interface power.
[0004] The present application discloses a method for determining interface power, which is applied to electronic equipment. The method includes:
[0005] In the resource preloading stage of the device startup process, the first interface power is read from the target storage partition, and the first interface power is written into the shared memory; the first interface power is the interface power displayed by the display device when the electronic device was shut down for the last time; the shared memory is the memory space shared with the kernel layer in the resource preloading stage;
[0006] In the kernel startup phase, the power level of the first interface is read from the shared memory through the kernel layer, and the power level of the second interface to be displayed is determined according to the power level of the first interface.
[0007] The embodiment of the present application discloses a device for determining interface power, which is applied to electronic equipment, and the device includes:
[0008] A power reading module is used to read the first interface power from the target storage partition during the resource preloading stage of the device startup process, and write the first interface power into the shared memory; the first interface power is the interface power displayed by the display device when the electronic device was shut down for the last time; the shared memory is the memory space shared with the kernel layer during the resource preloading stage;
[0009] The power determination module is used to read the power of the first interface from the shared memory through the kernel layer during the kernel startup phase, and determine the power of the second interface to be displayed according to the power of the first interface.
[0010] An embodiment of the present application discloses an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor implements the method described above.
[0011] An embodiment of the present application discloses a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method described above is implemented.
[0012] The method, device, electronic device and storage medium for determining interface power disclosed in the embodiment of the present application, in the resource preloading stage of the device startup process, read the first interface power from the target storage partition, and write the first interface power into the shared memory, the first interface power is the interface power displayed by the display device when the electronic device was shut down for the last time, in the kernel startup stage, read the first interface power from the shared memory through the kernel layer, and determine the second interface power to be displayed according to the first interface power. In the embodiment of the present application, when the electronic device is shut down, the first interface power displayed by the display device can be saved to the target storage partition, and when the device is started, the first interface power is read from the target storage partition, and the second interface power to be displayed is determined by using the first interface power, which can avoid the situation where the interface power displayed jumps when the electronic device is shut down and then started, avoiding causing trouble to the user, and in the resource preloading stage of the device startup process, the first interface power stored in the target storage partition is read, and then passed to the kernel layer through the shared memory, without waiting for the user space process to load, reducing the hysteresis of reading the first interface power, and improving the display efficiency of the interface power. In addition, the kernel layer does not directly interact with the target storage partition, which improves the security of the kernel layer. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0014] Figure 1A This is an application scenario diagram of a method for determining interface power in an embodiment;
[0015] Figure 1B A system architecture diagram of an operating system in an electronic device in one embodiment;
[0016] Figure 2 is a flow chart of a method for determining interface power in one embodiment;
[0017] Figure 3 is a flow chart of a method for determining interface power in another embodiment;
[0018] Figure 4 A flowchart of determining the power of a second interface to be displayed according to the power of a first interface in an embodiment;
[0019] Figure 5 is a block diagram of a device for determining interface power in one embodiment;
[0020] Figure 6 FIG. 4 is a structural block diagram of an electronic device in an embodiment. DETAILED DESCRIPTION
[0021] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0022] It should be noted that the terms "including" and "having" and any variations thereof in the embodiments of the present application and the accompanying drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices.
[0023] It is understood that the terms "first", "second", etc. used in this application can be used in this article to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from another element. For example, without departing from the scope of this application, the first interface charge can be referred to as the second interface charge, and similarly, the second interface charge can be referred to as the first interface charge. Both the first interface charge and the second interface charge are interface charges, but they do not indicate the same interface charge. The term "plurality" used in this application refers to two or more. The term "and / or" used in this application refers to one of the schemes, or any combination of multiple schemes.
[0024] The fuel gauge has a certain probability of jumping when monitoring the battery power, especially when charging is almost completed or the electronic device is shut down and restarted, the monitored power is prone to jump, such as jumping from 96% to 100%, or from 4% to 0%. There may be many reasons for the jump of the power monitored by the fuel gauge, such as the jump caused by the smoothing calculation of the internal algorithm of the fuel gauge. When the battery voltage is lower than a certain voltage threshold, the internal algorithm of the fuel gauge will accelerate the smoothing calculation, but the processor polls the power detected by the fuel gauge at a fixed time period. If the fuel gauge is smoothed too fast within a time period, it will cause the power read by the processor to jump; for example, the fuel gauge has a calculation error, which causes the power to jump, etc.
[0025] Therefore, the interface power displayed by the electronic device in the interface needs to be smoothed to ensure that the interface power does not jump but changes continuously. In the case where the electronic device is shut down and then restarted, in order to avoid the difference between the interface power displayed after the electronic device is started and the interface power when it was shut down before, causing trouble to the user, in the relevant technology, the interface power before shutdown will be saved to the RTC (Real_Time Clock) register of the PMIC (Power Management IC) through the kernel driver, and the saved interface power will be read from the RTC register and displayed when the device is turned on, so as to ensure that the interface power displayed after the electronic device is started is consistent with the interface power when it was shut down before.
[0026] However, not all PMICs of electronic devices have RTC registers, which makes this solution not very universal. In addition, if the interface power is stored in the RTC register, if the PMIC chip loses power, the data in the RTC register will be lost, which poses a certain risk.
[0027] The embodiments of the present application disclose a method, device, electronic device and storage medium for determining interface power, which can avoid jumps in the interface power displayed when the electronic device is started, avoid causing trouble to the user, and improve the display efficiency of the interface power. The solution is highly versatile and can avoid data loss.
[0028] Figure 1A FIG. 1 is an application scenario diagram of a method for determining interface power in an embodiment. Figure 1AAs shown, the method for determining the interface power can be applied to an electronic device 10, which may include but is not limited to a mobile phone, a wearable device, a vehicle-mounted terminal, a tablet computer, a PC (Personal Computer), a PDA (Personal Digital Assistant), etc. The electronic device 10 may include a display device, which may be a display screen, etc. The display device may be used to display a UI (User Interface) interface.
[0029] The display device of the electronic device 10 can display the interface power 110 in the interface, and the interface power 110 can be used to indicate the remaining available power of the battery in the electronic device 10, so as to facilitate the user to know the remaining available power of the battery. In an embodiment of the present application, the electronic device 10 can read the first interface power from the target storage partition during the resource preloading stage of the device startup process, and write the first interface power into the shared memory. The first interface power can be the interface power displayed by the display device when the electronic device 10 was last shut down. The shared memory is a memory space shared with the kernel layer during the resource preloading stage. During the kernel startup stage, the electronic device 10 can read the first interface power from the shared memory through the kernel layer, and determine the second interface power to be displayed based on the first interface power.
[0030] For example, Figure 1B FIG. 1 is a system architecture diagram of an operating system in an electronic device in an embodiment. Figure 1B As shown, taking the operating system of the electronic device as the Android system as an example, the operating system may include an application layer, an application framework layer, a system library and a kernel layer.
[0031] The application layer can include a series of application packages, such as camera, calendar, map, music and other applications.
[0032] The application framework layer provides application programming interface (API) and programming framework for the applications in the application layer; the application framework layer may include window manager, content provider, view system, phone manager, resource manager, notification manager, etc. Among them, the window manager is used to manage window programs, such as the window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc.; the content provider is used to store and obtain data and make these data accessible to applications; the view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc.; the phone manager is used to provide communication functions for electronic devices. For example, the management of call status (including connected, hung up, etc.); the resource manager provides various resources for applications, such as localized strings, icons, pictures, video files, etc.; the notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages.
[0033] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for the scheduling and management of the Android system. The core library is used to provide the function functions that the Java language needs to call and the Android core library, while the application layer and application framework layer run in the virtual machine.
[0034] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0035] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
[0036] Now combined Figure 1BThe system architecture diagram shown in the figure illustrates an embodiment of the present application. The power module driver (or charging module driver) of the kernel layer can determine the interface power to be displayed, and report the interface power to be displayed to the application layer (hereinafter referred to as the application layer), and the application layer displays the interface power through the user interface. When the electronic device is shut down, the application layer can respond to the shutdown instruction, obtain the first interface power currently displayed by the display device, and store the first interface power in the target storage partition. In the resource preloading stage of the device startup process of the electronic device, the first interface power can be read from the target storage partition, and the first interface power can be written to the shared memory. In the kernel startup stage, the power module driver (or charging module driver) will be initialized, and the initialized power module driver (or charging module driver) can read the first interface power from the shared memory, and determine the second interface power to be displayed according to the first interface power, and then report the second interface power to be displayed to the application layer, and display the second interface power in the user interface of the application layer.
[0037] It should be noted that Figure 1B The system architecture diagram shown in the figure is only used to illustrate the embodiment of the present application. The operating system of the electronic device may also be other operating systems or other system architectures, and is not limited to Figure 1B The system architecture is shown.
[0038] like Figure 2 As shown, in one embodiment, a method for determining the interface power is provided, which can be applied to the above electronic device, and the method may include the following steps:
[0039] Step 210, during the resource preloading stage of the device startup process, the first interface power is read from the target storage partition, and the first interface power is written into the shared memory.
[0040] The device startup process of an electronic device may refer to starting part or all of the operating system of the electronic device. Optionally, the device startup process may be the process of starting the entire operating system of the electronic device, such as the power-on process of the electronic device, etc. Optionally, the device startup process may also be the process of starting part of the operating system of the electronic device. For example, when the electronic device is in a shutdown state, if you want to realize the power display of shutdown charging when charging the electronic device, you need to start the part of the operating system process. Furthermore, the device startup process needs to start at least the kernel layer in the operating system and the target process running in the user space, and the target process can be used to realize the interface power display.
[0041] The device startup process may include the resource preloading stage, the kernel startup stage, and the user space process startup stage. Among them, the resource preloading stage is before the kernel startup stage. In the resource preloading stage (preload stage), some hardware modules of the electronic device (such as input and output systems, power management integrated circuits, etc.) can be initialized to establish the most basic operating environment; the kernel startup stage refers to the stage of starting the kernel layer, and the driver in the kernel layer will be loaded and initialized in the kernel startup stage; the user space process startup stage refers to the stage of starting the user space service process.
[0042] As a specific implementation, when the electronic device is powered on, the device starts up and the preload image file can be loaded into SRAM (Static Random-Access Memory) first, and then the resource preloading stage can be entered. In the resource preloading stage, the DRAM (Dynamic Random Access Memory) can be initialized, and then the kernel is loaded through the initialized DRAM, and then the kernel starts up and the kernel layer is started using the set kernel parameters. Among them, powering on the electronic device means that the power supply supplies power to the electronic device so that the electronic device can run some or all of the functional modules. The power supply can be a battery inside the electronic device, or a charging device (such as an adapter, etc.) connected to the electronic device.
[0043] During the resource preloading stage of the device startup process, the first interface power level can be read from the target storage partition, and the first interface power level can be the interface power level displayed by the display device when the electronic device was last shut down. Furthermore, the last time the electronic device was shut down can refer to shutting down the entire operating system of the electronic device. The first interface power level can be the interface power level displayed by the display device when the power source (including batteries and connected charging devices, etc.) stopped supplying power to the electronic device for the last time before the electronic device was powered on.
[0044] When the electronic device is shut down, the power level of the first interface displayed at the time of shutdown can be stored in the target storage partition, which can be a designated storage partition in the non-volatile memory. The target storage partition can be used only to store the displayed interface power level, or can be used to store the displayed interface power level and other battery-related data, such as battery temperature, battery charging current, charging voltage and other data, but not limited to this. The first interface power level is stored in the target storage partition, and the target storage partition does not have the problem of data loss due to chip power failure, which can avoid data loss. Almost all electronic devices are equipped with non-volatile memory, so the whole solution is more versatile and the whole function is more stable.
[0045] Optionally, in the resource preloading stage, data stored in the target storage partition in the non-volatile memory may be directly read to obtain the first interface power, and the first interface power is written into the shared memory.
[0046] The shared memory may be a memory space shared by the resource preloading stage and the kernel layer. The resource preloading stage and the kernel layer may both access the shared memory, and the shared memory may be used to implement data transmission between the resource preloading stage and the kernel layer. In some embodiments, the memory address of the shared memory may be preconfigured. During the resource preloading stage of the device startup process, after the memory is initialized, the shared memory may be accessed according to the memory address, and the power of the first interface may be written into the shared memory.
[0047] Step 220, during the kernel startup phase, the power level of the first interface is read from the shared memory through the kernel layer, and the power level of the second interface to be displayed is determined according to the power level of the first interface.
[0048] After entering the kernel startup phase of the device startup process, the power level of the first interface can be read from the shared memory through the kernel layer, and the power level of the second interface to be displayed can be determined through the kernel layer based on the power level of the first interface. As a specific implementation, the power module driver (or charging module driver) can be initialized during the kernel startup phase. The power module driver (or charging module driver) may include a power update submodule, which can be used to detect the real battery of the battery, and update or adjust the displayed interface power level and other functions. In the process of initializing the power module driver (or charging module driver), if the power update submodule is run, the power level of the first interface can be read from the shared memory, and the power level of the second interface to be displayed can be determined based on the power level of the first interface.
[0049] The power level of the second interface to be displayed may be the same as the power level of the first interface, or may be different from the power level of the first interface. In some embodiments, a power level display rule may be pre-set, and the power level of the second interface to be displayed may be determined according to the power level display rule. Optionally, the power level display rule may include but is not limited to one or more of the following:
[0050] (1) The power level of the first interface is directly determined as the power level of the second interface to be displayed.
[0051] (2) Compare the power level on the first interface with the actual power level of the battery. If the power level on the first interface differs greatly from the actual power level of the battery, it indicates that the power level on the first interface is inaccurate. The actual power level of the battery can be determined as the power level on the second interface to be displayed, so as to improve the accuracy of the power level on the displayed interface. If the power level on the first interface differs little from the actual power level of the battery, it indicates that the power level on the first interface is relatively accurate. In order to avoid a jump in the power level on the displayed interface when the electronic device is started, the power level on the first interface can be determined as the power level on the second interface to be displayed.
[0052] (3) Determine the time between the current device startup process and the last shutdown process. If the time is long, it means that the power level on the first interface is inaccurate. Then the actual power level of the battery can be determined as the power level on the second interface to be displayed, so as to improve the accuracy of the displayed interface power level. If the time is short, the power level on the first interface can be determined as the power level on the second interface to be displayed, so as to ensure that the power level on the interface displayed when the device was last shut down is consistent with that on the current device startup process, thus avoiding causing trouble to the user.
[0053] In some embodiments, the kernel layer may report the determined second interface power to be displayed to the application layer, and display the second interface power through the user interface of the application layer. After the target process in the user space is started, the kernel layer may pass the second interface power to the target process, and the target process controls the user interface to display the second interface power.
[0054] In the related art, it is usually the service process in the user space that reads the power of the first interface from a specific storage partition and then passes it to the kernel layer. The kernel layer determines the power of the interface to be displayed and then reports the power of the interface to be displayed to the application layer for display. However, the service process in the user space is started late in the device startup process, so the determination of the interface power can only be carried out after the service process in the user space is started. In the embodiment of the present application, the power of the first interface is read in the resource preloading stage of the device startup process and passed to the kernel layer through the shared memory. In the kernel startup stage, the power of the second interface to be displayed can be determined by the kernel layer. There is no need to wait for the service process in the user space to start and then read the power of the first interface by the service process and pass it to the kernel layer, which reduces the lag in reading the power of the first interface and improves the efficiency of determining and displaying the interface power.
[0055] In an embodiment of the present application, when the electronic device is shut down, the power of the first interface displayed by the display device can be saved in the target storage partition, and when the device is started, the power of the first interface is read from the target storage partition, and the power of the second interface to be displayed is determined by using the first interface power, which can avoid the situation where the displayed interface power jumps when the electronic device is shut down and then started again, avoiding causing trouble to the user, and in the resource preloading stage of the device startup process, the power of the first interface stored in the target storage partition is read, and then passed to the kernel layer through shared memory, without waiting for the process of the user space to load, reducing the lag of reading the power of the first interface and improving the display efficiency of the interface power. In addition, the kernel layer does not directly interact with the target storage partition, which improves the security of the kernel layer.
[0056] like Figure 3 As shown, in another embodiment, a method for determining the interface power is provided, which can be applied to the above electronic device, and the method may include the following steps:
[0057] Step 302, in response to the shutdown instruction, obtaining the first interface power level currently displayed by the display device.
[0058] When an electronic device detects that it needs to shut down, it can generate a shutdown command, which can be used to control the entire operating system of the electronic device to shut down. It should be noted that shutting down the electronic device may mean that there is no power supply to the electronic device and the operation of any functional module in the electronic device is not supported.
[0059] In some embodiments, the electronic device may generate a shutdown instruction when a shutdown operation is detected. The shutdown operation may include but is not limited to the user touching a key button, detecting the user's voice instructing shutdown, detecting a shutdown gesture, etc. Optionally, the shutdown operation may also include disconnecting the electronic device from the charging device (such as unplugging the charging device) when the electronic device is in the process of being shut down for charging, etc.
[0060] In some embodiments, the electronic device may also automatically generate a shutdown instruction according to the set shutdown rules. For example, when it detects that the actual battery power is less than a power threshold (such as 2% power, 3% power, etc.), it may automatically generate a shutdown instruction; or, when the set shutdown time period (such as 2 am to 5 am, etc.) is reached, a shutdown instruction may be automatically generated.
[0061] The electronic device can respond to the shutdown command and shut down. As a specific implementation, when the electronic device shuts down, the application layer first executes the shutdown process. The application layer can obtain the first interface power currently displayed by the display device before shutting down, and store the first interface power to the target storage partition. Optionally, the target process running in the user space can obtain the interface power most recently reported by the kernel layer as the first interface power currently displayed by the display device, and write the first interface power to the target storage partition.
[0062] Step 304: store the first interface power into the target storage partition according to the defined first data structure.
[0063] The first data structure may be a predefined data structure for updating the interface power stored in the target storage partition, and the first data structure may include at least one or more power display parameters, and a power display parameter may be used to characterize a variable attribute related to the interface power. For example, the first data structure may be as follows:
[0064]
[0065] Among them, Xxx represents other target parameters, Uisoc_tag is used to indicate the legality of the stored interface power. For example, when the value of Uisoc_tag is "uisoc", it means that the stored interface power is legal; Uisoc_value is used to indicate the specific interface power.
[0066] In some embodiments, the first data structure may also define the arrangement order of each power display parameter, and the data stored in the target storage area may be arranged according to a certain byte order. The arrangement order of each power display parameter defined in the first data structure may match the arrangement order of the storage data corresponding to the power display parameter in the target storage area, and the number of bytes occupied by the storage data corresponding to each power display parameter may be the same or different.
[0067] As an optional implementation, the first data currently stored in the target storage partition can be read from the target storage partition, the first data can be parsed according to the defined first data structure to obtain the power display parameter, and then the value of the power display parameter can be updated according to the first interface power to obtain the second data, and the second data can be written to the target storage partition.
[0068] The target storage partition can be used to store data corresponding to multiple target parameters related to the battery. Each target parameter can represent a variable attribute related to the battery. The multiple target parameters can at least include the above-mentioned power display parameters, and can also include other parameters, such as battery temperature parameters, charging voltage parameters when the battery is charged, charging current parameters and other parameters. The target storage partition can store data corresponding to each target parameter respectively. Optionally, the first data structure can include the multiple target parameters. The multiple target parameters contained in the first data structure can correspond one to one with the data type of the data stored in the target storage partition, and different target parameters can correspond to different data types respectively. Furthermore, the first data structure can define the arrangement order between the various target parameters. The arrangement order between the various target parameters defined in the first data structure matches (i.e. is the same as) the arrangement order of the storage data corresponding to each target parameter in the target storage partition.
[0069] Since the target storage partition stores data corresponding to multiple target parameters, when it is necessary to read or update the data of different target parameters in the target storage partition, the target storage partition can be mapped with different data structures. As a specific implementation, the target process in the user space can access the target storage partition through the access API (Application Programming Interface) corresponding to the target storage partition, and read the first data currently stored in the target storage partition from the target storage partition. The first data can be all the data stored in the target storage partition, or the first data can be all the battery-related data stored in the target storage partition. The target process can parse the first data according to the first data structure, find the power display parameters contained in the first data, and further find the values corresponding to each power display parameter in the first data, and update the value of the power display parameter according to the power of the first interface to obtain the second data.
[0070] Taking the first data structure in the above example as an example, the first data can be parsed according to the first data structure, and the value corresponding to Uisoc_value in the first data can be updated to the first interface power, and the value of Uisoc_tag in the first data can be updated to "uisoc", and the values of other target parameters remain unchanged to obtain the second data. That is to say, relative to the first data, only the value corresponding to the power display parameter is updated.
[0071] After obtaining the second data, the second data can be written into the target storage partition again according to the first data structure. Since the arrangement order between the target parameters defined in the first data structure matches the arrangement order of the storage data corresponding to the target parameters in the target storage partition, writing the second data into the target storage partition according to the first data structure can ensure that only the data corresponding to the power display parameters stored in the target storage partition is updated, thereby improving the accuracy of data storage.
[0072] After the target process saves the power of the first interface to the target storage partition, the application layer completes the shutdown process, and then the kernel layer shuts down. After the kernel layer completes the shutdown process, the electronic device is truly shut down.
[0073] Step 306, in the resource preloading stage of the device startup process, read the first interface power from the target storage partition according to the first data structure, and write the first interface power into the shared memory according to the defined second data structure.
[0074] In some embodiments, during the resource preloading stage of the device startup process, the second data stored in the target storage partition can be read from the target storage partition, and the second data can be parsed according to the first data structure to obtain the power display parameter. The read second data can be parsed using the first data structure to find the value corresponding to the power display parameter in the second data, and the power of the first interface can be determined according to the value of the power display parameter obtained by parsing.
[0075] Taking the first data structure in the above example as an example, in the resource preloading stage of the device startup process, the partition reading function of the resource preloading stage can be used to read the second data from the target storage partition, and the second data can be parsed according to the first data structure to obtain the value of Uisoc_value and the value of Uisoc_tag in the second data. It can be determined whether the value of Uisoc_tag is "uisoc" to determine the legality of the value of Uisoc_value. If it is determined that the value of Uisoc_value is legal, the value of Uisoc_value can be used as the first interface power. Through the defined first data structure, the first interface power can be accurately read from the target storage partition to ensure the accuracy of data reading.
[0076] After obtaining the power of the first interface, the power of the first interface can be written into the shared memory according to the defined second data structure. The second data structure can be a predefined data structure for transmitting the interface power saved at the last shutdown, and the second data structure can include at least one or more interface power parameters, and an interface power parameter can be used to characterize a variable attribute related to the interface power. Optionally, the second data structure can also include other parameters transmitted between the resource preloading stage and the kernel layer. For example, the second data structure can be as follows:
[0077]
[0078] Among them, Xxx represents other parameters transmitted between the resource preloading stage and the kernel layer, and share_uisoc is used to indicate the specific interface power.
[0079] In some embodiments, the second data structure may further define an arrangement order of the above-mentioned various other parameters and various interface power parameters, and the arrangement order may match an arrangement order of corresponding storage data of the various other parameters and various interface power parameters in the shared memory.
[0080] The shared memory can be used to store data that needs to be shared or transferred between the resource preloading stage and the kernel layer, which can at least include the values of the above-mentioned various interface power parameters, and can also include the values of other parameters transferred between the resource preloading stage and the kernel layer. In the resource preloading stage, the fourth data currently stored in the shared memory can be read from the shared memory, and the fourth data can be parsed according to the second data structure to obtain the interface power parameters. The second data structure can be used to parse the read fourth data to find the interface power parameters contained in the fourth data, and further, find the value corresponding to the interface power parameter in the fourth data, and update the value of the interface power parameter according to the first interface power to obtain the third data.
[0081] Taking the second data structure in the above example as an example, the fourth data can be parsed according to the second data structure, and the value corresponding to share_uisoc in the fourth data is updated to the first interface power, and the values of other parameters remain unchanged to obtain the third data. Optionally, it can be determined whether the first interface power read from the target storage partition is legal. If it is legal, the value corresponding to share_uisoc is updated to the first interface power. If it is illegal, the value corresponding to share_uisoc can be updated to a preset value, for example, the value corresponding to share_uisoc is set to 1, etc., but it is not limited to this.
[0082] After obtaining the third data, the third data can be written into the shared memory again according to the second data structure. Since the second data structure defines the arrangement order of the various other parameters and the various interface power parameters mentioned above, and matches the arrangement order of the storage data corresponding to the various other parameters and the various interface power parameters in the shared memory, writing the third data into the shared memory according to the second data structure can ensure that only the data corresponding to the interface power parameters stored in the shared memory is updated, and the data can be accurately transmitted to the kernel layer, thereby improving the accuracy of data transmission.
[0083] Step 308, during the kernel startup phase, the first interface power level is read from the shared memory according to the second data structure through the kernel layer, and the second interface power level to be displayed is determined according to the first interface power level.
[0084] During the kernel startup phase, the kernel layer can read the third data stored in the shared memory from the shared memory, and parse the third data according to the second data structure to obtain the first interface power. The kernel layer can parse the read third data using the second data structure, find the value corresponding to the interface power parameter in the third data, and determine the first interface power according to the value corresponding to the interface power parameter obtained by parsing.
[0085] Taking the second data structure in the above example as an example, after the kernel layer reads the third data from the shared memory, it can parse the third data according to the second data structure and obtain the value of share_uisoc in the third data as the first interface power. Through the defined second data structure, the kernel layer can accurately read the first interface power from the shared memory to ensure the accuracy of data reading.
[0086] It should be noted that the above-mentioned first data structure and second data structure are only used as an example to illustrate the embodiment of the present application, and are not used to limit the specific data structure. The first data structure and the second data structure can be adjusted and set according to actual needs, and the embodiment of the present application does not limit this.
[0087] In some embodiments, before the kernel layer determines the power level of the second interface to be displayed based on the power level of the first interface, it can first determine whether the power level of the first interface is correct data, that is, determine the rationality of the power level of the first interface. For example, it can determine whether the power level of the first interface is in the range of 0 to 100%. Since the displayed power level must be in the range of 0 to 100%, if the power level of the first interface read by the kernel layer is not in the range of 0 to 100%, it means that the power level of the first interface is incorrect data. In this case, the power level of the first interface can be discarded, and the real power value of the battery can be directly obtained, and the real power value of the battery can be used as the power level of the second interface to be displayed, thereby ensuring the accuracy of the interface power display.
[0088] In some embodiments, Figure 4 As shown, the step of determining the power level of the second interface to be displayed according to the power level of the first interface may include steps 402 to 410.
[0089] Step 402: Acquire the actual power value of the battery detected by the power meter.
[0090] An electronic device may be provided with a power meter, which can detect the actual power value of the battery in real time or at a certain time period. A power update submodule may be run in the power module driver (or charging module driver) in the kernel layer to obtain the actual power value of the battery detected by the power meter each time through the power update submodule.
[0091] Step 404, determining the power difference between the first interface power value and the actual power value.
[0092] Step 406 , determining whether the power difference is less than or equal to a difference threshold, if so, executing step 408 , if not, executing step 410 .
[0093] Step 408: determine the power level of the first interface as the power level of the second interface to be displayed.
[0094] Step 410: determine the actual power value as the power value of the second interface to be displayed.
[0095] The kernel layer can calculate the power difference between the power of the first interface and the actual power value of the battery most recently detected by the power meter, and determine whether the power difference is less than or equal to the difference threshold. If the power difference is less than or equal to the difference threshold, it can be considered that the power of the first interface is relatively accurate, and the power of the first interface can be directly determined as the power of the second interface to be displayed. If the power difference is greater than the difference threshold, it can be considered that the power of the first interface is inaccurate, and the actual power value of the battery can be determined as the power of the second interface to be displayed.
[0096] The difference threshold may be set according to actual needs, for example, the power difference may be an absolute value, and the difference threshold may be 20%, or 25%, 18%, etc. Optionally, the difference threshold may be a preconfigured fixed value or a dynamically adjusted value.
[0097] As an implementation method, the difference threshold can be determined based on the power range in which the actual power value is located. Multiple power ranges can be pre-set, and the multiple power ranges can correspond one-to-one to multiple difference thresholds. The difference thresholds corresponding to different power ranges may be the same or different. Furthermore, the difference threshold corresponding to the smallest power range may be greater than or equal to the difference thresholds corresponding to other power ranges. The smallest power range refers to the power range with the smallest lower limit value. For example, the power range of 0 to 20% is the smallest power range, or the power range of 0 to 10% is the smallest power range, etc.
[0098] When the real power value of the battery is in the minimum power interval, it means that the electronic device is in a low power state. If it is directly displayed with the real power value, it may cause the user's power anxiety. Therefore, a larger difference threshold can be set. The real power value is displayed only when the difference between the first interface power value and the real power value is really large. Otherwise, it is still displayed with the first interface power value to reduce the situation that causes the user's power anxiety and improve the user experience. Optionally, when the real power value of the battery is in the minimum power interval and the first interface power is displayed as the second interface power, the kernel layer can increase the update frequency of the interface power, and gradually reduce the displayed interface power from the first interface power to the real power value according to the increased update frequency. The user can intuitively know the process of power reduction and charge the electronic device as soon as possible to avoid the situation where the electronic device is shut down due to low power.
[0099] In some embodiments, if the power difference between the first interface power and the actual power value is greater than a difference threshold, the average of the first interface power and the actual power value can also be calculated, and the average value can be used as the second interface power to be displayed. This can not only avoid the problem that the interface power seen by the user when the electronic device is started is too different from the interface power seen when the electronic device was last shut down, but also avoid the problem of inaccurate interface power displayed due to a large difference between the displayed interface power and the actual power value. At the same time, it takes into account the accuracy and jump problem of the displayed interface power, thereby improving the user experience.
[0100] In some embodiments, when the electronic device is shut down, the first interface power displayed by the display device at the time of shutdown and the first time corresponding to the first interface power can be written into the target storage partition, wherein the first time corresponding to the first interface power can be the time when the first interface power is stored in the target storage partition (i.e., the time of responding to the shutdown command), or the first time can be the interface update time corresponding to the first interface power (i.e., the time when the interface power on the display device is updated to display the first interface power). In the resource preloading stage of the device startup process, the first interface power and the first time can be read from the target storage partition, and the first interface power and the first time can be written into the shared memory. In the kernel startup stage, the first interface power and the first time can be read from the shared memory through the kernel layer, and the time difference between the current second time and the first time can be determined. According to the time difference and the first interface power, the second interface power to be displayed is determined.
[0101] As an implementation method, when the electronic device is shut down, the target process in the user space can write the first interface power and the first time corresponding to the first interface power into the target storage partition according to the first data structure. In the resource preloading stage of the device startup process, the first interface power and the first time can be read from the target storage partition according to the first data structure, and the first interface power and the first time can be written into the shared memory according to the second data structure. In the kernel startup stage, the kernel layer can read the first interface power and the first time from the shared memory according to the second data structure.
[0102] In some embodiments, the second interface power to be displayed is determined based on the time difference and the first interface power, including but not limited to the following methods:
[0103] (1) The kernel layer can determine whether the time difference is greater than the time threshold. If it is greater than the time threshold, the real power value of the battery can be determined as the power of the second interface to be displayed. When the time difference between the current second moment and the first moment is greater than the time threshold, it means that the time difference between the current startup of the electronic device and the last shutdown is too long, and the first interface power saved at the last shutdown is likely to be inaccurate (the battery of the electronic device will also consume a small current during the shutdown process, resulting in a decrease in power). Therefore, the real power value of the battery detected by the power meter can be obtained, and the real power value can be determined as the power of the second interface to be displayed, thereby improving the accuracy of the displayed interface power.
[0104] If the time difference is not greater than the time threshold, the first interface power level can be determined as the second interface power level to be displayed. If the time difference between the current second moment and the first moment is not greater than the time threshold, it means that the time difference between the current startup of the electronic device and the last shutdown is short, and the first interface power level saved at the last shutdown is relatively accurate, then the first interface power level can be directly displayed, which can avoid the jump of the displayed interface power level when the electronic device is started, avoiding trouble to the user.
[0105] (2) The kernel layer can obtain the aging parameters of the battery, which can be used to characterize the degree of battery aging. The aging parameters may include but are not limited to the ratio of the actual capacity of the battery to the standard capacity, the internal resistance of the battery, the health of the battery, etc. The power loss can be calculated based on the aging parameters of the battery and the time difference, and the power loss is subtracted from the first interface power to obtain the power loss of the second interface to be displayed. The higher the degree of battery aging characterized by the aging parameters of the battery, the greater the corresponding loss coefficient can be. The corresponding loss coefficient can be determined based on the aging parameters of the battery, and the loss coefficient, the time difference and the power loss per unit time are multiplied to obtain the power loss. Among them, the power loss per unit time can be the theoretical power loss per unit time of the battery in the off state, which can be determined through multiple experiments. The power loss of the electronic device between the current device startup and the most recent shutdown is calculated based on the aging degree of the battery, and the power loss of the second interface to be displayed is determined, which can improve the accuracy of the displayed interface power.
[0106] In an embodiment of the present application, the first interface power can be written into a target storage partition and read from a target storage partition according to a defined first data structure, and the first interface power can be written into a shared memory and read from a shared memory according to a defined second data structure, thereby ensuring accurate writing and reading of the first interface power.
[0107] like Figure 5 As shown, in one embodiment, a device 500 for determining the interface power is provided, which can be applied to the above-mentioned electronic device. The device 500 for determining the interface power can include a power reading module 510 and a power determining module 520 .
[0108] The power reading module 510 is used to read the first interface power from the target storage partition and write the first interface power into the shared memory during the resource preloading stage of the device startup process; the first interface power is the interface power displayed by the display device when the electronic device was last shut down; the shared memory is the memory space shared with the kernel layer during the resource preloading stage.
[0109] The power determination module 520 is used to read the power of the first interface from the shared memory through the kernel layer during the kernel startup phase, and determine the power of the second interface to be displayed according to the power of the first interface.
[0110] In an embodiment of the present application, when the electronic device is shut down, the power of the first interface displayed by the display device can be saved in the target storage partition, and when the device is started, the power of the first interface is read from the target storage partition, and the power of the second interface to be displayed is determined by using the first interface power, which can avoid the situation where the displayed interface power jumps when the electronic device is shut down and then started again, avoiding causing trouble to the user, and in the resource preloading stage of the device startup process, the power of the first interface stored in the target storage partition is read, and then passed to the kernel layer through shared memory, without waiting for the process of the user space to load, reducing the lag of reading the power of the first interface and improving the display efficiency of the interface power. In addition, the kernel layer does not directly interact with the target storage partition, which improves the security of the kernel layer.
[0111] In one embodiment, the interface power determination device 500 further includes a storage module.
[0112] The storage module is used to obtain the first interface power currently displayed by the display device in response to the shutdown instruction; and store the first interface power in the target storage partition according to the defined first data structure.
[0113] In one embodiment, the storage module is also used to read the first data currently stored in the target storage partition from the target storage partition; parse the first data according to the defined first data structure to obtain the power display parameter; update the value of the power display parameter according to the first interface power to obtain the second data, and write the second data into the target storage partition.
[0114] In one embodiment, the power reading module 510 is also used to read the second data stored in the target storage partition from the target storage partition; parse the second data according to the first data structure to obtain the power display parameter, and determine the first interface power according to the value of the power display parameter obtained by parsing.
[0115] In one embodiment, the power reading module 510 is further configured to write the first interface power into the shared memory according to a defined second data structure.
[0116] The power determination module 520 is further configured to read the third data stored in the shared memory from the shared memory through the kernel layer, and parse the third data according to the second data structure to obtain the first interface power.
[0117] In one embodiment, the power determination module 520 is also used to obtain the actual power value of the battery detected by the power meter; determine the power difference between the first interface power and the actual power value; if the power difference is less than or equal to the difference threshold, determine the first interface power as the second interface power to be displayed; if the power difference is greater than the difference threshold, determine the actual power value as the second interface power to be displayed.
[0118] In one embodiment, the power reading module 510 is also used to read the first interface power and the first time from the target storage partition, and write the first interface power and the first time into the shared memory; the first time is the time when the first interface power is stored in the target storage partition, or the first time is the interface update time corresponding to the first interface power.
[0119] The power determination module 520 is also used to read the first interface power and the first time from the shared memory through the kernel layer; determine the time difference between the current second time and the first time; and determine the second interface power to be displayed based on the time difference and the first interface power.
[0120] In an embodiment of the present application, the first interface power can be written into a target storage partition and read from a target storage partition according to a defined first data structure, and the first interface power can be written into a shared memory and read from a shared memory according to a defined second data structure, thereby ensuring accurate writing and reading of the first interface power.
[0121] Figure 6 FIG. 1 is a structural block diagram of an electronic device in an embodiment. Figure 6 As shown, the electronic device 600 may include one or more of the following components: a processor 610, and a memory 620 coupled to the processor 610, wherein the memory 620 may store one or more computer programs, and the one or more computer programs may be configured to implement the methods described in the above embodiments when executed by one or more processors 610.
[0122] The processor 610 may include one or more processing cores. The processor 610 uses various interfaces and lines to connect various parts of the entire electronic device 600, and executes various functions and processes data of the electronic device 600 by running or executing instructions, programs, code sets or instruction sets stored in the memory 620, and calling data stored in the memory 620. Optionally, the processor 610 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 610 can integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 610, but may be implemented separately through a communication chip.
[0123] The memory 620 may include a random access memory (RAM) or a read-only memory (ROM). The memory 620 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 620 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc. The data storage area may also store data created by the electronic device 600 during use, etc.
[0124] It is understandable that the electronic device 600 may include more or fewer structural elements than those in the above structural block diagram, for example, a power module, physical buttons, a WiFi (Wireless Fidelity) module, a speaker, a Bluetooth module, a sensor, etc., and is not limited here.
[0125] An embodiment of the present application discloses a computer-readable storage medium storing a computer program, wherein the computer program implements the methods described in the above embodiments when executed by a processor.
[0126] An embodiment of the present application discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program can be executed by a processor to implement the methods described in the above embodiments.
[0127] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a ROM, etc.
[0128] As used herein, any reference to memory, storage, database, or other medium may include nonvolatile and / or volatile memory. Suitable nonvolatile memory may include ROM, programmable ROM (Programmable ROM, PROM), erasable PROM (Erasable PROM, EPROM), electrically erasable PROM (Electrically Erasable PROM, EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which is used as an external cache memory. By way of illustration and not limitation, RAM may be in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), memory bus direct RAM (RDRAM) and direct memory bus dynamic RAM (DRDRAM).
[0129] It should be understood that the "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. Those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required for the present application.
[0130] In the various embodiments of the present application, it should be understood that the size of the serial numbers of the above-mentioned processes does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0131] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0132] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0133] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0134] The above is a detailed introduction to a method, device, electronic device and storage medium for determining interface power disclosed in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for determining interface charge, characterized in that: Applied to electronic equipment, the method comprises: In the resource preloading stage of the device startup process, the first interface power is read from the target storage partition, and the first interface power is written into the shared memory; the first interface power is the interface power displayed by the display device when the electronic device was shut down for the last time; the shared memory is the memory space shared with the kernel layer in the resource preloading stage; In the kernel startup phase, the power level of the first interface is read from the shared memory through the kernel layer, and the power level of the second interface to be displayed is determined according to the power level of the first interface.
2. The method according to claim 1, characterized in that In the resource preloading stage of the device startup process, before reading the first interface power from the target storage partition, the method further includes: In response to the shutdown instruction, obtaining the first interface power currently displayed by the display device; According to the defined first data structure, the first interface power is stored in the target storage partition.
3. The method according to claim 2, characterized in that The step of storing the first interface power into a target storage partition according to the defined first data structure includes: Reading first data currently stored in the target storage partition from the target storage partition; Parsing the first data according to a defined first data structure to obtain a power display parameter; The value of the power display parameter is updated according to the first interface power to obtain second data, and the second data is written into the target storage partition.
4. The method according to claim 3, characterized in that The step of reading the first interface power from the target storage partition includes: Reading second data stored in the target storage partition from the target storage partition; The second data is parsed according to the first data structure to obtain a power display parameter, and the first interface power is determined according to the value of the power display parameter obtained by the parsing.
5. The method according to claim 1, characterized in that Writing the first interface power into the shared memory includes: Writing the first interface power into the shared memory according to the defined second data structure; The reading the first interface power from the shared memory through the kernel layer includes: The third data stored in the shared memory is read from the shared memory through the kernel layer, and the third data is parsed according to the second data structure to obtain the first interface power.
6. The method according to any one of claims 1 to 5, characterized in that: The determining the power of the second interface to be displayed according to the power of the first interface includes: Get the real power value of the battery detected by the fuel gauge; Determine a power difference between the first interface power value and the actual power value; If the power difference is less than or equal to the difference threshold, determining the power of the first interface as the power of the second interface to be displayed; If the power difference is greater than the difference threshold, the actual power value is determined as the power of the second interface to be displayed.
7. The method according to any one of claims 1 to 5, characterized in that: The step of reading the first interface power from the target storage partition and writing the first interface power into the shared memory includes: Reading a first interface power and a first time from a target storage partition, and writing the first interface power and the first time into a shared memory; the first time is a time when the first interface power is stored in the target storage partition, or the first time is an interface update time corresponding to the first interface power; The step of reading the first interface power from the shared memory through the kernel layer and determining the second interface power to be displayed according to the first interface power includes: Reading the first interface power and the first time from the shared memory through the kernel layer; Determine a time difference between a current second moment and the first moment; The power level of the second interface to be displayed is determined according to the time difference and the power level of the first interface.
8. A device for determining interface charge, characterized in that: Applied to electronic equipment, the device comprises: A power reading module is used to read the first interface power from the target storage partition during the resource preloading stage of the device startup process, and write the first interface power into the shared memory; the first interface power is the interface power displayed by the display device when the electronic device was shut down for the last time; the shared memory is the memory space shared with the kernel layer during the resource preloading stage; The power determination module is used to read the power of the first interface from the shared memory through the kernel layer during the kernel startup phase, and determine the power of the second interface to be displayed according to the power of the first interface.
9. An electronic device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor implements the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
User interface self-adapting showing method and terminal
CN103777862A
Improved method for measuring and calculating system battery electricity quantity
CN103792489A
Electricity quantity detecting method and device
CN106680728A
Interface power determination method, device, storage medium, and mobile terminal
CN109040467A
Information monitoring method and system and storage medium
CN111176958A