CN114780334A - Power consumption monitoring method, power consumption monitoring device and storage medium - Google Patents

Power consumption monitoring method, power consumption monitoring device and storage medium Download PDF

Info

Publication number
CN114780334A
CN114780334A CN202210372935.7A CN202210372935A CN114780334A CN 114780334 A CN114780334 A CN 114780334A CN 202210372935 A CN202210372935 A CN 202210372935A CN 114780334 A CN114780334 A CN 114780334A
Authority
CN
China
Prior art keywords
information
framework layer
power consumption
terminal equipment
complete machine
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210372935.7A
Other languages
Chinese (zh)
Inventor
黄其柏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Xiaomi Mobile Software Co Ltd
Original Assignee
Beijing Xiaomi Mobile Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Xiaomi Mobile Software Co Ltd filed Critical Beijing Xiaomi Mobile Software Co Ltd
Priority to CN202210372935.7A priority Critical patent/CN114780334A/en
Publication of CN114780334A publication Critical patent/CN114780334A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3058Monitoring arrangements for monitoring environmental properties or parameters of the computing system or of the computing system component, e.g. monitoring of power, currents, temperature, humidity, position, vibrations
    • G06F11/3062Monitoring arrangements for monitoring environmental properties or parameters of the computing system or of the computing system component, e.g. monitoring of power, currents, temperature, humidity, position, vibrations where the monitored property is the power consumption
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3089Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents
    • G06F11/3093Configuration details thereof, e.g. installation, enabling, spatial arrangement of the probes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/545Interprogram communication where tasks reside in different layers, e.g. user- and kernel-space

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Power Sources (AREA)

Abstract

The present disclosure relates to a power consumption monitoring method, a power consumption monitoring apparatus, and a storage medium, where the method is applied to a terminal device, and the terminal device includes: an application framework layer, a local framework layer and a kernel layer; the method comprises the following steps: acquiring battery attribute information of the terminal equipment from the application framework layer by using a first process corresponding to a monitoring program submodule of the local framework layer; the local framework layer comprises an active program submodule and a monitoring program submodule, and the compiling operation of the source program submodule and the compiling operation of the monitoring program submodule are independent; acquiring the current complete machine voltage information of the terminal equipment by utilizing the first process; and determining the current complete machine power consumption information of the terminal equipment based on the complete machine voltage information and the battery attribute information.

Description

