Add method to calculate last full charge time

Bug: 38481300
Test: RunSettingsRoboTests
Change-Id: Icd551921f263352eb01d0c6ada62d277c8699507
This commit is contained in:
jackqdyulei
2017-05-25 15:26:03 -07:00
parent dd7912e12f
commit 03539a07e4
3 changed files with 33 additions and 4 deletions

View File

@@ -27,6 +27,7 @@ import android.util.Log;
import android.util.SparseLongArray;
import com.android.internal.os.BatterySipper;
import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.overlay.FeatureFactory;
import java.lang.annotation.Retention;
@@ -228,6 +229,19 @@ public class BatteryUtils {
});
}
/**
* Calculate the time since last full charge, including the device off time
*
* @param batteryStatsHelper utility class that contains the data
* @param currentTimeMs current wall time
* @return time in millis
*/
public long calculateLastFullChargeTime(BatteryStatsHelper batteryStatsHelper,
long currentTimeMs) {
return currentTimeMs - batteryStatsHelper.getStats().getStartClockTime();
}
private long convertUsToMs(long timeUs) {
return timeUs / 1000;
}