Fix LoaderCallback.onLoadFinished uncalled issue

When two loaders started almost at the same time,
it is possible onLoadFinished is never called.

Bug: 256523472
Test: Unit tests passed and manual test on device
Change-Id: I41a041d5878f9930db44775408380d0d4588faba
Signed-off-by: Zhenwei Chen <zhenwec@google.com>
This commit is contained in:
Zhenwei Chen
2022-11-22 04:50:15 +08:00
parent db61f1fc4c
commit 41ce87729e
5 changed files with 245 additions and 33 deletions

View File

@@ -52,7 +52,6 @@ public class PowerUsageAdvanced extends PowerUsageBase {
private static final String KEY_REFRESH_TYPE = "refresh_type";
private static final String KEY_BATTERY_GRAPH = "battery_graph";
private static final String KEY_APP_LIST = "app_list";
private static final int LOADER_BATTERY_USAGE_STATS = 2;
@VisibleForTesting
BatteryHistoryPreference mHistPref;
@@ -165,7 +164,7 @@ public class PowerUsageAdvanced extends PowerUsageBase {
bundle.putInt(KEY_REFRESH_TYPE, refreshType);
if (!mIsChartDataLoaded) {
mIsChartDataLoaded = true;
getLoaderManager().restartLoader(LOADER_BATTERY_USAGE_STATS, bundle,
restartLoader(LoaderIndex.BATTERY_HISTORY_LOADER, bundle,
mBatteryHistoryLoaderCallbacks);
}
}