init: use frecon to display low battery warning on freon images
BUG=chromium:529496
CQ-DEPEND=I8178341e00ba70002c265c4202d0dd0634e8c6b3
TEST=via ssh: powerd_setuid_helper --action=shut_down --shutdown_reason=low-battery
Signed-off-by: Dominik Behr <dbehr@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/335584
(cherry picked from commit a87c8a5a91530bcd5fa2b199abd506e09e3f94d6)
Change-Id: I389c2c69e917867137383bdc24334caa13dc3566
Signed-off-by: Dominik Behr <dbehr@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/338513
Reviewed-by: Dominik Behr <dbehr@google.com>
Tested-by: Dominik Behr <dbehr@google.com>
diff --git a/init/display_low_battery_alert b/init/display_low_battery_alert
index 4c91220..d8ca434 100755
--- a/init/display_low_battery_alert
+++ b/init/display_low_battery_alert
@@ -4,19 +4,43 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-# Use differently-sized images depending on the framebuffer width.
-WIDTH=$(ply-image --print-resolution | cut -d ' ' -f 1)
ASSETS=/usr/share/chromeos-assets
ASSETS_200=$ASSETS/images_200_percent
ASSETS_100=$ASSETS/images_100_percent
-if [ $WIDTH -gt 1920 -a -e "$ASSETS_200/battery_alert_01.png" ]; then
- IMAGES="$ASSETS_200"/battery_alert*.png
-else
- IMAGES="$ASSETS_100"/battery_alert*.png
+
+if [ ! -x /sbin/frecon ]; then
+ # Fall back to old way with ply-image
+ # Use differently-sized images depending on the framebuffer width.
+ WIDTH=$(ply-image --print-resolution | cut -d ' ' -f 1)
+ if [ $WIDTH -gt 1920 -a -e "$ASSETS_200/battery_alert_01.png" ]; then
+ IMAGES="$ASSETS_200"/battery_alert*.png
+ else
+ IMAGES="$ASSETS_100"/battery_alert*.png
+ fi
+
+ # Run through the images from first to last and then from last to first; then
+ # repeat the sequence three times at 10 FPS.
+ SEQUENCE="$(ls $IMAGES ; ls -r $IMAGES)"
+ FRAMES="$SEQUENCE $SEQUENCE $SEQUENCE"
+ ply-image --clear 0x000000 --frame-interval=100 $FRAMES
+ exit
fi
-# Run through the images from first to last and then from last to first; then
-# repeat the sequence three times at 10 FPS.
-SEQUENCE="$(ls $IMAGES ; ls -r $IMAGES)"
-FRAMES="$SEQUENCE $SEQUENCE $SEQUENCE"
-ply-image --clear 0x000000 --frame-interval=100 $FRAMES
+IMAGES_100="$ASSETS_100"/battery_alert*.png
+SEQ_100="$(ls $IMAGES_100 ; ls -r $IMAGES_100)"
+IMAGES_200="$ASSETS_200"/battery_alert*.png
+SEQ_200="$(ls $IMAGES_200 ; ls -r $IMAGES_200)"
+BAT_IMAGES=""
+
+for image in ${SEQ_200}; do
+ BAT_IMAGES="${BAT_IMAGES} --image-hires ${image}"
+done
+for image in ${SEQ_100}; do
+ BAT_IMAGES="${BAT_IMAGES} --image ${image}"
+done
+
+killall -9 frecon
+/sbin/frecon --clear 0x000000 --loop-interval=100 --loop-count=3 \
+ --loop-start=0 --splash-only ${BAT_IMAGES}
+
+