commit | 53f48c4a974a4e1a641b0650b5ff7e9453055e24 | [log] [tgz] |
---|---|---|
author | ykhung <ykhung@google.com> | Mon Jun 05 01:01:55 2023 +0800 |
committer | YK Hung <ykhung@google.com> | Mon Jun 05 01:39:41 2023 +0000 |
tree | 19ef9825c2702ef6bbef076ef3edea4a8e4371ce | |
parent | 4834abe2415eda112749c1c1ba15199f5190550d [diff] |
Make the estimator cache logic is the same as SysUI flow Ensure the remaining time estimator cache logic is the same as SysUI https://source.corp.google.com/android/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryControllerImpl.java;l=375-386 Test: presubmit Fix: 285747156 Change-Id: If7218dc70792aafaec45c71018897bed80df7f3d
diff --git a/src/com/android/settings/fuelgauge/BatteryUtils.java b/src/com/android/settings/fuelgauge/BatteryUtils.java index 12760b1..f5d3950 100644 --- a/src/com/android/settings/fuelgauge/BatteryUtils.java +++ b/src/com/android/settings/fuelgauge/BatteryUtils.java
@@ -451,12 +451,10 @@ @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) {