diff --git a/configs/default_hooks/postwake b/configs/default_hooks/postwake index 03b1ad3..fef6881 100644 --- a/configs/default_hooks/postwake +++ b/configs/default_hooks/postwake @@ -1,45 +1,9 @@ #!/usr/bin/env sh -. "$(which sxmo_common.sh)" +UNSUSPENDREASON="$1" -if [ "$1" = "modem" ]; then - # Modem wakeup will be handled by the modemmonitor loops - # We should not manage the phone lock state here - exit 0 -fi +#The UNSUSPENDREASON can be "usb power", "modem", "rtc" (real-time clock +#periodic wakeup) or "button". You will likely want to check against this and +#decide what to do -REDLED_PATH="/sys/class/leds/red:indicator/brightness" -BLUELED_PATH="/sys/class/leds/blue:indicator/brightness" - -finish() { - kill $BLINKPID - - echo 0 > "$REDLED_PATH" - echo 0 > "$BLUELED_PATH" - - # Going back to crust - if [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; then - sxmo_screenlock.sh crust - fi - - exit 0 -} - -trap 'finish' TERM INT EXIT - -blink() { - while [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; do - echo 1 > "$REDLED_PATH" - echo 0 > "$BLUELED_PATH" - sleep 0.25 - echo 0 > "$REDLED_PATH" - echo 1 > "$BLUELED_PATH" - sleep 0.25 - done -} - -blink & -BLINKPID=$! - -# Replace this by wathever you want to do -sleep 5 +# Add here whatever you want to do diff --git a/scripts/core/sxmo_postwake.sh b/scripts/core/sxmo_postwake.sh new file mode 100755 index 0000000..56816c7 --- /dev/null +++ b/scripts/core/sxmo_postwake.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env sh + +. "$(which sxmo_common.sh)" + +UNSUSPENDREASON="$1" +if [ "$UNSUSPENDREASON" = "modem" ] || [ "$UNSUSPENDREASON" = "rtc" ]; then + # Modem wakeup will be handled by the modemmonitor loops + # Rtc wakeup will eventually be handled by the rtcwake script + # We should not manage those phone lock state here + # we will still call the postwake hook though + sxmo_hooks.sh postwake "$UNSUSPENDREASON" + exit 0 +fi + +REDLED_PATH="/sys/class/leds/red:indicator/brightness" +BLUELED_PATH="/sys/class/leds/blue:indicator/brightness" + +finish() { + kill $BLINKPID + + echo 0 > "$REDLED_PATH" + echo 0 > "$BLUELED_PATH" + + # Going back to crust + if [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; then + sxmo_screenlock.sh crust + fi + + exit 0 +} + +trap 'finish' TERM INT EXIT + +blink() { + while [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; do + echo 1 > "$REDLED_PATH" + echo 0 > "$BLUELED_PATH" + sleep 0.25 + echo 0 > "$REDLED_PATH" + echo 1 > "$BLUELED_PATH" + sleep 0.25 + done +} + +blink & +BLINKPID=$! + +# call the user hook, but ensure we wait at least 5 seconds which is essential for +# the unlock functionality to function well +sleep 5 & +SLEEPPID=$! +sxmo_hooks.sh postwake "$UNSUSPENDREASON" +wait $SLEEPPID diff --git a/scripts/core/sxmo_screenlock.sh b/scripts/core/sxmo_screenlock.sh index 71fc5a1..8f90858 100755 --- a/scripts/core/sxmo_screenlock.sh +++ b/scripts/core/sxmo_screenlock.sh @@ -179,7 +179,8 @@ elif [ "$1" = "crust" ] ; then if [ "$UNSUSPENDREASON" != "modem" ]; then echo 1200 > "$NETWORKRTCSCAN" fi - sxmo_hooks.sh postwake "$UNSUSPENDREASON" + #this will in turn invoke the postwake hook + sxmo_postwake.sh "$UNSUSPENDREASON" exit 0 elif [ "$1" = "getCurState" ] ; then getCurState