google_battery: add condition for the same marginal and need_rep threshold
Bug: 300479795
Change-Id: I95266cd97d5f5f2ba9c4e41fa1a6b678b62023cc
Signed-off-by: Jenny Ho <[email protected]>
diff --git a/google_battery.c b/google_battery.c
index 062d0f6..e485c3d 100644
--- a/google_battery.c
+++ b/google_battery.c
@@ -4102,9 +4102,9 @@
static int bhi_cycle_count_index(const struct health_data *health_data)
{
const int cc = health_data->bhi_data.cycle_count;
- const int cc_mt = health_data->cycle_count_marginal_threshold;
+ int cc_mt = health_data->cycle_count_marginal_threshold;
const int cc_nrt = health_data->cycle_count_need_rep_threshold;
- const int h_mt = health_data->marginal_threshold;
+ int h_mt = health_data->marginal_threshold;
const int h_nrt = health_data->need_rep_threshold;
int cc_index;
@@ -4112,6 +4112,12 @@
if (h_mt < h_nrt || cc_nrt <= cc_mt)
return BHI_ALGO_FULL_HEALTH;
+ /* remove marginal_threshold */
+ if (h_mt == h_nrt) {
+ h_mt = 100;
+ cc_mt = 0;
+ }
+
/* use interpolation to get index via cycle count/health threshold */
cc_index = (h_mt - h_nrt) * (cc - cc_nrt) / (cc_mt - cc_nrt) + h_nrt;
cc_index = cc_index * 100; /* for BHI_ROUND_INDEX*/