Power consumption monitoring method, power consumption monitoring device and storage medium
Technical Field
The present disclosure relates to the field of terminal technologies, and in particular, to a power consumption monitoring method, a power consumption monitoring apparatus, and a storage medium.
Background
In the testing process of the terminal equipment, monitoring of power consumption data of the terminal equipment is an indispensable part; but it is easy to additionally introduce partial power consumption while monitoring the power consumption data.
In the related technology, monitoring application is developed and broadcasted by using a broadcasting mechanism of an application Framework (Framework) layer in terminal equipment so as to obtain data of a bottom layer of the terminal equipment; however, such monitoring applications themselves bring a large amount of power consumption into the terminal device, which results in low accuracy of power consumption test of the terminal device.
Disclosure of Invention
To overcome the problems in the related art, the present disclosure provides a power consumption monitoring method, a power consumption monitoring apparatus, and a storage medium.
According to a first aspect of the embodiments of the present disclosure, a power consumption monitoring method is provided, which is applied to a terminal device, where the terminal device includes: an application framework layer, a local framework layer and a kernel layer; the method comprises the following steps:
acquiring battery attribute information of the terminal equipment from an application framework layer by utilizing a first process corresponding to a monitoring program submodule of a local framework layer; the local framework layer comprises an active program submodule and a monitoring program submodule, and the compiling operation of the source program submodule and the compiling operation of the monitoring program submodule are independent;
acquiring the current complete machine voltage information of the terminal equipment by utilizing the first process;
and determining the current complete machine power consumption information of the terminal equipment based on the complete machine voltage information and the battery attribute information.
Optionally, the obtaining, by using the first process corresponding to the monitoring program sub-module of the local framework layer, the battery attribute information of the terminal device from the application framework layer includes:
and acquiring the battery attribute information of the terminal equipment from the application framework layer through the communication between the first process and the second process of the application framework layer.
Optionally, the obtaining, by the communication between the first process and the second process of the application framework layer, the battery attribute information of the terminal device from the application framework layer includes:
the first process calls the second process through a preset communication interface, and returns the battery attribute information of the terminal equipment to the first process through the preset communication interface; and the preset communication interface is a Binder communication interface pre-configured by the second process.
Optionally, the battery attribute information includes: electric quantity information;
the obtaining of the current complete machine voltage information of the terminal equipment by using the first process includes:
and when the electric quantity information is monitored to change, acquiring the current complete machine voltage information of the terminal equipment by utilizing the first process.
Optionally, the obtaining, by using the first process, current overall voltage information of the terminal device includes:
and acquiring the current complete machine voltage information of the terminal equipment through the first process execution system grabbing instruction.
Optionally, the battery attribute information includes: current information of the whole machine;
the determining the current overall power consumption information of the terminal device based on the overall voltage information and the battery attribute information includes:
and determining the current instantaneous power consumption information of the terminal equipment based on the complete machine voltage information and the complete machine current information.
Optionally, before obtaining the battery attribute information of the terminal device from the application framework layer, the method further includes:
and reporting the battery attribute information of the terminal equipment detected by the kernel layer to the application framework layer through a third process corresponding to the source program submodule.
According to a second aspect of the embodiments of the present disclosure, there is provided a power consumption monitoring apparatus, where the terminal device includes: an application framework layer, a local framework layer and a kernel layer; the device, comprising:
the first acquisition module is used for acquiring the battery attribute information of the terminal equipment from the application framework layer by utilizing a first process corresponding to the monitoring program submodule of the local framework layer; the local framework layer comprises an active program submodule and a monitoring program submodule, and the compiling operation of the source program submodule and the compiling operation of the monitoring program submodule are mutually independent;
the second acquisition module is used for acquiring the current complete machine voltage information of the terminal equipment by utilizing the first process;
and the determining module is used for determining the current complete machine power consumption information of the terminal equipment based on the complete machine voltage information and the battery attribute information.
Optionally, the first obtaining module is configured to:
and acquiring the battery attribute information of the terminal equipment from the application framework layer through the communication between the first process and the second process of the application framework layer.
Optionally, the first obtaining module is configured to:
the first process calls the second process through a preset communication interface, and returns the battery attribute information of the terminal equipment to the first process through the preset communication interface; and the preset communication interface is a Binder communication interface pre-configured by the second process.
Optionally, the battery attribute information includes: electric quantity information;
and the second acquisition module is used for acquiring the current overall voltage information of the terminal equipment by utilizing the first process when the electric quantity information is monitored to change.
Optionally, the second obtaining module is configured to:
and acquiring the current complete machine voltage information of the terminal equipment through the first process execution system grabbing instruction.
Optionally, the battery attribute information includes: current information of the whole machine;
the determining module is used for determining the current instantaneous power consumption information of the terminal equipment based on the complete machine voltage information and the complete machine current information.
Optionally, the apparatus further comprises: a reporting module, configured to:
and reporting the battery attribute information of the terminal equipment detected by the kernel layer to the application framework layer through a third process corresponding to the source program submodule.
According to a third aspect of embodiments of the present disclosure, there is provided a power consumption monitoring apparatus including:
a processor;
a memory for storing executable instructions;
wherein the processor is configured to: when the executable instructions stored in the memory are executed, the steps in the power consumption monitoring method according to the first aspect of the embodiment of the present disclosure are implemented.
According to a fourth aspect of embodiments of the present disclosure, there is provided a non-transitory computer-readable storage medium, wherein instructions, when executed by a processor of a power consumption monitoring apparatus, enable the power consumption monitoring apparatus to perform the steps of the power consumption monitoring method according to the first aspect of the embodiments of the present disclosure.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects:
the method comprises the steps that battery attribute information of the terminal equipment is obtained from an application framework layer by utilizing a first process of a monitoring program submodule which is independent from a source program submodule in the local framework layer, and current whole machine voltage information of the terminal equipment is obtained, so that the bottom layer data of the terminal equipment is obtained on the basis that a local code file in the source program submodule of the terminal equipment is not modified, the power consumption condition of the terminal equipment is further determined, and non-invasive power consumption monitoring of the terminal equipment is realized; and the monitoring application of the application layer is not needed to monitor the power consumption data of the bottom layer of the terminal equipment, so that the power consumption introduced by the monitoring application in the power consumption monitoring process is reduced, and the accuracy of the power consumption test of the terminal equipment is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
Fig. 1 is a schematic diagram of reporting battery power based on multiple layers of an Android operating system in the related art.
Fig. 2 is a first flowchart illustrating a power consumption detection method according to an exemplary embodiment.
Fig. 3 is a flow chart diagram two illustrating a power consumption monitoring method according to an exemplary embodiment.
Fig. 4 is a schematic diagram illustrating a structure of a power consumption monitoring apparatus according to an exemplary embodiment.
Fig. 5 is a block diagram illustrating a terminal device according to an example embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.
The power consumption is an important index in the testing process of the terminal equipment, and the related technology utilizes the electric quantity reporting flow of the Android operating system to monitor the power consumption data of the terminal equipment. As shown in fig. 1, fig. 1 is a schematic diagram of reporting battery power based on multiple layers of an Android operating system in the related art.
The Kernel layer (Kernel) belongs to a battery driving part of the terminal device, is responsible for interacting with hardware, and generates a corresponding battery event (ue) to report when battery power information changes.
A battery information daemon (healthy) in a local framework layer (Native) runs a system service of battery properties (Battery Properties) and is responsible for monitoring a uevent reported by a kernel layer and monitoring the battery power in real time.
A battery service (Battery service) in an application Framework layer (Framework) monitors a battery information change message in a Battery Properties service, and forwards the battery information change message to an application layer (APP) in a system broadcast mode.
The application layer monitors system broadcast and updates the system user interface.
However, the power consumption data monitoring method is to monitor in an application layer, and the monitoring application runs in a background of the terminal device, so that a large amount of power consumption is introduced into the monitoring application, and the accuracy of a power consumption test result of the terminal device is low.
An embodiment of the present disclosure provides a power consumption monitoring method, and fig. 2 is a first schematic flow chart of a power consumption monitoring method according to an exemplary embodiment, as shown in fig. 2; the method comprises the following steps:
step S101, acquiring battery attribute information of the terminal equipment from an application framework layer by using a first process corresponding to a monitoring program submodule of a local framework layer; the local framework layer comprises an active program submodule and a monitoring program submodule, and the compiling operation of the source program submodule and the compiling operation of the monitoring program submodule are independent;
step S102, acquiring the current complete machine voltage information of the terminal equipment by utilizing the first process;
step S103, determining the current complete machine power consumption information of the terminal equipment based on the complete machine voltage information and the battery attribute information.
The power consumption monitoring method shown in the embodiment of the present disclosure can be applied to a terminal device, where the terminal device includes: the system comprises an application framework layer, a local framework layer and a kernel layer. The terminal device may be: a smart phone, a tablet computer, or a wearable electronic device, etc.
In step S101, the local framework layer includes an active program submodule and a monitoring program submodule, where the active program submodule is used to store a local code file in a terminal device; the monitoring program submodule is used for storing a power consumption monitoring code file, and the power consumption monitoring code file stored in the monitoring program submodule is not compiled simultaneously with a local code file stored in the source program submodule.
It can be understood that the compiling and operating processes of the power consumption monitoring code file stored in the monitoring program sub-module and the compiling and operating processes of the local code file stored in the source program sub-module are independent of each other.
Compiling a power consumption monitoring code file in a monitoring program sub-module of a local framework layer to generate an executable file, running the executable file to generate the first process, and performing information interaction with the application framework layer through the first process to acquire the battery attribute information of the terminal equipment.
It should be noted that the Android operating system can be divided into four layers, where the four layers are: an application layer, an application framework layer, a local framework layer, and a kernel layer (kernel space).
And the application layer consists of all applications running in the terminal equipment, including pre-installed system applications and third-party applications installed by the user.
The application framework layer is used for providing support for the application layer, so that the code information of the application layer can be correctly identified and executed; the application framework layer is implemented based on a code (such as Java code) run by a host environment of a virtual machine in the terminal device, namely, an application and an application framework in terms of a software structure, and includes any method formed by Java code. Communication between application components in the application layer is realized by centralized scheduling and message transfer of services provided by the application framework layer, and is not directly performed between the application components.
The local framework layer is implemented by local codes in the terminal device, for example, the local framework layer includes a kernel and a library file implemented by C/C + + codes and is used for providing local services and local implementation methods corresponding to the link library, and the local services and the local implementation methods provided by the local framework layer can be used by different components; the local framework layer can communicate with the code information of the upper layer (namely, the application framework layer) on one hand, and can interact with the hardware of the bottom layer (the kernel layer) on the other hand, so that the normal operation of the terminal equipment is guaranteed.
The Android operating system is realized based on a kernel layer, and core system services of the Android operating system, such as security, memory management, process management, network protocols and driving models, depend on the kernel layer.
It can be understood that, in the embodiment of the present disclosure, the battery attribute information of the terminal device is obtained from the application framework layer by using the first process of the monitoring program sub-module, which is independent from the source program sub-module, in the local framework layer, so that the bottom layer data of the terminal device is obtained on the basis of not modifying the local code file in the source program sub-module of the terminal device, and thus the power consumption condition of the terminal device is determined, and the introduction of additional power consumption in the power consumption monitoring process is reduced.
In an embodiment of the present disclosure, the battery attribute information may include: battery power, battery capacity, battery average temperature, charge-discharge state, current remaining capacity and the like. It can be understood that the battery attribute information in the terminal device may reflect the power consumption of the terminal device to a certain extent, for example, the residual power of the battery in the terminal device is consumed faster, which indicates that the current power consumption of the terminal device is higher.
In step S102, the overall voltage information may include: the battery in the terminal equipment is used for supplying power to the terminal equipment; the power consumption of the terminal device is related to the supply voltage value of a battery in the terminal device.
It can be understood that, the remaining power of the battery in the terminal device is different, and the power supply voltage of the battery for supplying power to the terminal device may also be different, so that when the power consumption condition of the terminal device is determined, the current power supply voltage of the battery in the terminal device needs to be obtained through the first process, so as to analyze the current power consumption condition of the terminal device according to the current power supply voltage of the battery in the subsequent process.
In step S103, after acquiring the current complete machine voltage information and the battery attribute information of the terminal device, the first process may determine the current complete machine power consumption information of the terminal device according to the complete machine voltage information and the battery attribute information.
The method comprises the steps that battery attribute information of the terminal equipment is obtained from an application framework layer by utilizing a first process of a monitoring program submodule which is independent from a source program submodule in the local framework layer, and current whole machine voltage information of the terminal equipment is obtained, so that bottom layer data of the terminal equipment is obtained on the basis that a local code file in the source program submodule of the terminal equipment is not modified, and the power consumption condition of the terminal equipment is further determined; the monitoring application of the application layer is not needed to monitor the power consumption data of the bottom layer of the terminal equipment, the power consumption introduced by the monitoring application in the power consumption monitoring process is reduced, and the accuracy of the power consumption test of the terminal equipment is improved.
Optionally, the obtaining, by using the first process corresponding to the monitoring program sub-module of the local framework layer, the battery attribute information of the terminal device from the application framework layer includes:
and acquiring the battery attribute information of the terminal equipment from the application framework layer through the communication between the first process and the second process of the application framework layer.
In this disclosure, the second process may be a BatteryService process of the application framework layer; the BatteryService process provides an interface for acquiring battery attribute information.
It should be noted that BatteryService is an important service for battery management, and the service inherits the system service (SystemService) of the application framework layer; battteryservice is started when SystemService starts a core service.
It can be understood that, the kernel layer of the Android operating system creates and starts an initialization Init process; creating and starting a virtual device Zygote sub-process by an Init process; and loading the initialization configuration file by the Zygote subprocess, creating and starting a Systemservice process, creating and starting a Batteryservice process by the Systemservice process, and completing the starting process of the Android operating system.
In the embodiment of the disclosure, the first process corresponding to the monitoring program submodule of the local framework layer and the second process of the application framework layer complete the transmission of the battery attribute information of the terminal device through inter-process communication.
Optionally, the obtaining, by the communication between the first process and the second process of the application framework layer, the battery attribute information of the terminal device from the application framework layer includes:
the first process calls the second process through a preset communication interface, and returns the battery attribute information of the terminal equipment to the first process through the preset communication interface; and the preset communication interface is a Binder communication interface pre-configured by the second process.
In the embodiment of the present disclosure, based on the preset communication interface, a first process corresponding to the monitoring program sub-module of the local framework layer performs Binder communication with a second process of the application framework layer, and transmits battery attribute information of the terminal device, acquired by the second process, to the first process through the preset communication interface.
It should be noted that the Binder communication mechanism is a mode of inter-process communication in the Android operating system, and is also one of the most important characteristics in the Android operating system. The four major components of the Android operating system are respectively: workflow (Activity), Service (Service), Broadcast receiver (Broadcast) and content provider (ContentProvider), all running between different processes, and Binder communication mechanism is the bridge for communication between these processes.
And each process of the Android operating system can only run in a virtual address space owned by the process. The virtual address space includes a user space and a kernel space that are independent of each other. For user space, the client process and the server process are not shareable with respect to each other, while the kernel space between the client process and the server process is shareable. Each communication between the client process and the server process is realized by a Binder driver in the kernel space.
In the communication process based on the Binder communication mechanism, the following three processes are mainly included:
and (3) registration service: a Service (Service) process firstly registers a Service to a Service manager, in which the Service is a client and the Service manager is a server.
And acquiring Service, wherein before a Client process uses a certain Service, the Client process acquires the corresponding Service from the ServiceManager. In this process, the Client is the Client and the ServiceManager is the server.
By using the Service, the Client establishes a communication path with the Service process where the Service is located according to the obtained Service information, and then can directly interact with the Service. In this process, the Client is the Client and the Service is the server.
Therefore, the preset communication interface is an interface which is registered and configured in advance in the ServiceManager by the second process; the first process can acquire a preset communication interface of the second process from the ServiceManager, establish a communication channel with the second process based on the preset communication interface, and interact with the second process.
Here, the predetermined communication interface may be a bindervice communication interface of batttery properties. It can be understood that, in the initialization process of the Android operating system, a BatteryService process of the application framework layer registers a BatteryProperties service and manages in a ServiceManager; the BatteryProperties service is used for monitoring the battery events reported in the kernel layer and monitoring the battery attribute information in real time. After the BinderService communication interface of the BatteryProperties is called, the battery attribute information monitored by the BatteryProperties service is transmitted through the BinderService communication interface.
Optionally, the battery attribute information includes: electric quantity information;
the obtaining of the current complete machine voltage information of the terminal device by using the first process includes:
and when the electric quantity information is monitored to be changed, acquiring the current overall voltage information of the terminal equipment by utilizing the first process.
In the embodiment of the disclosure, in the using process of the terminal device, the overall voltage of the terminal device is basically in a relatively stable state, but the overall voltage of the terminal device and the electric quantity of a battery in the terminal device have a mapping relation; it can be understood that when the electric quantity of the battery in the terminal equipment changes, the overall voltage of the terminal equipment also changes.
According to the method and the device, the electric quantity information of a battery in the terminal equipment is acquired through communication between a first process corresponding to a monitoring program submodule of the local framework layer and a second process of the application framework layer; and monitoring the electric quantity information, and acquiring the current overall machine voltage information of the terminal equipment by utilizing the first process when the electric quantity information changes.
It should be noted that, in order to implement real-time monitoring of the power consumption of the terminal device, the first process needs to continuously obtain the voltage information of the whole terminal device, which easily causes the efficiency core of the CPU to be fully loaded and the power consumption to be too high; the method comprises the steps of obtaining the current complete machine voltage information of the terminal equipment by utilizing a first process when the change of the electric quantity of the battery in the terminal equipment is monitored by considering that the complete machine voltage of the terminal equipment has a mapping relation with the electric quantity of the battery in the terminal equipment, so that the real-time monitoring of the power consumption change condition of the terminal equipment can be realized, the power consumption of the terminal equipment can be reduced, and the use experience of a user is improved.
Optionally, the obtaining, by using the first process, current overall voltage information of the terminal device includes:
and acquiring the current complete machine voltage information of the terminal equipment through the first process execution system grabbing instruction.
In an embodiment of the present disclosure, the system grab instruction may be a dumpsys pattern instruction.
It should be noted that dumpsys is a debugging tool running on the Android device, and may be used to view system service information. And adding query parameters after the dumpsys instruction, and checking specific service information of the Android equipment corresponding to the query parameters.
And executing the dumpsys battery instruction through the first process to acquire the current overall voltage information of the terminal equipment.
Optionally, the battery attribute information includes: current information of the whole machine;
the determining the current overall power consumption information of the terminal device based on the overall voltage information and the battery attribute information includes:
and determining the current instantaneous power consumption information of the terminal equipment based on the complete machine voltage information and the complete machine current information.
In an embodiment of the present disclosure, the complete machine current information may include: and the battery in the terminal equipment supplies power for the terminal equipment.
When the power supply current (i.e. the complete machine current information) and the power supply voltage (i.e. the complete machine voltage information) of the battery for supplying power to the terminal equipment are obtained, the current instantaneous power consumption value of the terminal equipment can be determined according to the product of the power supply current and the power supply voltage.
It should be noted that the battery in the terminal device needs to supply power to a plurality of devices (such as a camera, a CPU, a display screen, etc.) configured in the terminal device, and the number and the types of the devices that the battery needs to supply power may be different at different times, and the power consumption generated by different devices is different. When the power consumption test is carried out on the terminal equipment, the power consumption condition of the terminal equipment can be determined according to a plurality of instantaneous power consumptions of the terminal equipment in the test process by counting the instantaneous power consumptions of the terminal equipment, so that the accuracy of the power consumption test of the terminal equipment is improved.
Optionally, before obtaining the battery attribute information of the terminal device from the application framework layer, the method further includes:
and reporting the battery attribute information of the terminal equipment detected by the kernel layer to the application framework layer through a third process corresponding to the source program submodule.
In the embodiment of the present disclosure, an executable file is generated by compiling a local code file in a source program sub-module of a local framework layer, the executable file is run to generate the third process, battery attribute information monitored by a kernel layer is monitored through the third process, and the battery attribute information is reported to the application framework layer.
Here, the third process may be a battery information daemon (health).
It should be noted that the Healthd is an intermediary model, which monitors the battery event from the kernel layer downward and transmits the battery data to the BatteryService of the application architecture layer upward; so that the Battery service calculates the information such as battery capacity display, residual capacity, capacity level and the like according to the transmitted battery data.
An embodiment of the present disclosure provides a power consumption monitoring method, and fig. 3 is a schematic flow diagram of a power consumption monitoring method according to an exemplary embodiment, where as shown in fig. 3, the method includes:
step S201, utilizing a first process corresponding to a monitoring program submodule of a local framework layer, calling a second process of an application framework layer through a preset communication interface, and returning electric quantity information and complete machine current information of a battery in the terminal equipment to the first process through the preset communication interface; the local framework layer comprises an active program submodule and a monitoring program submodule, and the compiling operation of the source program submodule and the compiling operation of the monitoring program submodule are mutually independent;
in this example, a monitoring program submodule is newly added to a local framework layer, the monitoring program submodule stores a power consumption monitoring code file, and a first process is generated by operating the power consumption monitoring code file; and communicating with a second process of the application framework layer by utilizing the first process to acquire the electric quantity information and the whole machine current information stored by the application framework layer, so as to acquire bottom layer battery data of the terminal equipment on the basis of not modifying the source code of the local framework layer of the terminal equipment.
The second process may be a BatteryService process of the application framework layer; the BatteryService process provides an interface for acquiring the battery attribute information. The preset communication interface can be a BinderService communication interface of BatteryProperties which is registered in advance by the BatteryService process in the ServiceManager.
In some embodiments, the method further comprises:
and reporting the battery attribute information of the terminal equipment detected by the kernel layer to the application framework layer through a third process corresponding to the source program submodule.
In this example, the third process is a Healthd process, which monitors a battery event of the kernel layer by using the Healthd process of the local framework layer, and transfers battery data to a Batteryservice of the application framework layer.
Step S202, when the electric quantity information is monitored to change, a system grabbing instruction is executed by utilizing the first process, and the current complete machine voltage information of the terminal equipment is obtained;
in this example, the system grab instruction may be a dumpsys battery instruction.
It should be noted that, to calculate the power consumption information of the terminal device, the voltage data of the terminal device needs to be collected, and the power consumption information can be obtained by using a dumpsys battery instruction in the Android operating system. However, calling the instruction all the time easily causes the efficiency core of the CPU to be full, and introduces the problem of overhigh power consumption. The voltage data of the whole machine is basically in a relatively stable state in the using process of the terminal equipment, and the voltage data of the whole machine and the current electric quantity of the terminal equipment have a mapping relation.
Therefore, in the example, the electric quantity information of the terminal equipment is monitored, and when the electric quantity information changes, the whole machine voltage data of the terminal equipment is obtained through the executed dumpsys battery instruction.
Step S203, determining current overall power consumption information of the terminal device based on the overall voltage information and the overall current information.
In this example, after the complete machine voltage value and the complete machine current value of the terminal device are obtained, the current instantaneous power consumption value of the terminal device can be determined by the product of the complete machine voltage value and the complete machine current value.
The embodiment of the disclosure also provides a power consumption monitoring device. Fig. 4 is a schematic diagram illustrating a configuration of a power consumption monitoring apparatus according to an exemplary embodiment. As shown in fig. 4, the apparatus 100 is applied to a terminal device, and the terminal device includes: an application framework layer, a local framework layer and a kernel layer; the apparatus 100, comprising:
a first obtaining module 101, configured to obtain, by using a first process corresponding to a monitoring program submodule of a local framework layer, battery attribute information of a terminal device from an application framework layer; the local framework layer comprises an active program submodule and a monitoring program submodule, and the compiling operation of the source program submodule and the compiling operation of the monitoring program submodule are independent;
a second obtaining module 102, configured to obtain, by using the first process, current complete machine voltage information of the terminal device;
a determining module 103, configured to determine, based on the complete machine voltage information and the battery attribute information, current complete machine power consumption information of the terminal device.
Optionally, the first obtaining module 101 is configured to:
and acquiring the battery attribute information of the terminal equipment from the application framework layer through the communication between the first process and the second process of the application framework layer.
Optionally, the first obtaining module 101 is configured to:
the first process calls the second process through a preset communication interface, and returns the battery attribute information of the terminal equipment to the first process through the preset communication interface; and the preset communication interface is a Binder communication interface pre-configured by the second process.
Optionally, the battery attribute information includes: electric quantity information;
the second obtaining module 102 is configured to, when it is monitored that the electric quantity information changes, obtain, by using the first process, current complete machine voltage information of the terminal device.
Optionally, the second obtaining module 102 is configured to:
and acquiring the current complete machine voltage information of the terminal equipment through the first process execution system grabbing instruction.
Optionally, the battery attribute information includes: current information of the whole machine;
the determining module 103 is configured to determine current instantaneous power consumption information of the terminal device based on the complete machine voltage information and the complete machine current information.
Optionally, the apparatus further comprises: a reporting module 104, configured to:
and reporting the battery attribute information of the terminal equipment detected by the kernel layer to the application framework layer through a third process corresponding to the source program submodule.
Fig. 5 is a block diagram illustrating a terminal device according to an example embodiment. For example, the terminal device 800 may be a mobile phone, a mobile computer, or the like.
Referring to fig. 5, terminal device 800 may include one or more of the following components: processing component 802, memory 804, power component 806, multimedia component 808, audio component 810, input/output (I/O) interface 812, sensor component 814, and communication component 816.
The processing component 802 generally controls overall operation of the terminal device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operation at the device 800. Examples of such data include instructions for any application or method operating on terminal device 800, contact data, phonebook data, messages, pictures, videos, and the like. The memory 804 may be implemented by any type or combination of volatile and non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
Power components 806 provide power to the various components of terminal device 800. Power components 806 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for terminal device 800.
The multimedia component 808 comprises a screen providing an output interface between the terminal device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the device 800 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive an external audio signal when the terminal device 800 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
Sensor component 814 includes one or more sensors for providing various aspects of state assessment for terminal device 800. For example, sensor assembly 814 can detect the open/closed state of device 800, the relative positioning of components, such as a display and keypad of terminal device 800, sensor assembly 814 can also detect a change in the position of terminal device 800 or a component of terminal device 800, the presence or absence of user contact with terminal device 800, orientation or acceleration/deceleration of terminal device 800, and a change in the temperature of terminal device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
Communication component 816 is configured to facilitate communications between terminal device 800 and other devices in a wired or wireless manner. The terminal device 800 may access a wireless network based on a communication standard, such as Wi-Fi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the terminal device 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the terminal device 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.

