From e322f02b18508957c0e7cd30e7b54ce8abfb596c Mon Sep 17 00:00:00 2001 From: ykhung Date: Mon, 21 Jun 2021 16:11:08 +0800 Subject: [PATCH] Remove legacy MIN_POWER_THRESHOLD_MILLI_AMP_HOURS threshold value in the new design, we should store all data into the databae for showing the battery history, we should not filter the items first from the consumed battery value threshold Bug: 191468827 Test: make SettingsRoboTests Change-Id: I19d971fc5cdcc40af1693dc8ba2c78586da22d49 --- .../BatteryAppListPreferenceController.java | 4 +--- .../settings/fuelgauge/BatteryUtils.java | 18 ++---------------- .../settings/fuelgauge/BatteryUtilsTest.java | 12 +----------- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java index a6269bf42ea..29872ac4d40 100644 --- a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java +++ b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java @@ -359,9 +359,7 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro componentId < BatteryConsumer.FIRST_CUSTOM_POWER_COMPONENT_ID + deviceConsumer.getCustomPowerComponentCount(); componentId++) { - if (!showAllApps - && mBatteryUtils.shouldHideCustomDevicePowerComponent(deviceConsumer, - componentId)) { + if (!showAllApps) { continue; } diff --git a/src/com/android/settings/fuelgauge/BatteryUtils.java b/src/com/android/settings/fuelgauge/BatteryUtils.java index 52a4629a7ec..d521ed166a1 100644 --- a/src/com/android/settings/fuelgauge/BatteryUtils.java +++ b/src/com/android/settings/fuelgauge/BatteryUtils.java @@ -81,8 +81,6 @@ public class BatteryUtils { private static final String TAG = "BatteryUtils"; - private static final double MIN_POWER_THRESHOLD_MILLI_AMP_HOURS = 0.002; - private static BatteryUtils sInstance; private PackageManager mPackageManager; @@ -180,8 +178,7 @@ public class BatteryUtils { * battery consumption list. */ public boolean shouldHideUidBatteryConsumer(UidBatteryConsumer consumer, String[] packages) { - return consumer.getConsumedPower() < MIN_POWER_THRESHOLD_MILLI_AMP_HOURS - || mPowerUsageFeatureProvider.isTypeSystem(consumer.getUid(), packages) + return mPowerUsageFeatureProvider.isTypeSystem(consumer.getUid(), packages) || shouldHideUidBatteryConsumerUnconditionally(consumer, packages); } @@ -208,21 +205,10 @@ public class BatteryUtils { case BatteryConsumer.POWER_COMPONENT_WIFI: return true; default: - return consumer.getConsumedPower(powerComponentId) - < MIN_POWER_THRESHOLD_MILLI_AMP_HOURS; + return false; } } - /** - * Returns true if the specified device custom power component should be excluded from the - * summary battery consumption list. - */ - public boolean shouldHideCustomDevicePowerComponent(BatteryConsumer consumer, - int customPowerComponentId) { - return consumer.getConsumedPowerForCustomComponent(customPowerComponentId) - < MIN_POWER_THRESHOLD_MILLI_AMP_HOURS; - } - /** * Returns true if one the specified packages belongs to a hidden system module. */ diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java index 1259cdd5713..5a110a54c93 100644 --- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java +++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java @@ -246,17 +246,7 @@ public class BatteryUtilsTest { } @Test - public void testShouldHideSystemConsumer_LowPower_ReturnTrue() { - when(mAggregateBatteryConsumer.getConsumedPower( - BatteryConsumer.POWER_COMPONENT_FLASHLIGHT)).thenReturn(0.0005); - assertThat(mBatteryUtils.shouldHideDevicePowerComponent(mAggregateBatteryConsumer, - BatteryConsumer.POWER_COMPONENT_FLASHLIGHT)).isTrue(); - } - - @Test - public void testShouldHideSystemConsumer_HighPower_ReturnFalse() { - when(mAggregateBatteryConsumer.getConsumedPower( - BatteryConsumer.POWER_COMPONENT_FLASHLIGHT)).thenReturn(0.5); + public void testShouldHideSystemConsumer_OtherType_ReturnFalse() { assertThat(mBatteryUtils.shouldHideDevicePowerComponent(mAggregateBatteryConsumer, BatteryConsumer.POWER_COMPONENT_FLASHLIGHT)).isFalse(); }