Implement 0010 RPM/L2/WCD/UART deep-standby, Adreno 304 ICC/SMMU fixes, and C11 autostart daemons
- patches/kernel/0010-msm8909-rpm-lpm-bimc-wcd-ldo-uart.patch and device DTS/DTB files (nokia-{argon,beatles,beatles-cover,coconut,sparkler,leo}): vMPM APSS RPM sleep, L2 SAW2 collapse, WCD-digital runtime PM, PM8909 LDO seeding, ttyMSM0 disable, dynamic msm_gpu gfx-mem BIMC interconnect scaling (mas_oxili), and qcom_iommu context restore + atomic TLB flush on resume.
- Replace Python/shell autostart loops with compiled C11 ARM ELF daemons (bananarchy-dsds, bananarchy-modemmonitor, bananarchy-soundmonitor, bananarchy-notifmonitor, bananarchy-run-aligned, bananarchy-session-loop) plus scripts/test-dsds-daemon.py.
- Update scripts/check-rebuild.sh, CHANGELOG.md, BATTERY-OPTIMIZATION-ANALYSIS.md, MANUAL.md, README.md, and AGENTS.md with verified a1114 (carbonara) image/archive pins and guards.
This commit is contained in:
1 parent
96c66bf0c6
commit
2ae4ef34a2
86 files changed
+99754
-94563
No files matched your search
@@ -16,6 +16,7 @@ KBD_PATH=/sys/class/leds/white:kbd_backlight/brightness
|
||||
RL_PATH=/sys/devices/system/cpu/cpufreq/schedutil/rate_limit_us
|
||||
GPU_GOV_PATH=/sys/class/devfreq/1c00000.gpu/governor
|
||||
WIFI_OFFLOAD_PATH=/sys/module/wcn36xx/parameters/screen_off_offload
|
||||
SPM_SCREEN_OFF_PATH=/sys/module/cpuidle_qcom_spm/parameters/screen_off
|
||||
COVER_MARKER=/run/bananarchy/cover-backlight
|
||||
FORCE_MARKER=/run/bananarchy/cover-bl-force
|
||||
STATE_CACHE=/run/bananarchy/cover-power-state
|
||||
@@ -86,7 +87,9 @@ if [ "$(read_value "$LID_PROFILE")" != "flip" ]; then
|
||||
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "powersave"
|
||||
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "Y"
|
||||
force_dpms "Off"
|
||||
[ -w "$SPM_SCREEN_OFF_PATH" ] && set_if_changed "$SPM_SCREEN_OFF_PATH" "Y"
|
||||
else
|
||||
[ -w "$SPM_SCREEN_OFF_PATH" ] && set_if_changed "$SPM_SCREEN_OFF_PATH" "N"
|
||||
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "simple_ondemand"
|
||||
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "N"
|
||||
force_dpms "On"
|
||||
@@ -180,14 +183,23 @@ else
|
||||
fi
|
||||
|
||||
[ -n "$DESIRED_KBD" ] && set_if_changed "$KBD_PATH" "$DESIRED_KBD"
|
||||
if [ "$DESIRED_DPMS" = "Off" ] || [ "$marker" = "0" ] || [ "$marker" = "1" ]; then
|
||||
if [ "$DESIRED_DPMS" = "Off" ]; then
|
||||
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "powersave"
|
||||
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "Y"
|
||||
else
|
||||
[ -w "$GPU_GOV_PATH" ] && set_if_changed "$GPU_GOV_PATH" "simple_ondemand"
|
||||
fi
|
||||
if [ "$DESIRED_DPMS" = "Off" ] || [ "$marker" = "0" ] || [ "$marker" = "1" ]; then
|
||||
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "Y"
|
||||
else
|
||||
[ -w "$WIFI_OFFLOAD_PATH" ] && set_if_changed "$WIFI_OFFLOAD_PATH" "N"
|
||||
fi
|
||||
if [ "$DESIRED_DPMS" != "Off" ]; then
|
||||
[ -w "$SPM_SCREEN_OFF_PATH" ] && set_if_changed "$SPM_SCREEN_OFF_PATH" "N"
|
||||
fi
|
||||
force_dpms "$DESIRED_DPMS"
|
||||
if [ "$DESIRED_DPMS" = "Off" ]; then
|
||||
[ -w "$SPM_SCREEN_OFF_PATH" ] && set_if_changed "$SPM_SCREEN_OFF_PATH" "Y"
|
||||
fi
|
||||
[ -w "$RL_PATH" ] && set_if_changed "$RL_PATH" "40000"
|
||||
|
||||
if [ "$FORCE" -eq 1 ]; then
|
||||
|
||||
Executable
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -10,9 +10,15 @@ PARKED="$RUNDIR/parked"
|
||||
AIDFILE="$RUNDIR/secondary.aid"
|
||||
SLOTFILE="$RUNDIR/secondary.slot"
|
||||
TOKEN="$RUNDIR/token"
|
||||
RAT_PARKED="$RUNDIR/rat_parked"
|
||||
RAT_SAVED="$RUNDIR/saved_rat"
|
||||
RAT_TOKEN="$RUNDIR/rat.token"
|
||||
IPV6_RA_SAVED="$RUNDIR/wlan0_accept_ra"
|
||||
BOOTTOKEN="$RUNDIR/boot.token"
|
||||
READYSTAMP="$RUNDIR/modem_ready.stamp"
|
||||
DRXLOCK="$RUNDIR/lock.drx"
|
||||
ACCEPT_RA=/proc/sys/net/ipv6/conf/wlan0/accept_ra
|
||||
SPM_PARAM_DIR=/sys/module/cpuidle_qcom_spm/parameters
|
||||
QMI="timeout 8 qmicli --silent -pd qrtr://0"
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
@@ -23,6 +29,10 @@ WIFI_LISTEN_INTERVAL=5
|
||||
MODEM_DRX_MODE=6
|
||||
DSDS_SECONDARY_MODE=active
|
||||
DSDS_PARK_DELAY=300
|
||||
CPU_RPM_SLEEP=1
|
||||
CPU_L2_SLEEP=1
|
||||
WIFI_SCREEN_OFF_IPV6_MUTE=1
|
||||
WIFI_STANDBY_RAT=keep
|
||||
[ -r "$CONF" ] && . "$CONF"
|
||||
|
||||
mkdir -p "$RUNDIR" 2>/dev/null || true
|
||||
@@ -153,8 +163,95 @@ unpark() {
|
||||
rm -f "$PARKED" "$AIDFILE" "$SLOTFILE" "$RUNDIR"/drx.wwan* 2>/dev/null || true
|
||||
}
|
||||
|
||||
set_spm_bool() {
|
||||
path="$1"
|
||||
val="$2"
|
||||
[ -w "$path" ] || return 0
|
||||
case "$val" in
|
||||
1|Y|y) want="Y" ;;
|
||||
0|N|n) want="N" ;;
|
||||
*) return 0 ;;
|
||||
esac
|
||||
printf '%s\n' "$want" > "$path" 2>/dev/null || true
|
||||
}
|
||||
|
||||
apply_cpu_lpm() {
|
||||
set_spm_bool "$SPM_PARAM_DIR/rpm_sleep" "$CPU_RPM_SLEEP"
|
||||
set_spm_bool "$SPM_PARAM_DIR/l2_sleep" "$CPU_L2_SLEEP"
|
||||
}
|
||||
|
||||
mute_wifi_ipv6_ra() {
|
||||
[ "$WIFI_SCREEN_OFF_IPV6_MUTE" = "1" ] || return 0
|
||||
[ -w "$ACCEPT_RA" ] || return 0
|
||||
ip -4 addr show dev wlan0 2>/dev/null | grep -q 'inet ' || return 0
|
||||
if [ ! -f "$IPV6_RA_SAVED" ]; then
|
||||
cur_ra=""
|
||||
IFS= read -r cur_ra < "$ACCEPT_RA" 2>/dev/null || cur_ra=""
|
||||
case "$cur_ra" in ''|*[!0-9]*) cur_ra=1 ;; esac
|
||||
printf '%s\n' "$cur_ra" > "$IPV6_RA_SAVED" 2>/dev/null || true
|
||||
fi
|
||||
printf '0\n' > "$ACCEPT_RA" 2>/dev/null || true
|
||||
}
|
||||
|
||||
restore_wifi_ipv6_ra() {
|
||||
[ -f "$IPV6_RA_SAVED" ] || return 0
|
||||
saved_ra=1
|
||||
IFS= read -r saved_ra < "$IPV6_RA_SAVED" 2>/dev/null || saved_ra=1
|
||||
case "$saved_ra" in ''|*[!0-9]*) saved_ra=1 ;; esac
|
||||
[ -w "$ACCEPT_RA" ] && printf '%s\n' "$saved_ra" > "$ACCEPT_RA" 2>/dev/null || true
|
||||
rm -f "$IPV6_RA_SAVED" 2>/dev/null || true
|
||||
}
|
||||
|
||||
park_wifi_rat() {
|
||||
[ "$WIFI_STANDBY_RAT" = "gsm" ] || return 0
|
||||
[ -f "$RAT_PARKED" ] && return 0
|
||||
oper=""
|
||||
[ -r /sys/class/net/wlan0/operstate ] && { IFS= read -r oper < /sys/class/net/wlan0/operstate 2>/dev/null || oper=""; }
|
||||
[ "$oper" = "up" ] || return 0
|
||||
saved_rat="$($QMI --nas-get-system-selection-preference 2>/dev/null | awk -F"'" '
|
||||
/Mode preference:/ { gsub(/[[:space:]]*,[[:space:]]*/, "|", $2); print $2; exit }
|
||||
')"
|
||||
[ -n "$saved_rat" ] || saved_rat="gsm|umts|lte"
|
||||
[ "$saved_rat" = "gsm" ] && return 0
|
||||
printf '%s\n' "$saved_rat" > "$RAT_SAVED" 2>/dev/null || true
|
||||
if $QMI --nas-set-system-selection-preference='gsm' >/dev/null 2>&1; then
|
||||
: > "$RAT_PARKED"
|
||||
log "Wi-Fi standby RAT parked to gsm (saved: $saved_rat)"
|
||||
return 0
|
||||
fi
|
||||
rm -f "$RAT_SAVED" 2>/dev/null || true
|
||||
log "failed to park Wi-Fi standby RAT to gsm"
|
||||
return 1
|
||||
}
|
||||
|
||||
unpark_wifi_rat() {
|
||||
[ -f "$RAT_PARKED" ] || return 0
|
||||
saved_rat=""
|
||||
[ -r "$RAT_SAVED" ] && { IFS= read -r saved_rat < "$RAT_SAVED" 2>/dev/null || saved_rat=""; }
|
||||
[ -n "$saved_rat" ] || saved_rat="gsm|umts|lte"
|
||||
if $QMI --nas-set-system-selection-preference="$saved_rat" >/dev/null 2>&1; then
|
||||
log "Wi-Fi standby RAT restored ($saved_rat)"
|
||||
else
|
||||
log "failed to restore Wi-Fi standby RAT ($saved_rat)"
|
||||
fi
|
||||
rm -f "$RAT_PARKED" "$RAT_SAVED" 2>/dev/null || true
|
||||
}
|
||||
|
||||
screenoff() {
|
||||
apply_cpu_lpm
|
||||
mute_wifi_ipv6_ra
|
||||
apply_modem_drx cached || true
|
||||
if [ "$WIFI_STANDBY_RAT" = "gsm" ]; then
|
||||
rtok="$(date +%s)-$$"
|
||||
printf '%s\n' "$rtok" > "$RAT_TOKEN"
|
||||
(
|
||||
sleep 30
|
||||
cur=""
|
||||
[ -r "$RAT_TOKEN" ] && { read -r cur < "$RAT_TOKEN" 2>/dev/null || cur=""; }
|
||||
[ "$cur" = "$rtok" ] || exit 0
|
||||
"$0" _park_rat >/dev/null 2>&1
|
||||
) &
|
||||
fi
|
||||
[ "$DSDS_SECONDARY_MODE" = "eco" ] || return 0
|
||||
token="$(date +%s)-$$"
|
||||
printf '%s\n' "$token" > "$TOKEN"
|
||||
@@ -168,7 +265,11 @@ screenoff() {
|
||||
}
|
||||
|
||||
screenon() {
|
||||
rm -f "$TOKEN" 2>/dev/null || true
|
||||
rm -f "$TOKEN" "$RAT_TOKEN" 2>/dev/null || true
|
||||
set_spm_bool "$SPM_PARAM_DIR/screen_off" 0
|
||||
apply_cpu_lpm
|
||||
restore_wifi_ipv6_ra
|
||||
unpark_wifi_rat
|
||||
unpark
|
||||
apply_modem_drx cached || true
|
||||
}
|
||||
@@ -176,6 +277,9 @@ screenon() {
|
||||
apply_now() {
|
||||
rm -f "$BOOTTOKEN" "$READYSTAMP" "$RUNDIR"/drx.wwan* 2>/dev/null || true
|
||||
write_modprobe || true
|
||||
apply_cpu_lpm
|
||||
[ "$WIFI_SCREEN_OFF_IPV6_MUTE" = "1" ] || restore_wifi_ipv6_ra
|
||||
[ "$WIFI_STANDBY_RAT" = "gsm" ] || unpark_wifi_rat
|
||||
apply_modem_drx force || true
|
||||
}
|
||||
|
||||
@@ -198,8 +302,9 @@ modem_ready() {
|
||||
}
|
||||
|
||||
boot() {
|
||||
rm -f "$TOKEN" "$PARKED" "$AIDFILE" "$SLOTFILE" "$READYSTAMP" "$RUNDIR"/drx.wwan* 2>/dev/null || true
|
||||
rm -f "$TOKEN" "$RAT_TOKEN" "$PARKED" "$AIDFILE" "$SLOTFILE" "$RAT_PARKED" "$RAT_SAVED" "$IPV6_RA_SAVED" "$READYSTAMP" "$RUNDIR"/drx.wwan* 2>/dev/null || true
|
||||
write_modprobe || true
|
||||
apply_cpu_lpm
|
||||
btok="$$-$(cat /proc/uptime 2>/dev/null | awk '{print $1}' || echo 0)"
|
||||
printf '%s\n' "$btok" > "$BOOTTOKEN"
|
||||
(
|
||||
@@ -223,16 +328,37 @@ boot() {
|
||||
) >/dev/null 2>&1 &
|
||||
}
|
||||
|
||||
debugfs_summary() {
|
||||
dir="$1"
|
||||
[ -d "$dir" ] || { printf 'n/a'; return 0; }
|
||||
out=""
|
||||
for f in "$dir"/*; do
|
||||
[ -r "$f" ] || continue
|
||||
val="$(tr '\n\t' ' ' < "$f" 2>/dev/null | awk '{$1=$1; print}')"
|
||||
[ -n "$val" ] && out="${out:+$out; }${f##*/}: $val"
|
||||
done
|
||||
printf '%s' "${out:-n/a}"
|
||||
}
|
||||
|
||||
status() {
|
||||
printf 'WIFI_LISTEN_INTERVAL=%s\n' "$WIFI_LISTEN_INTERVAL"
|
||||
printf 'MODEM_DRX_MODE=%s\n' "$MODEM_DRX_MODE"
|
||||
printf 'DSDS_SECONDARY_MODE=%s\n' "$DSDS_SECONDARY_MODE"
|
||||
printf 'DSDS_PARK_DELAY=%s\n' "$DSDS_PARK_DELAY"
|
||||
printf 'CPU_RPM_SLEEP=%s\n' "$CPU_RPM_SLEEP"
|
||||
printf 'CPU_L2_SLEEP=%s\n' "$CPU_L2_SLEEP"
|
||||
printf 'WIFI_SCREEN_OFF_IPV6_MUTE=%s\n' "$WIFI_SCREEN_OFF_IPV6_MUTE"
|
||||
printf 'WIFI_STANDBY_RAT=%s\n' "$WIFI_STANDBY_RAT"
|
||||
if [ -f "$PARKED" ]; then
|
||||
printf 'secondary_parked=yes\n'
|
||||
else
|
||||
printf 'secondary_parked=no\n'
|
||||
fi
|
||||
if [ -f "$RAT_PARKED" ]; then
|
||||
printf 'rat_parked=yes\n'
|
||||
else
|
||||
printf 'rat_parked=no\n'
|
||||
fi
|
||||
if [ -r "$MODPROBE" ]; then
|
||||
printf 'modprobe_conf=%s (%s)\n' "$MODPROBE" "$(tail -n 1 "$MODPROBE")"
|
||||
else
|
||||
@@ -240,6 +366,14 @@ status() {
|
||||
fi
|
||||
printf 'wcn36xx_param=%s\n' "$(cat /sys/module/wcn36xx/parameters/listen_interval 2>/dev/null || echo n/a)"
|
||||
printf 'wcn36xx_screen_off_offload=%s\n' "$(cat /sys/module/wcn36xx/parameters/screen_off_offload 2>/dev/null || echo n/a)"
|
||||
printf 'cpuidle_rpm_sleep=%s\n' "$(cat "$SPM_PARAM_DIR/rpm_sleep" 2>/dev/null || echo n/a)"
|
||||
printf 'cpuidle_l2_sleep=%s\n' "$(cat "$SPM_PARAM_DIR/l2_sleep" 2>/dev/null || echo n/a)"
|
||||
printf 'cpuidle_screen_off=%s\n' "$(cat "$SPM_PARAM_DIR/screen_off" 2>/dev/null || echo n/a)"
|
||||
printf 'cpuidle_rpm_sleep_count=%s\n' "$(cat "$SPM_PARAM_DIR/rpm_sleep_count" 2>/dev/null || echo n/a)"
|
||||
printf 'cpuidle_l2_off_count=%s\n' "$(cat "$SPM_PARAM_DIR/l2_off_count" 2>/dev/null || echo n/a)"
|
||||
printf 'wlan0_accept_ra=%s\n' "$(cat "$ACCEPT_RA" 2>/dev/null || echo n/a)"
|
||||
printf 'qcom_stats=%s\n' "$(debugfs_summary /sys/kernel/debug/qcom_stats)"
|
||||
printf 'qcom_rpm_master_stats=%s\n' "$(debugfs_summary /sys/kernel/debug/qcom_rpm_master_stats)"
|
||||
drx_summary="$(timeout 8 /usr/libexec/msm-modem-uim-selection at all 'AT$QCDRX?' 2>/dev/null | awk '
|
||||
/^\[wwan0at/ { gsub(/[\[\]]/, "", $0); p=$0; next }
|
||||
/\$QCDRX:/ { gsub(/^[[:space:]]+|[[:space:]]+$/, "", $0); if (p != "") out = (out ? out " " : "") p ":" $0 }
|
||||
@@ -255,7 +389,8 @@ case "${1:-}" in
|
||||
screenoff) screenoff ;;
|
||||
screenon) screenon ;;
|
||||
_park) park ;;
|
||||
unpark) unpark ;;
|
||||
_park_rat) park_wifi_rat ;;
|
||||
unpark) restore_wifi_ipv6_ra; unpark_wifi_rat; unpark ;;
|
||||
status) status ;;
|
||||
*)
|
||||
printf 'Usage: %s [boot|apply|modem-ready|screenoff|screenon|unpark|status]\n' "${0##*/}" >&2
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -201,50 +201,4 @@ fi
|
||||
fi
|
||||
) &
|
||||
|
||||
first_iter=1
|
||||
while [ "$(cat "$SESSION_PID_FILE" 2>/dev/null)" = "$$" ]; do
|
||||
if pidof -s dwm >/dev/null 2>&1; then
|
||||
exit 0
|
||||
fi
|
||||
# U14: skip X resource/wallpaper work when the panel is powered down.
|
||||
_dark=0
|
||||
if [ -r /sys/class/backlight/backlight/brightness ]; then
|
||||
_bl=1
|
||||
read -r _bl < /sys/class/backlight/backlight/brightness 2>/dev/null || _bl=1
|
||||
[ "${_bl:-1}" = "0" ] && _dark=1
|
||||
fi
|
||||
if [ "$_dark" = "0" ]; then
|
||||
xrdb -merge "$HOME/.Xresources" >/dev/null 2>&1 || true
|
||||
/usr/bin/bananarchy-sync-dunst-theme --no-restart >/dev/null 2>&1 || true
|
||||
fi
|
||||
WP_FILE="/usr/share/wallpapers/bananarchy.png"
|
||||
if [ -f "$XDG_CONFIG_HOME/sxmo/wallpaper" ]; then
|
||||
custom_wp="$(head -n 1 "$XDG_CONFIG_HOME/sxmo/wallpaper" 2>/dev/null)"
|
||||
[ -n "$custom_wp" ] && [ -f "$custom_wp" ] && WP_FILE="$custom_wp"
|
||||
fi
|
||||
WP_FLAG="--bg-fill"
|
||||
if [ -f "$XDG_CONFIG_HOME/sxmo/wallpaper_mode" ]; then
|
||||
wp_mode="$(head -n 1 "$XDG_CONFIG_HOME/sxmo/wallpaper_mode" 2>/dev/null)"
|
||||
case "$wp_mode" in
|
||||
scale|--bg-scale) WP_FLAG="--bg-scale" ;;
|
||||
max|--bg-max) WP_FLAG="--bg-max" ;;
|
||||
center|--bg-center) WP_FLAG="--bg-center" ;;
|
||||
tile|--bg-tile) WP_FLAG="--bg-tile" ;;
|
||||
*) WP_FLAG="--bg-fill" ;;
|
||||
esac
|
||||
fi
|
||||
if [ "$_dark" = "0" ]; then ( feh --no-fehbg "$WP_FLAG" "$WP_FILE" >/dev/null 2>&1 </dev/null & ); fi
|
||||
if [ "$first_iter" = "0" ]; then
|
||||
pidof -s fcitx5 >/dev/null 2>&1 || superctl start fcitx5 >/dev/null 2>&1 || ( /usr/bin/bananarchy-fcitx5.sh </dev/null & )
|
||||
fi
|
||||
first_iter=0
|
||||
if [ -f /tmp/bananarchy_ext_logging ]; then
|
||||
dwm >/tmp/dwm.log 2>&1 || true
|
||||
else
|
||||
dwm >/dev/null 2>&1 || true
|
||||
fi
|
||||
if [ "$(cat "$SESSION_PID_FILE" 2>/dev/null)" != "$$" ] || pidof -s dwm >/dev/null 2>&1; then
|
||||
exit 0
|
||||
fi
|
||||
sleep 0.2
|
||||
done
|
||||
exec /usr/bin/bananarchy-session-loop "$SESSION_PID_FILE"
|
||||
@@ -1,182 +1,2 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright 2022 Sxmo Contributors
|
||||
|
||||
# include common definitions
|
||||
# shellcheck source=scripts/core/sxmo_common.sh
|
||||
. sxmo_common.sh
|
||||
|
||||
# see networkmanager documentation for these state names
|
||||
statenumtoname() {
|
||||
case "$1" in
|
||||
"int32 -1") printf "failed" ;;
|
||||
"int32 0") printf "unknown" ;;
|
||||
"int32 1") printf "initializing" ;;
|
||||
"int32 2") printf "locked" ;;
|
||||
"int32 3") printf "disabled" ;;
|
||||
"int32 4") printf "disabling" ;;
|
||||
"int32 5") printf "enabling" ;;
|
||||
"int32 6") printf "enabled" ;;
|
||||
"int32 7") printf "searching" ;;
|
||||
"int32 8") printf "registered" ;;
|
||||
"int32 9") printf "disconnecting" ;;
|
||||
"int32 10") printf "connecting" ;;
|
||||
"int32 11") printf "connected" ;;
|
||||
*) printf "ERROR" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
mainloop() {
|
||||
# get initial modem state and handle SIM2/QMI PIN lock or unprovisioned slot
|
||||
(
|
||||
tries=0
|
||||
newstate=""
|
||||
while [ "$tries" -lt 15 ]; do
|
||||
newstate="$(mmcli -m any -K 2>/dev/null | grep "^modem.generic.state " | cut -d':' -f2 | sed 's/^ //')"
|
||||
if [ -n "$newstate" ]; then
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
tries=$((tries + 1))
|
||||
done
|
||||
|
||||
uim_st="$(doas -n /usr/libexec/msm-modem-uim-selection status 2>/dev/null || /usr/libexec/msm-modem-uim-selection status 2>/dev/null || true)"
|
||||
if printf "%s\n" "$uim_st" | grep -qE "SLOT[12]_PIN1_STATE=(enabled-not-verified|blocked)|SLOT[12]_APP_STATE=(pin1|puk1)"; then
|
||||
newstate="locked"
|
||||
elif [ "$newstate" = "locked" ] && printf "%s\n" "$uim_st" | grep -q "^MODEM_AVAILABLE=1$"; then
|
||||
newstate="$(mmcli -m any -K 2>/dev/null | grep "^modem.generic.state " | cut -d':' -f2 | sed 's/^ //')"
|
||||
if [ "$newstate" = "locked" ]; then
|
||||
newstate="disabled"
|
||||
fi
|
||||
elif printf "%s\n" "$uim_st" | grep -qE "SLOT[12]_STATE=present" && printf "%s\n" "$uim_st" | grep -q "^PRIMARY_GW_SLOT=0$"; then
|
||||
doas -n /usr/libexec/msm-modem-uim-selection boot >/dev/null 2>&1 || true
|
||||
newstate="$(mmcli -m any -K 2>/dev/null | grep "^modem.generic.state " | cut -d':' -f2 | sed 's/^ //')"
|
||||
elif printf "%s\n" "$uim_st" | grep -q "^SLOT1_STATE=present$" && printf "%s\n" "$uim_st" | grep -q "^SLOT2_STATE=present$" && printf "%s\n" "$uim_st" | grep -q "^SECONDARY_GW_SLOT=0$"; then
|
||||
doas -n /usr/libexec/msm-modem-uim-selection boot >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
if [ -n "$newstate" ]; then
|
||||
# fake oldstate (boot) and reason (0)
|
||||
sxmo_hook_modem.sh "boot" "$newstate" "0"
|
||||
sxmo_hook_statusbar.sh modem
|
||||
fi
|
||||
) &
|
||||
|
||||
# Monitor Secondary GW SIM calls and SMS in Dual-SIM Dual Standby (DSDS)
|
||||
(
|
||||
sleep 4
|
||||
if [ ! -f /tmp/sxmo_dsds_active ]; then
|
||||
doas -n /usr/libexec/msm-modem-uim-selection status >/dev/null 2>&1 || /usr/libexec/msm-modem-uim-selection status >/dev/null 2>&1 || true
|
||||
fi
|
||||
while : ; do
|
||||
if [ "$(cat /tmp/sxmo_dsds_active 2>/dev/null || echo 0)" = "1" ]; then
|
||||
if command -v doas >/dev/null 2>&1; then
|
||||
doas -n /usr/libexec/msm-modem-uim-selection dsds-daemon 2>/dev/null || true
|
||||
else
|
||||
/usr/libexec/msm-modem-uim-selection dsds-daemon 2>/dev/null || true
|
||||
fi
|
||||
sleep 30
|
||||
else
|
||||
sleep 600
|
||||
fi
|
||||
done
|
||||
) &
|
||||
|
||||
# Monitor ModemManager signals using a single dbus-monitor connection
|
||||
dbus-monitor --system \
|
||||
"interface='org.freedesktop.ModemManager1.Modem.Voice',type='signal',member='CallAdded'" \
|
||||
"interface='org.freedesktop.ModemManager1.Modem.Messaging',type='signal',member='Added'" \
|
||||
"interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Sms'" \
|
||||
"interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Call'" \
|
||||
"interface='org.freedesktop.ModemManager1.Modem',type='signal',member='StateChanged'" \
|
||||
"interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd'" |
|
||||
while read -r line; do
|
||||
case "$line" in
|
||||
signal*"interface=org.freedesktop.ModemManager1.Modem.Voice"*"member=CallAdded"*)
|
||||
( sxmo_modem.sh checkforincomingcalls & )
|
||||
;;
|
||||
signal*"interface=org.freedesktop.ModemManager1.Modem.Messaging"*"member=Added"*)
|
||||
( sxmo_modem.sh checkfornewtexts & )
|
||||
;;
|
||||
signal*"path=/org/freedesktop/ModemManager1/SMS/"*"member=PropertiesChanged"*)
|
||||
( sxmo_modem.sh checkfornewtexts & )
|
||||
;;
|
||||
signal*"path=/org/freedesktop/ModemManager1/Call/"*"member=PropertiesChanged"*)
|
||||
( sxmo_modem.sh checkforfinishedcalls & )
|
||||
;;
|
||||
signal*"interface=org.freedesktop.ModemManager1.Modem;"*"member=StateChanged"*)
|
||||
read -r oldstate || true
|
||||
read -r newstate || true
|
||||
read -r reason || true
|
||||
(
|
||||
(
|
||||
sxmo_hook_modem.sh "$(statenumtoname "$oldstate")" \
|
||||
"$(statenumtoname "$newstate")" \
|
||||
"$(echo "$reason" | sed 's/uint32 //')"
|
||||
sxmo_hook_statusbar.sh modem
|
||||
) &
|
||||
)
|
||||
;;
|
||||
signal*"path=/org/freedesktop/ModemManager1/Modem/"*"member=PropertiesChanged"*)
|
||||
MODEM="$(echo "$line" | awk -F'[;=]' '{print $6}')"
|
||||
;;
|
||||
*"string \"NetworkNotification\""*)
|
||||
[ -n "${MODEM:-}" ] && ( sxmo_ussd.sh "$MODEM" "NetworkNotification" "" & )
|
||||
;;
|
||||
*"string \"NetworkRequest\""*)
|
||||
[ -n "${MODEM:-}" ] && ( sxmo_ussd.sh "$MODEM" "NetworkRequest" "" & )
|
||||
;;
|
||||
esac
|
||||
done &
|
||||
|
||||
if [ -f "${SXMO_MMS_BASE_DIR:-"$HOME"/.mms/modemmanager}/mms" ]; then
|
||||
# monitor for received mms
|
||||
dbus-monitor "interface='org.ofono.mms.Service',type='signal',member='MessageAdded'" |
|
||||
while read -r line; do
|
||||
if echo "$line" | grep -q '^object path'; then
|
||||
MESSAGE_PATH="$(echo "$line" | cut -d\" -f2)"
|
||||
fi
|
||||
if echo "$line" | grep -q 'string "received"'; then
|
||||
sxmo_mms.sh processmms "$MESSAGE_PATH"
|
||||
fi
|
||||
done &
|
||||
fi
|
||||
|
||||
if [ -f "${SXMO_VVM_BASE_DIR:-"$HOME"/.vvm/modemmanager}/vvm" ]; then
|
||||
# monitor for vvm (Visual Voice Mail)
|
||||
VVM_START=0
|
||||
dbus-monitor "interface='org.kop316.vvm.Service',type='signal',member='MessageAdded'" |
|
||||
while read -r line; do
|
||||
if echo "$line" | grep -q '^object path'; then
|
||||
VVM_ID="$(echo "$line" | cut -d\" -f2 | rev | cut -d'/' -f1 | rev)"
|
||||
VVM_START=1
|
||||
fi
|
||||
|
||||
if echo "$line" | grep -q '^]'; then
|
||||
VVM_START=0
|
||||
sxmo_vvm.sh processvvm "$VVM_DATE" "$VVM_SENDER" "$VVM_ID" "$VVM_ATTACHMENT"
|
||||
fi
|
||||
|
||||
if [ "$VVM_START" -eq 1 ]; then
|
||||
if echo "$line" | grep -q '^string "Date"'; then
|
||||
read -r line
|
||||
VVM_DATE="$(echo "$line" | cut -d\" -f2)"
|
||||
elif echo "$line" | grep -q '^string "Sender"'; then
|
||||
read -r line
|
||||
VVM_SENDER="$(echo "$line" | cut -d\" -f2)"
|
||||
elif echo "$line" | grep -q '^string "Attachments"'; then
|
||||
read -r line
|
||||
VVM_ATTACHMENT="$(echo "$line" | cut -d\" -f2)"
|
||||
fi
|
||||
fi
|
||||
done &
|
||||
fi
|
||||
|
||||
wait
|
||||
}
|
||||
|
||||
# new session, clean up all phone related files
|
||||
rm "$XDG_RUNTIME_DIR/sxmo_calls/"* 2>/dev/null || true
|
||||
rm -f "$XDG_RUNTIME_DIR"/sxmo.ring.pid 2>/dev/null
|
||||
rm -f "$SXMO_NOTIFDIR"/incomingcall* 2>/dev/null
|
||||
mainloop
|
||||
exec /usr/bin/bananarchy-modemmonitor "$@"
|
||||
@@ -23,7 +23,7 @@ clear_all() {
|
||||
rm -f "$SXMO_NOTIFDIR"/* 2>/dev/null || true
|
||||
dunstctl close-all >/dev/null 2>&1 || true
|
||||
dunstctl history-clear >/dev/null 2>&1 || true
|
||||
pkill -x dunstify >/dev/null 2>&1 || true
|
||||
killall -q dunstify >/dev/null 2>&1 || true
|
||||
sxmo_hook_statusbar.sh notifications >/dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
@@ -73,34 +73,7 @@ _notifications_hook() {
|
||||
}
|
||||
|
||||
monitor() {
|
||||
mkdir -p "$SXMO_NOTIFDIR"
|
||||
|
||||
find "$SXMO_NOTIFDIR" -type f 2>/dev/null | while read -r file; do
|
||||
_handle_new_notif_file "$file" "boot"
|
||||
done
|
||||
|
||||
_notifications_hook
|
||||
|
||||
fifo="$(mktemp -u)"
|
||||
mkfifo "$fifo"
|
||||
inotifywait -mq -e close_write,moved_to,delete "$SXMO_NOTIFDIR" >> "$fifo" &
|
||||
inotif_pid=$!
|
||||
|
||||
finish() {
|
||||
kill "$inotif_pid" 2>/dev/null || true
|
||||
rm -f "$fifo"
|
||||
exit
|
||||
}
|
||||
trap 'finish' TERM INT EXIT
|
||||
|
||||
while read -r notif_folder notif_type notif_file; do
|
||||
if echo "$notif_type" | grep -qE "CLOSE_WRITE|MOVED_TO"; then
|
||||
_handle_new_notif_file "$notif_folder$notif_file"
|
||||
fi
|
||||
_notifications_hook
|
||||
done < "$fifo"
|
||||
|
||||
wait "$inotif_pid"
|
||||
exec /usr/bin/bananarchy-notifmonitor
|
||||
}
|
||||
|
||||
_menu_lines() {
|
||||
@@ -200,7 +173,8 @@ new() {
|
||||
printf "%s\n%s\n%b\n" "$group" "$action" "$msg" > "$tmp_notif"
|
||||
mv -f "$tmp_notif" "$SXMO_NOTIFDIR/$id"
|
||||
|
||||
if ! pgrep -f "sxmo_notifs.sh monitor" >/dev/null 2>&1; then
|
||||
if ! pidof -s bananarchy-notifmonitor >/dev/null 2>&1 && \
|
||||
! pgrep -f "sxmo_notifs.sh monitor" >/dev/null 2>&1; then
|
||||
sxmo_hook_notification.sh "$SXMO_NOTIFDIR/$id" &
|
||||
fi
|
||||
|
||||
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec /usr/bin/bananarchy-run-aligned "$@"
|
||||
@@ -1,185 +1,2 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright 2023 Sxmo Contributors
|
||||
|
||||
# shellcheck source=scripts/core/sxmo_common.sh
|
||||
. "$(dirname "$0")/sxmo_common.sh"
|
||||
|
||||
find_jack_event_dev() {
|
||||
for sysname in /sys/class/input/event*/device/name; do
|
||||
[ -r "$sysname" ] || continue
|
||||
read -r dname < "$sysname" 2>/dev/null || continue
|
||||
case "$dname" in
|
||||
*[Jj]ack*|*[Hh]eadset*)
|
||||
ev="${sysname%/device/name}"
|
||||
ev="/dev/input/${ev##*/}"
|
||||
if [ -c "$ev" ]; then
|
||||
printf "%s\n" "$ev"
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
is_hp_plugged() {
|
||||
jdev="$1"
|
||||
if [ -n "$jdev" ] && command -v evtest >/dev/null 2>&1; then
|
||||
evtest --query "$jdev" EV_SW SW_HEADPHONE_INSERT >/dev/null 2>&1
|
||||
rc=$?
|
||||
[ "$rc" -eq 10 ] && return 0
|
||||
fi
|
||||
if command -v amixer >/dev/null 2>&1; then
|
||||
amixer -c 0 cget "name='Headphone Jack'" 2>/dev/null | grep -q ": values=on" && return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
is_mic_plugged() {
|
||||
jdev="$1"
|
||||
if [ -n "$jdev" ] && command -v evtest >/dev/null 2>&1; then
|
||||
evtest --query "$jdev" EV_SW SW_MICROPHONE_INSERT >/dev/null 2>&1
|
||||
rc=$?
|
||||
[ "$rc" -eq 10 ] && return 0
|
||||
fi
|
||||
if command -v amixer >/dev/null 2>&1; then
|
||||
amixer -c 0 cget "name='Mic Jack'" 2>/dev/null | grep -q ": values=on" && return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
handle_jack_insert() {
|
||||
jdev="$1"
|
||||
cur_out="$(sxmo_audio.sh device get 2>/dev/null || printf "Speaker")"
|
||||
if [ "$cur_out" != "Headphones" ]; then
|
||||
printf "%s\n" "$cur_out" > /tmp/sxmo_prev_out_device 2>/dev/null || true
|
||||
fi
|
||||
printf "1\n" > /tmp/sxmo_jack_plugged 2>/dev/null || true
|
||||
if is_mic_plugged "$jdev"; then
|
||||
printf "Headset\n" > /tmp/sxmo_audio_in_device 2>/dev/null || true
|
||||
sxmo_audio.sh device setinput Headset >/dev/null 2>&1 || true
|
||||
else
|
||||
printf "Mic1\n" > /tmp/sxmo_audio_in_device 2>/dev/null || true
|
||||
fi
|
||||
sxmo_audio.sh device set Headphones >/dev/null 2>&1 || true
|
||||
sxmo_log "Wired headphones plugged in -> routed audio to Headphones"
|
||||
}
|
||||
|
||||
handle_jack_remove() {
|
||||
printf "0\n" > /tmp/sxmo_jack_plugged 2>/dev/null || true
|
||||
printf "Mic1\n" > /tmp/sxmo_audio_in_device 2>/dev/null || true
|
||||
sxmo_audio.sh device setinput Mic1 >/dev/null 2>&1 || true
|
||||
target_out="Speaker"
|
||||
if [ -r /tmp/sxmo_in_call ]; then
|
||||
read -r incall < /tmp/sxmo_in_call 2>/dev/null || incall=0
|
||||
if [ "$incall" = "1" ]; then
|
||||
target_out="Earpiece"
|
||||
fi
|
||||
fi
|
||||
sxmo_audio.sh device set "$target_out" >/dev/null 2>&1 || true
|
||||
sxmo_log "Wired headphones unplugged -> routed audio to $target_out"
|
||||
}
|
||||
|
||||
monitor_jack_events() {
|
||||
while : ; do
|
||||
jdev="$(find_jack_event_dev || true)"
|
||||
if [ -z "$jdev" ] || ! command -v evtest >/dev/null 2>&1; then
|
||||
sleep 5
|
||||
continue
|
||||
fi
|
||||
|
||||
if is_hp_plugged "$jdev"; then
|
||||
handle_jack_insert "$jdev"
|
||||
else
|
||||
printf "0\n" > /tmp/sxmo_jack_plugged 2>/dev/null || true
|
||||
if [ -n "$(pactl list short sinks 2>/dev/null | awk '$2 ~ /^bluez_output\./ { print $2; exit }')" ]; then
|
||||
sxmo_audio.sh device set Bluetooth >/dev/null 2>&1 || true
|
||||
else
|
||||
sxmo_audio.sh device apply >/dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
|
||||
evtest "$jdev" 2>/dev/null | while read -r line; do
|
||||
case "$line" in
|
||||
*SW_HEADPHONE_INSERT*value\ 1*)
|
||||
sleep 0.1
|
||||
handle_jack_insert "$jdev"
|
||||
;;
|
||||
*SW_HEADPHONE_INSERT*value\ 0*)
|
||||
handle_jack_remove
|
||||
;;
|
||||
*SW_MICROPHONE_INSERT*value\ 1*)
|
||||
sxmo_audio.sh device setinput Headset >/dev/null 2>&1 || true
|
||||
;;
|
||||
*SW_MICROPHONE_INSERT*value\ 0*)
|
||||
sxmo_audio.sh device setinput Mic1 >/dev/null 2>&1 || true
|
||||
;;
|
||||
esac
|
||||
done
|
||||
sleep 2
|
||||
done
|
||||
}
|
||||
|
||||
handle_change() {
|
||||
prev_bt_sink="$(pactl list short sinks 2>/dev/null | awk '$2 ~ /^bluez_output\./ { print $2; exit }')"
|
||||
if [ -n "$prev_bt_sink" ]; then
|
||||
cur_out="$(cat /tmp/sxmo_audio_out_device 2>/dev/null || true)"
|
||||
if [ "$cur_out" != "Bluetooth" ]; then
|
||||
sxmo_audio.sh device set Bluetooth >/dev/null 2>&1 || true
|
||||
else
|
||||
sxmo_audio.sh device apply >/dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
|
||||
pactl subscribe 2>/dev/null | while read -r line; do
|
||||
case "$line" in
|
||||
*"Event 'new' on sink"*|*"Event 'new' on card"*|*"Event 'change' on card"*)
|
||||
bt_sink="$(pactl list short sinks 2>/dev/null | awk '$2 ~ /^bluez_output\./ { print $2; exit }')"
|
||||
if [ -n "$bt_sink" ] && [ "$bt_sink" != "$prev_bt_sink" ]; then
|
||||
prev_bt_sink="$bt_sink"
|
||||
sxmo_audio.sh device set Bluetooth >/dev/null 2>&1 || true
|
||||
sxmo_log "Bluetooth sink $bt_sink detected -> routed audio to Bluetooth"
|
||||
fi
|
||||
sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true
|
||||
;;
|
||||
*"Event 'remove' on sink"*|*"Event 'remove' on card"*)
|
||||
bt_sink="$(pactl list short sinks 2>/dev/null | awk '$2 ~ /^bluez_output\./ { print $2; exit }')"
|
||||
if [ -z "$bt_sink" ] && [ -n "$prev_bt_sink" ]; then
|
||||
prev_bt_sink=""
|
||||
cur_out="$(cat /tmp/sxmo_audio_out_device 2>/dev/null || true)"
|
||||
if [ "$cur_out" = "Bluetooth" ]; then
|
||||
if [ "$(cat /tmp/sxmo_jack_plugged 2>/dev/null || true)" = "1" ]; then
|
||||
sxmo_audio.sh device set Headphones >/dev/null 2>&1 || true
|
||||
elif [ -r /tmp/sxmo_in_call ]; then
|
||||
sxmo_audio.sh device set Earpiece >/dev/null 2>&1 || true
|
||||
else
|
||||
sxmo_audio.sh device set Speaker >/dev/null 2>&1 || true
|
||||
fi
|
||||
sxmo_log "Bluetooth sink removed -> restored local audio route"
|
||||
fi
|
||||
fi
|
||||
sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true
|
||||
;;
|
||||
*"Event 'change' on sink"*|*"Event 'change' on source"*)
|
||||
if [ ! -d /tmp/sxmo_volset.lock ]; then
|
||||
sxmo_hook_statusbar.sh volume >/dev/null 2>&1 || true
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
kill 0 2>/dev/null || true
|
||||
}
|
||||
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
monitor_jack_events &
|
||||
|
||||
while : ; do
|
||||
handle_change || true
|
||||
# U10: pactl subscribe is event-driven; only back off after a failure.
|
||||
sleep 10
|
||||
done
|
||||
exec /usr/bin/bananarchy-soundmonitor "$@"
|
||||
@@ -70,12 +70,12 @@ xorgdisplay() {
|
||||
if [ -w /sys/devices/system/cpu/cpufreq/policy0/scaling_governor ]; then
|
||||
printf 'powersave\n' > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor 2>/dev/null || true
|
||||
fi
|
||||
xset s off s noblank >/dev/null 2>&1 || true
|
||||
xset dpms force off >/dev/null 2>&1 || true
|
||||
# K5: pin the Adreno 304 devfreq to its minimum OPP while dark.
|
||||
if [ -w /sys/class/devfreq/1c00000.gpu/governor ]; then
|
||||
printf 'powersave\n' > /sys/class/devfreq/1c00000.gpu/governor 2>/dev/null || true
|
||||
fi
|
||||
xset s off s noblank >/dev/null 2>&1 || true
|
||||
xset dpms force off >/dev/null 2>&1 || true
|
||||
# Power policy: park the secondary SIM after the configured dark delay.
|
||||
/usr/bin/bananarchy-power-policy.sh screenoff >/dev/null 2>&1 &
|
||||
;;
|
||||
@@ -85,6 +85,9 @@ xorgdisplay() {
|
||||
if ! "${BANANARCHY_LID_GATE:-/usr/bin/bananarchy-lid-gate.sh}" wake; then
|
||||
return 0
|
||||
fi
|
||||
if [ -w /sys/module/cpuidle_qcom_spm/parameters/screen_off ]; then
|
||||
printf 'N\n' > /sys/module/cpuidle_qcom_spm/parameters/screen_off 2>/dev/null || true
|
||||
fi
|
||||
if [ -w /sys/devices/system/cpu/cpufreq/policy0/scaling_governor ]; then
|
||||
printf 'schedutil\n' > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor 2>/dev/null || true
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user