Log time between network drops -- from online to offline.
Rewrite most of metrics_daemon. Convert to low-level D-Bus API -- this
simplifies the code a little and also allows us to catch the power
state signal. I still suspect we may be abusing D-Bus a little but it
seems to work.
snanda@ -- please review the power state code specifically.
BUG=none
TEST=tested on target platform and arm-generic builds
Review URL: http://codereview.chromium.org/1799001
diff --git a/action_lid.sh b/action_lid.sh
index dc0646c..d870069 100755
--- a/action_lid.sh
+++ b/action_lid.sh
@@ -4,39 +4,47 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-# Shutdown instead of sleeping if no one is logged in
+# Shutdowns instead of sleeping if no one is logged in.
if ! test -f /var/run/state/logged-in; then
shutdown -h now
exit 0
fi
-# Check whether the lid is closed before proceeding
+# Checks whether the lid is closed before proceeding.
grep -q open /proc/acpi/button/lid/*/state
if [ $? = 0 ]; then
exit 0
fi
# On lid close:
-# - lock the screen
+# - locks the screen
export HOME=/home/chronos
/usr/bin/xscreensaver-command -l
-# - sleep for a bit to give the window manager time to draw the xscreensaver
+# - announces the event
+/usr/bin/dbus-send --type=signal --system / \
+ org.chromium.Power.Manager.PowerStateChanged string:mem
+
+# - sleeps for a bit to give the window manager time to draw the xscreensaver
# window to the screen -- see http://crosbug.com/2250.
# TODO: Remove this hack once we have a better solution in place that adds
# some coordination between the screen locker and the window manager.
sleep 0.5
-# - suspend the cryptohome device
+# - suspends the cryptohome device
#CRYPTOHOME=/dev/mapper/cryptohome
#/usr/bin/test -b $CRYPTOHOME && /sbin/dmsetup suspend $CRYPTOHOME
-# - suspend to ram
+# - suspends to ram
echo -n mem > /sys/power/state
# On lid open:
# - has it such that you don't have to press a key to display lock screen
/usr/bin/xscreensaver-command -deactivate
-# - resume cryptohome device
+# - announces the event
+/usr/bin/dbus-send --type=signal --system / \
+ org.chromium.Power.Manager.PowerStateChanged string:on
+
+# - resumes cryptohome device
#/usr/bin/test -b $CRYPTOHOME && /sbin/dmsetup resume $CRYPTOHOME