Merge "Remove legacy MIN_POWER_THRESHOLD_MILLI_AMP_HOURS threshold value" into sc-dev
This commit is contained in:
@@ -359,9 +359,7 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
|||||||
componentId < BatteryConsumer.FIRST_CUSTOM_POWER_COMPONENT_ID
|
componentId < BatteryConsumer.FIRST_CUSTOM_POWER_COMPONENT_ID
|
||||||
+ deviceConsumer.getCustomPowerComponentCount();
|
+ deviceConsumer.getCustomPowerComponentCount();
|
||||||
componentId++) {
|
componentId++) {
|
||||||
if (!showAllApps
|
if (!showAllApps) {
|
||||||
&& mBatteryUtils.shouldHideCustomDevicePowerComponent(deviceConsumer,
|
|
||||||
componentId)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -81,8 +81,6 @@ public class BatteryUtils {
|
|||||||
|
|
||||||
private static final String TAG = "BatteryUtils";
|
private static final String TAG = "BatteryUtils";
|
||||||
|
|
||||||
private static final double MIN_POWER_THRESHOLD_MILLI_AMP_HOURS = 0.002;
|
|
||||||
|
|
||||||
private static BatteryUtils sInstance;
|
private static BatteryUtils sInstance;
|
||||||
private PackageManager mPackageManager;
|
private PackageManager mPackageManager;
|
||||||
|
|
||||||
@@ -180,8 +178,7 @@ public class BatteryUtils {
|
|||||||
* battery consumption list.
|
* battery consumption list.
|
||||||
*/
|
*/
|
||||||
public boolean shouldHideUidBatteryConsumer(UidBatteryConsumer consumer, String[] packages) {
|
public boolean shouldHideUidBatteryConsumer(UidBatteryConsumer consumer, String[] packages) {
|
||||||
return consumer.getConsumedPower() < MIN_POWER_THRESHOLD_MILLI_AMP_HOURS
|
return mPowerUsageFeatureProvider.isTypeSystem(consumer.getUid(), packages)
|
||||||
|| mPowerUsageFeatureProvider.isTypeSystem(consumer.getUid(), packages)
|
|
||||||
|| shouldHideUidBatteryConsumerUnconditionally(consumer, packages);
|
|| shouldHideUidBatteryConsumerUnconditionally(consumer, packages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,21 +205,10 @@ public class BatteryUtils {
|
|||||||
case BatteryConsumer.POWER_COMPONENT_WIFI:
|
case BatteryConsumer.POWER_COMPONENT_WIFI:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return consumer.getConsumedPower(powerComponentId)
|
return false;
|
||||||
< MIN_POWER_THRESHOLD_MILLI_AMP_HOURS;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
* Returns true if one the specified packages belongs to a hidden system module.
|
||||||
*/
|
*/
|
||||||
|
@@ -246,17 +246,7 @@ public class BatteryUtilsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShouldHideSystemConsumer_LowPower_ReturnTrue() {
|
public void testShouldHideSystemConsumer_OtherType_ReturnFalse() {
|
||||||
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);
|
|
||||||
assertThat(mBatteryUtils.shouldHideDevicePowerComponent(mAggregateBatteryConsumer,
|
assertThat(mBatteryUtils.shouldHideDevicePowerComponent(mAggregateBatteryConsumer,
|
||||||
BatteryConsumer.POWER_COMPONENT_FLASHLIGHT)).isFalse();
|
BatteryConsumer.POWER_COMPONENT_FLASHLIGHT)).isFalse();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user