Claims (10)

1. A power consumption monitoring method is applied to a terminal device, and the terminal device comprises: an application framework layer, a local framework layer and a kernel layer; the method comprises the following steps:
acquiring battery attribute information of the terminal equipment from the application framework layer by using a first process corresponding to a monitoring program submodule of the local framework layer; the local framework layer comprises an active program submodule and a monitoring program submodule, and the compiling operation of the source program submodule and the compiling operation of the monitoring program submodule are independent;
acquiring the current complete machine voltage information of the terminal equipment by utilizing the first process;
and determining the current complete machine power consumption information of the terminal equipment based on the complete machine voltage information and the battery attribute information.
2. The method according to claim 1, wherein the obtaining battery attribute information of the terminal device from the application framework layer by using the first process corresponding to the monitoring program submodule of the local framework layer includes:
and acquiring the battery attribute information of the terminal equipment from the application framework layer through the communication between the first process and the second process of the application framework layer.
3. The method according to claim 2, wherein the obtaining battery property information of the terminal device from the application framework layer through communication between the first process and a second process of the application framework layer comprises:
the first process calls the second process through a preset communication interface, and returns the battery attribute information of the terminal equipment to the first process through the preset communication interface; and the preset communication interface is a Binder communication interface pre-configured by the second process.
4. The method of claim 1, wherein the battery attribute information comprises: electric quantity information;
the obtaining of the current complete machine voltage information of the terminal equipment by using the first process includes:
and when the electric quantity information is monitored to be changed, acquiring the current overall voltage information of the terminal equipment by utilizing the first process.
5. The method according to claim 1 or 4, wherein the obtaining, by using the first process, current overall voltage information of the terminal device includes:
and acquiring the current complete machine voltage information of the terminal equipment through the first process execution system grabbing instruction.
6. The method of claim 1, wherein the battery attribute information comprises: current information of the whole machine;
the determining the current complete machine power consumption information of the terminal equipment based on the complete machine voltage information and the battery attribute information comprises the following steps:
and determining the current instantaneous power consumption information of the terminal equipment based on the complete machine voltage information and the complete machine current information.
7. The method according to claim 1, wherein before obtaining the battery property information of the terminal device from the application framework layer, the method further comprises:
and reporting the battery attribute information of the terminal equipment detected by the kernel layer to the application framework layer through a third process corresponding to the source program submodule.
8. A power consumption monitoring device is applied to a terminal device, and the terminal device comprises: an application framework layer, a local framework layer and a kernel layer; the device, comprising:
the first acquisition module is used for acquiring the battery attribute information of the terminal equipment from the application framework layer by utilizing a first process corresponding to the monitoring program submodule of the local framework layer; the local framework layer comprises an active program submodule and a monitoring program submodule, and the compiling operation of the source program submodule and the compiling operation of the monitoring program submodule are independent;
the second acquisition module is used for acquiring the current complete machine voltage information of the terminal equipment by utilizing the first process;
and the determining module is used for determining the current complete machine power consumption information of the terminal equipment based on the complete machine voltage information and the battery attribute information.
9. A power consumption monitoring apparatus, comprising:
a processor;
a memory for storing executable instructions;
wherein the processor is configured to: the method of monitoring power consumption of any one of claims 1 to 7 when executed by executable instructions stored in the memory.
10. A non-transitory computer readable storage medium having instructions therein which, when executed by a processor of a power consumption monitoring device, enable the power consumption monitoring device to perform the power consumption monitoring method of any one of claims 1 to 7.
CN202210372935.7A 2022-04-11 2022-04-11 Power consumption monitoring method, power consumption monitoring device and storage medium Pending CN114780334A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210372935.7A CN114780334A (en) 2022-04-11 2022-04-11 Power consumption monitoring method, power consumption monitoring device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210372935.7A CN114780334A (en) 2022-04-11 2022-04-11 Power consumption monitoring method, power consumption monitoring device and storage medium

