packages/apps/Settings
Revision | 05777a7918f8ec487d5e6a876e198af860d7c457 (tree) |
---|---|
Zeit | 2017-06-21 07:35:59 |
Autor | TreeHugger Robot <treehugger-gerrit@goog...> |
Commiter | Android (Google) Code Review |
Merge "Hide wifi and bt in battery settings" into oc-dev
@@ -136,8 +136,10 @@ public class BatteryUtils { | ||
136 | 136 | sippers.remove(i); |
137 | 137 | if (sipper.drainType != BatterySipper.DrainType.OVERCOUNTED |
138 | 138 | && sipper.drainType != BatterySipper.DrainType.SCREEN |
139 | - && sipper.drainType != BatterySipper.DrainType.UNACCOUNTED) { | |
140 | - // Don't add it if it is overcounted, unaccounted or screen | |
139 | + && sipper.drainType != BatterySipper.DrainType.UNACCOUNTED | |
140 | + && sipper.drainType != BatterySipper.DrainType.BLUETOOTH | |
141 | + && sipper.drainType != BatterySipper.DrainType.WIFI) { | |
142 | + // Don't add it if it is overcounted, unaccounted, wifi, bluetooth, or screen | |
141 | 143 | proportionalSmearPowerMah += sipper.totalPowerMah; |
142 | 144 | } |
143 | 145 | } |
@@ -191,6 +193,8 @@ public class BatteryUtils { | ||
191 | 193 | || drainType == BatterySipper.DrainType.SCREEN |
192 | 194 | || drainType == BatterySipper.DrainType.UNACCOUNTED |
193 | 195 | || drainType == BatterySipper.DrainType.OVERCOUNTED |
196 | + || drainType == BatterySipper.DrainType.BLUETOOTH | |
197 | + || drainType == BatterySipper.DrainType.WIFI | |
194 | 198 | || (sipper.totalPowerMah * SECONDS_IN_HOUR) < MIN_POWER_THRESHOLD_MILLI_AMP |
195 | 199 | || mPowerUsageFeatureProvider.isTypeService(sipper) |
196 | 200 | || mPowerUsageFeatureProvider.isTypeSystem(sipper); |
@@ -80,6 +80,8 @@ public class BatteryUtilsTest { | ||
80 | 80 | private static final double BATTERY_OVERACCOUNTED_USAGE = 500; |
81 | 81 | private static final double BATTERY_UNACCOUNTED_USAGE = 700; |
82 | 82 | private static final double BATTERY_APP_USAGE = 100; |
83 | + private static final double BATTERY_WIFI_USAGE = 200; | |
84 | + private static final double BATTERY_BLUETOOTH_USAGE = 300; | |
83 | 85 | private static final double TOTAL_BATTERY_USAGE = 1000; |
84 | 86 | private static final double HIDDEN_USAGE = 200; |
85 | 87 | private static final int DISCHARGE_AMOUNT = 80; |
@@ -91,6 +93,10 @@ public class BatteryUtilsTest { | ||
91 | 93 | @Mock |
92 | 94 | private BatterySipper mNormalBatterySipper; |
93 | 95 | @Mock |
96 | + private BatterySipper mWifiBatterySipper; | |
97 | + @Mock | |
98 | + private BatterySipper mBluetoothBatterySipper; | |
99 | + @Mock | |
94 | 100 | private BatterySipper mScreenBatterySipper; |
95 | 101 | @Mock |
96 | 102 | private BatterySipper mOvercountedBatterySipper; |
@@ -130,6 +136,12 @@ public class BatteryUtilsTest { | ||
130 | 136 | mNormalBatterySipper.drainType = BatterySipper.DrainType.APP; |
131 | 137 | mNormalBatterySipper.totalPowerMah = TOTAL_BATTERY_USAGE; |
132 | 138 | |
139 | + mWifiBatterySipper.drainType = BatterySipper.DrainType.WIFI; | |
140 | + mWifiBatterySipper.totalPowerMah = BATTERY_WIFI_USAGE; | |
141 | + | |
142 | + mBluetoothBatterySipper.drainType = BatterySipper.DrainType.BLUETOOTH; | |
143 | + mBluetoothBatterySipper.totalPowerMah = BATTERY_BLUETOOTH_USAGE; | |
144 | + | |
133 | 145 | mScreenBatterySipper.drainType = BatterySipper.DrainType.SCREEN; |
134 | 146 | mScreenBatterySipper.totalPowerMah = BATTERY_SCREEN_USAGE; |
135 | 147 |
@@ -189,6 +201,8 @@ public class BatteryUtilsTest { | ||
189 | 201 | sippers.add(mSystemBatterySipper); |
190 | 202 | sippers.add(mOvercountedBatterySipper); |
191 | 203 | sippers.add(mUnaccountedBatterySipper); |
204 | + sippers.add(mWifiBatterySipper); | |
205 | + sippers.add(mBluetoothBatterySipper); | |
192 | 206 | when(mProvider.isTypeSystem(mSystemBatterySipper)) |
193 | 207 | .thenReturn(true); |
194 | 208 | doNothing().when(mBatteryUtils).smearScreenBatterySipper(any(), any()); |
@@ -230,6 +244,18 @@ public class BatteryUtilsTest { | ||
230 | 244 | } |
231 | 245 | |
232 | 246 | @Test |
247 | + public void testShouldHideSipper_TypeWifi_ReturnTrue() { | |
248 | + mNormalBatterySipper.drainType = BatterySipper.DrainType.WIFI; | |
249 | + assertThat(mBatteryUtils.shouldHideSipper(mNormalBatterySipper)).isTrue(); | |
250 | + } | |
251 | + | |
252 | + @Test | |
253 | + public void testShouldHideSipper_TypeBluetooth_ReturnTrue() { | |
254 | + mNormalBatterySipper.drainType = BatterySipper.DrainType.BLUETOOTH; | |
255 | + assertThat(mBatteryUtils.shouldHideSipper(mNormalBatterySipper)).isTrue(); | |
256 | + } | |
257 | + | |
258 | + @Test | |
233 | 259 | public void testShouldHideSipper_TypeSystem_ReturnTrue() { |
234 | 260 | mNormalBatterySipper.drainType = BatterySipper.DrainType.APP; |
235 | 261 | when(mNormalBatterySipper.getUid()).thenReturn(Process.ROOT_UID); |