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

@@ -551,10 +551,6 @@
<string name="battery_tip_dialog_summary_message" product="device">Your apps are using a normal amount of battery. If apps use too much battery, your device will suggest actions you can take.\n\nYou can always turn on Battery Saver if you\u2019re running low on battery.</string>
<!-- Summary for the smart battery toggle [CHAR LIMIT=NONE] -->
<string name="smart_battery_summary" product="default">Limit battery for apps that you don\u2019t use often</string>
<!-- Label for power consumed when Idle -->
<string name="power_idle" product="tablet">Tablet idle</string>
<!-- Label for power consumed when Idle -->
<string name="power_idle" product="default">Phone idle</string>
<!-- Battery Saver: Description for sticky battery saver preference [CHAR_LIMIT=NONE] -->
<string name="battery_saver_sticky_description_new" product="default">Battery Saver turns off when your phone charges above <xliff:g id="battery_percentage" example="80%">%1$s</xliff:g></string>
<!-- Battery Saver: Description for sticky battery saver preference [CHAR_LIMIT=NONE] -->

View File

@@ -1,25 +0,0 @@
<!--
Copyright (C) 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48"
android:tint="@color/battery_usage_system_icon_color">
<path
android:fillColor="@android:color/white"
android:pathData="M14,48h4v-4h-4v4zM22,48h4v-4h-4v4zM26,4h-4v20h4L26,4zM33.13,8.87l-2.89,2.89C33.69,13.87 36,17.66 36,22c0,6.63 -5.37,12 -12,12s-12,-5.37 -12,-12c0,-4.34 2.31,-8.13 5.76,-10.24l-2.89,-2.89C10.72,11.76 8,16.56 8,22c0,8.84 7.16,16 16,16s16,-7.16 16,-16c0,-5.44 -2.72,-10.24 -6.87,-13.13zM30,48h4v-4h-4v4z"/>
</vector>

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();
}

View File

@@ -337,9 +337,6 @@ public class BatteryEntryTest {
assertNameAndIcon(BatteryConsumer.POWER_COMPONENT_WIFI,
R.string.power_wifi,
R.drawable.ic_settings_wireless_no_theme);
assertNameAndIcon(BatteryConsumer.POWER_COMPONENT_IDLE,
R.string.power_idle,
R.drawable.ic_settings_phone_idle);
}
private void assertNameAndIcon(String name, int stringId) {