Add ringtones/wallpapers plugins, AT console, dialer USSD/*#06#, and SIM icon fix

This commit is contained in:
Luxferre
2026-10-24 19:58:11 +03:00
parent e549aaf413
commit dc59704547
64 changed files with 2743 additions and 130 deletions
@@ -408,8 +408,165 @@ case "$cmd" in
exit 1
;;
imei)
imei1=""
imei2=""
imei_sv=""
if detect_qmicli_modem; then
dms_ids="$($QMICLI_MODEM --dms-get-ids 2>/dev/null || true)"
imei1="$(printf "%s\n" "$dms_ids" | sed -n "s/.*IMEI: '\([0-9]\{14,16\}\)'/\1/p" | head -n1)"
imei_sv="$(printf "%s\n" "$dms_ids" | sed -n "s/.*IMEI SV: '\([^']*\)'/\1/p" | head -n1)"
fi
if [ -z "$imei1" ]; then
imei1="$(mmcli -m any -K 2>/dev/null | awk -F': ' '/modem\.3gpp\.imei/ {print $2; exit}')"
fi
# Query secondary AT channel (/dev/wwan0at1) if present
if [ -c "/dev/wwan0at1" ]; then
at_out="$(timeout 1 sh -c '
stty -F /dev/wwan0at1 raw -echo 115200 2>/dev/null || true
(cat /dev/wwan0at1 & pid=$!; printf "AT+CGSN\r\n" > /dev/wwan0at1; sleep 0.25; kill $pid 2>/dev/null) 2>/dev/null
' 2>/dev/null | tr -d "\r" | grep -oE '^[0-9]{15}$' | head -n1 || true)"
if [ -n "$at_out" ] && [ "$at_out" != "$imei1" ]; then
imei2="$at_out"
fi
fi
# Scan factory partitions for Luhn-valid 15-digit IMEIs (TAC 35...)
if [ -z "$imei2" ]; then
for part in /dev/disk/by-partlabel/traceability /dev/disk/by-partlabel/tunning /dev/disk/by-partlabel/devinfo /dev/disk/by-partlabel/oem; do
[ -e "$part" ] || continue
cand_list="$(strings -n 14 "$part" 2>/dev/null | grep -oE '35[0-9]{13}' | awk '
{
val = $0
sum = 0
for (i = 1; i <= 14; i++) {
d = substr(val, i, 1) + 0
if (i % 2 == 0) {
d *= 2
if (d > 9) d -= 9
}
sum += d
}
chk = (10 - (sum % 10)) % 10
if (chk == (substr(val, 15, 1) + 0)) print val
}
' || true)"
for c in $cand_list; do
if [ -z "$imei1" ]; then
imei1="$c"
elif [ "$c" != "$imei1" ] && [ -z "$imei2" ]; then
imei2="$c"
break 2
fi
done
done
fi
echo "IMEI1=${imei1}"
echo "IMEI2=${imei2}"
echo "IMEI_SV=${imei_sv}"
;;
usb-tether)
mode="${2:-status}"
case "$mode" in
on)
sysctl -w net.ipv4.ip_forward=1 >/dev/null 2>&1 || true
nft add table ip nat 2>/dev/null || true
nft 'add chain ip nat postrouting { type nat hook postrouting priority 100 ; }' 2>/dev/null || true
nft add rule ip nat postrouting oifname "wwan*" masquerade 2>/dev/null || true
nft add rule ip nat postrouting oifname "wlan*" masquerade 2>/dev/null || true
ip addr show dev usb0 2>/dev/null | grep -q "172.16.42.1" || ip addr add 172.16.42.1/16 dev usb0 2>/dev/null || true
ip link set usb0 up 2>/dev/null || true
echo "1" > /tmp/bananarchy_usb_tether.active
;;
off)
sysctl -w net.ipv4.ip_forward=0 >/dev/null 2>&1 || true
nft delete table ip nat 2>/dev/null || true
nmcli connection delete USBNetworkShare >/dev/null 2>&1 || true
ip addr show dev usb0 2>/dev/null | grep -q "172.16.42.1" || ip addr add 172.16.42.1/16 dev usb0 2>/dev/null || true
ip link set usb0 up 2>/dev/null || true
rm -f /tmp/bananarchy_usb_tether.active
;;
*)
if [ -f /tmp/bananarchy_usb_tether.active ] && [ "$(sysctl -n net.ipv4.ip_forward 2>/dev/null || echo 0)" = "1" ]; then
echo "ACTIVE=1"
else
echo "ACTIVE=0"
fi
;;
esac
;;
at)
port="${2:-auto}"
shift 2 2>/dev/null || true
at_cmd="$*"
if [ -z "$at_cmd" ]; then
echo "ERROR: Empty AT command"
exit 1
fi
run_at_dev() {
dev="$1"
[ -c "$dev" ] || return 1
out="$(timeout 2 awk -v dev="$dev" -v cmd="$at_cmd" '
BEGIN {
sys = "stty -F " dev " raw -echo 115200 min 0 time 2 2>/dev/null"
system(sys)
printf "%s\r\n", cmd > dev
close(dev)
}
' 2>/dev/null || true)"
return 0
}
resp=""
for candidate in "$port" wwan0at1 wwan0at0; do
case "$candidate" in
wwan0at0|wwan0at1)
dev="/dev/$candidate"
if [ -c "$dev" ]; then
resp="$(timeout 2 sh -c '
dev="$1"
cmd="$2"
stty -F "$dev" raw -echo 115200 min 0 time 2 2>/dev/null || true
exec 3<>"$dev"
dd bs=256 count=4 status=none <&3 >/dev/null 2>&1 || true
printf "%s\r\n" "$cmd" >&3
lines=""
i=0
while [ "$i" -lt 8 ]; do
chunk="$(dd bs=512 count=1 status=none <&3 2>/dev/null | tr -d "\r" || true)"
if [ -n "$chunk" ]; then
lines="${lines}${chunk}"
case "$lines" in
*OK*|*ERROR*)
break
;;
esac
fi
i=$((i + 1))
done
exec 3>&-
printf "%s\n" "$lines"
' _ "$dev" "$at_cmd" 2>/dev/null | sed '/^[[:space:]]*$/d' || true)"
if [ -n "$resp" ]; then
printf "%s\n" "$resp"
exit 0
fi
fi
;;
esac
[ "$port" != "auto" ] && [ "$candidate" = "$port" ] && break
done
mm_out="$(mmcli -m any --command="$at_cmd" 2>&1 || true)"
if [ -n "$mm_out" ]; then
printf "%s\n" "$mm_out" | sed "s/^response: '\(.*\)'$/\1/"
exit 0
fi
echo "ERROR: No response from modem AT channel"
exit 1
;;
*)
echo "Usage: $0 [boot|status|switch <1|2>|verify-pin <slot> <pin>|unblock-puk <slot> <puk> <newpin>|set-pin-lock <slot> <enable|disable> <pin>|change-pin <slot> <oldpin> <newpin>]" >&2
echo "Usage: $0 [boot|status|switch <1|2>|verify-pin <slot> <pin>|unblock-puk <slot> <puk> <newpin>|set-pin-lock <slot> <enable|disable> <pin>|change-pin <slot> <oldpin> <newpin>|imei|usb-tether <on|off|status>|at <port> <cmd>]" >&2
exit 1
;;
esac