diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryEntry.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryEntry.java index 2b56cc150fe..e9e034721a4 100644 --- a/src/com/android/settings/fuelgauge/batteryusage/BatteryEntry.java +++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryEntry.java @@ -200,16 +200,13 @@ public class BatteryEntry { /** Battery entry for a power component of AggregateBatteryConsumer */ public BatteryEntry(Context context, int powerComponentId, double devicePowerMah, - double appsPowerMah, long usageDurationMs) { + long usageDurationMs) { mContext = context; mBatteryConsumer = null; mUid = Process.INVALID_UID; mIsHidden = false; mPowerComponentId = powerComponentId; - mConsumedPower = - powerComponentId == BatteryConsumer.POWER_COMPONENT_SCREEN - ? devicePowerMah - : devicePowerMah - appsPowerMah; + mConsumedPower = devicePowerMah; mUsageDurationMs = usageDurationMs; mConsumerType = ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY; @@ -224,7 +221,7 @@ public class BatteryEntry { /** Battery entry for a custom power component of AggregateBatteryConsumer */ public BatteryEntry(Context context, int powerComponentId, String powerComponentName, - double devicePowerMah, double appsPowerMah) { + double devicePowerMah) { mContext = context; mBatteryConsumer = null; mUid = Process.INVALID_UID; @@ -234,10 +231,7 @@ public class BatteryEntry { mIconId = R.drawable.ic_power_system; mIcon = context.getDrawable(mIconId); mName = powerComponentName; - mConsumedPower = - powerComponentId == BatteryConsumer.POWER_COMPONENT_SCREEN - ? devicePowerMah - : devicePowerMah - appsPowerMah; + mConsumedPower = devicePowerMah; mConsumerType = ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY; } diff --git a/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java b/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java index b510e5b19e2..c0185d5a45b 100644 --- a/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java +++ b/src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java @@ -1243,14 +1243,11 @@ public final class DataProcessor { final BatteryConsumer deviceConsumer = batteryUsageStats.getAggregateBatteryConsumer( BatteryUsageStats.AGGREGATE_BATTERY_CONSUMER_SCOPE_DEVICE); - final BatteryConsumer appsConsumer = batteryUsageStats.getAggregateBatteryConsumer( - BatteryUsageStats.AGGREGATE_BATTERY_CONSUMER_SCOPE_ALL_APPS); for (int componentId = 0; componentId < BatteryConsumer.POWER_COMPONENT_COUNT; componentId++) { results.add(new BatteryEntry(context, componentId, deviceConsumer.getConsumedPower(componentId), - appsConsumer.getConsumedPower(componentId), deviceConsumer.getUsageDurationMillis(componentId))); } @@ -1260,8 +1257,7 @@ public final class DataProcessor { componentId++) { results.add(new BatteryEntry(context, componentId, deviceConsumer.getCustomPowerComponentName(componentId), - deviceConsumer.getConsumedPowerForCustomComponent(componentId), - appsConsumer.getConsumedPowerForCustomComponent(componentId))); + deviceConsumer.getConsumedPowerForCustomComponent(componentId))); } final List userBatteryConsumers = diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryEntryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryEntryTest.java index 90fa572b36c..463a66dbb41 100644 --- a/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryEntryTest.java +++ b/tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryEntryTest.java @@ -104,11 +104,19 @@ public class BatteryEntryTest { } private BatteryEntry createAggregateBatteryEntry(int powerComponentId) { - return new BatteryEntry(mMockContext, powerComponentId, 200, 100, 1000); + return new BatteryEntry( + mMockContext, + powerComponentId, + /* devicePowerMah= */ 200, + /* usageDurationMs= */ 1000); } private BatteryEntry createCustomAggregateBatteryEntry(int powerComponentId) { - return new BatteryEntry(mMockContext, powerComponentId, "CUSTOM", 200, 100); + return new BatteryEntry( + mMockContext, + powerComponentId, + /* powerComponentName= */ "CUSTOM", + /* devicePowerMah= */ 200); } private BatteryEntry createUserBatteryConsumer(int userId) { @@ -159,7 +167,9 @@ public class BatteryEntryTest { @Test public void batteryEntryForAOD_containCorrectInfo() { final BatteryEntry entry = new BatteryEntry(RuntimeEnvironment.application, - BatteryConsumer.POWER_COMPONENT_AMBIENT_DISPLAY, 200, 100, 1000); + BatteryConsumer.POWER_COMPONENT_AMBIENT_DISPLAY, + /* devicePowerMah= */ 200, + /* usageDurationMs= */ 1000); assertThat(entry.mIconId).isEqualTo(R.drawable.ic_settings_aod); assertThat(entry.mName).isEqualTo("Ambient display"); @@ -168,7 +178,9 @@ public class BatteryEntryTest { @Test public void batteryEntryForCustomComponent_containCorrectInfo() { final BatteryEntry entry = new BatteryEntry(RuntimeEnvironment.application, - BatteryConsumer.FIRST_CUSTOM_POWER_COMPONENT_ID + 42, "ABC", 200, 100); + BatteryConsumer.FIRST_CUSTOM_POWER_COMPONENT_ID + 42, + /* powerComponentName= */ "ABC", + /* devicePowerMah= */ 200); assertThat(entry.mIconId).isEqualTo(R.drawable.ic_power_system); assertThat(entry.mName).isEqualTo("ABC"); @@ -188,7 +200,9 @@ public class BatteryEntryTest { @Test public void getTimeInForegroundMs_aggregateBatteryConsumer() { final BatteryEntry entry = new BatteryEntry(RuntimeEnvironment.application, - BatteryConsumer.POWER_COMPONENT_BLUETOOTH, 10, 20, 100); + BatteryConsumer.POWER_COMPONENT_BLUETOOTH, + /* devicePowerMah= */ 10, + /* usageDurationMs= */ 100); assertThat(entry.getTimeInForegroundMs()).isEqualTo(100L); } @@ -207,7 +221,9 @@ public class BatteryEntryTest { @Test public void getTimeInBackgroundMs_systemConsumer() { final BatteryEntry entry = new BatteryEntry(RuntimeEnvironment.application, - BatteryConsumer.POWER_COMPONENT_BLUETOOTH, 100, 200, 1000); + BatteryConsumer.POWER_COMPONENT_BLUETOOTH, + /* devicePowerMah= */ 100, + /* usageDurationMs= */ 1000); assertThat(entry.getTimeInBackgroundMs()).isEqualTo(0); }