Merge "Hide running time for "Android System" in the optimization page" into tm-dev am: 10190793fe am: 7e3c63dcd5

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

Change-Id: I4010429f19259c2c23f78c73591e51907d5a5623
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-05-10 21:28:51 +00:00
committed by Automerger Merge Worker
4 changed files with 49 additions and 10 deletions

View File

@@ -525,20 +525,24 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
final long foregroundTimeMs = bundle.getLong(EXTRA_FOREGROUND_TIME);
final long backgroundTimeMs = bundle.getLong(EXTRA_BACKGROUND_TIME);
final int consumedPower = bundle.getInt(EXTRA_POWER_USAGE_AMOUNT);
final int uid = bundle.getInt(EXTRA_UID, 0);
final String slotTime = bundle.getString(EXTRA_SLOT_TIME, null);
final long totalTimeMs = foregroundTimeMs + backgroundTimeMs;
final CharSequence usageTimeSummary;
final PowerUsageFeatureProvider powerFeatureProvider =
FeatureFactory.getFactory(getContext()).getPowerUsageFeatureProvider(getContext());
final boolean isChartGraphEnabled = FeatureFactory.getFactory(getContext())
.getPowerUsageFeatureProvider(getContext()).isChartGraphEnabled(getContext());
if (!isChartGraphEnabled && BatteryEntry.isSystemUid(uid)) {
return null;
}
if (totalTimeMs == 0) {
final int batteryWithoutUsageTime = consumedPower > 0
? R.string.battery_usage_without_time : R.string.battery_not_usage_24hr;
usageTimeSummary = getText(powerFeatureProvider.isChartGraphEnabled(getContext())
usageTimeSummary = getText(isChartGraphEnabled
? batteryWithoutUsageTime : R.string.battery_not_usage);
} else if (slotTime == null) {
// Shows summary text with past 24 hr or full charge if slot time is null.
usageTimeSummary = powerFeatureProvider.isChartGraphEnabled(getContext())
usageTimeSummary = isChartGraphEnabled
? getAppPast24HrActiveSummary(foregroundTimeMs, backgroundTimeMs, totalTimeMs)
: getAppFullChargeActiveSummary(
foregroundTimeMs, backgroundTimeMs, totalTimeMs);

View File

@@ -434,7 +434,7 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
@VisibleForTesting
void setUsageSummary(Preference preference, BatteryEntry entry) {
if (entry.getUid() == Process.SYSTEM_UID) {
if (BatteryEntry.isSystemUid(entry.getUid())) {
return;
}
String packageName = entry.getDefaultPackageName();

View File

@@ -612,7 +612,7 @@ public class BatteryEntry {
return new NameAndIcon(name, null /* icon */, iconId);
}
private static boolean isSystemUid(int uid) {
static boolean isSystemUid(int uid) {
return uid == Process.SYSTEM_UID;
}
}