Fix issues in battery usage accounting

1. In High usage dialog, show top apps based on battery usage, not app
time.
2. Refactor the check for hidden system modules into ShouldHideSipper,
however don't smear it, this is also the current logic before this CL.

Bug: 133445008
Test: RunSettingsRoboTests
Change-Id: I851a1c9ef9b79a934ba0501cd96001f2e450bda4
This commit is contained in:
Lei Yu
2019-05-28 10:42:19 -07:00
parent 76cf0dbddd
commit c89ba29e92
6 changed files with 105 additions and 69 deletions

View File

@@ -367,6 +367,15 @@ public class BatteryUtilsTest {
assertThat(mBatteryUtils.shouldHideSipper(mNormalBatterySipper)).isTrue();
}
@Test
public void testShouldHideSipper_hiddenSystemModule_ReturnTrue() {
mNormalBatterySipper.drainType = BatterySipper.DrainType.APP;
when(mNormalBatterySipper.getUid()).thenReturn(UID);
when(mBatteryUtils.isHiddenSystemModule(mNormalBatterySipper)).thenReturn(true);
assertThat(mBatteryUtils.shouldHideSipper(mNormalBatterySipper)).isTrue();
}
@Test
public void testCalculateBatteryPercent() {
assertThat(mBatteryUtils.calculateBatteryPercent(BATTERY_SYSTEM_USAGE, TOTAL_BATTERY_USAGE,