~mil/sxmo-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH sxmo-utils] proximitylock: do not restore initial state if the user changed it in between

Details
Message ID
<20240328065748.30392-2-contact@willowbarraco.fr>
DKIM signature
pass
Download raw message
Patch: +36 -13
To do this, we add store, restore, and flushstored to sxmo_state.sh.

store output an id that the caller have to give back to restore. This way,
multiple caller can store, and only the first one that restore actually
does so. This ensure some consistency to the end state workflow.

Any user click in between automatically flushstored, so that the end of
proximitylock will not restore to initial state.

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
---
 scripts/core/sxmo_proximitylock.sh | 16 +++------------
 scripts/core/sxmo_state.sh         | 33 ++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/scripts/core/sxmo_proximitylock.sh b/scripts/core/sxmo_proximitylock.sh
index cef75fdf..863f7bb2 100755
--- a/scripts/core/sxmo_proximitylock.sh
+++ b/scripts/core/sxmo_proximitylock.sh
@@ -10,28 +10,16 @@

finish() {
	sxmo_wakelock.sh unlock sxmo_proximity_lock_running

	if [ -n "$INITIALSTATE" ]; then
		sxmo_state.sh set "$INITIALSTATE"
	fi

	sxmo_state.sh restore "$storeid"
	exit
}

near() {
	if [ -z "$INITIALSTATE" ]; then
		INITIALSTATE="$(sxmo_state.sh get)"
	fi

	sxmo_debug "near"
	sxmo_state.sh set screenoff
}

far() {
	if [ -z "$INITIALSTATE" ]; then
		INITIALSTATE="$(sxmo_state.sh get)"
	fi

	sxmo_debug "far"
	sxmo_state.sh set unlock
}
@@ -47,6 +35,8 @@ else
	prox_raw_bus="$SXMO_PROX_RAW_BUS"
fi

storeid="$(sxmo_state.sh store)"

while : ; do
	value="$(cat "$prox_raw_bus")"
	if [ "$value" -gt 100 ] && [ "$last" != "near" ]; then
diff --git a/scripts/core/sxmo_state.sh b/scripts/core/sxmo_state.sh
index 592597e9..6b51e48d 100644
--- a/scripts/core/sxmo_state.sh
+++ b/scripts/core/sxmo_state.sh
@@ -92,6 +92,7 @@ click() {
	else
		transition "$state"
	fi
	flushstored
}

idle() {
@@ -113,6 +114,25 @@ idle() {
	sxmo_log "idle: not transitioning from $state"
}

store() {
	storeid="$(tr -dc 'a-zA-Z0-9' < /dev/urandom 2>/dev/null | head -c 10)"
	printf %s "$state" > "$SXMO_STATE.stored.$storeid"
	printf %s "$storeid"
}

flushstored() {
	find "$(dirname "$SXMO_STATE")" -name 'sxmo.state.stored.*' -delete
}

restore() {
	storeid="$1"
	if [ -f "$SXMO_STATE.stored.$storeid" ]; then
		state="$(cat "$SXMO_STATE.stored.$storeid")"
		transition "$state"
		flushstored
	fi
}

exec 3<> "$SXMO_STATE.lock"

lock_exclusive() {
@@ -146,4 +166,17 @@ case "$action" in
			transition "$1"
		fi
		;;
	store)
		lock_exclusive
		read_state
		store
		;;
	restore)
		lock_exclusive
		restore "$1"
		;;
	flushstored)
		lock_exclusive
		flushstored
		;;
esac
-- 
2.44.0

[sxmo-utils/patches/test.yml] build failed

builds.sr.ht <builds@sr.ht>
Details
Message ID
<D056S77T0K4S.18XL5HOG1XFVS@fra01>
In-Reply-To
<20240328065748.30392-2-contact@willowbarraco.fr> (view parent)
DKIM signature
missing
Download raw message
sxmo-utils/patches/test.yml: FAILED in 13s

[proximitylock: do not restore initial state if the user changed it in between][0] from [Willow Barraco][1]

[0]: https://lists.sr.ht/~mil/sxmo-devel/patches/50495
[1]: contact@willowbarraco.fr

✗ #1180727 FAILED sxmo-utils/patches/test.yml https://builds.sr.ht/~mil/job/1180727
Reply to thread Export thread (mbox)