Ocean
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 
15 namespace Ocean
16 {
17 
18 namespace Platform
19 {
20 
21 namespace Android
22 {
23 
24 /**
25  * This class implements battery functions.
26  * @ingroup platformandroid
27  */
28 class 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  * @return Current battery capacity status, -1 if invalid
42  */
43  static float currentCapacity();
44 
45  /**
46  * Returns the current battery temperature in Celsius.
47  * @return Current battery temperature, -1 if invalid
48  */
49  static float currentTemperature();
50 
51  /**
52  * Returns the current battery current in amps.
53  * @param current The resulting single current reading for the battery, in amps
54  * @return True, if succeeded
55  */
56  static bool currentCurrent(double& current);
57 
58  /**
59  * Returns the current battery voltage in volts.
60  * @param voltage The resulting single voltage reading for the battery, in volts
61  * @return True, if succeeded
62  */
63  static bool currentVoltage(double& voltage);
64 
65  /**
66  * Returns whether the battery is charging.
67  * @return state The resulting state whether the battery is charging
68  * @return True, if succeeded
69  */
70  static bool isCharging(bool& state);
71 };
72 
73 }
74 
75 }
76 
77 }
78 
79 #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 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.
static float currentCapacity()
Returns the current battery capacity status in percent.
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