Add method to calculate last full charge time
Bug: 38481300 Test: RunSettingsRoboTests Change-Id: Icd551921f263352eb01d0c6ada62d277c8699507
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user