Support showing battery level chart first immediately after the battery level data is ready.

When the battery level chart is shown but app usage data is not ready,
the battery chart is still clickable, but the app list won't show. Once
the app usage data is ready, the app usage list of the latest selected
period will show. Please see the following screen record of forcing
loading app usage data very slow. In the real case, the app usage
loading is not that slow.

https://drive.google.com/file/d/196rlzwSa52xrQFRfF2gdHJJPZn-uecZF/view?usp=sharing&resourcekey=0-mGggQGG7IMd5-bSAG7l_LA

Bug: 243887839
Fix: 243887839
Test: manual
Change-Id: I170eb4afb46b1d0040b7971460b1b37dde5d1362
This commit is contained in:
Zaiyue Xue
2022-08-26 13:46:13 +08:00
parent 7159aec1d6
commit adc36d085b

View File

@@ -369,10 +369,6 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
addFooterPreferenceIfNeeded(false); addFooterPreferenceIfNeeded(false);
return false; return false;
} }
if (mBatteryUsageMap == null) {
// Battery usage data is not ready, wait for data ready to refresh UI.
return false;
}
if (isBatteryLevelDataInOneDay()) { if (isBatteryLevelDataInOneDay()) {
// Only 1 day data, hide the daily chart view. // Only 1 day data, hide the daily chart view.
@@ -394,6 +390,10 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
mHourlyChartView.setViewModel(hourlyViewModel); mHourlyChartView.setViewModel(hourlyViewModel);
} }
if (mBatteryUsageMap == null) {
// Battery usage data is not ready, wait for data ready to refresh UI.
return false;
}
mHandler.post(() -> { mHandler.post(() -> {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
removeAndCacheAllPrefs(); removeAndCacheAllPrefs();