Merge "Hide Camera background running time in the battery usage screen" into sc-dev am: 3f1d329878

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/15723822

Change-Id: Ie57e3be9bda2316a8ee6a59fba76043ed6e61c54
This commit is contained in:
YUKAI HUNG
2021-09-03 02:50:11 +00:00
committed by Automerger Merge Worker
4 changed files with 65 additions and 4 deletions

View File

@@ -25,6 +25,8 @@ import android.util.Log;
import androidx.annotation.VisibleForTesting;
import com.android.settings.overlay.FeatureFactory;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.time.Duration;
@@ -259,7 +261,7 @@ public final class ConvertUtils {
}
insert24HoursData(BatteryChartView.SELECTED_INDEX_ALL, resultMap);
if (purgeLowPercentageAndFakeData) {
purgeLowPercentageAndFakeData(resultMap);
purgeLowPercentageAndFakeData(context, resultMap);
}
return resultMap;
}
@@ -298,7 +300,12 @@ public final class ConvertUtils {
// Removes low percentage data and fake usage data, which will be zero value.
private static void purgeLowPercentageAndFakeData(
final Context context,
final Map<Integer, List<BatteryDiffEntry>> indexedUsageMap) {
final List<CharSequence> backgroundUsageTimeHideList =
FeatureFactory.getFactory(context)
.getPowerUsageFeatureProvider(context)
.getHideBackgroundUsageTimeList(context);
for (List<BatteryDiffEntry> entries : indexedUsageMap.values()) {
final Iterator<BatteryDiffEntry> iterator = entries.iterator();
while (iterator.hasNext()) {
@@ -307,6 +314,12 @@ public final class ConvertUtils {
|| FAKE_PACKAGE_NAME.equals(entry.getPackageName())) {
iterator.remove();
}
final String packageName = entry.getPackageName();
if (packageName != null
&& !backgroundUsageTimeHideList.isEmpty()
&& backgroundUsageTimeHideList.contains(packageName)) {
entry.mBackgroundUsageTimeInMs = 0;
}
}
}
}