Merge "[Battery usage U] Remove 'Phone Idle' to avoid confusion"

This commit is contained in:
TreeHugger Robot
2022-12-26 02:42:50 +00:00
committed by Android (Google) Code Review
7 changed files with 30 additions and 49 deletions

View File

@@ -146,15 +146,20 @@ public interface PowerUsageFeatureProvider {
Intent getResumeChargeIntent(boolean isDockDefender);
/**
* Returns {@link Set} for hiding applications background usage time.
* Returns {@link Set} for hiding system component ids in the usage screen.
*/
Set<CharSequence> getHideBackgroundUsageTimeSet(Context context);
Set<Integer> getHideSystemComponentSet(Context context);
/**
* Returns {@link Set} for hiding application package names in the usage screen.
*/
Set<CharSequence> getHideApplicationSet(Context context);
/**
* Returns {@link Set} for hiding applications background usage time.
*/
Set<CharSequence> getHideBackgroundUsageTimeSet(Context context);
/**
* Returns {@link Set} for ignoring task root class names for screen on time.
*/

View File

@@ -162,7 +162,7 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
}
@Override
public Set<CharSequence> getHideBackgroundUsageTimeSet(Context context) {
public Set<Integer> getHideSystemComponentSet(Context context) {
return new ArraySet<>();
}
@@ -171,6 +171,11 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
return new ArraySet<>();
}
@Override
public Set<CharSequence> getHideBackgroundUsageTimeSet(Context context) {
return new ArraySet<>();
}
@Override
public Set<CharSequence> getIgnoreScreenOnTimeTaskRootSet(Context context) {
return new ArraySet<>();

View File

@@ -590,11 +590,6 @@ public class BatteryEntry {
name = context.getResources().getString(R.string.power_wifi);
iconId = R.drawable.ic_settings_wireless_no_theme;
break;
case BatteryConsumer.POWER_COMPONENT_IDLE:
case BatteryConsumer.POWER_COMPONENT_MEMORY:
name = context.getResources().getString(R.string.power_idle);
iconId = R.drawable.ic_settings_phone_idle;
break;
default:
Log.w(TAG, "unknown attribute:" + DebugUtils.constantToString(
BatteryConsumer.class, "POWER_COMPONENT_", powerComponentId));

View File

@@ -1224,6 +1224,10 @@ public final class DataProcessor {
private static void processBatteryDiffData(
final Context context,
final Map<Integer, Map<Integer, BatteryDiffData>> resultMap) {
final Set<Integer> hideSystemComponentSet =
FeatureFactory.getFactory(context)
.getPowerUsageFeatureProvider(context)
.getHideSystemComponentSet(context);
final Set<CharSequence> hideBackgroundUsageTimeSet =
FeatureFactory.getFactory(context)
.getPowerUsageFeatureProvider(context)
@@ -1239,11 +1243,15 @@ public final class DataProcessor {
return;
}
purgeFakeAndHiddenPackages(
batteryDiffData.getAppDiffEntryList(), hideBackgroundUsageTimeSet,
hideApplicationSet);
batteryDiffData.getAppDiffEntryList(),
hideSystemComponentSet,
hideApplicationSet,
hideBackgroundUsageTimeSet);
purgeFakeAndHiddenPackages(
batteryDiffData.getSystemDiffEntryList(), hideBackgroundUsageTimeSet,
hideApplicationSet);
batteryDiffData.getSystemDiffEntryList(),
hideSystemComponentSet,
hideApplicationSet,
hideBackgroundUsageTimeSet);
batteryDiffData.setTotalConsumePower();
batteryDiffData.sortEntries();
});
@@ -1252,16 +1260,16 @@ public final class DataProcessor {
private static void purgeFakeAndHiddenPackages(
final List<BatteryDiffEntry> entries,
final Set<CharSequence> hideBackgroundUsageTimeSet,
final Set<CharSequence> hideApplicationSet) {
final Set<Integer> hideSystemComponentSet,
final Set<CharSequence> hideApplicationSet,
final Set<CharSequence> hideBackgroundUsageTimeSet) {
final Iterator<BatteryDiffEntry> iterator = entries.iterator();
while (iterator.hasNext()) {
final BatteryDiffEntry entry = iterator.next();
final String packageName = entry.getPackageName();
if (packageName == null) {
continue;
}
final Integer componentId = entry.mBatteryHistEntry.mDrainType;
if (ConvertUtils.FAKE_PACKAGE_NAME.equals(packageName)
|| hideSystemComponentSet.contains(componentId)
|| hideApplicationSet.contains(packageName)) {
iterator.remove();
}