Publications (1)

Publication Number Publication Date
CN114780334A true CN114780334A (en) 2022-07-22

Family

ID=82428650

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210372935.7A Pending CN114780334A (en) 2022-04-11 2022-04-11 Power consumption monitoring method, power consumption monitoring device and storage medium

Country Status (1)

Country Link
CN (1) CN114780334A (en)

Similar Documents

Publication Publication Date Title
KR101770931B1 (en) Method, apparatus, program and computer-readable recording medium of generating communication module firmware and plug-in
EP3316136B1 (en) Method and device for evaluating system fluency, and ue
US20170046015A1 (en) Method and apparatus for presenting multimedia information
EP2998899A1 (en) Method and apparatus for running application program
US9870239B2 (en) Method and device for running application program
CN111221559B (en) Application updating method, device, storage medium, terminal and server
CN111338910B (en) Log data processing method, log data display method, log data processing device, log data display device, log data processing equipment and log data storage medium
CN103916468B (en) Method for upgrading system, terminal, server and upgrade-system
CN111221733A (en) Information processing method and device, mobile terminal and storage medium
CN107562500B (en) Debugging device, method and equipment
CN109684112B (en) Program file operation method, device, terminal and storage medium
CN106612149B (en) Radio frequency circuit testing method, device and system and mobile terminal
CN110795354A (en) Information processing method, device and storage medium
CN106909481B (en) Interface test method, interface test device and electronic equipment
CN112256563A (en) Android application stability testing method and device, electronic equipment and storage medium
CN114896165A (en) Testing method and device of conversation robot system, electronic equipment and storage medium
CN114780334A (en) Power consumption monitoring method, power consumption monitoring device and storage medium
CN111274590B (en) Request processing method and device, electronic equipment and storage medium
CN114428737A (en) Communication method, device, equipment and storage medium based on micro service system
CN111597106A (en) Point burying management method and device
CN107391128B (en) Method and device for monitoring virtual file object model vdom
CN112230982A (en) Material processing method and device, electronic equipment and storage medium
CN111290944A (en) Script generation method, device and storage medium
CN113407879A (en) Data reporting method, device and readable medium
CN116662101B (en) Fault restoration method of electronic equipment and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination