Merge "Not show time information in battery optimization page when opened from Settings -> Apps"

This commit is contained in:
Kuan Wang
2023-01-16 07:02:38 +00:00
committed by Android (Google) Code Review
4 changed files with 13 additions and 7 deletions

View File

@@ -121,11 +121,11 @@ public class AppBatteryPreferenceController extends BasePreferenceController
Log.i(TAG, "handlePreferenceTreeClick():\n" + mBatteryDiffEntry);
AdvancedPowerUsageDetail.startBatteryDetailPage(
mParent.getActivity(),
mParent,
mParent.getMetricsCategory(),
mBatteryDiffEntry,
Utils.formatPercentage(
mBatteryDiffEntry.getPercentOfTotal(), /* round */ true),
/*slotInformation=*/ null);
/*slotInformation=*/ null, /*showTimeInformation=*/ false);
return true;
}

View File

@@ -139,13 +139,15 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
Activity caller, InstrumentedPreferenceFragment fragment,
BatteryDiffEntry diffEntry, String usagePercent, String slotInformation) {
startBatteryDetailPage(
caller, fragment.getMetricsCategory(), diffEntry, usagePercent, slotInformation);
caller, fragment.getMetricsCategory(), diffEntry, usagePercent, slotInformation,
/*showTimeInformation=*/ true);
}
/** Launches battery details page for an individual battery consumer fragment. */
public static void startBatteryDetailPage(
Context context, int sourceMetricsCategory,
BatteryDiffEntry diffEntry, String usagePercent, String slotInformation) {
BatteryDiffEntry diffEntry, String usagePercent, String slotInformation,
boolean showTimeInformation) {
final BatteryHistEntry histEntry = diffEntry.mBatteryHistEntry;
final LaunchBatteryDetailPageArgs launchArgs = new LaunchBatteryDetailPageArgs();
// configure the launch argument.
@@ -156,9 +158,11 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
launchArgs.mUid = (int) histEntry.mUid;
launchArgs.mIconId = diffEntry.getAppIconId();
launchArgs.mConsumedPower = (int) diffEntry.mConsumePower;
launchArgs.mForegroundTimeMs = diffEntry.mForegroundUsageTimeInMs;
launchArgs.mBackgroundTimeMs = diffEntry.mBackgroundUsageTimeInMs;
launchArgs.mScreenOnTimeMs = diffEntry.mScreenOnTimeInMs;
if (showTimeInformation) {
launchArgs.mForegroundTimeMs = diffEntry.mForegroundUsageTimeInMs;
launchArgs.mBackgroundTimeMs = diffEntry.mBackgroundUsageTimeInMs;
launchArgs.mScreenOnTimeMs = diffEntry.mScreenOnTimeInMs;
}
launchArgs.mIsUserEntry = histEntry.isUserEntry();
startBatteryDetailPage(context, sourceMetricsCategory, launchArgs);
}

View File

@@ -126,6 +126,7 @@ private class AppBatteryPresenter(private val context: Context, private val app:
this,
Utils.formatPercentage(percentOfTotal, true),
null,
false,
)
}

View File

@@ -162,6 +162,7 @@ class AppBatteryPreferenceTest {
batteryDiffEntry,
"10%",
null,
false,
)
}
}