Add abnormal interpolation info to log unexpected conditions

Bug: 184807417
Test: make SettingsRoboTests
Change-Id: I11156c85b6b955dd505b41a9a41be0756638f1dd
This commit is contained in:
ykhung
2021-05-06 10:22:55 +08:00
parent 9db43b8f76
commit 953b7e3bf5
2 changed files with 13 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ package com.android.settings.fuelgauge;
import android.content.ContentValues;
import android.database.Cursor;
import android.os.BatteryConsumer;
import android.util.Log;
import java.time.Duration;
@@ -310,6 +311,14 @@ public class BatteryHistEntry {
lowerHistEntry == null ? 0 : lowerHistEntry.mBackgroundUsageTimeInMs,
upperHistEntry.mBackgroundUsageTimeInMs,
ratio);
// Checks whether there is any abnoaml cases!
if (upperHistEntry.mConsumePower < consumePower
|| upperHistEntry.mForegroundUsageTimeInMs < foregroundUsageTimeInMs
|| upperHistEntry.mBackgroundUsageTimeInMs < backgroundUsageTimeInMs) {
Log.w(TAG, String.format(
"abnormal interpolation:\nupper:%s\nlower:%s",
upperHistEntry, lowerHistEntry));
}
final double batteryLevel =
lowerHistEntry == null
? upperHistEntry.mBatteryLevel