Thermal

#include <thermal.h>

Summary

Enumerations

AThermalStatus{
  ATHERMAL_STATUS_ERROR = -1,
  ATHERMAL_STATUS_NONE = 0,
  ATHERMAL_STATUS_LIGHT = 1,
  ATHERMAL_STATUS_MODERATE = 2,
  ATHERMAL_STATUS_SEVERE = 3,
  ATHERMAL_STATUS_CRITICAL = 4,
  ATHERMAL_STATUS_EMERGENCY = 5,
  ATHERMAL_STATUS_SHUTDOWN = 6
}
enum

Typedefs

AThermalManager typedef
An opaque type representing a handle to a thermal manager.
AThermal_StatusCallback)(void *data, AThermalStatus status) typedef
void(*
Prototype of the function that is called when thermal status changes.

Functions

AThermal_acquireManager()
Acquire an instance of the thermal manager.
AThermal_getCurrentThermalStatus(AThermalManager *manager)
Gets the current thermal status.
AThermal_registerThermalStatusListener(AThermalManager *manager, AThermal_StatusCallback callback, void *data)
int
Register the thermal status listener for thermal status change.
AThermal_releaseManager(AThermalManager *manager)
void
Release the thermal manager pointer acquired via AThermal_acquireManager.
AThermal_unregisterThermalStatusListener(AThermalManager *manager, AThermal_StatusCallback callback, void *data)
int
Unregister the thermal status listener previously resgistered.

Enumerations

AThermalStatus

 AThermalStatus
Properties
ATHERMAL_STATUS_CRITICAL

Platform has done everything to reduce power.

ATHERMAL_STATUS_EMERGENCY

Key components in platform are shutting down due to thermal condition.

Device functionalities will be limited.

ATHERMAL_STATUS_ERROR

Error in thermal status.

ATHERMAL_STATUS_LIGHT

Light throttling where UX is not impacted.

ATHERMAL_STATUS_MODERATE

Moderate throttling where UX is not largely impacted.

ATHERMAL_STATUS_NONE

Not under throttling.

ATHERMAL_STATUS_SEVERE

Severe throttling where UX is largely impacted.

ATHERMAL_STATUS_SHUTDOWN

Need shutdown immediately.

Typedefs

AThermalManager

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:

AThermal_StatusCallback

void(* AThermal_StatusCallback)(void *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

AThermalManager * 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

AThermalStatus AThermal_getCurrentThermalStatus(
  AThermalManager *manager
)

Gets the current thermal status.

Available since API level 30.

Details
Parameters
manager
The manager instance to use to query the thermal status. Acquired via AThermal_acquireManager.
Returns
current thermal status, ATHERMAL_STATUS_ERROR on failure.

AThermal_registerThermalStatusListener

int AThermal_registerThermalStatusListener(
  AThermalManager *manager,
  AThermal_StatusCallback callback,
  void *data
)

Register the thermal status listener for thermal status change.

Available since API level 30.

Details
Parameters
manager
The manager instance to use to register. Acquired via AThermal_acquireManager.
callback
The callback function to be called when thermal status updated.
data
The data pointer to be passed when callback is called.
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

void AThermal_releaseManager(
  AThermalManager *manager
)

Release the thermal manager pointer acquired via AThermal_acquireManager.

Available since API level 30.

Details
Parameters
manager
The manager to be released.

AThermal_unregisterThermalStatusListener

int AThermal_unregisterThermalStatusListener(
  AThermalManager *manager,
  AThermal_StatusCallback callback,
  void *data
)

Unregister the thermal status listener previously resgistered.

Available since API level 30.

Details
Parameters
manager
The manager instance to use to unregister. Acquired via AThermal_acquireManager.
callback
The callback function to be called when thermal status updated.
data
The data pointer to be passed when callback is called.
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.