mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 05:56:34 +00:00
Merge changes from topic "batteryStateOfHealth"
* changes: health: get batteryStateOfHealth from healthd health: batteryStateOfHealth should be a property
This commit is contained in:
@@ -34,11 +34,11 @@
|
||||
package android.hardware.health;
|
||||
@Backing(type="int") @VintfStability
|
||||
enum BatteryCapacityLevel {
|
||||
UNSUPPORTED = -1,
|
||||
UNKNOWN = 0,
|
||||
CRITICAL = 1,
|
||||
LOW = 2,
|
||||
NORMAL = 3,
|
||||
HIGH = 4,
|
||||
FULL = 5,
|
||||
UNSUPPORTED = (-1) /* -1 */,
|
||||
UNKNOWN,
|
||||
CRITICAL,
|
||||
LOW,
|
||||
NORMAL,
|
||||
HIGH,
|
||||
FULL,
|
||||
}
|
||||
|
||||
@@ -36,4 +36,5 @@ package android.hardware.health;
|
||||
parcelable BatteryHealthData {
|
||||
long batteryManufacturingDateSeconds;
|
||||
long batteryFirstUsageSeconds;
|
||||
long batteryStateOfHealth;
|
||||
}
|
||||
|
||||
@@ -57,9 +57,8 @@ parcelable HealthInfo {
|
||||
android.hardware.health.BatteryCapacityLevel batteryCapacityLevel;
|
||||
long batteryChargeTimeToFullNowSeconds;
|
||||
int batteryFullChargeDesignCapacityUah;
|
||||
int batteryStateOfHealth;
|
||||
android.hardware.health.BatteryChargingState chargingState;
|
||||
android.hardware.health.BatteryChargingPolicy chargingPolicy;
|
||||
@nullable android.hardware.health.BatteryHealthData batteryHealthData;
|
||||
const int BATTERY_CHARGE_TIME_TO_FULL_NOW_SECONDS_UNSUPPORTED = -1;
|
||||
const int BATTERY_CHARGE_TIME_TO_FULL_NOW_SECONDS_UNSUPPORTED = (-1) /* -1 */;
|
||||
}
|
||||
|
||||
@@ -29,4 +29,11 @@ parcelable BatteryHealthData {
|
||||
* The date of first usage is reported in epoch.
|
||||
*/
|
||||
long batteryFirstUsageSeconds;
|
||||
/**
|
||||
* Measured battery state of health (remaining estimate full charge capacity
|
||||
* relative to the rated capacity in %).
|
||||
* Value must be 0 if batteryStatus is UNKNOWN.
|
||||
* Otherwise, value must be in the range 0 to 100.
|
||||
*/
|
||||
long batteryStateOfHealth;
|
||||
}
|
||||
|
||||
@@ -136,13 +136,6 @@ parcelable HealthInfo {
|
||||
* Value must be less than 100 000 000 µAh if known.
|
||||
*/
|
||||
int batteryFullChargeDesignCapacityUah;
|
||||
/**
|
||||
* Measured battery state of health (remaining estimate full charge capacity
|
||||
* relative to the rated capacity in %).
|
||||
* Value must be 0 if batteryStatus is UNKNOWN.
|
||||
* Otherwise, value must be in the range 0 to 100.
|
||||
*/
|
||||
int batteryStateOfHealth;
|
||||
/**
|
||||
* Battery charging state
|
||||
*/
|
||||
|
||||
@@ -148,6 +148,11 @@ ndk::ScopedAStatus Health::getBatteryHealthData(BatteryHealthData* out) {
|
||||
!res.isOk()) {
|
||||
LOG(WARNING) << "Cannot get First_usage_date: " << res.getDescription();
|
||||
}
|
||||
if (auto res = GetProperty<int64_t>(&battery_monitor_, ::android::BATTERY_PROP_STATE_OF_HEALTH,
|
||||
0, &out->batteryStateOfHealth);
|
||||
!res.isOk()) {
|
||||
LOG(WARNING) << "Cannot get Battery_state_of_health: " << res.getDescription();
|
||||
}
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -278,6 +278,10 @@ MATCHER(IsValidHealthData, "") {
|
||||
*result_listener << " for batteryFirstUsageSeconds.";
|
||||
return false;
|
||||
}
|
||||
if (!ExplainMatchResult(Ge(-1), arg.batteryStateOfHealth, result_listener)) {
|
||||
*result_listener << " for batteryStateOfHealth.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user