README.md 674 Б
Newer Older
Зарубин Виталий Викторович's avatar
Зарубин Виталий Викторович включено в состав коммита
1
2
3
4
5
6
7
8
9
# Battery Info

The library to access various information about the battery of the device.

### Features:

- Battery charge level.
- Battery charger status.
- Listen charger status.
Зарубин Виталий Викторович's avatar
Зарубин Виталий Викторович включено в состав коммита
10
11
12
13
14
15
16

### Permissions

```
Permissions=DeviceInfo
```

Зарубин Виталий Викторович's avatar
Зарубин Виталий Викторович включено в состав коммита
17
### Dependency
Зарубин Виталий Викторович's avatar
Зарубин Виталий Викторович включено в состав коммита
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

- `LIBS += -ldbus-1`

### Example

```kotlin
var states: MutableMap<ULong, Boolean> = mutableMapOf()

class AuroraBatteryInfo {

    fun getLevel(): Int {
        return BatteryInfo.getLevel()
    }

    fun listen(): ULong {
        return BatteryInfo.listenCharger { id, value ->
            states.put(id, value)
        }
    }

    fun getStateCharger(id: ULong): Boolean {
        return states[id] ?: false
    }
}
```