google_battery: fix reporting wrong manufacturing date

Bug: 251427008
Change-Id: I8181ce27f93e48591b0c54826a1ef247ea29cb86
Signed-off-by: Jack Wu <[email protected]>
(cherry picked from commit c801a5212940edc53c2944818517c63820843b8d)
diff --git a/google_battery.c b/google_battery.c
index 190ff67..9e36f76 100644
--- a/google_battery.c
+++ b/google_battery.c
@@ -6692,6 +6692,15 @@
 	struct bm_date *date = &batt_drv->health_data.bhi_data.bm_date;
 	struct rtc_time tm;
 
+	/* read manufacturing date when data is not successfully read in probe */
+	if (date->bm_y == 0) {
+		int ret;
+
+		ret = batt_get_manufacture_date(&batt_drv->health_data.bhi_data);
+		if (ret < 0)
+			return scnprintf(buf, PAGE_SIZE, "%d\n", ret);
+	}
+
 	tm.tm_year = date->bm_y + 100;	// base is 1900
 	tm.tm_mon = date->bm_m - 1;	// 0 is Jan ... 11 is Dec
 	tm.tm_mday = date->bm_d;	// 1st ... 31th
@@ -6750,6 +6759,15 @@
 	struct bm_date date;
 	struct rtc_time tm;
 
+	/* read activation date when data is not successfully read in probe */
+	if (bhi_data->act_date[0] == 0) {
+		int ret;
+
+		ret = batt_get_activation_date(&batt_drv->health_data.bhi_data);
+		if (ret < 0)
+			return scnprintf(buf, PAGE_SIZE, "%d\n", ret);
+	}
+
 	/* format: YYMMDD */
 	date.bm_y = xymd_to_date(bhi_data->act_date[0]) + 20;
 	date.bm_m = xymd_to_date(bhi_data->act_date[1]);