health@2.0: IHealthInfoCallback expands HealthInfo struct.

IHealthInfoCallback reports more information, so that
BatteryService can send these fields to BatteryManager in framework.

Test: builds
Bug: 62229583
Change-Id: Ieacd4acabc3e0870d0d2fed04dad9d8c3255986b
Merged-In: Ieacd4acabc3e0870d0d2fed04dad9d8c3255986b
diff --git a/health/2.0/Android.bp b/health/2.0/Android.bp
index f944471..8281a84 100644
--- a/health/2.0/Android.bp
+++ b/health/2.0/Android.bp
@@ -75,6 +75,36 @@
 }
 
 genrule {
+    name: "android.hardware.health-V2.0-java_gen_java",
+    tools: ["hidl-gen"],
+    cmd: "$(location hidl-gen) -o $(genDir) -Ljava -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/V2_0/HealthInfo.java",
+        "android/hardware/health/V2_0/Result.java",
+        "android/hardware/health/V2_0/IHealth.java",
+        "android/hardware/health/V2_0/IHealthInfoCallback.java",
+    ],
+}
+
+java_library {
+    name: "android.hardware.health-V2.0-java",
+    no_framework_libs: true,
+    defaults: ["hidl-java-module-defaults"],
+    srcs: [":android.hardware.health-V2.0-java_gen_java"],
+    libs: [
+        "hwbinder",
+        "android.hardware.health-V1.0-java",
+        "android.hidl.base-V1.0-java",
+    ]
+}
+
+// This package does not export any types. Not creating java constants export.
+
+
+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",
@@ -100,7 +130,6 @@
     ],
 }
 
-
 cc_library {
     name: "android.hardware.health@2.0-adapter-helper",
     defaults: ["hidl-module-defaults"],
diff --git a/health/2.0/Android.mk b/health/2.0/Android.mk
deleted file mode 100644
index 344c963..0000000
--- a/health/2.0/Android.mk
+++ /dev/null
@@ -1,86 +0,0 @@
-# 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/IHealthInfoCallback.hal b/health/2.0/IHealthInfoCallback.hal
index 8e17bb9..15352ee 100644
--- a/health/2.0/IHealthInfoCallback.hal
+++ b/health/2.0/IHealthInfoCallback.hal
@@ -16,8 +16,6 @@
 
 package android.hardware.health@2.0;
 
-import @1.0::HealthInfo;
-
 /**
  * IHealthInfoCallback is the callback interface to
  * {@link IHealthInfoBus.registerCallback}.
diff --git a/health/2.0/types.hal b/health/2.0/types.hal
index 89ea444..0d17f9f 100644
--- a/health/2.0/types.hal
+++ b/health/2.0/types.hal
@@ -16,6 +16,7 @@
 
 package android.hardware.health@2.0;
 
+import @1.0::HealthInfo;
 import @1.0::Result;
 
 /**
@@ -25,3 +26,40 @@
     NOT_FOUND,
     CALLBACK_DIED,
 };
+
+struct HealthInfo {
+    /**
+     * Legacy information from 1.0 HAL.
+     *
+     * If a value is not available, it must be set to 0, UNKNOWN, or empty
+     * string.
+     */
+    @1.0::HealthInfo legacy;
+
+    /**
+     * Average battery current in microamperes. 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.
+     *
+     * If this value is not available, it must be set to 0.
+     */
+    int32_t batteryCurrentAverage;
+
+    /**
+     * Remaining battery capacity percentage of total capacity
+     * (with no fractional part). This value must be in the range 0-100
+     * (inclusive).
+     *
+     * If this value is not available, it must be set to 0.
+     */
+    int32_t batteryCapacity;
+
+    /**
+     * Battery remaining energy in nanowatt-hours.
+     *
+     * If this value is not available, it must be set to 0.
+     */
+    int64_t energyCounter;
+};
\ No newline at end of file