mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-01-27 14:23:34 +00:00
Health HAL: add hinge info
Add a hingeinfo field to the Health HAL that returns information related to a foldable's hinge health + rated life expectancy. Ignore-AOSP-First: deprecated_ota_test compilation Bug: 371322457 Test: th Change-Id: I23688be268afcc542fa4bc90af37933e9c1c36e7
This commit is contained in:
@@ -249,7 +249,7 @@
|
||||
</hal>
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.health</name>
|
||||
<version>3</version>
|
||||
<version>3-4</version>
|
||||
<interface>
|
||||
<name>IHealth</name>
|
||||
<instance>default</instance>
|
||||
|
||||
@@ -50,9 +50,8 @@ aidl_interface {
|
||||
version: "3",
|
||||
imports: [],
|
||||
},
|
||||
|
||||
],
|
||||
frozen: true,
|
||||
frozen: false,
|
||||
|
||||
}
|
||||
|
||||
@@ -84,7 +83,7 @@ cc_library {
|
||||
name: "android.hardware.health-translate-ndk",
|
||||
defaults: ["android.hardware.health-translate-ndk_defaults"],
|
||||
shared_libs: [
|
||||
"android.hardware.health-V3-ndk",
|
||||
"android.hardware.health-V4-ndk",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -101,7 +100,7 @@ java_library {
|
||||
name: "android.hardware.health-translate-java",
|
||||
srcs: ["android/hardware/health/Translate.java"],
|
||||
libs: [
|
||||
"android.hardware.health-V3-java",
|
||||
"android.hardware.health-V4-java",
|
||||
"android.hardware.health-V2.0-java",
|
||||
"android.hardware.health-V2.1-java",
|
||||
],
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
package android.hardware.health;
|
||||
@Backing(type="int") @VintfStability
|
||||
enum BatteryPartStatus {
|
||||
UNSUPPORTED,
|
||||
ORIGINAL,
|
||||
REPLACED,
|
||||
UNSUPPORTED = 0,
|
||||
ORIGINAL = 1,
|
||||
REPLACED = 2,
|
||||
}
|
||||
|
||||
@@ -60,5 +60,6 @@ parcelable HealthInfo {
|
||||
android.hardware.health.BatteryChargingState chargingState;
|
||||
android.hardware.health.BatteryChargingPolicy chargingPolicy;
|
||||
@nullable android.hardware.health.BatteryHealthData batteryHealthData;
|
||||
@nullable android.hardware.health.HingeInfo[] foldInfos;
|
||||
const int BATTERY_CHARGE_TIME_TO_FULL_NOW_SECONDS_UNSUPPORTED = (-1) /* -1 */;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||
// two cases:
|
||||
// 1). this is a frozen version file - do not edit this in any case.
|
||||
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||
// the interface (from the latest frozen version), the build system will
|
||||
// prompt you to update this file with `m <name>-update-api`.
|
||||
//
|
||||
// You must not make a backward incompatible change to any AIDL file built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.health;
|
||||
@VintfStability
|
||||
parcelable HingeInfo {
|
||||
int numTimesFolded;
|
||||
int expectedHingeLifespan;
|
||||
}
|
||||
@@ -49,6 +49,7 @@ interface IHealth {
|
||||
void setChargingPolicy(android.hardware.health.BatteryChargingPolicy in_value);
|
||||
android.hardware.health.BatteryChargingPolicy getChargingPolicy();
|
||||
android.hardware.health.BatteryHealthData getBatteryHealthData();
|
||||
android.hardware.health.HingeInfo[] getHingeInfo();
|
||||
const int STATUS_UNKNOWN = 2;
|
||||
const int STATUS_CALLBACK_DIED = 4;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.hardware.health.BatteryHealthData;
|
||||
import android.hardware.health.BatteryStatus;
|
||||
import android.hardware.health.DiskStats;
|
||||
import android.hardware.health.StorageInfo;
|
||||
import android.hardware.health.HingeInfo;
|
||||
|
||||
/**
|
||||
* Health Information.
|
||||
@@ -115,7 +116,6 @@ parcelable HealthInfo {
|
||||
* Battery capacity level. See {@link BatteryCapacityLevel} for more details.
|
||||
*/
|
||||
BatteryCapacityLevel batteryCapacityLevel;
|
||||
|
||||
/**
|
||||
* Value of {@link #batteryChargeTimeToFullNowSeconds} if it is not
|
||||
* supported.
|
||||
@@ -148,4 +148,8 @@ parcelable HealthInfo {
|
||||
* Battery health data
|
||||
*/
|
||||
@nullable BatteryHealthData batteryHealthData;
|
||||
/**
|
||||
* Information about foldable hinge health. Will be an empty vector if no hinges present
|
||||
*/
|
||||
@nullable HingeInfo[] foldInfos;
|
||||
}
|
||||
|
||||
37
health/aidl/android/hardware/health/HingeInfo.aidl
Normal file
37
health/aidl/android/hardware/health/HingeInfo.aidl
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.health;
|
||||
|
||||
/*
|
||||
* Information on foldable hinge health life time estimates, end of life
|
||||
* information and other attributes.
|
||||
*
|
||||
* All integers in this struct must be interpreted as non-negative.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable HingeInfo {
|
||||
/**
|
||||
* returns count of times a given hinge has been folded.
|
||||
*
|
||||
* opening fully counts as 1 fold and closing fully counts as another
|
||||
*/
|
||||
int numTimesFolded;
|
||||
/**
|
||||
* returns the expected lifespan of hinge in units of number of folds
|
||||
*/
|
||||
int expectedHingeLifespan;
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import android.hardware.health.DiskStats;
|
||||
import android.hardware.health.HealthInfo;
|
||||
import android.hardware.health.IHealthInfoCallback;
|
||||
import android.hardware.health.StorageInfo;
|
||||
import android.hardware.health.HingeInfo;
|
||||
|
||||
/**
|
||||
* IHealth manages health info and posts events on registered callbacks.
|
||||
@@ -242,4 +243,17 @@ interface IHealth {
|
||||
* for other errors.
|
||||
*/
|
||||
BatteryHealthData getBatteryHealthData();
|
||||
|
||||
/**
|
||||
* Get Hinge info.
|
||||
*
|
||||
* @return vector of HingeInfo structs if successful.
|
||||
* If error:
|
||||
* - Return exception with code EX_UNSUPPORTED_OPERATION
|
||||
* if this property is not supported,
|
||||
* - Return service specific error with code STATUS_UNKNOWN
|
||||
* for other errors.
|
||||
*/
|
||||
HingeInfo[] getHingeInfo();
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ cc_defaults {
|
||||
"libcutils",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"android.hardware.health-V3-ndk",
|
||||
"android.hardware.health-V4-ndk",
|
||||
|
||||
// TODO(b/177269435): remove when BatteryMonitor works with AIDL HealthInfo.
|
||||
"libhidlbase",
|
||||
@@ -48,7 +48,7 @@ cc_defaults {
|
||||
name: "libhealth_aidl_charger_defaults",
|
||||
shared_libs: [
|
||||
// common
|
||||
"android.hardware.health-V3-ndk",
|
||||
"android.hardware.health-V4-ndk",
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"liblog",
|
||||
@@ -195,7 +195,7 @@ cc_fuzz {
|
||||
"service_fuzzer_defaults",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.health-V3-ndk",
|
||||
"android.hardware.health-V4-ndk",
|
||||
"libbase",
|
||||
"liblog",
|
||||
"fuzz_libhealth_aidl_impl",
|
||||
|
||||
@@ -192,6 +192,12 @@ ndk::ScopedAStatus Health::getStorageInfo(std::vector<StorageInfo>*) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Health::getHingeInfo(std::vector<HingeInfo>*) {
|
||||
// This implementation does not support HingeInfo. An implementation may extend this
|
||||
// class and override this function to support storage info.
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Health::getHealthInfo(HealthInfo* out) {
|
||||
battery_monitor_.updateValues();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.health</name>
|
||||
<version>3</version>
|
||||
<version>4</version>
|
||||
<fqname>IHealth/default</fqname>
|
||||
</hal>
|
||||
</manifest>
|
||||
|
||||
@@ -72,6 +72,7 @@ class Health : public BnHealth, public HalHealthLoopCallback {
|
||||
// The default implementations return nothing in |out|.
|
||||
ndk::ScopedAStatus getDiskStats(std::vector<DiskStats>* out) override;
|
||||
ndk::ScopedAStatus getStorageInfo(std::vector<StorageInfo>* out) override;
|
||||
ndk::ScopedAStatus getHingeInfo(std::vector<HingeInfo>* out) override;
|
||||
|
||||
ndk::ScopedAStatus setChargingPolicy(BatteryChargingPolicy in_value) override;
|
||||
ndk::ScopedAStatus getChargingPolicy(BatteryChargingPolicy* out) override;
|
||||
|
||||
@@ -40,7 +40,7 @@ cc_test {
|
||||
"libbinder_ndk",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.health-V3-ndk",
|
||||
"android.hardware.health-V4-ndk",
|
||||
"libgmock",
|
||||
],
|
||||
header_libs: [
|
||||
|
||||
@@ -359,6 +359,19 @@ TEST_P(HealthAidl, getStorageInfo) {
|
||||
ASSERT_THAT(value, Each(IsValidStorageInfo()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests the values returned by getHingeInfo() from interface IHealth.
|
||||
*/
|
||||
TEST_P(HealthAidl, getHingeInfo) {
|
||||
std::vector<HingeInfo> value;
|
||||
auto status = health->getHingeInfo(&value);
|
||||
ASSERT_THAT(status, AnyOf(IsOk(), ExceptionIs(EX_UNSUPPORTED_OPERATION)));
|
||||
if (!status.isOk()) return;
|
||||
for (auto& hinge : value) {
|
||||
ASSERT_TRUE(hinge.expectedHingeLifespan > 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests the values returned by getDiskStats() from interface IHealth.
|
||||
*/
|
||||
|
||||
@@ -34,7 +34,7 @@ cc_defaults {
|
||||
"-Werror",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.health-V3-ndk",
|
||||
"android.hardware.health-V4-ndk",
|
||||
"android.hardware.health-translate-ndk",
|
||||
"android.hardware.health@1.0",
|
||||
"android.hardware.health@2.0",
|
||||
|
||||
@@ -43,6 +43,7 @@ class HealthShim : public BnHealth {
|
||||
ndk::ScopedAStatus getEnergyCounterNwh(int64_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus getChargeStatus(BatteryStatus* _aidl_return) override;
|
||||
ndk::ScopedAStatus getStorageInfo(std::vector<StorageInfo>* _aidl_return) override;
|
||||
ndk::ScopedAStatus getHingeInfo(std::vector<HingeInfo>* _aidl_return) override;
|
||||
ndk::ScopedAStatus getDiskStats(std::vector<DiskStats>* _aidl_return) override;
|
||||
ndk::ScopedAStatus getHealthInfo(HealthInfo* _aidl_return) override;
|
||||
ndk::ScopedAStatus setChargingPolicy(BatteryChargingPolicy in_value) override;
|
||||
|
||||
@@ -190,6 +190,10 @@ ScopedAStatus HealthShim::getStorageInfo(std::vector<StorageInfo>* out) {
|
||||
return ReturnAndResultToStatus(ret, out_result);
|
||||
}
|
||||
|
||||
ScopedAStatus HealthShim::getHingeInfo(std::vector<HingeInfo>* /*out*/) {
|
||||
return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ScopedAStatus HealthShim::getDiskStats(std::vector<DiskStats>* out) {
|
||||
Result out_result = Result::UNKNOWN;
|
||||
auto ret = service_->getDiskStats([out, &out_result](auto result, const auto& value) {
|
||||
|
||||
Reference in New Issue
Block a user