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