Chromium Code Reviews| Index: chromeos/dbus/power_manager_client.cc |
| diff --git a/chromeos/dbus/power_manager_client.cc b/chromeos/dbus/power_manager_client.cc |
| index 5998e5c8a3f457f54c7373d1111bf3f7db003457..1cab12b31d90471e88b74b8c376fb11a0d42e552 100644 |
| --- a/chromeos/dbus/power_manager_client.cc |
| +++ b/chromeos/dbus/power_manager_client.cc |
| @@ -804,24 +804,28 @@ class PowerManagerClientStubImpl : public PowerManagerClient { |
| void UpdateStatus() { |
| if (pause_count_ > 0) { |
| pause_count_--; |
| + if (pause_count_ == 2) |
|
Daniel Erat
2013/06/28 21:43:24
The old code was switching immediately to discharg
|
| + discharging_ = !discharging_; |
| } else { |
| - int discharge_amt = battery_percentage_ <= 10 ? 1 : 10; |
| - battery_percentage_ += (discharging_ ? -discharge_amt : discharge_amt); |
| + if (discharging_) |
| + battery_percentage_ -= (battery_percentage_ <= 10 ? 1 : 10); |
| + else |
| + battery_percentage_ += (battery_percentage_ >= 10 ? 10 : 1); |
|
Daniel Erat
2013/06/28 21:43:24
The discontinuity in the old code was bugging me:
|
| battery_percentage_ = std::min(std::max(battery_percentage_, 0), 100); |
| // We pause at 0 and 100% so that it's easier to check those conditions. |
| if (battery_percentage_ == 0 || battery_percentage_ == 100) { |
| - discharging_ = !discharging_; |
| pause_count_ = 4; |
| if (battery_percentage_ == 100) |
| cycle_count_ = (cycle_count_ + 1) % 3; |
| } |
| } |
| - const int kSecondsToEmptyFullBattery(3 * 60 * 60); // 3 hours. |
| + const int kSecondsToEmptyFullBattery = 3 * 60 * 60; // 3 hours. |
| status_.is_calculating_battery_time = (pause_count_ > 1); |
| status_.line_power_on = !discharging_; |
| status_.battery_is_present = true; |
| status_.battery_percentage = battery_percentage_; |
| + status_.battery_is_full = battery_percentage_ == 100 && !discharging_; |
| if (cycle_count_ != 2) { |
| status_.battery_state = discharging_ ? |
| PowerSupplyStatus::DISCHARGING : PowerSupplyStatus::CHARGING; |