SystemHealthManager.GetCpuHeadroom(CpuHeadroomParams) Method

Definition

Provides an estimate of available CPU capacity headroom of the device.

[Android.Runtime.Register("getCpuHeadroom", "(Landroid/os/CpuHeadroomParams;)F", "GetGetCpuHeadroom_Landroid_os_CpuHeadroomParams_Handler", ApiSince=36)]
public virtual float GetCpuHeadroom(Android.OS.CpuHeadroomParams? params);
[<Android.Runtime.Register("getCpuHeadroom", "(Landroid/os/CpuHeadroomParams;)F", "GetGetCpuHeadroom_Landroid_os_CpuHeadroomParams_Handler", ApiSince=36)>]
abstract member GetCpuHeadroom : Android.OS.CpuHeadroomParams -> single
override this.GetCpuHeadroom : Android.OS.CpuHeadroomParams -> single

Parameters

params
CpuHeadroomParams

params to customize the CPU headroom calculation, or null to use default.

Returns

a single value headroom or a Float.NaN if it's temporarily unavailable due to server error or not enough user CPU workload. Each valid value ranges from [0, 100], where 0 indicates no more cpu resources can be granted

Attributes

Remarks

Provides an estimate of available CPU capacity headroom of the device.

The value can be used by the calling application to determine if the workload was CPU bound and then take action accordingly to ensure that the workload can be completed smoothly. It can also be used with the thermal status and headroom to determine if reducing the CPU bound workload can help reduce the device temperature to avoid thermal throttling.

If the params are valid, each call will perform at least one synchronous binder transaction that can take more than 1ms. So it's not recommended to call or wait for this on critical threads. Some devices may implement this as an on-demand API with lazy initialization, so the caller should expect higher latency when making the first call (especially with non-default params) since app starts or after changing params, as the device may need to change its data collection.

Java documentation for android.os.health.SystemHealthManager.getCpuHeadroom(android.os.CpuHeadroomParams).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to