Thermal
Summary
Enumerations |
|
---|---|
AThermalStatus{
|
enum Thermal status used in function AThermal_getCurrentThermalStatus and AThermal_StatusCallback. |
Typedefs |
|
---|---|
AThermalHeadroomThreshold
|
typedefstruct AThermalHeadroomThreshold
|
AThermalManager
|
typedefstruct AThermalManager
An opaque type representing a handle to a thermal manager. |
AThermalStatus
|
typedefenum AThermalStatus
|
AThermal_StatusCallback)(void *_Nullable data, AThermalStatus status)
|
typedefvoid(*
Prototype of the function that is called when thermal status changes. |
Functions |
|
---|---|
AThermal_acquireManager()
|
AThermalManager *_Nonnull
Acquire an instance of the thermal manager.
|
AThermal_getCurrentThermalStatus(AThermalManager *_Nonnull manager)
|
Gets the current thermal status.
|
AThermal_getThermalHeadroom(AThermalManager *_Nonnull manager, int forecastSeconds)
|
float
Provides an estimate of how much thermal headroom the device currently has before hitting severe throttling.
|
AThermal_getThermalHeadroomThresholds(AThermalManager *_Nonnull manager, const AThermalHeadroomThreshold *_Nonnull *_Nullable outThresholds, size_t *_Nonnull size)
|
int
Gets the thermal headroom thresholds for all available thermal status.
|
AThermal_registerThermalStatusListener(AThermalManager *_Nonnull manager, AThermal_StatusCallback _Nullable callback, void *_Nullable data)
|
int
Register the thermal status listener for thermal status change.
|
AThermal_releaseManager(AThermalManager *_Nonnull manager)
|
void
Release the thermal manager pointer acquired via AThermal_acquireManager.
|
AThermal_unregisterThermalStatusListener(AThermalManager *_Nonnull manager, AThermal_StatusCallback _Nullable callback, void *_Nullable data)
|
int
Unregister the thermal status listener previously resgistered.
|
Structs |
|
---|---|
AThermalHeadroomThreshold |
This struct defines an instance of headroom threshold value and its status. |
Enumerations
AThermalStatus
Declared inandroid/thermal.h
AThermalStatus
Thermal status used in function AThermal_getCurrentThermalStatus and AThermal_StatusCallback.
Typedefs
AThermalHeadroomThreshold
Declared inandroid/thermal.h
struct AThermalHeadroomThreshold AThermalHeadroomThreshold
AThermalManager
Declared inandroid/thermal.h
struct AThermalManager AThermalManager
An opaque type representing a handle to a thermal manager.
An instance of thermal manager must be acquired prior to using thermal status APIs and must be released after use.
To use:
- Create a new thermal manager instance by calling the AThermal_acquireManager function.
- Get current thermal status with AThermal_getCurrentThermalStatus.
- Register a thermal status listener with AThermal_registerThermalStatusListener.
- Unregister a thermal status listener with AThermal_unregisterThermalStatusListener.
- Release the thermal manager instance with AThermal_releaseManager.
AThermal_StatusCallback
Declared inandroid/thermal.h
void(* AThermal_StatusCallback)(void *_Nullable data, AThermalStatus status)
Prototype of the function that is called when thermal status changes.
It's passed the updated thermal status as parameter, as well as the pointer provided by the client that registered a callback.
Functions
AThermal_acquireManager
Declared inandroid/thermal.h
AThermalManager *_Nonnull AThermal_acquireManager()
Acquire an instance of the thermal manager.
This must be freed using AThermal_releaseManager.
Available since API level 30.
Details | |
---|---|
Returns |
manager instance on success, nullptr on failure.
|
AThermal_getCurrentThermalStatus
Declared inandroid/thermal.h
AThermalStatus AThermal_getCurrentThermalStatus( AThermalManager *_Nonnull manager )
Gets the current thermal status.
Available since API level 30.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
current thermal status, ATHERMAL_STATUS_ERROR on failure.
|
AThermal_getThermalHeadroom
Declared inandroid/thermal.h
float AThermal_getThermalHeadroom( AThermalManager *_Nonnull manager, int forecastSeconds )
Provides an estimate of how much thermal headroom the device currently has before hitting severe throttling.
Note that this only attempts to track the headroom of slow-moving sensors, such as the skin temperature sensor. This means that there is no benefit to calling this function more frequently than about once per second, and attempted to call significantly more frequently may result in the function returning NaN
.
In addition, in order to be able to provide an accurate forecast, the system does not attempt to forecast until it has multiple temperature samples from which to extrapolate. This should only take a few seconds from the time of the first call, but during this time, no forecasting will occur, and the current headroom will be returned regardless of the value of forecastSeconds
.
The value returned is a non-negative float that represents how much of the thermal envelope is in use (or is forecasted to be in use). A value of 1.0 indicates that the device is (or will be) throttled at ATHERMAL_STATUS_SEVERE. Such throttling can affect the CPU, GPU, and other subsystems. Values may exceed 1.0, but there is no implied mapping to specific thermal levels beyond that point. This means that values greater than 1.0 may correspond to ATHERMAL_STATUS_SEVERE, but may also represent heavier throttling.
A value of 0.0 corresponds to a fixed distance from 1.0, but does not correspond to any particular thermal status or temperature. Values on (0.0, 1.0] may be expected to scale linearly with temperature, though temperature changes over time are typically not linear. Negative values will be clamped to 0.0 before returning.
Available since API level 31.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
a value greater than equal to 0.0, where 1.0 indicates the SEVERE throttling threshold, as described above. Returns NaN if the device does not support this functionality or if this function is called significantly faster than once per second.
|
AThermal_getThermalHeadroomThresholds
Declared inandroid/thermal.h
int AThermal_getThermalHeadroomThresholds( AThermalManager *_Nonnull manager, const AThermalHeadroomThreshold *_Nonnull *_Nullable outThresholds, size_t *_Nonnull size )
Gets the thermal headroom thresholds for all available thermal status.
A thermal status will only exist in output if the device manufacturer has the corresponding threshold defined for at least one of its slow-moving skin temperature sensors. If it's set, one should also expect to get it from AThermal_getCurrentThermalStatus or AThermal_StatusCallback.
The headroom threshold is used to interpret the possible thermal throttling status based on the headroom prediction. For example, if the headroom threshold for ATHERMAL_STATUS_LIGHT is 0.7, and a headroom prediction in 10s returns 0.75 (or
AThermal_getThermalHeadroom(10)=0.75
For new devices it's guaranteed to have a single sensor, but for older devices with multiple sensors reporting different threshold values, the minimum threshold is taken to be conservative on predictions. Thus, when reading real-time headroom, it's not guaranteed that a real-time value of 0.75 (or
AThermal_getThermalHeadroom(0)
AThermal_getCurrentThermalStatus()=ATHERMAL_STATUS_LIGHT
AThermal_getCurrentThermalStatus()=ATHERMAL_STATUS_NONE
The returned list of thresholds is cached on first successful query and owned by the thermal manager, which will not change between calls to this function. The caller should only need to free the manager with AThermal_releaseManager.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Returns |
0 on success EINVAL if outThresholds or size_t is nullptr, or *outThresholds is not nullptr. EPIPE if communication with the system service has failed. ENOSYS if the feature is disabled by the current system.
|
AThermal_registerThermalStatusListener
Declared inandroid/thermal.h
int AThermal_registerThermalStatusListener( AThermalManager *_Nonnull manager, AThermal_StatusCallback _Nullable callback, void *_Nullable data )
Register the thermal status listener for thermal status change.
Available since API level 30.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Returns |
0 on success EINVAL if the listener and data pointer were previously added and not removed. EPERM if the required permission is not held. EPIPE if communication with the system service has failed.
|
AThermal_releaseManager
Declared inandroid/thermal.h
void AThermal_releaseManager( AThermalManager *_Nonnull manager )
Release the thermal manager pointer acquired via AThermal_acquireManager.
Available since API level 30.
Details | |||
---|---|---|---|
Parameters |
|
AThermal_unregisterThermalStatusListener
Declared inandroid/thermal.h
int AThermal_unregisterThermalStatusListener( AThermalManager *_Nonnull manager, AThermal_StatusCallback _Nullable callback, void *_Nullable data )
Unregister the thermal status listener previously resgistered.
Available since API level 30.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Returns |
0 on success EINVAL if the listener and data pointer were not previously added. EPERM if the required permission is not held. EPIPE if communication with the system service has failed.
|