diff options
author | Jack Wu <wjack@google.com> | 2023-01-30 20:37:58 +0800 |
---|---|---|
committer | Jack Wu <wjack@google.com> | 2023-01-31 04:54:55 +0000 |
commit | 2ebce4b651436d70d9fcdfa73c39f08529ee283b (patch) | |
tree | 070939402c635bca773f28e012220c6b8af5a5d2 | |
parent | e990a54619390a0ee10452a469fb57c19bedc443 (diff) | |
download | bms-android-gs-pantah-5.10-u-preview-2.tar.gz |
google_battery: fix reporting wrong manufacturing dateandroid-u-preview-2_r0.4android-u-preview-2_r0.3android-gs-pantah-5.10-u-preview-2android-gs-bluejay-5.10-u-preview-2
Bug: 251427008
Change-Id: I8181ce27f93e48591b0c54826a1ef247ea29cb86
Signed-off-by: Jack Wu <wjack@google.com>
(cherry picked from commit c801a5212940edc53c2944818517c63820843b8d)
-rw-r--r-- | google_battery.c | 18 |
1 files changed, 18 insertions, 0 deletions
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 @@ static ssize_t manufacturing_date_show(struct device *dev, 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 @@ static ssize_t first_usage_date_show(struct device *dev, 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]); |