1# Lite Battery Manager<a name="EN-US_TOPIC_0000001174637973"></a> 2 3- [Introduction](#section11660541593) 4- [Directory Structure](#section19472752217) 5- [Usage](#section146636391856) 6 - [Available APIs](#section481251394) 7 - [Usage Guidelines](#section12620311012) 8 9- [Repositories Involved](#section63151229062) 10 11## Introduction<a name="section11660541593"></a> 12 13The lite battery manager provides the following functionalities: 14 151. Obtaining battery information 162. Obtaining the battery charging status and the battery state of charge \(SoC\) 173. Monitoring the battery state of health \(SoH\) 184. Controlling the battery charging indicator 19 20**Figure 1** Lite battery manager architecture<a name="fig106301571239"></a> 21 22 23![](figures/en-us_image_0000001176131699.png) 24 25## Directory Structure<a name="section19472752217"></a> 26 27``` 28base/powermgr/battery_lite 29├── figures # Architecture figures 30├── frameworks # Frameworks 31│ ├── js # Built_in interface 32│ └── native # Native code 33├── interfaces # APIs 34│ └── kits # External APIs 35├── services # Services 36│ ├── include # Header files 37│ └── src # Source files 38└── test # Interface test 39``` 40 41## Usage<a name="section146636391856"></a> 42 43### Available APIs<a name="section481251394"></a> 44 45The following table lists the JavaScript APIs provided by the lite battery manager. 46 47<a name="table45171237103112"></a> 48 49<table><thead align="left"><tr id="row12572123793117"><th class="cellrowborder" valign="top" width="38.71%" id="mcps1.1.3.1.1"><p id="p19572937163116"><a name="p19572937163116"></a><a name="p19572937163116"></a><strong id="b1783175664017"><a name="b1783175664017"></a><a name="b1783175664017"></a>API</strong></p> 50</th> 51<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.3.1.2"><p id="p157213711313"><a name="p157213711313"></a><a name="p157213711313"></a><strong id="b62896374115"><a name="b62896374115"></a><a name="b62896374115"></a>Description</strong></p> 52</th> 53</tr> 54</thead> 55<tbody><tr id="row14574143723119"><td class="cellrowborder" valign="top" width="38.71%" headers="mcps1.1.3.1.1 "><p id="p169098161437"><a name="p169098161437"></a><a name="p169098161437"></a>int32_t GetBatSoc()</p> 56</td> 57<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.3.1.2 "><p id="p105741337153115"><a name="p105741337153115"></a><a name="p105741337153115"></a>Obtains the battery SoC.</p> 58</td> 59</tr> 60<tr id="row19195203919318"><td class="cellrowborder" valign="top" width="38.71%" headers="mcps1.1.3.1.1 "><p id="p46911925104319"><a name="p46911925104319"></a><a name="p46911925104319"></a>BatteryChargeState GetChargingStatus()</p> 61</td> 62<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.3.1.2 "><p id="p1619618397312"><a name="p1619618397312"></a><a name="p1619618397312"></a>Obtains the current battery charging status.</p> 63</td> 64</tr> 65<tr id="row9397121153216"><td class="cellrowborder" valign="top" width="38.71%" headers="mcps1.1.3.1.1 "><p id="p1339731103216"><a name="p1339731103216"></a><a name="p1339731103216"></a>BatteryHealthState GetHealthStatus()</p> 66</td> 67<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.3.1.2 "><p id="p113972183214"><a name="p113972183214"></a><a name="p113972183214"></a>Obtains the battery SoH.</p> 68</td> 69</tr> 70<tr id="row1721311920324"><td class="cellrowborder" valign="top" width="38.71%" headers="mcps1.1.3.1.1 "><p id="p321412915320"><a name="p321412915320"></a><a name="p321412915320"></a>BatteryPluggedType GetPluggedType()</p> 71</td> 72<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.3.1.2 "><p id="p32141298323"><a name="p32141298323"></a><a name="p32141298323"></a>Obtains the charger type.</p> 73</td> 74</tr> 75<tr id="row269082112447"><td class="cellrowborder" valign="top" width="38.71%" headers="mcps1.1.3.1.1 "><p id="p16690202119449"><a name="p16690202119449"></a><a name="p16690202119449"></a>int32_t GetBatVoltage()</p> 76</td> 77<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.3.1.2 "><p id="p1869014214445"><a name="p1869014214445"></a><a name="p1869014214445"></a>Obtains the battery voltage.</p> 78</td> 79</tr> 80<tr id="row3654173318447"><td class="cellrowborder" valign="top" width="38.71%" headers="mcps1.1.3.1.1 "><p id="p11654173374412"><a name="p11654173374412"></a><a name="p11654173374412"></a>bool IsBatPresent()</p> 81</td> 82<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.3.1.2 "><p id="p13654123354416"><a name="p13654123354416"></a><a name="p13654123354416"></a>Checks whether the battery is present.</p> 83</td> 84</tr> 85<tr id="row12187141584413"><td class="cellrowborder" valign="top" width="38.71%" headers="mcps1.1.3.1.1 "><p id="p718841504418"><a name="p718841504418"></a><a name="p718841504418"></a>char* GetBatTechnology()</p> 86</td> 87<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.3.1.2 "><p id="p181881615194414"><a name="p181881615194414"></a><a name="p181881615194414"></a>Obtains the battery model.</p> 88</td> 89</tr> 90<tr id="row18381310134520"><td class="cellrowborder" valign="top" width="38.71%" headers="mcps1.1.3.1.1 "><p id="p18838610114516"><a name="p18838610114516"></a><a name="p18838610114516"></a>int32_t GetBatTemperature()</p> 91</td> 92<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.3.1.2 "><p id="p13838121064515"><a name="p13838121064515"></a><a name="p13838121064515"></a>Obtains the battery temperature.</p> 93</td> 94</tr> 95</tbody> 96</table> 97 98 99### Usage Guidelines<a name="section12620311012"></a> 100 101The lite battery manager provides APIs for obtaining the battery SoC, battery charging status, and battery SoH. 102 103The sample code is as follows: 104 105``` 106int32_t capacity = GetBatSoc(); 107BatteryChargeState chargState = GetChargingStatus(); 108``` 109 110## Repositories Involved<a name="section63151229062"></a> 111 112[Power management subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/power-management.md) 113 114[powermgr_power_manager](https://gitee.com/openharmony/powermgr_power_manager) 115 116[powermgr_display_manager](https://gitee.com/openharmony/powermgr_display_manager) 117 118[powermgr_battery_manager](https://gitee.com/openharmony/powermgr_battery_manager) 119 120[powermgr_thermal_manager](https://gitee.com/openharmony/powermgr_thermal_manager) 121 122[powermgr_battery_statistics](https://gitee.com/openharmony/powermgr_battery_statistics) 123 124**powermgr_battery_lite** 125 126[powermgr_powermgr_lite](https://gitee.com/openharmony/powermgr_powermgr_lite) 127