1# Lite Power Manager<a name="EN-US_TOPIC_0000001126247025"></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 power manager provides the following capabilities: 14 151. Managing sleep and wakeup locks. 162. Keeping the device screen always on using a lock 17 18**Figure 1** Lite power manager architecture<a name="fig106301571239"></a> 19 20 21![](figures/en-us_image_0000001079710638.png) 22 23## Directory Structure<a name="section19472752217"></a> 24 25``` 26base/powermgr/powermgr_lite 27├── figures # Architecture figures 28├── frameworks # Frameworks 29│ ├── include # Header files 30│ └── src # Source files 31├── interfaces # APIs 32│ ├── innerkits # Internal APIs 33│ └── kits # External APIs 34├── services # Services 35│ ├── include # Header files 36│ └── src # Source files 37└── utils # Utilities 38 ├── include # Header files 39 └── src # Source files 40``` 41 42## Usage<a name="section146636391856"></a> 43 44### Available APIs<a name="section481251394"></a> 45 46The following table lists the JavaScript APIs provided by the lite power manager. 47 48<a name="table45171237103112"></a> 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="b98969616388"><a name="b98969616388"></a><a name="b98969616388"></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="b17930187133810"><a name="b17930187133810"></a><a name="b17930187133810"></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="p67351028124111"><a name="p67351028124111"></a><a name="p67351028124111"></a>RunningLock *CreateRunningLock(const char *name, RunningLockType type, RunningLockFlag flag)</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>Creates a <strong id="b175677317248"><a name="b175677317248"></a><a name="b175677317248"></a>Runninglock</strong> object.</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="p219643914313"><a name="p219643914313"></a><a name="p219643914313"></a>void DestroyRunningLock(const RunningLock *lock)</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>Destroys an <strong id="b1383113383249"><a name="b1383113383249"></a><a name="b1383113383249"></a>Runninglock</strong> object.</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>BOOL AcquireRunningLock(const RunningLock *lock)</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 a <strong id="b7678195622413"><a name="b7678195622413"></a><a name="b7678195622413"></a>Runninglock</strong> object.</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>BOOL ReleaseRunningLock(const RunningLock *lock)</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>Releases a <strong id="b33588942512"><a name="b33588942512"></a><a name="b33588942512"></a>Runninglock</strong> object.</p> 73</td> 74</tr> 75</tbody> 76</table> 77 78### Usage Guidelines<a name="section12620311012"></a> 79 80**Runninglock Management** 81 82The lite power manager provides APIs to create, obtain, and release **Runninglock** objects. 83 84The sample code is as follows: 85 86``` 87const RunningLock *lock = CreateRunningLock("runinglock_example", RUNNINGLOCK_BACKGROUND, RUNNINGLOCK_FLAG_NONE); 88if (lock == NULL) { 89 return; 90} 91BOOL ret = AcquireRunningLock(lock); 92if (ret == FLASE) { 93 DestroyRunningLock(lock); 94 return; 95} 96ReleaseRunningLock(lock); 97DestroyRunningLock(lock); // Must release runninglock before destroyed 98``` 99 100## Repositories Involved<a name="section63151229062"></a> 101 102[Power management subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/power-management.md) 103 104[powermgr_power_manager](https://gitee.com/openharmony/powermgr_power_manager) 105 106[powermgr_display_manager](https://gitee.com/openharmony/powermgr_display_manager) 107 108[powermgr_battery_manager](https://gitee.com/openharmony/powermgr_battery_manager) 109 110[powermgr_thermal_manager](https://gitee.com/openharmony/powermgr_thermal_manager) 111 112[powermgr_battery_statistics](https://gitee.com/openharmony/powermgr_battery_statistics) 113 114[powermgr_battery_lite](https://gitee.com/openharmony/powermgr_battery_lite) 115 116[powermgr_powermgr_lite](https://gitee.com/openharmony/powermgr_powermgr_lite) 117 118