mirror of
https://github.com/dikeckaan/mu300-linux.git
synced 2026-12-05 08:02:40 +00:00
Add per-SIM IMS, VoLTE and VoNR switches with boot replay
This commit is contained in:
1 parent
48c6ad766a
commit
5f4732e4c6
9 files changed
+312
-10
No files matched your search
@@ -0,0 +1,19 @@
|
||||
# IMS、VoLTE、VoNR 开关(2026-10-14)
|
||||
|
||||
网页“蜂窝 → 网络锁定”新增三个独立开关。行为与 E5 公共仓库对齐,使用 MU300 原有 Shell AT、异步任务与启动流程,没有引入 Python 依赖,也不需要重编内核。
|
||||
|
||||
- 控制“查看/控制卡槽”选择的 SIM,不切换上网卡,设置分别保存。
|
||||
- 保留二次确认、切换卡槽后取消旧确认、互斥和错误提示。
|
||||
- 配置跟随“开机自动应用”;正常平台路径在 AT 握手完成、射频开启和首次拨号之前回放。未配置时保持基带默认,不新增语音设置启动命令。
|
||||
- 单独切换 IMS、VoLTE、VoNR,以及只有语音偏好的开机回放,均不执行 SFUN,不主动 ifup 或重拨。
|
||||
- 网络模式、频段、小区的现有回放和晚期恢复流程保持原样;“清除全部蜂窝锁定”不删除或修改这三项语音偏好。
|
||||
|
||||
指令与用户提供的 `UniSocCellularUtils.kt` 对齐:VoLTE 使用 `AT+CAVIMS`,VoNR 使用 `AT+SP5GCMDS="set nr param",45,<0|1>`,查询 `"get nr synch_param",42`。IMS 总开关使用原厂 RIL 的 `AT+IMSEN=<0|1>`。
|
||||
|
||||
VoLTE、VoNR 回读不一致时不保存。IMS 必须获得明确 OK;部分固件只支持 IMSEN 设置、不支持读取,此时页面明确标识“本次已应用”,不冒充真实回读。记录只对本次启动有效,不用旧开机的缓存推断当前状态。单项查询不支持时,不隐藏其他网络锁定功能。
|
||||
|
||||
关闭 IMS 不能保证屏蔽传统网络的全部电话和短信;页面有对应说明。未改动用户的 IMS APN、NV、射频模式或当前 SIM 设置。
|
||||
|
||||
验证包括 dash/bash 下的锁定与异步任务测试、新增语音开关成功/失败、缺失 OK、回读不一致、双卡文件隔离、仅语音配置的启动入口与单次回放、无额外 SFUN、重置保留偏好,以及实际页面处理函数的二次确认和三语言检查。
|
||||
|
||||
没有进行 MU300 实机部署或真实 IMS/VoLTE/VoNR 通话验证。本次先提交公共代码,不重新编译、打包 MU300。
|
||||
@@ -718,6 +718,12 @@ var DASH_I18N = {
|
||||
'已执行': ['Done', 'Tamamlandı'],
|
||||
'失败': ['Failed', 'Başarısız'],
|
||||
'未知错误': ['Unknown error', 'Bilinmeyen hata'],
|
||||
'状态暂不可读,请选择开启或关闭': ['State unavailable; choose on or off', 'Durum okunamıyor; açın veya kapatın'],
|
||||
'本次已应用': ['Applied this boot', 'Bu açılışta uygulandı'],
|
||||
'关闭后只停止下次开机回放,已保存的网络、IMS、VoLTE 和 VoNR 设置不会被删除。': ['Turning this off only disables boot replay; saved network, IMS, VoLTE and VoNR settings are kept.', 'Kapatmak yalnızca açılışta uygulamayı durdurur; ağ, IMS, VoLTE ve VoNR ayarları korunur.'],
|
||||
'IMS 为总开关,VoLTE 用于 4G 通话,VoNR 用于 5G SA 通话。设置按当前查看的 SIM 保存,并跟随“开机自动应用”。': ['IMS is the master switch; VoLTE handles 4G calls and VoNR handles 5G SA calls. Settings are saved per viewed SIM and follow Apply at boot.', 'IMS ana anahtardır; VoLTE 4G, VoNR 5G SA aramaları içindir. Ayarlar görüntülenen SIM için kaydedilir ve açılışta uygulama ayarını izler.'],
|
||||
'关闭 IMS 不等于屏蔽全部来电和短信,传统网络业务仍可能到达。': ['Disabling IMS does not block every call or SMS; traditional network services may still arrive.', 'IMS kapatıldığında tüm aramalar ve SMS engellenmez; geleneksel şebeke hizmetleri ulaşabilir.'],
|
||||
'IMS 设置没有获得明确确认,未保存': ['IMS setting was not acknowledged; not saved', 'IMS ayarı onaylanmadı; kaydedilmedi'],
|
||||
'调用失败': ['Request failed', 'İstek başarısız'],
|
||||
'正在断开数据连接': ['Disconnecting data', 'Veri bağlantısı kesiliyor'],
|
||||
'正在拨号': ['Connecting data', 'Veri bağlantısı kuruluyor'],
|
||||
|
||||
@@ -52,7 +52,20 @@ return view.extend({
|
||||
<div class="mud-ctl" style="margin-top:7px;max-width:340px">
|
||||
<button class="mud-btn" id="mud-lock-auto-apply">开机自动应用</button>
|
||||
</div>
|
||||
<div class="mud-note">关闭后只停止下次开机回放,已保存的网络模式、EN-DC、频段和小区配置不会被删除。</div>
|
||||
<div class="mud-note">关闭后只停止下次开机回放,已保存的网络、IMS、VoLTE 和 VoNR 设置不会被删除。</div>
|
||||
</div>
|
||||
|
||||
<div class="mud-sec">
|
||||
<h3>IMS · VoLTE · VoNR</h3>
|
||||
<div class="mud-note">IMS 为总开关,VoLTE 用于 4G 通话,VoNR 用于 5G SA 通话。设置按当前查看的 SIM 保存,并跟随“开机自动应用”。</div>
|
||||
${['ims','volte','vonr'].map(function(kind) {
|
||||
var name = {ims:'IMS',volte:'VoLTE',vonr:'VoNR'}[kind];
|
||||
return '<div class="mud-r"><span class="mud-k">'+name+'</span><span class="mud-v" id="mud-lock-'+kind+'-state">--</span></div>'+
|
||||
'<div class="mud-ctl" style="max-width:340px;margin:7px 0 12px;grid-template-columns:1fr 1fr">'+
|
||||
'<button class="mud-btn" data-voice="'+kind+'" data-enabled="on">开启</button>'+
|
||||
'<button class="mud-btn" data-voice="'+kind+'" data-enabled="off">关闭</button></div>';
|
||||
}).join('')}
|
||||
<div class="mud-note">关闭 IMS 不等于屏蔽全部来电和短信,传统网络业务仍可能到达。</div>
|
||||
</div>
|
||||
|
||||
<div class="mud-sec">
|
||||
@@ -178,6 +191,14 @@ return view.extend({
|
||||
btn.textContent = on ? '开机自动应用' : '开机自动应用 ✓';
|
||||
} });
|
||||
};
|
||||
root.querySelectorAll('[data-voice]').forEach(function(btn) {
|
||||
btn.onclick = function() {
|
||||
var kind = btn.dataset.voice, val = btn.dataset.enabled;
|
||||
var name = {ims:'IMS',volte:'VoLTE',vonr:'VoNR'}[kind];
|
||||
apply(kind, val, M.translate(val === 'on' ? '开启' : '关闭')+' '+name,
|
||||
{btn:btn,noSfun:true});
|
||||
};
|
||||
});
|
||||
this.Q('lock-refresh').onclick = function() {
|
||||
var btn = this;
|
||||
M.busy(btn, true);
|
||||
@@ -456,6 +477,19 @@ return view.extend({
|
||||
if (eb) { eb.className = 'mud-btn' + (l.endc === '1' ? ' on' : ''); eb.textContent = l.endc === '1' ? 'EN-DC' : 'EN-DC'; }
|
||||
var ab = this.Q('lock-auto-apply'), autoApply = l.auto_apply !== 0;
|
||||
if (ab) { ab.className = 'mud-btn' + (autoApply ? ' on' : ''); ab.textContent = M.translate(autoApply ? '开机自动应用 ✓' : '开机自动应用'); }
|
||||
['ims','volte','vonr'].forEach(function(kind) {
|
||||
var state = l[kind] || {}, known = typeof state.enabled === 'boolean';
|
||||
var text = M.translate(known ? (state.enabled ? '已开启' : '已关闭') : '状态暂不可读,请选择开启或关闭');
|
||||
if (state.source === 'acknowledged') text += ' · '+M.translate('本次已应用');
|
||||
setR('lock-'+kind+'-state', text);
|
||||
var box = self._root;
|
||||
if (box) box.querySelectorAll('[data-voice="'+kind+'"]').forEach(function(btn) {
|
||||
var selected = known && state.enabled === (btn.dataset.enabled === 'on');
|
||||
btn.className = 'mud-btn'+(selected ? ' on' : '');
|
||||
btn.setAttribute('aria-pressed', String(selected));
|
||||
btn.disabled = !!self._applying || selected;
|
||||
});
|
||||
});
|
||||
|
||||
/* Never expose speculative selectable bands before backend capabilities. */
|
||||
var caps = l.caps || {};
|
||||
|
||||
@@ -238,7 +238,7 @@ m_lock_set() {
|
||||
kind=$(inp '@.kind')
|
||||
val=$(inp '@.val')
|
||||
case "$kind" in
|
||||
mode|endc|lte|nr|cell|auto_apply|reset) ;;
|
||||
mode|endc|lte|nr|cell|auto_apply|reset|ims|volte|vonr) ;;
|
||||
*) printf '{"ok":0,"error":"unknown lock kind"}\n'; return ;;
|
||||
esac
|
||||
"$DASH/lock" start "$kind" "$val"
|
||||
|
||||
@@ -19,7 +19,7 @@ case $deadline in ''|*[!0-9]*) deadline=90 ;; esac
|
||||
[ "$(cat "$state/auto_apply" 2>/dev/null)" != off ] || exit 0
|
||||
have=0
|
||||
# An empty band/cell file explicitly means unlock, not missing state.
|
||||
for k in endc mode lte nr cell; do [ -f "$state/$k" ] && have=1; done
|
||||
for k in endc mode lte nr cell ims volte vonr; do [ -f "$state/$k" ] && have=1; done
|
||||
[ "$have" = 1 ] || exit 0
|
||||
[ -e "$marker" ] && exit 0
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# KIND / VALUE:
|
||||
# mode auto | 4g | sa | nsa network mode lock (SPTESTMODE + SP5GRAN)
|
||||
# endc on | off EN-DC / NSA anchor permission (SPENDC; note OFF is value 2)
|
||||
# ims | volte | vonr on | off per-SIM voice preferences; no SFUN cycle
|
||||
# lte "1,3,5" or "" LTE band lock (SPLBAND); empty = automatic
|
||||
# nr "78,41" or "" NR band lock (SPLBAND); empty = automatic
|
||||
# cell auto | off | "nr:627264,393" | "lte:1650,211" serving-cell lock (SPFORCEFRQ)
|
||||
@@ -23,10 +24,11 @@
|
||||
# +SPLBAND: <3 masks> read=3; NR tables A (n1..n74), B (n34..n79), super (n75..n86)
|
||||
# +SPFORCEFRQ: 12,3[,fr,pci] LTE read; 16,3 NR read; no pair = no lock
|
||||
#
|
||||
# Applying anything restarts the protocol stack (AT+SFUN=5, then AT+SFUN=4) - the
|
||||
# Applying mode/band/cell locks restarts the protocol stack (AT+SFUN=5, then AT+SFUN=4) - the
|
||||
# same sequence the official web UI and mobile-data's sim-reset use - so the new
|
||||
# setting takes effect. Cellular drops for half a minute; the data watchdog or the
|
||||
# configured netifd data interface brings the connection back.
|
||||
# EN-DC and IMS/VoLTE/VoNR changes do not perform this restart.
|
||||
#
|
||||
# The last applied state is saved in the configured state_dir. The package's
|
||||
# own procd service replays it when the selected AT adapter becomes ready; no
|
||||
@@ -233,8 +235,9 @@ do_get() {
|
||||
sort -n | awk 'NR>1{printf ","}{printf "%s", $1}')
|
||||
[ -n "$nrcap" ] || nrcap=1,5,6,8,28,41,78
|
||||
ltecap=1,3,5,8,34,38,39,40,41
|
||||
printf '{"ts":%d,"mode":{"label":"%s","work":"%s","gran":"%s","m1":"%s","prim":"%s"},"endc":"%s","lte":{"locked":"%s","raw":"%s"},"nr":{"locked":"%s","raw":"%s"},"cell":"%s","cells":%s,"write_caps":{"nr":"%s","lte":"1,3,5,8,34,38,39,40,41"},"caps":{"nr":"%s","lte":"%s"}}\n' \
|
||||
printf '{"ts":%d,"mode":{"label":"%s","work":"%s","gran":"%s","m1":"%s","prim":"%s"},"endc":"%s","lte":{"locked":"%s","raw":"%s"},"nr":{"locked":"%s","raw":"%s"},"cell":"%s","cells":%s,"write_caps":{"nr":"%s","lte":"1,3,5,8,34,38,39,40,41"},"caps":{"nr":"%s","lte":"%s"},"ims":%s,"volte":%s,"vonr":%s}\n' \
|
||||
"$(date +%s)" "$lbl" "${m0:-}" "${gran:-}" "$m1" "$prim" "${endc:-}" "${lte_b:-}" "${ltem:-}" "${nr_b:-}" "${nrm:-}" "${cell%%,*}" "${cells:-[]}" "$(canonical_bands "$(nr_bands "$(nr_masks "$nrcap")")")" "${nrcap:-}" "${ltecap:-}" \
|
||||
"$(voice_json ims 1)" "$(voice_json volte 1)" "$(voice_json vonr 1)" \
|
||||
| tee "$LOCKCACHE.part.$$" && mv "$LOCKCACHE.part.$$" "$LOCKCACHE"
|
||||
}
|
||||
|
||||
@@ -350,7 +353,7 @@ canonical_bands() {
|
||||
awk 'NR > 1 { printf "," } { printf "%s", $1 }'
|
||||
}
|
||||
verify_replay() {
|
||||
local d=$STATE_DIR val raw got want pair m0 gran nr3 cells rat p
|
||||
local d=$STATE_DIR val raw got want pair m0 gran nr3 cells rat p kind
|
||||
if [ -f "$d/mode" ]; then
|
||||
val=$(cat "$d/mode")
|
||||
pair=$(mode_pair "$val"); m0=${pair%% *}; gran=${pair#* }
|
||||
@@ -402,6 +405,10 @@ verify_replay() {
|
||||
want=$(grep -E '^(lte|nr):[0-9]+,[0-9]+$' "$d/cell" | sort -u)
|
||||
[ "$got" = "$want" ] || return 1
|
||||
fi
|
||||
for kind in volte vonr ims; do
|
||||
[ -f "$d/$kind" ] || continue
|
||||
voice_matches "$kind" "$(cat "$d/$kind")" || return 1
|
||||
done
|
||||
return 0
|
||||
}
|
||||
do_replay() {
|
||||
@@ -434,11 +441,11 @@ do_replay() {
|
||||
# what the dashboard last applied, then one stack restart at the end
|
||||
d=$STATE_DIR
|
||||
have=0
|
||||
for kind in endc mode lte nr cell; do [ -f "$d/$kind" ] && have=1; done
|
||||
for kind in endc mode lte nr cell ims volte vonr; do [ -f "$d/$kind" ] && have=1; done
|
||||
if [ "$have" = 0 ]; then : > "$marker"; return 0; fi
|
||||
# Validate the entire saved request before the first AT write. Reuse the
|
||||
# established MU300 codecs/capabilities, not another platform's rules.
|
||||
for kind in endc mode lte nr; do
|
||||
for kind in endc mode lte nr ims volte vonr; do
|
||||
[ -f "$d/$kind" ] || continue
|
||||
validate_apply "$kind" "$(cat "$d/$kind")" || { say "invalid saved $kind; replay aborted ($phase)"; return 1; }
|
||||
done
|
||||
@@ -472,6 +479,11 @@ do_replay() {
|
||||
done < "$d/cell"
|
||||
need_restart=1
|
||||
fi
|
||||
for kind in volte vonr ims; do
|
||||
[ -f "$d/$kind" ] || continue
|
||||
val=$(cat "$d/$kind")
|
||||
voice_set "$kind" "$val" 2 || { say "replay voice write failed: $kind ($phase)"; return 1; }
|
||||
done
|
||||
if ! verify_replay; then
|
||||
say "$phase replay readback failed; leaving completion marker absent"
|
||||
return 1
|
||||
|
||||
@@ -4,6 +4,7 @@ fail_apply() { printf '%s\n' "$1" >&2; return 1; }
|
||||
|
||||
validate_apply() {
|
||||
local kind=$1 val=$2 cap encoded pair fr pc
|
||||
case "$kind:$val" in ims:on|ims:off|volte:on|volte:off|vonr:on|vonr:off) return 0 ;; esac
|
||||
case "$kind:$val" in
|
||||
mode:auto|mode:4g|mode:sa|mode:nsa|endc:on|endc:off|auto_apply:on|auto_apply:off|reset:auto) return 0 ;;
|
||||
cell:auto|cell:off|cell:off-nr|cell:off-lte) return 0 ;;
|
||||
@@ -58,6 +59,105 @@ read_field() {
|
||||
at "$1" 4 | sed -n "s/^+$2: *//p" | head -n1 | tr -d ' \t'
|
||||
}
|
||||
|
||||
voice_receipt() {
|
||||
local bid bit source current
|
||||
current=$(cat /proc/sys/kernel/random/boot_id) || return 1
|
||||
[ -r "$RUNDIR/voice-$1" ] || return 1
|
||||
read -r bid bit source < "$RUNDIR/voice-$1" 2>/dev/null || return 1
|
||||
[ "$bid" = "$current" ] || return 1
|
||||
case "$bit:$source" in 0:modem|1:modem|0:acknowledged|1:acknowledged) printf '%s %s\n' "$bit" "$source" ;; *) return 1 ;; esac
|
||||
}
|
||||
|
||||
voice_record() {
|
||||
local dest=$RUNDIR/voice-$1 bid
|
||||
bid=$(cat /proc/sys/kernel/random/boot_id) || return 1
|
||||
printf '%s %s %s\n' "$bid" "$2" "$3" > "$dest.part.$$" && mv "$dest.part.$$" "$dest"
|
||||
}
|
||||
|
||||
voice_read() {
|
||||
local kind=$1 timeout=${2:-4} cmd prefix reply raw bid status=0
|
||||
case $kind in
|
||||
ims)
|
||||
bid=$(cat /proc/sys/kernel/random/boot_id) || return 1
|
||||
[ "$(cat "$RUNDIR/voice-ims-unsupported" 2>/dev/null)" != "$bid" ] || return 1
|
||||
cmd='AT+IMSEN?'; prefix=IMSEN ;;
|
||||
volte) cmd='AT+CAVIMS?'; prefix=CAVIMS ;;
|
||||
vonr) cmd='AT+SP5GCMDS="get nr synch_param",42'; prefix=SP5GCMDS ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
reply=$(lock_at "$cmd" "$timeout") || status=$?
|
||||
reply=$(printf '%s\n' "$reply" | tr -d '\r')
|
||||
if [ "$kind" = ims ] && printf '%s\n' "$reply" | grep -Eq '^(ERROR|\+CME ERROR: *4)$'; then
|
||||
printf '%s\n' "$bid" > "$RUNDIR/voice-ims-unsupported"
|
||||
fi
|
||||
[ "$status" = 0 ] && [ "$(printf '%s\n' "$reply" | sed '/^[[:space:]]*$/d' | tail -n1)" = OK ] || return 1
|
||||
raw=$(printf '%s\n' "$reply" | sed -n "s/^+$prefix: *//p" | head -n1 | tr -d ' \t"')
|
||||
if [ "$kind" = vonr ]; then
|
||||
raw=$(printf '%s\n' "$raw" | awk -F, '$1=="getnrsynch_param" && $2==42 && ($3=="0" || $3=="1") {print $3;exit}')
|
||||
fi
|
||||
case $raw in 0|1) printf '%s\n' "$raw" ;; *) return 1 ;; esac
|
||||
}
|
||||
|
||||
voice_set() {
|
||||
local kind=$1 val=$2 timeout=${3:-6} bit cmd reply status=0 got source
|
||||
case $val in on) bit=1 ;; off) bit=0 ;; *) return 1 ;; esac
|
||||
case $kind in
|
||||
ims) cmd="AT+IMSEN=$bit" ;;
|
||||
volte) cmd="AT+CAVIMS=$bit" ;;
|
||||
vonr) cmd="AT+SP5GCMDS=\"set nr param\",45,$bit" ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
reply=$(lock_at "$cmd" "$timeout") || status=$?
|
||||
reply=$(printf '%s\n' "$reply" | tr -d '\r')
|
||||
if printf '%s\n' "$reply" | grep -Eq '^(ERROR|\+CME ERROR|\+CMS ERROR)(:|$)'; then
|
||||
fail_apply '模组拒绝了设置'; return 1
|
||||
fi
|
||||
if [ "$kind" = ims ]; then
|
||||
# Stock RIL's IMS master switch. Do not substitute CAVIMS or treat
|
||||
# missing OK as success on a CP without an IMSEN read command.
|
||||
[ "$status" = 0 ] && [ "$(printf '%s\n' "$reply" | sed '/^[[:space:]]*$/d' | tail -n1)" = OK ] ||
|
||||
{ fail_apply 'IMS 设置没有获得明确确认,未保存'; return 1; }
|
||||
source=acknowledged
|
||||
else
|
||||
got=$(voice_read "$kind" "$timeout") && [ "$got" = "$bit" ] ||
|
||||
{ fail_apply '模组回读与请求设置不一致,未保存'; return 1; }
|
||||
source=modem
|
||||
fi
|
||||
voice_record "$kind" "$bit" "$source"
|
||||
}
|
||||
|
||||
voice_matches() {
|
||||
local kind=$1 val=$2 got
|
||||
case $val in on) val=1 ;; off) val=0 ;; *) return 1 ;; esac
|
||||
if [ "$kind" = ims ]; then
|
||||
got=$(voice_receipt ims) || return 1
|
||||
got=${got%% *}
|
||||
else
|
||||
got=$(voice_read "$kind" 2) || return 1
|
||||
fi
|
||||
[ "$got" = "$val" ]
|
||||
}
|
||||
|
||||
voice_json() {
|
||||
local kind=$1 refresh=${2:-0} got source=unknown enabled=null saved native=0
|
||||
# A getter must not overwrite a write receipt mid-operation. The apply
|
||||
# worker's existing refresh reads the receipt it just verified instead.
|
||||
if [ "$refresh" = 1 ] && [ ! -d "$APPLY_DIR" ]; then
|
||||
if got=$(voice_read "$kind"); then
|
||||
source=modem; native=1
|
||||
[ "$got" = 1 ] && enabled=true || enabled=false
|
||||
fi
|
||||
fi
|
||||
# Observations never overwrite a write receipt; only an accepted setter
|
||||
# can publish one. This also protects early replay from concurrent getters.
|
||||
if [ "$native" = 0 ] && got=$(voice_receipt "$kind"); then
|
||||
source=${got#* }; got=${got%% *}
|
||||
[ "$got" = 1 ] && enabled=true || enabled=false
|
||||
fi
|
||||
saved=$(cat "$STATE_DIR/$kind" 2>/dev/null)
|
||||
printf '{"enabled":%s,"source":"%s","saved":%s}' "$enabled" "$source" "$(qs "$saved")"
|
||||
}
|
||||
|
||||
read_cells() {
|
||||
local rat=$1 p raw
|
||||
[ "$rat" = nr ] && p=16 || p=12
|
||||
@@ -185,6 +285,14 @@ do_apply() {
|
||||
do_reset_apply
|
||||
return $?
|
||||
fi
|
||||
case $kind in
|
||||
ims|volte|vonr)
|
||||
voice_set "$kind" "$val" || return 1
|
||||
save_state "$kind" "$val" || { fail_apply '设置保存失败'; return 1; }
|
||||
say "applied $kind=$val for SIM ${MU300_SIM_SLOT:-0}"
|
||||
"$0" get fresh >/dev/null 2>&1
|
||||
return 0 ;;
|
||||
esac
|
||||
case "$kind" in
|
||||
mode)
|
||||
set -- $(mode_pair "$val"); m0=$1; gran=$2
|
||||
|
||||
@@ -49,6 +49,10 @@ async function main() {
|
||||
Date.now = oldDate;
|
||||
// All newly emitted backend error messages are translated in both locales.
|
||||
let messages = ['已应用并核对模组状态','等待模组能力数据','正在确认设置结果…'];
|
||||
messages.push('状态暂不可读,请选择开启或关闭','本次已应用',
|
||||
'关闭后只停止下次开机回放,已保存的网络、IMS、VoLTE 和 VoNR 设置不会被删除。',
|
||||
'IMS 为总开关,VoLTE 用于 4G 通话,VoNR 用于 5G SA 通话。设置按当前查看的 SIM 保存,并跟随“开机自动应用”。',
|
||||
'关闭 IMS 不等于屏蔽全部来电和短信,传统网络业务仍可能到达。');
|
||||
for (const file of ['lock-apply.sh','lock-jobs.sh']) {
|
||||
const src=fs.readFileSync(path.join(root,'root/usr/libexec/unisoc-modem',file),'utf8');
|
||||
messages.push(...[...src.matchAll(/'([^'\n]*[\u3400-\u9fff][^'\n]*)'/g)]
|
||||
@@ -65,7 +69,10 @@ async function main() {
|
||||
// modem in a browser test, but do check confirmation, SIM scope and busy.
|
||||
let selected=1, confirm, modal, requests=[], finishJob, failJob, notes=[];
|
||||
const elements=new Map();
|
||||
const pageRoot={isConnected:true, querySelectorAll:()=>[], querySelector:selector=>{
|
||||
const voices=['ims','volte','vonr'].flatMap(kind=>['on','off'].map(val=>({
|
||||
dataset:{voice:kind,enabled:val},setAttribute(k,v){this[k]=v;}
|
||||
})));
|
||||
const pageRoot={isConnected:true, querySelectorAll:selector=>selector==='[data-voice]' ? voices : [], querySelector:selector=>{
|
||||
if(!elements.has(selector)) elements.set(selector, {
|
||||
classList:{toggle:()=>{}}, addEventListener:()=>{}, querySelectorAll:()=>[], children:[]
|
||||
});
|
||||
@@ -82,6 +89,17 @@ async function main() {
|
||||
page.refresh=()=>Promise.resolve();
|
||||
page.note=(text,type)=>notes.push({text,type});
|
||||
page.wire(pageRoot);
|
||||
for(const kind of ['ims','volte','vonr']) {
|
||||
const btn=voices.find(b=>b.dataset.voice===kind&&b.dataset.enabled==='off');
|
||||
btn.onclick();assert.equal(modal.options.danger,false);
|
||||
confirm(false);await flush();assert.equal(requests.length,0);
|
||||
btn.onclick();confirm(true);await flush();
|
||||
assert.deepEqual(requests,[{kind,val:'off',slot:1}]);
|
||||
assert.equal(btn.busy,true);
|
||||
finishJob({...start,kind});await flush();
|
||||
assert.equal(btn.busy,false);assert.equal(page._applying,false);
|
||||
requests.length=0;notes.length=0;
|
||||
}
|
||||
const reset=elements.get('#mud-lock-reset');
|
||||
lang='en'; reset.onclick();
|
||||
assert.equal(modal.title,'Clear all locks for SIM 2?');
|
||||
|
||||
+106
-1
@@ -38,21 +38,26 @@ p=Path(os.environ['STUBLOG']); f=p/'modem.json'; s=json.loads(f.read_text())
|
||||
cmd=sys.argv[-1]
|
||||
with (p/'commands').open('a') as log: log.write(cmd+'\\n')
|
||||
reads={'AT+SPTESTMODE?':('SPTESTMODE','tm'), 'AT+SP5GRAN?':('SP5GRAN','gran'),
|
||||
'AT+IMSEN?':('IMSEN','ims'), 'AT+CAVIMS?':('CAVIMS','volte'),
|
||||
'AT+SPENDC?':('ENDC','endc'), 'AT+SPLBAND=0':('SPLBAND','lte'),
|
||||
'AT+SPLBAND=3':('SPLBAND','nr'), 'AT+CFUN?':('CFUN','cfun')}
|
||||
if cmd in reads:
|
||||
if cmd=='AT+IMSEN?' and s.get('no_ims_query'): print('ERROR'); sys.exit(1)
|
||||
if s.get('silent'): sys.exit(1)
|
||||
label,key=reads[cmd]; value=s.get('read_override',{}).get(key,s[key])
|
||||
if key=='endc' and value=='2': value=s.get('endc_off_reply','0')
|
||||
print('+'+label+': '+value); print('OK'); sys.exit(0)
|
||||
if cmd=='AT+SP5GCMDS="get nr support_band"':
|
||||
print('+SP5GCMDS: get nr support_band,6,41,78,1,8,28,5'); print('OK'); sys.exit(0)
|
||||
if cmd=='AT+SP5GCMDS="get nr synch_param",42':
|
||||
print('+SP5GCMDS: "get nr synch_param",42,'+s['vonr']); print('OK'); sys.exit(0)
|
||||
if cmd in ('AT+SPFORCEFRQ=12,3','AT+SPFORCEFRQ=16,3'):
|
||||
tag=cmd.split('=')[1].split(',')[0]; cells=s.get('cell_read_override',{}).get(tag,s['cells'+tag])
|
||||
print('+SPFORCEFRQ: '+tag+',3'+(''.join(','+x for x in cells))); print('OK'); sys.exit(0)
|
||||
if s.get('reject'): print('+CME ERROR: 3'); sys.exit(0)
|
||||
if s.get('reject_restart') and cmd.startswith('AT+SFUN='): print('ERROR'); sys.exit(0)
|
||||
for prefix,key in [('AT+SPTESTMODE=','tm'),('AT+SP5GRAN=','gran'),('AT+SPENDC=','endc'),
|
||||
('AT+IMSEN=','ims'),('AT+CAVIMS=','volte'),('AT+SP5GCMDS="set nr param",45,','vonr'),
|
||||
('AT+SPLBAND=1,','lte'),('AT+SPLBAND=2,','nr')]:
|
||||
if cmd.startswith(prefix) and not s.get('ignore'): s[key]=cmd[len(prefix):]
|
||||
if cmd.startswith('AT+SPTESTMODE=') and s.get('corrupt_mode_fields'): s['tm']=s['tm'].split(',')[0]+',134,0'
|
||||
@@ -73,7 +78,8 @@ print('OK')
|
||||
|
||||
def reset(self, **extra):
|
||||
state = dict(tm='134,128,1,0,0,0', gran='1', endc='1',
|
||||
lte='0,0,0,0,0', nr='0,0,0,0', cfun='1', cells12=['1650,10'], cells16=[])
|
||||
lte='0,0,0,0,0', nr='0,0,0,0', cfun='1', cells12=['1650,10'], cells16=[],
|
||||
ims='1',volte='1',vonr='0')
|
||||
state.update(extra)
|
||||
self.modem.write_text(json.dumps(state))
|
||||
(self.tmp / 'commands').write_text('')
|
||||
@@ -90,6 +96,105 @@ print('OK')
|
||||
(directory / key).write_text(value)
|
||||
return saved
|
||||
|
||||
def test_voice_switches_keep_separate_state_and_do_not_cycle_radio(self):
|
||||
for shell in self.each_shell():
|
||||
self.reset()
|
||||
for kind, value in [('ims','off'), ('volte','off'), ('vonr','on')]:
|
||||
result=self.apply(shell,kind,value)
|
||||
self.assertEqual(result.returncode,0,result.stderr)
|
||||
self.assertEqual((self.state/kind).read_text(),value)
|
||||
current=json.loads((self.run/'lock.json').read_text())
|
||||
self.assertEqual(current['ims']['source'],'acknowledged')
|
||||
self.assertIs(current['ims']['enabled'],False)
|
||||
self.assertIs(current['volte']['enabled'],False)
|
||||
self.assertIs(current['vonr']['enabled'],True)
|
||||
trace=(self.tmp/'commands').read_text()
|
||||
self.assertNotIn('SFUN',trace)
|
||||
self.assertNotIn('ifup',trace)
|
||||
self.assertNotIn('AT+CASIMS=',trace)
|
||||
|
||||
def test_voice_failures_never_save_and_ims_requires_ok(self):
|
||||
for shell in self.each_shell():
|
||||
for kind, value, fault in [('ims','off','reject'),('ims','off','omit_ok'),
|
||||
('volte','off','ignore'),('vonr','on','ignore')]:
|
||||
self.reset(**{fault:True})
|
||||
(self.state/kind).unlink(missing_ok=True)
|
||||
result=self.apply(shell,kind,value)
|
||||
self.assertNotEqual(result.returncode,0,(kind,fault))
|
||||
self.assertFalse((self.state/kind).exists())
|
||||
self.assertNotIn('SFUN',(self.tmp/'commands').read_text())
|
||||
|
||||
def test_voice_only_replay_is_early_once_and_never_restarts(self):
|
||||
for shell in self.each_shell():
|
||||
self.reset()
|
||||
for kind,value in [('ims','off'),('volte','off'),('vonr','on')]:
|
||||
(self.state/kind).write_text(value)
|
||||
result=self.replay(shell,'early')
|
||||
self.assertEqual(result.returncode,0,result.stderr)
|
||||
self.assertTrue((self.tmp/'marker').exists())
|
||||
trace=(self.tmp/'commands').read_text()
|
||||
self.assertLess(trace.index('AT+CAVIMS=0'),trace.index('AT+IMSEN=0'))
|
||||
self.assertNotIn('SFUN',trace)
|
||||
self.assertNotIn('AT+IMSEN?',trace)
|
||||
self.assertEqual(self.script(shell,self.lock,'replay','late',**self.extra).returncode,0)
|
||||
self.assertEqual((self.tmp/'commands').read_text(),trace)
|
||||
|
||||
def test_unsupported_ims_read_does_not_hide_other_locks_or_write_receipt(self):
|
||||
for shell in self.each_shell():
|
||||
self.reset(no_ims_query=True)
|
||||
result=self.apply(shell,'ims','off')
|
||||
self.assertEqual(result.returncode,0,result.stderr)
|
||||
result=self.script(shell,self.lock,'get','fresh',**self.extra)
|
||||
current=json.loads(result.stdout)
|
||||
self.assertIn('mode',current)
|
||||
self.assertIs(current['ims']['enabled'],False)
|
||||
self.assertEqual(current['ims']['source'],'acknowledged')
|
||||
before=(self.tmp/'commands').read_text().count('AT+IMSEN?')
|
||||
self.script(shell,self.lock,'get','fresh',**self.extra)
|
||||
self.assertEqual((self.tmp/'commands').read_text().count('AT+IMSEN?'),before)
|
||||
|
||||
def test_secondary_voice_settings_do_not_write_primary_preferences(self):
|
||||
for shell in self.each_shell():
|
||||
self.reset()
|
||||
second=self.state/'sim1';second.mkdir(exist_ok=True)
|
||||
scoped=self.run/'sim1';scoped.mkdir(exist_ok=True)
|
||||
(self.state/'ims').write_text('on')
|
||||
result=self.script(shell,self.lock,'apply','ims','off',**dict(self.extra,
|
||||
MU300_SIM_SLOT='1',MU300_STATE_DIR=second,MU300_DASH_DIR=scoped))
|
||||
self.assertEqual(result.returncode,0,result.stderr)
|
||||
self.assertEqual((second/'ims').read_text(),'off')
|
||||
self.assertEqual((self.state/'ims').read_text(),'on')
|
||||
self.assertTrue((scoped/'voice-ims').exists())
|
||||
self.assertFalse((self.run/'voice-ims').exists())
|
||||
|
||||
def test_reset_keeps_voice_preferences(self):
|
||||
for shell in self.each_shell():
|
||||
self.reset(ims='0',volte='0',vonr='1')
|
||||
for kind,val in [('ims','off'),('volte','off'),('vonr','on')]:
|
||||
(self.state/kind).write_text(val)
|
||||
result=self.apply(shell,'reset','auto')
|
||||
self.assertEqual(result.returncode,0,result.stderr)
|
||||
for kind,val in [('ims','off'),('volte','off'),('vonr','on')]:
|
||||
self.assertEqual((self.state/kind).read_text(),val)
|
||||
trace=(self.tmp/'commands').read_text()
|
||||
self.assertNotIn('AT+IMSEN=',trace)
|
||||
self.assertNotIn('AT+CAVIMS=',trace)
|
||||
|
||||
def test_voice_only_boot_worker_detects_all_three_settings(self):
|
||||
for shell in self.each_shell():
|
||||
for kind in ('ims','volte','vonr'):
|
||||
with self.subTest(kind=kind):
|
||||
self.reset()
|
||||
path=self.state/kind;path.write_text('off')
|
||||
(self.tmp/'marker').unlink(missing_ok=True)
|
||||
env=dict(self.extra,UNISOC_AT_BIN=self.tmp/'fake-at',
|
||||
UNISOC_LOCK_BIN=self.lock,UNISOC_EARLY_PENDING=self.tmp/'pending')
|
||||
result=self.script(shell,LIB/'boot-replay',**env)
|
||||
self.assertEqual(result.returncode,0,result.stderr)
|
||||
self.assertTrue((self.tmp/'marker').exists())
|
||||
self.assertNotIn('SFUN',(self.tmp/'commands').read_text())
|
||||
path.unlink()
|
||||
|
||||
def test_reset_clears_all_types_once_preserving_other_sim_and_identity(self):
|
||||
for shell in self.each_shell():
|
||||
for omit_ok in (False, True):
|
||||
|
||||
Reference in new issue
Block a user