OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/system/chromeos/power/tray_power.h" | 5 #include "ash/system/chromeos/power/tray_power.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_delegate.h" | 9 #include "ash/shell_delegate.h" |
10 #include "ash/system/chromeos/power/power_status_view.h" | 10 #include "ash/system/chromeos/power/power_status_view.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 } | 210 } |
211 | 211 |
212 TrayPower::~TrayPower() { | 212 TrayPower::~TrayPower() { |
213 if (PowerManagerHandler::IsInitialized()) | 213 if (PowerManagerHandler::IsInitialized()) |
214 PowerManagerHandler::Get()->RemoveObserver(this); | 214 PowerManagerHandler::Get()->RemoveObserver(this); |
215 } | 215 } |
216 | 216 |
217 // static | 217 // static |
218 bool TrayPower::IsBatteryChargingUnreliable( | 218 bool TrayPower::IsBatteryChargingUnreliable( |
219 const chromeos::PowerSupplyStatus& supply_status) { | 219 const chromeos::PowerSupplyStatus& supply_status) { |
220 return | 220 // Sometimes devices can get into a state where the battery is almost fully |
221 supply_status.battery_state == | 221 // charged and the power subsystem reports "neither charging nor discharging" |
222 PowerSupplyStatus::NEITHER_CHARGING_NOR_DISCHARGING || | 222 // despite the battery not at 100%. For now, only report unreliable charging |
223 supply_status.battery_state == | 223 // on USB. |
224 PowerSupplyStatus::CONNECTED_TO_USB; | 224 // TODO(derat): Update this when the power manager code is refactored for M29. |
| 225 return supply_status.battery_state == PowerSupplyStatus::CONNECTED_TO_USB; |
225 } | 226 } |
226 | 227 |
227 // static | 228 // static |
228 int TrayPower::GetBatteryImageIndex( | 229 int TrayPower::GetBatteryImageIndex( |
229 const chromeos::PowerSupplyStatus& supply_status) { | 230 const chromeos::PowerSupplyStatus& supply_status) { |
230 int image_index = 0; | 231 int image_index = 0; |
231 if (supply_status.battery_percentage >= 100) { | 232 if (supply_status.battery_percentage >= 100) { |
232 image_index = kNumPowerImages - 1; | 233 image_index = kNumPowerImages - 1; |
233 } else if (!supply_status.battery_is_present) { | 234 } else if (!supply_status.battery_is_present) { |
234 image_index = kNumPowerImages; | 235 image_index = kNumPowerImages; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 return false; | 478 return false; |
478 case NOTIFICATION_CRITICAL: | 479 case NOTIFICATION_CRITICAL: |
479 return false; | 480 return false; |
480 } | 481 } |
481 NOTREACHED(); | 482 NOTREACHED(); |
482 return false; | 483 return false; |
483 } | 484 } |
484 | 485 |
485 } // namespace internal | 486 } // namespace internal |
486 } // namespace ash | 487 } // namespace ash |
OLD | NEW |