自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
DeviceBatteryResourceMetricCollector
public
class
DeviceBatteryResourceMetricCollector
extends Object
implements
IResourceMetricCollector
java.lang.Object
|
↳ |
com.android.tradefed.monitoring.collector.DeviceBatteryResourceMetricCollector
|
此收集器会收集设备电池指标。它会发出 adb shell 命令并解析响应,指标包括状态、运行状况、等级、比例和温度。
摘要
常量
BATTERY_TEMP_DENOMINATOR
public static final float BATTERY_TEMP_DENOMINATOR
常量值:
10.0
字段
BATTERY_CMD
public static final String BATTERY_CMD
BATTERY_PATTERN
public static final Pattern BATTERY_PATTERN
BATTERY_RESOURCE_NAME
public static final String BATTERY_RESOURCE_NAME
FIELD_GROUP
public static final String FIELD_GROUP
温度
public static final String TEMPERATURE
VALUE_GROUP
public static final String VALUE_GROUP
公共构造函数
DeviceBatteryResourceMetricCollector
public DeviceBatteryResourceMetricCollector ()
公共方法
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# DeviceBatteryResourceMetricCollector\n====================================\n\n\n`\npublic\n\n\nclass\nDeviceBatteryResourceMetricCollector\n`\n\n\n`\n\nextends Object\n\n\n`\n\n`\n\n\nimplements\n\n`[IResourceMetricCollector](../../../../../../../reference/tradefed/com/android/tradefed/monitoring/collector/IResourceMetricCollector.html)`\n\n\n`\n\n|---|--------------------------------------------------------------------------------|\n| java.lang.Object ||\n| ↳ | com.android.tradefed.monitoring.collector.DeviceBatteryResourceMetricCollector |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nThis collector collects device battery metrics. It issues adb shell commands and parse the\nresponse, the metrics include status, health, level, scale and temperature.\n\nSummary\n-------\n\n| ### Constants ||\n|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `float` | [BATTERY_TEMP_DENOMINATOR](../../../../../../../reference/tradefed/com/android/tradefed/monitoring/collector/DeviceBatteryResourceMetricCollector.html#BATTERY_TEMP_DENOMINATOR) |\n\n| ### Fields ||\n|--------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` public static final String` | [BATTERY_CMD](../../../../../../../reference/tradefed/com/android/tradefed/monitoring/collector/DeviceBatteryResourceMetricCollector.html#BATTERY_CMD) |\n| ` public static final Pattern` | [BATTERY_PATTERN](../../../../../../../reference/tradefed/com/android/tradefed/monitoring/collector/DeviceBatteryResourceMetricCollector.html#BATTERY_PATTERN) |\n| ` public static final String` | [BATTERY_RESOURCE_NAME](../../../../../../../reference/tradefed/com/android/tradefed/monitoring/collector/DeviceBatteryResourceMetricCollector.html#BATTERY_RESOURCE_NAME) |\n| ` public static final String` | [FIELD_GROUP](../../../../../../../reference/tradefed/com/android/tradefed/monitoring/collector/DeviceBatteryResourceMetricCollector.html#FIELD_GROUP) |\n| ` public static final String` | [TEMPERATURE](../../../../../../../reference/tradefed/com/android/tradefed/monitoring/collector/DeviceBatteryResourceMetricCollector.html#TEMPERATURE) |\n| ` public static final String` | [VALUE_GROUP](../../../../../../../reference/tradefed/com/android/tradefed/monitoring/collector/DeviceBatteryResourceMetricCollector.html#VALUE_GROUP) |\n\n| ### Public constructors ||\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| ` `[DeviceBatteryResourceMetricCollector](../../../../../../../reference/tradefed/com/android/tradefed/monitoring/collector/DeviceBatteryResourceMetricCollector.html#DeviceBatteryResourceMetricCollector())`() ` |\n\n| ### Public methods ||\n|-----|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` ` | ` `[getDeviceResourceMetrics](../../../../../../../reference/tradefed/com/android/tradefed/monitoring/collector/DeviceBatteryResourceMetricCollector.html#getDeviceResourceMetrics(com.android.tradefed.command.remote.DeviceDescriptor,%20com.android.tradefed.device.IDeviceManager))`(`[DeviceDescriptor](../../../../../../../reference/tradefed/com/android/tradefed/command/remote/DeviceDescriptor.html)` descriptor, `[IDeviceManager](../../../../../../../reference/tradefed/com/android/tradefed/device/IDeviceManager.html)` deviceManager) ` Gets device battery state. |\n\nConstants\n---------\n\n### BATTERY_TEMP_DENOMINATOR\n\n```\npublic static final float BATTERY_TEMP_DENOMINATOR\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nConstant Value:\n\n10.0\n\n\nFields\n------\n\n### BATTERY_CMD\n\n```\npublic static final String BATTERY_CMD\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### BATTERY_PATTERN\n\n```\npublic static final Pattern BATTERY_PATTERN\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### BATTERY_RESOURCE_NAME\n\n```\npublic static final String BATTERY_RESOURCE_NAME\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### FIELD_GROUP\n\n```\npublic static final String FIELD_GROUP\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### TEMPERATURE\n\n```\npublic static final String TEMPERATURE\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### VALUE_GROUP\n\n```\npublic static final String VALUE_GROUP\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nPublic constructors\n-------------------\n\n### DeviceBatteryResourceMetricCollector\n\n```\npublic DeviceBatteryResourceMetricCollector ()\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nPublic methods\n--------------\n\n### getDeviceResourceMetrics\n\n```\npublic getDeviceResourceMetrics (../../../../../../../reference/tradefed/com/android/tradefed/command/remote/DeviceDescriptor.html descriptor, \n ../../../../../../../reference/tradefed/com/android/tradefed/device/IDeviceManager.html deviceManager)\n```\n\nGets device battery state.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `descriptor` | `DeviceDescriptor`: the [DeviceDescriptor](../../../../../../../reference/tradefed/com/android/tradefed/command/remote/DeviceDescriptor.html) about the metricizing device. \u003cbr /\u003e |\n| `deviceManager` | `IDeviceManager`: the [IDeviceManager](../../../../../../../reference/tradefed/com/android/tradefed/device/IDeviceManager.html) instance. \u003cbr /\u003e |\n\n| Returns ||\n|---|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | a [ERROR(/Collection)](../../../../../../../) of device [Resource](../../../../../../../reference/tradefed/com/google/dualhomelab/monitoringagent/resourcemonitoring/Resource.html). \u003cbr /\u003e |"]]