summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-04 23:58:43 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-04 23:58:43 +0000
commitf2fcbd24d0aeb1d1c8b4e5033dd20a266c362356 (patch)
tree017bd61f9783cc6b597469a209cb2293fec71d8e /ash
parentf2c46252bbeeed180343eccf969dc423c7ef7a17 (diff)
downloadchromium_src-f2fcbd24d0aeb1d1c8b4e5033dd20a266c362356.zip
chromium_src-f2fcbd24d0aeb1d1c8b4e5033dd20a266c362356.tar.gz
chromium_src-f2fcbd24d0aeb1d1c8b4e5033dd20a266c362356.tar.bz2
cros: Update charging not reliable battery status
Don't display the "charging not reliable" battery status in the non-charging-non-discharging state, as that can happen normally in some circumstances. Also, update the string to be more human-friendly. See bug for details. BUG=246336 TEST=manual, see bug R=derat@chromium.org Review URL: https://codereview.chromium.org/15993020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204085 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/system/chromeos/power/power_status_view.cc19
-rw-r--r--ash/system/chromeos/power/tray_power.cc11
2 files changed, 17 insertions, 13 deletions
diff --git a/ash/system/chromeos/power/power_status_view.cc b/ash/system/chromeos/power/power_status_view.cc
index 9aa461c..d427875 100644
--- a/ash/system/chromeos/power/power_status_view.cc
+++ b/ash/system/chromeos/power/power_status_view.cc
@@ -32,6 +32,13 @@ const int kLabelMinWidth = 120;
const int kPaddingBetweenBatteryStatusAndIcon = 3;
// Minimum battery percentage rendered in UI.
const int kMinBatteryPercent = 1;
+
+base::string16 GetChargingUnreliableString() {
+ // String is intentionally hard-coded in English for backport to M28 only.
+ // See crbug.com/246336 for details.
+ return UTF8ToUTF16("Low-power charger");
+}
+
} // namespace
PowerStatusView::PowerStatusView(ViewType view_type,
@@ -123,9 +130,8 @@ void PowerStatusView::UpdateTextForDefaultView() {
battery_time_status =
rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BATTERY_FULL);
} else if (supply_status_.battery_percentage < 0.0f) {
- battery_time_status =
- is_charging_unreliable ?
- rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE) :
+ battery_time_status = is_charging_unreliable ?
+ GetChargingUnreliableString() :
rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING);
} else {
battery_percentage = l10n_util::GetStringFUTF16(
@@ -133,8 +139,7 @@ void PowerStatusView::UpdateTextForDefaultView() {
base::IntToString16(TrayPower::GetRoundedBatteryPercentage(
supply_status_.battery_percentage)));
if (is_charging_unreliable) {
- battery_time_status = rb.GetLocalizedString(
- IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE);
+ battery_time_status = GetChargingUnreliableString();
} else {
if (supply_status_.is_calculating_battery_time) {
battery_time_status =
@@ -207,9 +212,7 @@ void PowerStatusView::UpdateTextForNotificationView() {
}
if (is_charging_unreliable) {
- time_label_->SetText(
- ui::ResourceBundle::GetSharedInstance().GetLocalizedString(
- IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE));
+ time_label_->SetText(GetChargingUnreliableString());
} else if (supply_status_.is_calculating_battery_time) {
time_label_->SetText(
ui::ResourceBundle::GetSharedInstance().GetLocalizedString(
diff --git a/ash/system/chromeos/power/tray_power.cc b/ash/system/chromeos/power/tray_power.cc
index 64f33f2..7206fbe 100644
--- a/ash/system/chromeos/power/tray_power.cc
+++ b/ash/system/chromeos/power/tray_power.cc
@@ -217,11 +217,12 @@ TrayPower::~TrayPower() {
// static
bool TrayPower::IsBatteryChargingUnreliable(
const chromeos::PowerSupplyStatus& supply_status) {
- return
- supply_status.battery_state ==
- PowerSupplyStatus::NEITHER_CHARGING_NOR_DISCHARGING ||
- supply_status.battery_state ==
- PowerSupplyStatus::CONNECTED_TO_USB;
+ // Sometimes devices can get into a state where the battery is almost fully
+ // charged and the power subsystem reports "neither charging nor discharging"
+ // despite the battery not at 100%. For now, only report unreliable charging
+ // on USB.
+ // TODO(derat): Update this when the power manager code is refactored for M29.
+ return supply_status.battery_state == PowerSupplyStatus::CONNECTED_TO_USB;
}
// static