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

@@ -64,11 +64,6 @@ public class PowerUsageSummary extends PowerUsageBase implements
@VisibleForTesting
static final String KEY_BATTERY_USAGE = "battery_usage_summary";
@VisibleForTesting
static final int BATTERY_INFO_LOADER = 1;
@VisibleForTesting
static final int BATTERY_TIP_LOADER = 2;
@VisibleForTesting
PowerUsageFeatureProvider mPowerFeatureProvider;
@VisibleForTesting
@@ -241,7 +236,7 @@ public class PowerUsageSummary extends PowerUsageBase implements
@VisibleForTesting
void restartBatteryTipLoader() {
getLoaderManager().restartLoader(BATTERY_TIP_LOADER, Bundle.EMPTY, mBatteryTipsCallbacks);
restartLoader(LoaderIndex.BATTERY_TIP_LOADER, Bundle.EMPTY, mBatteryTipsCallbacks);
}
@VisibleForTesting
@@ -274,8 +269,7 @@ public class PowerUsageSummary extends PowerUsageBase implements
if (!mIsBatteryPresent) {
return;
}
getLoaderManager().restartLoader(BATTERY_INFO_LOADER, Bundle.EMPTY,
mBatteryInfoLoaderCallbacks);
restartLoader(LoaderIndex.BATTERY_INFO_LOADER, Bundle.EMPTY, mBatteryInfoLoaderCallbacks);
}
@VisibleForTesting