Android 10.0 system framework modifies low battery shutdown value to 2%

1 Introduction

In the system product development of 10.0, the value of low-power shutdown in the system is different for each platform. This value should be adjusted according to the actual situation according to the actual development requirements of the underlying hardware.
Therefore, it is necessary to analyze the code flow related to power change execution to implement this function

2. The system framework modifies the core class with a low battery shutdown value of 2%

frameworks\base\services\core\java\com\android\server\BatteryService.java

3. System framework changes the core function analysis and implementation of low battery shutdown value to 2%

BatteryService serves as a battery and charging related service: monitors Uevent, reads the status in sysfs, and broadcasts Intent.ACTION_BATTERY_CHANGED.
BatteryService implements a UevenObserver mUEventObserver. uevent is a mechanism used by the Linux kernel to proactively report events to user space.
For JAVA programs, only implement the virtual function onUEvent of UEventObserver and then register it.
BatteryService only pays attention to power_supply events, mainly through battery-related information processing reported at the driver layer. At the same time, the same goes for changes in battery power.
In BatteryService. Processed in java, event processing such as when the battery is too low and the battery becomes hot
Information about the battery, voltage, temperature, charging status, etc. are all provided by BatteryService.
BatteryService runs in system_process and is started during system initialization.
BatteryService reads relevant data through JNI (com_android_server_BatteryService.cpp) and then performs related processing
Let’s analyze BatteryS

Guess you like

Origin blog.csdn.net/baidu_41666295/article/details/134912257