Make the estimator cache logic is the same as SysUI flow am: 53f48c4a97

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

Change-Id: I42405b0eef20370cc6a838d1040149f9a635d391
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
ykhung
2023-06-05 07:02:11 +00:00
committed by Automerger Merge Worker

View File

@@ -451,12 +451,10 @@ public class BatteryUtils {
@VisibleForTesting
Estimate getEnhancedEstimate() {
Estimate estimate = null;
// Get enhanced prediction if available
if (Duration.between(Estimate.getLastCacheUpdateTime(mContext), Instant.now())
.compareTo(Duration.ofSeconds(10)) < 0) {
estimate = Estimate.getCachedEstimateIfAvailable(mContext);
} else if (mPowerUsageFeatureProvider != null &&
// Align the same logic in the BatteryControllerImpl.updateEstimate()
Estimate estimate = Estimate.getCachedEstimateIfAvailable(mContext);
if (estimate == null &&
mPowerUsageFeatureProvider != null &&
mPowerUsageFeatureProvider.isEnhancedBatteryPredictionEnabled(mContext)) {
estimate = mPowerUsageFeatureProvider.getEnhancedBatteryPrediction(mContext);
if (estimate != null) {