Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryControllerImpl.java +14 −11 Original line number Diff line number Diff line Loading @@ -212,6 +212,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC @Nullable private String generateTimeRemainingString() { synchronized (mFetchCallbacks) { if (mEstimate == null) { return null; } Loading @@ -220,6 +221,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC return PowerUtil.getBatteryRemainingShortStringFormatted( mContext, mEstimate.getEstimateMillis()); } } private void updateEstimateInBackground() { if (mFetchingEstimate) { Loading @@ -230,19 +232,20 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC mFetchingEstimate = true; Dependency.get(Dependency.BG_HANDLER).post(() -> { // Only fetch the estimate if they are enabled synchronized (mFetchCallbacks) { mEstimate = null; if (mEstimates.isHybridNotificationEnabled()) { updateEstimate(); } } mFetchingEstimate = false; Dependency.get(Dependency.MAIN_HANDLER).post(this::notifyEstimateFetchCallbacks); }); } private void notifyEstimateFetchCallbacks() { String estimate = generateTimeRemainingString(); synchronized (mFetchCallbacks) { String estimate = generateTimeRemainingString(); for (EstimateFetchCompletion completion : mFetchCallbacks) { completion.onBatteryRemainingEstimateRetrieved(estimate); } Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryControllerImpl.java +14 −11 Original line number Diff line number Diff line Loading @@ -212,6 +212,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC @Nullable private String generateTimeRemainingString() { synchronized (mFetchCallbacks) { if (mEstimate == null) { return null; } Loading @@ -220,6 +221,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC return PowerUtil.getBatteryRemainingShortStringFormatted( mContext, mEstimate.getEstimateMillis()); } } private void updateEstimateInBackground() { if (mFetchingEstimate) { Loading @@ -230,19 +232,20 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC mFetchingEstimate = true; Dependency.get(Dependency.BG_HANDLER).post(() -> { // Only fetch the estimate if they are enabled synchronized (mFetchCallbacks) { mEstimate = null; if (mEstimates.isHybridNotificationEnabled()) { updateEstimate(); } } mFetchingEstimate = false; Dependency.get(Dependency.MAIN_HANDLER).post(this::notifyEstimateFetchCallbacks); }); } private void notifyEstimateFetchCallbacks() { String estimate = generateTimeRemainingString(); synchronized (mFetchCallbacks) { String estimate = generateTimeRemainingString(); for (EstimateFetchCompletion completion : mFetchCallbacks) { completion.onBatteryRemainingEstimateRetrieved(estimate); } Loading