Merge "[Battery usage U] [UI] Add a threshold to filter out very small battery usage items in the app list"
This commit is contained in:
committed by
Android (Google) Code Review
commit
d481b398dd
@@ -35,6 +35,11 @@ public interface PowerUsageFeatureProvider {
|
|||||||
*/
|
*/
|
||||||
boolean isBatteryUsageEnabled();
|
boolean isBatteryUsageEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a threshold (mA) for the minimal comsume power in battery usage list
|
||||||
|
*/
|
||||||
|
double getBatteryUsageListConsumePowerThreshold();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an allowlist of app names combined into the system-apps item
|
* Returns an allowlist of app names combined into the system-apps item
|
||||||
*/
|
*/
|
||||||
@@ -46,7 +51,7 @@ public interface PowerUsageFeatureProvider {
|
|||||||
boolean isLocationSettingEnabled(String[] packages);
|
boolean isLocationSettingEnabled(String[] packages);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an {@link Intent} to show additional battery info.
|
* Gets an {@link Intent} to show additional battery info
|
||||||
*/
|
*/
|
||||||
Intent getAdditionalBatteryInfoIntent();
|
Intent getAdditionalBatteryInfoIntent();
|
||||||
|
|
||||||
@@ -61,37 +66,37 @@ public interface PowerUsageFeatureProvider {
|
|||||||
boolean isTypeSystem(int uid, String[] packages);
|
boolean isTypeSystem(int uid, String[] packages);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an improved prediction for battery time remaining.
|
* Returns an improved prediction for battery time remaining
|
||||||
*/
|
*/
|
||||||
Estimate getEnhancedBatteryPrediction(Context context);
|
Estimate getEnhancedBatteryPrediction(Context context);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an improved projection curve for future battery level.
|
* Returns an improved projection curve for future battery level
|
||||||
*
|
*
|
||||||
* @param zeroTime timestamps (array keys) are shifted by this amount
|
* @param zeroTime timestamps (array keys) are shifted by this amount
|
||||||
*/
|
*/
|
||||||
SparseIntArray getEnhancedBatteryPredictionCurve(Context context, long zeroTime);
|
SparseIntArray getEnhancedBatteryPredictionCurve(Context context, long zeroTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the toggle for enhanced battery predictions is enabled.
|
* Checks whether the toggle for enhanced battery predictions is enabled
|
||||||
*/
|
*/
|
||||||
boolean isEnhancedBatteryPredictionEnabled(Context context);
|
boolean isEnhancedBatteryPredictionEnabled(Context context);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether debugging should be enabled for battery estimates.
|
* Checks whether debugging should be enabled for battery estimates
|
||||||
*/
|
*/
|
||||||
boolean isEstimateDebugEnabled();
|
boolean isEstimateDebugEnabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the provided string containing the remaining time into a debug string for enhanced
|
* Converts the provided string containing the remaining time into a debug string for enhanced
|
||||||
* estimates.
|
* estimates
|
||||||
*
|
*
|
||||||
* @return A string containing the estimate and a label indicating it is an enhanced estimate
|
* @return A string containing the estimate and a label indicating it is an enhanced estimate
|
||||||
*/
|
*/
|
||||||
String getEnhancedEstimateDebugString(String timeRemaining);
|
String getEnhancedEstimateDebugString(String timeRemaining);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the provided string containing the remaining time into a debug string.
|
* Converts the provided string containing the remaining time into a debug string
|
||||||
*
|
*
|
||||||
* @return A string containing the estimate and a label indicating it is a normal estimate
|
* @return A string containing the estimate and a label indicating it is a normal estimate
|
||||||
*/
|
*/
|
||||||
@@ -103,7 +108,7 @@ public interface PowerUsageFeatureProvider {
|
|||||||
boolean isSmartBatterySupported();
|
boolean isSmartBatterySupported();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether we should show usage information by slots or not.
|
* Checks whether we should show usage information by slots or not
|
||||||
*/
|
*/
|
||||||
boolean isChartGraphSlotsEnabled(Context context);
|
boolean isChartGraphSlotsEnabled(Context context);
|
||||||
|
|
||||||
@@ -123,7 +128,7 @@ public interface PowerUsageFeatureProvider {
|
|||||||
boolean isExtraDefend();
|
boolean isExtraDefend();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code true} if delay the hourly job when device is booting.
|
* Returns {@code true} if delay the hourly job when device is booting
|
||||||
*/
|
*/
|
||||||
boolean delayHourlyJobWhenBooting();
|
boolean delayHourlyJobWhenBooting();
|
||||||
|
|
||||||
@@ -133,27 +138,27 @@ public interface PowerUsageFeatureProvider {
|
|||||||
Intent getResumeChargeIntent(boolean isDockDefender);
|
Intent getResumeChargeIntent(boolean isDockDefender);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@link Set} for the system component ids which are combined into others.
|
* Returns {@link Set} for the system component ids which are combined into others
|
||||||
*/
|
*/
|
||||||
Set<Integer> getOthersSystemComponentSet();
|
Set<Integer> getOthersSystemComponentSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@link Set} for hiding system component ids in the usage screen.
|
* Returns {@link Set} for hiding system component ids in the usage screen
|
||||||
*/
|
*/
|
||||||
Set<Integer> getHideSystemComponentSet();
|
Set<Integer> getHideSystemComponentSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@link Set} for hiding application package names in the usage screen.
|
* Returns {@link Set} for hiding application package names in the usage screen
|
||||||
*/
|
*/
|
||||||
Set<String> getHideApplicationSet();
|
Set<String> getHideApplicationSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@link Set} for hiding applications background usage time.
|
* Returns {@link Set} for hiding applications background usage time
|
||||||
*/
|
*/
|
||||||
Set<String> getHideBackgroundUsageTimeSet();
|
Set<String> getHideBackgroundUsageTimeSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@link Set} for ignoring task root class names for screen on time.
|
* Returns {@link Set} for ignoring task root class names for screen on time
|
||||||
*/
|
*/
|
||||||
Set<String> getIgnoreScreenOnTimeTaskRootSet();
|
Set<String> getIgnoreScreenOnTimeTaskRootSet();
|
||||||
}
|
}
|
||||||
|
@@ -71,6 +71,11 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getBatteryUsageListConsumePowerThreshold() {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getSystemAppsAllowlist() {
|
public List<String> getSystemAppsAllowlist() {
|
||||||
return null;
|
return null;
|
||||||
|
@@ -48,7 +48,7 @@ public class BatteryDiffData {
|
|||||||
if (!isAccumulated) {
|
if (!isAccumulated) {
|
||||||
final PowerUsageFeatureProvider featureProvider =
|
final PowerUsageFeatureProvider featureProvider =
|
||||||
FeatureFactory.getFactory(context).getPowerUsageFeatureProvider(context);
|
FeatureFactory.getFactory(context).getPowerUsageFeatureProvider(context);
|
||||||
purgeFakeAndHiddenPackages(featureProvider);
|
purgeBatteryDiffData(featureProvider);
|
||||||
combineBatteryDiffEntry(context, featureProvider);
|
combineBatteryDiffEntry(context, featureProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,9 +65,9 @@ public class BatteryDiffData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Removes fake usage data and hidden packages. */
|
/** Removes fake usage data and hidden packages. */
|
||||||
private void purgeFakeAndHiddenPackages(final PowerUsageFeatureProvider featureProvider) {
|
private void purgeBatteryDiffData(final PowerUsageFeatureProvider featureProvider) {
|
||||||
purgeFakeAndHiddenPackages(featureProvider, mAppEntries);
|
purgeBatteryDiffData(featureProvider, mAppEntries);
|
||||||
purgeFakeAndHiddenPackages(featureProvider, mSystemEntries);
|
purgeBatteryDiffData(featureProvider, mSystemEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Combines into SystemAppsBatteryDiffEntry and OthersBatteryDiffEntry. */
|
/** Combines into SystemAppsBatteryDiffEntry and OthersBatteryDiffEntry. */
|
||||||
@@ -89,9 +89,11 @@ public class BatteryDiffData {
|
|||||||
Collections.sort(mSystemEntries, BatteryDiffEntry.COMPARATOR);
|
Collections.sort(mSystemEntries, BatteryDiffEntry.COMPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void purgeFakeAndHiddenPackages(
|
private static void purgeBatteryDiffData(
|
||||||
final PowerUsageFeatureProvider featureProvider,
|
final PowerUsageFeatureProvider featureProvider,
|
||||||
final List<BatteryDiffEntry> entries) {
|
final List<BatteryDiffEntry> entries) {
|
||||||
|
final double consumePowerThreshold =
|
||||||
|
featureProvider.getBatteryUsageListConsumePowerThreshold();
|
||||||
final Set<Integer> hideSystemComponentSet = featureProvider.getHideSystemComponentSet();
|
final Set<Integer> hideSystemComponentSet = featureProvider.getHideSystemComponentSet();
|
||||||
final Set<String> hideBackgroundUsageTimeSet =
|
final Set<String> hideBackgroundUsageTimeSet =
|
||||||
featureProvider.getHideBackgroundUsageTimeSet();
|
featureProvider.getHideBackgroundUsageTimeSet();
|
||||||
@@ -99,9 +101,11 @@ public class BatteryDiffData {
|
|||||||
final Iterator<BatteryDiffEntry> iterator = entries.iterator();
|
final Iterator<BatteryDiffEntry> iterator = entries.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
final BatteryDiffEntry entry = iterator.next();
|
final BatteryDiffEntry entry = iterator.next();
|
||||||
|
final double comsumePower = entry.mConsumePower;
|
||||||
final String packageName = entry.getPackageName();
|
final String packageName = entry.getPackageName();
|
||||||
final Integer componentId = entry.mBatteryHistEntry.mDrainType;
|
final Integer componentId = entry.mBatteryHistEntry.mDrainType;
|
||||||
if (ConvertUtils.FAKE_PACKAGE_NAME.equals(packageName)
|
if (comsumePower < consumePowerThreshold
|
||||||
|
|| ConvertUtils.FAKE_PACKAGE_NAME.equals(packageName)
|
||||||
|| hideSystemComponentSet.contains(componentId)
|
|| hideSystemComponentSet.contains(componentId)
|
||||||
|| (packageName != null && hideApplicationSet.contains(packageName))) {
|
|| (packageName != null && hideApplicationSet.contains(packageName))) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
|
@@ -67,6 +67,11 @@ public class PowerUsageFeatureProviderImplTest {
|
|||||||
assertThat(mPowerFeatureProvider.isBatteryUsageEnabled()).isTrue();
|
assertThat(mPowerFeatureProvider.isBatteryUsageEnabled()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetBatteryUsageListConsumePowerThreshold_return0() {
|
||||||
|
assertThat(mPowerFeatureProvider.getBatteryUsageListConsumePowerThreshold()).isEqualTo(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsTypeSystem_uidRoot_returnTrue() {
|
public void testIsTypeSystem_uidRoot_returnTrue() {
|
||||||
assertThat(mPowerFeatureProvider.isTypeSystem(Process.ROOT_UID, null)).isTrue();
|
assertThat(mPowerFeatureProvider.isTypeSystem(Process.ROOT_UID, null)).isTrue();
|
||||||
|
Reference in New Issue
Block a user