• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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├── frameworks        # Frameworks
30│   ├── include       # Header files
31│   └── src           # Source files
32├── interfaces        # APIs
33│   ├── innerkits     # Internal APIs
34│   └── kits          # External APIs
35├── services          # Services
36│   ├── include       # Header files
37│   └── src           # Source files
38```
39
40## Usage<a name="section146636391856"></a>
41
42### Available APIs<a name="section481251394"></a>
43
44The following table lists the JavaScript APIs provided by the lite battery manager.
45
46<a name="table45171237103112"></a>
47
48<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>
49</th>
50<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>
51</th>
52</tr>
53</thead>
54<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>
55</td>
56<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>
57</td>
58</tr>
59<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>
60</td>
61<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>
62</td>
63</tr>
64<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>
65</td>
66<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>
67</td>
68</tr>
69<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>
70</td>
71<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>
72</td>
73</tr>
74<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>
75</td>
76<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>
77</td>
78</tr>
79<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>
80</td>
81<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>
82</td>
83</tr>
84<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>
85</td>
86<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>
87</td>
88</tr>
89<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>
90</td>
91<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>
92</td>
93</tr>
94</tbody>
95</table>
96
97
98### Usage Guidelines<a name="section12620311012"></a>
99
100The lite battery manager provides APIs for obtaining the battery SoC, battery charging status, and battery SoH.
101
102The sample code is as follows:
103
104```
105int32_t capacity = GetBatSoc();
106BatteryChargeState chargState = GetChargingStatus();
107```
108
109## Repositories Involved<a name="section63151229062"></a>
110
111[Power management subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/power-management.md)
112
113[powermgr_power_manager](https://gitee.com/openharmony/powermgr_power_manager)
114
115[powermgr_display_manager](https://gitee.com/openharmony/powermgr_display_manager)
116
117[powermgr_battery_manager](https://gitee.com/openharmony/powermgr_battery_manager)
118
119[powermgr_thermal_manager](https://gitee.com/openharmony/powermgr_thermal_manager)
120
121[powermgr_battery_statistics](https://gitee.com/openharmony/powermgr_battery_statistics)
122
123**powermgr_battery_lite**
124
125[powermgr_powermgr_lite](https://gitee.com/openharmony/powermgr_powermgr_lite)
126