Ocean
Loading...
Searching...
No Matches
Battery.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_PLATFORM_ANDROID_BATTERY_H
9#define META_OCEAN_PLATFORM_ANDROID_BATTERY_H
10
12
14
15namespace Ocean
16{
17
18namespace Platform
19{
20
21namespace Android
22{
23
24/**
25 * This class implements battery functions.
26 * @ingroup platformandroid
27 */
28class OCEAN_PLATFORM_ANDROID_EXPORT Battery
29{
30 protected:
31
32 /**
33 * Definition of a scoped object for FILE pointers.
34 */
35 using ScopedFILE = ScopedObjectCompileTimeT<FILE*, FILE*, int, pclose, 0, false /*tCheckReturnValue*/>;
36
37 public:
38
39 /**
40 * Returns the current battery capacity status in percent.
41 * @param path Optional path to the battery file, if not specified the default path will be used
42 * @return Current battery capacity status, -1 if invalid
43 */
44 static float currentCapacity(const char* path = nullptr);
45
46 /**
47 * Returns the current battery temperature in Celsius.
48 * @return Current battery temperature, -1 if invalid
49 */
50 static float currentTemperature();
51
52 /**
53 * Returns the current battery current in amps.
54 * @param current The resulting single current reading for the battery, in amps
55 * @return True, if succeeded
56 */
57 static bool currentCurrent(double& current);
58
59 /**
60 * Returns the current battery voltage in volts.
61 * @param voltage The resulting single voltage reading for the battery, in volts
62 * @return True, if succeeded
63 */
64 static bool currentVoltage(double& voltage);
65
66 /**
67 * Returns whether the battery is charging.
68 * @return state The resulting state whether the battery is charging
69 * @return True, if succeeded
70 */
71 static bool isCharging(bool& state);
72};
73
74}
75
76}
77
78}
79
80#endif // META_OCEAN_PLATFORM_ANDROID_BATTERY_H
This class implements battery functions.
Definition Battery.h:29
static bool currentVoltage(double &voltage)
Returns the current battery voltage in volts.
static float currentCapacity(const char *path=nullptr)
Returns the current battery capacity status in percent.
static bool currentCurrent(double &current)
Returns the current battery current in amps.
static bool isCharging(bool &state)
Returns whether the battery is charging.
static float currentTemperature()
Returns the current battery temperature in Celsius.
This class wraps an unmanaged object (or reference) which needs to be released after usage.
Definition ScopedObject.h:166
The namespace covering the entire Ocean framework.
Definition Accessor.h:15