google_ttf: check whole data before return the calculated result

add check cc[soc + 1] case before calculating delta_cc. ttf will
trigger update when unplug at "ttf_soc_update": if I unplug at 95%,
it will update from start to 94% however, when we calculate
"ttf_pwr_avg_cc" => it use cc[soc + 1] - cc[soc]

Bug: 163087907
Signed-off-by: Jenny Ho <[email protected]>
Change-Id: Ic06808b809bf68f24f8909b61b5c9e8aad54413f
Signed-off-by: Ken Tsou <[email protected]>
(cherry picked from commit 5fbde1a24857d3d4703af2eb168f0c1e42841239)
diff --git a/google_ttf.c b/google_ttf.c
index 1a3417b..c2c48f2 100644
--- a/google_ttf.c
+++ b/google_ttf.c
@@ -102,9 +102,11 @@
 	int delta_cc;
 
 	/* soc average current demand */
-	if (stats->soc_stats.cc[soc] && stats->soc_stats.elap[soc])
+	if (stats->soc_stats.cc[soc + 1] && stats->soc_stats.cc[soc] &&
+	    stats->soc_stats.elap[soc])
 		sstat = &stats->soc_stats;
-	else if (stats->soc_ref.cc[soc] && stats->soc_ref.elap[soc])
+	else if (stats->soc_ref.cc[soc + 1] && stats->soc_ref.cc[soc] &&
+		 stats->soc_ref.elap[soc])
 		sstat = &stats->soc_ref;
 	else
 		return 0;