summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authortengs@chromium.org <tengs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 11:06:27 +0000
committertengs@chromium.org <tengs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-24 11:06:27 +0000
commitdd3957d1c2e2cec31c18e52db8aefa4280107da4 (patch)
tree176d84e734d4f6f9ae374d29787fbc6af32e8017 /chromeos
parent7a2ad5798270c6804dd18be81643e09b27ecd77e (diff)
downloadchromium_src-dd3957d1c2e2cec31c18e52db8aefa4280107da4.zip
chromium_src-dd3957d1c2e2cec31c18e52db8aefa4280107da4.tar.gz
chromium_src-dd3957d1c2e2cec31c18e52db8aefa4280107da4.tar.bz2
Validate consistency of power supply status values.
If the status is not currently calculating battery time to full/empty, then the time to full/empty should not ever be negative. BUG=236601 TEST=manually on device Review URL: https://chromiumcodereview.appspot.com/15922002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202051 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/dbus/power_manager_client.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/chromeos/dbus/power_manager_client.cc b/chromeos/dbus/power_manager_client.cc
index 566dbab..ccf75a7 100644
--- a/chromeos/dbus/power_manager_client.cc
+++ b/chromeos/dbus/power_manager_client.cc
@@ -430,6 +430,19 @@ class PowerManagerClientImpl : public PowerManagerClient {
NOTREACHED();
break;
}
+
+ // Check power status values are consistent
+ if (!status.is_calculating_battery_time) {
+ int64 battery_seconds_to_goal = status.line_power_on ?
+ status.battery_seconds_to_full : status.battery_seconds_to_empty;
+ if (battery_seconds_to_goal < 0) {
+ LOG(ERROR) << "Received power supply status with negative seconds to "
+ << (status.line_power_on ? "full" : "empty")
+ << ". Assume time is still being calculated.";
+ status.is_calculating_battery_time = true;
+ }
+ }
+
VLOG(1) << "Power status: " << status.ToString();
FOR_EACH_OBSERVER(Observer, observers_, PowerChanged(status));
}