Merge "Don't show Screen as Apps in advanced battery page" into oc-dev
am: 89bc5b2bff

Change-Id: I1058418e9df7965046a6387594c60fb3e8fad629
diff --git a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
index a0ebba8..29cd4e8 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
@@ -227,6 +227,11 @@
     }
 
     @VisibleForTesting
+    boolean shouldShowBatterySipper(BatterySipper batterySipper) {
+        return batterySipper.drainType != DrainType.SCREEN;
+    }
+
+    @VisibleForTesting
     List<PowerUsageData> parsePowerUsageData(BatteryStatsHelper statusHelper) {
         final List<BatterySipper> batterySippers = statusHelper.getUsageList();
         final Map<Integer, PowerUsageData> batteryDataMap = new HashMap<>();
@@ -245,7 +250,9 @@
                         BatteryUtils.StatusType.FOREGROUND, sipper.uidObj, STATUS_TYPE);
             }
             usageData.totalUsageTimeMs += sipper.usageTimeMs;
-            usageData.usageList.add(sipper);
+            if (shouldShowBatterySipper(sipper)) {
+                usageData.usageList.add(sipper);
+            }
         }
 
         final List<PowerUsageData> batteryDataList = new ArrayList<>(batteryDataMap.values());
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
index 3f87bb4..bbf6bef 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
@@ -260,4 +260,18 @@
         assertThat(mPowerUsageAdvanced.shouldHideSummary(mPowerUsageData)).isFalse();
     }
 
+    @Test
+    public void testShouldShowBatterySipper_typeScreen_returnFalse() {
+        mNormalBatterySipper.drainType = DrainType.SCREEN;
+
+        assertThat(mPowerUsageAdvanced.shouldShowBatterySipper(mNormalBatterySipper)).isFalse();
+    }
+
+    @Test
+    public void testShouldShowBatterySipper_typeNormal_returnTrue() {
+        mNormalBatterySipper.drainType = DrainType.APP;
+
+        assertThat(mPowerUsageAdvanced.shouldShowBatterySipper(mNormalBatterySipper)).isTrue();
+    }
+
 }