IHealth: get* function return 0 on fail.

getChargeCounter, getCurrentNow, getCurrentAverage,
getCapacity, getEnergyCounter returns 0 when result is
not SUCCESS.

This is consistent with the invalid value defined
by @1.0::IHealthInfo and @2.0::IHealthInfo.
IHealthInfoCallback.healthInfoChanged() and
IHealth.getHealthInfo() both zero-fill invalid values.

This does not affect any clients, because client code
checks for result before using the value.

Test: health VTS test
Change-Id: I50e6faa5f4feb42bb1ec899e289567d6dde7e9c2
diff --git a/health/2.0/IHealth.hal b/health/2.0/IHealth.hal
index a33bb15..fbcc89f 100644
--- a/health/2.0/IHealth.hal
+++ b/health/2.0/IHealth.hal
@@ -69,7 +69,7 @@
      *                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.
+     * @return value battery capacity, or 0 if not successful.
      */
     getChargeCounter() generates (Result result, int32_t value);
 
@@ -84,7 +84,7 @@
      *                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
+     * @return value instantaneous battery current, or 0 if not
      *               successful.
      */
     getCurrentNow() generates (Result result, int32_t value);
@@ -101,7 +101,7 @@
      *                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.
+     * @return value average battery current, or 0 if not successful.
      */
     getCurrentAverage() generates (Result result, int32_t value);
 
@@ -113,7 +113,7 @@
      *                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.
+     * @return value remaining battery capacity, or 0 if not successful.
      */
     getCapacity() generates (Result result, int32_t value);
 
@@ -123,7 +123,7 @@
      * @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.
+     * @return value remaining energy, or 0 if not successful.
      */
     getEnergyCounter() generates (Result result, int64_t value);
 
diff --git a/health/2.0/default/Health.cpp b/health/2.0/default/Health.cpp
index 96f6d70..e67cdb4 100644
--- a/health/2.0/default/Health.cpp
+++ b/health/2.0/default/Health.cpp
@@ -108,27 +108,27 @@
 }
 
 Return<void> Health::getChargeCounter(getChargeCounter_cb _hidl_cb) {
-    getProperty(battery_monitor_, BATTERY_PROP_CHARGE_COUNTER, INT32_MIN, _hidl_cb);
+    getProperty<int32_t>(battery_monitor_, BATTERY_PROP_CHARGE_COUNTER, 0, _hidl_cb);
     return Void();
 }
 
 Return<void> Health::getCurrentNow(getCurrentNow_cb _hidl_cb) {
-    getProperty(battery_monitor_, BATTERY_PROP_CURRENT_NOW, INT32_MIN, _hidl_cb);
+    getProperty<int32_t>(battery_monitor_, BATTERY_PROP_CURRENT_NOW, 0, _hidl_cb);
     return Void();
 }
 
 Return<void> Health::getCurrentAverage(getCurrentAverage_cb _hidl_cb) {
-    getProperty(battery_monitor_, BATTERY_PROP_CURRENT_AVG, INT32_MIN, _hidl_cb);
+    getProperty<int32_t>(battery_monitor_, BATTERY_PROP_CURRENT_AVG, 0, _hidl_cb);
     return Void();
 }
 
 Return<void> Health::getCapacity(getCapacity_cb _hidl_cb) {
-    getProperty(battery_monitor_, BATTERY_PROP_CAPACITY, INT32_MIN, _hidl_cb);
+    getProperty<int32_t>(battery_monitor_, BATTERY_PROP_CAPACITY, 0, _hidl_cb);
     return Void();
 }
 
 Return<void> Health::getEnergyCounter(getEnergyCounter_cb _hidl_cb) {
-    getProperty(battery_monitor_, BATTERY_PROP_ENERGY_COUNTER, INT64_MIN, _hidl_cb);
+    getProperty<int64_t>(battery_monitor_, BATTERY_PROP_ENERGY_COUNTER, 0, _hidl_cb);
     return Void();
 }