diff options
-rw-r--r-- | health/2.0/Android.bp | 156 | ||||
-rw-r--r-- | health/2.0/Android.mk | 86 | ||||
-rw-r--r-- | health/2.0/IHealth.hal | 140 | ||||
-rw-r--r-- | health/2.0/IHealthInfoCallback.hal | 32 | ||||
-rw-r--r-- | health/2.0/types.hal | 27 | ||||
-rw-r--r-- | health/Android.bp | 1 |
6 files changed, 442 insertions, 0 deletions
diff --git a/health/2.0/Android.bp b/health/2.0/Android.bp new file mode 100644 index 000000000..d7e8dd090 --- /dev/null +++ b/health/2.0/Android.bp @@ -0,0 +1,156 @@ +// This file is autogenerated by hidl-gen. Do not edit manually. + +filegroup { + name: "android.hardware.health@2.0_hal", + srcs: [ + "types.hal", + "IHealth.hal", + "IHealthInfoCallback.hal", + ], +} + +genrule { + name: "android.hardware.health@2.0_genc++", + tools: ["hidl-gen"], + cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.health@2.0", + srcs: [ + ":android.hardware.health@2.0_hal", + ], + out: [ + "android/hardware/health/2.0/types.cpp", + "android/hardware/health/2.0/HealthAll.cpp", + "android/hardware/health/2.0/HealthInfoCallbackAll.cpp", + ], +} + +genrule { + name: "android.hardware.health@2.0_genc++_headers", + tools: ["hidl-gen"], + cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.health@2.0", + srcs: [ + ":android.hardware.health@2.0_hal", + ], + out: [ + "android/hardware/health/2.0/types.h", + "android/hardware/health/2.0/hwtypes.h", + "android/hardware/health/2.0/IHealth.h", + "android/hardware/health/2.0/IHwHealth.h", + "android/hardware/health/2.0/BnHwHealth.h", + "android/hardware/health/2.0/BpHwHealth.h", + "android/hardware/health/2.0/BsHealth.h", + "android/hardware/health/2.0/IHealthInfoCallback.h", + "android/hardware/health/2.0/IHwHealthInfoCallback.h", + "android/hardware/health/2.0/BnHwHealthInfoCallback.h", + "android/hardware/health/2.0/BpHwHealthInfoCallback.h", + "android/hardware/health/2.0/BsHealthInfoCallback.h", + ], +} + +cc_library { + name: "android.hardware.health@2.0", + defaults: ["hidl-module-defaults"], + generated_sources: ["android.hardware.health@2.0_genc++"], + generated_headers: ["android.hardware.health@2.0_genc++_headers"], + export_generated_headers: ["android.hardware.health@2.0_genc++_headers"], + vendor_available: true, + vndk: { + enabled: true, + }, + shared_libs: [ + "libhidlbase", + "libhidltransport", + "libhwbinder", + "liblog", + "libutils", + "libcutils", + "android.hardware.health@1.0", + ], + export_shared_lib_headers: [ + "libhidlbase", + "libhidltransport", + "libhwbinder", + "libutils", + "android.hardware.health@1.0", + ], +} + +genrule { + name: "android.hardware.health@2.0-adapter-helper_genc++", + tools: ["hidl-gen"], + cmd: "$(location hidl-gen) -o $(genDir) -Lc++-adapter-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.health@2.0", + srcs: [ + ":android.hardware.health@2.0_hal", + ], + out: [ + "android/hardware/health/2.0/AHealth.cpp", + "android/hardware/health/2.0/AHealthInfoCallback.cpp", + ], +} + +genrule { + name: "android.hardware.health@2.0-adapter-helper_genc++_headers", + tools: ["hidl-gen"], + cmd: "$(location hidl-gen) -o $(genDir) -Lc++-adapter-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.health@2.0", + srcs: [ + ":android.hardware.health@2.0_hal", + ], + out: [ + "android/hardware/health/2.0/AHealth.h", + "android/hardware/health/2.0/AHealthInfoCallback.h", + ], +} + + +cc_library { + name: "android.hardware.health@2.0-adapter-helper", + defaults: ["hidl-module-defaults"], + generated_sources: ["android.hardware.health@2.0-adapter-helper_genc++"], + generated_headers: ["android.hardware.health@2.0-adapter-helper_genc++_headers"], + export_generated_headers: ["android.hardware.health@2.0-adapter-helper_genc++_headers"], + vendor_available: true, + shared_libs: [ + "libhidlbase", + "libhidltransport", + "libhwbinder", + "liblog", + "libutils", + "libcutils", + "libhidladapter", + "android.hardware.health@1.0", + "android.hardware.health@2.0", + "android.hardware.health@1.0-adapter-helper", + "android.hidl.base@1.0-adapter-helper", + ], + export_shared_lib_headers: [ + "libhidlbase", + "libhidltransport", + "libhwbinder", + "libutils", + "libhidladapter", + "android.hardware.health@1.0", + "android.hardware.health@2.0", + "android.hardware.health@1.0-adapter-helper", + "android.hidl.base@1.0-adapter-helper", + ], +} + +genrule { + name: "android.hardware.health@2.0-adapter_genc++", + tools: ["hidl-gen"], + cmd: "$(location hidl-gen) -o $(genDir) -Lc++-adapter-main -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.health@2.0", + out: ["main.cpp"] +} + +cc_test { + name: "android.hardware.health@2.0-adapter", + shared_libs: [ + "libhidladapter", + "libhidlbase", + "libhidltransport", + "libutils", + "android.hardware.health@1.0", + "android.hardware.health@2.0", + "android.hardware.health@2.0-adapter-helper", + ], + generated_sources: ["android.hardware.health@2.0-adapter_genc++"], +} diff --git a/health/2.0/Android.mk b/health/2.0/Android.mk new file mode 100644 index 000000000..344c96323 --- /dev/null +++ b/health/2.0/Android.mk @@ -0,0 +1,86 @@ +# This file is autogenerated by hidl-gen. Do not edit manually. + +LOCAL_PATH := $(call my-dir) + +################################################################################ + +include $(CLEAR_VARS) +LOCAL_MODULE := android.hardware.health-V2.0-java +LOCAL_MODULE_CLASS := JAVA_LIBRARIES + +intermediates := $(call local-generated-sources-dir, COMMON) + +HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX) + +LOCAL_JAVA_LIBRARIES := \ + android.hardware.health-V1.0-java \ + android.hidl.base-V1.0-java \ + +LOCAL_NO_STANDARD_LIBRARIES := true +LOCAL_JAVA_LIBRARIES += core-oj hwbinder + +# +# Build types.hal (Result) +# +GEN := $(intermediates)/android/hardware/health/V2_0/Result.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.health@2.0::types.Result + +$(GEN): $(LOCAL_PATH)/types.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) + +# +# Build IHealth.hal +# +GEN := $(intermediates)/android/hardware/health/V2_0/IHealth.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IHealth.hal +$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IHealthInfoCallback.hal +$(GEN): $(LOCAL_PATH)/IHealthInfoCallback.hal +$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal +$(GEN): $(LOCAL_PATH)/types.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.health@2.0::IHealth + +$(GEN): $(LOCAL_PATH)/IHealth.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) + +# +# Build IHealthInfoCallback.hal +# +GEN := $(intermediates)/android/hardware/health/V2_0/IHealthInfoCallback.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IHealthInfoCallback.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.health@2.0::IHealthInfoCallback + +$(GEN): $(LOCAL_PATH)/IHealthInfoCallback.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) +include $(BUILD_JAVA_LIBRARY) + + + +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/health/2.0/IHealth.hal b/health/2.0/IHealth.hal new file mode 100644 index 000000000..3e10701a4 --- /dev/null +++ b/health/2.0/IHealth.hal @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2017 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@2.0; + +import @1.0::BatteryStatus; + +import IHealthInfoCallback; + +/** + * IHealth manages health info and posts events on registered callbacks. + */ +interface IHealth { + + /** + * Register a callback for any health info events. + * + * Registering a new callback must not unregister the old one; the old + * callback remains registered until one of the following happens: + * - A client explicitly calls {@link unregisterCallback} to unregister it. + * - The client process that hosts the callback dies. + * + * @param callback the callback to register. + * @return result SUCCESS if successful, + * UNKNOWN for other errors. + */ + registerCallback(IHealthInfoCallback callback) generates (Result result); + + /** + * Explicitly unregister a callback that is previously registered through + * {@link registerCallback}. + * + * @param callback the callback to unregister + * @return result SUCCESS if successful, + * NOT_FOUND if callback is not registered previously, + * UNKNOWN for other errors. + */ + unregisterCallback(IHealthInfoCallback callback) generates (Result result); + + /** + * Schedule update. + * + * When update() is called, the service must notify all registered callbacks + * with the most recent health info. + * + * @return result SUCCESS if successful, + * CALLBACK_DIED if any registered callback is dead, + * UNKNOWN for other errors. + */ + update() generates (Result result); + + /** + * Get battery capacity in microampere-hours(µAh). + * + * @return result SUCCESS if successful, + * NOT_SUPPORTED if this property is not supported + * (e.g. the file that stores this property does not exist), + * UNKNOWN for other errors. + * @return value battery capacity, or INT32_MIN if not successful. + */ + getChargeCounter() generates (Result result, int32_t value); + + /** + * Get instantaneous battery current in microamperes(µA). + * + * Positive values indicate net current entering the battery from a charge + * source, negative values indicate net current discharging from the + * battery. + * + * @return result SUCCESS if successful, + * NOT_SUPPORTED if this property is not supported + * (e.g. the file that stores this property does not exist), + * UNKNOWN for other errors. + * @return value instantaneous battery current, or INT32_MIN if not + * successful. + */ + getCurrentNow() generates (Result result, int32_t value); + + /** + * Get average battery current in microamperes(µA). + * + * Positive values indicate net current entering the battery from a charge + * source, negative values indicate net current discharging from the + * battery. The time period over which the average is computed may depend on + * the fuel gauge hardware and its configuration. + * + * @return result SUCCESS if successful, + * NOT_SUPPORTED if this property is not supported + * (e.g. the file that stores this property does not exist), + * UNKNOWN for other errors. + * @return value average battery current, or INT32_MIN if not successful. + */ + getCurrentAverage() generates (Result result, int32_t value); + + /** + * Get remaining battery capacity percentage of total capacity + * (with no fractional part). + * + * @return result SUCCESS if successful, + * NOT_SUPPORTED if this property is not supported + * (e.g. the file that stores this property does not exist), + * UNKNOWN for other errors. + * @return value remaining battery capacity, or INT32_MIN if not successful. + */ + getCapacity() generates (Result result, int32_t value); + + /** + * Get battery remaining energy in nanowatt-hours. + * + * @return result SUCCESS if successful, + * NOT_SUPPORTED if this property is not supported, + * UNKNOWN for other errors. + * @return value remaining energy, or INT64_MIN if not successful. + */ + getEnergyCounter() generates (Result result, int64_t value); + + /** + * Get battery charge status. + * + * @return result SUCCESS if successful, + * NOT_SUPPORTED if this property is not supported + * (e.g. the file that stores this property does not exist), + * UNKNOWN other errors. + * @return value charge status, or UNKNOWN if not successful. + */ + getChargeStatus() generates (Result result, BatteryStatus value); +}; diff --git a/health/2.0/IHealthInfoCallback.hal b/health/2.0/IHealthInfoCallback.hal new file mode 100644 index 000000000..8e17bb96b --- /dev/null +++ b/health/2.0/IHealthInfoCallback.hal @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2017 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@2.0; + +import @1.0::HealthInfo; + +/** + * IHealthInfoCallback is the callback interface to + * {@link IHealthInfoBus.registerCallback}. + */ +interface IHealthInfoCallback { + /** + * An implementation of IHealthInfoBus must call healthInfoChanged on all + * registered callbacks after health info changes. + * @param info the updated HealthInfo + */ + oneway healthInfoChanged(HealthInfo info); +}; diff --git a/health/2.0/types.hal b/health/2.0/types.hal new file mode 100644 index 000000000..89ea44486 --- /dev/null +++ b/health/2.0/types.hal @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2017 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@2.0; + +import @1.0::Result; + +/** + * Status values for HAL methods. + */ +enum Result : @1.0::Result { + NOT_FOUND, + CALLBACK_DIED, +}; diff --git a/health/Android.bp b/health/Android.bp index 33f70ebae..31e042a98 100644 --- a/health/Android.bp +++ b/health/Android.bp @@ -2,4 +2,5 @@ subdirs = [ "1.0", "1.0/vts/functional", + "2.0", ] |